diff --git a/CODEOWNERS b/CODEOWNERS index ca2ba48baa68fb4990cc3e34fcf9ee5537ef1c28..a98eba13b7b574232201efd76d84579561a42ccd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -23,11 +23,17 @@ zh-cn/device-dev/quick-start/ @li-yan339 zh-cn/device-dev/driver/ @li-yan339 zh-cn/device-dev/get-code/ @li-yan339 zh-cn/device-dev/hpm-part/ @duangavin123_admin -zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 -zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 -zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 -zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 -zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 +zh-cn/device-dev/reference/hdi-apis/ @li-yan339 +zh-cn/device-dev/quick-start/quickstart-standard-env-setup.md @li-yan339 @chenmudan +zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @li-yan339 @chenmudan +zh-cn/device-dev/porting/porting-thirdparty-overview.md @Austin23 @chenmudan +zh-cn/device-dev/porting/porting-thirdparty-makefile.md @Austin23 @chenmudan +zh-cn/device-dev/porting/porting-thirdparty-cmake.md @Austin23 @chenmudan +zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @Austin23 @chenmudan +zh-cn/device-dev/subsystems/subsys-build-standard-large.md @Austin23 @chenmudan +zh-cn/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @Austin23 @chenmudan +zh-cn/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guid.md @Austin23 @chenmudan +zh-cn/device-dev/subsystems/subsys-build-gn-hap-compilation-guide.md @Austin23 @chenmudan zh-cn/device-dev/subsystems/subsys-remote-start.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-graphics-overview.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-graphics-container-guide.md @duangavin123_admin @@ -45,7 +51,7 @@ zh-cn/device-dev/subsystems/subsys-utils-overview.md @Austin23 zh-cn/device-dev/subsystems/subsys-utils-guide.md @Austin23 zh-cn/device-dev/subsystems/subsys-utils-faqs.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-guide.md @Austin23 -zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md @Austin23 +zh-cn/device-dev/subsystems/subsys-aiframework-envbuild.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-name.md @Austin23 zh-cn/device-dev/subsystems/subsys-aiframework-tech-interface.md @Austin23 @@ -79,14 +85,19 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin -zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23 -zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 -zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 -zh-cn/device-dev/subsystems/subsys-boot-syspara.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-cfg.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-sandbox.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-service.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23 +zh-cn/device-dev/subsystems/subsys-boot.md @Austin23 zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23 zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin @@ -200,7 +211,7 @@ zh-cn/application-dev/reference/apis/js-apis-screenshot.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-window.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-screen.md @ge-yafang -zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-webgl.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-webgl2.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-audio.md @zengyawen diff --git a/README_zh.md b/README_zh.md index 3c65434aac3acaee899db2e1eba85e61c03de5a5..ebf1bc8d7557d35f99eaacf8fd1427972d61d3b0 100644 --- a/README_zh.md +++ b/README_zh.md @@ -18,7 +18,7 @@ - master:最新开å‘版本。 - - OpenHarmony 3.2 Beta1版本:点击[æ¤å¤„](zh-cn/release-notes/OpenHarmony-v3.2-beta1.md)了解版本详情。 + - OpenHarmony 3.2 Beta2版本:点击[æ¤å¤„](zh-cn/release-notes/OpenHarmony-v3.2-beta2.md)了解版本详情。 - OpenHarmony 3.1 Release版本:点击[æ¤å¤„](zh-cn/release-notes/OpenHarmony-v3.1-release.md)了解版本详情。 diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md index c9eff6c8fe752a73cc4b8a2837ffe2a8ee7c0f0f..1331ac52206cf1980ce59a7def62bfd32c27e406 100644 --- a/en/OpenHarmony-Overview.md +++ b/en/OpenHarmony-Overview.md @@ -1,202 +1,205 @@ # OpenHarmony Project -## Introduction<a name="section1270210396435"></a> +## Introduction -OpenHarmony is an open-source project incubated and operated by the OpenAtom Foundation. It is an open-source operating system with a framework and platform applicable to smart devices in all scenarios of a fully-connected world. It aims to promote the development of the Internet of Everything (IoE). +OpenHarmony is an open-source project incubated and operated by the OpenAtom Foundation. The purpose of this project is to build an open-source, distributed operating system (OS) framework for smart devices in all scenarios of a fully-connected world. -## Technical Architecture<a name="section2502124574318"></a> +## Technical Architecture -OpenHarmony is designed with a layered architecture, which from bottom to top, consists of the kernel layer, system service layer, framework layer, and application layer. System functions are expanded by levels, from system to subsystem, and further to module. In a multi-device deployment scenario, unnecessary modules can be excluded from the system as required. The following figure shows the technical architecture of OpenHarmony. +OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from the bottom up. System functions are expanded by levels, from system to subsystem, and further to component. In a multi-device deployment scenario, unnecessary components can be excluded from the system as required. The following figure shows the technical architecture of OpenHarmony.  **Kernel layer** -- Kernel subsystem: OpenHarmony uses a multi-kernel design \(Linux or LiteOS\) so that different kernels can be selected for devices with different resource limitations. The kernel abstraction layer \(KAL\) hides differences in kernel implementations and provides the upper layer with basic kernel capabilities, including process and thread management, memory management, file system, network management, and peripheral management. +- Kernel subsystem: OpenHarmony uses a multi-kernel design (Linux or LiteOS) so that different kernels can be selected for devices with different resource limitations. The kernel abstraction layer (KAL) hides differences in kernel implementations and provides the upper layer with basic kernel capabilities, including process and thread management, memory management, file system, network management, and peripheral management. -- Driver subsystem: Hardware Driver Foundation \(HDF\) lays the foundation for an open OpenHarmony hardware ecosystem. It allows for unified access from peripheral devices and provides foundation for driver development and management. +- Driver subsystem: Hardware Driver Foundation (HDF) lays the foundation for an open OpenHarmony hardware ecosystem. It allows for unified access from peripheral devices and provides foundation for driver development and management. **System service layer** -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: +The system service layer provides a complete set of capabilities essential for OpenHarmony to offer services for applications 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: Distributed Soft Bus (DSoftBus), distributed data management, Distributed Scheduler, Utils, multimodal input, graphics, security, and AI. +- Basic system capability subsystem set: Implements distributed application 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\). +- Basic software service subsystem set: Provides OpenHarmony with common universal software services, including common event and notification, telephony, multimedia, and Design For X (DFX). -- Enhanced software service subsystem set: Provides OpenHarmony with differentiated enhanced software services, including those dedicated to smart TVs, wearables, IoT devices, and more. +- Enhanced software service subsystem set: Provides OpenHarmony with differentiated enhanced software services, including those dedicated to smart TVs, wearables, IoT devices, and more. -- Hardware service subsystem set: Provides OpenHarmony with hardware services, including location, IAM, as well as those dedicated to wearables and IoT devices. +- Hardware service subsystem set: Provides OpenHarmony with hardware services, including location, user IAM, as well as those dedicated to wearables and IoT devices. -The basic software service, enhanced software service, and hardware service subsystem sets can be modified by the subsystems, and each subsystem can be modified by various functions, depending on the deployment scenario for a particular device form. +The basic software service, enhanced software service, and hardware service subsystem sets can be tailored by subsystems, and each subsystem can be tailored by functions, depending on the deployment scenario for a particular device form. **Framework layer** -This layer provides with what you need to develop OpenHarmony apps: application framework and ability framework, specific to multiple languages \(like C, C++, and JS\), ArkUI framework, as well as multi-language APIs for hardware and software services. The APIs designed for different OpenHarmony devices can be modified based on various system components. +This layer provides with what you need to develop OpenHarmony applications: application framework and ability framework specific to multiple languages (like C, C++, and JS), JS-specific ArkUI framework, as well as multi-language APIs for hardware and software services. The APIs designed for different OpenHarmony devices vary according to the components in use. **Application layer** -This layer consists of system apps and third-party apps. Each OpenHarmony app is powered by one or more Feature Abilities \(FAs\) or Particle Abilities \(PAs\). An FA provides a UI for user interaction. A PA has no UI and provides background task processing as well as data access. Apps developed based on FAs and PAs provide specific service characteristics and enable cross-device scheduling and distribution, delighting users with consistent and efficient experience. +This layer consists of system applications and third-party applications. Each OpenHarmony application is powered by one or more Feature Abilities (FAs) or Particle Abilities (PAs). An FA provides a UI for user interaction. A PA has no UI and provides background task processing as well as data access. Applications developed based on FAs and PAs provide specific service characteristics and enable cross-device scheduling and distribution, delighting users with consistent and efficient experience. -## Technical Features<a name="section12212842173518"></a> +## Technical Features **Hardware collaboration and resource sharing** This feature is implemented through the following modules: -- DSoftBus +- DSoftBus - 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. + 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 - - 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. -- 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 data management + + Distributed data management leverages DSoftBus to manage application data and user data distributed on 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 applications 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. -- 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. + +- Distributed Scheduler + + 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 applications across devices. This way, your application 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 + + 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 Device. **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 application, ability, and UI frameworks. With these frameworks, you can develop your applications once, and then flexibly deploy them across a broad range of different devices. One-time development for multi-device deployment -Consistent APIs ensure the operational compatibility of apps across devices. +Consistent APIs ensure the operational compatibility of applications 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 applications and the software platform. **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. -## OS Types<a name="section145241459142416"></a> +## System Types -OpenHarmony supports the following types: +OpenHarmony supports the following system types: -- Mini system +- Mini system - A mini system runs on the devices whose memory is greater than or equal to 128 KiB and that are equipped with MCU processors such as Arm Cortex-M and 32-bit RISC-V. This system provides multiple lightweight network protocols and graphics frameworks, and a wide range of read/write components for the IoT bus. Typical products include connection modules, sensors, and wearables for smart home. + A mini system fits into devices that come with Micro Controller Units (MCUs), such as Arm Cortex-M and 32-bit RISC-V processors, and memory greater than or equal to 128 KiB. This system provides multiple lightweight network protocols, a lightweight graphics framework, and a wide range of read/write components with the IoT bus. Typical products include connection modules, sensors, and wearables for smart home. -- Small system +- Small system - A small system runs on the devices whose memory is greater than or equal to 1 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, routers, and event data recorders \(EDRs\) for smart travel. + A small system runs on devices whose memory is greater than or equal to 1 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, and routers, and event data recorders (EDRs) for easy travel. -- Standard system +- Standard system - A standard system runs on the devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays. + A standard system runs on devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as Arm Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays. -## Subsystems<a name="section25831825174419"></a> +## Subsystems You need to understand the following basic concepts related to OpenHarmony: -- Subsystem +- Subsystem - OpenHarmony is designed with a layered architecture, which from bottom to top consists of the kernel layer, system service layer, framework layer, and application layer. System functions are expanded by levels, from system to subsystem, and further to module. In a multi-device deployment scenario, unnecessary modules can be excluded from the system as required. A subsystem is a logical concept and is a flexible combination of functions. + OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from the bottom up. System functions are expanded by levels, from system to subsystem, and further to component. In a multi-device deployment scenario, unnecessary components can be excluded from the system as required. A subsystem, as a logical concept, consists of the least required components. -- Module +- Components - A module is a reusable software binary unit that contains source code, configuration files, resource files, and build scripts. A module can be built independently, integrated in binary mode, and then tested independently. + A component is a reusable software binary unit that contains source code, configuration files, resource files, and build scripts. A component can be built independently, integrated in binary mode, and then tested independently. -The following table describes the subsystems of OpenHarmony. For details about the readme files of these subsystems, see [https://gitee.com/openharmony/docs/tree/master/en/readme](https://gitee.com/openharmony/docs/tree/master/en/readme). +The following table describes the subsystems of OpenHarmony. For details about the readme files of these subsystems, see [https://gitee.com/openharmony/docs/tree/master/en/readme](https://gitee.com/openharmony/docs/tree/master/en/readme). -| Subsystem| Description| Applicable To| + +| Subsystem | Description | Application Scope | | -------- | -------- | -------- | -| 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 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 | -| Startup | Starts the OS middle layer between the time the kernel is started and the time apps are started. In addition, you can query and modify system attributes and restore factory settings. | All systems | -| Update | Supports over the air (OTA) update of OpenHarmony devices. | Standard system | -| 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 | -| 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 | -| 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, 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 | -| DSoftBus | Provides cross-process or cross-device communication capabilities for the OpenHarmony system and consists of the DSoftBus and IPC modules. The DSoftBus module enables distributed communication between near-field devices and provides device discovery, connection, networking, and data transmission functions, regardless of the communication mode. The IPC module enables communication between processes on a device or across devices. | All systems | -| XTS | Provides a set of OpenHarmony compatibility test suites, including the currently supported application compatibility test suite (ACTS) and the device compatibility test suite (DCTS) that will be supported in the future. | All systems | -| System Apps | Provides system apps that are applicable to the OpenHarmony standard system, such as Launcher, SystemUI, and Settings. It also provides specific examples for you to build standard-system apps, which can be installed on all devices running the standard system. | Standard system | -| DFX | Provides non-functional capabilities of OpenHarmony. It provides a logging system, app and system event logging APIs, the event log subscription service, and fault information generation and collection capabilities. | All systems | -| Globalization | If OpenHarmony devices and apps need to be used globally, they must meet the requirements of users in different regions on languages and cultures. The Globalization subsystem provides multi-language and multi-cultural capabilities for global use, including resource management and internationalization (i18n). | All systems | -| Security | Provides system, data, and app security capabilities to protect system and user data of OpenHarmony. Its functions include app integrity verification, app permission management, device authentication, and key management. | All systems | - -## Supported Development Boards<a name="section25831825174123"></a> - -Currently, OpenHarmony supports the development boards listed in the following table. - -| System Type| Board Model| Chip Model| Function Description| Application Scenario| Code Repository and Daily Build| +| 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 modules. It is an application framework that can be built on the LiteOS to develop OpenHarmony applications for 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 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 application 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 | +| Startup | Starts the OS middle layer between the time the kernel is started and the time applications are started. In addition, you can query and modify system attributes and restore factory settings.| All systems | +| Update | Supports over the air (OTA) update of OpenHarmony devices. | Standard system | +| Account | Provides interconnection with vendors' cloud account applications on the device side, and query and update of the cloud account login status.| Standard system | +| Build | 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 application data management for lightweight preference databases and relational databases<br>- Distributed data service to provide applications 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 JS UI framework 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 applications to use multimedia resources of the system.| All systems | +| Common Event and Notification | Provides the common event management capabilities that allow applications 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, 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 components of OpenHarmony, which can be used by OpenHarmony subsystems and upper-layer applications.| 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 | +| DSoftBus | Provides cross-process or cross-device communication capabilities for the OpenHarmony system and consists of the DSoftBus and IPC modules. The DSoftBus module enables distributed communication between near-field devices and provides device discovery, connection, networking, and data transmission functions, regardless of the communication mode. The IPC module enables communication between processes on a device or across devices.| All systems | +| XTS | Provides a set of OpenHarmony compatibility test suites, including the currently supported application compatibility test suite (ACTS) and the device compatibility test suite (DCTS) that will be supported in the future.| All systems | +| System Apps | Provides system apps that are applicable to the OpenHarmony standard system, such as Home Screen, SystemUI, and Settings. It also provides specific examples for you to build standard-system applications, which can be installed on all devices running the standard system.| Standard system | +| DFX | Provides non-functional capabilities of OpenHarmony. It provides a logging system, application and system event logging APIs, the event log subscription service, and fault information generation and collection capabilities.| All systems | +| Globalization | If OpenHarmony devices and applications need to be used globally, they must meet the requirements of users in different regions on languages and cultures. The Globalization subsystem provides multi-language and multi-cultural capabilities for global use, including resource management and internationalization (i18n).| All systems | +| Security | Provides system, data, and application security capabilities to protect system and user data of OpenHarmony. Its functions include application integrity verification, application permission management, device authentication, and key management.| All systems | + +## Supported Development Boards + +Currently, the OpenHarmony community supports 17 types of development boards, which are listed in [Development Boards Supported](device-dev/dev-board-on-the-master.md). The following table describes three of them, which are the first three integrated into the OpenHarmony master. You can visit http://ci.openharmony.cn/dailys/dailybuilds to obtain daily builds. + +| System Type| Board Model| Chip Model| <div style="width:200pt">Function Description and Use Case</div> | Application Scenario| Code Repository | | -------- | -------- | -------- | -------- | -------- | -------- | -| Standard system| Hi3516DV300 | Hi3516DV300 | Hi3516D V300 is a the next-generation system on chip (SoC) for smart HD IP cameras. It integrates the next-generation image signal processor (ISP), H.265 video compression encoder, and high-performance NNIE engine, and delivers exceptional performance in terms of low bit rate, high image quality, intelligent processing and analysis, and low power consumption.| Devices with screens, such as refrigerators and head units.| Code repositories:<br>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) <br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | -| Standard system| Runhe HH-SCDAYU200| RK3568 | Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates a dual-core GPU and high-efficiency NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, WiFi, audio, video, and camera features, with a wide range of expansion ports as well as video input and output ports. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.| Video and audio entertainment, smart travel, and smart home, such as kitchen hoods, ovens, and treadmills.| Code repositories:<br>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) <br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | -| Lightweight| Goodix GR5515-STARTER-KIT| GR5515 | The GR5515-STARTER-KIT development board is a Bluetooth 5.1-capable single-mode Bluetooth low energy (BLE) SoC and comes with multifunctional keys and LED indicators.| Smart hardware, such as watches, wristbands, and price tags.| Code repositories:<br>[device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)<br>[device_board_goodix](https://gitee.com/openharmony/device_board_goodix)<br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | -| Lightweight| Langguo LANGO200| ASR582X | The LANGO200 IoT development board integrates the high-performance WiFi-BLE dual-mode chip ASR5822, external storage chip, voice playing chip, and analog-to-digital converter. It supports common peripheral interfaces like SPI, and can be connected to an external OLED display and infrared remote control.| Connection modules for smart home products.| Code repositories:<br>[device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)<br>[device_board_lango](https://gitee.com/openharmony/device_board_lango)<br>[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro) <br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | -| Lightweight| Fn-Link multi-modal V200ZR| BES2600 | The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core Arm processor with a frequency of up to 1 GHz as well as dual-mode WiFi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.| Smart hardware with screens, such as speakers and watches.| Code repositories:<br>[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) <br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | -| Lightweight| BearPi-HM_Nano| Hi3861 | The BearPi-HM_Nano development board is specially designed for OpenHarmony. It is equipped with the highly integrated 2.4 GHz WiFi SoC chip Hi3861, near field communication (NFC) circuits, and standard E53 interfaces, which can be used to connect to smart humidifiers, smart desk lamps, smart security facilities, and intelligent smoke detectors.| Connection devices like smart street lamps, smart logistics sensors, and human body infrared sensors.| Code repositories:<br>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)<br> Daily build:<br>http://ci.openharmony.cn/dailys/dailybuilds | +| Standard system| Runhe HH-SCDAYU200| RK3568 | <div style="width:200pt">Function description:<br>Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates the dual-core GPU and efficient NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, Wi-Fi, audio, video, and camera features, with a wide range of expansion ports to accommodate various video input and outputs. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.<br>Use case:<br>[DAYU200 Use Case](device-dev/porting/porting-dayu200-on_standard-demo.md)</div> | Entertainment, easy travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) <br> | +| Small system| Hispark_Taurus | Hi3516DV300 | <div style="width:200pt">Function Description:<br>Hi3516D V300 is the next-generation system on chip (SoC) for smart HD IP cameras. It integrates the next-generation image signal processor (ISP), H.265 video compression encoder, and high-performance NNIE engine, and delivers high performance in terms of low bit rate, high image quality, intelligent processing and analysis, and low power consumption.</div> | Smart device with screens, such as refrigerators with screens and head units.| [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) <br> | +| Mini system| Multi-modal V200Z-R | BES2600 | <div style="width:200pt">Function description:<br>The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core ARM processor with a frequency of up to 1 GHz as well as dual-mode Wi-Fi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.<br>Use case:<br>[Multi-modal V200Z-R Use Case](device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md)</div> | Smart hardware, and smart devices with screens, such as speakers and watches.| [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) <br> | -## Getting Started<a name="section44681652104210"></a> +## Getting Started - [Getting Started for Device Development](device-dev/quick-start/quickstart-ide-lite-overview.md) - [Getting Started for Application Development](application-dev/quick-start/start-overview.md) -## Code Repository Addresses<a name="section107651249181914"></a> -OpenHarmony project: [https://gitee.com/openharmony](https://gitee.com/openharmony) -OpenHarmony SIG: [https://gitee.com/openharmony-sig](https://gitee.com/openharmony-sig) +## Code Repository Addresses + +OpenHarmony project: [https://gitee.com/openharmony](https://gitee.com/openharmony) + +OpenHarmony SIGs: [https://gitee.com/openharmony-sig](https://gitee.com/openharmony-sig) -OpenHarmony third-party components: [https://gitee.com/openharmony-tpc](https://gitee.com/openharmony-tpc) +OpenHarmony third-party components: [https://gitee.com/openharmony-tpc](https://gitee.com/openharmony-tpc) -OpenHarmony archived projects: [https://gitee.com/openharmony-retired](https://gitee.com/openharmony-retired) +OpenHarmony archived projects: [https://gitee.com/openharmony-retired](https://gitee.com/openharmony-retired) -## OpenHarmony Documentation<a name="section21031470109"></a> +## OpenHarmony Documentation -[Chinese version](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme.md) +[Chinese version](https://gitee.com/openharmony/docs/tree/master/zh-cn) -[English version](https://gitee.com/openharmony/docs/blob/master/en/readme.md) +[English version](https://gitee.com/openharmony/docs/tree/master/en) -## Source Code Downloading<a name="section39011923144212"></a> +## Source Code Downloading -For details about how to obtain the source code of OpenHarmony, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md). +For details about how to obtain the source code of OpenHarmony, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md) -## Hands-On Tutorials<a name="sectionsamples"></a> +## Hands-On Tutorials [Samples](https://gitee.com/openharmony/app_samples) [Codelabs](https://gitee.com/openharmony/codelabs) -## How to Participate<a name="section19611528174215"></a> +## How to Participate -For details about how to join in the OpenHarmony community, see [OpenHarmony Community](https://gitee.com/openharmony/community/blob/master/README-EN.md). +For details about how to join in the OpenHarmony community, see [OpenHarmony Community](https://gitee.com/openharmony/community/blob/master/README-EN.md) -For details about how to contribute, see [How to Contribute](contribute/how-to-contribute.md). +For details about how to contribute, see [How to contribute](contribute/how-to-contribute.md). -## License Agreement<a name="section1245517472115"></a> +## License Agreement OpenHarmony complies with Apache License Version 2.0. For details, see the LICENSE in each repository. -OpenHarmony uses third-party open-source software and licenses. For details, see [Third-Party Open-Source Software](https://gitee.com/openharmony/docs/blob/master/en/contribute/third-party-open-source-software-and-license-notice.md). +OpenHarmony uses third-party open-source software and licenses. For details, see [Third-Party Open-Source Software](https://gitee.com/openharmony/docs/blob/master/en/contribute/third-party-open-source-software-and-license-notice.md). -## Contact Info<a name="section61728335424"></a> +## Contact Info Website: diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index fdc79edbcb58a00729b62b5e9f7d239b52cdbf59..8e42633391269303e5e8d888561281f57d1718ae 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -15,7 +15,6 @@ - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - - [Resource File Categories](quick-start/basic-resource-file-categories.md) - [SysCap](quick-start/syscap.md) - Development - [Ability Development](ability/Readme-EN.md) @@ -45,8 +44,5 @@ - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) - APIs - [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) - Contribution - [How to Contribute](../contribute/documentation-contribution.md) diff --git a/en/application-dev/ability/ability-brief.md b/en/application-dev/ability/ability-brief.md index 187064a1c67d7bd21c823a945cca79366428d3f8..9943d4d697fa787db084fc14848d37abdad90fe9 100644 --- a/en/application-dev/ability/ability-brief.md +++ b/en/application-dev/ability/ability-brief.md @@ -4,8 +4,8 @@ An ability is the abstraction of a functionality that an application can provide The ability framework model has two forms. -- FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there are Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. -- Stage model, which is introduced since API version 9. In the stage model, there are Ability and ExtensionAbility. The ExtensionAbility is further extended to ServiceExtensionAbility, FormExtensionAbility, DataShareExtensionAbility, and more. +- FA model, which applies to application development using API version 8 and earlier versions. In the FA model, there is Feature Ability (FA) and Particle Ability (PA). The FA supports Page abilities, and the PA supports Service, Data, and Form abilities. +- Stage model, which is introduced since API version 9. In the stage model, there is `Ability` and `ExtensionAbility`. `ExtensionAbility` is further extended to `ServiceExtensionAbility`, `FormExtensionAbility`, `DataShareExtensionAbility`, and more. The stage model is designed to make it easier to develop complex applications in the distributed environment. The table below lists the design differences between the two models. diff --git a/en/application-dev/ability/figures/fa-package-info.png b/en/application-dev/ability/figures/fa-package-info.png deleted file mode 100644 index 86da707408da8fdb149ea62d92298fed605132ca..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ability/figures/fa-package-info.png and /dev/null differ diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 5b61bcec4b25312f994ed94362339e601df5cd55..e1d67a295b673453d7340fb20a40c81d8c7a7855 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -78,29 +78,29 @@ To create Page abilities for an application in the stage model, you must impleme onCreate(want, launchParam) { console.log("MainAbility onCreate") } - + onDestroy() { console.log("MainAbility onDestroy") } - + onWindowStageCreate(windowStage) { console.log("MainAbility onWindowStageCreate") - + 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)) }) } - + onWindowStageDestroy() { console.log("MainAbility onWindowStageDestroy") } - + onForeground() { console.log("MainAbility onForeground") } - + onBackground() { console.log("MainAbility onBackground") } @@ -300,7 +300,7 @@ export default class MainAbility extends Ability { Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI. ```ts -import router from '@system.router' +import router from '@ohos.router' @Entry @Component diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md index 753b706605487dbe2cf5ebe0ce961b19d94e7ee0..e60f2c01333c1bef7324b3ef6cfe2c83821a95cd 100644 --- a/en/application-dev/application-dev-guide-for-gitee.md +++ b/en/application-dev/application-dev-guide-for-gitee.md @@ -54,8 +54,10 @@ 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 (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) + - [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 and TS APIs](reference/apis/Readme-EN.md) - Native APIs diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md index c07f787d38091637215907537e54812c397a417e..7065480d1c4a12bd0984f4916d678c1bed7a4997 100644 --- a/en/application-dev/application-dev-guide.md +++ b/en/application-dev/application-dev-guide.md @@ -54,8 +54,14 @@ 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: -- [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) + +- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) + +- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.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) diff --git a/en/application-dev/connectivity/ipc-rpc-overview.md b/en/application-dev/connectivity/ipc-rpc-overview.md index 19bbe8dc26871bec8b2f6f48273d90dacc148d70..e75536863b1ae1b5c5371f51b0d7e26e4db97ed6 100755 --- a/en/application-dev/connectivity/ipc-rpc-overview.md +++ b/en/application-dev/connectivity/ipc-rpc-overview.md @@ -19,4 +19,4 @@ In OpenHarmony documents, proxy represents the service requester, and stub repre ## Related Modules -[Distributed Scheduler](https://gitee.com/openharmony/distributedschedule_dms_fwk) +[Distributed Scheduler](https://gitee.com/openharmony/ability_dmsfwk) diff --git a/en/application-dev/connectivity/subscribe-remote-state.md b/en/application-dev/connectivity/subscribe-remote-state.md index fa70738556ec7992c33fd8bcf3e74fbd6145fcb6..8d9365d6bbba940bb85d9ac7493b7069c48845eb 100755 --- a/en/application-dev/connectivity/subscribe-remote-state.md +++ b/en/application-dev/connectivity/subscribe-remote-state.md @@ -1,25 +1,30 @@ -# Subscribing to State Changes of a Remote Object<a name="EN-US_TOPIC_0000001104030756"></a> +# Subscribing to State Changes of a Remote Object -IPC/RPC allows you to subscribe to the state changes of a remote stub object. When the remote stub object dies, a death notification will be sent to your local proxy object. You can also unsubscribe from the state changes if they are no longer needed. Such subscription and unsubscription are controlled by APIs. To be specific, you need to implement the **IRemoteObject.DeathRecipient** interface and the **onRemoteDied** method to clear resources. This callback is invoked when the process accommodating the remote stub object dies, or the device accommodating the remote stub object leaves the network. It is worth noting that these APIs should be called in the following order: The proxy object must first subscribe to death notifications of the stub object. If the stub object is in the normal state, the proxy object can cancel the subscription as required. If the process of the stub object exits or the device hosting the stub object goes offline, subsequent operations customized by the proxy object will be automatically triggered. +IPC/RPC allows you to subscribe to the state changes of a remote stub object. When the remote stub object dies, a death notification will be sent to your local proxy object. Such subscription and unsubscription are controlled by APIs. To be specific, you need to implement the **DeathRecipient** callback and the **onRemoteDied** method to clear resources. This callback is invoked when the process accommodating the remote stub object dies, or the device accommodating the remote stub object leaves the network. -**Development Using Native APIs** +Note that the proxy object must first subscribe to death notifications of the stub object. If the stub object is in the normal state, the proxy object can cancel the subscription as required. If the process of the stub object exits or the device hosting the stub object goes offline, subsequent operations customized by the proxy object will be automatically triggered. -The following APIs are used to add a recipient for death notifications of a remote stub object, remove such a recipient, and perform subsequent operations upon receiving a death notification of the remote stub object: -``` -bool AddDeathRecipient(const sptr<DeathRecipient> &recipient); -bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient); -void OnRemoteDied(const wptr<IRemoteObject> &object); -``` -The sample code is as follows: + +## **Development Using Native APIs** + +| API| Description| +| -------- | -------- | +| AddDeathRecipient(const sptr\<DeathRecipient> &recipient); | Adds a recipient for death notifications of a remote stub object.| +| RemoveDeathRecipient(const sptr\<DeathRecipient> &recipient); | Removes the recipient for death notifications of a remote stub object.| +| OnRemoteDied(const wptr\<IRemoteObject> &object); | Called when the remote stub object dies.| + + +## Sample Code + ``` class TestDeathRecipient : public IRemoteObject::DeathRecipient { public: virtual void OnRemoteDied(const wptr<IRemoteObject>& remoteObject); } -sptr<IRemoteObject::DeathRecipient> deathRecipient (new TestDeathRecipient()); // Construct a death notification recipient. -bool result = proxy->AddDeathRecipient(deathRecipient); // Add the recipient to the proxy. -result = proxy->RemoveDeathRecipient(deathRecipient); // Remove the recipient. +sptr<IRemoteObject::DeathRecipient> deathRecipient (new TestDeathRecipient());// Construct a death notification recipient. +bool result = proxy->AddDeathRecipient(deathRecipient); // Add a recipient for death notifications. +result = proxy->RemoveDeathRecipient(deathRecipient); // Remove the recipient for death notifications. ``` diff --git a/en/application-dev/connectivity/websocket-connection.md b/en/application-dev/connectivity/websocket-connection.md index 01f5f38fad74e234c8a9fb483ee4a11ae2a8c7a7..b68d537fc5ad96f3ab60b53e2e75a96d7b555f76 100644 --- a/en/application-dev/connectivity/websocket-connection.md +++ b/en/application-dev/connectivity/websocket-connection.md @@ -3,7 +3,7 @@ ## Use Cases -You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the **createWebSocket** API to create a **WebSocket** object and then use the **connect** API to connect to the server. If the connection is successful, the client will receive a callback of the **open** event. Then, the client can communicate with the server using the **send** API. When the server sends a message to the client, the client will receive a callback of the **message** event. If the client no longer needs this connection, it can call the **close** API to disconnect from the server. Then, the client will receive a callback of the **close** event. +You can use WebSocket to establish a bidirectional connection between a server and a client. Before doing this, you need to use the **createWebSocket()** API to create a **WebSocket** object and then use the **connect()** API to connect to the server. If the connection is successful, the client will receive a callback of the **open** event. Then, the client can communicate with the server using the **send()** API. When the server sends a message to the client, the client will receive a callback of the **message** event. If the client no longer needs this connection, it can call the **close()** API to disconnect from the server. Then, the client will receive a callback of the **close** event. If an error occurs in any of the preceding processes, the client will receive a callback of the **error** event. @@ -18,14 +18,14 @@ The WebSocket connection function is mainly implemented by the WebSocket module. | connect() | Establishes a WebSocket connection to a given URL. | | send() | Sends data through the WebSocket connection. | | close() | Closes a WebSocket connection. | -| on(type: 'open') | Enables listening for **open** events of a WebSocket connection. | -| off(type: 'open') | Disables listening for **open** events of a WebSocket connection. | -| on(type: 'message') | Enables listening for **message** events of a WebSocket connection. | -| off(type: 'message') | Disables listening for **message** events of a WebSocket connection. | -| on(type: 'close') | Enables listening for **close** events of a WebSocket connection. | -| off(type: 'close') | Disables listening for **close** events of a WebSocket connection. | -| on(type: 'error') | Enables listening for **error** events of a WebSocket connection. | -| off(type: 'error') | Disables listening for **error** events of a WebSocket connection. | +| on(type: 'open') | Enables listening for **open** events of a WebSocket connection. | +| off(type: 'open') | Disables listening for **open** events of a WebSocket connection. | +| on(type: 'message') | Enables listening for **message** events of a WebSocket connection. | +| off(type: 'message') | Disables listening for **message** events of a WebSocket connection. | +| on(type: 'close') | Enables listening for **close** events of a WebSocket connection. | +| off(type: 'close') | Disables listening for **close** events of a WebSocket connection. | +| on(type: 'error') | Enables listening for **error** events of a WebSocket connection. | +| off(type: 'error') | Disables listening for **error** events of a WebSocket connection. | ## How to Develop @@ -50,9 +50,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. // When receiving the on('open') event, the client can use the send() API to communicate with the server. ws.send("Hello, server!", (err, value) => { if (!err) { - console.log("send success"); + console.log("Message sent successfully"); } else { - console.log("send fail, err:" + JSON.stringify(err)); + console.log("Failed to send the message. Err:" + JSON.stringify(err)); } }); }); @@ -62,9 +62,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. if (value === 'bye') { ws.close((err, value) => { if (!err) { - console.log("close success"); + console.log("Connection closed successfully"); } else { - console.log("close fail, err is " + JSON.stringify(err)); + console.log("Failed to close the connection. Err: " + JSON.stringify(err)); } }); } @@ -77,9 +77,9 @@ The WebSocket connection function is mainly implemented by the WebSocket module. }); ws.connect(defaultIpAddress, (err, value) => { if (!err) { - console.log("connect success"); + console.log("Connected successfully"); } else { - console.log("connect fail, err:" + JSON.stringify(err)); + console.log("Connection failed. Err:" + JSON.stringify(err)); } }); ``` diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md index baf12a5741e2186ab57aeb5feb1acb534fa4651a..dde1feb495e9827ab1f0fd1fad903f71acb9cbb3 100644 --- a/en/application-dev/database/database-distributedobject-guidelines.md +++ b/en/application-dev/database/database-distributedobject-guidelines.md @@ -7,6 +7,8 @@ The distributed data objects allow data across devices to be processed like loca ## Available APIs +For details about the APIs related to the distributed data object, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md). + ### Creating a Distributed Data Object Instance Call **createDistributedObject()** to create a distributed data object instance. You can specify the attributes of the instance in **source**. @@ -15,7 +17,7 @@ Call **createDistributedObject()** to create a distributed data object instance. **Table 1** API for creating a distributed data object instance | Package| API| Description| | -------- | -------- | -------- | -| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- **source**: attributes of the **distributedObject** set.<br>- **DistributedObject**: returns the distributed object created.| +| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- **source**: attributes of the **distributedObject** set.<br>- **DistributedObject**: returns the distributed object created.| ### Generating a Session ID @@ -33,16 +35,16 @@ Call **setSessionId()** to set a session ID for a distributed data object. The s **Table 3** API for setting a session ID | Class| API| Description| | -------- | -------- | -------- | -| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br> **sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| +| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br> **sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| ### Observing Data Changes Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes. **Table 4** APIs for observing data changes of a distributed data object -| Class| API| Description| +| Class| API| Description| | -------- | -------- | -------- | -| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| +| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array<string> }>): void | Subscribes to data changes.| | DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array<string> }>): void | Unsubscribes from data changes. **Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.| ### Observing Online or Offline Status @@ -67,13 +69,13 @@ The saved data will be released in the following cases: - The application has been uninstalled. - Data is successfully restored. -**Table 6** APIs for saving a distributed data object and revoking the saving +**Table 6** APIs for saving a distributed data object and revoking the saving operation | Class| API| Description| | -------- | -------- | -------- | | DistributedDataObject | save(deviceId: string): Promise<SaveSuccessResponse> | Saves a distributed data object. This API uses a promise to return the result.| | DistributedDataObject| save(deviceId: string, callback: AsyncCallback<SaveSuccessResponse>): void | Saves a distributed data object. This API uses an asynchronous callback to return the result.| -| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result. | -| DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation. This API uses a promise to return the result. | +| DistributedDataObject | revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result.| +| DistributedDataObject| revokeSave(): Promise<RevokeSaveSuccessResponse> | Revokes the data saving operation. This API uses a promise to return the result.| ## How to Develop @@ -157,7 +159,7 @@ The following example shows how to implement a distributed data object synchroni local_object.on("change", this.changeCallback.bind(this)); ``` -6. Modify object attributes. <br>The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). +6. Modify object attributes. <br>The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types). The sample code is as follows: ```js @@ -205,41 +207,39 @@ The following example shows how to implement a distributed data object synchroni 10. Save a distributed data object and revoke the data saving operation. - Callback - - - ```js - // Save a distributed data object. - local_object.save("local", (result, data)=>{ - console.log("save callback"); - console.info("save sessionId " + data.sessionId); - console.info("save version " + data.version); - console.info("save deviceId " + data.deviceId); - }); - // Revoke the data saving operation. - local_object.revokeSave((result, data) =>{ - console.log("revokeSave callback"); - console.info("revokeSave sessionId " + data.sessionId); - }); - ``` - - Promise - - ```js - // Save a distributed data object. - g_object.save("local").then((result)=>{ - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); - }, (result)=>{ - console.info("save local failed."); - }); - // Revoke the data saving operation. - g_object.revokeSave().then((result)=>{ - console.info("revokeSave success."); - }, (result)=>{ - console.info("revokeSave failed."); - }); - ``` -11. Unsubscribe from the status changes of the distributed data object. <br>You can specify the callback to unregister. If you do not specify the callback, this API unregister all callbacks of this distributed data object. + + ```js + // Save a distributed data object. + local_object.save("local", (result, data)=>{ + console.log("save callback"); + console.info("save sessionId " + data.sessionId); + console.info("save version " + data.version); + console.info("save deviceId " + data.deviceId); + }); + // Revoke the data saving operation. + local_object.revokeSave((result, data) =>{ + console.log("revokeSave callback"); + console.info("revokeSave sessionId " + data.sessionId); + }); + ``` + - Promise + ```js + // Save a distributed data object. + g_object.save("local").then((result)=>{ + console.info("save sessionId " + result.sessionId); + console.info("save version " + result.version); + console.info("save deviceId " + result.deviceId); + }, (result)=>{ + console.info("save local failed."); + }); + // Revoke the data saving operation. + g_object.revokeSave().then((result)=>{ + console.info("revokeSave success."); + }, (result)=>{ + console.info("revokeSave failed."); + }); + ``` +11. Unsubscribe from the status changes of the distributed data object. <br>You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object. The sample code is as follows: ```js diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md index 309d2a38e4cbcab79a102b809bb9444cf9a8e1ee..c5608c6eabd526c38a87bd3907fba89fb1a11629 100644 --- a/en/application-dev/database/database-mdds-guidelines.md +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -7,19 +7,21 @@ The Distributed Data Service (DDS) implements synchronization of application dat ## Available APIs +For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md). + The table below describes the APIs provided by the OpenHarmony DDS module. **Table 1** APIs provided by the DDS -| Category | API | Description | -| -------- | --- | ----------- | -| Creating a distributed database | createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void<br>createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| -| Obtaining a distributed KV store | getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void<br>getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**. | -| Managing data in a distributed KV store | put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void<br>put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts and updates data. | +| Category | API | Description | +| ------------ | ------------- | ------------- | +| Creating a distributed database| createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void<br>createKVManager(config: KVManagerConfig): Promise<KVManager> | Creates a **KVManager** object for database management.| +| Obtaining a distributed KV store| getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void<br>getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | Obtains the KV store with the specified **Options** and **storeId**.| +| Managing data in a distributed KV store| put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void<br>put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | Inserts and updates data.| | Managing data in a distributed KV store| delete(key: string, callback: AsyncCallback<void>): void<br>delete(key: string): Promise<void> | Deletes data. | -| Managing data in a distributed KV store | get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void<br>get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | -| Subscribing to changes in the distributed data | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void<br>on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store. | -| Synchronizing data across devices | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | +| Managing data in a distributed KV store| get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void<br>get(key: string): Promise<Uint8Array \| string \| boolean \| number> | Queries data. | +| Subscribing to changes in the distributed data| on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void<br>on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | Subscribes to data changes in the KV store.| +| Synchronizing data across devices| sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | Triggers database synchronization in manual mode. | @@ -29,14 +31,13 @@ The table below describes the APIs provided by the OpenHarmony DDS module. The following uses a single KV store as an example to describe the development procedure. 1. Import the distributed data module. - ```js import distributedData from '@ohos.data.distributedData'; ``` 2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. - 1. Create a **KvManagerConfig** object based on the application context. - 2. Create a **KvManager** instance. + (1) Create a **KvManagerConfig** object based on the application context. + (2) Create a **KvManager** instance. The sample code is as follows: ```js @@ -63,8 +64,8 @@ The following uses a single KV store as an example to describe the development p ``` 3. Create and obtain a single KV store. - 1. Declare the ID of the single KV store to create. - 2. Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required. + (1) Declare the ID of the single KV store to create. + (2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required. The sample code is as follows: ```js @@ -91,12 +92,11 @@ The following uses a single KV store as an example to describe the development p } ``` - >  **NOTE**<br/> + >  **NOTE**<br/> > For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (**kvStore** in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle. -4. Subscribe to changes in the distributed data.<br/> +4. Subscribe to changes in the distributed data.<br/> The following is the sample code for subscribing to the data changes of a single KV store: - ```js kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { console.log("dataChange callback call data: " + JSON.stringify(data)); @@ -104,8 +104,8 @@ The following uses a single KV store as an example to describe the development p ``` 5. Write data to the single KV store. - 1. Construct the key and value to be written into the single KV store. - 2. Write key-value pairs into the single KV store. + (1) Construct the key and value to be written into the single KV store. + (2) Write key-value pairs into the single KV store. The following is the sample code for writing key-value pairs of the string type into the single KV store: @@ -126,11 +126,10 @@ The following uses a single KV store as an example to describe the development p ``` 6. Query data in the single KV store. - 1. Construct the key to be queried from the single KV store. - 2. Query data from the single KV store. + (1) Construct the key to be queried from the single KV store. + (2) Query data from the single KV store. The following is the sample code for querying data of the string type from the single KV store: - ```js const KEY_TEST_STRING_ELEMENT = 'key_test_string'; const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; @@ -178,3 +177,7 @@ The following uses a single KV store as an example to describe the development p } }); ``` +## Samples +The following samples are provided to help you better understand the distributed data development: +- [`KvStore`: Distributed Database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) +- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index 50d34b56ce3309b953285083d9ce97405e0721d2..53bba062801ec1b8bcf1f65cdc4119fa53757f10 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -34,7 +34,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th | Class| API| Description| | -------- | -------- | -------- | - | RdbStore | insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This API uses a callback to return the result.<br>- **table**: name of the target table.<br>- **values**: data to be inserted into the table.<br>- **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.| + | RdbStore | insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void | Inserts a row of data into a table. This API uses a callback to return the result.<br>- **table**: name of the target table.<br>- **values**: data to be inserted into the table.<br>- **callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.| | RdbStore | insert(table: string, values: ValuesBucket): Promise<number> | Inserts a row of data into a table. This API uses a promise to return the result.<br>- **table**: name of the target table.<br>- **values**: data to be inserted into the table.| - **Updating data** @@ -190,7 +190,7 @@ You can obtain the distributed table name for a remote device based on the local | -------- | -------- | -------- | | RdbStore |off(event:'dataChange', type: SubscribeType, observer: Callback\<Array\<string>>): void;| Unregisters the observer of the specified type for the RDB store. This API uses a callback to return the result.<br>- **type**: subscription type. **SUBSCRIBE_TYPE_REMOTE** means to subscribe to remote data changes.<br>- **observer**: observer to unregister.| -### Backing Up and Restore an RDB Store +### Backing Up and Restoring an RDB Store **Backing Up an RDB Store** @@ -198,8 +198,8 @@ You can obtain the distributed table name for a remote device based on the local | Class| API| Description| | -------- | -------- | -------- | -| RdbStore |backup(destName:string, callback: AsyncCallback<void>):void| Backs up the RDB store with the specified name. This API uses an asynchronous callback to return the result.<br>- **destName**: name of the RDB backup file.<br>- **callback**: callback invoked to return the result.| -| RdbStore |backup(destName:string): Promise<void>| Backs up the RDB store with the specified name. This API uses a promise to return the result.<br>- **destName**: name of the RDB backup file.| +| RdbStore |backup(destName:string, callback: AsyncCallback<void>):void| Backs up an RDB store. This API uses an asynchronous callback to return the result.<br>- **destName**: name of the RDB backup file.<br>- **callback**: callback invoked to return the result.| +| RdbStore |backup(destName:string): Promise<void>| Backs up an RDB store. This API uses a promise to return the result.<br>- **destName**: name of the RDB backup file.| **Restoring an RDB Store** @@ -207,8 +207,8 @@ You can obtain the distributed table name for a remote device based on the local | Class| API| Description| | -------- | -------- | -------- | -| RdbStore |restore(srcName:string, callback: AsyncCallback<void>):void| Restores an RDB store using the specified backup file. This API uses an asynchronous callback to return the result.<br>- **srcName**: name of the RDB backup file.<br>- **callback**: callback invoked to return the result.| -| RdbStore |restore(srcName:string): Promise<void>| Restores an RDB store using the specified backup file. This API uses a promise to return the result.<br>- **srcName**: name of the RDB backup file.| +| RdbStore |restore(srcName:string, callback: AsyncCallback<void>):void| Restores an RDB store using a backup file. This API uses an asynchronous callback to return the result.<br>- **srcName**: name of the RDB backup file.<br>- **callback**: callback invoked to return the result.| +| RdbStore |restore(srcName:string): Promise<void>| Restores an RDB store using a backup file. This API uses a promise to return the result.<br>- **srcName**: name of the RDB backup file.| ## How to Develop @@ -270,7 +270,7 @@ You can obtain the distributed table name for a remote device based on the local const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType")) resultSet.close() }) - ``` + ``` 4. Set the distributed tables to be synchronized. diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md index c4e4fdf3850f4bd3b1b8f6902133835764414cb3..fb107049c515d0ff1961313a9f0bebb39c4e4c9d 100644 --- a/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ b/en/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md @@ -3,7 +3,6 @@ ## When to Use With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and bundle group. - The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported. ## Available APIs @@ -23,7 +22,7 @@ import stats from '@ohos.bundleState'; | function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.| | function queryAppUsagePriorityGroup(): Promise<number>; | Queries the priority group of this application. This API uses a promise to return the result.| | function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. | -| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**.| +| function getRecentlyUsedModules(maxNum? : number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**. If **maxNum** is not specified, the default value **1000** is used.| | function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries the number of notifications from all applications based on the specified start time and end time.| | function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.| | function queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback<number>): void | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result.| @@ -45,7 +44,7 @@ import stats from '@ohos.bundleState'; ..., "reqPermissions": [ { - "name": "ohos.permission.BUNDLE_ACTIVE_INFO" + "name": "ohos.permission.BUNDLE_ACTIVE_INFO" } ] } @@ -57,13 +56,13 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.queryBundleActiveStates(0, 20000000000000).then( res => { + stats.queryBundleActiveStates(0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); } - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); }); @@ -87,7 +86,7 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.queryBundleStateInfos(0, 20000000000000).then( res => { + stats.queryBundleStateInfos(0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); let i = 1; for (let key in res){ @@ -95,7 +94,7 @@ import stats from '@ohos.bundleState'; console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); i++; } - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); }); @@ -121,13 +120,13 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { + stats.queryCurrentBundleActiveStates(0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); } - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); }); @@ -151,13 +150,13 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { + stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); for (let i = 0; i < res.length; i++) { console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); } - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); }); @@ -179,14 +178,14 @@ import stats from '@ohos.bundleState'; ```js import stats from '@ohos.bundleState' - + // Promise mode - stats.queryAppUsagePriorityGroup().then( res => { + stats.queryAppUsagePriorityGroup().then(res => { console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); - + // Callback mode stats.queryAppUsagePriorityGroup((err, res) => { if (err) { @@ -196,16 +195,16 @@ import stats from '@ohos.bundleState'; } }); ``` - + 7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file. A third-party application can only check the idle status of itself. ```js import stats from '@ohos.bundleState' // Promise mode - stats.isIdleState("com.ohos.camera").then( res => { + stats.isIdleState("com.ohos.camera").then(res => { console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); }); @@ -225,18 +224,18 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.getRecentlyUsedModules(1000).then( res => { + stats.getRecentlyUsedModules(1000).then(res => { console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); for (let i = 0; i < res.length; i++) { console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1)); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i])); } - }).catch( err=> { + }).catch(err=> { console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); }); // Promise mode when maxNum is not specified - stats.getRecentlyUsedModules().then( res => { + stats.getRecentlyUsedModules().then(res => { console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); for (let i = 0; i < res.length; i++) { console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1)); @@ -247,7 +246,7 @@ import stats from '@ohos.bundleState'; }); // Asynchronous callback mode - stats.getRecentlyUsedModules(1000,(err, res) => { + stats.getRecentlyUsedModules(1000, (err, res) => { if(err) { console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); } else { @@ -261,7 +260,7 @@ import stats from '@ohos.bundleState'; // Asynchronous callback mode when maxNum is not specified stats.getRecentlyUsedModules((err, res) => { - if(err) { + if (err) { console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); } else { console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.'); @@ -279,10 +278,10 @@ import stats from '@ohos.bundleState'; import stats from '@ohos.bundleState' // Promise mode - stats.queryAppNotificationNumber(0, 20000000000000).then( res => { + stats.queryAppNotificationNumber(0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.'); console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code); }); @@ -301,15 +300,15 @@ import stats from '@ohos.bundleState'; ```js import stats from '@ohos.bundleState' - + // Promise mode - stats.queryBundleActiveEventStates(0, 20000000000000).then( res => { + stats.queryBundleActiveEventStates(0, 20000000000000).then(res => { console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.'); console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code); }); - + // Asynchronous callback mode stats.queryBundleActiveEventStates(0, 20000000000000, (err, res) => { if (err) { @@ -325,14 +324,14 @@ import stats from '@ohos.bundleState'; ```js import stats from '@ohos.bundleState' - + // Promise mode without parameters - stats.queryAppUsagePriorityGroup().then( res => { + stats.queryAppUsagePriorityGroup().then(res => { console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); - + // Asynchronous callback mode without parameters stats.queryAppUsagePriorityGroup((err, res) => { if (err) { @@ -341,17 +340,17 @@ import stats from '@ohos.bundleState'; console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); } }); - + // Promise mode with parameters - stats.queryAppUsagePriorityGroup(this.bundleName).then( res => { + stats.queryAppUsagePriorityGroup(this.bundleName).then(res => { console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res)); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code); }); - + // Asynchronous callback mode with parameters stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => { - if(err) { + if (err) { console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); } else { console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res)); @@ -363,16 +362,16 @@ import stats from '@ohos.bundleState'; ```javascript import stats from '@ohos.bundleState' - + // Promise mode - stats.setBundleGroup(this.bundleName, this.newGroup).then( () => { + stats.setBundleGroup(this.bundleName, this.newGroup).then(() => { console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.'); }).catch( err => { console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code); }); // Asynchronous callback mode stats.setBundleGroup(this.bundleName, this.newGroup, (err) => { - if(err) { + if (err) { console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code); } else { console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.'); @@ -384,9 +383,9 @@ import stats from '@ohos.bundleState'; ```javascript import stats from '@ohos.bundleState' - + // Promise mode - let onBundleGroupChanged = (err,res) =>{ + let onBundleGroupChanged = (err,res) => { console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup); @@ -394,13 +393,13 @@ import stats from '@ohos.bundleState'; console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName); }; - stats.registerGroupCallBack(onBundleGroupChanged).then( () => { + stats.registerGroupCallBack(onBundleGroupChanged).then(() => { console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.'); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code); }); // Asynchronous callback mode - let onBundleGroupChanged = (err,res) =>{ + let onBundleGroupChanged = (err,res) => { console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup); @@ -408,29 +407,29 @@ import stats from '@ohos.bundleState'; console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName); }; - stats.registerGroupCallBack(onBundleGroupChanged, (err)=>{ - if(err) { + stats.registerGroupCallBack(onBundleGroupChanged, (err) => { + if (err) { console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code); } else { console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.'); } }); ``` - + 13. Deregister the callback for application group changes. ```javascript import stats from '@ohos.bundleState' - + //promise - stats.unRegisterGroupCallBack().then( () => { + stats.unRegisterGroupCallBack().then(() => { console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.'); - }).catch( err => { + }).catch(err => { console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code); }); //callback - stats.unRegisterGroupCallBack((err)=>{ - if(err) { + stats.unRegisterGroupCallBack((err) => { + if (err) { console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code); } else { console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.'); diff --git a/en/application-dev/device/device-location-geocoding.md b/en/application-dev/device/device-location-geocoding.md index 30f647d98a368168ba945e11f11bb59f65a5b455..f95df63eebe64eedb6063ae193f4b141bfd946c6 100644 --- a/en/application-dev/device/device-location-geocoding.md +++ b/en/application-dev/device/device-location-geocoding.md @@ -3,9 +3,9 @@ ## When to Use -Describing a location using coordinates is accurate, but neither intuitive nor user-friendly. +Describing a location using coordinates is accurate, but neither intuitive nor user-friendly. With the geocoding and reverse geocoding capabilities, you will be able to convert geographic description into specific coordinates and vice versa. -With the geocoding and reverse geocoding capabilities, you will be able to convert geographic description into specific coordinates and vice versa. The geocoding information describes a location using several attributes, including the country, administrative region, street, house number, and address, etc. +The geographic description helps users understand a location easily by providing several key attributes, for example, country, administrative region, street, house number, and address. ## Available APIs @@ -36,13 +36,29 @@ The following table describes APIs available for mutual conversion between coord import geolocation from '@ohos.geolocation'; ``` -2. Obtain the conversion result. +2. Query whether geocoder service is available. + - Call **isGeoServiceAvailable** to query whether the geocoder service is available. If the service is available, continue with step 3. + ``` + geolocation.isGeoServiceAvailable((err, data) => { + if (err) { + console.log('isGeoServiceAvailable err: ' + JSON.stringify(err)); + } else { + console.log('isGeoServiceAvailable data: ' + JSON.stringify(data)); + } + }); + ``` + +3. Obtain the conversion result. - Call **getAddressesFromLocation** to convert coordinates into geographical location information. ``` var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; - geolocation.getAddressesFromLocation(reverseGeocodeRequest, (data) => { - console.log('getAddressesFromLocation: ' + JSON.stringify(data)); + geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { + if (err) { + console.log('getAddressesFromLocation err: ' + JSON.stringify(err)); + } else { + console.log('getAddressesFromLocation data: ' + JSON.stringify(data)); + } }); ``` @@ -51,8 +67,12 @@ The following table describes APIs available for mutual conversion between coord ``` var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1}; - geolocation.getAddressesFromLocationName(geocodeRequest, (data) => { - console.log('getAddressesFromLocationName: ' + JSON.stringify(data)); + geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { + if (err) { + console.log('getAddressesFromLocationName err: ' + JSON.stringify(err)); + } else { + console.log('getAddressesFromLocationName data: ' + JSON.stringify(data)); + } }); ``` diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md index 84f189d7f247bd9516204c7dd0d76aafb6438dbb..a32decd05ac0ba0d6db06749c18dcd31d3a7645b 100644 --- a/en/application-dev/device/device-location-info.md +++ b/en/application-dev/device/device-location-info.md @@ -14,49 +14,49 @@ The following table describes APIs available for obtaining device location infor **Table 1** APIs for obtaining device location information -| API | Description | -| -------- | -------- | -| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. | -| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. | -| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. | -| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. | -| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. | -| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. | -| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. | -| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. | -| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. | -| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. | -| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. | -| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. | -| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. | -| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. | -| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. | -| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. | -| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. | -| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. | -| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. | -| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. | -| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. | -| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. | -| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. | -| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. | -| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. | -| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. | -| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. | -| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. | -| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. | -| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. | +| API | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. | +| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. | +| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. | +| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. | +| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. | +| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. | +| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. | +| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. | +| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. | +| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. | +| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. | +| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. | +| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This API uses an asynchronous callback to return the result. | +| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This API uses a promise to return the result. | +| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This API uses an asynchronous callback to return the result. | +| getLastLocation() : Promise<Location> | Obtains the previous location. This API uses a promise to return the result. | +| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This API uses an asynchronous callback to return the result. | +| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This API uses a promise to return the result. | +| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This API uses an asynchronous callback to return the result. | +| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This API uses a promise to return the result. | +| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This API uses an asynchronous callback to return the result. | +| enableLocation() : Promise<boolean> | Enables the location service. This API uses a promise to return the result. | +| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This API uses an asynchronous callback to return the result. | +| disableLocation() : Promise<boolean> | Disables the location service. This API uses a promise to return the result. | +| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This API uses an asynchronous callback to return the result. | +| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This API uses a promise to return the result. | +| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This API uses an asynchronous callback to return the result.| +| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This API uses a promise to return the result.| +| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This API uses an asynchronous callback to return the result.| +| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This API uses a promise to return the result. | +| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This API uses an asynchronous callback to return the result.| +| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This API uses a promise to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This API uses an asynchronous callback to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This API uses a promise to return the result.| ## How to Develop To learn more about the APIs for obtaining device location information, see [Geolocation](../reference/apis/js-apis-geolocation.md). -1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user. For details, see the following section. +1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below. The system provides the following location permissions: - ohos.permission.LOCATION @@ -64,9 +64,9 @@ To learn more about the APIs for obtaining device location information, see [Geo The **ohos.permission.LOCATION** permission is a must if your application needs to access the device location information. - If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. + If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background. - To allow your application to access device location information, you can declare the required permissions in the **config.json** file of your application. The sample code is as follows: + To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows: ``` @@ -83,8 +83,8 @@ To learn more about the APIs for obtaining device location information, see [Geo } } ``` - - For details about the fields, see . + + For details about the fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. @@ -92,7 +92,7 @@ To learn more about the APIs for obtaining device location information, see [Geo import geolocation from '@ohos.geolocation'; ``` -3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information. +3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information.<br> **Method 1:** To better serve your needs for using APIs, the system has categorized APIs into different packages to match your common use cases of the location function. In this way, you can directly use the APIs specific to a certain use case, making application development much easier. The following table lists the use cases currently supported. @@ -112,18 +112,18 @@ To learn more about the APIs for obtaining device location information, see [Geo **Table 2** Common use cases of the location function - | Use Case | Constant | Description | - | -------- | -------- | -------- | - | Navigation | NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.<br/>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Trajectory tracking | TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br/>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Ride hailing | CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br/>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Life service | DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br/>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency | NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.<br/>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - - The following example instantiates the **RequestParam** object for navigation: + | Use Case | Constant | Description | + | ------------ | ------------------- | ------------------------------------------------------------ | + | Navigation | NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Trajectory tracking| TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Ride hailing| CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Life service| DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency | NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + + Sample code for initializing **requestInfo** for navigation: ``` - var requestInfo = {'scenario': 0x301, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + var requestInfo = {'scenario': geolocation.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` **Method 2:** @@ -143,20 +143,20 @@ To learn more about the APIs for obtaining device location information, see [Geo **Table 3** Location priority policies - | Policy | Constant | Description | - | -------- | -------- | -------- | - | Location accuracy priority | ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.<br/>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Fast location priority | FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.<br/>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency priority | LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.<br/>To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization. | + | Policy | Constant | Description | + | ------------------ | -------------- | ------------------------------------------------------------ | + | Location accuracy priority | ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.<br>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Fast location priority | FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.<br>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency priority| LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.<br>To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization.| - The following example instantiates the **RequestParam** object for the location accuracy priority policy: + Sample code for initializing **requestInfo** for the location accuracy priority policy: ``` - var requestInfo = {'priority': 0x201, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + var requestInfo = {'priority': geolocation.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` 4. Instantiate the **Callback** object for the system to report location results. - Your application needs to implement the callback interface defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. + Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. ``` var locationChange = (location) => { @@ -176,11 +176,15 @@ To learn more about the APIs for obtaining device location information, see [Geo geolocation.off('locationChange', locationChange); ``` - If your application does not need the real-time device location, it can use the last known device location cached in the system instead. - +If your application does not need the real-time device location, it can use the last known device location cached in the system instead. + ``` - geolocation.getLastLocation((data) => { - console.log('getLastLocation: data: ' + JSON.stringify(data)); + geolocation.getLastLocation((err, data) => { + if (err) { + console.log('getLastLocation: err: ' + JSON.stringify(err)); + } else { + console.log('getLastLocation: data: ' + JSON.stringify(data)); + } }); ``` diff --git a/en/application-dev/dfx/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md index e1d4cddeb2ff96c8a07a6df84382ad0b8d22464c..54199719cd93a523d8f2b0af14c12578997a02a2 100644 --- a/en/application-dev/dfx/hiappevent-guidelines.md +++ b/en/application-dev/dfx/hiappevent-guidelines.md @@ -2,13 +2,13 @@ ## When to Use -The event logging function helps applications log various information generated during running. +The event logging function helps applications to log various information generated during running. ## Available APIs JS application event logging APIs are provided by the **hiAppEvent** module. -**APIs for Event Logging** +**Table 1** APIs for event logging | API | Return Value | Description | | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | @@ -17,7 +17,7 @@ JS application event logging APIs are provided by the **hiAppEvent** module. 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** +**Table 2** APIs for event logging configuration | API | Return Value | Description | | ------------------------------ | ------------ | ------------------------------------------------------------ | diff --git a/en/application-dev/dfx/hiappevent-overview.md b/en/application-dev/dfx/hiappevent-overview.md index 403aec02035c965da4633e8667be6803031ddf60..2a5e36f879a922f3d6bf845e700068c2a299b337 100644 --- a/en/application-dev/dfx/hiappevent-overview.md +++ b/en/application-dev/dfx/hiappevent-overview.md @@ -2,8 +2,10 @@ HiAppEvent provides event logging APIs for applications to log the fault, statistical, security, and user behavior events reported during running. Based on event information, you will be able to analyze the running status of your application. +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. + ## Basic Concepts -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** -**Logging**: Logs changes caused by user operations to provide service data for development, product, and O&M analysis. + Logs changes caused by user operations to provide service data for development, product, and O&M analysis. diff --git a/en/application-dev/dfx/hitracemeter-guidelines.md b/en/application-dev/dfx/hitracemeter-guidelines.md index e7e97631c240bb42358d3b0b630a92094f34bcfc..316ee1b07898a24721b81625c2e9193ae08aa85f 100644 --- a/en/application-dev/dfx/hitracemeter-guidelines.md +++ b/en/application-dev/dfx/hitracemeter-guidelines.md @@ -6,9 +6,9 @@ HiTraceMeter provides APIs for system performance tracing. You can call the APIs ## Available APIs -The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). +The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md). -**APIs for performance tracing** +**Table 1** APIs for performance tracing | API| Return Value| Description| | ---------------------------------------------------------------------------- | --------- | ------------ | diff --git a/en/application-dev/dfx/hitracemeter-overview.md b/en/application-dev/dfx/hitracemeter-overview.md index 3683092b34fcd23a65245303406934b3fb8acad5..649fa7704dd566ab8bc02776de6f62756d7f26a6 100644 --- a/en/application-dev/dfx/hitracemeter-overview.md +++ b/en/application-dev/dfx/hitracemeter-overview.md @@ -15,4 +15,4 @@ hiTraceMeter is a tool for you to trace service processes and monitor system per ## Constraints -- Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. +Due to the asynchronous I/O feature of JS, the hiTraceMeter module provides only asynchronous APIs. diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md index 66b002200fc1c1965f1d3e741739685ae97236e6..0e34d66d523abea51e259bbcea5d7be08e755e3e 100644 --- a/en/application-dev/internationalization/i18n-guidelines.md +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -23,57 +23,64 @@ You can use APIs provided in the following table to obtain the system language a ### How to Develop -1. Obtain the system language.<br> +1. Obtain the system language. + Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module). - ``` + ```js var language = i18n.getSystemLanguage(); ``` -2. Obtain the system region.<br> +2. Obtain the system region. + Call the **getSystemRegion** method to obtain the system region. - ``` + ```js var region = i18n.getSystemRegion(); ``` -3. Obtain the system locale.<br> +3. Obtain the system locale. + Call the **getSystemLocale** method to obtain the system locale. - ``` + ```js var locale = i18n.getSystemLocale(); ``` -4. Check whether the locale's language is RTL.<br> +4. Check whether the locale's language is RTL. + Call the **isRTL** method to check whether the locale's language is RTL. - ``` + ```js var rtl = i18n.isRTL("zh-CN"); ``` -5. Check whether the system uses a 24-hour clock.<br> +5. Check whether the system uses a 24-hour clock. + Call the **is24HourClock** method to check whether the system uses a 24-hour clock. - ``` + ```js var hourClock = i18n.is24HourClock(); ``` -6. Obtain the localized display of a language.<br> +6. Obtain the localized display of a language. + Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. - ``` + ```js var language = "en"; var locale = "zh-CN"; var sentenceCase = false; var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase); ``` -7. Obtain the localized display of a country.<br> +7. Obtain the localized display of a country. + Call the **getDisplayCountry** method to obtain the localized display of a country name. **country** indicates the country code (a two-letter code in compliance with ISO-3166, for example, CN), **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized. - ``` + ```js var country = "US"; var locale = "zh-CN"; var sentenceCase = false; @@ -106,70 +113,78 @@ You can use APIs provided in the following table to obtain the system language a ### How to Develop -1. Instantiate a **Calendar** object.<br> +1. Instantiate a **Calendar** object. + Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used. - ``` + ```js var calendar = i18n.getCalendar("zh-CN", "gregory); ``` -2. Set the time for the **Calendar** object.<br> +2. Set the time for the **Calendar** object. + Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT. - ``` + ```js var date1 = new Date(); calendar.setTime(date1); var date2 = 1000; calendar.setTime(date2); ``` -3. Set the year, month, day, hour, minute, and second for the **Calendar** object.<br> +3. Set the year, month, day, hour, minute, and second for the **Calendar** object. + Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object. - ``` + ```js calendar.set(2021, 12, 21, 6, 0, 0) ``` -4. Set and obtain the time zone for the **Calendar** object.<br> +4. Set and obtain the time zone for the **Calendar** object. + Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set. - ``` + ```js calendar.setTimeZone("Asia/Shanghai"); var timezone = calendar.getTimeZone(); ``` -5. Set and obtain the first day of a week for the **Calendar** object.<br> +5. Set and obtain the first day of a week for the **Calendar** object. + Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday. - ``` + ```js calendar.setFirstDayOfWeek(1); var firstDayOfWeek = calendar.getFirstDayOfWeek(); ``` -6. Set and obtain the minimum count of days in the first week for the **Calendar** object.<br> +6. Set and obtain the minimum count of days in the first week for the **Calendar** object. + Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object. - ``` + ```js calendar.setMinimalDaysInFirstWeek(3); var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); ``` -7. Obtain the localized display of the **Calendar** object.<br> +7. Obtain the localized display of the **Calendar** object. + Call the **getDisplayName** method to obtain the localized display of the **Calendar** object. - ``` + ```js var localizedName = calendar.getDisplayName("zh-CN"); ``` -8. Check whether a date is a weekend.<br> +8. Check whether a date is a weekend. + Call the **isWeekend** method to determine whether the input date is a weekend. - ``` + ```js var date = new Date(); var weekend = calendar.isWeekend(date); ``` @@ -191,25 +206,26 @@ You can use APIs provided in the following table to obtain the system language a ### How to Develop -1. Instantiate a **PhoneNumberFormat** object.<br> +1. Instantiate a **PhoneNumberFormat** object. + Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**. - ``` + ```js var phoneNumberFormat = new i18n.PhoneNumberFormat("CN", {type: "E164"}); ``` 2. Check whether the phone number format is correct. Call the **isValidNumber** method to check whether the format of the input phone number is correct. - ``` + ```js var validNumber = phoneNumberFormat.isValidNumber("15812341234"); ``` 3. Format a phone number. Call the **format** method of **PhoneNumberFormat** to format the input phone number. - ``` + ```js var formattedNumber = phoneNumberFormat.format("15812341234"); ``` @@ -232,7 +248,7 @@ The **unitConvert** API is provided to help you implement measurement conversion Call the [unitConvert](../reference/apis/js-apis-intl.md) method to convert a measurement unit and format the display result. - ``` + ```js var fromUnit = {unit: "cup", measureSystem: "US"}; var toUnit = {unit: "liter", measureSystem: "SI"}; var number = 1000; @@ -259,32 +275,36 @@ The **unitConvert** API is provided to help you implement measurement conversion ### How to Develop -1. Instantiate an **IndexUtil** object.<br> +1. Instantiate an **IndexUtil** object. + Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale. - ``` + ```js var indexUtil = getInstance("zh-CN"); ``` -2. Obtain the index list.<br> +2. Obtain the index list. + Call the **getIndexList** method to obtain the alphabet index list of the current locale. - ``` + ```js var indexList = indexUtil.getIndexList(); ``` -3. Add an index.<br> +3. Add an index. + Call the **addLocale** method to add the alphabet index of a new locale to the current index list. - ``` + ```js indexUtil.addLocale("ar") ``` -4. Obtain the index of a string.<br> +4. Obtain the index of a string. + Call the **getIndex** method to obtain the alphabet index of a string. - ``` + ```js var text = "access index"; indexUtil.getIndex(text); ``` @@ -313,38 +333,42 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api ### How to Develop -1. Instantiate a **BreakIterator** object.<br> +1. Instantiate a **BreakIterator** object. + Call the **getLineInstance** method to instantiate a **BreakIterator** object. - ``` + ```js var locale = "en-US" var breakIterator = i18n.getLineInstance(locale); ``` -2. Set and access the text that requires line breaking.<br> +2. Set and access the text that requires line breaking. + Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking. - ``` + ```js var text = "Apple is my favorite fruit"; breakIterator.setLineBreakText(text); var breakText = breakIterator.getLineBreakText(); ``` -3. Obtain the current position of the **BreakIterator** object.<br> +3. Obtain the current position of the **BreakIterator** object. + Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed. - ``` + ```js var pos = breakIterator.current(); ``` -4. Set the position of a **BreakIterator** object.<br> +4. Set the position of a **BreakIterator** object. + The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed. - ``` + ```js var firstPos = breakIterator.first(); // Set a BreakIterator object to the first break point, that is, the start position of the text. var lastPos = breakIterator.last(); // Set a BreakIterator object to the last break point, that is, the position after the text end. // Move a BreakIterator object forward or backward by a certain number of break points. @@ -356,10 +380,11 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api var followingPos = breakIterator.following(10); ``` -5. Determine whether a position is a break point.<br> +5. Determine whether a position is a break point. + Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position. - ``` + ```js var isboundary = breakIterator.isBoundary(5); ``` diff --git a/en/application-dev/internationalization/intl-guidelines.md b/en/application-dev/internationalization/intl-guidelines.md index 09bc3b733346db921cd04b76aff04b41d60af0b9..44748056f7886d4817cda2d9d0504f6966c32700 100644 --- a/en/application-dev/internationalization/intl-guidelines.md +++ b/en/application-dev/internationalization/intl-guidelines.md @@ -3,7 +3,8 @@ This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N interfaces defined in ECMA 402. The [I18N](i18n-guidelines.md) module provides enhanced I18N capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities. -> **NOTE**<br> +> **NOTE** +> > In the code snippets in this document, **intl** refers to the name of the imported module. ## Setting Locale Information @@ -24,7 +25,8 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc ### How to Develop -1. Instantiate a **Locale** object.<br> +1. Instantiate a **Locale** object. + Create a **Locale** object by using the **Locale** constructor. This method receives a string representing the locale and an optional [Attributes](../reference/apis/js-apis-intl.md) list. A **Locale** object consists of four parts: language, script, region, and extension, which are separated by using a hyphen (-). @@ -42,30 +44,33 @@ Use [Locale](../reference/apis/js-apis-intl.md) APIs to maximize or minimize loc | kf | Whether upper case or lower case is considered when sorting or comparing strings.| - ``` + ```js var locale = "zh-CN"; var options = {caseFirst: false, calendar: "chinese", collation: pinyin}; var localeObj = new intl.Locale(locale, options); ``` -2. Obtain the string representing a **Locale** object.<br> +2. Obtain the string representing a **Locale** object. + Call the **toString** method to obtain the string representing a **Locale** object, which includes the language, region, and other options. - ``` + ```js var localeStr = localeObj.toString(); ``` -3. Maximize locale information.<br> +3. Maximize locale information. + Call the **maximize** method to maximize locale information; that is, supplement the missing script and region information. - ``` + ```js var maximizedLocale = localeObj.maximize(); ``` -4. Minimize locale information.<br> +4. Minimize locale information. + Call the **minimize** method to minimize locale information; that is, delete the unnecessary script and region information. - ``` + ```js var minimizedLocale = localeObj.minimize(); ``` @@ -88,42 +93,46 @@ Use [DateTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the date ### How to Develop -1. Instantiate a **DateTimeFormat** object.<br> +1. Instantiate a **DateTimeFormat** object. + Use the default constructor of **DateTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **DateTimeFormat** object. - ``` + ```js var dateTimeFormat = new intl.DateTimeFormat(); ``` Alternatively, use your own locale and formatting parameters to create a **DateTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [DateTimeOptions](../reference/apis/js-apis-intl.md). - ``` + ```js var options = {dateStyle: "full", timeStyle: "full"}; var dateTimeFormat = new intl.DateTimeFormat("zh-CN", options); ``` -2. Format the date and time.<br> +2. Format the date and time. + Call the **format** method to format the date and time in the **DateTimeFormat** object. This method returns a string representing the formatting result. - ``` + ```js Date date = new Date(); var formatResult = dateTimeFormat.format(date); ``` -3. Format a period.<br> +3. Format a period. + Call the **formatRange** method to format the period in the **DateTimeFormat** object. This method requires input of two **Date** objects, which respectively indicate the start date and end date of a period. This method returns a string representing the formatting result. - ``` + ```js Date startDate = new Date(); Date endDate = new Date(); var formatResult = dateTimeFormat.formatRange(startDate, endDate); ``` -4. Obtain attributes of the **DateTimeFormat** object.<br> +4. Obtain attributes of the **DateTimeFormat** object. + Call the **resolvedOptions** method to obtain attributes of the **DateTimeFormat** object. This method will return an array that contains all attributes and values of the object. - ``` + ```js var options = dateTimeFormat.resolvedOptions(); ``` @@ -145,33 +154,36 @@ Use [NumberFormat](../reference/apis/js-apis-intl.md) APIs to format numbers for ### How to Develop -1. Instantiate a **NumberFormat** object.<br> +1. Instantiate a **NumberFormat** object. + Use the default constructor of **NumberFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **NumberFormat** object. - ``` + ```js var numberFormat = new intl.NumberFormat(); ``` Alternatively, use your own locale and formatting parameters to create a **NumberFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [NumberOptions](../reference/apis/js-apis-intl.md). - ``` + ```js var options = {compactDisplay: "short", notation: "compact"}; var numberFormat = new intl.NumberFormat("zh-CN", options); ``` -2. Format a number.<br> +2. Format a number. + Call the **format** method to format a number. A string is returned as the formatting result. - ``` + ```js var number = 1234.5678 var formatResult = numberFormat.format(number); ``` -3. Obtain attributes of the **NumberFormat** object.<br> +3. Obtain attributes of the **NumberFormat** object. + Call the **resolvedOptions** method to obtain attributes of the **NumberFormat** object. This method will return an array that contains all attributes and values of the object. - ``` + ```js var options = numberFormat.resolvedOptions(); ``` @@ -193,33 +205,36 @@ Use [Collator](../reference/apis/js-apis-intl.md) APIs to sort strings based on ### How to Develop -1. Instantiate a **Collator** object.<br> +1. Instantiate a **Collator** object. + Use the default constructor of **Collator** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **Collator** object. - ``` + ```js var collator = new intl.Collator(); ``` Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md). + ```js + var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}); ``` - var collator= new intl.Collator("zh-CN", {localeMatcher: "best fit", usage: "sort"}; - ``` -2. Compare two strings.<br> +2. Compare two strings. + Call the **compare** method to compare two input strings. This method returns a value as the comparison result. The return value **-1** indicates that the first string is shorter than the second string, the return value **1** indicates that the first string is longer than the second string, and the return value **0** indicates that the two strings are of equal lengths. - ``` + ```js var str1 = "first string"; var str2 = "second string"; var compareResult = collator.compare(str1, str2); ``` -3. Obtain attributes of the **Collator** object.<br> +3. Obtain attributes of the **Collator** object. + Call the **resolvedOptions** method to obtain attributes of the **Collator** object. This method will return an array that contains all attributes and values of the object. - ``` + ```js var options = collator.resolvedOptions(); ``` @@ -240,24 +255,26 @@ Use [PluralRules](../reference/apis/js-apis-intl.md) APIs to determine the singu ### How to Develop -1. Instantiate a **PluralRules** object.<br> +1. Instantiate a **PluralRules** object. + Use the default constructor of **PluralRules** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **PluralRules** object. - ``` + ```js var pluralRules = new intl.PluralRules(); ``` Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md). - ``` - var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}; + ```js + var plurals = new intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); ``` -2. Determine the singular-plural type.<br> +2. Determine the singular-plural type. + Call the **select** method to determine the singular-plural type of an input number. This method will return a string representing the singular-plural type, which can be any of the following: **zero**, **one**, **two**, **few**, **many**, and **other**. - ``` + ```js var number = 1234.5678 var categoryResult = plurals.select(number); ``` @@ -281,41 +298,45 @@ Use [RelativeTimeFormat](../reference/apis/js-apis-intl.md) APIs to format the r ### How to Develop -1. Instantiate a **RelativeTimeFormat** object.<br> +1. Instantiate a **RelativeTimeFormat** object. + Use the default constructor of **RelativeTimeFormat** to obtain the system default locale by accessing the system language and region settings, and set it as the locale in the **RelativeTimeFormat** object. - ``` + ```js var relativeTimeFormat = new intl.RelativeTimeFormat(); ``` Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [ RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md). + ```js + var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); ``` - var relativeTimeFormat = new intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}; - ``` -2. Format the relative time.<br> +2. Format the relative time. + Call the **format** method to format the relative time. This method receives a numeric value representing the time length and a string-form unit, like **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, and **second**. This method returns a string representing the formatting result. - ``` + ```js var number = 2; var unit = "year" var formatResult = relativeTimeFormat.format(number, unit); ``` -3. Obtain each part of the relative time format.<br> +3. Obtain each part of the relative time format. + Upon obtaining each part of the relative time format, customize the relative time formatting result. - ``` + ```js var number = 2; var unit = "year" var formatResult = relativeTimeFormat.formatToParts(number, unit); ``` -4. Obtain attributes of the **RelativeTimeFormat** object.<br> +4. Obtain attributes of the **RelativeTimeFormat** object. + Call the **resolvedOptions** method to obtain attributes of the **RelativeTimeFormat** object. This method will return an array that contains all attributes and values of the object. For a full list of attributes, see [ RelativeTimeFormatResolvedOptions](../reference/apis/js-apis-intl.md). - ``` + ```js var options = numberFormat.resolvedOptions(); ``` diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index b9f7b63d5b451da5213a8c282d52865d48c4e3eb..677e70f6e3b7eee215530cd15e7ab1b42676866c 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -1,7 +1,6 @@ # Media - Audio - - [Audio Overview](audio-overview.md) - [Audio Playback Development](audio-playback.md) - [Audio Recording Development](audio-recorder.md) @@ -15,9 +14,9 @@ - [Video Playback Development](video-playback.md) - [Video Recording Development](video-recorder.md) -- Image +- Image - [Image Development](image.md) -- Camera +- Camera - [Camera Development](camera.md) diff --git a/en/application-dev/media/audio-interruptmode.md b/en/application-dev/media/audio-interruptmode.md index 9f9355f68c326ec9b6ae8140a6579114bfaefcc3..8be8a00cedd10ff4ecd08ee46d746d9803b3c71a 100644 --- a/en/application-dev/media/audio-interruptmode.md +++ b/en/application-dev/media/audio-interruptmode.md @@ -48,7 +48,7 @@ For details about the APIs, see [AudioRenderer in Audio Management](../reference ```js var mode_ = audio.InterruptMode.SHARE_MODE; - await this.audioRenderer.setInterruptMode(mode_).then(()=>{ + await this.audioRenderer.setInterruptMode(mode_).then(() => { console.log('[JSAR] [SetInterruptMode] Setting: '+ (mode_ == 0? " share mode":"independent mode") + "success"); }); ``` diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index 2b0f260908c9e2986269601e588659ce6ce119fc..d65d0abfc4d4649f7f1847abdbe6fb0a832e194e 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -39,38 +39,38 @@ function printfDescription(obj) { // Set the player callbacks. function setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. + audioPlayer.play(); // The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the `play` event callback. console.info('audio play success'); - audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. + audioPlayer.pause(); // Trigger the 'pause' event callback and pause the playback. }); - audioPlayer.on('pause', () => { // Set the 'pause' event callback. + audioPlayer.on('pause', () => { // Set the `pause` event callback. console.info('audio pause success'); - audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. + audioPlayer.seek(5000); // Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback. }); - audioPlayer.on('stop', () => { // Set the 'stop' event callback. + audioPlayer.on('stop', () => { // Set the `stop` event callback. console.info('audio stop success'); - audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. + audioPlayer.reset(); // Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song. }); - audioPlayer.on('reset', () => { // Set the 'reset' event callback. + audioPlayer.on('reset', () => { // Set the `reset` event callback. console.info('audio reset success'); - audioPlayer.release(); // Release the AudioPlayer instance. + audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer = undefined; }); - audioPlayer.on('timeUpdate', (seekDoneTime) => {// Set the 'timeUpdate' event callback. + audioPlayer.on('timeUpdate', (seekDoneTime) => { // Set the `timeUpdate` event callback. if (typeof(seekDoneTime) == 'undefined') { console.info('audio seek fail'); return; } console.info('audio seek success, and seek time is ' + seekDoneTime); - audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. + audioPlayer.setVolume(0.5); // Trigger the 'volumeChange' event callback. }); - audioPlayer.on('volumeChange', () => { // Set the 'volumeChange' event callback. + audioPlayer.on('volumeChange', () => { // Set the `volumeChange` event callback. console.info('audio volumeChange success'); - audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. + audioPlayer.getTrackDescription((error, arrlist) => { // Obtain the audio track information in callback mode. if (typeof (arrlist) != 'undefined') { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); @@ -78,13 +78,13 @@ function setCallBack(audioPlayer) { } else { console.log(`audio getTrackDescription fail, error:${error.message}`); } - audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. + audioPlayer.stop(); // Trigger the 'stop' event callback to stop the playback. }); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. + audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. console.info('audio play finish'); }); - audioPlayer.on('error', (error) => { // Set the 'error' event callback. + audioPlayer.on('error', (error) => { // Set the 'error' event callback. console.info(`audio error called, errName is ${error.name}`); console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); @@ -94,7 +94,7 @@ function setCallBack(audioPlayer) { async function audioPlayerDemo() { // 1. Create an AudioPlayer instance. let audioPlayer = media.createAudioPlayer(); - setCallBack(audioPlayer); // Set the event callbacks. + setCallBack(audioPlayer); // Set the event callbacks. // 2. Set the URI of the audio file. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. @@ -107,7 +107,7 @@ async function audioPlayerDemo() { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. } ``` @@ -119,23 +119,23 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the `play` event callback. console.info('audio play success'); }); - audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. + audioPlayer.on('finish', () => { // Set the 'finish' event callback, which is triggered when the playback is complete. console.info('audio play finish'); - audioPlayer.release(); // Release the AudioPlayer instance. + audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer = undefined; }); } async audioPlayerDemo() { - let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. - this.setCallBack(audioPlayer); // Set the event callbacks. + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; @@ -147,7 +147,7 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. } } ``` @@ -161,20 +161,20 @@ export class AudioDemo { // Set the player callbacks. private isNextMusic = false; setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback. + audioPlayer.on('play', () => { // Set the `play` event callback. console.info('audio play success'); - audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. + audioPlayer.reset(); // Call the reset() API and trigger the 'reset' event callback. }); - audioPlayer.on('reset', () => { // Set the 'reset' event callback. + audioPlayer.on('reset', () => { // Set the `reset` event callback. console.info('audio play success'); - if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. - this.nextMusic(audioPlayer); // Changing songs is implemented. + if (!this.isNextMusic) { // When isNextMusic is false, changing songs is implemented. + this.nextMusic(audioPlayer); // Changing songs is implemented. } else { - audioPlayer.release(); // Release the AudioPlayer instance. + audioPlayer.release(); // Release the AudioPlayer instance. audioPlayer = undefined; } }); @@ -197,8 +197,8 @@ export class AudioDemo { } async audioPlayerDemo() { - let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. - this.setCallBack(audioPlayer); // Set the event callbacks. + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; @@ -223,19 +223,19 @@ import fileIO from '@ohos.fileio' export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { - audioPlayer.on('dataLoad', () => { // Set the 'dataLoad' event callback, which is triggered when the src attribute is set successfully. + audioPlayer.on('dataLoad', () => { // Set the `dataLoad` event callback, which is triggered when the src attribute is set successfully. console.info('audio set source success'); - audioPlayer.loop = true; // Set the loop playback attribute. - audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. + audioPlayer.loop = true; // Set the loop playback attribute. + audioPlayer.play(); // Call the play() API to start the playback and trigger the 'play' event callback. }); - audioPlayer.on('play', () => { // Set the 'play' event callback to start loop playback. + audioPlayer.on('play', () => { // Set the 'play' event callback to start loop playback. console.info('audio play success'); }); } async audioPlayerDemo() { - let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. - this.setCallBack(audioPlayer); // Set the event callbacks. + let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. + this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; @@ -247,7 +247,7 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback. + audioPlayer.src = fdPath; // Set the src attribute and trigger the `dataLoad` event callback. } } ``` diff --git a/en/application-dev/napi/napi-guidelines.md b/en/application-dev/napi/napi-guidelines.md index f2b6fe0e20564626d7a37d03832fae69f7f7866a..e58eed34cccb7dd820e1144a616dfb93a10f4d34 100644 --- a/en/application-dev/napi/napi-guidelines.md +++ b/en/application-dev/napi/napi-guidelines.md @@ -1,10 +1,10 @@ # Using Native APIs in Application Projects -OpenHarmony applications use JavaScript (JS) when calling native APIs. The native APIs (NAPIs) provided by the **arkui_napi** repository are used to implement the interaction with JS. Currently, the **arkui_napi** repository supports some third-party **Node.js** interfaces. The names of the NAPIs are the same as those in the third-party **Node.js**. For details about the interfaces supported, see `libnapi.ndk.json` in this repository. +OpenHarmony applications use JavaScript (JS) when calling native APIs. The native APIs (NAPIs) provided by the [ace_napi](https://gitee.com/openharmony/arkui_napi/tree/master) repository are used to implement interaction with JS. Currently, the **ace_napi** repository supports some third-party **Node.js** interfaces. The names of the NAPIs are the same as those in the third-party **Node.js**. For details about the interfaces supported, see `libnapi.ndk.json` in this repository. ## How to Develop -The IDE has a default project that uses NAPIs. You can choose `File` > `New` > `Create Project` to create a `Native C++` project. The **cpp** directory is generated in the **main** directory. You can use the NAPIs provided by the **arkui_napi** repository for development. +The IDE has a default project that uses NAPIs. You can choose `File` > `New` > `Create Project` to create a `Native C++` project. The **cpp** directory is generated in the **main** directory. You can use the NAPIs provided by the **ace_napi** repository for development. You can `import` the native .so that contains the JS processing logic. For example, `import hello from 'libhello.so'` to use the **libhello.so** capability. Then, the JS object created using the NAPI can be passed to the `hello` object of the application to call the native capability. @@ -74,7 +74,7 @@ export default storage; ### Implementation -You can obtain the complete code from `sample/native_module_storage/` in the **arkui_napi** repository. +You can obtain the complete code from `sample/native_module_storage/` in the [OpenHarmony/arkui_napi](https://gitee.com/openharmony/arkui_napi/tree/master) repository. #### Registering the Module @@ -212,7 +212,7 @@ static napi_value JSStorageGet(napi_env env, napi_callback_info info) napi_create_async_work( env, nullptr, resource, - // Callback 1: This callback contains the service logic to be asynchronously executed and is asynchronously executed by the NAPI. Do not operate JS objects using theNAPI because the execution is asynchronous. + // Callback 1: This callback contains the service logic to be asynchronously executed and is asynchronously executed by the NAPI. Do not operate JS objects using the NAPI because the execution is asynchronous. [](napi_env env, void* data) { StorageAsyncContext* asyncContext = (StorageAsyncContext*)data; auto itr = gKeyValueStorage.find(asyncContext->key); @@ -307,7 +307,7 @@ export class NetServer { ### Implementation -You can obtain the complete code from `sample/native_module_netserver/` in the **arkui_napi** repository. +You can obtain the complete code from `sample/native_module_netserver/` in the [OpenHarmony/arkui_napi](https://gitee.com/openharmony/arkui_napi/tree/master) repository. #### Registering the Module @@ -494,7 +494,7 @@ This example describes how to invoke a JS callback in a non-JS thread. For examp ### Implementation -You can obtain the complete code from `sample/native_module_callback/` in the **arkui_napi** repository. +You can obtain the complete code from `sample/native_module_callback/` in the [OpenHarmony/arkui_napi](https://gitee.com/openharmony/arkui_napi/tree/master) repository. #### Registering the Module @@ -562,7 +562,7 @@ void callbackTest(CallbackContext* context) uv_queue_work( loop, work, - // This callback is executed in another common thread to process tasks asynchronously. After the callback is complete, execute the next callback. In this scenario, the callback does not need to execute any task. + // This callback is executed in another common thread to process tasks asynchronously. After the callback is complete, execute the next callback. In this scenario, this callback does not need to execute any task. [](uv_work_t* work) {}, // This callback is executed in the JS thread bound to env. [](uv_work_t* work, int status) { diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index f44905cb2c2d33a8efb52f80d01e199e674e2c5b..77038cc101186059e9377c85d8e5b880784c2b9e 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -9,6 +9,5 @@ - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](package-structure.md) - [Application Package Structure Configuration File (Stage Model)](stage-structure.md) - - [Resource File Categories](basic-resource-file-categories.md) - [SysCap](syscap.md) - [HarmonyAppProvision Configuration File](app-provision-structure.md) diff --git a/en/application-dev/quick-start/basic-resource-file-categories.md b/en/application-dev/quick-start/basic-resource-file-categories.md deleted file mode 100644 index e37a24074d5396103b9204f3c6ab20a745de2616..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/basic-resource-file-categories.md +++ /dev/null @@ -1,79 +0,0 @@ -# Resource File Categories - - -## resources Directory - -All the application resource files, such as strings, images, and audio files, are stored in the **resources** directory, allowing you to easily access, use, and maintain them. The **resources** directory consists of two types of sub-directories: the **base** sub-directory and qualifiers sub-directories, and the **rawfile** sub-directory. For details, see Categories of the **resources** directory. - -Example of the **resources** directory: - -``` -resources -|---base // Default sub-directory -| |---element -| | |---string.json -| |---media -| | |---icon.png -|---en_GB-vertical-car-mdpi // Example of a qualifiers sub-directory, which needs to be created on your own -| |---element -| | |---string.json -| |---media -| | |---icon.png -|---rawfile // Default sub-directory -``` - -**Table 1** Categories of the **resources** directory - -| Category | base and Qualifiers Sub-directories | rawfile Sub-directory | -| ----------- | ---------------------------------------- | ---------------------------------------- | -| Structure | Sub-directories are structured in two levels. The directory name must comply with specified naming conventions so that its target resource file in the correct directory can be matched based on the device status.<br/> The **base** sub-directory and qualifiers sub-directories are the first level of sub-directories under **resources**.<br/>- The **base** sub-directory is generated by default. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced.<br/>- You need to create qualifiers sub-directories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).<br/>Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.<br/>However, resource files in the **rawfile** sub-directory will not be matched based on the device status. | -| Compilation | Resource files in the sub-directories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | -| Reference | Resource files in the sub-directories are referenced based on the resource type and resource name. | Resource files in the sub-directories are referenced based on the specified file path and file name. | - - -## Qualifiers Sub-directories - -The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-). When creating a qualifiers sub-directory, you need to understand the directory naming conventions and the rules for matching qualifiers sub-directories and the device status. - -**Naming Conventions for Qualifiers Sub-directories** - -- Qualifiers are ordered in the following sequence: _MCC_MNC-language_script_country/region-screen orientation-device type-color mode-screen density_. You can select one or multiple qualifiers to name your sub-directory based on your application scenarios and device characteristics. - -- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. - -- Value range of qualifiers: The value of each qualifier must meet the requirements. Otherwise, the resource files in the sub-directory cannot be matched. - - **Table 2** Requirements for qualifier values - - | Qualifier Type | Description and Value Range | - | ------------------ | ---------------------------------------- | - | MCC&MNC | Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (_) in between or be used independently. For example, **mcc460** represents China, and **mcc460_mnc00** represents China Mobile.<br/>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions). | - | Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.<br/>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages). | - | Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, **Hans** indicates simplified Chinese and **Hant** indicates traditional Chinese.<br/>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts). | - | Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, **CN** indicates China and **GB** indicates the United Kingdom.<br/>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions). | - | Screen orientation | Indicates the screen orientation of the device. The value can be:<br/>- **vertical**: portrait orientation<br/>- **horizontal**: landscape orientation | - | Device type | Indicates the device type. The value can be:<br/>- **car**: head units<br/>- **tv**: smart TVs<br/>- **wearable**: wearables | - | Color mode | Indicates the color mode of the device. The value can be:<br/>- **dark**: dark mode<br/>- **light**: light mode | - | Screen density | Indicates the screen density of the device, in dpi. The value can be:<br/>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br/>- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].<br/>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br/>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br/>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br/>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640]. | - -**Rules for Matching Qualifiers Sub-directories and Device Resources** - -- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density - -- If the qualifiers sub-directories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the sub-directories can be used for matching the device resources. For example, the qualifiers sub-directory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**. - - -## Resource Group Sub-directories - -You can create resource group sub-directories (including element, media, animation, layout, graphic, and profile) in the **base** and qualifiers sub-directories to store resource files of specific types. For details, see Resource group sub-directories. - -**Table 3** Resource group sub-directories - -| Resource Group Sub-directory | Description | Resource File | -| ---------------------------- | ---------------------------------------- | ---------------------------------------- | -| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:<br/>- **boolean**: boolean data<br/>- **color**: color data<br/>- **float**: floating-point data<br/>- **intarray**: array of integer<br/>- **integer**: integer data<br/>- **pattern**: pattern data<br/>- **plural**: plural form data<br/>- **strarray**: array of strings<br/>- **string**: string data | It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:<br/>- boolean.json<br/>- color.json<br/>- float.json<br/>- intarray.json<br/>- integer.json<br/>- pattern.json<br/>- plural.json<br/>- strarray.json<br/>- string.json | -| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | -| animation | Indicates animation resources, in XML format. | The file name can be customized, for example, **zoom_in.xml**. | -| layout | Indicates layout resources, in XML format. | The file name can be customized, for example, **home_layout.xml**. | -| graphic | Indicates graphic resources, in XML format. | The file name can be customized, for example, **notifications_dark.xml**. | -| profile | Indicates other types of files, which are stored in their raw formats. | The file name can be customized. | diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png b/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png new file mode 100644 index 0000000000000000000000000000000000000000..048b8e07817272b759781df104c1dd4526685d61 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655128646.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655128939.png b/en/application-dev/quick-start/figures/en-us_image_0000001655128939.png new file mode 100644 index 0000000000000000000000000000000000000000..606ce3a0eab0a39f166029182bcc2f70291740d6 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655128939.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655128998.png b/en/application-dev/quick-start/figures/en-us_image_0000001655128998.png new file mode 100644 index 0000000000000000000000000000000000000000..d044d5d829ab1ad805f4ffcda19837f867b976fc Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655128998.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129041.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129041.png new file mode 100644 index 0000000000000000000000000000000000000000..2dd664a2b25751cc32bd81927b30036d5cc4f351 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129041.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129232.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129232.png new file mode 100644 index 0000000000000000000000000000000000000000..7d3222667d7bffe89a148dc3b08861a86c43713e Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129232.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129264.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129264.png new file mode 100644 index 0000000000000000000000000000000000000000..c188c864c051f68984ecc0c4c64be83f0dd6e1e9 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129264.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129333.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129333.png new file mode 100644 index 0000000000000000000000000000000000000000..b42f2e3896d334d86e89b867cf3428782f88d600 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129333.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129372.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129372.png new file mode 100644 index 0000000000000000000000000000000000000000..8541c80810d3f3dfb7180fede34a51221dc56106 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129372.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001655129398.png b/en/application-dev/quick-start/figures/en-us_image_0000001655129398.png new file mode 100644 index 0000000000000000000000000000000000000000..2dda1a5cfca8d75d70e40b8bc0d555faade04583 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001655129398.png differ diff --git a/en/application-dev/quick-start/full-sdk-switch-guide.md b/en/application-dev/quick-start/full-sdk-switch-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..4c20e429bdef97ab0503614d01f1807e56eedb13 --- /dev/null +++ b/en/application-dev/quick-start/full-sdk-switch-guide.md @@ -0,0 +1,98 @@ +# Guide to Switching to Full SDK + +Both the public SDK and full SDK are toolkits for application development. + +The public SDK is intended for application developers and provided as standard in DevEco Studio. It does not contain system APIs – APIs required by system applications. + +The full SDK is intended for original equipment manufacturers (OEMs) and provided separately. It contains system APIs. + +The SDK of API version 8 provided in DevEco Studio is a public SDK. If your project depends on any system API, such as the **animator** component, **xcomponent** component, or APIs in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, or **@ohos.bluetooth.d.ts**, switch to the full SDK by performing the following steps. + +## Downloading the Full SDK (of 3.1.1 Release in this example) + +Manually download the full SDK. For details, see the source code acquisition section in [OpenHarmony 3.1.1 Release](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.1.1-release.md). + + + + + + +## Checking the Local SDK Location<br>In this example, an eTS project is used. For a JS project, replace **ets** with **js**. + +In DevEco Studio, choose **Tools** > **OpenHarmony SDK Manager** to check the location of the local SDK. + + + + + + +## Replacing the SDK + +1. Make sure the downloaded SDK is a full SDK. + + a. Verify that the name of the downloaded file contains **sdk-full**. + +  + + b. Verify that the SDK contains system APIs (such as APIs defined in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, and **@ohos.bluetooth.d.ts**). + + Note: The criteria for identifying system APIs are subject to the released API documentation. + + + +2. Replace the SDK. The following uses full SDK 3.1.6.6 for Windows as an example. + + + + a. Decompress the downloaded full SDK file: `ets-windows-3.1.6.5-Release.zip` + +  + + b. Replace the SDK files. + + Back up the local SDK files. (Copy and rename the version number directory in the **ets** directory, or copy the entire **ets** directory to another local path.) + + Go to the obtained location of the local installed SDK and back up the files therein. + +  + + Note: The name of the backup version number directory must be different from the value of **version** field in the **oh-uni-package.json** file. In the example below, the name of the backup version number directory is **3.1.6.6_backup**. + +  + + The configuration in the **oh-uni-package.json** file is as follows: + + ``` + { + "apiVersion": "8", + "displayName": "Ets", + "meta": { + "metaVersion": "3.0.0" + }, + "path": "ets", + "releaseType": "Release", + "version": "3.1.6.6" + } + ``` + + **Delete all files in the original SDK (3.1.6.6) directory.** Failure to do so may result in some files being unable to be overwritten. + + + + Copy the full SDK to the location of the local SDK. + + Copy all files in the **ets** directory in the full SDK to the **ets\3.1.6.6** directory in the location of the local SDK. + + Change the value of **version** in the **oh-uni-package.json** file to the current SDK version number. + + + + In the **3.1.6.6\build-tools\ets-loader** directory, open the **cmd/powerShell** window and run the **npm install** command to download the **node_modules** dependency package. + +  + + + + c. Check for system APIs. + +  diff --git a/en/application-dev/reference/Readme-EN.md b/en/application-dev/reference/Readme-EN.md index 30bb3aacd85d9e11012fb66dc276a88476139126..f2ee2ee4ab190bcd3487aaca974a153c0aed914e 100644 --- a/en/application-dev/reference/Readme-EN.md +++ b/en/application-dev/reference/Readme-EN.md @@ -1,9 +1,9 @@ # Development References -- [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md) -- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) +- [Component Reference(TypeScript-based Declarative Development Paradigm)](arkui-ts/Readme-EN.md) +- [Component Reference(JavaScript-based Web-like Development Paradigm)](arkui-js/Readme-EN.md) - [APIs](apis/Readme-EN.md) - + - [JS (eTS Included) APIs](apis/Readme-EN.md) - Native APIs - [Standard Library](native-lib/third_party_libc/musl.md) diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 4646544abd6e22a632a35faeba6184819d601097..6b5bbc8aa3d671c4cf0b01316db441d33c0f189f 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -1,53 +1,61 @@ # APIs +- [API Reference Document Description](development-intro.md) + - Ability Framework - - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md) - - [@ohos.ability.errorCode](js-apis-ability-errorCode.md) - - [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md) - - [@ohos.application.Ability](js-apis-application-ability.md) - - [@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) - - [@ohos.ability.featureAbility](js-apis-featureAbility.md) - - [@ohos.application.formBindingData](js-apis-formbindingdata.md) - - [@ohos.application.FormExtension](js-apis-formextension.md) - - [@ohos.application.formError](js-apis-formerror.md) - - [@ohos.application.formHost](js-apis-formhost.md) - - [@ohos.application.formInfo](js-apis-formInfo.md) - - [@ohos.application.missionManager](js-apis-missionManager.md) - - [@ohos.application.formProvider](js-apis-formprovider.md) - - [@ohos.ability.particleAbility](js-apis-particleAbility.md) - - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) - - [@ohos.application.StartOptions](js-apis-application-StartOptions.md) - - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) - - [@ohos.application.uriPermissionManager](js-apis-uripermissionmanager.md) - - [@ohos.application.Want](js-apis-application-Want.md) - - [@ohos.wantAgent](js-apis-wantAgent.md) - - 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) - - application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md) - - application/[AbilityStageContext](js-apis-abilitystagecontext.md) - - application/[Context](js-apis-application-context.md) - - application/[ExtensionContext](js-apis-extension-context.md) - - application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md) - - application/[FormExtensionContext](js-apis-formextensioncontext.md) - - application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) - - application/[PermissionRequestResult](js-apis-permissionrequestresult.md) - - 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) - + - FA Model + - [@ohos.ability.featureAbility](js-apis-featureAbility.md) + - [@ohos.ability.particleAbility](js-apis-particleAbility.md) + - ability/[dataAbilityHelper](js-apis-dataAbilityHelper.md) + - app/[context](js-apis-Context.md) + - Stage Model + - [@ohos.application.Ability](js-apis-application-ability.md) + - [@ohos.application.AbilityConstant](js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage](js-apis-application-abilitystage.md) + - [@ohos.application.abilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) + - [@ohos.application.DataShareExtensionAbility](js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.FormExtension](js-apis-formextension.md) + - [@ohos.application.ServiceExtensionAbility](js-apis-service-extension-ability.md) + - [@ohos.application.StartOptions](js-apis-application-StartOptions.md) + - [@ohos.application.StaticSubscriberExtensionAbility](js-apis-application-staticSubscriberExtensionAbility.md) + - application/[AbilityContext](js-apis-ability-context.md) + - application/[ApplicationContext](js-apis-application-applicationContext.md) + - application/[AbilityStageContext](js-apis-abilitystagecontext.md) + - application/[Context](js-apis-application-context.md) + - application/[ExtensionContext](js-apis-extension-context.md) + - application/[FormExtensionContext](js-apis-formextensioncontext.md) + - application/[PermissionRequestResult](js-apis-permissionrequestresult.md) + - application/[ServiceExtensionContext](js-apis-service-extension-context.md) + - FA and Stage Models + - [@ohos.ability.dataUriUtils](js-apis-DataUriUtils.md) + - [@ohos.ability.errorCode](js-apis-ability-errorCode.md) + - [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md) + - [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md) + - [@ohos.application.abilityManager](js-apis-application-abilityManager.md) + - [@ohos.application.appManager](js-apis-appmanager.md) + - [@ohos.application.Configuration](js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) + - [@ohos.application.EnvironmentCallback](js-apis-application-EnvironmentCallback.md) + - [@ohos.application.formBindingData](js-apis-formbindingdata.md) + - [@ohos.application.formError](js-apis-formerror.md) + - [@ohos.application.formHost](js-apis-formhost.md) + - [@ohos.application.formInfo](js-apis-formInfo.md) + - [@ohos.application.formProvider](js-apis-formprovider.md) + - [@ohos.application.missionManager](js-apis-missionManager.md) + - [@ohos.application.Want](js-apis-application-Want.md) + - [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md) + - [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md) + - [@ohos.wantAgent](js-apis-wantAgent.md) + - application/[abilityDelegator](js-apis-application-abilityDelegator.md) + - application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md) + - application/[abilityMonitor](js-apis-application-abilityMonitor.md) + - application/[AbilityRunningInfo](js-apis-abilityrunninginfo.md) + - application/[ExtensionRunningInfo](js-apis-extensionrunninginfo.md) + - application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) + - application/[ProcessRunningInfo](js-apis-processrunninginfo.md) + - application/[shellCmdResult](js-apis-application-shellCmdResult.md) + - continuation/[ContinuationResult](js-apis-continuation-continuationResult.md) - Common Event and Notification - [@ohos.commonEvent](js-apis-commonEvent.md) @@ -55,7 +63,7 @@ - [@ohos.notification](js-apis-notification.md) - [@ohos.reminderAgent](js-apis-reminderAgent.md) - application/[EventHub](js-apis-eventhub.md) - + - Bundle Management - [@ohos.bundle](js-apis-Bundle.md) @@ -66,26 +74,30 @@ - bundle/[ApplicationInfo](js-apis-bundle-ApplicationInfo.md) - bundle/[BundleInfo](js-apis-bundle-BundleInfo.md) - bundle/[CustomizeData](js-apis-bundle-CustomizeData.md) + - bundle/[ElementName](js-apis-bundle-ElementName.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 - [@ohos.animator](js-apis-animator.md) - [@ohos.mediaquery](js-apis-mediaquery.md) - [@ohos.prompt](js-apis-prompt.md) - [@ohos.router](js-apis-router.md) - + - [@ohos.uiAppearance](js-apis-uiappearance.md) + - Graphics - [@ohos.display ](js-apis-display.md) + - [@ohos.effectKit](js-apis-effectKit.md) + - [@ohos.screen](js-apis-screen.md) - [@ohos.screenshot](js-apis-screenshot.md) - [@ohos.window](js-apis-window.md) - [webgl](js-apis-webgl.md) - [webgl2](js-apis-webgl2.md) - + - Media - [@ohos.multimedia.audio](js-apis-audio.md) @@ -93,41 +105,46 @@ - [@ohos.multimedia.image](js-apis-image.md) - [@ohos.multimedia.media](js-apis-media.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) - + - Resource Management + - [@ohos.i18n](js-apis-i18n.md) - [@ohos.intl](js-apis-intl.md) - [@ohos.resourceManager](js-apis-resource-manager.md) - + - Resource Scheduling - [@ohos.backgroundTaskManager](js-apis-backgroundTaskManager.md) - [@ohos.workScheduler ](js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility](js-apis-WorkSchedulerExtensionAbility.md) - + - Custom Management - [@ohos.configPolicy](js-apis-config-policy.md) - [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md) - [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md) - + - Security - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) + - [@ohos.privacyManager](js-apis-privacyManager.md) - [@ohos.security.huks ](js-apis-huks.md) - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md) - [@system.cipher](js-apis-system-cipher.md) - + - Data Management - [@ohos.data.dataAbility ](js-apis-data-ability.md) + - [@ohos.data.dataShare](js-apis-data-dataShare.md) + - [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md) + - [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md) - [@ohos.data.distributedData](js-apis-distributed-data.md) - [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md) - [@ohos.data.preferences](js-apis-data-preferences.md) - [@ohos.data.rdb](js-apis-data-rdb.md) - - [@ohos.settings](js-apis-settings.md) + - [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md) - data/rdb/[resultSet](js-apis-data-resultset.md) - + - File Management - [@ohos.document](js-apis-document.md) @@ -138,7 +155,7 @@ - [@ohos.storageStatistics](js-apis-storage-statistics.md) - [@ohos.volumeManager](js-apis-volumemanager.md) - [@ohos.securityLabel](js-apis-securityLabel.md) - + - Telephony Service - [@ohos.contact](js-apis-contact.md) @@ -148,14 +165,15 @@ - [@ohos.telephony.sim](js-apis-sim.md) - [@ohos.telephony.sms](js-apis-sms.md) - [@ohos.telephony.data](js-apis-telephony-data.md) - + - Network Management + - [@ohos.net.connection](js-apis-net-connection.md) - [@ohos.net.http](js-apis-http.md) - [@ohos.request](js-apis-request.md) - [@ohos.net.socket](js-apis-socket.md) - [@ohos.net.webSocket](js-apis-webSocket.md) - + - Connectivity - [@ohos.bluetooth](js-apis-bluetooth.md) @@ -166,7 +184,7 @@ - [@ohos.rpc](js-apis-rpc.md) - [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifiext](js-apis-wifiext.md) - + - Basic Features - [@ohos.accessibility](js-apis-accessibility.md) @@ -185,7 +203,7 @@ - [@ohos.systemTime](js-apis-system-time.md) - [@ohos.wallpaper](js-apis-wallpaper.md) - [Timer](js-apis-timer.md) - + - Device Management - [@ohos.batteryInfo ](js-apis-battery-info.md) @@ -205,18 +223,19 @@ - [@ohos.power](js-apis-power.md) - [@ohos.runningLock](js-apis-runninglock.md) - [@ohos.sensor](js-apis-sensor.md) + - [@ohos.settings](js-apis-settings.md) - [@ohos.systemParameter](js-apis-system-parameter.md) - [@ohos.thermal](js-apis-thermal.md) - [@ohos.update](js-apis-update.md) - [@ohos.usb](js-apis-usb.md) - [@ohos.vibrator](js-apis-vibrator.md) - + - Account Management - [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.osAccount](js-apis-osAccount.md) - + - Language Base Class Library - [@ohos.convertxml](js-apis-convertxml.md) @@ -240,11 +259,12 @@ - [@ohos.util.Vector](js-apis-vector.md) - [@ohos.worker](js-apis-worker.md) - [@ohos.xml](js-apis-xml.md) - + - Test + - [@ohos.application.testRunner](js-apis-testRunner.md) - [@ohos.uitest](js-apis-uitest.md) - + - APIs No Longer Maintained - [@ohos.bytrace](js-apis-bytrace.md) diff --git a/en/application-dev/reference/apis/development-intro.md b/en/application-dev/reference/apis/development-intro.md new file mode 100644 index 0000000000000000000000000000000000000000..8528a10ab6f4ba3dd14186079357ce28e650ee6a --- /dev/null +++ b/en/application-dev/reference/apis/development-intro.md @@ -0,0 +1,51 @@ +# API Reference Document Description + +API references provide the description of APIs used for application development. This topic describes common fields in the API references to help you better use the reference document. + +## Version Description + +In API references, the earliest versions of APIs and components are specified in the following ways: + +- For a new API or component, the version information is provided at the beginning of the reference document. Example: "The initial APIs of this module are supported since API version 7." +- For a new feature of an existing API or component, a superscript is added following the feature. For example, "uid<sup>8+</sup>" indicates that the **uid** attribute is supported since API version 8. + +## Ability Framework Model Description + +Ability is the minimum unit for the system to schedule applications. An application can contain one or more `Ability` instances. Ability framework models are classified into the FA model and stage model. For details, see [Ability Framework Overview](../../ability/ability-brief.md). + +- If all the APIs of a module support only one model, the following description is provided at the beginning of the reference document: "The APIs of this module can be used only in the FA model." or "The APIs of this module can be used only in the stage model." +- If certain APIs of a module support only one model, the following description is provided individually for these APIs: "This API can be used only in the FA model." or "This API can be used only in the stage model." +- If both models are supported, no special description is provided. + +## Available APIs + +Certain APIs provided by OpenHarmony are system APIs, which can be used only by original equipment manufacturers (OEMs) and cannot be used by non-system applications. + +A description regarding system APIs will be provided in the document. + +- If all the APIs of a module are system APIs, the following description is provided at the beginning of the reference document: "All the APIs of this module are system APIs." +- If a specific API of a module is a system API, the following description is provided individually for the API: "This is a system API." + +## Permission Description + +By default, applications can access limited system resources. However, in some cases, an application needs to access excess data (including personal data) and functions of the system or another application to implement extended functions. For details, see [Access Control Overview](../../security/accesstoken-overview.md). + +To call APIs to access these resources, you must apply for the corresponding permissions by following the instructions provided in [Access Control Development](../../security/accesstoken-guidelines.md). + +- If an application can call an API only after it has obtained a specific permission, the following description is provided for the API: "**Required permissions**: ohos.permission.xxxx" +- If an application can call an API without any permission, no special description is provided. + +To determine whether an application can apply for a specific permission, see [Permission List](../../security/permission-list.md). + +## System Capability Description + +System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see [SysCap](../../quick-start/syscap.md). + +The following description is provided for each API in the reference document to describe the system capability of the API: "**System capability**: SystemCapability.xxx.xxx" + +## Sample Code Language Description + +OpenHarmony supports two development languages: JS and TS. + +- When a code block is labeled with `js`, the sample code can be used in the JS and eTS projects. +- When a code block is labeled with `ts`, the sample code can be used only in the eTS project. diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index 20e8f1573b48402b5561e69c1a67ac0c6a1dd9ea..409cb84c143a04dc46ec010fe9323f009b66c7ab 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -1,14 +1,14 @@ # Bundle -The **Bundle** module provides APIs for querying bundle information, application information, abilities, Extension abilities, and application states. +The **Bundle** module provides APIs for querying the information about bundles, applications, abilities, Extension abilities, and application states. > **NOTE** -> +> > 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. > API version 9 is a canary version for trial use. The APIs of this version may be unstable. ## Modules to Import -``` +```js import bundle from '@ohos.bundle'; ``` @@ -23,8 +23,9 @@ SystemCapability.BundleManager.BundleFramework | ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about a specified application. | | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED| system_basic | Permission to query information about all applications.| | ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications. | +| ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | Permission to set and query the application disposal status. | -For details, see “Permission Levels†in [Access Control Overview](../../security/accesstoken-overview.md). +For details, see "Permission Levels" in [Access Control Overview](../../security/accesstoken-overview.md). ## bundle.getApplicationInfo @@ -44,7 +45,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | @@ -68,8 +69,6 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId) }) ``` - - ## bundle.getApplicationInfo getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback\<ApplicationInfo>): void @@ -88,7 +87,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | | callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | @@ -108,7 +107,6 @@ bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { }) ``` - ## bundle.getApplicationInfo getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<ApplicationInfo>): void @@ -127,7 +125,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | callback | AsyncCallback\<[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)> | Yes | Callback used to return the application information. | @@ -145,7 +143,6 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => { }) ``` - ## bundle.getAllBundleInfo getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise<Array\<BundleInfo>> @@ -186,8 +183,6 @@ bundle.getAllBundleInfo(bundleFlag, userId) }) ``` - - ## bundle.getAllBundleInfo getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback<Array\<BundleInfo>>): void @@ -222,7 +217,6 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => { }) ``` - ## bundle.getAllBundleInfo getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback<Array\<BundleInfo>>): void @@ -259,8 +253,6 @@ bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { }) ``` - - ## bundle.getBundleInfo getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\<BundleInfo> @@ -279,7 +271,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | options | [BundleOptions](#bundleoptions) | No | Includes **userId**. | @@ -305,8 +297,6 @@ bundle.getBundleInfo(bundleName, bundleFlags, options) }) ``` - - ## bundle.getBundleInfo getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\<BundleInfo>): void @@ -325,7 +315,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | -------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information 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 bundle information. | @@ -362,7 +352,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | -------------------------- | ---- | --------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| | options | [BundleOptions](#bundleoptions) | Yes | Includes **userId**. | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the bundle information. | @@ -384,6 +374,466 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { }) ``` +## bundle.getBundleInstaller + +getBundleInstaller(): Promise<BundleInstaller>; + +Obtains the installation package information. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | -------------------------------------------- | +| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Promise used to return the installation package information.| + +## bundle.getBundleInstaller + +getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void; + +Obtains the installation package information. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | Yes | Callback used to return the installation package information.| + +## bundle.cleanBundleCacheFiles<sup>8+</sup> + +cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback<void>): void; + +Clears the cache data of an application. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.REMOVE_CACHE_FILES + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------- | ---- | ------------------------------------- | +| bundleName | string | Yes | Bundle name of an application.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +## bundle.cleanBundleCacheFiles<sup>8+</sup> + +cleanBundleCacheFiles(bundleName: string): Promise<void> + +Clears the cache data of an application. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.REMOVE_CACHE_FILES + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------------------------- | +| bundleName | string | Yes | Bundle name of an application.| + +**Return value** + +| Type | Description | +| ------------- | ------------------------------------ | +| Promise\<void> | Promise that returns no value.| + +## bundle.setApplicationEnabled<sup>8+</sup> + +setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback<void>): void; + +Sets whether to enable an application. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------- | ---- | ----------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +## bundle.setApplicationEnabled<sup>8+</sup> + +setApplicationEnabled(bundleName: string, isEnable: boolean): Promise<void> + +Sets whether to enable an application. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------- | ---- | ----------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| isEnable | boolean | Yes | Whether to enable the application. The value **true** means to enable the application, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ------------- | ------------------------------------ | +| Promise\<void> | Promise that returns no value.| + +## bundle.setAbilityEnabled<sup>8+</sup> + +setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback<void>): void; + +Sets whether to enable an ability. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ----------------------------------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | +| isEnable | boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +## bundle.setAbilityEnabled<sup>8+</sup> + +setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise<void> + +Sets whether to enable an ability. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------- | ---- | ----------------------------------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. | +| isEnable | boolean | Yes | Whether to enable the ability. The value **true** means to enable the ability, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ------------- | ------------------------------------ | +| Promise\<void> | Promise that returns no value.| + +## bundle.getPermissionDef<sup>8+</sup> + +getPermissionDef(permissionName: string, callback: AsyncCallback<PermissionDef>): void; + +Obtains the permission details by permission name. This API uses an asynchronous callback to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | +| permissionName | string | Yes | Name of the permission. | +| callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | Yes | Callback used to return the permission details.| + +## bundle.getPermissionDef<sup>8+</sup> + +getPermissionDef(permissionName: string): Promise<PermissionDef> + +Obtains the permission details by permission name. This API uses a promise to return the result. + +**Required permissions** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | ---------------- | +| permissionName | string | Yes | Name of the permission.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | +| Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | Promise used to return the permission details.| + +## bundle.setModuleUpgradeFlag<sup>9+</sup> + +setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback<void>):void; + +Sets whether the module needs an upgrade. This API uses an asynchronous callback to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| moduleName | string | Yes | Module name of the application. | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is used only by the internal system. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +## bundle.setModuleUpgradeFlag<sup>9+</sup> + +setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise<void> + +Sets whether the module needs an upgrade. This API uses a promise to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| moduleName | string | Yes | Module name of the application. | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | Yes | Upgrade flag, which is used only by the internal system.| + +**Return value** + +| Type | Description | +| ------------- | ------------------------------------ | +| Promise\<void> | Promise that returns no value.| + +## bundle.isModuleRemovable<sup>9+</sup> + +isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback<boolean>): void; + +Checks whether a module is removable. This API uses an asynchronous callback to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ---------------------- | ---- | --------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| moduleName | string | Yes | Module name of the application. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.| + +## bundle.isModuleRemovable<sup>9+</sup> + +isModuleRemovable(bundleName: string, moduleName: string): Promise<boolean> + +Checks whether a module is removable. This API uses a promise to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ------------------ | +| bundleName | string | Yes | Bundle name of an application. | +| moduleName | string | Yes | Module name of the application.| + +**Return value** + +| Type | Description | +| ---------------- | ---------------------------- | +| Promise<boolean> | Promise used to return the result. If the module is removable, **true** is returned. Otherwise, **false** is returned.| + +## bundle.getBundlePackInfo<sup>9+</sup> + +getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback<pack.BundlePackInfo>): void; + +Obtains the bundle package information based on a given bundle name and bundle flags. This API uses an asynchronous callback to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ---------------------------------- | ---- | ---------------------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package. | +| callback | AsyncCallback<pack.BundlePackInfo> | Yes | Callback used to return the bundle package information.| + +## bundle.getBundlePackInfo<sup>9+</sup> + +getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise<pack.BundlePackInfo>; + +Obtains the bundle package information based on a given bundle name and bundle flags. This API uses a promise to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------- | ---- | ---------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| bundlePackFlag | pack.BundlePackFlag | Yes | Flags of the bundle package.| + +**Return value** + +| Type | Description | +| ---------------------------- | ----------------------------------- | +| Promise<pack.BundlePackInfo> | Promise used to return the bundle package information.| + +## bundle.getDispatcherVersion<sup>9+</sup> + +getDispatcherVersion(callback: AsyncCallback<DispatchInfo>): void; + +Obtains the dispatcher version. This API uses an asynchronous callback to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[DispatchInfo](js-apis-dispatchInfo.md)> | Yes | Callback used to return the [DispatchInfo](js-apis-dispatchInfo.md).| + +## bundle.getDispatcherVersion<sup>9+</sup> + +getDispatcherVersion(): Promise<DispatchInfo>; + +Obtains the dispatcher version. This API uses a promise to return the result. + +**System capability** + +SystemCapability.BundleManager.BundleFramework + +**System API** + +This is a system API and cannot be called by third-party applications. + +**Return value** + +| Type | Description | +| ------------------------------------------------ | ------------------------------------------------------------ | +| Promise<[DispatchInfo](js-apis-dispatchInfo.md)> | Promise used to return the [DispatchInfo](js-apis-dispatchInfo.md).| ## bundle.getAllApplicationInfo @@ -584,7 +1034,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| **Return value** @@ -624,7 +1074,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| | callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.| @@ -659,7 +1109,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | moduleName | string | Yes | Module name of the application. | | abilityName | string | Yes | Ability name.| @@ -701,7 +1151,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | moduleName | string | Yes | Module name of the application. | | abilityName | string | Yes | Ability name.| | callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | Callback used to return the ability information.| @@ -739,7 +1189,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| **Return value** @@ -779,7 +1229,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------- | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | abilityName | string | Yes | Ability name.| | callback | AsyncCallback\<string> | Yes | Callback used to return the application name. | @@ -814,7 +1264,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ------ | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | moduleName | string | Yes | Module name of the application. | | abilityName | string | Yes | Ability name.| @@ -856,7 +1306,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ----------- | ---------------------- | ---- | ---------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | moduleName | string | Yes | Module name of the application. | | abilityName | string | Yes | Ability name.| | callback | AsyncCallback\<string> | Yes | Callback used to return the application name. | @@ -959,7 +1409,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | -| bundleName | string | Yes | Bundle name of the application.| +| bundleName | string | Yes | Bundle name of an application.| **Return value** @@ -993,7 +1443,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ----------------------- | ---- | --------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | callback | AsyncCallback\<boolean> | Yes | Callback used to return whether the ability is enabled. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.| **Example** @@ -1156,7 +1606,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------ | -| bundleName | string | Yes | Bundle name of the application.| +| bundleName | string | Yes | Bundle name of an application.| **Return value** | Type | Description | @@ -1193,7 +1643,7 @@ SystemCapability.BundleManager.BundleFramework | Name | Type | Mandatory | Description | | ---------- | -------------------- | ---- | ------------------------------ | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | Yes | Callback used to return the **Want** object.| **Example** @@ -1278,7 +1728,7 @@ bundle.getNameForUid(uid, (err, data) => { getAbilityIcon(bundleName: string, abilityName: string): Promise\<image.PixelMap>; -Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result. +Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses a promise to return the result. **Required permissions** @@ -1298,7 +1748,7 @@ SystemCapability.BundleManager.BundleFramework **Return value** | Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise\<image.PixelMap> | Promise used to return the [PixelMap](js-apis-image.md).| +| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).| **Example** @@ -1317,7 +1767,7 @@ bundle.getAbilityIcon(bundleName, abilityName) getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void; -Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result. +Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name and ability name. This API uses an asynchronous callback to return the result. **Required permissions** @@ -1333,7 +1783,7 @@ SystemCapability.BundleManager.BundleFramework | ----------- | ---------------------------------------- | ---- | ---------------------------------------- | | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | -| callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [PixelMap](js-apis-image.md).| +| callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [pixel map](js-apis-image.md).| **Example** @@ -1353,11 +1803,11 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise\<image.PixelMap>; -Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses a promise to return the result. +Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses a promise to return the result. **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1374,7 +1824,7 @@ SystemCapability.BundleManager.BundleFramework **Return value** | Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise\<image.PixelMap> | Promise used to return the [PixelMap](js-apis-image.md).| +| Promise\<image.PixelMap> | Promise used to return the [pixel map](js-apis-image.md).| **Example** @@ -1394,11 +1844,11 @@ bundle.getAbilityIcon(bundleName, moduleName, abilityName) getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback\<image.PixelMap>): void; -Obtains the [PixelMap](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. +Obtains the [pixel map](js-apis-image.md) of the icon corresponding to a given bundle name, module name, and ability name. This API uses an asynchronous callback to return the result. **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1411,7 +1861,7 @@ SystemCapability.BundleManager.BundleFramework | bundleName | string | Yes | Bundle name based on which the pixel map is to obtain. | | moduleName | string | Yes | Module name based on which the pixel map is to obtain. | | abilityName | string | Yes | Ability name based on which the pixel map is to obtain. | -| callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [PixelMap](js-apis-image.md).| +| callback | AsyncCallback\<image.PixelMap> | Yes | Callback used to return the [pixel map](js-apis-image.md).| **Example** @@ -1528,7 +1978,7 @@ Obtains the Extension ability information based on a given want. This API uses a **Required permissions** -ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO **System capability** @@ -1693,6 +2143,142 @@ bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataNa }) ``` +## bundle.setDisposedStatus<sup>9+</sup> + +setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\<void>): void; + +Sets the disposal status for an application based on a given bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| status | number | Yes | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed. | +| callback | AsyncCallback\<void> | Yes | Callback that returns no value. | + +**Example** + +```js +let bundleName = 'com.ohos.camera'; +let status = 1; +const caller = function callback(err, data) { + console.error('Operation err is: ' + err); + console.error('Operation result is: ' + data); +} +bundle.setDisposedStatus(bundleName, status, caller) +``` + +## bundle.setDisposedStatus<sup>9+</sup> + +setDisposedStatus(bundleName: string, status: number): Promise\<void>; + +Sets the disposal status for an application based on a given bundle name. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| status | number | Yes | Disposal status to set. This parameter is reserved for the application market. The default value is **0**, indicating that no disposal is performed. | + +**Return value** + +| Type | Description | +| ------------------------------------- | ------------------------------ | +| Promise\<void> | Promise that returns no value.| + +**Example** + +```js +let bundleName = 'com.ohos.camera'; +let status = 1; + +bundle.setDisposedStatus(bundleName, status).then(data=>{ + console.error('Operation result is: ' + data); +}).catch(err=>{ + console.error('Operation err is: ' + err); +}) +``` + +## bundle.getDisposedStatus<sup>9+</sup> + +getDisposedStatus(bundleName: string, callback: AsyncCallback\<number>): void; + +Obtains the disposal status of an application based on a given bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | +| callback | AsyncCallback\<number> | Yes | Callback used to return the disposal status. | + +**Example** + +```js +let bundleName = 'com.ohos.camera'; +const caller = function callback(err, data) { + console.error('Operation err is: ' + err); + console.error('Operation result is: ' + data); +} +bundle.getDisposedStatus(bundleName, caller) +``` + +## bundle.getDisposedStatus<sup>9+</sup> + +getDisposedStatus(bundleName: string): Promise\<number>; + +Obtains the disposal status of an application based on a given bundle name. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_DISPOSED_APP_STATUS + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------------- | ---------------------------------- | ---- | ---------------------------------------- | +| bundleName | string | Yes | Bundle name of an application. | + +**Return value** + +| Type | Description | +| ------------------------------------- | ------------------------------ | +| Promise\<number> | Promise used to return the disposal status.| + +**Example** + +```js +let bundleName = 'com.ohos.camera'; + +bundle.getDisposedStatus(bundleName).then(data=>{ + console.error('Operation result is: ' + data); +}).catch(err=>{ + console.error('Operation err is: ' + err); +}) +``` + ## InstallErrorCode **System capability**: SystemCapability.BundleManager.BundleFramework @@ -1779,15 +2365,15 @@ Enumerates display orientations. | LANDSCAPE | None | Landscape orientation. | | PORTRAIT | None | Portrait orientation. | | FOLLOW_RECENT | None | Orientation same as that of the nearest ability in the stack.| -| LANDSCAPE_INVERTED |None | Reverse landscape orientation. | -| PORTRAIT_INVERTED |None | Reverse portrait orientation. | -| AUTO_ROTATION |None | Orientation determined by the sensor. | -| AUTO_ROTATION_LANDSCAPE |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape. | -| AUTO_ROTATION_PORTRAIT |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait. | -| AUTO_ROTATION_RESTRICTED |None | Orientation determined by the sensor when the sensor switch is enabled. | -| AUTO_ROTATION_LANDSCAPE_RESTRICTED |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape, when the sensor switch is enabled. | -| AUTO_ROTATION_PORTRAIT_RESTRICTED |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait, when the sensor switch is enabled. | -| LOCKED |None | Auto rotate locked. | +| LANDSCAPE_INVERTED<sup>9+</sup> |None | Reverse landscape orientation. | +| PORTRAIT_INVERTED<sup>9+</sup> |None | Reverse portrait orientation. | +| AUTO_ROTATION<sup>9+</sup> |None | Orientation determined by the sensor. | +| AUTO_ROTATION_LANDSCAPE<sup>9+</sup> |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape. | +| AUTO_ROTATION_PORTRAIT<sup>9+</sup> |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait. | +| AUTO_ROTATION_RESTRICTED<sup>9+</sup> |None | Orientation determined by the sensor when the sensor switch is enabled. | +| AUTO_ROTATION_LANDSCAPE_RESTRICTED<sup>9+</sup> |None | Orientation determined by the sensor in the horizontal direction, including landscape and reverse landscape, when the sensor switch is enabled. | +| AUTO_ROTATION_PORTRAIT_RESTRICTED<sup>9+</sup> |None | Orientation determined by the sensor in the vertical direction, including portrait and reverse portrait, when the sensor switch is enabled. | +| LOCKED<sup>9+</sup> |None | Auto rotate disabled. | ## LaunchMode Enumerates launch modes. @@ -1827,9 +2413,12 @@ Enumerates Extension ability types. | FILE_SHARE<sup>9+</sup> | 6 | File sharing included.| | STATIC_SUBSCRIBER<sup>9+</sup> | 7 | Subscribers included. | | WALLPAPER<sup>9+</sup> | 8 | Wallpaper included. | -| BACKUP<sup>9+</sup> | 9 | Data backup and restore included.| +| BACKUP<sup>9+</sup> | 9 | Data backup and restore included.| +| WINDOW<sup>9+</sup> | 10 | Window type extension information included.| | ENTERPRISE_ADMIN<sup>9+</sup> | 11 | Enterprise administrators included. | -| UNSPECIFIED<sup>9+</sup> | 20 | Unspecified type. | +| THUMBNAIL<sup>9+</sup> | 13 | Thumbnails included.| +| PREVIEW<sup>9+</sup> | 14 | Preview included.| +| UNSPECIFIED<sup>9+</sup> | 255 | Unspecified type. | ## ExtensionFlag<sup>9+</sup> @@ -1876,6 +2465,20 @@ Enumerates window modes. | Name | Type | Description | | ------------------ | ---- | ---- | -| FULLSCREEN | None | Full screen.| -| SPLIT | None | Split-screen. | -| FLOATING | None | Floating. | +| FULL_SCREEN<sup>9+</sup> | 0 | Full screen.| +| SPLIT<sup>9+</sup> | 1 | Split-screen. | +| FLOATING<sup>9+</sup> | 2 | Floating. | + +## UpgradeFlag + +Enumerates the upgrade flags, which are for internal use only. + +**System API**: This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Value | Description | +| ----------------------------- | ---- | ---------------- | +| NOT_UPGRADE<sup>9+</sup> | 0 | No module needs an upgrade. | +| SINGLE_UPGRADE<sup>9+</sup> | 1 | A single module needs an upgrade.| +| RELATION_UPGRADE<sup>9+</sup> | 2 | The module that has a relationship with the current one needs an upgrade.| diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index 7e947ddbe0194fabeb31d1c10c44eab0dcfe1550..ce415ad942510c481755380bdd90adb7eb1c75ae 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -1,19 +1,16 @@ # Context +The **Context** module provides context for abilities or applications. It allows access to application-specific resources, as well as permission requests and verification. + > **NOTE** -> -> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> > The APIs of this module can be used only in the FA model. -## Modules to Import - -```js -import featureAbility from '@ohos.ability.featureAbility' -``` - ## Usage -The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows: +The **Context** object is created in a **featureAbility** and returned through its **getContext()** API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the **Context** module. An example is as follows: ```js import featureAbility from '@ohos.ability.featureAbility' @@ -91,7 +88,7 @@ Verifies whether a specific PID and UID have the given permission. This API uses | ---------- | --------------------------------------- | ---- | ------------------------------------- | | permission | string | Yes | Name of the permission to verify. | | options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | -| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -119,7 +116,7 @@ Verifies whether the current PID and UID have the given permission. This API use | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ------------------------------------- | | permission | string | Yes | Name of the permission to verify. | -| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| callback | AsyncCallback\<number> | Yes | Callback used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -148,7 +145,7 @@ Verifies whether a specific PID and UID have the given permission. This API uses | Type | Description | | ---------------- | ----------------------------------------------------------- | -| Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| Promise\<number> | Promise used to return the permission verification result. The value **0** means that the PID and UID have the given permission, and the value **-1** means the opposite.| **Example** @@ -255,7 +252,7 @@ context.getApplicationInfo().then((data) => { getBundleName(callback: AsyncCallback\<string>): void -Obtains the bundle name of the current ability. This API uses an asynchronous callback to return the result. +Obtains the bundle name of this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -279,7 +276,7 @@ context.getBundleName() getBundleName(): Promise\<string> -Obtains the bundle name of the current ability. This API uses a promise to return the result. +Obtains the bundle name of this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -300,6 +297,225 @@ context.getBundleName().then((data) => { }); ``` +## Context.getDisplayOrientation<sup>7+</sup> + +getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void + +Obtains the display orientation of this ability. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getDisplayOrientation() +``` + +## Context.getDisplayOrientation<sup>7+</sup> + +getDisplayOrientation(): Promise\<bundle.DisplayOrientation>; + +Obtains the display orientation of this ability. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| ---------------- | ------------------------- | +| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getDisplayOrientation().then((data) => { + console.info("=======================>getDisplayOrientationCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setDisplayOrientation<sup>7+</sup> + +setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\<void>): void + +Obtains the display orientation for this ability. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| orientation | [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes | Display orientation to set.| +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Yes | Callback used to return the display orientation.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import bundle from '@ohos.bundle' +var context = featureAbility.getContext(); +var orientation=bundle.DisplayOrientation.UNSPECIFIED +context.setDisplayOrientation(orientation, (err) => { + console.log('---------- setDisplayOrientation fail, err: -----------', err); +}); +``` + +## Context.setDisplayOrientation<sup>7+</sup> + +setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void>; + +Obtains the display orientation for this ability. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| ---------------- | ------------------------- | +| orientation | [bundle.DisplayOrientation](js-apis-bundle.md#displayorientation) | Yes | Display orientation to set.| +| Promise\<[bundle.DisplayOrientation](js-apis-bundle.md#displayorientation)> | Promise used to return the display orientation.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import bundle from '@ohos.bundle' +var context = featureAbility.getContext(); +var orientation=bundle.DisplayOrientation.UNSPECIFIED +context.setDisplayOrientation(orientation).then((data) => { + console.info("=======================>setDisplayOrientationCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setShowOnLockScreen<sup>7+</sup> + +setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void + +Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var show=true +context.setShowOnLockScreen(show, (err) => { + console.log('---------- setShowOnLockScreen fail, err: -----------', err); +}); +``` + +## Context.setShowOnLockScreen<sup>7+</sup> + +setShowOnLockScreen(show: boolean): Promise\<void>; + +Sets whether to show this feature at the top of the lock screen each time the lock screen is displayed so that the feature remains activated. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| show | boolean | Yes | Whether to show this feature at the top of the lock screen. The value **true** means to show this feature at the top of the lock screen, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ---------------- | ------------------------- | +| Promise\<void>| Promise used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var show=true +context.setShowOnLockScreen(show).then((data) => { + console.info("=======================>setShowOnLockScreenCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setWakeUpScreen<sup>7+</sup> + +setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void + +Sets whether to wake up the screen when this feature is restored. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var wakeUp=true +context.setWakeUpScreen(wakeUp, (err) => { + console.log('---------- setWakeUpScreen fail, err: -----------', err); +}); +``` + +## Context.setWakeUpScreen<sup>7+</sup> + +setWakeUpScreen(wakeUp: boolean): Promise\<void>; + +Sets whether to wake up the screen when this feature is restored. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ----------------------------- | +| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite.| + +**Return value** + +| Type | Description | +| ---------------- | ------------------------- | +| Promise\<void>| Promise used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var wakeUp=true +context.setWakeUpScreen(wakeUp).then((data) => { + console.info("=======================>setWakeUpScreenCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + + ## Context.getProcessInfo<sup>7+</sup> @@ -357,7 +573,7 @@ context.getProcessInfo().then((data) => { getElementName(callback: AsyncCallback\<ElementName>): void -Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses an asynchronous callback to return the result. +Obtains the **ohos.bundle.ElementName** object of this ability. This API uses an asynchronous callback to return the result. This API is available only to Page abilities. @@ -383,7 +599,7 @@ context.getElementName() getElementName(): Promise\<ElementName> -Obtains the **ohos.bundle.ElementName** object of the current ability. This API uses a promise to return the result. +Obtains the **ohos.bundle.ElementName** object of this ability. This API uses a promise to return the result. This API is available only to Page abilities. @@ -510,7 +726,7 @@ context.getCallingBundle().then((data) => { getCacheDir(callback: AsyncCallback\<string>): void -Obtains the cache directory of the application on the internal storage. This API uses an asynchronous callback to return the result. +Obtains the cache directory of the application in the internal storage. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -538,7 +754,7 @@ context.getCacheDir((err, data) => { getCacheDir(): Promise\<string> -Obtains the cache directory of the application on the internal storage. This API uses a promise to return the result. +Obtains the cache directory of the application in the internal storage. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -563,7 +779,7 @@ context.getCacheDir().then((data) => { getFilesDir(callback: AsyncCallback\<string>): void -Obtains the file directory of the application on the internal storage. This API uses an asynchronous callback to return the result. +Obtains the file directory of the application in the internal storage. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -591,7 +807,7 @@ context.getFilesDir((err, data) => { getFilesDir(): Promise\<string> -Obtains the file directory of the application on the internal storage. This API uses a promise to return the result. +Obtains the file directory of the application in the internal storage. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -732,7 +948,7 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | Yes | Callback used to return the **ModuleInfo** object.| +| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | Callback used to return the **ModuleInfo** object.| **Example** @@ -760,7 +976,7 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to | Type | Description | | --------------- | ------------------------- | -| Promise\<[HapModuleInfo](#hapmoduleinfo)> | Promise used to return the **ModuleInfo** object.| +| Promise\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Promise used to return the **ModuleInfo** object.| **Example** @@ -774,9 +990,9 @@ context.getHapModuleInfo().then((data) => { ## Context.getAppVersionInfo<sup>7+</sup> -getAppVersionInfo(callback: AsyncCallback\<HapModuleInfo>): void +getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void -Obtains the version information of the application. This API uses an asynchronous callback to return the result. +Obtains the version information of this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -804,7 +1020,7 @@ context.getAppVersionInfo((err, data) => { getAppVersionInfo(): Promise\<AppVersionInfo> -Obtains the version information of the application. This API uses a promise to return the result. +Obtains the version information of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -828,7 +1044,7 @@ context.getAppVersionInfo().then((data) => { getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void -Obtains information of the current ability. This API uses an asynchronous callback to return the result. +Obtains information about this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -856,7 +1072,7 @@ context.getAbilityInfo((err, data) => { getAbilityInfo(): Promise\<AbilityInfo> -Obtains information of the current ability. This API uses a promise to return the result. +Obtains information about this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -897,6 +1113,111 @@ import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext().getApplicationContext(); ``` +## Context.isUpdatingConfigurations<sup>7+</sup> + +isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void; + +Checks whether the configuration of this ability is being changed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------- | +| callback | AsyncCallback\<boolean> | Yes | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.isUpdatingConfigurations((err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}); +``` + +## Context.isUpdatingConfigurations<sup>7+</sup> + +isUpdatingConfigurations(): Promise\<boolean>; + +Checks whether the configuration of this ability is being changed. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| --------------- | ------------------------- | +|Promise\<boolean> | Returns **true** if the configuration of the capability is being changed; returns **false** otherwise.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.isUpdatingConfigurations().then((data) => { + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.printDrawnCompleted<sup>7+</sup> + +printDrawnCompleted(callback: AsyncCallback\<void>): void; + +Notifies the system of the time required to draw this page function. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------- | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.printDrawnCompleted((err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}); +``` + +## Context.printDrawnCompleted<sup>7+</sup> + +printDrawnCompleted(): Promise\<void>; + +Notifies the system of the time required to draw this page function. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| --------------- | ------------------------- | +|Promise\<void> | Promise used to return the result.| + +**Example** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.printDrawnCompleted().then((data) => { + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + + ## PermissionOptions<sup>7+</sup> **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -916,31 +1237,10 @@ var context = featureAbility.getContext().getApplicationContext(); | permissions | Read-only | Array\<string> | Yes | Permissions requested. | | authResults | Read-only | Array\<number> | Yes | Permission request result. | -## HapModuleInfo<sup>7+</sup> - -Describes the HAP module information. - -| Name | Type| Readable| Writable| Description| -| ------ | ------ | ------ | ------ | ------ | -| name | string | Yes | No | Module name. | -| description | string | Yes | No | Module description. | -| descriptionId | number | Yes | No | Module description ID. | -| icon | string | Yes | No | Module icon. | -| label | string | Yes | No | Module label. | -| labelId | number | Yes | No | Module label ID. | -| iconId | number | Yes | No | Module icon ID. | -| backgroundImg | string | Yes | No | Module background image. | -| supportedModes | number | Yes | No | Running modes supported by the module. | -| reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running.| -| deviceTypes | Array\<string> | Yes | No | Device types supported by the module.| -| abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. | -| moduleName | string | Yes | No | Module name. | -| mainAbilityName | string | Yes | No | Name of the main ability. | -| installationFree | boolean | Yes | No | Whether installation-free is supported. | -| mainElementName | string | Yes| No| Information about the main ability.| - ## AppVersionInfo<sup>7+</sup> +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name | Type| Readable | Writable | Description| | ------ | ------ | ------| ------ | ------ | | appName | string | Yes | No | Module name. | diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md index 584b7e1285c0087bc1109bd32d50eb1143360df1..18cfa0cdc0c54ea8e8aa85fc43fcf61b3d63fc7a 100644 --- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md +++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md @@ -1,4 +1,6 @@ -# DataUriUtils Module +# DataUriUtils + +The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. > **NOTE** > diff --git a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md index 5b7866478f7f527ceb806b2aec083bd21835800a..06cac3878b46d62fdc09e6a342bdcc9340714c4f 100644 --- a/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @@ -1,18 +1,22 @@ -# EnterpriseAdminExtentionAbility +# EnterpriseAdminExtensionAbility -The **EnterpriseAdminExtentionAbility** module provides APIs for Extension abilities of enterprise administrators. +The **EnterpriseAdminExtensionAbility** module provides Extension abilities for enterprise administrators. + +To have the capabilities provided by the module, for example, receiving the application activation or deactivation notification sent by the system, an enterprise administrator application must have an **EnterpriseAdminExtensionAbility** instance and override the APIs in it. > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> > The APIs of this module can be used only in the stage model. + ## Modules to Import ```ts -import EnterpriseAdminExtentionAbility from '@ohos.EnterpriseAdminExtentionAbility' +import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility' ``` -## EnterpriseAdminExtentionAbility.onAdminEnabled +## EnterpriseAdminExtensionAbility.onAdminEnabled onAdminEnabled(): void @@ -22,14 +26,14 @@ Called when an enterprise administrator is enabled. **Example** - ```ts +```ts export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { - onAdminEnabled() { - } + onAdminEnabled() { + } }; - ``` +``` -## EnterpriseAdminExtentionAbility.onAdminDisabled +## EnterpriseAdminExtensionAbility.onAdminDisabled onAdminDisabled(): void @@ -38,11 +42,10 @@ Called when an enterprise administrator is disabled. **System capability**: SystemCapability.Customization.EnterpriseDeviceManager **Example** - - ```ts +```ts export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility { - onAdminDisabled() { - } + onAdminDisabled() { + } }; - ``` +``` diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index b858d93cbd061d4f1df583ac9d4045e152105b7a..e2333a523a918e229c6a35c4e341df9383bfb26a 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,17 +1,14 @@ # AbilityContext +The **AbilityContext** module, inherited from **Context**, implements the context for abilities. + +This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a pop-up window. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Implements the ability context. This module is inherited from **Context**. - -## Modules to Import - -```js -import Ability from '@ohos.application.Ability' -``` ## Usage Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. @@ -25,7 +22,6 @@ class MainAbility extends Ability { } ``` - ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -34,16 +30,18 @@ class MainAbility extends Ability { | -------- | -------- | -------- | -------- | -------- | | abilityInfo | AbilityInfo | Yes| No| Ability information.| | currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| - +| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration information.| ## AbilityContext.startAbility startAbility(want: Want, callback: AsyncCallback<void>): void -Starts an ability. This API uses a callback to return the result. +Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -69,10 +67,12 @@ Starts an ability. This API uses a callback to return the result. startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void -Starts an ability. This API uses a callback to return the result. +Starts an ability with start options specified. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -106,6 +106,8 @@ Starts an ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -143,7 +145,7 @@ Starts an ability. This API uses a promise to return the result. startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; -Starts an ability. This API uses a callback to return the result when the ability is terminated. +Starts an ability. This API uses an asynchronous callback to return the result when the ability is terminated. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -171,7 +173,7 @@ Starts an ability. This API uses a callback to return the result when the abilit startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; -Starts an ability. This API uses a callback to return the result when the ability is terminated. +Starts an ability with start options specified. This API uses an asynchronous callback to return the result when the ability is terminated. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -235,12 +237,134 @@ Starts an ability. This API uses a promise to return the result when the ability }) ``` +## AbilityContext.startAbilityForResultWithAccount + +startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>): void; + +Starts an ability. This API uses an asynchronous callback to return the result when the account of the ability is destroyed. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| callback | AsyncCallback\<AbilityResult\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startAbilityWithAccount(want, accountId, (err, data) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + console.log('---------- startAbilityWithAccount success, data: -----------', data); + }); + ``` + + +## AbilityContext.startAbilityForResultWithAccount + +startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void\>): void; + +Starts an ability with start options specified. This API uses an asynchronous callback to return the result when the account of the ability is destroyed. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityForResultWithAccount(want, accountId, options, (err) => { + console.log('---------- startAbilityForResultWithAccount fail, err: -----------', err); + }); + ``` + + + ## AbilityContext.startAbilityForResultWithAccount + +startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<AbilityResult\>; + +Starts an ability with start options specified. This API uses a promise to return the result when the account of the ability is destroyed. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<AbilityResult> | Promise used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityForResultWithAccount(want, accountId, options) + .then((data) => { + console.log('---------- startAbilityForResultWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startAbilityForResultWithAccount fail, err: -----------', err); + }) + ``` + ## AbilityContext.terminateSelf terminateSelf(callback: AsyncCallback<void>): void; -Terminates this ability. This API uses a callback to return the result. +Terminates this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -248,7 +372,7 @@ Terminates this ability. This API uses a callback to return the result. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -271,12 +395,12 @@ Terminates this ability. This API uses a promise to return the result. | Type| Description| | -------- | -------- | -| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Promise<void> | Promise used to return the result.| **Example** ```js - this.context.terminateSelf(want).then((data) => { + this.context.terminateSelf().then((data) => { console.log('success:' + JSON.stringify(data)); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); @@ -288,7 +412,7 @@ Terminates this ability. This API uses a promise to return the result. terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; -Terminates this ability. This API uses a callback to return the information to the caller of **startAbilityForResult**. +Terminates this ability. This API uses an asynchronous callback to return the information to the caller of **startAbilityForResult**. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -346,6 +470,149 @@ Terminates this ability. This API uses a promise to return information to the ca ) ``` +## AbilityContext.connectAbility + +connectAbility(want: Want, options: ConnectOptions): number; + +Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to another ability. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | No| Remote object instance.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Result code of the ability connection.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var options = { + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { console.log('----------- onFailed -----------') } + } + const result = this.context.connectAbility(want, options); + console.log('----------- connectAbilityResult: ------------', result); + ``` + + +## AbilityContext.connectAbilityWithAccount + +connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + +Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect this ability to another ability. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | No| Parameters for the connection.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Result code of the ability connection.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { console.log('----------- onFailed -----------') } + } + const result = this.context.connectAbilityWithAccount(want, accountId, options); + console.log('----------- connectAbilityResult: ------------', result); + ``` + +## AbilityContext.disconnectAbility + +disconnectAbility(connection: number): Promise\<void>; + +Disconnects a connection. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| connection | number | Yes| Result code of the ability connection.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + var connectionNumber = 0; + this.context.disconnectAbility(connectionNumber).then((data) => { + console.log('disconnectAbility success, data: ', data); + }).catch((err) => { + console.log('disconnectAbility fail, err: ', err); + }); + ``` + +## AbilityContext.disconnectAbility + +disconnectAbility(connection: number, callback:AsyncCallback\<void>): void; + +Disconnects a connection. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| connection | number | Yes| Result code of the ability connection.| +| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + var connectionNumber = 0; + this.context.disconnectAbility(connectionNumber, (err) => { + console.log('---------- disconnectAbility fail, err: -----------', err); + }); + ``` ## AbilityContext.startAbilityByCall @@ -388,12 +655,126 @@ Obtains the caller interface of the specified ability, and if the specified abil } ``` +## AbilityContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void\>): void; + +Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startAbilityWithAccount(want, accountId, (err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }); + ``` + + +## AbilityContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void\>): void; + +Starts an ability with the account ID and start options specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityWithAccount(want, accountId, options, (err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }); + ``` + + +## AbilityContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void\>; + +Starts an ability with the account ID specified. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityWithAccount(want, accountId, options) + .then((data) => { + console.log('---------- startAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }) + ``` ## AbilityContext.requestPermissionsFromUser requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; -Requests permissions from the user by displaying a pop-up window. This API uses a callback to return the result. +Requests permissions from the user by displaying a pop-up window. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -402,7 +783,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | permissions | Array<string> | Yes| Permissions to request.| -| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the API is successfully called.| +| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the permission request result.| **Example** @@ -433,7 +814,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses | Type| Description| | -------- | -------- | -| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.| +| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the permission request result.| **Example** @@ -452,7 +833,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses setMissionLabel(label: string, callback:AsyncCallback<void>): void; -Sets the label of the ability in the mission. This API uses an asynchronous callback to return the result. +Sets a label for this ability in the mission. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -461,7 +842,7 @@ Sets the label of the ability in the mission. This API uses an asynchronous call | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | label | string | Yes| Label of the ability to set.| -| callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -476,7 +857,7 @@ Sets the label of the ability in the mission. This API uses an asynchronous call setMissionLabel(label: string): Promise<void> -Sets the label of the ability in the mission. This API uses a promise to return the result. +Sets a label for this ability in the mission. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -490,7 +871,7 @@ Sets the label of the ability in the mission. This API uses a promise to return | Type| Description| | -------- | -------- | -| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Promise<void> | Promise used to return the result.| **Example** @@ -501,6 +882,117 @@ Sets the label of the ability in the mission. This API uses a promise to return console.log('failed:' + JSON.stringify(error)); }); ``` +## AbilityContext.setMissionIcon + +setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void; + +Sets an icon for this ability in the mission. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| icon | image.PixelMap | Yes| Icon of the ability to set.| +| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + import image from '@ohos.multimedia.image' + var imagePixelMap; + var color = new ArrayBuffer(0); + var initializationOptions = { + size: { + height: 100, + width: 100 + } + }; + image.createPixelMap(color, initializationOptions) + .then((data) => { + imagePixelMap = data; + }) + .catch((err) => { + console.log('--------- createPixelMap fail, err: ---------', err) + }); + this.context.setMissionIcon(imagePixelMap, (err) => { + console.log('---------- setMissionIcon fail, err: -----------', err); + }) + ``` + + +## AbilityContext.setMissionIcon + +setMissionIcon(icon: image.PixelMap): Promise\<void>; + +Sets an icon for this ability in the mission. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| icon | image.PixelMap | Yes| Icon of the ability to set.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js + import image from '@ohos.multimedia.image' + var imagePixelMap; + var color = new ArrayBuffer(0); + var initializationOptions = { + size: { + height: 100, + width: 100 + } + }; + image.createPixelMap(color, initializationOptions) + .then((data) => { + imagePixelMap = data; + }) + .catch((err) => { + console.log('--------- createPixelMap fail, err: ---------', err) + }); + this.context.setMissionIcon(imagePixelMap) + .then((data) => { + console.log('-------------- setMissionIcon success, data: -------------', data); + }) + .catch((err) => { + console.log('-------------- setMissionIcon fail, err: -------------', err); + }); + ``` +## AbilityContext.restoreWindowStage + +restoreWindowStage(localStorage: LocalStorage) : void; + +Restores the window stage data for this ability. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| localStorage | image.LocalStorage | Yes| Storage used to store the restored window stage.| + +**Example** + + ```js + var storage = new LocalStorage(); + this.context.restoreWindowStage(storage); + ``` ## AbilityContext.isTerminating diff --git a/en/application-dev/reference/apis/js-apis-ability-errorCode.md b/en/application-dev/reference/apis/js-apis-ability-errorCode.md index cc0197f022957aadb0dd784c1d4ae8c6e0c50005..6a131521d3c447cfb2df65b53a592c5be89678be 100644 --- a/en/application-dev/reference/apis/js-apis-ability-errorCode.md +++ b/en/application-dev/reference/apis/js-apis-ability-errorCode.md @@ -1,8 +1,10 @@ # ErrorCode +The **ErrorCode** module defines the error codes that can be used when the ability is started. + > **NOTE** > -> The initial APIs of this module are supported since API 6. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -12,7 +14,7 @@ import errorCode from '@ohos.ability.errorCode' ## ErrorCode -Defines the error code used when the ability is started. +Defines the error codes used when the ability is started. **System capability**: SystemCapability.Ability.AbilityRuntime.Core diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md index e1d57d47b1b77f1695f8ec79ac49bfbb22422d05..c2bb08c5314a44dcf6f4ad9246e6ee08a313ecd8 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -1,8 +1,10 @@ # wantConstant +The **wantConstant** module provides the action, entity, and flags used in **Want** objects. + > **NOTE** > -> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -12,73 +14,75 @@ import wantConstant from '@ohos.ability.wantConstant' ## wantConstant.Action -**System capability**: SystemCapability.Ability.AbilityBase +Enumerates the action constants of the **Want** object. -Lists the permissions. +**System capability**: SystemCapability.Ability.AbilityBase -| Common Event Macro | Common Event Name | Subscriber Permission | +| Name | Value | Description | | ------------ | ------------------ | ---------------------- | -| ACTION_HOME | ohos.want.action.home | None | -| ACTION_DIAL | ohos.want.action.dial | None | -| ACTION_SEARCH | ohos.want.action.search | None | -| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None | -| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None | -| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | -| ACTION_SET_ALARM | ohos.want.action.setAlarm | None | -| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None | -| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None | -| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None | -| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None | -| ACTION_SEND_SMS | ohos.want.action.sendSms | None | -| ACTION_CHOOSE | ohos.want.action.choose | None | -| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | None | -| ACTION_VIDEO_CAPTUR<sup>8+</sup> | ohos.want.action.videoCapture | None | -| ACTION_SELECT | ohos.want.action.select | None | -| ACTION_SEND_DATA | ohos.want.action.sendData | None | -| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None | -| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None | -| ACTION_VIEW_DATA | ohos.want.action.viewData | None | -| ACTION_EDIT_DATA | ohos.want.action.editData | None | -| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None | -| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None | -| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | None | -| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | None | -| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | None | +| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. | +| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. | +| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. | +| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. | +| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. | +| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. | +| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. | +| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. | +| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. | +| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. | +| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. | +| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. | +| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. | +| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. | +| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. | +| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. | +| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. | +| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. | +| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. | +| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. | +| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. | +| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. | +| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. | +| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. | +| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. | +| ACTION_MARKER_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. | ## wantConstant.Entity -**System capability**: SystemCapability.Ability.AbilityBase +Enumerates the entity constants of the **Want** object. -Lists the permissions. +**System capability**: SystemCapability.Ability.AbilityBase -| Common Event Macro | Common Event Name | Subscriber Permission | +| Name | Value | Description | | ------------ | ------------------ | ---------------------- | -| ENTITY_DEFAULT | entity.system.default | None | -| ENTITY_HOME | entity.system.homel | None | -| ENTITY_VOICE | ENTITY_VOICE | None | -| ENTITY_BROWSABLE | entity.system.browsable | None | -| ENTITY_VIDEO | entity.system.video | None | -| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None | +| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. | +| ENTITY_HOME | entity.system.home | Home screen entity. | +| ENTITY_VOICE | entity.system.voice | Voice interaction entity. | +| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. | +| ENTITY_VIDEO | entity.system.video | Video type entity. | + +## wantConstant.Flags -## flags +Describes flags. **System capability**: SystemCapability.Ability.AbilityBase | Name | Value | Description | | ------------------------------------ | ---------- | ------------------------------------------------------------ | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. | | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. | | FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. | -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. | -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications.| | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. | -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.| diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 5a21d564110cdf922e344c52ded3bd8d44604b2f..2b17d252af9d09d5519f36ece4306834e8085c5a 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -1,6 +1,6 @@ # Ability Access Control -Provides program permission management capabilities, including authentication, authorization, and revocation. +The **AbilityAccessCtrl** module provides APIs for application permission management, including authentication, authorization, and revocation. > **NOTE** > @@ -69,6 +69,36 @@ promise.then(data => { }); ``` +### verifyAccessTokenSync<sup>9+</sup> + +verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus + +Checks whether an application has been granted the specified permission. This API synchronously returns the result. + +**System capability**: SystemCapability.Security.AccessToken + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------- | ---- | ------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to verify.| + +**Return value** + +| Type | Description | +| :------------ | :---------------------------------- | +| [GrantStatus](#grantstatus) | Permission grant state.| + +**Example** + +```js +var AtManager = abilityAccessCtrl.createAtManager(); +let tokenID = 0; +let data = verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); +console.log(`data->${JSON.stringify(data)}`); +``` + ### grantUserGrantedPermission grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFlag: number): Promise<number> diff --git a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md index a609e0df688e7a9cc5b32ea25907eda95ab14c47..d30dce2a75e700019c9f44ce1c918a9574f3cea7 100644 --- a/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md +++ b/en/application-dev/reference/apis/js-apis-abilityDelegatorRegistry.md @@ -1,5 +1,7 @@ # AbilityDelegatorRegistry +The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -24,8 +26,6 @@ Enumerates the ability lifecycle states. | BACKGROUND | 3 | The ability is running in the background. | | DESTROY | 4 | The ability is destroyed.| - - ## AbilityDelegatorRegistry.getAbilityDelegator getAbilityDelegator(): AbilityDelegator diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md index 508463e3a428fffe336de4ae2c986623fb54d3b1..098f4ebba840a13d1f37d6e14256fcc9695f2a8d 100644 --- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,17 +1,11 @@ # AbilityRunningInfo +The **AbilityRunningInfo** module implements ability running information and ability states. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides ability running information. - -## Modules to Import - -```js -import abilitymanager from '@ohos.application.abilityManager'; -``` - ## Usage The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**. @@ -27,26 +21,13 @@ abilitymanager.getAbilityRunningInfos((err,data) => { **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| ability | ElementName | Yes| No| Information that matches an ability. | -| pid | number | Yes| No| Process ID.| -| uid | number | Yes| No| User ID. | -| processName | string | Yes| No| Process name. | -| startTime | number | Yes| No| Ability start time. | -| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. | - - -## abilityManager.AbilityState - -Enumerates the ability states. - -**System capability**: SystemCapability.Ability.AbilityRuntime.Core - -| Name| Value| Description| -| -------- | -------- | -------- | -| INITIAL | 0 | The ability is in the initial state.| -| FOREGROUND | 9 | The ability is in the foreground state. | -| BACKGROUND | 10 | The ability is in the background state. | -| FOREGROUNDING | 11 | The ability is in the foregrounding state. | -| BACKGROUNDING | 12 | The ability is in the backgrounding state. | +| ability | ElementName | Yes| No| Information that matches an ability. | +| pid | number | Yes| No| Process ID.| +| uid | number | Yes| No| User ID. | +| processName | string | Yes| No| Process name. | +| startTime | number | Yes| No| Ability start time. | +| abilityState | [abilityManager.AbilityState](js-apis-application-abilityManager.md#abilitystate) | Yes| No| Ability state. | diff --git a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md index 65705aae3936cc2c9e9643f6142be6de6564124b..5475dc51466d01d8eadef472248cce237f1b6241 100644 --- a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -1,18 +1,14 @@ # AbilityStageContext +The **AbilityStageContext** module, inherited from [Context](js-apis-application-context.md), implements the context of an ability stage. + +This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the **ModuleInfo** object and environment configuration of an ability stage. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md). - -## Modules to Import - -```js -import AbilityStage from '@ohos.application.AbilityStage'; -``` - ## Usage The ability stage context is obtained through an **AbilityStage** instance. diff --git a/en/application-dev/reference/apis/js-apis-accessibility.md b/en/application-dev/reference/apis/js-apis-accessibility.md index 17ef631d0f7207b676177a59d0903cc77dcd1045..f9d286cbd34296fa43596032fe89f2ecdd6e5d93 100644 --- a/en/application-dev/reference/apis/js-apis-accessibility.md +++ b/en/application-dev/reference/apis/js-apis-accessibility.md @@ -1,6 +1,9 @@ # Accessibility -> **NOTE**<br> +The **Accessibility** module implements the accessibility functions, including obtaining the accessibility application list, accessibility application enabled status, and captions configuration. + +> **NOTE** +> > 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. ## Modules to Import @@ -13,162 +16,162 @@ import accessibility from '@ohos.accessibility'; Enumerates the states of an accessibility application. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - | Name | Description | - | -------- | -------- | - | enable | The accessibility application is enabled. | - | disable | The accessibility application is disabled. | - | install | The accessibility application has been installed. | +| Name| Description| +| -------- | -------- | +| enable | The accessibility application is enabled.| +| disable | The accessibility application is disabled.| +| install | The accessibility application has been installed.| ## AbilityType Enumerates the types of accessibility applications. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - | Name | Description | - | -------- | -------- | - | audible | The accessibility application provides audible feedback. | - | generic | The accessibility application provides generic feedback. | - | haptic | The accessibility application provides haptic feedback. | - | spoken | The accessibility application provides spoken feedback. | - | visual | The accessibility application provides visual feedback. | +| Name| Description| +| -------- | -------- | +| audible | The accessibility application provides audible feedback.| +| generic | The accessibility application provides generic feedback.| +| haptic | The accessibility application provides haptic feedback.| +| spoken | The accessibility application provides spoken feedback.| +| visual | The accessibility application provides visual feedback.| +| all<sup>9+</sup> | All the preceding types.| ## AccessibilityAbilityInfo Provides information about an accessibility application. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core ### Attributes - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | id | number | Yes | No | Ability ID. | - | name | string | Yes | No | Ability name. | - | bundleName | string | Yes | No | Bundle name. | - | abilityTypes | Array<[AbilityType](#abilitytype)> | Yes | No | Accessibility application type. | - | capabilities | Array<[Capability](#capability)> | Yes | No | Capabilities list of the accessibility application. | - | description | string | Yes | No | Description of the accessibility application. | - | eventTypes | Array<[EventType](#eventtype)> | Yes | No | List of events that the accessibility application focuses on. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | number | Yes| No| Ability ID.| +| name | string | Yes| No| Ability name.| +| bundleName | string | Yes| No| Bundle name.| +| targetBundleNames<sup>9+</sup> | Array<string> | Yes| No| Name of the target bundle.| +| abilityTypes | Array<[AbilityType](#abilitytype)> | Yes| No| Accessibility application type.| +| capabilities | Array<[Capability](#capability)> | Yes| No| Capabilities list of the accessibility application.| +| description | string | Yes| No| Description of the accessibility application.| +| eventTypes | Array<[EventType](#eventtype)> | Yes| No| List of events that the accessibility application focuses on.| ## Action Describes the target action supported by an accessibility application. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core - - | Name | Description | - | -------- | -------- | - | click | Clicking. | - | longClick | Long pressing. | - | scrollForward | Scrolling forward. | - | scrollBackward | Scrolling backward. | - | focus | Obtaining focus. | - | clearFocus | Clearing focus. | - | clearSelection | Clearing selection. | - | accessibilityFocus | Obtaining the accessibility focus. | - | clearAccessibilityFocus | Clearing the accessibility focus. | - | cut | Cut. | - | copy | Copy. | - | paste | Paste. | - | select | Select. | - | setText | Setting the text. | - | delete | Delete. | - | setSelection | Setting the selection. | +**System capability**: SystemCapability.BarrierFree.Accessibility.Core + +| Name| Description| +| -------- | -------- | +| click | Clicking.| +| longClick | Long pressing.| +| scrollForward | Scrolling forward.| +| scrollBackward | Scrolling backward.| +| focus | Obtaining focus.| +| clearFocus | Clearing focus.| +| clearSelection | Clearing selection.| +| accessibilityFocus | Obtaining the accessibility focus.| +| clearAccessibilityFocus | Clearing the accessibility focus.| +| cut | Cut.| +| copy | Copy.| +| paste | Paste.| +| select | Select.| +| setText | Setting the text.| +| delete | Delete.| +| setSelection | Setting the selection.| ## Capability Enumerates the capabilities of an auxiliary application. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - | Name | Description | - | -------- | -------- | - | retrieve | Capability to retrieve the window content. | - | touchGuide | Capability of touch guide mode. | - | keyEventObserver | Capability to filter key events. | - | zoom | Capability to control the display zoom level. | - | gesture | Capability to perform gesture actions. | +| Name| Description| +| -------- | -------- | +| retrieve | Capability to retrieve the window content.| +| touchGuide | Capability of touch guide mode.| +| keyEventObserver | Capability to filter key events.| +| zoom | Capability to control the display zoom level.| +| gesture | Capability to perform gesture actions.| ## CaptionsFontEdgeType<sup>8+</sup> -Enumerates the caption font edge type. +Enumerates the font edge types of captions. -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing - | Name | Description | - | -------- | -------- | - | none | No effect. | - | raised | Raised effect. | - | depressed | Depressed effect. | - | uniform | Uniform effect. | - | dropShadow | Drop shadow effect. | +| Name| Description| +| -------- | -------- | +| none | No effect.| +| raised | Raised effect.| +| depressed | Depressed effect.| +| uniform | Uniform effect.| +| dropShadow | Drop shadow effect.| ## CaptionsFontFamily<sup>8+</sup> -Enumerates the caption font families. +Enumerates the font families of captions. -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing - | Name | Description | - | -------- | -------- | - | default | Default font family. | - | monospacedSerif | Monospaced Serif fonts, which use the same width for each character. | - | serif | Serif fonts. | - | monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character. | - | sansSerif | Sans Serif fonts. | - | casual | Casual fonts. | - | cursive | Cursive fonts. | - | smallCapitals | Small caps fonts. | +| Name| Description| +| -------- | -------- | +| default | Default font family.| +| monospacedSerif | Monospaced Serif fonts, which use the same width for each character.| +| serif | Serif fonts.| +| monospacedSansSerif | Monospaced Sans Serif fonts, which use the same width for each character.| +| sansSerif | Sans Serif fonts.| +| casual | Casual fonts.| +| cursive | Cursive fonts.| +| smallCapitals | Small caps fonts.| ## CaptionsStyle<sup>8+</sup> -Describes the caption style. +Describes the style of captions. -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes | No | Font family of the captions. | - | fontScale | number | Yes | No | Font scale of the captions. | - | fontColor | number \ | string | Yes | No | Font color of the captions. | - | fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes | No | Font edge type of the captions. | - | backgroundColor | number \ | string | Yes | No | Background color of the captions. | - | windowColor | number \ | string | Yes | No | Window color of the captions. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | Yes| No| Font family of captions.| +| fontScale | number | Yes| No| Font scale of captions.| +| fontColor | number \| string | Yes| No| Font color of captions.| +| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | Yes| No| Font edge type of captions.| +| backgroundColor | number \| string | Yes| No| Background color of captions.| +| windowColor | number \| string | Yes| No| Window color of captions.| ## CaptionsManager<sup>8+</sup> -Implements caption configuration management. +Implements configuration management for captions. -### Attributes +**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | enabled | boolean | Yes | No | Whether to enable caption configuration. | - | style | [CaptionsStyle](#captionsstyle8) | Yes | No | Caption style. | +### Attributes -### Methods +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| enabled | boolean | Yes| No| Whether to enable captions configuration.| +| style | [CaptionsStyle](#captionsstyle8) | Yes| No| Style of captions.| -In the following API examples, you must first use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) method to obtain a **captionsManager** instance, and then call the methods using the obtained instance. +In the following API examples, you must first use the [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) API to obtain a **captionsManager** instance, and then call the methods using the obtained instance. -#### on('enableChange') +### on('enableChange') on(type: 'enableChange', callback: Callback<boolean>): void; -Enables listening for enable status changes of caption configuration. - -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +Enables listening for enabled status changes of captions configuration. - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to listen for, which is set to **enableChange** in this API. | - | callback | Callback<boolean> | Yes | Callback invoked when the enable status of caption configuration changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.| + | callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.| -- Example +- **Example** ```typescript captionsManager.on('enableChange',(data) => { @@ -176,22 +179,20 @@ Enables listening for enable status changes of caption configuration. }) ``` -#### on('styleChange') +### on('styleChange') on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; -Enables listening for caption style changes. - -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +Enables listening for captions style changes. - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to listen for, which is set to **styleChange** in this API. | - | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes | Callback invoked when the caption style changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.| + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | Yes| Callback invoked when the style of captions changes.| -- Example +- **Example** ```typescript captionsManager.on('styleChange',(data) => { @@ -199,43 +200,39 @@ Enables listening for caption style changes. }) ``` -#### off('enableChange') +### off('enableChange') off(type: 'enableChange', callback?: Callback<boolean>): void; -Disables listening for enable status changes of caption configuration. - -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +Disables listening for enabled status changes of captions configuration. - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to listen for, which is set to **enableChange** in this API. | - | callback | Callback<boolean> | No | Callback invoked when the enable status of caption configuration changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to listen for, which is set to **enableChange** in this API.| + | callback | Callback<boolean> | No| Callback invoked when the enabled status of captions configuration changes.| -- Example +- **Example** ```typescript captionsManager.off('enableChange') ``` -#### off('styleChange') +### off('styleChange') off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; -Disables listening for caption style changes.s is removed. - -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +Disables listening for captions style changes. - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to listen for, which is set to **styleChange** in this API. | - | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No | Callback invoked when the caption style changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to listen for, which is set to **styleChange** in this API.| + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | No| Callback invoked when the style of captions changes.| -- Example +- **Example** ```typescript captionsManager.off('styleChange') @@ -245,80 +242,92 @@ Disables listening for caption style changes.s is removed. Describes a GUI change event. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core ### Attributes - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | type | [EventType](#eventtype) | Yes | Yes | Accessibility event type. | - | windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes | Yes | Window update type. | - | bundleName | string | Yes | Yes | Target application name. | - | componentType | string | Yes | Yes | Type of the event source component, for example, button or chart. | - | pageId | number | Yes | Yes | Page ID of the event source. | - | description | string | Yes | Yes | Event description. | - | triggerAction | [Action](#action) | Yes | Yes | Action that triggers the event. | - | textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes | Yes | Text movement unit. | - | contents | Array<string> | Yes | Yes | Array of contents. | - | lastContent | string | Yes | Yes | Latest content. | - | beginIndex | number | Yes | Yes | Sequence number of the first item displayed on the page. | - | currentIndex | number | Yes | Yes | Sequence number of the current item. | - | endIndex | number | Yes | Yes | Sequence number of the last item displayed on the page. | - | itemCount | number | Yes | Yes | Total number of items. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | [EventType](#eventtype) | Yes| Yes| Accessibility event type.| +| windowUpdateType | [WindowUpdateType](#windowupdatetype) | Yes| Yes| Window update type.| +| bundleName | string | Yes| Yes| Target application name.| +| componentType | string | Yes| Yes| Type of the event source component, for example, button or chart.| +| pageId | number | Yes| Yes| Page ID of the event source.| +| description | string | Yes| Yes| Event description.| +| triggerAction | [Action](#action) | Yes| Yes| Action that triggers the event.| +| textMoveUnit | [TextMoveUnit](#textmoveunit) | Yes| Yes| Text movement unit.| +| contents | Array<string> | Yes| Yes| Array of contents.| +| lastContent | string | Yes| Yes| Latest content.| +| beginIndex | number | Yes| Yes| Sequence number of the first item displayed on the page.| +| currentIndex | number | Yes| Yes| Sequence number of the current item.| +| endIndex | number | Yes| Yes| Sequence number of the last item displayed on the page.| +| itemCount | number | Yes| Yes| Total number of items.| + +### constructor + +constructor(jsonObject) + +Implements a constructor. + +- **Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | jsonObject | string | Yes| JSON string required for creating an object.| + +- **Example** + + ```typescript + let eventInfo = new accessibility.EventInfo({"type":"click","bundleName":"com.example.MyApplication","triggerAction":"click"}) + ``` ## EventType Enumerates accessibility event types. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core - - | Name | Description | - | -------- | -------- | - | click | Event of clicking a component. | - | longClick | Event of long-pressing a component. | - | select | Event of selecting a component. | - | focus | Event indicating that the component obtains the focus. | - | textUpdate | Event indicating that the component text has been updated. | - | hoverEnter | Event indicating that the hover enters a component. | - | hoverExit | Event indicating that the hover exits a component. | - | scroll | Event of the scroll view. | - | textSelectionUpdate | Event indicating that the selected text has been updated. | - | accessibilityFocus | Event indicating that the accessibility focus has been obtained. | - | accessibilityFocusClear | Event indicating that the accessibility focus has been cleared. | +**System capability**: SystemCapability.BarrierFree.Accessibility.Core + +| Name| Description| +| -------- | -------- | +| click | Event of clicking a component.| +| longClick | Event of long-pressing a component.| +| select | Event of selecting a component.| +| focus | Event indicating that the component obtains the focus.| +| textUpdate | Event indicating that the component text has been updated.| +| hoverEnter | Event indicating that the hover enters a component.| +| hoverExit | Event indicating that the hover exits a component.| +| scroll | Event of the scroll view.| +| textSelectionUpdate | Event indicating that the selected text has been updated.| +| accessibilityFocus | Event indicating that the accessibility focus has been obtained.| +| accessibilityFocusClear | Event indicating that the accessibility focus has been cleared.| ## TextMoveUnit Enumerates the movement units for traversing the node text. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - | Name | Description | - | -------- | -------- | - | char | The movement unit for traversing the node text is by character. | - | word | The movement unit for traversing the node text is by word. | - | line | The movement unit for traversing the node text is by line. | - | page | The movement unit for traversing the node text is by page. | - | paragraph | The movement unit for traversing the node text is by paragraph. | +| Name| Description| +| -------- | -------- | +| char | The movement unit for traversing the node text is by character.| +| word | The movement unit for traversing the node text is by word.| +| line | The movement unit for traversing the node text is by line.| +| page | The movement unit for traversing the node text is by page.| +| paragraph | The movement unit for traversing the node text is by paragraph.| ## WindowUpdateType Enumerates window update types. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core - - | Name | Description | - | -------- | -------- | - | add | Window adding. | - | remove | Window deletion. | - | title | Window title change. | - | bounds | Window boundary change. | - | layer | Window layer change. | - | active | Window activity change. | - | focus | Window focus change. | - | accessibilityFocus | Window accessibility focus change. | - | parent | Parent window change. | - | children | Child window change. | - | pip | Picture-in-picture (PIP) mode change. | +**System capability**: SystemCapability.BarrierFree.Accessibility.Core + +| Name| Description| +| -------- | -------- | +| add | Window adding.| +| remove | Window deletion.| +| bounds | Window boundary change.| +| active | Window activity change.| +| focus | Window focus change.| ## accessibility.getAbilityLists @@ -326,22 +335,22 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A Obtains the accessibility application list. This API uses a promise to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | abilityType | [AbilityType](#abilitytype) | Yes | Accessibility application type. | - | stateType | [AbilityState](#abilitystate) | Yes | Accessibility application status. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| + | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| -- Return value +- **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list. | + | Type| Description| + | -------- | -------- | + | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Promise used to return the accessibility application list.| -- Example +- **Example** ```typescript accessibility.getAbilityLists("spoken", "enable") @@ -369,17 +378,17 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn Obtains the accessibility application list. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | abilityType | [AbilityType](#abilitytype) | Yes | Accessibility application type. | - | stateType | [AbilityState](#abilitystate) | Yes | Accessibility application status. | - | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes | Callback used to return the accessibility application list. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | Yes| Accessibility application type.| + | stateType | [AbilityState](#abilitystate) | Yes| Accessibility application status.| + | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | Yes| Callback used to return the accessibility application list.| -- Example +- **Example** ```typescript accessibility.getAbilityLists("visual", "enable", (err, data) => { @@ -406,17 +415,17 @@ Obtains the accessibility application list. This API uses an asynchronous callba getCaptionsManager(): CaptionsManager -Obtains the accessibility caption configuration. +Obtains the captions configuration. -**System capability**: SystemCapability.Barrierfree.Accessibility.Hearing +**System capability**: SystemCapability.BarrierFree.Accessibility.Hearing -- Return value +- **Return value** - | Type | Description | - | -------- | -------- | - | [CaptionsManager](#captionsmanager8) | Accessibility caption configuration. | + | Type| Description| + | -------- | -------- | + | [CaptionsManager](#captionsmanager8) | Captions configuration.| -- Example +- **Example** ```typescript captionsManager = accessibility.getCaptionsManager() @@ -430,12 +439,12 @@ Enables listening for the accessibility application or touch guide mode status c - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Type of the event to listen for.<br>- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.<br>**System capability**: SystemCapability.Barrierfree.Accessibility.Core<br>- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.<br>**System capability**: SystemCapability.Barrierfree.Accessibility.Vision | - | callback | Callback<boolean> | Yes | Callback invoked when the enable status changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision| + | callback | Callback<boolean> | Yes| Callback invoked when the enabled status of captions configuration changes.| -- Example +- **Example** ```typescript accessibility.on('accessibilityStateChange',(data) => { @@ -447,18 +456,16 @@ Enables listening for the accessibility application or touch guide mode status c off(type: 'accessibilityStateChange ' | 'touchGuideStateChange', callback?: Callback<boolean>): void -Disables listening for the accessibility application or touch guide mode status changes. - - +Disables listening for the accessibility application or touch guide mode status changes. - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | type | string | No | Type of the event to listen for.<br>- **accessibilityStateChange** means to listen for enable status changes of the accessibility application.<br>**System capability**: SystemCapability.Barrierfree.Accessibility.Core<br>- **touchGuideStateChange** means to listen for enable status changes of the touch guide mode.<br>**System capability**: SystemCapability.Barrierfree.Accessibility.Vision | - | callback | Callback<boolean> | No | Callback invoked when the enable status changes. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | No| Type of the event to listen for.<br>- **'accessibilityStateChange'** means to listen for enabled status changes of the accessibility application.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Core<br>- **'touchGuideStateChange'** means to listen for enabled status changes of the touch guide mode.<br>**System capability**: SystemCapability.BarrierFree.Accessibility.Vision| + | callback | Callback<boolean> | No| Callback invoked when the enabled status changes.| -- Example +- **Example** ```typescript accessibility.off('accessibilityStateChange',(data) => { @@ -472,15 +479,15 @@ isOpenAccessibility(): Promise<boolean> Checks whether accessibility is enabled. This API uses a promise to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core -- Return value +- **Return value** - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Returns **true** if accessibility is enabled; returns **false** otherwise.| -- Example +- **Example** ```typescript accessibility.isOpenAccessibility() @@ -497,15 +504,15 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void Checks whether accessibility is enabled. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core -- Parameters +- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if accessibility is enabled; returns **false** otherwise.| -- Example +- **Example** ```typescript accessibility.isOpenAccessibility((err, data) => { @@ -523,15 +530,15 @@ isOpenTouchGuide(): Promise<boolean> Checks whether touch guide mode is enabled. This API uses a promise to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Vision -- Return value +- **Return value** - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Returns **true** if touch guide mode is enabled; returns **false** otherwise.| -- Example +- **Example** ```typescript accessibility.isOpenTouchGuide() @@ -548,15 +555,15 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void Checks whether touch guide mode is enabled. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Vision -- Parameters +- **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. Returns **true** if touch guide mode is enabled; returns **false** otherwise.| -- Example +- **Example** ```typescript accessibility.isOpenTouchGuide((err, data) => { @@ -574,21 +581,21 @@ sendEvent(event: EventInfo): Promise<void> Sends an accessibility event. This API uses a promise to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | event | [EventInfo](#eventinfo) | Yes | Accessibility event. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | Yes| Accessibility event.| -- Return value +- **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise. | + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.| -- Example +- **Example** ```typescript accessibility.sendEvent(this.eventInfo) @@ -605,16 +612,16 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void Sends an accessibility event. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Barrierfree.Accessibility.Core +**System capability**: SystemCapability.BarrierFree.Accessibility.Core - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | event | [EventInfo](#eventinfo) | Yes | Accessibility event. | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | Yes| Accessibility event.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result. Returns data if the accessibility event is sent successfully; returns an error otherwise.| -- Example +- **Example** ```typescript accessibility.sendEvent(this.eventInfo,(err, data) => { diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 60f404c4b0510809a4c1d515c3cc99c184796ab9..2a3dc0d9e34fd7ba2dd3e37c018292bec6da8be9 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -21,7 +21,7 @@ Creates an **AppAccountManager** instance. **System capability**: SystemCapability.Account.AppAccount -**Return Value** +**Return value** | Type | Description | | ----------------- | ------------ | @@ -102,7 +102,7 @@ Adds an app account name and additional information (information that can be con | name | string | Yes | Name of the app account to add. | | extraInfo | string | Yes | Additional information to add. The additional information cannot contain sensitive information, such as the app account password.| -**Return Value** +**Return value** | Type | Description | | ------------------- | --------------------- | @@ -198,7 +198,7 @@ Deletes an app account from the **AppAccountManager** service. This API uses a p | ---- | ------ | ---- | ----------- | | name | string | Yes | Name of the app account to delete.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -255,7 +255,7 @@ Disables an app account from accessing an app with the given bundle name. This A | name | string | Yes | Name of the target app account.| | bundleName | string | Yes | Bundle name of the app. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -312,7 +312,7 @@ Enables an app account to access an app with the given bundle name. This API use | name | string | Yes | Name of the target app account. | | bundleName | string | Yes | Bundle name of the app.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -371,7 +371,7 @@ Checks whether an app account allows app data synchronization. This API uses a p | ---- | ------ | ---- | ------- | | name | string | Yes | Name of the target app account.| -**Return Value** +**Return value** | Type | Description | | :--------------------- | :-------------------- | @@ -430,7 +430,7 @@ Sets a credential for an app account. This API uses a promise to return the resu | credentialType | string | Yes | Type of the credential to set.| | credential | string | Yes | Credential to set. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -487,7 +487,7 @@ Sets additional information for an app account. This API uses a promise to retur | name | string | Yes | Name of the target app account. | | extraInfo | string | Yes | Additional information to set.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -548,7 +548,7 @@ Sets whether to enable app data synchronization for an app account. This API use | name | string | Yes | Name of the target app account. | | isEnable | boolean | Yes | Whether to enable app data synchronization.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -606,7 +606,7 @@ Sets data to be associated with an app account. This API uses a promise to retur | key | string | Yes | Key of the data to set. The private key can be customized.| | value | string | Yes | Value of the data to be set. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :-------------------- | @@ -664,7 +664,7 @@ Obtains the credential of an app account. This API uses a promise to return the | name | string | Yes | Name of the target app account. | | credentialType | string | Yes | Type of the credential to obtain.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :-------------------- | @@ -720,7 +720,7 @@ Obtains additional information of an app account. This API uses a promise to ret | ---- | ------ | ---- | ------- | | name | string | Yes | Name of the target app account.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :-------------------- | @@ -778,7 +778,7 @@ Obtains data associated with an app account. This API uses a promise to return t | name | string | Yes | Name of the target app account. | | key | string | Yes | Key of the data to obtain.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :-------------------- | diff --git a/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md new file mode 100644 index 0000000000000000000000000000000000000000..3289f1d2efc43a5af0a8fa3266f41b1ff3139aaa --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -0,0 +1,429 @@ +# Data Share Extension Ability + +The **DataShareExtensionAbility** module provides Extension abilities for data share services. + +>**NOTE** +> +>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +>The APIs provided by this module are system APIs. +> +>The APIs of this module can be used only in the stage model. + + +## Modules to Import + +```ts +import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility' +``` + +## Attributes + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| context | [ExtensionContext](js-apis-extension-context.md) | Yes| No|Context of the DataShare Extension ability.| + +## onCreate + +onCreate?(want: Want, callback: AsyncCallback<void>): void + +Called by the server to initialize service logic when the DataShare client connects to the DataShareExtensionAbility server. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| want | [Want](js-apis-application-Want.md#want) | Yes | **Want** information, including the ability name and bundle name.| +| callback | AsyncCallback<void> | Yes| Callback that returns no value.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + onCreate(want, callback) { + rdb.getRdbStore(this.context, { + name: DB_NAME + }, 1, function (err, data) { + console.log('getRdbStore done, data : ' + data); + rdbStore = data; + rdbStore.executeSql(DDL_TBL_CREATE, [], function (err) { + console.log('executeSql done, error message : ' + err); + }); + if (callback) { + callback(); + } + }); + } +}; +``` + +## getFileTypes + +getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): void + +Obtains the Multipurpose Internet Mail Extensions (MIME) types supported by a file. This API is called by the server and can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ---------------------------------------- | ---- | ---------------------------------- | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME types to match. | +| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the MIME types obtained.| + +**Example** + +```ts +export default class DataShareExtAbility extends DataShareExtensionAbility { + getFileTypes(uri, mimeTypeFilter, callback) { + let err = {"code":0}; + let ret = new Array("type01", "type02", "type03"); + callback(err, ret); + } +}; +``` + +## openFile + +openFile?(uri: string, mode: string, callback: AsyncCallback<number>): void + +Opens a file. This API is called by the server and can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------------------------------ | +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | File open mode, which can be read-only or read/write.| +| callback | AsyncCallback<number> | Yes | Callback invoked to return the file descriptor. | + +**Example** + +```ts +export default class DataShareExtAbility extends DataShareExtensionAbility { + openFile(uri, mode, callback) { + let err = {"code":0}; + let fd = 0; + callback(err,fd); + } +}; +``` + +## insert + +insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<number>): void + +Inserts data into the database. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| uri |string | Yes | URI of the data to insert.| +| valueBucket |[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| Data to insert.| +| callback |AsyncCallback<number> | Yes| Callback invoked to return the index of the data inserted.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + insert(uri, valueBucket, callback) { + if (valueBucket == null) { + console.info('invalid valueBuckets'); + return; + } + rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) { + console.info('callback ret:' + ret); + if (callback != undefined) { + callback(err, ret); + } + }); + } +}; +``` + +## update + +update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback<number>): void + +Updates data in the database. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| uri | string | Yes | URI of the data to update.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for updating data.| +| valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes| New data.| +| callback | AsyncCallback<number> | Yes| Callback invoked to return the number of updated data records.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + update(uri, predicates, valueBucket, callback) { + if (predicates == null || predicates == undefined) { + return; + } + rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { + if (callback != undefined) { + callback(err, ret); + } + }); + } +}; +``` + +## delete + +delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void + +Deletes data from the database. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- | +| uri | string | Yes | URI of the data to delete. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for deleting data. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of data records deleted.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + delete(uri, predicates, callback) { + if (predicates == null || predicates == undefined) { + return; + } + rdbStore.delete(TBL_NAME, predicates, function (err, ret) { + if (callback != undefined) { + callback(err, ret); + } + }); + } +}; +``` + +## query + +query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>): void + +Queries data from the database. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| uri | string | Yes | URI of the data to query.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.| +| columns | Array<string> | Yes| Columns to query. If this parameter is empty, all columns will be queried.| +| callback | AsyncCallback<Object> | Yes| Callback invoked to return the result set.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + query(uri, predicates, columns, callback) { + if (predicates == null || predicates == undefined) { + return; + } + rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) { + if (resultSet != undefined) { + console.info('resultSet.rowCount: ' + resultSet.rowCount); + } + if (callback != undefined) { + callback(err, resultSet); + } + }); + } +}; +``` + +## getType + +getType?(uri: string, callback: AsyncCallback<string>): void + +Obtains the MIME type corresponding to the given URI. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| uri | string | Yes | URI of the target data.| +| callback | AsyncCallback<string> | Yes| Callback invoked to return the MIME type obtained.| + +**Example** + +```ts +export default class DataShareExtAbility extends DataShareExtensionAbility { + getType(uri, callback) { + let err = {"code":0}; + let ret = "image"; + callback(err, ret); + } +}; +``` + +## batchInsert + +batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: AsyncCallback<number>): void + +Batch inserts data into the database. This API is called by the server and can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------------------ | ---- | -------------------------------- | +| uri | string | Yes | URI of the data to insert. | +| valueBuckets | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes | Data to insert. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the number of inserted data records.| + +**Example** + +```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + batchInsert(uri, valueBuckets, callback) { + if (valueBuckets == null || valueBuckets.length == undefined) { + console.info('invalid valueBuckets'); + return; + } + let resultNum = valueBuckets.length + valueBuckets.forEach(vb => { + rdbStore.insert(TBL_NAME, vb, function (err, ret) { + if (callback != undefined) { + callback(err, resultNum); + } + }); + }); + } +}; +``` + +## normalizeUri + +normalizeUri?(uri: string, callback: AsyncCallback<string>): void + +Normalizes a URI. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ----------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to normalize.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result. If the operation is successful, the normalized URI is returned. Otherwise, **null** is returned.| + +**Example** + +```ts +export default class DataShareExtAbility extends DataShareExtensionAbility { + normalizeUri(uri, callback) { + let err = {"code":0}; + let ret = "normalize+" + uri; + callback(err, ret); + } +}; +``` + +## denormalizeUri + +denormalizeUri?(uri: string, callback: AsyncCallback<string>): void + +Denormalizes a URI. This API can be overridden as required. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ----------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to denormalize.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result. If the operation is successful, the denormalized URI is returned. If the URI passed in is returned, denormalization is not required. If denormalization is not supported, **null** is returned.| + +**Example** + +```ts +export default class DataShareExtAbility extends DataShareExtensionAbility { + denormalizeUri(uri, callback) { + let err = {"code":0}; + let ret = "denormalize+" + uri; + callback(err, ret); + } +}; +``` diff --git a/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md b/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md new file mode 100644 index 0000000000000000000000000000000000000000..f0d75fc57deed25160bbb080ef1565a45a94679d --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md @@ -0,0 +1,62 @@ +# EnvironmentCallback + +The **EnvironmentCallback** module provides the **onConfigurationUpdated** API for the application context to listen for system environment changes. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the stage model. + + +## Modules to Import + +```js +import EnvironmentCallback from "@ohos.application.EnvironmentCallback"; +``` + + +## EnvironmentCallback.onConfigurationUpdated + +onConfigurationUpdated(config: Configuration): void; + +Called when the system environment changes. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes| **Configuration** object after the change.| + +**Example** + + + ```js +import AbilityStage from "@ohos.application.AbilityStage"; + +var callbackId; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.applicationContext = this.context.getApplicationContext(); + let EnvironmentCallback = { + onConfigurationUpdated(config){ + console.log("onConfigurationUpdated config:" + JSON.stringify(config)); + }, + } + // 1. Obtain an applicationContext object. + let applicationContext = globalThis.applicationContext; + // 2. Register a listener for the environment changes through the applicationContext object. + callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); + console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); + } + onDestroy() { + let applicationContext = globalThis.applicationContext; + applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { + console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + }); + } +} + ``` diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index c850915c4d2743d7ee8f03ce0b96d6a4f7739525..c97515fa2bd988b91c4fd5c27a8e27ed285f141c 100644 --- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -1,23 +1,39 @@ # MissionSnapshot +The **MissionSnapshot** module provides the mission snapshot information of an ability. + > **NOTE** -> +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module are system APIs and cannot be called by third-party applications. -Provides the snapshot of a mission. +## Usage -## Modules to Import +The mission snapshot information can be obtained by using **getMissionSnapShot** in **missionManager**. -``` -import missionManager from '@ohos.application.missionManager' +```js import ElementName from '@ohos.bundle'; import image from '@ohos.multimedia.image'; -``` +import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + missionManager.getMissionSnapShot("", id, (error, snapshot) => { + console.log("getMissionSnapShot is called, error.code = " + error.code); + console.log("bundleName = " + snapshot.ability.bundleName); + }) + }) +``` ## MissionSnapshot Describes the mission snapshot. +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | | ability | ElementName | Yes| Yes| Information that matches an ability.| diff --git a/en/application-dev/reference/apis/js-apis-application-StartOptions.md b/en/application-dev/reference/apis/js-apis-application-StartOptions.md index e221f4506244b56ea43e24ef916085ef1f3fac63..d1d7416500d37ab61523633f3880670ad8b98779 100644 --- a/en/application-dev/reference/apis/js-apis-application-StartOptions.md +++ b/en/application-dev/reference/apis/js-apis-application-StartOptions.md @@ -1,12 +1,12 @@ # StartOptions +The **StartOptions** module implements ability startup options. + > **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -**StartOptions** is the basic communication component of the system. - ## Modules to Import ``` @@ -15,10 +15,9 @@ import StartOptions from '@ohos.application.StartOptions'; ## Attributes -**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore +**System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name| Readable| Writable| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -------- | -------- | -| [windowMode](js-apis-window.md#windowmode) | Yes| No| number | No| Window mode.| +| [windowMode](js-apis-application-abilityConstant.md#AbilityConstant.WindowMode) | Yes| No| number | No| Window mode.| | displayId | Yes| No| number | No| Display ID.| - diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md index 26c0cd030bcdf36cee488cba5066b2beba38a3d3..f51fee8402c98f9c36e81f355df105a3154e0105 100644 --- a/en/application-dev/reference/apis/js-apis-application-Want.md +++ b/en/application-dev/reference/apis/js-apis-application-Want.md @@ -1,11 +1,11 @@ # Want +The **Want** module provides the basic communication component of the system. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -**Want** is the basic communication component of the system. - ## Modules to Import ``` @@ -20,11 +20,26 @@ import Want from '@ohos.application.Want'; | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | deviceId | Read only | string | No | ID of the device running the ability. | | bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.| -| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.| +| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.| | uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| | type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. | | flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).| | action | Read only | string | No | Action option. | -| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. | +| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.js) module can be used to obtain application and bundle information. | | entities | Read only | Array\<string> | No | List of entities. | -| moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs. Different abilities among HAP files in an application may use the same name. If the abilities cannot be distinguished by the combination of **bundleName** and **abilityName**, you can set **moduleName** for better distinguishing.| | +| moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs.| + +**Example** + +``` js + var want = { + "deviceId": "", // An empty deviceId indicates the local device. + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleName is optional. + }; + this.context.startAbility(want, (error) => { + // Start an ability explicitly. The bundleName, abilityName, and moduleName parameters uniquely identify an ability. + console.log("error.code = " + error.code) + }) +``` diff --git a/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md new file mode 100644 index 0000000000000000000000000000000000000000..8a366b1e21bb988c608ba0a5e57251f2bd237d75 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @@ -0,0 +1,137 @@ +# Window Extension Ability +**WindowExtensionAbility** inherits from **ExtensionAbility**. The content in a **WindowExtensionAbility** object can be displayed as an ability component in other application windows. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. +> +> The APIs of this module can be used only in the stage model. + +## Modules to Import + +```ts +import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility'; +``` + +## Attributes + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| --------- | -------- | ---- | ---- | ------------------------- | +| context | [ExtensionContext](js-apis-extension-context.md) | Yes | No | Context of an Extension ability. | + +## WindowExtensionAbility.onConnect + +onConnect(want: Want): rpc.RemoteObject + +Called when this Window Extension ability is connected to an ability for the first time. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. | + +**Return value** +| Type | Description | +| ----------------------------------------------- | -------------------- | +| [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Proxy of this Window Extension ability.| + +**Example** + +```ts +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + return true; + } + queryLocalInterface(descriptor) { + return null; + } + getInterfaceDescriptor() { + return ""; + } + sendRequest(code, data, reply, options) { + return null; + } + getCallingPid() { + return 1; + } + getCallingUid() { + return 1; + } + attachLocalInterface(localInterface, descriptor){} +} + +export default class MyWindowExtensionAbility extends WindowExtensionAbility { + + onConnect(want): rpc.RemoteObject { + console.info('WindowExtAbility onConnect ' + want.abilityName); + return new StubTest("test"); + } + +} +``` + +## WindowExtensionAbility.onDisconnect + +onDisconnect(want: Want): void + +Called when this Window Extension ability is disconnected from all connected abilities. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. | + + +**Example** + +```ts +export default class MyWindowExtensionAbility extends WindowExtensionAbility { + + onDisconnect(want) { + console.info('WindowExtAbility onDisconnect ' + want.abilityName); + } + +} +``` + + +## WindowExtensionAbility.onWindowReady + +onWindowReady(window: Window): void + +Called when a window is ready. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| window | [Window](js-apis-window.md) | Yes| Current **Window** instance.| + + +**Example** + +```ts +export default class MyWindowExtensionAbility extends WindowExtensionAbility { + + onWindowReady(window) { + window.loadContent('WindowExtAbility/pages/index1').then(() => { + window.getProperties().then((pro) => { + console.log("WindowExtension " + JSON.stringify(pro)); + }) + window.show(); + }) + } + +} +``` diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md index bdf719b34ed6e7ba0dcc227ff5866c8ae7b87a87..565210637c6e83f83ec734c0905e11596baaf0db 100644 --- a/en/application-dev/reference/apis/js-apis-application-ability.md +++ b/en/application-dev/reference/apis/js-apis-application-ability.md @@ -1,12 +1,17 @@ # Ability +The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information. + +This module provides the following common ability-related functions: + +- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee). +- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Manages the ability lifecycle and context. - ## Modules to Import ``` @@ -17,14 +22,12 @@ import Ability from '@ohos.application.Ability'; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| -| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.| -| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| -| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| - - +| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.| +| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.| +| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.| +| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.| ## Ability.onCreate @@ -36,13 +39,13 @@ Called to initialize the service logic when an ability is created. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| - | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.| +| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.| + +**Example** -**Example** - ```js class myAbility extends Ability { onCreate(want, param) { @@ -62,12 +65,12 @@ Called when a **WindowStage** is created for this ability. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes| **WindowStage** information.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| windowStage | window.WindowStage | Yes| **WindowStage** information.| + +**Example** -**Example** - ```js class myAbility extends Ability { onWindowStageCreate(windowStage) { @@ -85,8 +88,8 @@ Called when the **WindowStage** is destroyed for this ability. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onWindowStageDestroy() { @@ -106,12 +109,12 @@ Called when the **WindowStage** is restored during the migration of this ability **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes| **WindowStage** information.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| windowStage | window.WindowStage | Yes| **WindowStage** information.| + +**Example** -**Example** - ```js class myAbility extends Ability { onWindowStageRestore(windowStage) { @@ -129,8 +132,8 @@ Called when this ability is destroyed to clear resources. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onDestroy() { @@ -148,8 +151,8 @@ Called when this ability is switched from the background to the foreground. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onForeground() { @@ -167,8 +170,8 @@ Called when this ability is switched from the foreground to the background. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js class myAbility extends Ability { onBackground() { @@ -188,18 +191,18 @@ Called to save data during the ability migration preparation process. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | wantParam | {[key: string]: any} | Yes| **want** parameter.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| wantParam | {[key: string]: any} | Yes| **want** parameter.| **Return value** - | Type| Description| - | -------- | -------- | - | AbilityConstant.OnContinueResult | Continuation result.| +| Type| Description| +| -------- | -------- | +| AbilityConstant.OnContinueResult | Continuation result.| + +**Example** -**Example** - ```js import AbilityConstant from "@ohos.application.AbilityConstant" class myAbility extends Ability { @@ -222,13 +225,13 @@ Called when the ability startup mode is set to singleton. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| - | launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.| +| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.| + +**Example** -**Example** - ```js class myAbility extends Ability { onNewWant(want, launchParams) { @@ -251,12 +254,12 @@ Called when the configuration of the environment where the ability is running is **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| + +**Example** -**Example** - ```js class myAbility extends Ability { onConfigurationUpdated(config) { @@ -269,18 +272,18 @@ Called when the configuration of the environment where the ability is running is dump(params: Array\<string>): Array\<string>; -Called when the client information is dumped. +Dumps client information. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | params | Array\<string> | Yes| Parameters in the form of a command.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| params | Array\<string> | Yes| Parameters in the form of a command.| + +**Example** -**Example** - ```js class myAbility extends Ability { dump(params) { @@ -307,19 +310,19 @@ Sends sequenceable data to the target ability. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| - | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| +| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return a response.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return a response.| + +**Example** -**Example** - ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ // Custom sequenceable data structure @@ -380,19 +383,19 @@ Sends sequenceable data to the target ability and obtains the sequenceable data **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| - | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.| +| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.| +| Type| Description| +| -------- | -------- | +| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.| + +**Example** -**Example** - ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ @@ -452,8 +455,8 @@ Releases the caller interface of the target ability. **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -**Example** - +**Example** + ```js import Ability from '@ohos.application.Ability'; var caller; @@ -489,12 +492,12 @@ Registers a callback that is invoked when the stub on the target ability is disc **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.| + +**Example** -**Example** - ```js import Ability from '@ohos.application.Ability'; var caller; @@ -529,7 +532,7 @@ Implements callbacks for caller notification registration and deregistration. ## Callee.on -on(method: string, callback: CaleeCallBack): void; +on(method: string, callback: CalleeCallBack): void; Registers a caller notification callback, which is invoked when the target ability registers a function. @@ -537,13 +540,12 @@ Registers a caller notification callback, which is invoked when the target abili **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Notification message string negotiated between the two abilities.| - | callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| method | string | Yes| Notification message string negotiated between the two abilities.| +| callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.| -**Example** - +**Example** ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ @@ -593,9 +595,9 @@ Deregisters a caller notification callback, which is invoked when the target abi **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | method | string | Yes| Registered notification message string.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| method | string | Yes| Registered notification message string.| **Example** @@ -616,17 +618,17 @@ Deregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.| - +| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.| + - ## CaleeCallBack + ## CalleeCallBack (indata: rpc.MessageParcel): rpc.Sequenceable; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.| +| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.| diff --git a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md index 3b2a958f7f403cade73487d61ff3695e5935d1bb..ca3269353344ca06935afaf6b390ae0c906f1a1a 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityConstant.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityConstant.md @@ -1,12 +1,14 @@ # AbilityConstant +The **AbilityConstant** module provides ability launch parameters. + +The parameters include the initial launch reasons, reasons for the last exit, and ability continuation results. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Provides parameters related to ability launch. - ## Modules to Import ```js @@ -17,10 +19,10 @@ import AbilityConstant from '@ohos.application.AbilityConstant'; **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| launchReason | LaunchReason| Yes| Yes| Ability launch reason.| -| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.| +| launchReason | LaunchReason| Yes| Yes| Ability launch reason.| +| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.| ## AbilityConstant.LaunchReason @@ -60,3 +62,17 @@ Enumerates ability continuation results. | AGREE | 0 | Continuation agreed.| | REJECT | 1 | Continuation denied.| | MISMATCH | 2 | Mismatch.| + +## AbilityConstant.WindowMode + +Enumerates the window modes when an ability is started. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Value| Description | +| --- | --- | --- | +| WINDOW_MODE_UNDEFINED | 0 | Undefined window mode. | +| WINDOW_MODE_FULLSCREEN | 1 | The ability is displayed in full screen. | +| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. | +| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. | +| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.| diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md index ec8655be70c9037622328066aa63d2cc643421d1..542214482f3e5bc8a74dad3d9990e1817b3f02e8 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -1,13 +1,21 @@ # AbilityDelegator +The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** instances that are used to monitor the lifecycle state changes of a specified ability. You can use the APIs to add and remove **AbilityMonitor** instances, wait for an ability to reach the **OnCreate** lifecycle state, set the waiting time, obtain the lifecycle state of an ability, obtain the top ability of the current application, and start an ability. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Usage +The ability delegator can be obtained by calling **getAbilityDelegator** in **AbilityDelegatorRegistry**. ```js import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + ``` ## AbilityDelegator @@ -174,7 +182,7 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => { waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<Ability>): void -Waits for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses an asynchronous callback to return the result. +Waits for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -211,7 +219,7 @@ abilityDelegator.waitAbilityMonitor(monitor, (err : any, data : any) => { waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback\<Ability>): void -Waits a period of time for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses an asynchronous callback to return the result. +Waits a period of time for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -250,7 +258,7 @@ abilityDelegator.waitAbilityMonitor(monitor, timeout, (err : any, data : any) => waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<Ability> -Waits a period of time for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses a promise to return the result. +Waits a period of time for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -355,7 +363,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { getCurrentTopAbility(callback: AsyncCallback\<Ability>): void -Obtains the top ability of the application. This API uses an asynchronous callback to return the result. +Obtains the top ability of this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -384,7 +392,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { getCurrentTopAbility(): Promise\<Ability> -Obtains the top ability of the application. This API uses a promise to return the result. +Obtains the top ability of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -491,7 +499,7 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses an | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------------------- | | ability | Ability | Yes | Target ability. | -| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.| +| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.| **Example** @@ -529,7 +537,7 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses a p | Type | Description | | ----------------- | ------------------------------------------------------------ | -| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.| +| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.| **Example** @@ -562,7 +570,7 @@ Schedules the lifecycle state of an ability to **Background**. This API uses an | Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------------------- | | ability | Ability | Yes | Target ability. | -| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.| +| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.| **Example** @@ -600,7 +608,7 @@ Schedules the lifecycle state of an ability to **Background**. This API uses a p | Type | Description | | ----------------- | ------------------------------------------------------------ | -| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.| +| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.| **Example** @@ -620,6 +628,32 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { +### printSync<sup>9+</sup> + +printSync(msg: string): void + +Prints log information to the unit test console. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------- | +| msg | string | Yes | Log string.| + +**Example** + +```js +var abilityDelegator; +var msg = "msg"; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.printSync(msg); +``` + + + ### print print(msg: string, callback: AsyncCallback\<void>): void diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md index ad43acc77bd9e7ff82b9d5bb7e01467e6b36c656..dffe0e39e69e38123bf7e89338b3d4efb14ad82a 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md @@ -1,22 +1,30 @@ # AbilityDelegatorArgs +The **AbilityDelegatorArgs** module provides a global register to store the registered **AbilityDelegator** and **AbilityDelegatorArgs** instances during application startup. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Usage + +The ability delegator arguments are obtained by calling **getArguments** in **AbilityDelegatorRegistry**. ```js import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var args = AbilityDelegatorRegistry.getArguments(); ``` ## AbilityDelegatorArgs -Describes the test parameters. +Describes the ability delegator arguments. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable| Writable| Description | | ------------------- | ---------------------- | ---- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes | Yes | Bundle name of the application to test.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| parameters | {[key:string]: string} | Yes | Yes | Parameters of the unit test that is started currently.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| testCaseNames | string | Yes | Yes | Test case names.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| testRunnerClassName | string | Yes | Yes | Names of the test executors that execute the test cases.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| +| bundleName | string | Yes | Yes | Bundle name of the application to test. | +| parameters | {[key:string]: string} | Yes | Yes | Parameters of the unit test that is started currently. | +| testCaseNames | string | Yes | Yes | Test case names. | +| testRunnerClassName | string | Yes | Yes | Names of the test case executors. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index 02803ad07bcde72288958a9be4981a15b8b4b555..42974b5fd683af842146b53fec22022edca84de6 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -1,17 +1,17 @@ # AbilityLifecycleCallback +The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to receive lifecycle state changes in the application context. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -A callback class that provides APIs, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to listen for the lifecycle of the application context. - ## Modules to Import ```js -import AbilityLifecycleCallback from "@ohos.application.abilityLifecycleCallback"; +import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback"; ``` diff --git a/en/application-dev/reference/apis/js-apis-abilityManager.md b/en/application-dev/reference/apis/js-apis-application-abilityManager.md similarity index 94% rename from en/application-dev/reference/apis/js-apis-abilityManager.md rename to en/application-dev/reference/apis/js-apis-application-abilityManager.md index 28c5cd31b0350ca0e8b24c8bfbda21fb039adcd7..e1bf96bae511de4e1fb83d92df6ee05bdddbf990 100644 --- a/en/application-dev/reference/apis/js-apis-abilityManager.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityManager.md @@ -7,7 +7,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying > 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. -# Modules to Import +## Modules to Import ```js import AbilityManager from '@ohos.application.abilityManager' @@ -21,24 +21,24 @@ Enumerates the ability states. **System API**: This is a system API and cannot be called by third-party applications. -| Name| Value| Description| +| Name| Value| Description| | -------- | -------- | -------- | -| INITIAL | 0 | The ability is in the initial state.| -| FOREGROUND | 9 | The ability is in the foreground state. | -| BACKGROUND | 10 | The ability is in the background state. | -| FOREGROUNDING | 11 | The ability is in the foregrounding state. | -| BACKGROUNDING | 12 | The ability is in the backgrounding state. | +| INITIAL | 0 | The ability is in the initial state.| +| FOREGROUND | 9 | The ability is in the foreground state. | +| BACKGROUND | 10 | The ability is in the background state. | +| FOREGROUNDING | 11 | The ability is in the foregrounding state. | +| BACKGROUNDING | 12 | The ability is in the backgrounding state. | ## updateConfiguration updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void -Obtains the ability running information. This API uses an asynchronous callback to return the result. +Updates the configuration. This API uses an asynchronous callback to return the result. **Permission required**: ohos.permission.UPDATE_CONFIGURATION **System capability**: SystemCapability.Ability.AbilityRuntime.Core - + **Parameters** | Name | Type | Mandatory | Description | @@ -80,7 +80,7 @@ Updates the configuration. This API uses a promise to return the result. | Type | Description | | ---------------------------------------- | ------- | -| Promise\<void> | Promise used to return the result. | +| Promise\<void> | Promise used to return the result.| **Example** @@ -138,7 +138,7 @@ Obtains the ability running information. This API uses a promise to return the r | Type | Description | | ---------------------------------------- | ------- | -| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result. | +| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.| **Example** @@ -186,7 +186,7 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>> Obtains the extension running information. This API uses a promise to return the result. - + **Required permissions**: ohos.permission.GET_RUNNING_INFO **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -201,7 +201,7 @@ Obtains the extension running information. This API uses a promise to return the | Type | Description | | ---------------------------------------- | ------- | -| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result. | +| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result.| **Example** @@ -246,14 +246,14 @@ abilitymanager.getTopAbility((err,data) => { getTopAbility(): Promise\<ElementName>; Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result. - + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Return value** | Type | Description | | ---------------------------------------- | ------- | -| Promise\<ElementName>| Promise used to return the result. | +| Promise\<ElementName>| Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md index e7f017b48ebb0f440b021386e7a427e2d0a59852..33feda3afdd757e91ed7b7f682dca1ef597a7847 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md @@ -1,26 +1,47 @@ # AbilityMonitor +The **AbilityMonitor** module provides monitors for abilities that meet specified conditions. The latest matched abilities are stored in an **AbilityMonitor** object. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Usage + +The ability monitor is set by calling **addAbilityMonitor** in **abilityDelegator**. ```js import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +var abilityDelegator; + +function onAbilityCreateCallback(data) { + console.info("onAbilityCreateCallback"); +} + +var monitor = { + abilityName: "abilityname", + onAbilityCreate: onAbilityCreateCallback +} + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.addAbilityMonitor(monitor, (err : any) => { + console.info("addAbilityMonitor callback"); +}); ``` ## AbilityMonitor Describes an ability monitor. +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name | Type | Readable| Writable| Description | | ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| +| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor. | +| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | +| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md index 731d21305f151cd0318b14813e270bc14a27a3d2..c4f5da0e2989b5565d6405198a8c83ad7f20ee65 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,12 +1,14 @@ # AbilityStage +**AbilityStage** is a runtime class for HAP files. + +The **AbilityStage** module notifies you of when you can perform HAP initialization such as resource pre-loading and thread creation during the HAP loading. + > **NOTE** > -> 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. +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Runtime class for HAP files. It provides APIs to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads. - ## Modules to Import ```js diff --git a/en/application-dev/reference/apis/js-apis-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-application-applicationContext.md index 517d9fb529fce872c5972a1aada50ce9f9b54ec9..88eccc98c39c5373930f35465ca48da1df19c40d 100644 --- a/en/application-dev/reference/apis/js-apis-application-applicationContext.md +++ b/en/application-dev/reference/apis/js-apis-application-applicationContext.md @@ -1,19 +1,13 @@ # ApplicationContext +The **ApplicationContext** module provides application-level context. You can use the APIs of this module to register and deregister the ability lifecycle listener in an application. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -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 +## Usage Before calling any APIs in **ApplicationContext**, obtain an **ApplicationContext** instance through the **context** instance. @@ -34,7 +28,7 @@ Registers a listener to monitor the ability lifecycle of the application. | Name | Type | Mandatory| Description | | ------------------------ | -------- | ---- | ------------------------------ | -| [AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) | callback | Yes | Callback used to return the ID of the registered listener.| +| callback | [AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) | Yes | Callback used to return the ID of the registered listener.| **Return value** @@ -42,6 +36,54 @@ Registers a listener to monitor the ability lifecycle of the application. | ------ | ------------------------------ | | number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.| +**Example** + + ```js +import AbilityStage from "@ohos.application.AbilityStage"; + +var lifecycleId; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let AbilityLifecycleCallback = { + onAbilityCreate(ability){ + console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); + }, + onAbilityWindowStageCreate(ability){ + console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability)); + }, + onAbilityWindowStageDestroy(ability){ + console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability)); + }, + onAbilityDestroy(ability){ + console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); + }, + onAbilityForeground(ability){ + console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); + }, + onAbilityBackground(ability){ + console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); + }, + onAbilityContinue(ability){ + console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); + } + } + // 1. Obtain applicationContext through the context attribute. + let applicationContext = this.context.getApplicationContext(); + // 2. Use applicationContext to register a listener for the ability lifecycle in the application. + lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); + console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId)); + } + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + }); + } +} + ``` + ## ApplicationContext.unregisterAbilityLifecycleCallback @@ -56,52 +98,91 @@ Deregisters the listener that monitors the ability lifecycle of the application. | Name | Type | Mandatory| Description | | ------------- | -------- | ---- | -------------------------- | | callbackId | number | Yes | ID of the listener to deregister.| -| AsyncCallback | callback | Yes | Callback used to return the result. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + + ```js + let applicationContext = this.context.getApplicationContext(); + let lifecycleId = 1; + console.log("stage applicationContext: " + JSON.stringify(applicationContext)); + applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + }); + ``` + +## ApplicationContext.registerEnvironmentCallback + +registerEnvironmentCallback(callback: EnvironmentCallback): **number**; + +Registers a listener for system environment changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------------------ | -------- | ---- | ------------------------------ | +| callback | [EnvironmentCallback](js-apis-application-EnvironmentCallback.md) | Yes | Callback used to return the ID of the registered listener.| + +**Return value** + +| Type | Description | +| ------ | ------------------------------ | +| number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.| + +**Example** + + ```js +import AbilityStage from "@ohos.application.AbilityStage"; + +var callbackId; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.applicationContext = this.context.getApplicationContext(); + let EnvironmentCallback = { + onConfigurationUpdated(config){ + console.log("onConfigurationUpdated config:" + JSON.stringify(config)); + }, + } + // 1. Obtain an applicationContext object. + let applicationContext = globalThis.applicationContext; + // 2. Use applicationContext to register a listener for the ability lifecycle in the application. + callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback); + console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId)); + } + onDestroy() { + let applicationContext = globalThis.applicationContext; + applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { + console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + }); + } +} + ``` + +## ApplicationContext.unregisterEnvironmentCallback + +unregisterEnvironmentCallback(callbackId: **number**, callback: AsyncCallback<**void**>): **void**; + +Deregisters the listener for system environment changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | -------- | ---- | -------------------------- | +| callbackId | number | Yes | ID of the listener to deregister. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | **Example** ```js - import AbilityStage from "@ohos.application.AbilityStage"; - - var lifecycleid; - - export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("MyAbilityStage onCreate") - let AbilityLifecycleCallback = { - onAbilityCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); - }, - onAbilityWindowStageCreate(ability){ - console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability)); - }, - onAbilityWindowStageDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability)); - }, - onAbilityDestroy(ability){ - console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability)); - }, - onAbilityForeground(ability){ - console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability)); - }, - onAbilityBackground(ability){ - console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability)); - }, - onAbilityContinue(ability){ - console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability)); - } - } - // 1. Obtain applicationContext through the context attribute. - let applicationContext = this.context.getApplicationContext(); - // 2. Use applicationContext to register a listener for the ability lifecycle in the application. - lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); - console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); - } - onDestroy() { - let applicationContext = this.context.getApplicationContext(); - applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); - }); - } - } + let applicationContext = this.context.getApplicationContext(); + let callbackId = 1; + applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { + console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error)); + }); ``` diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md index 66cd6b7150041bdbf45d4d0e0adf105e0ade044b..cf5291224477451554ea36e823ecedc0629cbfe0 100644 --- a/en/application-dev/reference/apis/js-apis-application-context.md +++ b/en/application-dev/reference/apis/js-apis-application-context.md @@ -1,39 +1,43 @@ # Context +The **Context** module provides the context for running code. You can use the APIs to query and set the application information and resource manager. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Provides the context for running code, including **applicationInfo** and **resourceManager**. - -## Modules to Import -``` -import AbilityContext from '@ohos.application.Ability'; -``` - ## Usage You must extend **AbilityContext** to implement this module. + ```js +import AbilityContext from '@ohos.application.Ability' + class MainAbility extends AbilityContext { + onWindowStageCreate(windowStage) { + let test = "com.example.test"; + let context = this.context.createBundleContext(test); + } + } + ``` + ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.| +| resourceManager | resmgr.ResourceManager; | Yes| No| **ResourceManager** object.| | applicationInfo | ApplicationInfo | Yes| No| Information about the application.| | cacheDir | string | Yes| No| Cache directory of the application on the internal storage.| | tempDir | string | Yes| No| Temporary file directory of the application.| | filesDir | string | Yes| No| File directory of the application on the internal storage.| | databaseDir | string | Yes| No| Storage directory of local data.| -| storageDir | string | Yes| No| Storage directory of lightweight data.| | bundleCodeDir | string | Yes| No| Application installation path.| | distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.| | eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.| | area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.| - +| preferencesDir | string | Yes| Yes| Preferences directory of the application.| ## Context.createBundleContext @@ -41,19 +45,23 @@ createBundleContext(bundleName: string): Context; Creates a context for a given application. +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Application bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | Yes| Application bundle name.| **Return value** - | Type| Description| - | -------- | -------- | - | Context | Context created.| +| Type| Description| +| -------- | -------- | +| Context | Context created.| **Example** @@ -79,15 +87,15 @@ Creates a context for a given HAP. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | moduleName | string | Yes| HAP name in the application.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| moduleName | string | Yes| HAP name in the application.| **Return value** - | Type| Description| - | -------- | -------- | - | Context | Context created.| +| Type| Description| +| -------- | -------- | +| Context | Context created.| **Example** @@ -111,18 +119,20 @@ Creates a context for a given HAP in an application. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Application bundle name.| - | moduleName | string | Yes| HAP name in the application.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | Yes| Application bundle name.| +| moduleName | string | Yes| HAP name in the application.| **Return value** - | Type| Description| - | -------- | -------- | - | Context | Context created.| +| Type| Description| +| -------- | -------- | +| Context | Context created.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-application-missionInfo.md b/en/application-dev/reference/apis/js-apis-application-missionInfo.md deleted file mode 100644 index 05938521e10970192409f856e68b816c18d3f3f0..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-application-missionInfo.md +++ /dev/null @@ -1,28 +0,0 @@ -# MissionInfo - -> **NOTE** -> -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -## Modules to Import - -```js -import MissionInfo from '@ohos.application.missionInfo' -``` - -## MissionInfo - -Provides the mission information. - -**System capability**: SystemCapability.Ability.AbilityBase - -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| missionId | number | Yes| Yes| Mission ID.| -| runningState | number | Yes| Yes| Running state of the mission.| -| lockedState | boolean | Yes| Yes| Locked state of the mission.| -| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| -| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.| -| label | string | Yes| Yes| Label of the mission.| -| iconPath | string | Yes| Yes| Path of the mission icon.| -| continuable | boolean | Yes| Yes| Whether the mission is continuable.| diff --git a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md index e0cddeee652418cdd714507cee826971fce73e28..9c47b27f1173eba688942f542cf8eef6e9c90666 100644 --- a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md +++ b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md @@ -1,20 +1,34 @@ # ShellCmdResult +The **ShellCmdResult** module provides the shell command execution result. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Usage + +The result is obtained by calling **executeShellCommand** in **abilityDelegator**. ```js import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +var abilityDelegator; +var cmd = "cmd"; +var timeout = 100; + +abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => { + console.info("executeShellCommand promise"); +}); ``` ## ShellCmdResult Describes the shell command execution result. +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + | Name | Type | Readable| Writable| Description | | --------- | ------ | ---- | ---- | ------------------------------------------------------------ | -| stdResult | string | Yes | Yes | Standard output content.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| -| exitCode | number | Yes | Yes | Result code.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core| +| stdResult | string | Yes | Yes | Standard output content. | +| exitCode | number | Yes | Yes | Result code. | diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index abd004e82d684fc3b038aebf8fb1153602137476..7c5ba607718d5d14317a55645627022b78976461 100644 --- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -1,5 +1,7 @@ # StaticSubscriberExtensionAbility +The **StaticSubscriberExtensionAbility** module provides Extension abilities for static subscribers. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -16,13 +18,15 @@ onReceiveEvent(event: CommonEventData): void; Callback of the common event of a static subscriber. -**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | event | CommonEventData | Yes| Callback of the common event of a static subscriber.| + | event | CommonEventData | Yes| Common event of a static subscriber.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md index 236ed9c1af1231ebb1ddc8c63356a20f57cb3010..05ff78e77e6d6d54527148782b18d0dbca007cd6 100644 --- a/en/application-dev/reference/apis/js-apis-appmanager.md +++ b/en/application-dev/reference/apis/js-apis-appmanager.md @@ -1,21 +1,17 @@ # appManager +The **appManager** module implements application management. You can use the APIs of this module to query whether the application is undergoing a stability test, whether the application is running on a RAM constrained device, the memory size of the application, and information about the running process. + > **NOTE** > > 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. - -Implements application management. - - ## Modules to Import - ```js import app from '@ohos.application.appManager'; ``` - ## appManager.isRunningInStabilityTest<sup>8+</sup> static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void @@ -165,6 +161,8 @@ getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>; Obtains information about the running processes. This API uses a promise to return the result. +**Required permissions**: ohos.permission.GET_RUNNING_INFO + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Return value** @@ -189,6 +187,8 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo Obtains information about the running processes. This API uses an asynchronous callback to return the result. +**Required permissions**: ohos.permission.GET_RUNNING_INFO + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **Parameters** @@ -206,13 +206,533 @@ Obtains information about the running processes. This API uses an asynchronous c }) ``` -## ProcessRunningInfo +## appManager.registerApplicationStateObserver<sup>8+</sup> + +registerApplicationStateObserver(observer: ApplicationStateObserver): number; + +Registers the application state observer. + +**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observer | ApplicationStateObserver | No| Numeric code of the observer.| + +**Example** + + ```js + var applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log('------------ onForegroundApplicationChanged -----------', appStateData); + }, + onAbilityStateChanged(abilityStateData) { + console.log('------------ onAbilityStateChanged -----------', abilityStateData); + }, + onProcessCreated(processData) { + console.log('------------ onProcessCreated -----------', processData); + }, + onProcessDied(processData) { + console.log('------------ onProcessDied -----------', processData); + } + } + const observerCode = app.registerApplicationStateObserver(applicationStateObserver); + console.log('-------- observerCode: ---------', observerCode); + + ``` +## appManager.unregisterApplicationStateObserver<sup>8+</sup> + +unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\<void>): void; + +Deregisters the application state observer. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observerId | number | No| Numeric code of the observer.| +| callback | AsyncCallback\<void> | No| Callback used to return the result.| + +**Example** + + ```js + var observerId = 100; + + function unregisterApplicationStateObserverCallback(err) { + if (err) { + console.log('------------ unregisterApplicationStateObserverCallback ------------', err); + } + } + app.unregisterApplicationStateObserver(observerId, unregisterApplicationStateObserverCallback); + ``` + +## appManager.unregisterApplicationStateObserver<sup>8+</sup> + +unregisterApplicationStateObserver(observerId: number): Promise\<void>; + +Deregisters the application state observer. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| observerId | number | No| Numeric code of the observer.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + var observerId = 100; + + app.unregisterApplicationStateObserver(observerId) + .then((data) => { + console.log('----------- unregisterApplicationStateObserver success ----------', data); + }) + .catch((err) => { + console.log('----------- unregisterApplicationStateObserver fail ----------', err); + }) + ``` + +## appManager.getForegroundApplications<sup>8+</sup> + +getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void; + +Obtains applications that run in the foreground. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_RUNNING_INFO + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback\<Array\<AppStateData>> | No| Callback used to return the application state data.| + +**Example** + + ```js + function getForegroundApplicationsCallback(err, data) { + if (err) { + console.log('--------- getForegroundApplicationsCallback fail ---------', err); + } else { + console.log('--------- getForegroundApplicationsCallback success ---------', data) + } + } + app.getForegroundApplications(getForegroundApplicationsCallback); + ``` + +## appManager.getForegroundApplications<sup>8+</sup> + +getForegroundApplications(): Promise\<Array\<AppStateData>>; + +Obtains applications that run in the foreground. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_RUNNING_INFO + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\<Array\<ProcessRunningInfo>> | Promise used to return the application state data.| + +**Example** + + ```js + app.getForegroundApplications() + .then((data) => { + console.log('--------- getForegroundApplications success -------', data); + }) + .catch((err) => { + console.log('--------- getForegroundApplications fail -------', err); + }) + ``` + +## appManager.killProcessWithAccount<sup>8+</sup> + +killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> + +Kills the process by bundle name and account ID. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of an application.| + | accountId | number | Yes| Account ID.| + +**Example** + +```js +var bundleName = 'bundleName'; +var accountId = 0; +app.killProcessWithAccount(bundleName, accountId) + .then((data) => { + console.log('------------ killProcessWithAccount success ------------', data); + }) + .catch((err) => { + console.log('------------ killProcessWithAccount fail ------------', err); + }) +``` + + +## appManager.killProcessWithAccount<sup>8+</sup> + +killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\<void\>): void + +Kills the process by bundle name and account ID. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | bundleName | string | Yes| Bundle name of an application.| + | accountId | number | Yes| Account ID.| + | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + +```js +var bundleName = 'bundleName'; +var accountId = 0; +function killProcessWithAccountCallback(err, data) { + if (err) { + console.log('------------- killProcessWithAccountCallback fail, err: --------------', err); + } else { + console.log('------------- killProcessWithAccountCallback success, data: --------------', data); + } +} +app.killProcessWithAccount(bundleName, accountId, killProcessWithAccountCallback); +``` + +## appManager.killProcessesByBundleName<sup>8+</sup> + +killProcessesByBundleName(bundleName: string, callback: AsyncCallback\<void>); + +Kills a process by bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.CLEAN_BACKGROUND_PROCESSES + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | No| Bundle name of an application.| +| callback | AsyncCallback\<void> | No| Callback used to return the result.| + +**Example** + + ```js + var bundleName = 'bundleName'; + function killProcessesByBundleNameCallback(err, data) { + if (err) { + console.log('------------- killProcessesByBundleNameCallback fail, err: --------------', err); + } else { + console.log('------------- killProcessesByBundleNameCallback success, data: --------------', data); + } + } + app.killProcessesByBundleName(bundleName, killProcessesByBundleNameCallback); + ``` + +## appManager.killProcessesByBundleName<sup>8+</sup> + +killProcessesByBundleName(bundleName: string): Promise\<void>; + +Kills a process by bundle name. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.CLEAN_BACKGROUND_PROCESSES + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | No| Bundle name of an application.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js +var bundleName = 'bundleName'; +app.killProcessesByBundleName(bundleName) + .then((data) => { + console.log('------------ killProcessesByBundleName success ------------', data); + }) + .catch((err) => { + console.log('------------ killProcessesByBundleName fail ------------', err); + }) + + ``` + +## appManager.clearUpApplicationData<sup>8+</sup> + +clearUpApplicationData(bundleName: string, callback: AsyncCallback\<void>); + +Clears application data by bundle name. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.CLEAN_APPLICATION_DATA + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | No| Bundle name of an application.| +| callback | AsyncCallback\<void> | No| Callback used to return the result.| + +**Example** + + ```js + var bundleName = 'bundleName'; + function clearUpApplicationDataCallback(err, data) { + if (err) { + console.log('------------- clearUpApplicationDataCallback fail, err: --------------', err); + } else { + console.log('------------- clearUpApplicationDataCallback success, data: --------------', data); + } + } + app.clearUpApplicationData(bundleName, clearUpApplicationDataCallback); + + ``` + +## appManager.clearUpApplicationData<sup>8+</sup> + +clearUpApplicationData(bundleName: string): Promise\<void>; + +Clears application data by bundle name. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.CLEAN_APPLICATION_DATA + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| bundleName | string | No| Bundle name of an application.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + var bundleName = 'bundleName'; + app.clearUpApplicationData(bundleName) + .then((data) => { + console.log('------------ clearUpApplicationData success ------------', data); + }) + .catch((err) => { + console.log('------------ clearUpApplicationData fail ------------', err); + }) + + ``` + +## ApplicationStateObserver.onForegroundApplicationChanged<sup>8+</sup> + +onForegroundApplicationChanged(appStateData: AppStateData): void; + +Called when the application state changes. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| appStateData | [AppStateData](#appstatedata) | No| Information about the application whose state is changed.| + +**Example** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const foregroundApplicationInfo = ApplicationStateObserver.onForegroundApplicationChanged(); +console.log('-------- foregroundApplicationInfo: ---------', foregroundApplicationInfo); +``` + +## ApplicationStateObserver.onAbilityStateChanged<sup>8+</sup> + +onAbilityStateChanged(abilityStateData: AbilityStateData): void; + +Called when the ability state changes. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| abilityStateData | [AbilityStateData](#abilitystatedata) | No| Information about the ability whose state is changed.| + +**Example** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const abilityStateChangedInfo = ApplicationStateObserver.onAbilityStateChanged(); +console.log('-------- abilityStateChangedInfo: ---------', abilityStateChangedInfo); +``` + +## ApplicationStateObserver.onProcessCreated<sup>8+</sup> + +onProcessCreated(processData: ProcessData): void; + +Called when a process is created. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| processData | [ProcessData](#processdata) | No| Process information.| + +**Example** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const processCreatedInfo = ApplicationStateObserver.onProcessCreated(); +console.log('-------- processCreatedInfo: ---------', processCreatedInfo); +``` + +## ApplicationStateObserver.onProcessDied<sup>8+</sup> + +onProcessDied(processData: ProcessData): void; + +Called when a process is terminated. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| processData | ProcessData | No| Process information.| + +**Example** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const processDiedInfo = ApplicationStateObserver.onProcessDied(); +console.log('-------- processDiedInfo: ---------', processDiedInfo); +``` + +## AppStateData + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + | Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| pid<sup>8+</sup> | Read only | number | No | Process ID. | +| bundleName<sup>8+</sup> | Read only | string | No | Bundle name of an application. | | uid<sup>8+</sup> | Read only | number | No | User ID.| -| processName<sup>8+</sup> | Read only | string | No | Process name.| -| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.| +| state<sup>8+</sup> | Read only | number | No | Application state.| + +## AbilityStateData + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| pid<sup>8+</sup> | number | Yes | No | Process ID. | +| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. | +| abilityName<sup>8+</sup> | string | Yes | No | Ability name. | +| uid<sup>8+</sup> | number | Yes | No | User ID. | +| state<sup>8+</sup> | number | Yes | No | Application information. | +| moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the ability belongs. | +| abilityType<sup>8+</sup> | string | Yes | No | Ability type. | + +## ProcessData + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| pid<sup>8+</sup> | number | Yes | No | Process ID. | +| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. | +| uid<sup>8+</sup> | number | Yes | No | User ID. | + + + +## ProcessRunningInfo + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Readable/Writable| Type | Mandatory| Description | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| pid<sup>9+</sup> | Read only | number | No | Process ID. | +| uid<sup>9+</sup> | Read only | number | No | User ID.| +| processName<sup>9+</sup> | Read only | string | No | Process name.| +| bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.| diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 894370d603afe13fef35c965beb2adaec6f1ef8b..68d01ed3f45885cf6b53fb3de35fc9b3e6c45da5 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -2273,7 +2273,43 @@ Writes the buffer. This API uses an asynchronous callback to return the result. ``` import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility' +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.streamUsage.STREAM_USAGE_VOICE_COMMUNICATION + rendererFlags: 1 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data)=> { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); + }); +var bufferSize; +audioRenderer.getBufferSize().then((data)=> { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); + bufferSize = data; + }).catch((err) => { + console.info.('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); + }); +console.info('Buffer size:'+bufferSize); +var context = featureAbility.getContext(); +var path = await context.getCacheDir(); +var filePath = path+"/StarWars10s-2C-48000-4SW.wav" let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); ss.readSync(buf); @@ -2305,7 +2341,42 @@ Writes the buffer. This API uses a promise to return the result. ``` import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility' + +var audioStreamInfo = { + samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels:audio.AudioChannel.CHANNEL_2, + sampleFormat.audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType.audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.streamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 +} +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); + }); +var bufferSize; +audioRenderer.getBufferSize().then((data) => { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); + }); +console.info('BufferSize: ' + bufferSize); +var context = featureAbility.getContext(); +var path = await context.getCacheDir(); var filePath = 'data/StarWars10s-2C-48000-4SW.wav'; let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); @@ -2408,12 +2479,39 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a **Example** ``` +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; + +var audioStreamInfo = { + samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels:audio.AudioChannel.CHANNEL_2, + sampleFormat.audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType.audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.streamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: '+err.message); + }); var bufferSize; -await audioRenderer.getBufferSize().then(async function (data) => { - console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data); +audioRenderer.getBufferSize().then((data) => { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS '+data); bufferSize=data; }).catch((err) => { - console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message); + console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: '+err.message); }); ``` @@ -2542,7 +2640,8 @@ Sets the audio interruption mode for the application. This API uses a promise to **Example** ``` -audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE).then(() => { +const audioManager = audio.getAudioManager(); +audioManager.setInterruptMode(audio.InterruptMode.SHARE_MODE).then(() => { console.log('Promise returned to indicate a successful volume setting.'); }); ``` @@ -2564,7 +2663,8 @@ Sets the audio interruption mode for the application. This API uses a callback t **Example** ``` -audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE,()=>{ +const audioManager = audio.getAudioManager(); +audioManager.setInterruptMode(audio.InterruptMode.SHARE_MODE,()=>{ console.log('Callback returned to indicate a successful volume setting.'); }); ``` @@ -2654,7 +2754,7 @@ Subscribes to mark reached events. When the number of frames rendered reaches th ``` audioRenderer.on('markReach', 1000, (position) => { - if (position == "1000") { + if (position == 1000) { console.log('ON Triggered successfully'); } }); @@ -2701,7 +2801,7 @@ Subscribes to period reached events. When the period of frame rendering reaches ``` audioRenderer.on('periodReach', 1000, (position) => { - if (position == "1000") { + if (position == 1000) { console.log('ON Triggered successfully'); } }); @@ -2935,13 +3035,35 @@ Starts capturing. This API uses a promise to return the result. **Example** ``` +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; + +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags = 1 +} + +var audioCapturer; +audio.createAudioCapturer(audioCapturerOptions).then((data) => { + audioCapturer = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created: ERROR: '+err.message); + }); audioCapturer.start().then(() => { console.info('AudioFrameworkRecLog: ---------START---------'); - console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); - console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state); - console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer: STATE: '+audioCapturer.state); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS '); if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { - stateFlag = true; + console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); } }).catch((err) => { console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); @@ -2994,15 +3116,13 @@ Stops capturing. This API uses a promise to return the result. ``` audioCapturer.stop().then(() => { - console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); - console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS'); if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ - stateFlag=true; - console.info('AudioFrameworkRecLog: resultFlag : '+stateFlag); + console.info('AudioFrameworkRecLog: State is Stopped': '); } }).catch((err) => { - console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); - stateFlag=false; + console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message); }); ``` @@ -3054,11 +3174,9 @@ audioCapturer.release().then(() => { console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state); - stateFlag=true; console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); }).catch((err) => { - console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); - stateFlag=false + console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+err.message); }); ``` @@ -3082,6 +3200,13 @@ Reads the buffer. This API uses an asynchronous callback to return the result. **Example** ``` +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize: EROOR: '+err.message); + }); audioCapturer.read(bufferSize, true, async(err, buffer) => { if (!err) { console.log("Success in reading the buffer data"); @@ -3114,6 +3239,14 @@ Reads the buffer. This API uses a promise to return the result. **Example** ``` +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS '+data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize: ERROR '+err.message); + }); +console.info('Buffer size: ' + bufferSize); audioCapturer.read(bufferSize, true).then((buffer) => { console.info('buffer read successfully'); }).catch((err) => { @@ -3217,12 +3350,12 @@ Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a **Example** ``` -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('AudioFrameworkRecordLog: getBufferSize :ERROR : '+err.message); +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize :SUCCESS '+ data); + bufferSize = data; +}).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize :ERROR : '+ err.message); }); ``` @@ -3247,7 +3380,7 @@ Subscribes to mark reached events. When the number of frames captured reaches th ``` audioCapturer.on('markReach', 1000, (position) => { - if (position == "1000") { + if (position == 1000) { console.log('ON Triggered successfully'); } }); @@ -3293,7 +3426,7 @@ Subscribes to mark reached events. When the period of frame capturing reaches th ``` audioCapturer.on('periodReach', 1000, (position) => { - if (position == "1000") { + if (position == 1000) { console.log('ON Triggered successfully'); } }); diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index 5eacfc8a69610d57abec3afdd0fba6f7addaa30b..32dc8d6c6ebea54129c103a2323dacdc34a442c1 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -1011,7 +1011,7 @@ bluetooth.off('sppRead', clientNumber); ``` -## bluetooth.getProfile<sup>8+</sup><a name="getProfile"></a> +## bluetooth.getProfile<sup>8+</sup><a name="bt-getProfile"></a> getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile @@ -1037,9 +1037,9 @@ Obtains a profile object. let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); ``` -## bluetooth.getProfile<sup>9+</sup><a name="getProfile"></a> +## bluetooth.getProfileInst<sup>9+</sup><a name="getProfileInst"></a> -getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile +getProfileInst(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile Obtains a profile instance. API version 9 is added with **HidHostProfile** and **PanProfile**. @@ -1060,7 +1060,7 @@ Obtains a profile instance. API version 9 is added with **HidHostProfile** and * **Example** ```js -let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); +let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST); ``` @@ -1451,14 +1451,12 @@ a2dpSrc.off('connectionStateChange', onReceiveEvent); ``` -### getPlayingState<sup>9+</sup> +### getPlayingState<sup>8+</sup> getPlayingState(device: string): PlayingState Obtains the playing state of a device. -**Required permissions**: ohos.permission.USE_BLUETOOTH - **System capability**: SystemCapability.Communication.Bluetooth.Core **Parameters** @@ -1559,7 +1557,7 @@ Subscribes to the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| -| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HFP connection state change event. | +| callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback used to return the HFP connection state change event. | **Return value** @@ -1612,7 +1610,7 @@ hfpAg.off('connectionStateChange', onReceiveEvent); Before using a method of **HidHostProfile**, you need to create an instance of this class by using the **getProfile()** method. -### connect<sup>9+</sup><a name="connect"></a> +### connect<sup>9+</sup><a name="HidHost-connect"></a> connect(device: string): boolean @@ -1644,7 +1642,7 @@ let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); ``` -### disconnect<sup>9+</sup><a name="disconnect"></a> +### disconnect<sup>9+</sup><a name="HidHost-disconnect"></a> disconnect(device: string): boolean @@ -1742,7 +1740,7 @@ hidHost.off('connectionStateChange', onReceiveEvent); Before using a method of **PanProfile**, you need to create an instance of this class by using the **getProfile()** method. -### disconnect<sup>9+</sup><a name="disconnect"></a> +### disconnect<sup>9+</sup><a name="PanP-disconnect"></a> disconnect(device: string): boolean @@ -1837,7 +1835,7 @@ panProfile.off('connectionStateChange', onReceiveEvent); ### setTethering<sup>9+</sup><a name="setTethering"></a> -setTethering(value: boolean): boolean +setTethering(enable: boolean): void Sets tethering. @@ -1871,12 +1869,10 @@ let ret = panProfile.setTethering(true); isTetheringOn(): boolean -Obtains the tethering status. +Obtains the tethering state. This is a system API. -**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH - **System capability**: SystemCapability.Communication.Bluetooth.Core **Return value** @@ -2019,7 +2015,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; // Create characteristics. @@ -2129,7 +2125,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', @@ -2502,7 +2498,6 @@ let gattServer = bluetooth.BLE.createGattServer(); gattServer.off("descriptorWrite"); ``` - ### on('connectStateChange') on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void @@ -2709,8 +2704,10 @@ Obtains all services of the remote BLE device. This API uses a promise to return ```js // Promise -gattClientDevice.getServices().then(result => { - console.info("Got services successfully:" + JSON.stringify(result)); +let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX'); +device.connect(); +device.getServices().then(result => { + console.info("getServices successfully:" + JSON.stringify(result)); }); ``` @@ -3051,7 +3048,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', @@ -3311,7 +3308,7 @@ Enumerates the scan modes. **System capability**: SystemCapability.Communication.Bluetooth.Core -| Name | Default Value | Description | +| Name | Default Value | Description | | ---------------------------------------- | ---- | --------------- | | SCAN_MODE_NONE | 0 | No scan mode. | | SCAN_MODE_CONNECTABLE | 1 | Connectable mode. | @@ -3326,7 +3323,7 @@ Enumerates the pairing states. **System capability**: SystemCapability.Communication.Bluetooth.Core -| Name | Default Value | Description | +| Name | Default Value | Description | | ------------------ | ---- | ------ | | BOND_STATE_INVALID | 0 | Invalid pairing.| | BOND_STATE_BONDING | 1 | Pairing. | @@ -3352,7 +3349,7 @@ Enumerates the SPP link types. **System capability**: SystemCapability.Communication.Bluetooth.Core -| Name | Default Value | Description | +| Name | Default Value | Description | | ---------- | ---- | ------------- | | SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.| @@ -3536,7 +3533,7 @@ Defines the scan filter parameters. | serviceSolicitationUuidMask<sup>9+</sup> | string | Yes | Yes | Service solicitation UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.| | serviceData<sup>9+</sup> | ArrayBuffer | Yes | Yes | Service data of the device to filter, for example, **[0x90, 0x00, 0xF1, 0xF2]**.| | serviceDataMask<sup>9+</sup> | ArrayBuffer | Yes | Yes | Service data mask of the device to filter, for example, **[0xFF,0xFF,0xFF,0xFF]**.| -| manufacturerId<sup>9+</sup> | number | Yes | Yes | Manufacturer ID of the device to filter, for example, **0x0006**. | +| manufactureId<sup>9+</sup> | number | Yes | Yes | Manufacturer ID of the device to filter, for example, **0x0006**. | | manufactureData<sup>9+</sup> | ArrayBuffer | Yes | Yes | Manufacturer data of the device to filter, for example, **[0x1F,0x2F,0x3F]**.| | manufactureDataMask<sup>9+</sup> | ArrayBuffer | Yes | Yes | Manufacturer data mask of the device to filter, for example, **[0xFF, 0xFF, 0xFF]**.| @@ -3617,7 +3614,7 @@ Defines the BLE advertising parameters. | Name | Type | Readable | Writable | Description | | ----------- | ------- | ---- | ---- | ---------------------------------------- | -| interval | number | Yes | Yes | Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16777215** slots. The default value is **1600** slots (1s).| +| interval | number | Yes | Yes | Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16384** slots. The default value is **1600** slots (1s).| | txPower | number | Yes | Yes | Transmit power, in dBm. The value range is -127 to 1. The default value is **-7**. | | connectable | boolean | Yes | Yes | Whether the advertisement is connectable. The default value is **true**. | @@ -3828,7 +3825,7 @@ Enumerates the A2DP playing states. ## ProfileId<sup>8+</sup><a name="ProfileId"></a> -Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST**. +Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST** and **PROFILE_PAN_NETWORK**. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -3837,3 +3834,4 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS | PROFILE_A2DP_SOURCE | 0x0001 | A2DP profile.| | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | HFP profile. | | PROFILE_HID_HOST<sup>9+</sup> | 0x0006 | Human Interface Device (HID) profile. | +| PROFILE_PAN_NETWORK<sup>9+</sup> | 0x0007 | PAN profile. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md index 185338803c92789aea72fa0fca2ab7791ab89ea1..94182ce2915f60bd6998f512d17288920549d3f8 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @@ -1,17 +1,15 @@ # ApplicationInfo +The **ApplicationInfo** module provides application information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. + > **NOTE** > > 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. -Provides the application information. - ## ApplicationInfo **System capability**: SystemCapability.BundleManager.BundleFramework - - | Name | Type | Readable| Writable| Description | | -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | | name | string | Yes | No | Application name. | @@ -26,16 +24,19 @@ Provides the application information. | process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. | | supportedModes | number | Yes | No | Running modes supported by the application. | | moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. | -| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. | +| permissions | Array\<string> | Yes | No | Permissions required for accessing the application.<br>The value is obtained by passing **GET_APPLICATION_INFO_WITH_PERMISSION**.| | moduleInfos | Array\<[ModuleInfo](js-apis-bundle-ModuleInfo.md)> | Yes | No | Application module information. | | entryDir | string | Yes | No | Path for storing application files. | | codePath<sup>8+</sup> | string | Yes | No | Installation directory of the application. | -| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | Yes | No | Custom metadata of the application. | -| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | Yes | No | Metadata of the application. | +| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | Yes | No | Custom metadata of the application.<br>The value is obtained by passing **GET_APPLICATION_INFO_WITH_METADATA**.| +| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | Yes | No | Metadata of the application.<br>The value is obtained by passing **GET_APPLICATION_INFO_WITH_METADATA**.| | removable<sup>8+</sup> | boolean | Yes | No | Whether the application is removable. | | 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 request for 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 request for the application.<br>The value is obtained by passing **GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT**.| +| iconResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Icon resource of the application.| +| labelResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Label resource of the application.| +| descriptionResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application.| | appDistributionType<sup>9+</sup> | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. | | appProvisionType<sup>9+</sup> | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md index f9e8ea3be2d7ccfff71426848d2dbc2f0e349201..eb85e5d52d50068b8147c1a4789389b2cf5506e1 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-BundleInfo.md @@ -1,45 +1,41 @@ # BundleInfo - - > **NOTE** > > 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. - - -Provides the application bundle information. +The **BundleInfo** module provides bundle information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. ## BundleInfo **System capability**: SystemCapability.BundleManager.BundleFramework -| Name | Type | Readable| Writable| Description | -| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------ | -| name | string | Yes | No | Bundle name. | -| type | string | Yes | No | Bundle type. | -| appId | string | Yes | No | ID of the application to which the bundle belongs. | -| uid | number | Yes | No | UID of the application to which the bundle belongs. | -| installTime | number | Yes | No | Time when the HAP file was installed. | -| updateTime | number | Yes | No | Time when the HAP file was updated. | -| appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. | -| abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | No | Ability configuration information. | -| reqPermissions | Array\<string> | Yes | No | Permissions to request from the system for running the application. | -| reqPermissionDetails | Array\<[ReqPermissionDetail](#ReqPermissionDetail)> | Yes | No | Detailed information of the permissions to request from the system.| -| vendor | string | Yes | No | Vendor of the bundle. | -| versionCode | number | Yes | No | Version number of the bundle. | -| versionName | string | Yes | No | Version description of the bundle. | -| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. | -| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. | -| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. | -| hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | No | Module configuration information. | -| entryModuleName | string | Yes | No | Name of the entry module. | -| cpuAbi | string | Yes | No | cpuAbi information of the bundle. | -| isSilentInstallation | string | Yes | No | Whether the application can be installed in silent mode. | -| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | -| entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. | -| reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. | -| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Extension ability information. | +| Name | Type | Readable| Writable| Description | +| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| name | string | Yes | No | Bundle name. | +| type | string | Yes | No | Bundle type. | +| appId | string | Yes | No | ID of the application to which the bundle belongs. | +| uid | number | Yes | No | UID of the application to which the bundle belongs. | +| installTime | number | Yes | No | Time when the HAP file was installed. | +| updateTime | number | Yes | No | Time when the HAP file was updated. | +| appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application configuration information. | +| abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | Yes | No | Ability configuration information.<br>The value is obtained by passing **GET_BUNDLE_WITH_ABILITIES**.| +| reqPermissions | Array\<string> | Yes | No | Permissions to request from the system for running the application.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.| +| reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | Yes | No | Detailed information of the permissions to request from the system.<br>The value is obtained by passing **GET_BUNDLE_WITH_REQUESTED_PERMISSION**.| +| vendor | string | Yes | No | Vendor of the bundle. | +| versionCode | number | Yes | No | Version number of the bundle. | +| versionName | string | Yes | No | Version description of the bundle. | +| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. | +| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. | +| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. | +| hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | Yes | No | Module configuration information. | +| entryModuleName | string | Yes | No | Name of the entry module. | +| cpuAbi | string | Yes | No | CPU and ABI information of the bundle. | +| isSilentInstallation | string | Yes | No | Whether the application can be installed in silent mode. | +| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | +| entryInstallationFree | boolean | Yes | No | Whether installation-free is supported for the entry module. | +| reqPermissionStates<sup>8+</sup> | Array\<number> | Yes | No | Permission grant state. | +| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Extension ability information.<br>The value is obtained by passing **GET_BUNDLE_WITH_EXTENSION_ABILITY**.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md index 3c98a25b721a8f3cce41f927d7a35456761db366..9b11bb2f18da535af770b96cda13981cef95c62a 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md @@ -6,9 +6,7 @@ > > 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. - - -Provides the Extension ability information. +The **ExtensionAbilityInfo** module provides Extension ability information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. ## ExtensionAbilityInfo @@ -28,5 +26,5 @@ Provides the Extension ability information. | applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the Extension ability. | | metadata | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the Extension ability. | | enabled | boolean | Yes | No | Whether the Extension ability is enabled. | -| readPermission | string | Yes | No | Permission required for reading the Extension ability data. | +| readPermission | string | Yes | No | Permission required for reading data from the Extension ability. | | writePermission | string | Yes | No | Permission required for writing data to the Extension ability. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md b/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md index 2f6dbbef26e41ec1f78fe5768c2389d1a8ee0578..5a11609281eebb7464b1e627ec432b4ffad72700 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md @@ -6,16 +6,12 @@ > > 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. - - -Provides the HAP module information. +The **HapModuleInfo** module provides module information. Unless otherwise specified, all attributes are obtained through **GET_BUNDLE_DEFAULT**. ## HapModuleInfo **System capability**: SystemCapability.BundleManager.BundleFramework - - | Name | Type | Readable| Writable| Description | | --------------------------------- | ------------------------------------------------------------ | ---- | ---- | -------------------- | | name | string | Yes | No | Module name. | @@ -36,4 +32,4 @@ Provides the HAP module information. | mainElementName<sup>9+</sup> | string | Yes | No | Information about the main ability. | | extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Information about the Extension ability.| | metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. | -| hashValue<sup>9+</sup> | string | Yes | No | Hash value of the module. | +| hashValue<sup>9+</sup> | string | Yes | No | Hash value of the module.<br>The value is obtained by passing **GET_BUNDLE_WITH_HASH_VALUE**.| diff --git a/en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md b/en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md new file mode 100644 index 0000000000000000000000000000000000000000..e80cf7f78b02192642a29794feaf794052bd4dc4 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md @@ -0,0 +1,474 @@ +# DefaultAppManager + +The **DefaultAppManager** module provides APIs to query whether the current application is the default application of a specific type. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import defaultAppMgr from '@ohos.bundle.defaultAppManager' +``` +## defaultAppMgr.ApplicationType + +Enumerates the application types. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +| Name | Type | Description | +| -------- | -------- | -------------------------------------- | +| BROWSER | string | Default browser. | +| IMAGE | string | Default image viewer. | +| AUDIO | string | Default audio player. | +| VIDEO | string | Default video player. | +| PDF | string | Default PDF reader. | +| WORD | string | Default Word viewer. | +| EXCEL | string | Default Excel viewer. | +| PPT | string | Default PowerPoint viewer. | + +## defaultAppMgr.isDefaultApplication + +isDefaultApplication(type: string): Promise\<boolean> + +Checks whether this application is the default application of a system-defined application type. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype). | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<boolean> | Promise used to return the result. If the application is the default application, `true` is returned; otherwise, `false` is returned.| + +**Example** + +```js +defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) +.then((data) => { + console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); +``` + +## defaultAppMgr.isDefaultApplication + +isDefaultApplication(type: string, callback: AsyncCallback\<boolean>): void + +Checks whether this application is the default application of a system-defined application type. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------------------------------- | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype). | +| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. If the application is the default application, `true` is returned; otherwise, `false` is returned.| + +**Example** + +```js +defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. IsDefaultApplication ? ' + JSON.stringify(data)); + }); +``` + +## defaultAppMgr.getDefaultApplication + +getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo> + +Obtains the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| userId | number | No | User ID. The default value is the user ID of the caller. | + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Promise used to return the default application.| + +**Example** + +```js +defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) +.then((data) => { + console.info('Operation successful. bundleInfo: ' + JSON.stringify(data)); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); + +defaultAppMgr.getDefaultApplication("image/png") +.then((data) => { + console.info('Operation successful. bundleInfo: ' + JSON.stringify(data)); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); +``` + +## defaultAppMgr.getDefaultApplication + +getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<BundleInfo>) : void + +Obtains the default application of a user based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the default application. | + +**Example** + +```js +defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); +}); + +defaultAppMgr.getDefaultApplication("image/png", 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); +}); +``` + +## defaultAppMgr.getDefaultApplication + +getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void + +Obtains the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | Yes | Callback used to return the default application. | + +**Example** + +```js +defaultAppMgr.getDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); +}); + +defaultAppMgr.getDefaultApplication("image/png", (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. bundleInfo:' + JSON.stringify(data)); +}); +``` + +## defaultAppMgr.setDefaultApplication + +setDefaultApplication(type: string, elementName: ElementName, userId?: number): Promise\<void> + +Sets the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses a promise to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | +| userId | number | No | User ID. The default value is the user ID of the caller. | + +**Example** + +```js +defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}) +.then((data) => { + console.info('Operation successful.'); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); + +defaultAppMgr.setDefaultApplication("image/png", { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}) +.then((data) => { + console.info('Operation successful.'); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); +``` + +## defaultAppMgr.setDefaultApplication + +setDefaultApplication(type: string, elementName: ElementName, userId: number, callback: AsyncCallback\<void>) : void; + +Sets the default application for a user based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}, 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); + }); + +defaultAppMgr.setDefaultApplication("image/png", { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}, 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); + }); +``` + +## defaultAppMgr.setDefaultApplication + +setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCallback\<void>) : void; + +Sets the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | Yes | Information about the element to be set as the default application. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +defaultAppMgr.setDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); + }); + +defaultAppMgr.setDefaultApplication("image/png", { + bundleName: "com.test.app", + moduleName: "module01", + abilityName: "MainAbility" +}, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); + }); +``` + +## defaultAppMgr.resetDefaultApplication + +resetDefaultApplication(type: string, userId?: number): Promise\<void> + +Resets the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses a promise to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| userId | number | No | User ID. The default value is the user ID of the caller. | + +**Example** + +```js +defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER) +.then((data) => { + console.info('Operation successful.'); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); + +defaultAppMgr.resetDefaultApplication("image/png") +.then((data) => { + console.info('Operation successful.'); +}) +.catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}); +``` + +## defaultAppMgr.resetDefaultApplication + +resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<void>) : void; + +Resets the default application for a user based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| userId | number | Yes | User ID. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); +}); + +defaultAppMgr.resetDefaultApplication("image/png", 100, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); +}); +``` + +## defaultAppMgr.resetDefaultApplication + +resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; + +Resets the default application based on a system-defined application type or a file type that complies with the media type format (either specified by **type** or **subtype**). This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.SET_DEFAULT_APPLICATION + +**System capability**: SystemCapability.BundleManager.BundleFramework + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----------- | ------ | ---- | --------------------------------------- | +| type | string | Yes | Type of the target application. It must be set to a value defined by [ApplicationType](#defaultappmgrapplicationtype) or a file type that complies with the media type format. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +defaultAppMgr.resetDefaultApplication(defaultAppMgr.ApplicationType.BROWSER, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); +}); + +defaultAppMgr.resetDefaultApplication("image/png", (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful.'); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-bytrace.md b/en/application-dev/reference/apis/js-apis-bytrace.md index 3d532293b18ca1b262feabe80615dc1807ac30dc..72fcfaca8fb39e4345c2392e761b19b364922499 100644 --- a/en/application-dev/reference/apis/js-apis-bytrace.md +++ b/en/application-dev/reference/apis/js-apis-bytrace.md @@ -7,7 +7,7 @@ ## Modules to Import -``` + ```js import bytrace from '@ohos.bytrace'; ``` @@ -35,7 +35,7 @@ Marks the start of a timeslice trace task. **Example** -``` + ```js bytrace.startTrace("myTestFunc", 1); bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms. ``` @@ -62,7 +62,7 @@ Marks the end of a timeslice trace task. **Example** -``` + ```js bytrace.finishTrace("myTestFunc", 1); ``` @@ -105,7 +105,7 @@ Defines the variable that indicates the number of timeslice trace tasks. **Example** -``` + ```js let traceCount = 3; bytrace.traceByValue("myTestCount", traceCount); traceCount = 4; diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 43f15f6c7b3666fc53f69deadb0043e6adacca46..1298f29856048924fd2a7e8397724aa9fc0df8ee 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -347,7 +347,7 @@ After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera ```js async function getCameraInfo("cameraId") { - var cameraManager = await camera.getCameraManager(); + var cameraManager = await camera.getCameraManager(context); var cameras = await cameraManager.getCameras(); var cameraObj = cameras[0]; var cameraId = cameraObj.cameraId; @@ -2231,6 +2231,10 @@ Captures a photo with the specified capture settings. This API uses an asynchron **Example** ```js +let settings:PhotoCaptureSetting = { + quality = 1, + rotation = 0 +} photoOutput.capture(settings, (err) => { if (err) { console.error('Failed to capture the photo ${err.message}'); @@ -2359,7 +2363,7 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu **Example** ```js -photoOutput.on('frameShutter', (frameShutterInfo) => { +photoOutput.on('frameShutter', (err, frameShutterInfo) => { console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); }) @@ -2383,7 +2387,7 @@ Listens for photo capture end events. This API uses an asynchronous callback to **Example** ```js -photoOutput.on('captureEnd', (captureEndInfo) => { +photoOutput.on('captureEnd', (err, captureEndInfo) => { console.log('photo capture end, captureId : ' + captureEndInfo.captureId); console.log('frameCount : ' + captureEndInfo.frameCount); }) @@ -2407,7 +2411,7 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error **Example** ```js -photoOutput.on('error', (photoOutputError) => { +photoOutput.on('error', (err, photoOutputError) => { console.log('Photo output error code: ' + photoOutputError.code); }) ``` diff --git a/en/application-dev/reference/apis/js-apis-configuration.md b/en/application-dev/reference/apis/js-apis-configuration.md index 507b8a42448dd4ae892424feaae061c47d814138..14abee7e2d9cca63278e11b16486643d89e56bd0 100644 --- a/en/application-dev/reference/apis/js-apis-configuration.md +++ b/en/application-dev/reference/apis/js-apis-configuration.md @@ -1,11 +1,11 @@ # Configuration +The **Configuration** module provides environment configuration information. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides the configuration for the environment where the ability is running. - ## Modules to Import ```js @@ -23,3 +23,4 @@ import Configuration from '@ohos.application.Configuration'; | direction<sup>9+</sup> | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.| | screenDensity<sup>9+</sup> | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).| | displayId<sup>9+</sup> | number | Yes| No| ID of the display where the application is located.| +| hasPointerDevice<sup>9+</sup> | boolean | Yes| No| Whether the pointer device is connected.| diff --git a/en/application-dev/reference/apis/js-apis-configurationconstant.md b/en/application-dev/reference/apis/js-apis-configurationconstant.md index ebb78bc00e5ece7a6e04e64db6135f9d2f7ed7fd..70d527483a15d7f676402ad406964740a5686a6b 100644 --- a/en/application-dev/reference/apis/js-apis-configurationconstant.md +++ b/en/application-dev/reference/apis/js-apis-configurationconstant.md @@ -1,13 +1,11 @@ # ConfigurationConstant +The **ConfigurationConstant** module provides the enumerated values of the environment configuration information. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -Defines enumerated values of the configuration for the environment where the ability is running. - - ## Modules to Import @@ -15,7 +13,6 @@ Defines enumerated values of the configuration for the environment where the abi import ConfigurationConstant from '@ohos.application.ConfigurationConstant'; ``` - ## ConfigurationConstant.ColorMode You can obtain the value of this constant by calling the **ConfigurationConstant.ColorMode** API. diff --git a/en/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md b/en/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md new file mode 100644 index 0000000000000000000000000000000000000000..cfbfb83e3359a4b7d41cf6ab039d0c1f0552c9eb --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md @@ -0,0 +1,22 @@ +# ContinuationExtraParams + +The **ContinuationExtraParams** module provides the extra parameters required by the device selection module in the continuation management entry. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## ContinuationExtraParams + +Describes the extra parameters required by the device selection module in the continuation management entry. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| deviceType | Array\<string> | Yes| Yes| Device type.| +| targetBundle | string | Yes| Yes| Target bundle name.| +| description | string | Yes| Yes| Device filtering description.| +| filter | any | Yes| Yes| Device filtering parameter.| +| continuationMode | [ContinuationMode](js-apis-continuation-continuationManager.md#continuationmode) | Yes| Yes| Continuation mode.| +| authInfo | { [key: string]: any } | Yes| Yes| Authentication information.| diff --git a/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md new file mode 100644 index 0000000000000000000000000000000000000000..007d35d1408e2381aca841dd64cb9ce6a078b16a --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -0,0 +1,496 @@ +# continuationManager + +The **continuationManager** module provides the continuation management entry. You can use the APIs of this module to connect to and cancel the continuation management service, subscribe to and unsubscribe from device connection events, start the device selection module, and update the device connection state. + +Currently, this module provides incomplete functions, and its APIs are mainly used to start the device selection module. **The continuation capability is not available for application development.** + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import continuationManager from '@ohos.continuation.continuationManager' +``` + +## continuationManager.register + +register(callback: AsyncCallback\<number>): void; + +Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.| + +**Example** + + ```js + let token = -1; + continuationManager.register((err, data) => { + if (err.code != 0) { + console.error('register failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('register finished, ' + JSON.stringify(data)); + token = data; + }); + ``` + +## continuationManager.register + +register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void; + +Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| + | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.| + +**Example** + + ```js + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + continuationManager.register(continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('register failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('register finished, ' + JSON.stringify(data)); + token = data; + }); + ``` + +## continuationManager.register + +register(options?: ContinuationExtraParams): Promise\<number>; + +Registers the continuation management service and obtains a token. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<number> | Promise used to return the token generated after the continuation management service is connected.| + +**Example** + + ```js + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + continuationManager.register(continuationExtraParams) + .then((data) => { + console.info('register finished, ' + JSON.stringify(data)); + token = data; + }) + .catch((err) => { + console.error('register failed, cause: ' + JSON.stringify(err)); + }); + ``` + +## continuationManager.on("deviceConnect")<sup>(deprecated)</sup> +> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect) instead. + +on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; + +Subscribes to device connection events. This API uses an asynchronous callback to return the result. + +## continuationManager.on("deviceDisconnect")<sup>(deprecated)</sup> +> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect) instead. + +on(type: "deviceDisconnect", callback: Callback\<string>): void; + +Subscribes to device disconnection events. This API uses an asynchronous callback to return the result. + +## continuationManager.off("deviceConnect")<sup>(deprecated)</sup> +> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect) instead. + +off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void; + +Unsubscribes from device connection events. This API uses an asynchronous callback to return the result. + +## continuationManager.off("deviceDisconnect")<sup>(deprecated)</sup> +> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect) instead. + +off(type: "deviceDisconnect", callback?: Callback\<string>): void; + +Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result. + +## continuationManager.on("deviceConnect")<sup>9+</sup> + +on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void; + +Subscribes to device connection events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| + +**Example** + + ```js + let token = 1; + continuationManager.on("deviceConnect", token, (data) => { + console.info('onDeviceConnect len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id)); + console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type)); + console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name)); + } + }); + ``` + +## continuationManager.on("deviceDisconnect")<sup>9+</sup> + +on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void; + +Subscribes to device disconnection events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | Callback\<Array\<string>> | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + +**Example** + + ```js + let token = 1; + continuationManager.on("deviceDisconnect", token, (data) => { + console.info('onDeviceDisconnect len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i])); + } + console.info('onDeviceDisconnect finished.'); + }); + ``` + +## continuationManager.off("deviceConnect")<sup>9+</sup> + +off(type: "deviceConnect", token: number): void; + +Unsubscribes from device connection events. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | token | number | Yes| Token obtained after the registration of the continuation management service.| + +**Example** + + ```js + let token = 1; + continuationManager.off("deviceConnect", token); + ``` + +## continuationManager.off("deviceDisconnect")<sup>9+</sup> + +off(type: "deviceDisconnect", token: number): void; + +Unsubscribes from device disconnection events. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | token | number | Yes| Token obtained after the registration of the continuation management service.| + +**Example** + + ```js + let token = 1; + continuationManager.off("deviceDisconnect", token); + ``` + +## continuationManager.startDeviceManager + +startDeviceManager(token: number, callback: AsyncCallback\<void>): void; + +Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + let token = 1; + continuationManager.startDeviceManager(token, (err, data) => { + if (err.code != 0) { + console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startDeviceManager finished, ' + JSON.stringify(data)); + }); + ``` + +## continuationManager.startDeviceManager + +startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void; + +Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| + | callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + continuationManager.startDeviceManager(token, continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startDeviceManager finished, ' + JSON.stringify(data)); + }); + ``` + +## continuationManager.startDeviceManager + +startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>; + +Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + continuationManager.startDeviceManager(token, continuationExtraParams) + .then((data) => { + console.info('startDeviceManager finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); + }); + ``` + +## continuationManager.updateConnectStatus + +updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void; + +Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | deviceId | string | Yes| Device ID.| + | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.| + | callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + let token = 1; + let deviceId: string = "test deviceId"; + continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { + if (err.code != 0) { + console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('updateConnectStatus finished, ' + JSON.stringify(data)); + }); + ``` + +## continuationManager.updateConnectStatus + +updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>; + +Instructs the device selection module to update the device connection state. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | deviceId | string | Yes| Device ID.| + | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + let token = 1; + let deviceId: string = "test deviceId"; + continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) + .then((data) => { + console.info('updateConnectStatus finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); + }); + ``` + +## continuationManager.unregister + +unregister(token: number, callback: AsyncCallback\<void>): void; + +Deregisters the continuation management service. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | AsyncCallback\<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + let token = 1; + continuationManager.unregister(token, (err, data) => { + if (err.code != 0) { + console.error('unregister failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('unregister finished, ' + JSON.stringify(data)); + }); + ``` + +## continuationManager.unregister + +unregister(token: number): Promise\<void>; + +Deregisters the continuation management service. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\<void> | Promise used to return the result.| + +**Example** + + ```js + let token = 1; + continuationManager.unregister(token) + .then((data) => { + console.info('unregister finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('unregister failed, cause: ' + JSON.stringify(err)); + }); + ``` + +## DeviceConnectState + +Enumerates the device connection states. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Value| Description| + | -------- | -------- | -------- | -------- | + | IDLE | number | 0 | The device is in the initial state.| + | CONNECTING | number | 1 | The device is being connected.| + | CONNECTED | number | 2 | The device is connected.| + | DISCONNECTING | number | 3 | The device is being disconnected.| + +## ContinuationMode + +Enumerates the continuation modes provided by the device selection module. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Value| Description| + | -------- | -------- | -------- | -------- | + | COLLABORATION_SINGLE | number | 0 | Single-choice mode.| + | COLLABORATION_MULTIPLE | number | 1 | Multi-choice mode.| diff --git a/en/application-dev/reference/apis/js-apis-continuation-continuationResult.md b/en/application-dev/reference/apis/js-apis-continuation-continuationResult.md new file mode 100644 index 0000000000000000000000000000000000000000..bdebb727ff7b5c6b41868f37bf5ecdb0ea333d10 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-continuation-continuationResult.md @@ -0,0 +1,17 @@ +# ContinuationResult + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## ContinuationResult + +Describes the device information returned by the continuation management entry. + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| id | string | Yes| Yes| Device ID.| +| type | string | Yes| Yes| Device type.| +| name | string | Yes| Yes| Device name.| diff --git a/en/application-dev/reference/apis/js-apis-convertxml.md b/en/application-dev/reference/apis/js-apis-convertxml.md index 3fd4e4e52ca7a82b33dd6a13aa7f425ab2aea9be..43e096b951e7ea4d97ed9e0d40dc0481f34a0290 100644 --- a/en/application-dev/reference/apis/js-apis-convertxml.md +++ b/en/application-dev/reference/apis/js-apis-convertxml.md @@ -1,6 +1,9 @@ # XML-to-JavaScript Conversion -> **NOTE**<br/> +The **convertxml** module provides APIs for converting XML text into JavaScript objects. + +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -47,10 +50,10 @@ let xml = '</note>'; let conv = new convertxml.ConvertXML(); let options = {trim : false, declarationKey:"_declaration", - instructionKey : "_instruction", attributesKey : "_attributes", - textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", - commentKey : "_comment", parentKey : "_parent", typeKey : "_type", - nameKey : "_name", elementsKey : "_elements"} + instructionKey : "_instruction", attributesKey : "_attributes", + textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", + commentKey : "_comment", parentKey : "_parent", typeKey : "_type", + nameKey : "_name", elementsKey : "_elements"} let result = JSON.stringify(conv.convert(xml, options)); console.log(result) ``` diff --git a/en/application-dev/reference/apis/js-apis-data-DataShareResultSet.md b/en/application-dev/reference/apis/js-apis-data-DataShareResultSet.md new file mode 100644 index 0000000000000000000000000000000000000000..6adaa00f48cfb7f2e685841e013e3d719bc58548 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @@ -0,0 +1,424 @@ +# Data Share Result Set + +The **DataShareResultSet** module provides methods for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type. + +>**NOTE** +> +>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +```ts +import DataShareResultSet from '@ohos.data.DataShareResultSet'; +``` + +## How to Use + +You can call [query()](js-apis-data-dataShare.md#query) to obtain the **DataShareResultSet** object. + +```ts +import dataShare from '@ohos.data.dataShare'; +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let dataShareHelper; +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +await dataShare.createDataShareHelper(this.context, uri, (err, data) => { + if (err != undefined) { + console.info("createDataShareHelper fail, error message : " + err); + } else { + console.info("createDataShareHelper end, data : " + data); + dataShareHelper = data; + } +}); + +let columns = ["*"]; +let da = new dataSharePredicates.DataSharePredicates(); +let resultSet; +da.equalTo("name", "ZhangSan"); +dataShareHelper.query(uri, da, columns).then((data) => { + console.log("query end, data : " + data); + resultSet = data; +}).catch((err) => { + console.log("query fail, error message : " + err); +}); +``` + +## Attributes + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +| Name | Type | Mandatory| Description | +| ----------- | ------------- | ---- | ------------------------ | +| columnNames | Array<string> | Yes | Names of all columns in the result set. | +| columnCount | number | Yes | Number of columns in the result set. | +| rowCount | number | Yes | Number of rows in the result set. | +| isClosed | boolean | Yes | Whether the result set is closed.| + +## goToFirstRow + +goToFirstRow(): boolean + +Moves to the first row of the result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| :------ | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let isGoTOFirstRow = resultSet.goToFirstRow(); +console.info('resultSet.goToFirstRow: ' + isGoTOFirstRow); +``` + +## goToLastRow + +goToLastRow(): boolean + +Moves to the last row of the result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let isGoToLastRow = resultSet.goToLastRow(); +console.info('resultSet.goToLastRow: ' + isGoToLastRow); +``` + +## goToNextRow + +goToNextRow(): boolean + +Moves to the next row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let isGoToNextRow = resultSet.goToNextRow(); +console.info('resultSet.goToNextRow: ' + isGoToNextRow); +``` + +## goToPreviousRow + +goToPreviousRow(): boolean + +Moves to the previous row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let isGoToPreviousRow = resultSet.goToPreviousRow(); +console.info('resultSet.goToPreviousRow: ' + isGoToPreviousRow); +``` + +## goTo + +goTo(offset:number): boolean + +Moves based on the specified offset. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name**| **Type**| **Mandatory**| Description | +| ---------- | -------- | -------- | ------------------------------------------------------------ | +| offset | number | Yes | Offset relative to the current position. A negative value means to move backward, and a positive value means to move forward.| + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let goToNum = 1; +let isGoTo = resultSet.goTo(goToNum); +console.info('resultSet.goTo: ' + isGoTo); +``` + +## goToRow + +goToRow(position: number): boolean + +Moves to the specified row in the result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name**| **Type**| **Mandatory**| Description | +| ---------- | -------- | -------- | ------------------------ | +| position | number | Yes | Destination position to move.| + +**Return value** + +| Type | Description | +| ------- | --------------------------------------------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```ts +let goToRowNum = 2 +let isGoToRow = resultSet.goToRow(goToRowNum); +console.info('resultSet.goToRow: ' + isGoToRow); +``` + +## getBlob + +getBlob(columnIndex: number): Uint8Array + +Obtains the value in the specified column in the current row as a byte array. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | ----------------------- | +| columnIndex | number | Yes | Index of the target column, starting from 0.| + +**Return value** + +| Type | Description | +| ---------- | -------------------------------- | +| Uint8Array | Value obtained.| + +**Example** + +```ts +let columnIndex = 1 +let goToFirstRow = resultSet.goToFirstRow(); +let getBlob = resultSet.getBlob(columnIndex); +console.info('resultSet.getBlob: ' + getBlob); +``` + +## getString + +getString(columnIndex: number): *string* + +Obtains the value in the specified column in the current row as a string. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | ----------------------- | +| columnIndex | number | Yes | Index of the target column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| string | Value obtained.| + +**Example** + +```ts +let columnIndex = 1 +let goToFirstRow = resultSet.goToFirstRow(); +let getString = resultSet.getString(columnIndex); +console.info('resultSet.getString: ' + getString); +``` + +## getLong + +getLong(columnIndex: number): number + +Obtains the value in the specified column in the current row as a long integer. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | ----------------------- | +| columnIndex | number | Yes | Index of the target column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| number | Value obtained.| + +**Example** + +```ts +let columnIndex = 1 +let goToFirstRow = resultSet.goToFirstRow(); +let getLong = resultSet.getLong(columnIndex); +console.info('resultSet.getLong: ' + getLong); +``` + +## getDouble + +getDouble(columnIndex: number): number + +Obtains the value in the specified column in the current row as a double-precision floating-point number. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | ----------------------- | +| columnIndex | number | Yes | Index of the target column, starting from 0.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| number | Value obtained.| + +**Example** + +```ts +let columnIndex = 1 +let goToFirstRow = resultSet.goToFirstRow(); +let getDouble = resultSet.getDouble(columnIndex); +console.info('resultSet.getDouble: ' + getDouble); +``` + +## close + +close(): void + +Closes this result set. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Example** + +```ts +resultSet.close(); +``` + +## getColumnIndex + +getColumnIndex(columnName: string): number + +Obtains the column index based on the column name. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name**| **Type**| **Mandatory**| Description | +| ---------- | -------- | -------- | -------------------------- | +| columnName | string | Yes | Column name.| + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| number | Column index obtained.| + +**Example** + +```ts +let ColumnName = "name" +let getColumnIndex = resultSet.getColumnIndex(ColumnName) +console.info('resultSet.getColumnIndex: ' + getColumnIndex); +``` + +## getColumnName + +getColumnName(columnIndex: number): *string* + +Obtains the column name based on the column index. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | -------------------------- | +| columnIndex | number | Yes | Column index.| + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| string | Column name obtained.| + +**Example** + +```ts +let columnIndex = 1 +let getColumnName = resultSet.getColumnName(columnIndex) +console.info('resultSet.getColumnName: ' + getColumnName); +``` + +## getDataType + +getDataType(columnIndex: number): DataType + +Obtains the data type based on the specified column index. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| **Name** | **Type**| **Mandatory**| Description | +| ----------- | -------- | -------- | -------------------------- | +| columnIndex | number | Yes | Column index.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------ | +| [DataType](#datatype) | Data type obtained.| + +**Example** + +```ts +let columnIndex = 1; +let getDataType = resultSet.getDataType(columnIndex); +console.info('resultSet.getDataType: ' + getDataType); +``` + +## DataType + +Enumerates the data types. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +| Name | Value| Description | +| ----------- | ------ | -------------------- | +| TYPE_NULL | 0 | Null. | +| TYPE_LONG | 1 | Long integer. | +| TYPE_DOUBLE | 2 | Double-precision floating-point number.| +| TYPE_STRING | 3 | String.| +| TYPE_BLOB | 4 | Byte array.| diff --git a/en/application-dev/reference/apis/js-apis-data-ValuesBucket.md b/en/application-dev/reference/apis/js-apis-data-ValuesBucket.md new file mode 100644 index 0000000000000000000000000000000000000000..dc239c35cbe017f7c5edc0a9fd8ff1bd74b3c366 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-data-ValuesBucket.md @@ -0,0 +1,37 @@ +# Value Bucket + +The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database. + +>**NOTE** +> +>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +```ts +import { ValueType } from '@ohos.data.ValuesBucket'; +import { ValuesBucket } from '@ohos.data.ValuesBucket'; +``` + +## ValueType + +Enumerates the value types allowed by the database. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +| Type | Description | +| ------- | -------------------- | +| number | The value is a number. | +| string | The value is a string.| +| boolean | The value is of Boolean type.| + +## ValuesBucket + +Defines the types of the key and value in a KV pair. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +| Key Type | Value Type | +| ------------- | --------------------------------------------- | +| string | [ValueType](#valuetype)\| Uint8Array \| null | diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index a1c0aba0f59aa5831cfa2e54cbad92302b8724c8..3860be1f4cd4fae2b432c7286ae5aca1c2b44868 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -789,7 +789,7 @@ Enumerates the value types. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core -| Name | Description | +| Type | Description | | ------- | -------------------- | | number | The value is a number. | | string | The value is a string. | diff --git a/en/application-dev/reference/apis/js-apis-data-dataShare.md b/en/application-dev/reference/apis/js-apis-data-dataShare.md new file mode 100644 index 0000000000000000000000000000000000000000..c3b59a85ab9e2945a8375a61b44c7e45c5d1c385 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-data-dataShare.md @@ -0,0 +1,932 @@ +# Data Sharing + +The **DataShare** module allows an application to manage its own data and share data with other applications on the same device. + +>**NOTE** +> +>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +```ts +import dataShare from '@ohos.data.dataShare' +``` + + +## dataShare.createDataShareHelper + +createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<DataShareHelper>): void + +Creates a **DataShareHelper** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| context | [Context](js-apis-application-context.md#context) | Yes | Context of an application. | +| uri | string | Yes | Uniform Resource Identifier (URI) of the server application to connect. | +| callback | AsyncCallback<[DataShareHelper](#datasharehelper)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the **DataShareHelper** instance created. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let dataShareHelper; +dataShare.createDataShareHelper(this.context, uri, (err, data) => { + if (err != undefined) { + console.info("createDataShareHelper failed, error message : " + err); + } else { + console.info("createDataShareHelper succeed, data : " + data); + dataShareHelper = data; + } +}); +``` + +## dataShare.createDataShareHelper + +createDataShareHelper(context: Context, uri: string): Promise<DataShareHelper> + +Creates a **DataShareHelper** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------------- | ---- | ------------------------------ | +| context | [Context](js-apis-application-context.md#context) | Yes | Context of an application. | +| uri | string | Yes | URI of the server application to connect.| + +**Return value** + +| Type | Description | +| -------------------------------------------------- | -------------------------------------- | +| Promise<[DataShareHelper](#datasharehelper)> | Promise used to return the **DataShareHelper** instance created.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let dataShareHelper; +dataShare.createDataShareHelper(this.context, uri).then((data) => { + console.info("createDataShareHelper succeed, data : " + data); + dataShareHelper = data; +}).catch((err) => { + console.info("createDataShareHelper failed, error message : " + err); +}) +``` + +## DataShareHelper + +Provides a **DataShareHelper** instance to access or manage data on the server. Before calling an API provided by **DataShareHelper**, you must create a **DataShareHelper** instance using [createDataShareHelper](#datasharecreatedatasharehelper). + +This API can be used only in the stage model. + +### openFile + +openFile(uri: string, mode: string, callback: AsyncCallback<number>): void + +Opens a file. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ---------------------------------- | +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | File open mode.<br>**r** means to open a file for reading; **w** means to open a file for writing (erasing any data in the file); **wa** means to open a file in append mode for writing at the end of the file; **rw** means to open a file for both reading and writing.| +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the file descriptor. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.openFile(uri, "rwt", (err, data) => { + if (err != undefined) { + console.info("openFile failed, error message : " + err); + }else { + console.info("openFile succeed, data : " + data); + let fd = data; + } +}); +``` + +### openFile + +openFile(uri: string, mode: string): Promise<number> + +Opens a file. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | File open mode.<br>**r** means to open a file for reading; **w** means to open a file for writing (erasing any data in the file); **wa** means to open a file in append mode for writing at the end of the file; **rw** means to open a file for both reading and writing.| + +**Return value** + +| Type | Description | +| --------------- | ---------------- | +| Promise<number> | Promise used to return the file descriptor.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.openFile(uri, "rwt").then((data) => { + console.info("openFile succeed, data : " + data); + let fd = data; +}).catch((err) => { + console.info("openFile failed, error message : " + err); +}) +``` + +### on('dataChange') + +on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void + +Subscribes to changes of the specified data. After an observer is registered, the subscriber will receive a notification when the change notification is triggered (the **notifyChange()** method is called). This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Event type to subscribe to. The value is **dataChange**, which indicates data change events.| +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback<void> | Yes | Called when the change notification is triggered. In this case, **err** is **undefined**. Otherwise, it is not called or **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +function onCallback() { + console.info("**** Observer on callback ****"); +} +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.on("dataChange", uri, onCallback); +``` + +### off('dataChange') + +off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void + +Unsubscribes from the changes of the specified data. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Event type to unsubscribe from. The value is **dataChange**, which indicates data change events.| +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback<void> | No | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +function offCallback() { + console.info("**** Observer off callback ****"); +} +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.off("dataChange", uri, offCallback); +``` + +### insert + +insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): void + +Inserts a single data record into the database. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to insert. | +| value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes | Data to insert. If this parameter is empty, a blank row will be inserted. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the index of the inserted data record. Otherwise, **err** is an error object.<br>The data index is not returned if the APIs of the database in use, for example, the key-value database (KVDB), do not support the return of indexes.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +const valueBucket = { + "name": "rose", + "age": 22, + "salary": 200.5, +} +dataShareHelper.insert(uri, valueBucket, (err, data) => { + if (err != undefined) { + console.log("insert failed, error message : " + err); + }else{ + console.log("insert succeed, data : " + data); + } +}); +``` + +### insert + +insert(uri: string, value: ValuesBucket): Promise<number> + +Inserts a single data record into the database. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----- | --------------------------------------------------------- | ---- | -------------------------------------------------- | +| uri | string | Yes | URI of the data to insert. | +| value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes | Data to insert. If this parameter is empty, a blank row will be inserted.| + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the index of the inserted data record.<br>The data index is not returned if the APIs of the database in use (for example, KVDB) do not support the return of indexes.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +const valueBucket = { + "name": "rose1", + "age": 221, + "salary": 20.5, +} +dataShareHelper.insert(uri, valueBucket).then((data) => { + console.log("insert succeed, data : " + data); +}).catch((err) => { + console.log("insert failed, error message : " + err); +}); +``` + +### delete + +delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void + +Deletes one or more data records from the database. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to delete. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **delete()** vary depending on the database in use. For example, the KVDB supports only **inKeys**.| +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the number of deleted data records. Otherwise, **err** is an error object.<br>The number of deleted data records is not returned if the APIs of the database in use (for example, KVDB) do not support this return.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +dataShareHelper.delete(uri, da, (err, data) => { + if (err != undefined) { + console.log("delete failed, error message : " + err); + }else{ + console.log("delete succeed, data : " + data); + } +}); +``` + +### delete + +delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number> + +Deletes one or more data records from the database. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to delete. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **delete()** vary depending on the database in use. For example, the KVDB supports only **inKeys**.| + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the number of deleted data records.<br>The number of deleted data records is not returned if the APIs of the database in use (for example, KVDB) do not support this return.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +dataShareHelper.delete(uri, da).then((data) => { + console.log("delete succeed, data : " + data); +}).catch((err) => { + console.log("delete failed, error message : " + err); +}); +``` + +### query + +query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<DataShareResultSet>): void + +Queries data in the database. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to query. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **query()** vary depending on the database used. For example, the KVDB supports only **inKeys** and **prefixKey**.| +| columns | Array<string> | Yes | Columns to query. If this parameter is empty, all columns will be queried. | +| callback | AsyncCallback<[DataShareResultSet](js-apis-data-DataShareResultSet.md#datashareresultset)> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the result set obtained. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let columns = ["*"]; +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +dataShareHelper.query(uri, da, columns, (err, data) => { + if (err != undefined) { + console.log("query failed, error message : " + err); + }else{ + console.log("query succeed, rowCount : " + data.rowCount); + } +}); +``` + +### query + +query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>): Promise<DataShareResultSet> + +Queries data in the database. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to query. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **query()** vary depending on the database used. For example, the KVDB supports only **inKeys** and **prefixKey**.| +| columns | Array<string> | Yes | Columns to query. If this parameter is empty, all columns will be queried. | + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise<[DataShareResultSet](js-apis-data-DataShareResultSet.md#datashareresultset)> | Promise used to return the result set obtained.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let columns = ["*"]; +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +dataShareHelper.query(uri, da, columns).then((data) => { + console.log("query succeed, rowCount : " + data.rowCount); +}).catch((err) => { + console.log("query failed, error message : " + err); +}); +``` + +### update + +update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket, callback: AsyncCallback<number>): void + +Updates data in the database. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to update. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **update()** vary depending on the database in use. For example, only the relational database (RDB) supports predicates.| +| value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes | New data. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the number of updated data records. Otherwise, **err** is an error object.<br>The number of updated data records is not returned if the APIs of the database in use (for example, KVDB) do not support this return.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +const va = { + "name": "roe1", + "age": 21, + "salary": 20.5, + +} +dataShareHelper.update(uri, da, va, (err, data) => { + if (err != undefined) { + console.log("update failed, error message : " + err); + }else{ + console.log("update succeed, data : " + data); + } +}); +``` + +### update + +update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise<number> + +Updates data in the database. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to update. | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria.<br>The predicate methods supported by **update()** vary depending on the database in use. For example, only the relational database (RDB) supports predicates.| +| value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | Yes | New data. | + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the number of data records updated.<br>The number of updated data records is not returned if the APIs of the database in use (for example, KVDB) do not support this return.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +import dataSharePredicates from '@ohos.data.dataSharePredicates' + +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let da = new dataSharePredicates.DataSharePredicates(); +da.equalTo("name", "ZhangSan"); +const va = { + "name": "roe1", + "age": 21, + "salary": 20.5, + +} +dataShareHelper.update(uri, da, va).then((data) => { + console.log("update succeed, data : " + data); +}).catch((err) => { + console.log("update failed, error message : " + err); +}); +``` + +### batchInsert + +batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void + +Batch inserts data into the database. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the data to insert. | +| values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes | Data to insert. | +| callback | AsyncCallback<number> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the number of data records inserted. Otherwise, **err** is an error object.<br>The number of inserted data records is not returned if the APIs of the database in use (for example, KVDB) do not support this return.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, + {"name": "roe12", "age": 21, "salary": 20.5,}, + {"name": "roe13", "age": 21, "salary": 20.5,}) +dataShareHelper.batchInsert(uri, vbs, (err, data) => { + if (err != undefined) { + console.log("batchInsert failed, error message : " + err); + }else{ + console.log("batchInsert succeed, data : " + data); + } +}); +``` + +### batchInsert + +batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number> + +Batch inserts data into the database. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ------------------------------------------------------------ | ---- | ------------------------ | +| uri | string | Yes | URI of the data to insert.| +| values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes | Data to insert. | + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the number of data records inserted.<br>The number of inserted data records is not returned if the APIs of the database (for example, KVDB) in use do not the return of the number of data records.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, + {"name": "roe12", "age": 21, "salary": 20.5,}, + {"name": "roe13", "age": 21, "salary": 20.5,}) +dataShareHelper.batchInsert(uri, vbs).then((data) => { + console.log("batchInsert succeed, data : " + data); +}).catch((err) => { + console.log("batchInsert failed, error message : " + err); +}); +``` + +### getType + +getType(uri: string, callback: AsyncCallback<string>): void + +Obtains the Multipurpose Internet Mail Extensions (MIME) type of the specified data. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------- | +| uri | string | Yes | URI of the data. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the MIME type obtained. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.getType(uri, (err, data)=>{ + if (err != undefined) { + console.log("getType failed, error message : " + err); + }else{ + console.log("getType succeed, data : " + data); + let result = data; + } +}); +``` + +### getType + +getType(uri: string): Promise<string> + +Obtains the MIME type of the specified data. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | -------------------- | +| uri | string | Yes | URI of the data.| + +**Return value** + +| Type | Description | +| ---------------- | ----------------------------------- | +| Promise<string> | Promise used to return the MIME type obtained.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.getType(uri).then((data) => { + console.log("getType succeed, data : " + data); +}).catch((err) => { + console.log("getType failed, error message : " + err); +}); +``` + +### getFileTypes + +getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): void + +Obtains the supported MIME types. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME types to match. Example:<br>**\*/\***: Obtain all supported types.<br>**image/\***: Obtain the MIMEs with the main type of **image**.<br>**\*/jpg**: Obtain the MIMEs with the subtype of **jpg**.| +| callback | AsyncCallback<Array\<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the MIME types obtained. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let mimeTypeFilter = "image/*"; +dataShareHelper.getFileTypes(uri, mimeTypeFilter, (err,data) => { + if (err != undefined) { + console.log("getFileTypes failed, error message : " + err); + }else{ + console.log("getFileTypes succeed, data : " + data); + } +}); +``` + +### getFileTypes + +getFileTypes(uri: string, mimeTypeFilter: string): Promise<Array<string>> + +Obtains the supported MIME types. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME types to match. Example:<br>**\*/\***: Obtain all supported types.<br>**image/\***: Obtain the MIMEs with the main type of **image**.<br>**\*/jpg**: Obtain the MIMEs with the subtype of **jpg**.| + +**Return value** + +| Type | Description | +| ------------------------ | ------------------------ | +| Promise<Array<string>> | Promise used to return the MIME types obtained.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +let mimeTypeFilter = "image/*"; +dataShareHelper.getFileTypes(uri, mimeTypeFilter).then((data) => { + console.log("getFileTypes succeed, data : " + data); +}).catch((err) => { + console.log("getFileTypes failed, error message : " + err); +}); +``` + +### normalizeUri + +normalizeUri(uri: string, callback: AsyncCallback<string>): void + +Normalizes a **DataShare** URI. The **DataShare** URI can be used only by the local device, but the normalized URI can be used across devices. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | -------------------------------------------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to normalize. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the normalized URI (if **null** is returned, URI normalization is not supported). Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.normalizeUri(uri, (err, data) => { + if (err != undefined) { + console.log("normalizeUri failed, error message : " + err); + }else{ + console.log("normalizeUri = " + data); + } +}); +``` + +### normalizeUri + +normalizeUri(uri: string): Promise<string> + +Normalizes a **DataShare** URI. The **DataShare** URI can be used only by the local device, but the normalized URI can be used across devices. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ----------------------------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to normalize.| + +**Return value** + +| Type | Description | +| ---------------- | ---------------------------------------------- | +| Promise<string> | Promise used to return the result. If URI normalization is supported, the normalized URI is returned. Otherwise, **null** is returned.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.normalizeUri(uri).then((data) => { + console.log("normalizeUri = " + data); +}).catch((err) => { + console.log("normalizeUri failed, error message : " + err); +}); +``` + +### denormalizeUri + +denormalizeUri(uri: string, callback: AsyncCallback<string>): void + +Denormalizes a URI. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to denormalize.| +| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the URI obtained. If the original URI is returned, denormalization is not required. If **null** is returned, denormalization is not supported. If the operation fails, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.denormalizeUri(uri, (err, data) => { + if (err != undefined) { + console.log("denormalizeUri failed, error message : " + err); + }else{ + console.log("denormalizeUri = " + data); + } +}); +``` + +### denormalizeUri + +denormalizeUri(uri: string): Promise<string> + +Denormalizes a URI. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------------------------------- | +| uri | string | Yes | [URI](js-apis-uri.md#uri) to denormalize.| + +**Return value** + +| Type | Description | +| ---------------- | ----------------------------------------- | +| Promise<string> | Promise used to return the result. If the denormalization is successful, the URI obtained is returned. If no operation is required, the original URI is returned. If denormalization is not supported, **null** is returned.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.denormalizeUri(uri).then((data) => { + console.log("denormalizeUri = " + data); +}).catch((err) => { + console.log("denormalizeUri failed, error message : " + err); +}); +``` + +### notifyChange + +notifyChange(uri: string, callback: AsyncCallback<void>): void + +Notifies the registered observer of data changes. This API uses an asynchronous callback to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the observer is notified of the data changes, **err** is **undefined**. Otherwise, **err** is an error object.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.notifyChange(uri, () => { + console.log("***** notifyChange *****"); +}); +``` + +### notifyChange + +notifyChange(uri: string): Promise<void> + +Notifies the registered observer of data changes. This API uses a promise to return the result. + +This API can be used only in the stage model. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Consumer + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | -------------------- | +| uri | string | Yes | URI of the data.| + +**Return value** + +| Type | Description | +| -------------- | --------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```ts +import Ability from '@ohos.application.Ability' +let uri = ("datashare:///com.samples.datasharetest.DataShare"); +dataShareHelper.notifyChange(uri); +``` diff --git a/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md b/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md new file mode 100644 index 0000000000000000000000000000000000000000..16c1c1c7b622782a577719bae992d10b1f4634a0 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-data-dataSharePredicates.md @@ -0,0 +1,861 @@ +# Data Share Predicates + +You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data with **DataShare**. + +>**NOTE** +> +>The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; +``` + +## equalTo + +equalTo(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value equal to the specified value. + +Currently, only the relational database (RDB) and key-value database (KVDB, schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------------------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "Rose") +``` + +## notEqualTo + +notEqualTo(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value not equal to the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------------------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.notEqualTo("NAME", "Rose") +``` + +## beginWrap + +beginWrap(): DataSharePredicates + +Adds a left parenthesis to this **DataSharePredicates**. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ---------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with a left parenthesis.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` + +## endWrap + +endWrap(): DataSharePredicates + +Adds a right parenthesis to this **DataSharePredicates** object. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ---------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with a right parenthesis.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "lisi") + .beginWrap() + .equalTo("AGE", 18) + .or() + .equalTo("SALARY", 200.5) + .endWrap() +``` + +## or + +or(): DataSharePredicates + +Adds the OR condition to this **DataSharePredicates** object. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ---------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with the OR condition.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "lisi") + .or() + .equalTo("NAME", "Rose") +``` + +## and + +and(): DataSharePredicates + +Adds the AND condition to this **DataSharePredicates** object. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ---------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object with the AND condition.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "lisi") + .and() + .equalTo("SALARY", 200.5) +``` + +## contains + +contains(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match the string that contains the specified value. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | Value contained in the string.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.contains("NAME", "os") +``` + +## beginsWith + +beginsWith(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match a string that starts with the specified value. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | Start value of the string.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.beginsWith("NAME", "os") +``` + +## endsWith + +endsWith(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match a string that ends with the specified value. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | End value of the string.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.endsWith("NAME", "os") +``` + +## isNull + +isNull(field: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field whose value is null. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| field | string | Yes | Column name in the database table.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.isNull("NAME") +``` + +## isNotNull + +isNotNull(field: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field whose value is not null. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| field | string | Yes | Column name in the database table.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.isNotNull("NAME") +``` + +## like + +like(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match a string that is similar to the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.like("NAME", "%os%") +``` + +## unlike + +unlike(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match a string that is not similar to the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.unlike("NAME", "%os%") +``` + +## glob + +glob(field: string, value: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match the specified string. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | string | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified string.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.glob("NAME", "?h*g") +``` + +## between + +between(field: string, low: ValueType, high: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value within the specified range. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------------------- | ---- | ------------------------ | +| field | string | Yes | Column name in the database table. | +| low | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The lowest value of the range.| +| high | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The highest value of the range.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.between("AGE", 10, 50) +``` + +## notBetween + +notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value out of the specified range. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------------------- | ---- | ------------------------ | +| field | string | Yes | Column name in the database table. | +| low | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The lowest value of the range.| +| high | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The highest value of the range.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.notBetween("AGE", 10, 50) +``` + +## greaterThan + +greaterThan(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value greater than the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | --------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.greaterThan("AGE", 10) +``` + +## lessThan + +lessThan(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value less than the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | --------------------------------------------------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.lessThan("AGE", 50) +``` + +## greaterThanOrEqualTo + +greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value greater than or equal to the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | --------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.greaterThanOrEqualTo("AGE", 10) +``` + +## lessThanOrEqualTo + +lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **ValueType** and value less than or equal to the specified value. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | --------- | ---- | ---------------------- | +| field | string | Yes | Column name in the database table. | +| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.lessThanOrEqualTo("AGE", 50) +``` + +## orderByAsc + +orderByAsc(field: string): DataSharePredicates + +Sets a **DataSharePredicates** object that sorts the values in a column in ascending order. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| field | string | Yes | Column name in the database table.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.orderByAsc("AGE") +``` + +## orderByDesc + +orderByDesc(field: string): DataSharePredicates + +Sets a **DataSharePredicates** object that sorts the values in a column in descending order. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| field | string | Yes | Column name in the database table.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.orderByDesc("AGE") +``` + +## distinct + +distinct(): DataSharePredicates + +Sets a **DataSharePredicates** object to filter out duplicate records. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "Rose").distinct() +``` + +## limit + +limit(total: number, offset: number): DataSharePredicates + +Sets a **DataSharePredicates** object to specify the number of results and the start position. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | -------------- | +| total | number | Yes | Number of results. | +| offset | number | Yes | Start position.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.equalTo("NAME", "Rose").limit(10, 3) +``` + +## groupBy + +groupBy(fields: Array<string>): DataSharePredicates + +Sets a **DataSharePredicates** object to group the records according to the specified parameters. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------- | ---- | -------------------- | +| fields | Array<string> | Yes | Names of the columns to group.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.groupBy(["AGE", "NAME"]) +``` + +## indexedBy + +indexedBy(field: string): DataSharePredicates + +Sets a **DataSharePredicates** object to specify the index column. Currently, only the RDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| field | string | Yes | Name of the index column.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.indexedBy("SALARY_INDEX") +``` + +## in + +in(field: string, value: Array<ValueType>): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **Array<ValueType>** and value within the specified range. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------- | ---- | --------------------------------------- | +| field | string | Yes| Column name in the database table. | +| value | Array<[ValueType](js-apis-data-ValuesBucket.md#valuetype)> | Yes | Array of **ValueType**s to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.in("AGE", [18, 20]) +``` + +## notIn + +notIn(field: string, value: Array<ValueType>): DataSharePredicates + +Sets a **DataSharePredicates** object to match the field with data type **Array<ValueType>** and value out of the specified range. + +Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ---------------- | ---- | --------------------------------------- | +| field | string | Yes | Column name in the database table. | +| value | Array<[ValueType](js-apis-data-ValuesBucket.md#valuetype)> | Yes | Array of **ValueType**s to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.notIn("NAME", ["Lisa", "Rose"]) +``` + +## prefixKey + +prefixKey(prefix: string): DataSharePredicates + +Sets a **DataSharePredicates** object to match a field with the specified key prefix. Currently, only the KVDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------- | +| prefix | string | Yes | Key prefix to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.prefixKey("NAME") +``` + +## inKeys + +inKeys(keys: Array<string>): DataSharePredicates + +Sets a **DataSharePredicates** object to match the fields whose keys are within the given range. Currently, only the KVDB supports this **DataSharePredicates** object. + +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------- | ---- | ------------------ | +| inKeys | Array<string> | Yes | Array of the keys to match.| + +**Return value** + +| Type | Description | +| ------------------------------------------- | -------------------------- | +| [DataSharePredicates](#datasharepredicates) | **DataSharePredicates** object that matches the specified field.| + +**Example** + +```ts +let predicates = new dataSharePredicates.DataSharePredicates() +predicates.inKeys(["Lisa", "Rose"]) +``` diff --git a/en/application-dev/reference/apis/js-apis-data-distributedobject.md b/en/application-dev/reference/apis/js-apis-data-distributedobject.md index a58a4583a1db69548342f0c63b8a13aec0dfb623..83875a6edb8aa2395b8750e70fb86b7fa596b03d 100644 --- a/en/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/en/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -1,6 +1,6 @@ # Distributed Data Object -Provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices. +The distributedDataObject module provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices. > **NOTE**<br/> > @@ -23,9 +23,9 @@ Creates a distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| source | object | Yes| Attribute of the distributed data object to create.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | source | object | Yes| Attribute of the distributed data object to create.| **Return value** | Type| Description| @@ -33,12 +33,11 @@ Creates a distributed data object. | [DistributedObject](#distributedobject) | Distributed data object created.| **Example** - ```js - import distributedObject from '@ohos.data.distributedDataObject'; - // Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object. - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, - parent:{mother:"jack mom",father:"jack Dad"}}); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +// Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object. +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); +``` ## distributedObject.genSessionId @@ -50,15 +49,15 @@ Creates a random session ID. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Return value** -| Type| Description| -| -------- | -------- | -| string | Session ID created.| + | Type| Description| + | -------- | -------- | + | string | Session ID created.| **Example** - ```js - import distributedObject from '@ohos.data.distributedDataObject'; - var sessionId = distributedObject.genSessionId(); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var sessionId = distributedObject.genSessionId(); +``` ## SaveSuccessResponse<sup>9+</sup> @@ -98,27 +97,26 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.| **Return value** -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. | **Example** - ```js - import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, - parent:{mother:"jack mom",father:"jack Dad"}}); - // Add g_object to the distributed network. - g_object.setSessionId(distributedObject.genSessionId()); - // Remove g_object from the distributed network. - g_object.setSessionId(""); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}});; +// Add g_object to the distributed network. +g_object.setSessionId(distributedObject.genSessionId()); +// Remove g_object from the distributed network. +g_object.setSessionId(""); +``` ### on('change') @@ -130,15 +128,15 @@ Subscribes to the changes of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | Yes| Callback used to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| **Example** ```js import distributedObject from '@ohos.data.distributedDataObject'; -var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}}); +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); globalThis.changeCallback = (sessionId, changeData) => { console.info("change" + sessionId); if (changeData != null && changeData != undefined) { @@ -159,16 +157,16 @@ Unsubscribes from the changes of this distributed data object. **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| -| callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback to be unregistered. If this parameter is not set, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.| + | callback | Callback<{ sessionId: string, fields: Array<string> }> | No| Callback to be unregistered. If this parameter is not set, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.| **Example** ```js import distributedObject from '@ohos.data.distributedDataObject'; -var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}}); +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); // Unregister the specified data change callback. g_object.off("change", globalThis.changeCallback); // Unregister all data change callbacks. @@ -184,10 +182,10 @@ Subscribes to the status change (online or offline) of this distributed data obj **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| -| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.<br>**sessionId**: session ID of the distributed data object.<br>**networkId**: object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.<br>**sessionId**: session ID of the distributed data object.<br>**networkId**: object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.| **Example** ```js @@ -195,7 +193,7 @@ import distributedObject from '@ohos.data.distributedDataObject'; globalThis.statusCallback = (sessionId, networkId, status) => { globalThis.response += "status changed " + sessionId + " " + status + " " + networkId; } -var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}}); +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); g_object.on("status", globalThis.statusCallback); ``` @@ -209,16 +207,16 @@ Unsubscribes from the status change (online or offline) of this distributed data **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| -| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.<br>**sessionId**: session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the status, which can be online or offline.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.| + | callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.<br>**sessionId**: session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the status, which can be online or offline.| **Example** ```js import distributedObject from '@ohos.data.distributedDataObject'; -var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}}); +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false, parent:{mother:"jack mom",father:"jack Dad"}}); globalThis.statusCallback = (sessionId, networkId, status) => { globalThis.response += "status changed " + sessionId + " " + status + " " + networkId; } @@ -245,24 +243,24 @@ The saved data will be released in the following cases: **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.| -| callback | AsyncCallback<[SaveSuccessResponse](#savesuccessresponse)> | Yes| Callback used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.| + | callback | AsyncCallback<[SaveSuccessResponse](#savesuccessresponse9)> | Yes| Callback used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| **Example** - - ```ts - import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); - g_object.setSessionId("123456"); - g_object.save("local", (result)=>{ - console.log("save callback"); - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); - }); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); +g_object.setSessionId("123456"); +g_object.save("local", (status, result)=>{ + console.log("save status = " + status); + console.log("save callback"); + console.info("save sessionId: " + result.sessionId); + console.info("save version: " + result.version); + console.info("save deviceId: " + result.deviceId); +}); +``` ### save<sup>9+</sup> @@ -281,31 +279,31 @@ The saved data will be released in the following cases: **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. | - **Return value** +**Return value** -| Type| Description| -| -------- | -------- | -| Promise<[SaveSuccessResponse](#savesuccessresponse)> | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| + | Type| Description| + | -------- | -------- | + | Promise<[SaveSuccessResponse](#savesuccessresponse9)> | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.| **Example** - ```ts - import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); - g_object.setSessionId("123456"); - g_object.save("local").then((result)=>{ - console.log("save callback"); - console.info("save sessionId " + result.sessionId); - console.info("save version " + result.version); - console.info("save deviceId " + result.deviceId); - }, ()=>{ - console.error("save failed"); - }); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); +g_object.setSessionId("123456"); +g_object.save("local").then((result)=>{ + console.log("save callback"); + console.info("save sessionId " + result.sessionId); + console.info("save version " + result.version); + console.info("save deviceId " + result.deviceId); +}, ()=>{ + console.error("save failed"); +}); +``` ### revokeSave<sup>9+</sup> @@ -319,20 +317,20 @@ If the object is stored on another device, the data on the local device will be **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[RevokeSaveSuccessResponse](#revokesavesuccessresponse)> | No| Callback used to return **RevokeSaveSuccessResponse**, which contains the session ID.| + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | No| Callback used to return **RevokeSaveSuccessResponse**, which contains the session ID.| **Example** - ```ts - import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); - g_object.setSessionId("123456"); - g_object.revokeSave((result, data) =>{ - console.log("revokeSave callback"); - }); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); +g_object.setSessionId("123456"); +g_object.revokeSave((result, data) =>{ + console.log("revokeSave callback"); +}); +``` ### revokeSave<sup>9+</sup> @@ -345,22 +343,22 @@ If the object is stored on another device, the data on the local device will be **System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject - **Return value** +**Return value** -| Type| Description| -| -------- | -------- | -| Promise<[RevokeSaveSuccessResponse](#revokesavesuccessresponse)> | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.| + | Type| Description| + | -------- | -------- | + | Promise<[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)> | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.| **Example** - ```ts - import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); - g_object.setSessionId("123456"); - g_object.revokeSave("local").then((result)=>{ - console.log("revokeSave callback"); - console.log("sessionId" + result.sessionId); - }, ()=>{ - console.error("revokeSave failed"); - }); - ``` +```js +import distributedObject from '@ohos.data.distributedDataObject'; +var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false}); +g_object.setSessionId("123456"); +g_object.revokeSave().then((result)=>{ + console.log("revokeSave callback"); + console.log("sessionId" + result.sessionId); +}, ()=>{ + console.error("revokeSave failed"); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-data-preferences.md b/en/application-dev/reference/apis/js-apis-data-preferences.md index 63371ed42b8eb940caa8072ffda6aa17d78658c5..560696c1ca48cb404aa0a29e95f8c3c1a1841198 100644 --- a/en/application-dev/reference/apis/js-apis-data-preferences.md +++ b/en/application-dev/reference/apis/js-apis-data-preferences.md @@ -681,7 +681,7 @@ Enumerates the value types. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Name | Description | +| Type | Description | | -------------- | ------------------------------ | | number | The value is a number. | | string | The value is a string. | diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index 71b5d2bec230d88f378b1fa122319e8ba983c6e7..38c07d6247487e037e9158a00e5c2f752621b44e 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -781,13 +781,6 @@ Sets the **RdbPredicates** to filter out duplicate records. ```js let predicates = new data_rdb.RdbPredicates("EMPLOYEE") predicates.equalTo("NAME", "Rose").distinct("NAME") -let promise = rdbStore.query(predicates, ["NAME"]) -promise.then((resultSet) => { - console.log("ResultSet column names: " + resultSet.columnNames) - console.log("ResultSet column count: " + resultSet.columnCount) -}).catch((err) => { - console.log("Query err.") -}) ``` @@ -1109,7 +1102,7 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| | values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates)| Yes| Update conditions specified by the **DataSharePredicates** object.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates)| Yes| Update conditions specified by the **DataSharePredicates** object.| | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| **Example** @@ -1133,7 +1126,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { ``` ### update<sup>9+</sup> -update(table: string, values: ValuesBucket, predicates: DataSharePredicates):Promise<number> +update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. @@ -1144,7 +1137,7 @@ Updates data in the RDB store based on the specified **DataSharePredicates** obj | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| | values | [ValuesBucket](#valuesbucket) | Yes| Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.| -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** object.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Update conditions specified by the **DataSharePredicates** object.| **Return value** | Type| Description| @@ -1215,7 +1208,7 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. **Return value** | Type| Description| | -------- | -------- | -| Promise<number> | Promise used to return the number of rows updated.| +| Promise<number> | Promise used to return the number of rows updated.| **Example** ```js @@ -1231,7 +1224,7 @@ promise.then((rows) => { ### delete<sup>9+</sup> -delete(table: string, predicates: DataSharePredicates, callback: AsyncCallback<number>):void +delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. @@ -1242,7 +1235,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| | callback | AsyncCallback<number> | Yes| Callback invoked to return the number of rows updated.| **Example** @@ -1270,12 +1263,12 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | table | string | Yes| Name of the target table.| -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Conditions specified by the **DataSharePredicates** object for deleting data.| **Return value** | Type| Description| | -------- | -------- | -| Promise<number> | Promise used to return the number of rows updated.| +| Promise<number> | Promise used to return the number of rows updated.| **Example** ```js @@ -1354,7 +1347,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro ### query<sup>9+</sup> -query(predicates: DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void +query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void Queries data in the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. @@ -1363,7 +1356,8 @@ Queries data in the RDB store based on specified conditions. This API uses an as **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| +| table | string | Yes| Name of the target table.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | columns | Array<string> | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.| | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| @@ -1384,7 +1378,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], ### query<sup>9+</sup> -query(predicates: DataSharePredicates, columns?: Array<string>):Promise<ResultSet> +query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> Queries data in the RDB store based on specified conditions. This API uses a promise to return the result. @@ -1393,7 +1387,8 @@ Queries data in the RDB store based on specified conditions. This API uses a pro **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| +| table | string | Yes| Name of the target table.| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | columns | Array<string> | No| Columns to query. If this parameter is not specified, the query applies to all columns.| **Return value** @@ -1591,7 +1586,7 @@ rdbStore.commit() ### rollBack<sup>8+</sup> -rollBack():void; +rollBack():void Rolls back the SQL statements that have been executed. @@ -1997,7 +1992,7 @@ Defines the data types allowed. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -| Name| Description| +| Type| Description| | -------- | -------- | | number | Number.| | string | String.| @@ -2006,14 +2001,13 @@ Defines the data types allowed. ## ValuesBucket -Defines a bucket to store key-value pairs. +Defines the types of the key and value in a KV pair. **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| [key: string] | [ValueType](#valuetype)\| Uint8Array \| null | Yes| Defines a bucket to store key-value pairs.| - +| Key Type| Value Type| +| -------- | -------- | +| string | [ValueType](#valuetype)\| Uint8Array \| null | ## SyncMode<sup>8+</sup> diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index 47a961f7cceb3c20de583387d9ed54d5494e5ac4..45465710a587c51fea60e7c59f2b804c80888043 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -793,7 +793,7 @@ Enumerates the value types. **System capability**: SystemCapability.DistributedDataManager.Preferences.Core -| Name | Description | +| Type | Description | | ------- | -------------------- | | number | The value is a number. | | string | The value is a string. | diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md index df69b38be754f255ce637249c18a9d2fca5e13fd..52af89ae7faa9fd20a28a62f959f4a3f39340ced 100644 --- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -5,12 +5,6 @@ > 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 can be used only in the FA model. -## Modules to Import - -```js -import featureAbility from "@ohos.ability.featureAbility"; -``` - ## Usage Import the following modules based on the actual situation before using the current module: @@ -573,7 +567,7 @@ Inserts multiple data records into the database. This API uses an asynchronous c | Name | Type | Mandatory| Description | | ------------ | ----------------------- | ---- | -------------------------------- | | uri | string | Yes | URI of the data to insert. | -| valuesBucket | Array\<rdb.ValuesBucket> | Yes | Data records to insert. | +| valuesBucket | Array<rdb.ValuesBucket> | Yes | Data records to insert. | | callback | AsyncCallback\<number> | Yes | Callback used to return the number of inserted data records.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-device-manager.md b/en/application-dev/reference/apis/js-apis-device-manager.md index 93ab553ef10e531fea0b2d0871b65183d22bf6fa..8c27495f208ad620ed6e104fb19c958350805c1e 100644 --- a/en/application-dev/reference/apis/js-apis-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-device-manager.md @@ -1,11 +1,22 @@ # Device Management ->  **NOTE** +The **DeviceManager** module provides APIs for distributed device management. + +System applications can call the APIs to do the following: + +- Subscribe to or unsubscribe from device state changes. +- Discover peripheral untrusted devices. +- Authenticate or deauthenticate a device. +- Query the trusted device list. +- Query local device information, including the device name, type, and ID. + +> **NOTE** +> > - 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. -## Modules to import: +## Modules to Import ``` import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -21,10 +32,10 @@ Creates a **DeviceManager** instance. **System capability**: SystemCapability.DistributedHardware.DeviceManager - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes| Bundle name of the application.| - | callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes| Callback invoked to return the **DeviceManager** instance created.| + | Name | Type | Mandatory | Description | + | ---------- | ---------------------------------------- | ---- | ------------------------------------ | + | bundleName | string | Yes | Bundle name of an application. | + | callback | AsyncCallback<[DeviceManager](#devicemanager)> | Yes | Callback used to return the **DeviceManager** instance created.| - Example ``` @@ -34,10 +45,40 @@ Creates a **DeviceManager** instance. return; } console.info("createDeviceManager success"); - this.dmInstance = data; + let dmInstance = data; }); ``` +## DeviceInfo + +Defines device information. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Type | Mandatory | Description | +| ---------------------- | ------------------------- | ---- | -------- | +| deviceId | string | Yes | Unique identifier of a device.| +| deviceName | string | Yes | Device name. | +| deviceType | [DeviceType](#devicetype) | Yes | Device type. | +| networkId<sup>8+</sup> | string | Yes | Network ID of the device. | + + +## DeviceType + +Enumerates the device types. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Default Value | Description | +| ------------ | ---- | ---- | +| SPEAKER | 0x0A | Smart speaker.| +| PHONE | 0x0E | Phone. | +| TABLET | 0x11 | Tablet. | +| WEARABLE | 0x6D | Wearable.| +| TV | 0x9C | Smart TV. | +| CAR | 0x83 | Car. | +| UNKNOWN_TYPE | 0 | Unknown device type.| + ## DeviceStateChangeAction @@ -45,42 +86,103 @@ Enumerates the device states. **System capability**: SystemCapability.DistributedHardware.DeviceManager -| Name| Default Value| Description| -| -------- | -------- | -------- | -| ONLINE | 0 | The device is online.| -| READY | 1 | The device is ready, and the device information has been synchronized.| -| OFFLINE | 2 | The device is offline.| -| CHANGE | 3 | The device information is changed.| +| Name | Default Value | Description | +| ------- | ---- | --------------- | +| ONLINE | 0 | The device is online. | +| READY | 1 | The device is ready, and the device information has been synchronized.| +| OFFLINE | 2 | The device is offline. | +| CHANGE | 3 | The device information is changed. | +## SubscribeInfo -## DeviceType +Defines subscription information. -Enumerates the device types. +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Type | Mandatory | Description | +| ------------- | --------------------------------- | ---- | ----------------- | +| subscribeId | number | Yes | Subscription ID, used to identify a device discovery period.| +| mode | [DiscoverMode ](#discovermode) | No | Device discovery mode. | +| medium | [ExchangeMedium](#exchangemedium) | No | Medium used for device discovery. | +| freq | [ExchangeFreq](#exchangefreq) | No | Frequency of device discovery. | +| isSameAccount | boolean | No | Whether the same account is used on the discovered device. | +| isWakeRemote | boolean | No | Whether to wake up the discovered device. | +| capability | [SubscribeCap](#subscribecap) | No | Discovery capability. | + + +## DiscoverMode + +Enumerates the device discovery modes. **System capability**: SystemCapability.DistributedHardware.DeviceManager -| Name| Default Value| Description| -| -------- | -------- | -------- | -| SPEAKER | 0x0A | Smart speaker.| -| PHONE | 0x0E | Phone.| -| TABLET | 0x11 | Tablet.| -| WEARABLE | 0x6D | Wearable.| -| TV | 0x9C | Smart TV.| -| CAR | 0x83 | Car.| -| UNKNOWN_TYPE | 0 | Unknown device type.| +| Name | Default Value | Description | +| --------------------- | ---- | ----- | +| DISCOVER_MODE_PASSIVE | 0x55 | Passive discovery.| +| DISCOVER_MODE_ACTIVE | 0xAA | Active discovery.| -## DeviceInfo +## ExchangeMedium -Defines device information. +Enumerates the media used for device discovery. **System capability**: SystemCapability.DistributedHardware.DeviceManager -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceId | number | Yes| Unique device identifier.| -| deviceName | string | Yes| Device name.| -| deviceType | number | Yes| Device type.| +| Name | Default Value | Description | +| ---- | ---- | --------- | +| AUTO | 0 | Automatic. | +| BLE | 1 | Bluetooth. | +| COAP | 2 | Wi-Fi.| +| USB | 3 | USB. | + +## ExchangeFreq + +Enumerates the device discovery frequencies. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Default Value | Description | +| ---------- | ---- | ----- | +| LOW | 0 | Low frequency. | +| MID | 1 | Medium frequency. | +| HIGH | 2 | High frequency. | +| SUPER_HIGH | 3 | Ultra-high frequency.| + + +## SubscribeCap + +Enumerates the discovery capabilities. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Default Value | Description | +| ------------------------- | ---- | -------------- | +| SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP capability. This will be deprecated later.| +| SUBSCRIBE_CAPABILITY_OSD | 1 | OSD capability. | + + +## AuthParam + +Defines the authentication parameters. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Type | Mandatory | Description | +| --------- | -------------------- | ---- | ---------- | +| authType | number | Yes | Authentication type. | +| extraInfo | {[key:string] : any} | No | Extended field.| + +## AuthInfo + +Defines authentication information. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +| Name | Type | Mandatory | Description | +| --------- | -------------------- | ---- | ---------- | +| authType | number | Yes | Authentication type. | +| token | number | Yes | Authentication token. | +| extraInfo | {[key:string] : any} | No | Extended field.| ## DeviceManager @@ -92,12 +194,12 @@ Provides APIs to obtain information about trusted devices and local devices. Bef release(): void -Releases the **DeviceManager** instance that is no longer used. +Releases this **DeviceManager** instance when it is no longer used. **System capability**: SystemCapability.DistributedHardware.DeviceManager - Example - ``` + ```js dmInstance.release(); ``` @@ -111,16 +213,258 @@ Obtains all trusted devices synchronously. **System capability**: SystemCapability.DistributedHardware.DeviceManager - Return value - | Name| Description| - | -------- | -------- | + | Name | Description | + | -------------------------------------- | --------- | | Array<[DeviceInfo](#deviceinfo)> | List of trusted devices obtained.| - Example - ``` + ```js var deviceInfoList = dmInstance.getTrustedDeviceListSync(); ``` +### getTrustedDeviceList<sup>8+</sup> + +getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): void + +Obtains all trusted devices. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | --------------------- | + | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | Yes | Callback used to return the list of trusted devices.| + +- Example + ```js + dmInstance.getTrustedDeviceList((err, data) => { + console.log("getTrustedDeviceList err: " + JSON.stringify(err)); + console.log('get trusted device info: ' + JSON.stringify(data)); + } + ); + ``` + +### getTrustedDeviceList<sup>8+</sup> + +getTrustedDeviceList(): Promise<Array<DeviceInfo>> + +Obtains all trusted devices. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- Return value + | Type | Description | + | ---------------------------------------- | --------------------- | + | Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise used to return the list of trusted devices.| + +- Example + ```js + dmInstance.getTrustedDeviceList().then((data) => { + console.log('get trusted device info: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getTrustedDeviceList err: " + JSON.stringify(err)); + }); + ``` + +### getLocalDeviceInfoSync<sup>8+</sup> + +getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) + +Obtains local device information synchronously. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- Return value + | Name | Description | + | -------------------------------------- | --------- | + | Array<[DeviceInfo](#deviceinfo)> | List of local devices obtained.| + +- Example + ```js + var deviceInfo = dmInstance.getLocalDeviceInfoSync(); + ``` + + +### getLocalDeviceInfo<sup>8+</sup> + +getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void + +Obtains local device information. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | --------- | + | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | Yes | Callback used to return the local device information.| + +- Example + ```js + dmInstance.getLocalDeviceInfo((err, data) => { + console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); + console.log('get local device info: ' + JSON.stringify(data)); + } + ); + ``` + +### getLocalDeviceInfo<sup>8+</sup> + +getLocalDeviceInfo(): Promise<DeviceInfo> + +Obtains local device information. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- Return value + | Type | Description | + | ---------------------------------------- | --------------------- | + | Promise<[DeviceInfo](#deviceinfo)> | Promise used to return the local device information.| + +- Example + ```js + dmInstance.getLocalDeviceInfo().then((data) => { + console.log('get local device info: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getLocalDeviceInfo err: " + JSON.stringify(err)); + }); + ``` + +### startDeviceDiscovery + +startDeviceDiscovery(subscribeInfo: SubscribeInfo): void + +Starts to discover peripheral devices. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | ------------- | ------------------------------- | ---- | ----- | + | subscribeInfo | [SubscribeInfo](#subscribeinfo) | Yes | Subscription information.| + +- Example + ```js + // Automatically generate a unique subscription ID. + var subscribeId = Math.floor(Math.random() * 10000 + 1000); + var subscribeInfo = { + "subscribeId": subscribeId, + "mode": 0xAA, // Active discovery + "medium": 0, // Automatic. Multiple media can be used for device discovery. + "freq": 2, // High frequency + "isSameAccount": false, + "isWakeRemote": false, + "capability": 1 + }; + dmInstance.startDeviceDiscovery(subscribeInfo); // The deviceFound callback is invoked to notify the application when a device is discovered. + ``` + +### stopDeviceDiscovery + +stopDeviceDiscovery(subscribeId: number): void + +Stops device discovery. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | ----------- | ------ | ---- | ----- | + | subscribeId | number | Yes | Subscription ID.| + +- Example + ```js + // The subscribeId input must be the same as that automatically generated in startDeviceDiscovery. + dmInstance.stopDeviceDiscovery(subscribeId); + ``` + +### authenticateDevice + +authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void + +Authenticates a device. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | ---------- | ---------------------------------------- | ---- | ------- | + | deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information. | + | authParam | [AuthParam](#authparam) | Yes | Authentication parameter. | + | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | Yes | Callback used to return the authentication result.| + +- Example + ```js + // Information about the device to authenticate. The information can be obtained from the device discovery result. + var deviceInfo ={ + "deviceId": "XXXXXXXX", + "deviceName": "", + deviceType: 0x0E + }; + let authParam = { + "authType": 1, // Authentication type. The value 1 means no account PIN authentication. + "extraInfo": {} + } + dmInstance.authenticateDevice(deviceInfo, authParam, (err, data) => { + if (err) { + console.info(TAG + "authenticateDevice err:" + JSON.stringify(err)); + return; + } + console.info(TAG + "authenticateDevice result:" + JSON.stringify(data)); + token = data.pinToken; + }); + ``` + +### unAuthenticateDevice<sup>8+</sup> + +unAuthenticateDevice(deviceInfo: DeviceInfo): void + +Deauthenticates a device. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | ---------- | ------------------------- | ---- | ----- | + | deviceInfo | [DeviceInfo](#deviceinfo) | Yes | Device information.| + +- Example + ```js + dmInstance.unAuthenticateDevice(deviceInfo); + ``` + + +### verifyAuthInfo + +verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void + +Verifies authentication information. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ------- | + | authInfo | [AuthInfo](#authinfo) | Yes | Authentication information. | + | authInfo | AsyncCallback<{ deviceId: string, level: number }> | Yes | Callback used to return the verification result.| + +- Example + ```js + let authInfo = { + "authType": 1, + "token": xxxxxx, + "extraInfo": {} + } + dmInstance.verifyAuthInfo(authInfo, (err, data) => { + if (err) { + console.info(TAG + "verifyAuthInfo err:" + JSON.stringify(err)); + return; + } + console.info(TAG + "verifyAuthInfo result:" + JSON.stringify(data)); + }); + ``` + + ### on('deviceStateChange') on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void @@ -130,13 +474,13 @@ Subscribes to changes in the device state. **System capability**: SystemCapability.DistributedHardware.DeviceManager - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **deviceStateChange**, which indicates a device state change event.| - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes| Callback invoked to return the device information and state.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event.| + | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state. | - Example - ``` + ```js dmInstance.on('deviceStateChange', (data) => { console.info("deviceStateChange on:" + JSON.stringify(data)); } @@ -146,20 +490,20 @@ Subscribes to changes in the device state. ### off('deviceStateChange') -off(type: 'deviceStateChange', callback?: Call back<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void +off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void Unsubscribes from changes in the device state. **System capability**: SystemCapability.DistributedHardware.DeviceManager - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **deviceStateChange** indicates an event of device state change.| - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes| Callback invoked to return the device information and state.| + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | Yes | Event type. The value **'deviceStateChange'** indicates a device state change event. | + | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | Yes | Callback invoked to return the device information and state.| - Example - ``` + ```js dmInstance.off('deviceStateChange', (data) => { console.info('deviceStateChange' + JSON.stringify(data)); } @@ -167,6 +511,95 @@ Unsubscribes from changes in the device state. ``` +### on('deviceFound') + +on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: DeviceInfo }>): void + +Subscribes to device discovery events. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | -------------------------- | + | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered.| + | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | Yes | Callback used for device discovery. | + +- Example + ```js + dmInstance.on('deviceFound', (data) => { + console.info("deviceFound:" + JSON.stringify(data)); + } + ); + ``` + +### off('deviceFound') + +off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: DeviceInfo }>): void + +Unsubscribes from device discovery events. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | Yes | Event type. The value **'deviceFound'** indicates an event reported when a device is discovered. | + | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | Yes | Callback used for device discovery, which is invoked to return the device information and state.| + +- Example + ```js + dmInstance.off('deviceFound', (data) => { + console.info('deviceFound' + JSON.stringify(data)); + } + ); + ``` + +### on('discoverFail') + +on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: number }>): void + +Subscribes to device discovery failures. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails.| + | callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure. | + +- Example + ```js + dmInstance.on('discoverFail', (data) => { + this.log("discoverFail on:" + JSON.stringify(data)); + } + ); + ``` + +### off('discoverFail') + +off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: number }>): void + +Unsubscribes from device discovery failures. + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +- **Parameters** + | Name | Type | Mandatory | Description | + | -------- | ---------------------------------------- | ---- | ----------------- | + | type | string | Yes | Event type. The event **'discoverFail'** indicates an event reported when device discovery fails. | + | callback | Callback<{ subscribeId: number, reason: number }> | Yes | Callback used for the device discovery failure.| + +- Example + ```js + dmInstance.off('deviceFound', (data) => { + console.info('deviceFound' + JSON.stringify(data)); + } + ); + ``` + + ### on('serviceDie') on(type: 'serviceDie', callback: () => void): void @@ -176,13 +609,13 @@ Subscribes to dead events of the **DeviceManager** service. **System capability**: SystemCapability.DistributedHardware.DeviceManager - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **serviceDie** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | () => void | Yes| Callback invoked when a dead event of the **DeviceManager** service occurs.| + | Name | Type | Mandatory | Description | + | -------- | ----------------------- | ---- | ---------------------------------------- | + | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| + | callback | () => void | Yes | Callback invoked when a dead event of the **DeviceManager** service occurs. | - Example - ``` + ```js dmInstance.on("serviceDie", () => { console.info("serviceDie on"); } @@ -199,13 +632,13 @@ Unsubscribes from dead events of the **DeviceManager** service. **System capability**: SystemCapability.DistributedHardware.DeviceManager - **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value **serviceDie** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| - | callback | () => void | No| Callback used to return the dead event of the **DeviceManager** service.| + | Name | Type | Mandatory | Description | + | -------- | ----------------------- | ---- | ---------------------------------------- | + | type | string | Yes | Event type. The value **'serviceDie'** indicates an event reported when the **DeviceManager** service is terminated unexpectedly.| + | callback | () => void | No | Callback used to return the dead event of the **DeviceManager** service. | - Example - ``` + ```js dmInstance.off("serviceDie", () => { console.info("serviceDie off"); } diff --git a/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md index 2ae6d7b5a18696850e13d8d088f9a1300561742c..8d18622ce2eb432210858545308e2a607891b1f0 100644 --- a/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md +++ b/en/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @@ -1,6 +1,24 @@ # Device Usage Statistics -> **NOTE**<br> +This module provides APIs for collecting statistics on device usage. + +System applications can call these APIs to implement the following features: + +- Query the usage duration in different time segments, events (foreground, background, start and end of continuous tasks), and the number of notifications, on a per application basis. +- Query statistics about system events (sleep, wakeup, unlock, and screen lock). +- Query the bundle group information of applications, including the invoking application itself. +- Query the idle status of applications, including the invoking application itself. +- Set the bundle group for other applications. +- Register and deregister the callback for application group changes. + +Third-party applications can call these APIs to implement the following features: + +- Query the idle status of the invoking application itself. +- Query the bundle group information of the invoking application itself. +- Query the events of the invoking application itself. + +> **NOTE** +> > 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. @@ -23,7 +41,7 @@ Checks whether the application specified by **bundleName** is in the idle state. | Name | Type | Mandatory | Description | | ---------- | ---------------------------- | ---- | ---------------------------------------- | | bundleName | string | Yes | Bundle name of an application. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the value of **bundleName** is valid, **null** will be returned.| +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the value of <b class="+ topic/ph hi-d/b " id="b597417553714">bundleName</b> is valid, <b class="+ topic/ph hi-d/b " id="b1897411555719">null</b> will be returned.| **Example** @@ -69,7 +87,7 @@ Checks whether the application specified by **bundleName** is in the idle state. ## bundleState.queryAppUsagePriorityGroup -queryAppUsagePriorityGroup(): Promise\<number> +queryAppUsagePriorityGroup(): Promise<number> Queries the priority group of this application. This API uses a promise to return the result. @@ -79,7 +97,7 @@ Queries the priority group of this application. This API uses a promise to retur | Type | Description | | --------------- | --------------------------- | -| Promise\<number> | Promise used to return the result.| +| Promise<number> | Promise used to return the result.| **Example** @@ -93,7 +111,7 @@ bundleState.queryAppUsagePriorityGroup().then( res => { ## bundleState.queryAppUsagePriorityGroup -queryAppUsagePriorityGroup(callback: AsyncCallback\<number>): void +queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void Queries the priority group of this application. This API uses an asynchronous callback to return the result. @@ -103,20 +121,11 @@ Queries the priority group of this application. This API uses an asynchronous ca | Name | Type | Mandatory | Description | | -------- | --------------------- | ---- | -------------------------- | -| callback | AsyncCallback\<number> | Yes | Callback used to return the result.| +| callback | AsyncCallback<number> | Yes | Callback used to return the result.| **Example** ```javascript -// Callback with bundleName -bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => { - if(err) { - console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); - } else { - console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res)); - } -}); -// Callback without bundleName bundleState.queryAppUsagePriorityGroup((err, res) => { if(err) { console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); @@ -523,7 +532,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an ## bundleState.queryAppUsagePriorityGroup<sup>9+</sup> -queryAppUsagePriorityGroup(bundleName? : string): Promise<number> +queryAppUsagePriorityGroup(bundleName? : string): Promise<number> Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result. @@ -543,13 +552,14 @@ Queries the priority group of the application specified by **bundleName**. If ** | Type | Description | | --------------- | --------------------------- | -| Promise\<number> | Promise used to return the result.| +| Promise<number> | Promise used to return the result.| **Example** ```javascript // Promise with bundleName -bundleState.queryAppUsagePriorityGroup(this.bundleName).then( res => { +let bundleName = "com.ohos.camera"; +bundleState.queryAppUsagePriorityGroup(bundleName).then( res => { console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res)); }).catch( err => { console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code); @@ -564,7 +574,7 @@ bundleState.queryAppUsagePriorityGroup().then( res => { ## bundleState.queryAppUsagePriorityGroup<sup>9+</sup> -queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback\<number>): void +queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback<number>): void Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result. @@ -579,13 +589,14 @@ Queries the priority group of the application specified by **bundleName**. If ** | Name | Type | Mandatory | Description | | ---------- | --------------------- | ---- | ---------------------------------------- | | bundleName | string | No | Bundle name of the target application. If this parameter is not specified, the priority group of the current application is queried.| -| callback | AsyncCallback\<number> | Yes | Callback used to return the result. | +| callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Example** ```javascript // Callback with bundleName -bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => { +let bundleName = "com.ohos.camera"; +bundleState.queryAppUsagePriorityGroup(bundleName, (err, res) => { if(err) { console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); } else { @@ -604,7 +615,7 @@ bundleState.queryAppUsagePriorityGroup((err, res) => { ## bundleState.setBundleGroup<sup>9+</sup> -setBundleGroup(bundleName: string, newGroup: GroupType): Promise\<void> +setBundleGroup(bundleName: string, newGroup: GroupType): Promise<void> Sets the group for the application specified by **bundleName**. This API uses a promise to return the result. @@ -618,22 +629,22 @@ Sets the group for the application specified by **bundleName**. This API uses a | Name | Type | Mandatory | Description | | ---------- | --------- | ---- | ---- | -| bundleName | string | Yes | Bundle name of the target application.| -| newGroup | GroupType | Yes | Application group.| +| bundleName | string | Yes | Bundle name of an application.| +| newGroup | [GroupType](#grouptype) | Yes | Application group.| **Return value** | Type | Description | | ------------- | ------------------------- | -| Promise\<void> | Promise used to return the result.| +| Promise<void> | Promise used to return the result.| **Example** ```javascript -this.bundleName = "com.example.deviceUsageStatistics"; -this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY; +let bundleName = "com.example.deviceUsageStatistics"; +let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; -bundleState.setBundleGroup(this.bundleName, this.newGroup).then( () => { +bundleState.setBundleGroup(bundleName, newGroup).then( () => { console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.'); }).catch( err => { console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code); @@ -642,7 +653,7 @@ bundleState.setBundleGroup(this.bundleName, this.newGroup).then( () => { ## bundleState.setBundleGroup<sup>9+</sup> -setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback\<void>): void +setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback<void>): void Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result. @@ -656,17 +667,17 @@ Sets the group for the application specified by **bundleName**. This API uses an | Name | Type | Mandatory | Description | | ---------- | ------------------- | ---- | ------------------------- | -| bundleName | string | Yes | Bundle name of the target application. | -| newGroup | GroupType | Yes | Application group. | -| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| +| bundleName | string | Yes | Bundle name of an application. | +| newGroup | [GroupType](#grouptype) | Yes | Application group. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```javascript -this.bundleName = "com.example.deviceUsageStatistics"; -this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY; +let bundleName = "com.example.deviceUsageStatistics"; +let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; -bundleState.setBundleGroup(this.bundleName, this.newGroup, (err) => { +bundleState.setBundleGroup(bundleName, newGroup, (err) => { if(err) { console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code); } else { @@ -677,9 +688,9 @@ bundleState.setBundleGroup(this.bundleName, this.newGroup, (err) => { ## bundleState.registerGroupCallBack<sup>9+</sup> -registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>): Promise\<void> +registerGroupCallBack(callback: Callback<BundleActiveGroupCallbackInfo>): Promise<void> -Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses a promise to return the result. +Registers a callback for application group changes. When an application group of the user changes, a **[BundleActiveGroupCallbackInfo](#bundleactivegroupcallbackinfo9)** instance is returned to all applications that have registered the callback. This API uses a promise to return the result. **Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO @@ -689,26 +700,26 @@ Registers a callback for application group changes. When an application group of **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------------------- | ---- | ----------- | -| callback | Callback\<BundleActiveGroupCallbackInfo> | Yes | Callback for application group changes.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| callback | Callback<[BundleActiveGroupCallbackInfo](#bundleactivegroupcallbackinfo9)> | Yes | Callback used to return the application group changes.| **Return value** | Type | Description | | ------------- | ----------------------- | -| Promise\<void> | Promise used to return the result.| +| Promise<void> | Promise used to return the result.| **Example** ```javascript let onBundleGroupChanged = (err,res) =>{ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result appUsageOldGroup is : ' + res.appUsageOldGroup); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result appUsageNewGroup is : ' + res.appUsageNewGroup); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result changeReason is : ' + res.changeReason); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result userId is : ' + res.userId); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result bundleName is : ' + res.bundleName); }; bundleState.registerGroupCallBack(onBundleGroupChanged).then( () => { console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.'); @@ -719,9 +730,9 @@ bundleState.registerGroupCallBack(onBundleGroupChanged).then( () => { ## bundleState.registerGroupCallBack<sup>9+</sup> -registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>, callback: AsyncCallback\<void>): void +registerGroupCallBack(callback: Callback<BundleActiveGroupCallbackInfo>, callback: AsyncCallback<void>): void -Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result. +Registers a callback for application group changes. When an application group of the user changes, a **[BundleActiveGroupCallbackInfo](#bundleactivegroupcallbackinfo9)** instance is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO @@ -731,21 +742,21 @@ Registers a callback for application group changes. When an application group of **Parameters** -| Name | Type | Mandatory | Description | -| -------- | --------------------------------------- | ---- | ------------- | -| callback | Callback\<BundleActiveGroupCallbackInfo> | Yes | Callback for application group changes. | -| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------- | +| callback | Callback<[BundleActiveGroupCallbackInfo](#bundleactivegroupcallbackinfo9)> | Yes | Callback used to return the application group changes. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```javascript let onBundleGroupChanged = (err,res) =>{ console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId); - console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result appUsageOldGroup is : ' + res.appUsageOldGroup); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result appUsageNewGroup is : ' + res.appUsageNewGroup); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result changeReason is : ' + res.changeReason); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result userId is : ' + res.userId); + console.log('BUNDLE_ACTIVE RegisterGroupCallBack result bundleName is : ' + res.bundleName); }; bundleState.registerGroupCallBack(onBundleGroupChanged, (err)=>{ if(err) { @@ -758,7 +769,7 @@ bundleState.registerGroupCallBack(onBundleGroupChanged, (err)=>{ ## bundleState.unRegisterGroupCallBack<sup>9+</sup> -unRegisterGroupCallBack(): Promise\<void> +unRegisterGroupCallBack(): Promise<void> Deregisters the callback for application group changes. This API uses a promise to return the result. @@ -774,7 +785,7 @@ Deregisters the callback for application group changes. This API uses a promise | Type | Description | | ------------- | ------------------------ | -| Promise\<void> | Promise used to return the result.| +| Promise<void> | Promise used to return the result.| **Example** @@ -788,7 +799,7 @@ bundleState.unRegisterGroupCallBack().then( () => { ## bundleState.unRegisterGroupCallBack<sup>9+</sup> -unRegisterGroupCallBack(callback: AsyncCallback\<void>): void; +unRegisterGroupCallBack(callback: AsyncCallback<void>): void; Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result. @@ -802,7 +813,7 @@ Deregisters the callback for application group changes. This API uses an asynchr | Name | Type | Mandatory | Description | | -------- | ------------------- | ---- | -------------- | -| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** @@ -870,7 +881,7 @@ Queries statistics about system events (hibernation, wakeup, unlocking, and scre | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | begin | number | Yes | Start time. | | end | number | Yes | End time. | -| callback | AsyncCallback<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Yes | Promise used to return the result.| +| callback | AsyncCallback<Array<[BundleActiveEventState](#bundleactiveeventstate9)>> | Yes | Callback used to return the result.| **Example** @@ -982,7 +993,7 @@ Provides the FA widget usage information. | Name | Type | Mandatory | Description | | ---------------- | ------ | ---- | ----------- | -| formName | number | Yes | Widget name. | +| formName | string | Yes | Widget name. | | formDimension | number | Yes | Widget dimensions. | | formId | number | Yes | Widget ID. | | formLastUsedTime | number | Yes | Last time when the widget was clicked.| @@ -992,15 +1003,15 @@ Provides the FA widget usage information. Provides the application group changes returned through a callback. -**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App +**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup -| Name | Type | Mandatory | Description | -| ---------------- | ------ | ---- | -------- | -| appUsageOldGroup | number | Yes | Application group before the change.| -| appUsageNewGroup | number | Yes | Application group after the change.| -| useId | number | Yes | User ID. | -| changeReason | number | Yes | Reason for the group change. | -| bundleName | string | Yes | Bundle name of an application. | +| Name | Type | Mandatory| Description | +| ---------------- | ------ | ---- | ---------------- | +| appUsageOldGroup | number | Yes | Application group before the change.| +| appUsageNewGroup | number | Yes | Application group after the change.| +| userId | number | Yes | User ID. | +| changeReason | number | Yes | Reason for the group change. | +| bundleName | string | Yes | Bundle name of an application. | ## BundleStateInfo @@ -1008,11 +1019,11 @@ Provides the usage duration information of applications. ### Attributes -**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup +**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App | Name | Type | Mandatory | Description | | ------------------------ | ------ | ---- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | abilityPrevAccessTime | number | Yes | Last time when the application was used. | | abilityInFgTotalTime | number | Yes | Total time that the application runs in the foreground. | | id | number | No | User ID.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| @@ -1029,8 +1040,6 @@ merge(toMerge: BundleStateInfo): void Merges the application usage information that has the same bundle name. -This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. - **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **Parameters** @@ -1047,7 +1056,7 @@ Provides information about an application event. | Name | Type | Mandatory | Description | | --------------------- | ------ | ---- | ---------------------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of an application. | | stateType | number | Yes | Application event type. | | stateOccurredTime | number | Yes | Timestamp when the application event occurs. | | appUsagePriorityGroup | number | No | Usage priority group of the application.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| @@ -1092,7 +1101,7 @@ Enumerates the interval types for querying the application usage duration. | BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis. | | BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis. | -## GroupType +## GroupType<sup>9+</sup> Enumerates the application group types. diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index ffbc73ff530a4d8f9ec39fd6e824760df9448644..25cf9ed242f66a0983303065dcea527989444223 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -1,5 +1,5 @@ # Display -Provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. +The **Display** module provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. > **NOTE** > @@ -14,11 +14,11 @@ import display from '@ohos.display'; ## DisplayState -Provides the state of a display. +Enumerates the display states. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name| Default Value| Description| +| Name| Value| Description| | -------- | -------- | -------- | | STATE_UNKNOWN | 0 | Unknown.| | STATE_OFF | 1 | The display is shut down.| @@ -56,7 +56,7 @@ Describes the attributes of a display. getDefaultDisplay(callback: AsyncCallback<Display>): void -Obtains the default display object. +Obtains the default display object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -82,7 +82,7 @@ Obtains the default display object. getDefaultDisplay(): Promise<Display> -Obtains the default display object. +Obtains the default display object. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -103,11 +103,31 @@ Obtains the default display object. }); ``` +## display.getDefaultDisplaySync<sup>9+</sup> + +getDefaultDisplaySync(): Display + +Obtains the default display object. This API returns the result synchronously. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** + +| Type | Description | +| ------------------------------| ----------------------------------------------| +| [Display](#display) | Default display object.| + +**Example** + +```js +var displayClass = display.getDefaultDisplaySync(); +``` + ## display.getAllDisplay getAllDisplay(callback: AsyncCallback<Array<Display>>): void -Obtains all the display objects. +Obtains all display objects. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -133,7 +153,7 @@ Obtains all the display objects. getAllDisplay(): Promise<Array<Display>> -Obtains all the display objects. +Obtains all display objects. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -158,15 +178,15 @@ Obtains all the display objects. on(type: 'add'|'remove'|'change', callback: Callback<number>): void -Enables listening. +Subscribes to display changes. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:<br>- **add**: listening for whether a display is added<br>- **remove**: listening for whether a display is removed<br>- **change**: listening for whether a display is changed| - | callback | Callback<number> | Yes| Callback used to return the ID of the display.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.| +| callback | Callback<number> | Yes| Callback used to return the ID of the display.| **Example** ```js @@ -181,14 +201,14 @@ Enables listening. off(type: 'add'|'remove'|'change', callback?: Callback<number>): void -Disables listening. +Unsubscribes from display changes. **System capability**: SystemCapability.WindowManager.WindowManager.Core **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:<br>- **add**: listening for whether a display is added<br>- **remove**: listening for whether a display is removed<br>- **change**: listening for whether a display is changed| + | type | string | Yes| Event type.<br>- **add**, indicating the display addition event.<br>- **remove**, indicating the display removal event.<br>- **change**, indicating the display change event.| | callback | Callback<number> | No| Callback used to return the ID of the display.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index bc64da83d9a829da97b02be79a94804df498a670..dc674978d2c4b9491e860b13f1720787380cc53e 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -2,7 +2,7 @@ The distributedAccount module provides basic functions for managing distributed accounts, including querying and updating account login status. ->  **NOTE**<br> +> **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. diff --git a/en/application-dev/reference/apis/js-apis-distributed-data .md b/en/application-dev/reference/apis/js-apis-distributed-data .md new file mode 100644 index 0000000000000000000000000000000000000000..5682921badad9367817fd3e421b1afb823970425 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-distributed-data .md @@ -0,0 +1,5671 @@ +# Distributed Data Management + +The distributed data management module implements collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to distributed databases and perform operations such as adding, deleting, modifying, querying, and synchronizing data in distributed databases. + +This module provides the following functions: + +- [KVManager](#kvmanager): provides a **KVManager** instance to manage key-value (KV) stores. +- [KvStoreResultSet<sup>8+</sup>](#kvstoreresultset8): provides methods to obtain the KV store result set and query or move the data read position. +- [Query<sup>8+</sup>](#query8): provides methods to query data from the database through a **Query** instance by using predicates. +- [KVStore](#kvstore): provides methods to add data, delete data, and observe data changes and data synchronization through a **KVStore** instance. +- [SingleKVStore](#singlekvstore): provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore), and data is not distinguished by device. +- [DeviceKVStore<sup>8+</sup> ](#devicekvstore8): provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore), and data is distinguished by device. + +>**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. + + +## Modules to Import + +```js +import distributedData from '@ohos.data.distributedData'; +``` + + +## distributedData.createKVManager + +createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void + +Creates a **KVManager** instance to manage KV stores. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| config | [KVManagerConfig](#kvmanagerconfig) | Yes | Configuration of the **KVManager** instance, including the bundle name and user information of the caller.| +| callback | AsyncCallback<[KVManager](#kvmanager)> | Yes | Callback invoked to return the **KVManager** instance created.| + +**Example** + +Stage model: +```ts +import AbilityStage from '@ohos.application.Ability' +let kvManager; +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + return; + } + console.log("Created KVManager"); + kvManager = manager; + }); + } +} +``` + +FA model: +```js +import AbilityStage from '@ohos.application.Ability' +let kvManager; +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context.getApplicationContext(), + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + return; + } + console.log("Created KVManager"); + kvManager = manager; + }); + } +} +``` + +## distributedData.createKVManager + +createKVManager(config: KVManagerConfig): Promise<KVManager> + +Creates a **KVManager** instance to manage KV stores. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| config |[KVManagerConfig](#kvmanager) | Yes | Configuration of the **KVManager** instance, including the bundle name and user information of the caller.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<[KVManager](#kvmanager)> | Promise used to return the **KVManager** instance created.| + +**Example** + +Stage model: +```ts +import AbilityStage from '@ohos.application.Ability' +let kvManager; +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context, + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + return; + } + console.log("Created KVManager"); + kvManager = manager; + }); + } +} +``` + +FA model: +```js +import AbilityStage from '@ohos.application.Ability' +let kvManager; +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + let context = this.context + const kvManagerConfig = { + context: context.getApplicationContext(), + bundleName: 'com.example.datamanagertest', + userInfo: { + userId: '0', + userType: distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("Failed to create KVManager: " + JSON.stringify(err)); + return; + } + console.log("Created KVManager"); + kvManager = manager; + }); + } +} +``` + +## KVManagerConfig + +Provides configuration of the **KVManager** object, including the bundle name and user information of the caller. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| context<sup>9+<sup> | Context | Yes| Application context.<br>For the application context of the FA model, see [Context](js-apis-Context.md).<br>For the application context of the stage model, see [Context](js-apis-ability-context.md).| +| userInfo | [UserInfo](#userinfo) | Yes | User information.| +| bundleName | string | Yes | Bundle name.| + +## UserInfo + +Defines user information. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| userId | string | Yes | User ID.| +| userType | [UserType](#usertype) | Yes | User type.| + + +## UserType + +Enumerates the user types. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name| Value| Description| +| ----- | ------ | ------ | +| SAME_USER_ID | 0 | User who logs in to different devices using the same account.| + + +## KVManager + +Creates a **KVManager** object to obtain KV store information. Before calling any method in **KVManager**, you must use [createKVManager](#distributeddatacreatekvmanager) to create a **KVManager** object. + +### getKVStore + +getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void + +Creates and obtains a KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| options | [Options](#options) | Yes | Configuration of the KV store.| +| callback | AsyncCallback<T> , <T extends [KVStore](#kvstore)>| Yes | Callback invoked to return the KV store created.| + +**Example** + +```js +let kvStore; +let kvManager; +try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options, function (err, store) { + if (err) { + console.log("getKVStore err: " + JSON.stringify(err)); + return; + } + console.log("getKVStore success"); + kvStore = store; + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + + +### getKVStore + +getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> + +Creates and obtains a KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ---------------------- | ---- | -------------------- | +| storeId | string | Yes | Unique identifier of the KV store. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| options | [Options](#options) | Yes | Configuration of the KV store.| + + +**Return value** + +| Type | Description | +| -------------------------------------- | ------------------------ | +| Promise<T>, <T extends [KVStore](#kvstore)> | Promise used to return the KV store created.| + +**Example** + +```js +let kvStore; +let kvManager; +try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options).then((store) => { + console.log("getKVStore success"); + kvStore = store; + }).catch((err) => { + console.log("getKVStore err: " + JSON.stringify(err)); + }); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + +### closeKVStore<sup>8+</sup> ### + +closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback<void>): void + +Closes a KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + + +| Name | Type | Mandatory| Description | +| ------- | ----------------- | ---- | --------------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | +| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| kvStore | [KVStore](#kvstore) | Yes | KV store to close. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +let kvStore; +let kvManager; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } + try { + kvManager.getKVStore('storeId', options, async function (err, store) { + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { + console.log('closeKVStore success'); + }); + }); +} catch (e) { + console.log('closeKVStore e ' + e); +} +``` + + +### closeKVStore<sup>8+</sup> ### + +closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void> + +Closes a KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | +| storeId | string | Yes | Unique identifier of the KV store to close. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| kvStore | [KVStore](#kvstore) | Yes | KV store to close. | + +**Return value** + +| Type | Description | +| ------------- | -------------- | +| Promise\<void> | Promise that returns no value.| + +**Example** + +```js +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} + try { + kvManager.getKVStore('storeId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { + console.log('closeKVStore success'); + }).catch((err) => { + console.log('closeKVStore err ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('closeKVStore e ' + e); +} +``` + + +### deleteKVStore<sup>8+</sup> ### + +deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void + +Deletes a KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | +| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} +try { + kvManager.getKVStore('store', options, async function (err, store) { + console.log('getKVStore success'); + kvStore = store; + kvManager.deleteKVStore('appId', 'storeId', function (err, data) { + console.log('deleteKVStore success'); + }); + }); +} catch (e) { + console.log('DeleteKVStore e ' + e); +} +``` + +### deleteKVStore<sup>8+</sup> ### + +deleteKVStore(appId: string, storeId: string): Promise<void> + +Deletes a KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | +| storeId | string | Yes | Unique identifier of the KV store to delete. The length cannot exceed [MAX_STORE_ID_LENGTH](#constants).| + + +**Return value** + +| Type | Description | +| ------------- | -------------- | +| Promise<void> | Promise that returns no value.| + +**Example** + +```js +let kvManager; +let kvStore; +const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, +} +try { + kvManager.getKVStore('storeId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + kvManager.deleteKVStore('appId', 'storeId').then(() => { + console.log('deleteKVStore success'); + }).catch((err) => { + console.log('deleteKVStore err ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('getKVStore err ' + JSON.stringify(err)); + }); +} catch (e) { + console.log('deleteKVStore e ' + e); +} +``` + + +### getAllKVStoreId<sup>8+</sup> ### + +getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void + +Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) and have not been deleted by [deleteKVStore()](#deletekvstore8). This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | +| callback | AsyncCallback<string[]> | Yes |Callback used to return the KV store IDs obtained. | + +**Example** + +```js +let kvManager; +try { + kvManager.getAllKVStoreId('appId', function (err, data) { + console.log('GetAllKVStoreId success'); + console.log('GetAllKVStoreId size = ' + data.length); + }); +} catch (e) { + console.log('GetAllKVStoreId e ' + e); +} +``` + + +### getAllKVStoreId<sup>8+</sup> ### + +getAllKVStoreId(appId: string): Promise<string[]> + +Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) and have not been deleted by [deleteKVStore()](#deletekvstore8). This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes | Bundle name of the app that invokes the KV store. | + + +**Return value** + +| Type | Description | +| ------------- | -------------- | +| Promise<string[]>| Promise used to return the KV store IDs obtained.| + +**Example** + +```js +let kvManager; +try { + console.log('GetAllKVStoreId'); + kvManager.getAllKVStoreId('appId').then((data) => { + console.log('getAllKVStoreId success'); + console.log('size = ' + data.length); + }).catch((err) => { + console.log('getAllKVStoreId err ' + JSON.stringify(err)); + }); +} catch(e) { + console.log('getAllKVStoreId e ' + e); +} +``` + + +### on('distributedDataServiceDie')<sup>8+</sup> ### + +on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void + +Subscribes to service status changes. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event | string | Yes | Event to subscribe to. The value is **distributedDataServiceDie**, which indicates service status changes.| +| deathCallback | Callback<void> | Yes | Callback invoked to return service status changes.| + +**Example** + +```js +let kvManager; +try { + + console.log('KVManagerOn'); + const deathCallback = function () { + console.log('death callback call'); + } + kvManager.on('distributedDataServiceDie', deathCallback); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + + +### off('distributedDataServiceDie')<sup>8+</sup> ### + +off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void + +Unsubscribes from the service status changes. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event | string | Yes | Event to unsubscribe from. The value is **distributedDataServiceDie**, which indicates service status changes.| +| deathCallback | Callback<void> | No | Callback used to return service status changes.| + + +**Example** + +```js +let kvManager; +try { + console.log('KVManagerOff'); + const deathCallback = function () { + console.log('death callback call'); + } + kvManager.off('distributedDataServiceDie', deathCallback); +} catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} + +``` + +## Options + +Provides KV store configuration. + + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| backup | boolean | No|Whether to back up database files. By default, database files are backed up. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| autoSync | boolean | No|Whether database files are automatically synchronized. By default, database files are not automatically synchronized.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core<br>**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC | +| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| schema<sup>8+</sup> | [Schema](#schema8) | No| Schema used to define the values stored in a KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| + + +## KVStoreType + +Enumerates the KV store types. + + +| Name | Value| Description | +| --- | ---- | ----------------------- | +| DEVICE_COLLABORATION | 0 | Device KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| SINGLE_VERSION | 1 | Single KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core| +| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| + + +## SecurityLevel + +Enumerates the KV store security levels. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Value| Description | +| --- | ---- | ----------------------- | +| NO_LEVEL | 0 | No security level is set for the KV store. | +| S0 | 1 | The KV store security level is public.| +| S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, a KV store that contains system data such as wallpapers.| +| S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, a KV store that contains information created by users or call records, such as audio or video clips.| +| S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database. For example, a KV store that contains information such as user fitness, health, and location data.| +| S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, a KV store that contains information such as authentication credentials and financial data.| + + +## Constants + +Defines the KV store constants. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Value| Description | +| --- | ---- | ----------------------- | +| MAX_KEY_LENGTH | 1024 | Maximum length of a key in the KV store, in bytes. | +| MAX_VALUE_LENGTH | 4194303 | Maximum length of a value in the KV store, in bytes. | +| MAX_KEY_LENGTH_DEVICE | 896 | Maximum length of a device key, in bytes.| +| MAX_STORE_ID_LENGTH | 128 | Maximum length of a KV store ID, in bytes. | +| MAX_QUERY_LENGTH | 512000 | Maximum query length, in bytes.| +| MAX_BATCH_SIZE | 128 | Maximum number of batch operations.| + +## Schema<sup>8+</sup> ## + +Defines the schema of a KV store. You can create a **Schema** object and place it in [Options](#options) when creating or opening a KV store. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +| Name | Type| Description | +| --- | ---- | ----------------------- | +| root<sup>8+</sup> | [FieldNode](#fieldnode8) | JSON root object.| +| indexes<sup>8+</sup> | Array\<string> | String array in JSON format. | +| mode<sup>8+</sup> | number | Schema mode. | +| skip<sup>8+</sup> | number | Size of a skip of the schema. | + +### constructor<sup>8+</sup> ### + +constructor() + +A constructor used to create a **Schema** instance. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +## FieldNode<sup>8+</sup> ## + +Represents a **Schema** instance, which provides the methods for defining the values stored in a KV store. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +| Name | Type| Description | +| --- | ---- | ----------------------- | +| nullable<sup>8+</sup> | boolean | Whether the database field can be null. | +| default<sup>8+</sup> | string | Default value of a **FieldNode**.| +| type<sup>8+</sup> | number | Value of the data type corresponding to the specified node.| + +### constructor<sup>8+</sup> ### + +constructor(name: string) + +A constructor used to create a **FieldNode** instance with a string field. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name| Type| Mandatory| Description | +| ------ | -------- | ---- | --------------- | +| name | string | Yes | Value of **FieldNode**.| + +### appendChild<sup>8+</sup> ### + +appendChild(child: FieldNode): boolean + +Appends a child node to this **FieldNode**. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| child | [FieldNode](#fieldnode8) | Yes | Child node to append. | + +**Return value** + +| Type | Description | +| ------------- | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +**Example** + +```js +import ddm from '@ohos.data.distributedData'; +try { + let node = new ddm.FieldNode("root"); + let child1 = new ddm.FieldNode("child1"); + let child2 = new ddm.FieldNode("child2"); + let child3 = new ddm.FieldNode("child3"); + node.appendChild(child1); + node.appendChild(child2); + node.appendChild(child3); + console.log("appendNode " + JSON.stringify(node)); + child1 = null; + child2 = null; + child3 = null; + node = null; +} catch (e) { + console.log("AppendChild " + e); +} +``` + + +## KvStoreResultSet<sup>8+</sup> ## + +Provides methods to obtain the KV store result sets, and query and move the data read position. + +Before calling any method in **KvStoreResultSet**, you must use [getKVStore](#getkvstore) to obtain a **KVStore** object. + + +### getCount<sup>8+</sup> ### + +getCount(): number + +Obtains the total number of rows in the result set. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| number |Total number of rows obtained. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const count = resultSet.getCount(); + console.log("getCount succeed:" + count); +} catch (e) { + console.log("getCount failed: " + e); +} +``` + +### getPosition<sup>8+</sup> ### + +getPosition(): number + +Obtains the current data read position (position from which data is read) in the result set. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| number |Current data read position obtained. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeeded.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const position = resultSet.getPosition(); + console.log("getPosition succeed:" + position); +} catch (e) { + console.log("getPosition failed: " + e); +} +``` + + +### moveToFirst<sup>8+</sup> ### + +moveToFirst(): boolean + +Moves the data read position to the first row. If the result set is empty, **false** will be returned. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved1 = resultSet.moveToFirst(); + console.log("moveToFirst succeed: " + moved1); +} catch (e) { + console.log("moveToFirst failed " + e); +} +``` + + +### moveToLast<sup>8+</sup> ### + +moveToLast(): boolean + +Moves the data read position to the last row. If the result set is empty, **false** will be returned. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved2 = resultSet.moveToLast(); + console.log("moveToLast succeed:" + moved2); +} catch (e) { + console.log("moveToLast failed: " + e); +} +``` + + +### moveToNext<sup>8+</sup> ### + +moveToNext(): boolean + +Moves the data read position to the next row. If the result set is empty, **false** will be returned. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved3 = resultSet.moveToNext(); + console.log("moveToNext succeed: " + moved3); +} catch (e) { + console.log("moveToNext failed: " + e); +} +``` + + +### moveToPrevious<sup>8+</sup> ### + +moveToPrevious(): boolean + +Moves the data read position to the previous row. If the result set is empty, **false** will be returned. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved4 = resultSet.moveToPrevious(); + console.log("moveToPrevious succeed:" + moved4); +} catch (e) { + console.log("moveToPrevious failed: " + e); +} +``` + + +### move<sup>8+</sup> ### + +move(offset: number): boolean + +Moves the data read position with the specified offset from the current position. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| offset | number | Yes | Offset to move the data read position. A negative value means to move backward, and a positive value means to move forward. | + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved5 = resultSet.move(); + console.log("move succeed:" + moved5); +} catch (e) { + console.log("move failed: " + e); +} +``` + + +### moveToPosition<sup>8+</sup> ### + +moveToPosition(position: number): boolean + +Moves the data read position from 0 to an absolute position. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| position | number | Yes |Absolute position to move to. | + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const moved6 = resultSet.moveToPosition(); + console.log("moveToPosition succeed: " + moved6); +} catch (e) { + console.log("moveToPosition failed: " + e); +} +``` + + +### isFirst<sup>8+</sup> ### + +isFirst(): boolean + +Checks whether the data read position is the first row. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the first row is being read; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const isfirst = resultSet.isFirst(); + console.log("Check isFirst succeed:" + isfirst); +} catch (e) { + console.log("Check isFirst failed: " + e); +} +``` + + +### isLast<sup>8+</sup> ### + +isLast(): boolean + +Checks whether the data read position is the last row. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the last row is being read; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const islast = resultSet.isLast(); + console.log("Check isLast succeed: " + islast); +} catch (e) { + console.log("Check isLast failed: " + e); +} +``` + +### isBeforeFirst<sup>8+</sup> ### + +isBeforeFirst(): boolean + +Checks whether the data read position is before the first row. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the data read position is before the first row; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const isbeforefirst = resultSet.isBeforeFirst(); + console.log("Check isBeforeFirst succeed: " + isbeforefirst); +} catch (e) { + console.log("Check isBeforeFirst failed: " + e); +} +``` + + +### isAfterLast<sup>8+</sup> ### + +isAfterLast(): boolean + +Checks whether the data read position is after the last row. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | -------------- | +| boolean |Returns **true** if the data read position is after the last row; returns **false** otherwise. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const isafterlast = resultSet.isAfterLast(); + console.log("Check isAfterLast succeed:" + isafterlast); +} catch (e) { + console.log("Check isAfterLast failed: " + e); +} +``` + + +### getEntry<sup>8+</sup> ### + +getEntry(): Entry + +Obtains the KV pair from the current position. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Entry](#entry) |KV pair obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + err); + }); + const entry = resultSet.getEntry(); + console.log("getEntry succeed:" + JSON.stringify(entry)); +} catch (e) { + console.log("getEntry failed: " + e); +} +``` + + +## Query<sup>8+</sup> ## + +Provides methods to create a **Query** object, which defines different data query criteria. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +### constructor<sup>8+</sup> ### + +constructor() + +A constructor used to create a **Schema** instance. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + + +### reset<sup>8+</sup> ### + +reset(): Query + +Resets the **Query** object. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object reset.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.equalTo("key", "value"); + console.log("query is " + query.getSqlLike()); + query.reset(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("simply calls should be ok :" + e); +} +``` + + +### equalTo<sup>8+</sup> ### + +equalTo(field: string, value: number|string|boolean): Query + +Creates a **Query** object to match the specified field whose value is equal to the given value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.equalTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### notEqualTo<sup>8+</sup> ### + +notEqualTo(field: string, value: number|string|boolean): Query + +Creates a **Query** object to match the specified field whose value is not equal to the specified value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### greaterThan<sup>8+</sup> ### + +greaterThan(field: string, value: number|string|boolean): Query + +Creates a **Query** object to match the specified field whose value is greater than the specified value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.greaterThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### lessThan<sup>8+</sup> ### + +lessThan(field: string, value: number|string): Query + +Creates a **Query** object to match the specified field whose value is less than the specified value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.lessThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### greaterThanOrEqualTo<sup>8+</sup> ### + +greaterThanOrEqualTo(field: string, value: number|string): Query + +Creates a **Query** object to match the specified field whose value is greater than or equal to the specified value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.greaterThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### lessThanOrEqualTo<sup>8+</sup> ### + +lessThanOrEqualTo(field: string, value: number|string): Query + +Creates a **Query** object to match the specified field whose value is less than or equal to the specified value. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | number\|string\|boolean | Yes | Value specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.lessThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### isNull<sup>8+</sup> ### + +isNull(field: string): Query + +Creates a **Query** object to match the specified field whose value is **null**. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.isNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### inNumber<sup>8+</sup> ### + +inNumber(field: string, valueList: number[]): Query + +Creates a **Query** object to match the specified field whose value is within the specified list of numbers. + + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| valueList | number[] | Yes | List of numbers.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.inNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### inString<sup>8+</sup> ### + +inString(field: string, valueList: string[]): Query + +Creates a **Query** object to match the specified field whose value is within the specified list of strings. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| valueList | string[] | Yes | List of strings.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.inString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### notInNumber<sup>8+</sup> ### + +notInNumber(field: string, valueList: number[]): Query + +Creates a **Query** object to match the specified field whose value is not within the specified list of numbers. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| valueList | number[] | Yes | List of numbers.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notInNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### notInString<sup>8+</sup> ### + +notInString(field: string, valueList: string[]): Query + +Creates a **Query** object to match the specified field whose value is not within the specified list of strings. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| valueList | string[] | Yes | List of strings.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notInString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### like<sup>8+</sup> ### + +like(field: string, value: string): Query + +Creates a **Query** object to match the specified field whose value is similar to the specified string. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | string | Yes | String specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.like("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### unlike<sup>8+</sup> ### + +unlike(field: string, value: string): Query + +Creates a **Query** object to match the specified field whose value is not similar to the specified string. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | +| value | string | Yes | String specified.| + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.unlike("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### and<sup>8+</sup> ### + +and(): Query + +Creates a **Query** object with the AND condition. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object Created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.and(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### or<sup>8+</sup> ### + +or(): Query + +Creates a **Query** object with the OR condition. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object Created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.or(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### orderByAsc<sup>8+</sup> ### + +orderByAsc(field: string): Query + +Creates a **Query** object to sort the query results in ascending order. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByAsc("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### orderByDesc<sup>8+</sup> ### + +orderByDesc(field: string): Query + +Creates a **Query** object to sort the query results in descending order. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByDesc("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### limit<sup>8+</sup> ### + +limit(total: number, offset: number): Query + +Creates a **Query** object to specify the number of results and where to start. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| total | number | Yes |Number of results to query. | +| offset | number | Yes |Start position for query. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +let total = 10; +let offset = 1; +try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.limit(total, offset); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### isNotNull<sup>8+</sup> ### + +isNotNull(field: string): Query + +Creates a **Query** object to match the specified field whose value is not **null**. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes |Field to match. It cannot contain '^'. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.isNotNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### beginGroup<sup>8+</sup> ### + +beginGroup(): Query + +Creates a **Query** object for a query condition group with a left parenthesis. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### endGroup<sup>8+</sup> ### + +endGroup(): Query + +Creates a **Query** object for a query condition group with a right parenthesis. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### prefixKey<sup>8+</sup> ### + +prefixKey(prefix: string): Query + +Creates a **Query** object with a specified key prefix. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| prefix | string | Yes |Key prefix. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.prefixKey("$.name"); + query.prefixKey("0"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### setSuggestIndex<sup>8+</sup> ### + +setSuggestIndex(index: string): Query + +Creates a **Query** object with an index preferentially used for query. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| index | string | Yes |Index preferentially used for query. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.setSuggestIndex("$.name"); + query.setSuggestIndex("0"); + console.log("query is " + query.getSqlLike()); + query = null; +} catch (e) { + console.log("duplicated calls should be ok :" + e); +} +``` + + +### deviceId<sup>8+</sup> ### + +deviceId(deviceId:string):Query + +Creates a **Query** object with the device ID as the key prefix. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId | string | Yes |Device ID. | + + +**Return value** + +| Type | Description | +| ------ | ------- | +| [Query](#query8) |**Query** object created.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + query.deviceId("deviceId"); + console.log("query is " + query.getSqlLike()); +} catch (e) { + console.log("should be ok on Method Chaining : " + e); +} +``` + + +### getSqlLike<sup>8+</sup> ### + +getSqlLike():string + +Obtains the query statement of the **Query** object. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| string |Returns the query statement obtained.| + +**Example** + +```js +try { + let query = new distributedData.Query(); + let sql1 = query.getSqlLike(); + console.log("GetSqlLike sql=" + sql1); +} catch (e) { + console.log("duplicated calls should be ok : " + e); +} +``` + + +## KVStore + +Provides methods to manage data in a KV store, for example, adding or deleting data and subscribing to data changes or completion of data synchronization. + +Before calling any method in **KVStore**, you must use [getKVStore](#getkvstore) to obtain a **KVStore** object. + +### put + +put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void + +Adds a KV pair of the specified type to this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | +| value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). | +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + + +### put + +put(key: string, value: Uint8Array | string | number | boolean): Promise<void> + +Adds a KV pair of the specified type to this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes |Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | +| value | Uint8Array \| string \| number \| boolean | Yes |Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX_VALUE_LENGTH](#constants). | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + +### delete + +delete(key: string, callback: AsyncCallback<void>): void + +Deletes a KV pair from this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("delete err: " + JSON.stringify(err)); + return; + } + console.log("delete success"); + }); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + +### delete + +delete(key: string): Promise<void> + +Deletes a KV pair from this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes |Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("delete success"); + }).catch((err) => { + console.log("delete err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + +### delete<sup>9+</sup> + +delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<void>) + +Deletes KV pairs that meet the specified predicates. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |Conditions for deleting data. If this parameter is **null**, define the processing logic.| +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +import dataSharePredicates from '@ohos.data.dataSharePredicates'; +let kvStore; +try { + let predicates = new dataSharePredicates.DataSharePredicates(); + kvStore.delete(predicates, function (err, data) { + if (err == undefined) { + console.log('delete success'); + } else { + console.log('delete fail' + err); + } + }); +} catch (e) { + console.log('An unexpected error occurred. Error:' + e); +} +``` + +### delete<sup>9+</sup> + +delete(predicates: dataSharePredicates.DataSharePredicates): Promise<void> + +Deletes KV pairs that meet the specified predicates. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |Conditions for deleting data. If this parameter is **null**, define the processing logic.| + + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +**Example** + +```js +import dataSharePredicates from '@ohos.data.dataSharePredicates'; +let kvStore; +try { + let predicates = new dataSharePredicates.DataSharePredicates(); + let arr = ["name"]; + predicates.inKeys(arr); + kvStore.put("name", "bob").then((data) => { + console.log('put success' + JSON.stringify(data)); + kvStore.delete(predicates).then((data) => { + console.log('delete success'); + }).catch((err) => { + console.log('delete fail' + JSON.stringify(err)); + }); + }) .catch((err) => { + console.log(' put fail' + err); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} + +``` + +### on('dataChange') + +on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void + +Subscribes to data change notifications of the specified type. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **dataChange**, which indicates data changes. | +| type |[SubscribeType](#subscribetype) | Yes |Type of data changes. | +| listener |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return the data changes.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); +}); +``` + + +### on('syncComplete') + +on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void + +Subscribes to data synchronization complete events. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates completion of a data synchronization. | +| syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return the data synchronization result. | + +**Example** + +```js +let kvStore; +kvStore.on('syncComplete', function (data) { + console.log("callback call data: " + data); +}); +``` + +### off('dataChange')<sup>8+</sup> + +off(event:'dataChange', listener?: Callback<ChangeNotification>): void + +Unsubscribes from data change notifications. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates data changes. | +| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return the data changes.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', function (data) { + console.log("callback call data: " + data); +}); +kvStore.off('dataChange', function (data) { + console.log("callback call data: " + data); +}); +``` + +### off('syncComplete')<sup>9+</sup> + +off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void + +Unsubscribes from data change events. This API uses a synchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates completion of a data synchronization. | +| syncCallback |Callback<Array<[string, number]>> | No |Callback used to return the synchronization result. | + +**Example** + +```js +let kvStore; +try { + const func = function (data) { + console.log('syncComplete ' + data) + }; + kvStore.on('syncComplete', func); + kvStore.off('syncComplete', func); +}catch(e) { + console.log('syncComplete e ' + e); +} +``` + + +### putBatch<sup>8+</sup> + +putBatch(entries: Entry[], callback: AsyncCallback<void>): void + +Inserts KV pairs in batches to this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. | +| callback |Asyncallback<void> |Yes |Callback used to return the result.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + kvStore.getEntries('batch_test_string_key', function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + JSON.stringify(e)); +} +``` + + +### putBatch<sup>8+</sup> + +putBatch(entries: Entry[]): Promise<void> + +Inserts KV pairs in batches to this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| entries |[Entry](#entry)[] | Yes |KV pairs to insert in batches. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + kvStore.getEntries('batch_test_string_key').then((entries) => { + console.log('getEntries success'); + console.log('PutBatch ' + JSON.stringify(entries)); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + JSON.stringify(e)); +} +``` + +### putBatch<sup>9+</sup> + +putBatch(value: Array<ValuesBucket>, callback: AsyncCallback<void>): void + +Writes data to this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| value |Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes |Data to write. | +| callback |Asyncallback<void> |Yes |Callback used to return the result.| + +**Example** + +```js +let kvStore; +try { + let v8Arr = []; + let arr = new Uint8Array([4,5,6,7]); + let vb1 = {key : "name_1", value : 32} + let vb2 = {key : "name_2", value : arr}; + let vb3 = {key : "name_3", value : "lisi"}; + + v8Arr.push(vb1); + v8Arr.push(vb2); + v8Arr.push(vb3); + kvStore.putBatch(v8Arr, async function (err,data) { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('putBatch e ' + JSON.stringify(e)); +} +``` + +### putBatch<sup>9+</sup> + +putBatch(value: Array<ValuesBucket>): Promise<void> + +Writes data of the **valuesbucket** type to this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| value |Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | Yes |Data to write. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +**Example** + +```js +let kvStore; +try { + let v8Arr = []; + let arr = new Uint8Array([4,5,6,7]); + let vb1 = {key : "name_1", value : 32} + let vb2 = {key : "name_2", value : arr}; + let vb3 = {key : "name_3", value : "lisi"}; + + v8Arr.push(vb1); + v8Arr.push(vb2); + v8Arr.push(vb3); + kvStore.putBatch(v8Arr).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + JSON.stringify(e)); +} + +``` + +### deleteBatch<sup>8+</sup> + +deleteBatch(keys: string[], callback: AsyncCallback<void>): void + +Deletes KV pairs in batches from this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keys |string[] | Yes |KV pairs to delete in batches. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + keys.push(key + i); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + kvStore.deleteBatch(keys, async function (err,data) { + console.log('deleteBatch success'); + }); + }); +}catch(e) { + console.log('DeleteBatch e ' + e); +} +``` + + +### deleteBatch<sup>8+</sup> ### + +deleteBatch(keys: string[]): Promise<void> + +Deletes KV pairs in batches from this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keys |string[] | Yes |KV pairs to delete in batches. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + keys.push(key + i); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + kvStore.deleteBatch(keys).then((err) => { + console.log('deleteBatch success'); + }).catch((err) => { + console.log('deleteBatch fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('DeleteBatch e ' + e); +} +``` + + +### startTransaction<sup>8+</sup> ### + +startTransaction(callback: AsyncCallback<void>): void + +Starts the transaction in this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +function putBatchString(len, prefix) { + let entries = []; + for (var i = 0; i < len; i++) { + var entry = { + key : prefix + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + return entries; +} +try { + var count = 0; + kvStore.on('dataChange', 0, function (data) { + console.log('startTransaction 0' + data) + count++; + }); + kvStore.startTransaction(async function (err,data) { + console.log('startTransaction success'); + let entries = putBatchString(10, 'batch_test_string_key'); + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + }); + }); +}catch(e) { + console.log('startTransaction e ' + e); +} +``` + + +### startTransaction<sup>8+</sup> ### + +startTransaction(): Promise<void> + +Starts the transaction in this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + var count = 0; + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { + console.log('startTransaction ' + JSON.stringify(data)); + count++; + }); + kvStore.startTransaction().then(async (err) => { + console.log('startTransaction success'); + }).catch((err) => { + console.log('startTransaction fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('startTransaction e ' + e); +} +``` + + +### commit<sup>8+</sup> ### + +commit(callback: AsyncCallback<void>): void + +Commits the transaction in this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + kvStore.commit(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); +}catch(e) { + console.log('Commit e ' + e); +} +``` + + +### commit<sup>8+</sup> ### + +commit(): Promise<void> + +Commits the transaction in this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + kvStore.commit().then(async (err) => { + console.log('commit success'); + }).catch((err) => { + console.log('commit fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('Commit e ' + e); +} +``` + + +### rollback<sup>8+</sup> ### + +rollback(callback: AsyncCallback<void>): void + +Rolls back the transaction in this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + kvStore.rollback(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); +}catch(e) { + console.log('Rollback e ' + e); +} +``` + + +### rollback<sup>8+</sup> ### + +rollback(): Promise<void> + +Rolls back the transaction in this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + kvStore.rollback().then(async (err) => { + console.log('rollback success'); + }).catch((err) => { + console.log('rollback fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('Rollback e ' + e); +} +``` + + +### enableSync<sup>8+</sup> ### + +enableSync(enabled: boolean, callback: AsyncCallback<void>): void + +Sets data synchronization, which can be enabled or disabled. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| enabled |boolean | Yes |Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + kvStore.enableSync(true, function (err,data) { + if (err == undefined) { + console.log('enableSync success'); + } else { + console.log('enableSync fail'); + } + }); +}catch(e) { + console.log('EnableSync e ' + e); +} +``` + + +### enableSync<sup>8+</sup> ### + +enableSync(enabled: boolean): Promise<void> + +Sets data synchronization, which can be enabled or disabled. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| enabled |boolean | Yes |Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite. | + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + kvStore.enableSync(true).then((err) => { + console.log('enableSync success'); + }).catch((err) => { + console.log('enableSync fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('EnableSync e ' + e); +} +``` + + +### setSyncRange<sup>8+</sup> ### + +setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback<void>): void + +Sets the data synchronization range. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| localLabels |string[] | Yes |Synchronization labels set for the local device. | +| remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) { + console.log('SetSyncRange put success'); + }); +}catch(e) { + console.log('SetSyncRange e ' + e); +} +``` + + +### setSyncRange<sup>8+</sup> ### + +setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<void> + +Sets the data synchronization range. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| localLabels |string[] | Yes |Synchronization labels set for the local device. | +| remoteSupportLabels |string[] | Yes |Synchronization labels set for remote devices. | + + +**Return value** + +| Type | Description | +| ------ | ------- | +| Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { + console.log('setSyncRange success'); + }).catch((err) => { + console.log('delete fail ' + err); + }); +}catch(e) { + console.log('SetSyncRange e ' + e); +} +``` + + +## SubscribeType + +Enumerates the subscription types. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Value | Description | +| ----- | ------ | ----------------------- | +| SUBSCRIBE_TYPE_LOCAL |0 |Local data changes. | +| SUBSCRIBE_TYPE_REMOTE |1 |Remote data changes. | +| SUBSCRIBE_TYPE_ALL |2 |Local and remote data changes. | + +## ChangeNotification + +Defines the content of data change notifications, including inserted data, updated data, deleted data, and device ID. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Type |Readable |Writable | Description | +| ----- | ------- | -----| ------|------------------------ | +| insertEntries | [Entry](#entry)[] | Yes | Yes|Data inserted. | +| updateEntries | [Entry](#entry)[] | Yes | Yes|Data updated. | +| deleteEntries | [Entry](#entry)[] | Yes | Yes|Data deleted. | +| deviceId | string | Yes | Yes|UUID of the device. | + +## Entry + +Defines the KV pairs stored in the KV store. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Type |Readable |Writable | Description | +| ----- | ------- | -----| ------|------------------------ | +| key | string | Yes | Yes|Key of the KV pair stored in the KV store. | +| value | [Value](#value) | Yes | Yes|Value of the KV pair stored in the KV store. | + + +## Value + +Defines the **value** object in a KV store. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Type |Readable |Writable | Description | +| ----- | ------- | -----| ------|------------------------ | +| type | [ValueType](#value) | Yes | Yes|Type of the value. | +| value | Uint8Array \| string \| number \| boolean| Yes | Yes|Value of the KV pair stored in the KV store. | + +## ValueType + +Enumerates the data types. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Value | Description | +| ----- | ------ | ----------------------- | +| STRING |0 |String. | +| INTEGER |1 |Integer. | +| FLOAT |2 |Float (single-precision floating point). | +| BYTE_ARRAY |3 |Byte array. | +| BOOLEAN |4 |Boolean. | +| DOUBLE |5 |Double (double-precision floating point). | + +## SingleKVStore + +Provides methods to query and synchronize data in a single KV store. This class inherits from [KVStore](#kvstore). + +Data is not distinguished by device in a single KV store. The data written to different devices using the same key will be overwritten. For example, a single KV store can be used to synchronize a user's calendar and contact data between different devices. + +Before calling any method in **SingleKVStore**, you must use [getKVStore](#getkvstore) to obtain a **SingleKVStore** instance. + +### get + +get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void + +Obtains the value of the specified key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key |string | Yes |Key of the value to obtain. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | +| callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | Yes |Callback invoked to return the value obtained. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log("get success data: " + data); + }); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + + +### get + +get(key: string): Promise<Uint8Array | string | boolean | number> + +Obtains the value of the specified key. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| key |string | Yes |Key of the value to obtain. It cannot be empty, and the length cannot exceed [MAX_KEY_LENGTH](#constants). | + + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<Uint8Array \| string \| boolean \| number> |Promise used to return the value obtained.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("get success data: " + data); + }).catch((err) => { + console.log("get err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); +}catch (e) { + console.log("An unexpected error occurred. Error:" + e); +} +``` + +### getEntries<sup>8+</sup> ### + +getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void + +Obtains all KV pairs that match the specified key prefix. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes |Key prefix to match. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback invoked to return the KV pairs obtained. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_number_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.INTEGER, + value : 222 + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + kvStore.getEntries('batch_test_number_key', function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(keyPrefix: string): Promise<Entry[]> + +Obtains all KV pairs that match the specified key prefix. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes |Key prefix to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + kvStore.getEntries('batch_test_string_key').then((entries) => { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(query: Query, callback: AsyncCallback<Entry[]>): void + +Obtains the KV pairs that match the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |Key prefix to match. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getEntries(query, function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(query: Query): Promise<Entry[]> + +Obtains the KV pairs that match the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getEntries(query).then((entries) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getResultSet<sup>8+</sup><a name="singlekvstore_getresultset"></a> ### + +getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains the result set with the specified prefix. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes |Key prefix to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | Yes |Callback invoked to return the result set obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('GetResultSet putBatch success'); + kvStore.getResultSet('batch_test_string_key', async function (err, result) { + console.log('GetResultSet getResultSet succeed.'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('GetResultSet closeResultSet success'); + }) + }); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(keyPrefix: string): Promise<KvStoreResultSet> + +Obtains the result set with the specified prefix. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes |Key prefix to match.| + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise used to return the result set obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('GetResult getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResult closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResult e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains a **KvStoreResultSet** object that matches the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |Query | Yes |**Query** object to match. | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet succeed.'); + resultSet = result; + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(query: Query): Promise<KvStoreResultSet> + +Obtains a **KvStoreResultSet** object that matches the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise used to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query).then((result) => { + console.log(' getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + +### getResultSet<sup>9+</sup> ### + +getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains a **KvStoreResultSet** object that matches the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |**DataSharePredicates** object to match. If this parameter is **null**, define the processing logic. | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +import dataSharePredicates from '@ohos.data.dataSharePredicates'; +let kvStore; +try { + let resultSet; + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.prefixKey("batch_test_string_key"); + kvStore.getResultSet(predicates, async function (err, result) { + console.log(' GetResultSet success'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log(' closeResultSet success'); + }) + }); +}catch(e) { + console.log('An unexpected error occurred. Error:' + e); +} +``` +### getResultSet<sup>9+</sup> ### + +getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<KvStoreResultSet> + +Obtains a **KvStoreResultSet** object that matches the specified **DataSharePredicates** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| predicates |[DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes |**DataSharePredicates** object to match. If this parameter is **null**, define the processing logic. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)> |Promise used to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +import dataSharePredicates from '@ohos.data.dataSharePredicates'; +let kvStore; +try { + let resultSet; + let predicates = new dataSharePredicates.DataSharePredicates(); + predicates.prefixKey("batch_test_string_key"); + kvStore.getResultSet(predicates) .then((result) => { + console.log(' GetResultSet success'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log(' closeResultSet success'); + }) + }); +}catch(e) { + console.log('An unexpected error occurred. Error:' + e); +} +``` +### closeResultSet<sup>8+</sup> ### + +closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void + +Closes the **KvStoreResultSet** object obtained by [SingleKvStore.getResultSet](#singlekvstore_getresultset). This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` + + +### closeResultSet<sup>8+</sup> ### + +closeResultSet(resultSet: KvStoreResultSet): Promise<void> + +Closes the **KvStoreResultSet** object obtained by [SingleKvStore.getResultSet](#singlekvstore_getresultset). This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#kvstoreresultset8) | Yes |**KvStoreResultSet** object to close. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(query: Query, callback: AsyncCallback<number>): void + +Obtains the number of results that matches the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<number> | Yes |Callback invoked to return the number of results obtained. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet succeed.'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(query: Query): Promise<number> + +Obtains the number of results that matches the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet succeed.'); + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### removeDeviceData<sup>8+</sup> ### + +removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void + +Deletes data of a device. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } + }); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` + + +### removeDeviceData<sup>8+</sup> ### + +removeDeviceData(deviceId: string): Promise<void> + +Deletes data of a device. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('removeDeviceData put success'); + }).catch((err) => { + console.log('put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` + + +### on('syncComplete')<sup>8+</sup> ### + +on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void + +Subscribes to the data synchronization complete events. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates completion of a data synchronization. | +| syncCallback |Callback<Array<[string, number]>> | Yes |Callback called to return the synchronization result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; +const VALUE_TEST_FLOAT_ELEMENT = 321.12; +try { + kvStore.on('syncComplete', function (data) { + console.log('syncComplete ' + data) + }); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); +}catch(e) { + console.log('syncComplete put e ' + e); +} +``` + + +### off('syncComplete')<sup>8+</sup> ### + +off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void + +Unsubscribes from the data synchronization complete events. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates completion of a data synchronization. | +| syncCallback |Callback<Array<[string, number]>> | No |Callback used to return the synchronization result. | + +**Example** + +```js +let kvStore; +try { + const func = function (data) { + console.log('syncComplete ' + data) + }; + kvStore.on('syncComplete', func); + kvStore.off('syncComplete', func); +}catch(e) { + console.log('syncComplete e ' + e); +} +``` + +### on('dataChange')<sup>9+</sup> ### + +on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void + +Subscribes to data changes of the specified type. This API returns the result synchronously. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **dataChange**, which indicates data changes. | +| type |[SubscribeType](#subscribetype) | Yes |Subscription type. | +| listener |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return the result.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); +}); + +``` + +### off('dataChange')<sup>9+</sup> ### + +off(event:'dataChange', listener?: Callback<ChangeNotification>): void + +Unsubscribes from the data change events. This API returns the result synchronously. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates data changes. | +| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return the result.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', function (data) { + console.log("callback call data: " + data); +}); +kvStore.off('dataChange', function (data) { + console.log("callback call data: " + data); +}); +``` +### sync<sup>7+</sup> + + +sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void + +Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceIds |string[] | Yes |List of IDs of the devices in the same networking environment to be synchronized. | +| mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | +| delayMs |number | No |Allowed synchronization delay time, in ms. | + +**Example** + +```js +let kvStore; +kvStore.sync('deviceIds', distributedData.SyncMode.PULL_ONLY, 1000); +``` + +### sync<sup>9+</sup> +sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void + +Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceIds |string[] | Yes |List of IDs of the devices in the same networking environment to be synchronized. | +| mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | +| query |[Query](#query8) | Yes |**Query** object to match. | +| delayMs |number | No |Allowed synchronization delay time, in ms. | + +**Example** + +```js +let kvStore; +const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; +const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; +try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + console.log('Sync put success'); + const devices = ['deviceList']; + const mode = distributedData.SyncMode.PULL_ONLY; + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.sync(devices, query, mode , 1000); + }); +}catch(e) { + console.log('Sync e' + e); +} +``` + +### setSyncParam<sup>8+</sup> ### + +setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void + +Sets the default delay allowed for KV store synchronization. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| defaultAllowedDelayMs |number | Yes |Default delay allowed for database synchronization, in ms. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) { + console.log('SetSyncParam put success'); + }); +}catch(e) { + console.log('testSingleKvStoreSetSyncParam e ' + e); +} +``` + + +### setSyncParam<sup>8+</sup> ### + +setSyncParam(defaultAllowedDelayMs: number): Promise<void> + +Sets the default delay allowed for KV store synchronization. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| defaultAllowedDelayMs |number | Yes |Default delay allowed for database synchronization, in ms. | + + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { + console.log('SetSyncParam put success'); + }).catch((err) => { + console.log('SetSyncParam put fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('SetSyncParam e ' + e); +} +``` + + +### getSecurityLevel<sup>8+</sup> ### + +getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void + +Obtains the security level of this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<[SecurityLevel](#securitylevel)> | Yes |Callback invoked to return the security level obtained. | + +**Example** + +```js +let kvStore; +try { + kvStore.getSecurityLevel(function (err,data) { + console.log('getSecurityLevel success'); + }); +}catch(e) { + console.log('GetSecurityLevel e ' + e); +} +``` + + +### getSecurityLevel<sup>8+</sup> ### + +getSecurityLevel(): Promise<SecurityLevel> + +Obtains the security level of this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[SecurityLevel](#securitylevel)> |Promise used to return the security level obtained.| + +**Example** + +```js +let kvStore; +try { + kvStore.getSecurityLevel().then((data) => { + console.log(' getSecurityLevel success'); + }).catch((err) => { + console.log('getSecurityLevel fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetSecurityLevel e ' + e); +} +``` + + +## DeviceKVStore<sup>8+</sup> ## + +Provides methods to query and synchronize data in a device KV store. This class inherits from [KVStore](#kvstore). + +Data is distinguished by device in a device KV store. Each device can only write and modify its own data. Data of other devices is read-only and cannot be modified. + +For example, a device KV store can be used to implement image sharing between devices. The images of other devices can be viewed, but not be modified or deleted. + +Before calling any method in **DeviceKVStore**, you must use [getKVStore](#getkvstore) to obtain a **DeviceKVStore** object. + +### get<sup>8+</sup> ### + +get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|number|Uint8Array>): void + +Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| key |string | Yes |Key to match. | +| callback |AsyncCallback<boolean\|string\|number\|Uint8Array> | Yes |Callback used to return the value obtained. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try{ + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log('get success'); + }); + }) +}catch(e) { + console.log('get e' + e); +} +``` + + +### get<sup>8+</sup> ### + +get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array> + +Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| key |string | Yes |Key to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<boolean\|string\|number\|Uint8Array> |Promise used to return the string value obtained.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { + console.log(' put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success'); + }).catch((err) => { + console.log('get fail ' + JSON.stringify(err)); + }); + }).catch((error) => { + console.log('put error' + error); + }); +} catch (e) { + console.log('Get e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void + +Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| keyPrefix |string | Yes |Key prefix to match. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> + +Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| keyPrefix |string | Yes |Key prefix to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('PutBatch e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(query: Query, callback: AsyncCallback<Entry[]>): void + +Obtains the KV pairs that match the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback used to return the KV pairs obtained. | + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getEntries(query, function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(query: Query): Promise<Entry[]> + +Obtains the KV pairs that match the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getEntries(query).then((entries) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void + +Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<[Entry](#entry)[]> | Yes |Callback invoked to return the KV pairs obtained. | + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + kvStore.getEntries('localDeviceId', query, function (err,entries) { + console.log('getEntries success'); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + }) + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getEntries<sup>8+</sup> ### + +getEntries(deviceId: string, query: Query): Promise<Entry[]> + +Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +**Example** + +```js +let kvStore; +try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + kvStore.getEntries('localDeviceId', query).then((entries) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + console.log('GetEntries success'); +}catch(e) { + console.log('GetEntries e ' + e); +} +``` + + +### getResultSet<sup>8+</sup><a name="devicekvstore_getresultset"></a> ### + +getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains a **KvStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| keyPrefix |string | Yes |Key prefix to match. | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { + console.log('getResultSet succeed.'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet> + +Obtains a **KvStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| keyPrefix |string | Yes |Key prefix to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains a **KvStoreResultSet** object that matches the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet succeed.'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(query: Query): Promise<KvStoreResultSet> + +Obtains a **KvStoreResultSet** object that matches the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + err); + }); + const query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.getResultSet(query).then((result) => { + console.log('getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreResultSet>): void + +Obtains a **KvStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained. | + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet('localDeviceId', query, async function (err, result) { + console.log('getResultSet succeed.'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); +} catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### getResultSet<sup>8+</sup> ### + +getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> + +Obtains a **KvStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultset8)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +**Example** + +```js +let kvStore; +try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('GetResultSet putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet('localDeviceId', query).then((result) => { + console.log('GetResultSet getResultSet succeed.'); + resultSet = result; + }).catch((err) => { + console.log('GetResultSet getResultSet failed: ' + JSON.stringify(err)); + }); + query.deviceId('localDeviceId'); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResultSet closeResultSet success'); + }).catch((err) => { + console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err)); + }); + +}catch(e) { + console.log('GetResultSet e ' + e); +} +``` + + +### closeResultSet<sup>8+</sup> ### + +closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void + +Closes the **KvStoreResultSet** object obtained by [DeviceKVStore.getResultSet](#devicekvstore_getresultset). This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#getresultset8) | Yes |**KvStoreResultSet** object to close. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` + + +### closeResultSet<sup>8+</sup> ### + +closeResultSet(resultSet: KvStoreResultSet): Promise<void> + +Closes the **KvStoreResultSet** object obtained by [DeviceKVStore.getResultSet](#devicekvstore_getresultset). This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#getresultset8) | Yes |**KvStoreResultSet** object to close. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('CloseResultSet e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(query: Query, callback: AsyncCallback<number>): void + +Obtains the number of results that matches the specified **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<number> | Yes |Callback invoked to return the number of results obtained. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet succeed.'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(query: Query): Promise<number> + +Obtains the number of results that matches the specified **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet succeed.'); + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void; + +Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | +| callback |AsyncCallback<number> | Yes |Callback invoked to return the number of results obtained. | + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { + console.log('getResultSet succeed.'); + }); + }); +} catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### getResultSize<sup>8+</sup> ### + +getResultSize(deviceId: string, query: Query): Promise<number> + +Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| query |[Query](#query8) | Yes |**Query** object to match. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +**Example** + +```js +let kvStore; +try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + var query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize('localDeviceId', query).then((resultSize) => { + console.log('getResultSet succeed.'); + }).catch((err) => { + console.log('getResultSet failed: ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('GetResultSize e ' + e); +} +``` + + +### removeDeviceData<sup>8+</sup> ### + +removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void + +Deletes data of the specified device from this KV store. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | +| callback |AsyncCallback<void> | Yes |Callback used to return the result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData put success'); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } + }); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` + + +### removeDeviceData<sup>8+</sup> ### + +removeDeviceData(deviceId: string): Promise<void> + +Deletes data of the specified device from this KV store. This API uses a promise to return the result. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes |ID of the target device. | + +**Return value** + +| Type | Description | +| ------ | ------- | +|Promise<void> |Promise that returns no value.| + +**Example** + +```js +let kvStore; +const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; +try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('RemoveDeviceData put success'); + }).catch((err) => { + console.log('RemoveDeviceData put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('RemoveDeviceData get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); +}catch(e) { + console.log('RemoveDeviceData e ' + e); +} +``` + + +### sync<sup>8+</sup> ### + +sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void + +Synchronizes the KV store manually. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceIds |string[] | Yes |IDs of the devices to be synchronized.| +| mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | +| delayMs |number | No |Allowed synchronization delay time, in ms. | + +**Example** + +```js +let kvStore; +const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; +const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; +try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + console.log('Sync put success'); + const devices = ['deviceList']; + const mode = distributedData.SyncMode.PULL_ONLY; + kvStore.sync(devices, mode); + }); +}catch(e) { + console.log('Sync e' + e); +} +``` + +### sync<sup>9+</sup> ### + +sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void + +Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of the distributed data service, see [Distributed Data Service Overview] (../../database/database-mdds-overview.md). + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| deviceIds |string[] | Yes |IDs of the devices to be synchronized.| +| query |[Query](#query8) | Yes | **Query** object to match.| +| delayMs |number | No |Allowed synchronization delay time, in ms. | + +**Example** + +```js +let kvStore; +const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; +const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; +try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + console.log('Sync put success'); + const devices = ['deviceList']; + const mode = distributedData.SyncMode.PULL_ONLY; + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.sync(devices, query, 1000); + }); +}catch(e) { + console.log('Sync e' + e); +} +``` + +### on('syncComplete')<sup>8+</sup> ### + +on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void + +Subscribes to the data synchronization complete events. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **syncComplete**, which indicates the data synchronization complete event.| +| syncCallback |Callback<Array<[string, number]>> | Yes |Callback used to return the synchronization result. | + +**Example** + +```js +let kvStore; +const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; +const VALUE_TEST_FLOAT_ELEMENT = 321.12; +try { + kvStore.on('syncComplete', function (data) { + console.log('syncComplete ' + data) + }); + kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); +}catch(e) { + console.log('syncComplete put e ' + e); +} +``` + + +### off('syncComplete')<sup>8+</sup> ### + +off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]>>): void + +Unsubscribes from the synchronization complete events. This API returns the result synchronously. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **syncComplete**, which indicates the data synchronization complete event.| +| syncCallback |Callback<Array<[string, number]>> | No |Callback used to return the synchronization result. | + +**Example** + +```js +let kvStore; +try { + const func = function (data) { + console.log('syncComplete ' + data) + }; + kvStore.on('syncComplete', func); + kvStore.off('syncComplete', func); +}catch(e) { + console.log('syncComplete e ' + e); +} +``` + +### on('dataChange')<sup>9+</sup> ### + +on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void + +Subscribes to data changes of the specified type. This API returns the result synchronously. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to subscribe to. The value is **dataChange**, which indicates data changes. | +| type |[SubscribeType](#subscribetype) | Yes |Subscription type. | +| listener |Callback<[ChangeNotification](#changenotification)> | Yes |Callback used to return the result.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); +}); +``` + + +### off('dataChange')<sup>9+</sup> ### + +off(event:'dataChange', listener?: Callback<ChangeNotification>): void + +Unsubscribes from the data change events. This API returns the result synchronously. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +**Parameters** + +| Name | Type| Mandatory | Description | +| ----- | ------ | ---- | ----------------------- | +| event |string | Yes |Event to unsubscribe from. The value is **dataChange**, which indicates data changes. | +| listener |Callback<[ChangeNotification](#changenotification)> |No |Callback used to return the result.| + +**Example** + +```js +let kvStore; +kvStore.on('dataChange', function (data) { + console.log("callback call data: " + data); +}); +kvStore.off('dataChange', function (data) { + console.log("callback call data: " + data); +}); +``` + +## SyncMode + +Enumerates the synchronization modes. + +**System capability**: SystemCapability.DistributedDataManager.KVStore.Core + +| Name | Value | Description | +| ----- | ------ | ----------------------- | +| PULL_ONLY |0 |Pull data from the peer end to the local end only.| +| PUSH_ONLY |1 |Push data from the local end to the peer end only.| +| PUSH_PULL |2 |Push data from the local end to the peer end and then pull data from the peer end to the local end.| + diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index 154bba75b0c8172459b41725add26ce2fa96db34..bad85aee529e6f5b2bff68cd79fd4172c53e7969 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -489,7 +489,7 @@ Obtains the IDs of all KV stores that are created by [getKVStore()](#getkvstore) let kvManager; try { console.log('GetAllKVStoreId'); - kvManager.getAllKVStoreId('apppId').then((data) => { + kvManager.getAllKVStoreId('appId').then((data) => { console.log('getAllKVStoreId success'); console.log('size = ' + data.length); }).catch((err) => { @@ -775,7 +775,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeeed.'); + console.log('getResultSet succeeded.'); resultSet = result; }).catch((err) => { console.log('getResultSet failed: ' + err); @@ -2453,10 +2453,10 @@ try { console.log('entries: ' + JSON.stringify(entries)); kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key', function (err,entrys) { + kvStore.getEntries('batch_test_string_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -2505,7 +2505,7 @@ try { console.log('entries: ' + JSON.stringify(entries)); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key').then((entrys) => { + kvStore.getEntries('batch_test_string_key').then((entries) => { console.log('getEntries success'); console.log('PutBatch ' + JSON.stringify(entries)); }).catch((err) => { @@ -3245,10 +3245,10 @@ try { } kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('batch_test_number_key', function (err,entrys) { + kvStore.getEntries('batch_test_number_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -3297,12 +3297,12 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key').then((entrys) => { + kvStore.getEntries('batch_test_string_key').then((entries) => { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); }); @@ -3353,10 +3353,10 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query, function (err,entrys) { + kvStore.getEntries(query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); console.log('GetEntries success'); @@ -3409,7 +3409,7 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query).then((entrys) => { + kvStore.getEntries(query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); @@ -3650,7 +3650,7 @@ Obtains a **KvStoreResultSet** object that matches the specified **Predicates** | Name | Type| Mandatory | Description | | ----- | ------ | ---- | ----------------------- | | predicates | Predicates | Yes |**Predicates** object to match. If this parameter is **null**, define the processing logic. | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | Yes |Callback invoked to return the **KvStoreResultSet** object obtained.| **Example** @@ -4134,7 +4134,7 @@ Synchronizes the KV store manually. This API uses a synchronous mode. For detail | ----- | ------ | ---- | ----------------------- | | deviceIds |string[] | Yes |List of IDs of the devices in the same networking environment to be synchronized. | | mode |[SyncMode](#syncmode) | Yes |Synchronization mode. | -| query |[Query](#querysup8sup) | Yes |**Query** object to match. | +| query |[Query](#query8) | Yes |**Query** object to match. | | delayMs |number | No |Allowed synchronization delay time, in ms. | **Example** @@ -4252,7 +4252,7 @@ try { console.log('getSecurityLevel success'); }); }catch(e) { - console.log('GetSecurityLeve e ' + e); + console.log('GetSecurityLevel e ' + e); } ``` @@ -4282,7 +4282,7 @@ try { console.log('getSecurityLevel fail ' + JSON.stringify(err)); }); }catch(e) { - console.log('GetSecurityLeve e ' + e); + console.log('GetSecurityLevel e ' + e); } ``` @@ -4412,10 +4412,10 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entrys) { + kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -4465,12 +4465,12 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entrys) => { + kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); }); @@ -4522,10 +4522,10 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); query.deviceId('localDeviceId'); - kvStore.getEntries(query, function (err,entrys) { + kvStore.getEntries(query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); console.log('GetEntries success'); @@ -4578,7 +4578,7 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query).then((entrys) => { + kvStore.getEntries(query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); @@ -4633,10 +4633,10 @@ try { var query = new distributedData.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); - kvStore.getEntries('localDeviceId', query, function (err,entrys) { + kvStore.getEntries('localDeviceId', query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }) }); console.log('GetEntries success'); @@ -4691,7 +4691,7 @@ try { var query = new distributedData.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); - kvStore.getEntries('localDeviceId', query).then((entrys) => { + kvStore.getEntries('localDeviceId', query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md index 458685119e17635f1b5af60e27910808bf8f99d6..3fbdc4f46c5e28f74743575a12f23fc138350f58 100644 --- a/en/application-dev/reference/apis/js-apis-document.md +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -14,21 +14,21 @@ import document from '@ohos.document'; choose(types? : string[]): Promise<string> -Chooses a file of the specified type using the file manager. This API uses a promise to return the result. +Chooses files of the specified types using the file manager. This API uses a promise to return the result. **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ---------------------------- | - | types | string[] | No | Type of the file to choose.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------------- | +| types | string[] | No | Types of the files to choose. | **Return value** - | Type | Description | - | --------------------- | -------------- | - | Promise<string> | Promise used to return the result. An error code is returned.| +| Type | Description | +| --------------------- | -------------- | +| Promise<string> | Promise used to return the result. An error code is returned.| **Example** @@ -46,9 +46,9 @@ Chooses a file using the file manager. This API uses an asynchronous callback to **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| **Example** @@ -62,16 +62,16 @@ Chooses a file using the file manager. This API uses an asynchronous callback to choose(types:string[], callback:AsyncCallback<string>): void -Chooses a file using the file manager. This API uses an asynchronous callback to return the result. +Chooses files using the file manager. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.FileManagement.UserFileService **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | types | string[] | No | Type of the file to choose.| - | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------- | +| types | string[] | No | Types of the files to choose.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| **Example** @@ -93,16 +93,16 @@ Opens a file. This API uses a promise to return the result. **Parameters** - | Name| Type | Mandatory| Description | - | ---- | ------ | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open.| - | type | string | Yes | Type of the file to open.| +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ---------------------------- | +| uri | string | Yes | URI of the file to open.| +| type | string | Yes | Type of the file to open.| **Return value** - | Type | Description | - | --------------------- | ------------ | - | Promise<void> | Promise used to return the result. An error code is returned.| +| Type | Description | +| --------------------- | ------------ | +| Promise<void> | Promise used to return the result. An error code is returned.| **Example** @@ -122,11 +122,11 @@ Opens a file. This API uses an asynchronous callback to return the result. **Parameters** - | Name | Type | Mandatory| Description | - | -------- | --------------------------- | ---- | ---------------------------- | - | uri | string | Yes | URI of the file to open.| - | type | string | Yes | Type of the file to open.| - | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------- | +| uri | string | Yes | URI of the file to open.| +| type | string | Yes | Type of the file to open.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-effectKit.md b/en/application-dev/reference/apis/js-apis-effectKit.md new file mode 100644 index 0000000000000000000000000000000000000000..089bf96cb239204c4b52c3ce71848f15141d76a4 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-effectKit.md @@ -0,0 +1,310 @@ +# Image Effect + +The **EffectKit** module provides basic image processing capabilities, including brightness adjustment, blurring, grayscale adjustment, and color picker. + +This module provides the following classes: + +- [Filter](#filter): a class that provides the effect chain. +- [Color](#color): a class used to store the color picked. +- [ColorPicker](#colorpicker): a smart color picker. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import effectKit from '@ohos.effectKit'; +``` + +## effectKit.createEffect +createEffect(source: image.PixelMap): Filter + +Creates a **Filter** instance based on the pixel map. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ----------------- | ---- | -------- | +| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | **PixelMap** instance created by the image module. | + +**Return value** + +| Type | Description | +| -------------------------------- | -------------- | +| [Filter](#filter) | Head node of the filter linked list without any effect. If the operation fails, **null** is returned.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts) + .then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap) + }) +``` + +## effectKit.createColorPicker + +createColorPicker(source: image.PixelMap): Promise\<ColorPicker> + +Creates a **ColorPicker** instance based on the pixel map. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------- | ---- | -------------------------- | +| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | **PixelMap** instance created by the image module.| + +**Return value** + +| Type | Description | +| ---------------------- | -------------- | +| Promisse\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts, (pixelMap) => { + effectKit.createColorPicker(pixelMap).then(colorPicker => { + console.info("color picker=" + colorPicker); + }) + .catch(ex => console.error(".error=" + ex.toString())) +}) +``` + +## effectKit.createColorPicker + +createColorPicker(source: image.PixelMap, callback: AsyncCallback\<ColorPicker>): void + +Creates a **ColorPicker** instance based on the pixel map. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------ | ---- | -------------------------- | +| source | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes |**PixelMap** instance created by the image module. | +| callback | AsyncCallback\<[ColorPicker](#colorpicker)> | Yes | Callback used to return the **ColorPicker** instance created.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts, (pixelMap) => { + effectKit.createColorPicker(pixelMap, (error, colorPicker) => { + if(error) { + console.log('Failed to create color picker.'); + } else { + console.log('Succeeded in creating color picker.'); + } + }) +}) +``` + +## Color + +A class that stores the color picked. + +**System capability**: SystemCapability.Multimedia.Image.Core + +| Name | Type | Readable| Writable| Description | +| ------ | ----- | ---- | ---- | ---------------- | +| red | number | Yes | No | Value of the red component. | +| green | number | Yes | No | Value of the green component. | +| blue | number | Yes | No | Value of the blue component. | +| alpha | number | Yes | No | Value of the alpha component. | + +## ColorPicker + +A class used to obtain the main color of an image from its data. Before calling any method of **ColorPicker**, use [createColorPicker](#effectkitcreatecolorpicker) to create a **ColorPicker** instance. + +### getMainColor + +getMainColor(): Promise\<Color> + +Obtains the main color of the image and writes the result to a **[Color](#color)** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| :------------- | :---------------------------------------------- | +| Promise\<[Color](#color)> | Promise used to return the color value of the main color. If the operation fails, an error message is returned.| + +**Example** + +```js +colorPicker.getMainColor().then(color => { + console.log('Succeeded in getting main color.') + console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue); +}).catch(error => { + console.log('Failed to get main color.'); +}) +``` + +### getMainColorSync + +getMainColorSync(): Color + +Obtains the main color of the image and writes the result to a **[Color](#color)** instance. This API returns the result in synchronous mode. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| :------- | :----------------------------------- | +| [Color](#color) | Color value of the main color. If the operation fails, **null** is returned.| + +**Example** + +```js +let color = colorPicker.getMainColorSync(); +console.log('get main color =' + color); +``` + +## Filter + +A class used to add a specified effect to an image. Before calling any method of **Filter**, use [createEffect](#effectkitcreateeffect) to create a **Filter** instance. + +### blur + +blur(radius: number): Filter + +Adds the blur effect to the filter linked list, and returns the head node of the linked list. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| radius | number | Yes | Blur radius, in pixels. The blur effect is proportional to the configured value. A larger value indicates a more obvious effect.| + +**Return value** + +| Type | Description | +| :------------- | :---------------------------------------------- | +| [Filter](#filter) | Head node of the filter linked list.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts) + .then((pixelMap) => { + let radius = 5; + let headFilter = effectKit.createEffect(pixelMap) + if (headFilter != null) { + headFilter.blur(radius) + } + }) +``` + +### brightness + +brightness(bright: number): Filter + +Adds the brightness effect to the filter linked list, and returns the head node of the linked list. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------- | ---- | ------------------------------------------------------------ | +| bright | number | Yes | Brightness value, ranging from 0 to 1. When the value is **0**, the image brightness remains unchanged.| + +**Return value** + +| Type | Description | +| :------------- | :---------------------------------------------- | +| [Filter](#filter) | Head node of the filter linked list.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts) + .then((pixelMap) => { + let bright = 0.5; + let headFilter = effectKit.createEffect(pixelMap) + if (headFilter != null) { + headFilter.brightness(bright) + } + }) +``` + +### grayscale + +grayscale(): Filter + +Adds the grayscale effect to the filter linked list, and returns the head node of the linked list. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| :------------- | :---------------------------------------------- | +| [Filter](#filter) | Head node of the filter linked list.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts) + .then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap) + if (headFilter != null) { + headFilter.grayscale() + } + }) +``` + +### getPixelMap + +getPixelMap(): image.PixelMap + +Obtains **image.PixelMap** of the source image to which the filter linked list is added. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| :------------- | :---------------------------------------------- | +| [image.PixelMap](js-apis-image.md#pixelmap7) | **image.PixelMap** of the source image.| + +**Example** + +```js +import image from "@ohos.multimedia.image" +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts) + .then((pixelMap) => { + let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap() + }) +``` diff --git a/en/application-dev/reference/apis/js-apis-environment.md b/en/application-dev/reference/apis/js-apis-environment.md index 942e514367c923db4d7aa270218e39ae82f65aa0..d023cdc8403d028ff250d3ea7afa82858d6ad5b8 100644 --- a/en/application-dev/reference/apis/js-apis-environment.md +++ b/en/application-dev/reference/apis/js-apis-environment.md @@ -1,12 +1,12 @@ # Environment +This module provides JS APIs for obtaining the root directories of the storage and public files. + > **NOTE** > > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The APIs of this module are system APIs and cannot be called by third-party applications. -This module provides JS APIs for obtaining the root directories of the storage and public files. - ## Modules to Import ```js diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md index a5a25efdbab5c977e92b85a5fcc656f5c3ae3ef7..ca1b1500dcb8836b73abd13e837a0255a78a3a5f 100644 --- a/en/application-dev/reference/apis/js-apis-eventhub.md +++ b/en/application-dev/reference/apis/js-apis-eventhub.md @@ -1,18 +1,12 @@ # EventHub +The **EventHub** module provides APIs to subscribe to, unsubscribe from, and trigger events. + > **NOTE** > -> 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. +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Implements event subscription, unsubscription, and triggering. - -## Modules to Import - -```js -import Ability from '@ohos.application.Ability' -``` - ## Usage ​Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance. diff --git a/en/application-dev/reference/apis/js-apis-extension-context.md b/en/application-dev/reference/apis/js-apis-extension-context.md index 24ca2bb2e99bd5b308aea4683a9242c998417e78..7d7b21f2cb04fbb7c0cb9d9a3581e09813cd00ef 100644 --- a/en/application-dev/reference/apis/js-apis-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-extension-context.md @@ -1,22 +1,20 @@ # ExtensionContext +The **ExtensionContext** module, inherited from **Context**, implements the context for Extension abilities. + +This module allows access to Extension abilities. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -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 -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. | +| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. | | config | Configuration | Yes| No| Module configuration information.| +| extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | Yes| No| Extension ability information.| diff --git a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md index 62f6d9b631aa687e61fc6a1b4fe26fb72f16f105..66b794234a41c9e57977946adbf02a9f35182b60 100644 --- a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md @@ -1,20 +1,15 @@ # ExtensionRunningInfo +The **ExtensionRunningInfo** module provides running information and states for Extension abilities. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -Provides extension running information. - -## Modules to Import - -```js -import abilitymanager from '@ohos.application.abilityManager'; -``` +> The APIs of this module are system APIs and cannot be called by third-party applications. ## Usage -The extension running information is obtained through an **abilityManager** instance. +The Extension ability running information is obtained through an **abilityManager** instance. ```js import abilitymanager from '@ohos.application.abilityManager'; @@ -24,37 +19,16 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { }); ``` - -### Attributes +## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| extension | ElementName | Yes| No| Information that matches an extension.| +| extension | ElementName | Yes| No| Information that matches an Extension ability.| | pid | number | Yes| No| Process ID.| | uid | number | Yes| No| User ID.| | processName | string | Yes| No| Process name.| -| startTime | number | Yes| No| Extension start time.| +| startTime | number | Yes| No| Start time of the Extension ability.| | clientPackage | Array<String> | Yes| No| Names of all packages in the process.| -| type | [bundle.ExtensionAbilityType](#bundleextensionabilitytype) | Yes| No| Extension type.| - - -## bundle.ExtensionAbilityType - -Enumerates extension types. - -**System capability**: SystemCapability.BundleManager.BundleFramework - - | Name| Value| Description| -| -------- | -------- | -------- | -| FORM | 0 | Extension information of the form type.< | -| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< | -| INPUT_METHOD | 2 | Extension information of the input method type.< | -| SERVICE | 3 | Extension information of the service type.< | -| ACCESSIBILITY | 4 | Extension information of the accessibility type.< | -| DATA_SHARE | 5 | Extension information of the data share type.< | -| FILE_SHARE | 6 | Extension information of the file share type.< | -| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< | -| WALLPAPER | 8 | Extension information of the wallpaper type.< | -| UNSPECIFIED | 9 | Extension information of the unspecified type.< | +| type | [bundle.ExtensionAbilityType](js-apis-Bundle.md#extensionabilitytype9) | Yes| No| Extension ability type.| diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 4c15fefc458a174ee0477d23b77aa9796f2bb051..93941ea52e332de2f3306673c20c74ef176cb808 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -1,5 +1,7 @@ # FeatureAbility +The **FeatureAbility** module provides a UI for interacting with users. You can use APIs of this module to start a new ability, obtain the **dataAbilityHelper**, set a Page ability, obtain the window corresponding to this ability, and connecting to a Service ability. + > **NOTE** > > 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. @@ -19,7 +21,7 @@ import featureAbility from '@ohos.ability.featureAbility' startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>): void -Starts an ability. This API uses a callback to return the result. +Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -127,7 +129,7 @@ featureAbility.acquireDataAbilityHelper( startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void -Starts an ability. This API uses a callback to return the execution result when the ability is destroyed. +Starts an ability. This API uses an asynchronous callback to return the execution result when the ability is destroyed. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -214,7 +216,6 @@ featureAbility.startAbilityForResult( mykey7: true, }, }, - requestCode: 2, }, ).then((data) => { console.info("==========================>startAbilityForResult=======================>"); @@ -225,7 +226,7 @@ featureAbility.startAbilityForResult( terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void -Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result. +Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -326,13 +327,11 @@ featureAbility.terminateSelfWithResult( }); ``` - - ## featureAbility.hasWindowFocus<sup>7+<sup> hasWindowFocus(callback: AsyncCallback\<boolean>): void -Checks whether the main window of this ability has the focus. This API uses a callback to return the result. +Checks whether the main window of this ability has the focus. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -349,8 +348,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus() ``` - - ## featureAbility.hasWindowFocus<sup>7+<sup> hasWindowFocus(): Promise\<boolean> @@ -368,19 +365,17 @@ Checks whether the main window of this ability has the focus. This API uses a pr **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus().then((data) => { console.info("==========================>hasWindowFocus=======================>"); }); ``` - - ## featureAbility.getWant getWant(callback: AsyncCallback\<Want>): void -Obtains the **Want** object sent from this ability. This API uses a callback to return the result. +Obtains the **Want** object sent from this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -397,8 +392,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant() ``` - - ## featureAbility.getWant getWant(): Promise\<Want> @@ -444,13 +437,11 @@ var context = featureAbility.getContext() context.getBundleName() ``` - - ## featureAbility.terminateSelf<sup>7+</sup> terminateSelf(callback: AsyncCallback\<void>): void -Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result. +Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -467,8 +458,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf() ``` - - ## featureAbility.terminateSelf<sup>7+</sup> terminateSelf(): Promise\<void> @@ -496,7 +485,7 @@ featureAbility.terminateSelf().then((data) => { connectAbility(request: Want, options:ConnectOptions): number -Connects this ability to a specific Service ability. This API uses a callback to return the result. +Connects this ability to a specific Service ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -505,17 +494,9 @@ Connects this ability to a specific Service ability. This API uses a callback to | Name | Type | Mandatory | Description | | ------- | -------------- | ---- | --------------------- | | request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.| -| options | ConnectOptions | Yes | Callback used to return the result. | +| options | [ConnectOptions](#connectoptions) | Yes | Callback used to return the result. | -Want - -**System capability**: SystemCapability.Ability.AbilityBase - -| Name | Readable/Writable| Type | Mandatory | Description | -| ----------- | ---- | ------ | ---- | ---------------------------------------- | -| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.| -| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. | -| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. | +## ConnectOptions ConnectOptions @@ -523,9 +504,9 @@ ConnectOptions | Name | Readable/Writable| Type | Mandatory | Description | | ------------ | ---- | -------- | ---- | ------------------------- | -| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. | -| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. | -| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.| +| onConnect<sup>7+</sup> | Read-only | function | Yes | Callback invoked when the connection is successful. | +| onDisconnect<sup>7+</sup> | Read-only | function | Yes | Callback invoked when the connection fails. | +| onFailed<sup>7+</sup> | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.| **Return value** @@ -565,7 +546,7 @@ var connId = featureAbility.connectAbility( disconnectAbility(connection: number, callback:AsyncCallback\<void>): void -Disconnects this ability from a specific Service ability. This API uses a callback to return the result. +Disconnects this ability from a specific Service ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -654,8 +635,10 @@ var connId = featureAbility.connectAbility( }, ); -featureAbility.disconnectAbility(connId).then((error,data) => { - console.log('featureAbilityTest result errCode : ' + error.code + " data: " + data); +featureAbility.disconnectAbility(connId).then((data) => { + console.log('data : ' + data); +}).catch((error)=>{ + console.log('featureAbilityTest result errCode : ' + error.code); }); ``` @@ -664,7 +647,7 @@ featureAbility.disconnectAbility(connId).then((error,data) => { getWindow(callback: AsyncCallback\<window.Window>): void -Obtains the window corresponding to this ability. This API uses a callback to return the result. +Obtains the window corresponding to this ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -914,7 +897,7 @@ Enumerates operation types of the Data ability. ## StartAbilityParameter -**System capability**: SystemCapability.AbilityRuntime.FAModel +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | Name | Readable/Writable| Type | Mandatory | Description | | ------------------- | ---- | -------------------- | ---- | -------------------------------------- | @@ -925,7 +908,7 @@ Enumerates operation types of the Data ability. **System capability**: SystemCapability.Ability.AbilityBase -| Name | Value | Description | +| Name | Name | Description | | ------------------------------------ | ---------- | ---------------------------------------- | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. | @@ -933,10 +916,10 @@ Enumerates operation types of the Data ability. | FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. | -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. | -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications. | | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. | -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.<br>**System API**: This is a system API and cannot be called by third-party applications. | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. | diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 133276e077b78d22fb2c06222ba067611f9ee3c7..6e970785345a27be2c2c4d1051f87c13c4d8533f 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -16,6 +16,7 @@ import fileio from '@ohos.fileio'; ## Guidelines Before using the APIs provided by this module to perform operations on files or directories, obtain the path of the application sandbox as follows: + ```js import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); @@ -353,58 +354,11 @@ Synchronously closes a file. **Example** ```js + let fd = fileio.openSync(path); fileio.closeSync(fd); ``` -## fileio.close<sup>7+</sup> - -close(): Promise<void> - -Closes the stream. This API uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.File.FileIO - -**Return value** - - | Type | Description | - | ------------------- | ---------------------------- | - | Promise<void> | Promise that returns no value.| - -**Example** - - ```js - fileio.close().then(function(){ - console.info("File stream closed"); - }).catch(function(err){ - console.info("Failed to close the file stream. Error:"+ err); - }); - ``` - - -## fileio.close<sup>7+</sup> - -close(callback: AsyncCallback<void>): void - -Closes the stream. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.FileManagement.File.FileIO - -**Parameters** - - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | ------------- | - | callback | AsyncCallback<void> | Yes | Callback invoked when the stream is closed asynchronously.| - -**Example** - - ```js - fileio.close(function(err){ - // Do something. - }); - ``` - - ## fileio.copyFile copyFile(src:string | number, dest:string | number, mode?:number):Promise<void> @@ -430,6 +384,8 @@ Copies a file. This API uses a promise to return the result. **Example** ```js + let src = path; + let dest = src + 'tgt'; fileio.copyFile(src, dest).then(function(){ console.info("File copied"); }).catch(function(err){ @@ -458,6 +414,8 @@ Copies a file. This API uses an asynchronous callback to return the result. **Example** ```js + let src = path; + let dest = src + 'tgt'; fileio.copyFile(src, dest, function (err) { // Do something. }); @@ -483,6 +441,8 @@ Synchronously copies a file. **Example** ```js + let src = path; + let dest = src + 'tgt'; fileio.copyFileSync(src, dest); ``` @@ -957,7 +917,7 @@ Writes data into a file. This API uses a promise to return the result. ```js let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world").then(function(number){ - console.info("Data written to file and size is:"+ number); + console.info("Data written to the file. Size is:"+ number); }).catch(function(err){ console.info("Failed to write data to the file. Error:"+ err); }); @@ -992,7 +952,7 @@ Writes data into a file. This API uses an asynchronous callback to return the re let fd = fileio.openSync(path, 0o100 | 0o2, 0o666); fileio.write(fd, "hello, world", function (err, bytesWritten) { if (bytesWritten) { - console.info("Data written to file and size is:"+ bytesWritten); + console.info("Data written to the file. Size is:"+ bytesWritten); } }); ``` @@ -1059,7 +1019,7 @@ Calculates the hash value of a file. This API uses a promise to return the resul ```js fileio.hash(path, "sha256").then(function(str){ console.info("Calculated file hash:"+ str); - }).catch(function(error){ + }).catch(function(err){ console.info("Failed to calculate the file hash. Error:"+ err); }); ``` @@ -1116,7 +1076,7 @@ Changes file permissions. This API uses a promise to return the result. **Example** ```js - fileio.chmod(path, mode).then(function() { + fileio.chmod(path, 0o700).then(function() { console.info("File permissions changed"); }).catch(function(err){ console.info("Failed to change file permissions. Error:"+ err); @@ -1143,7 +1103,7 @@ Changes file permissions. This API uses an asynchronous callback to return the r **Example** ```js - fileio.chmod(path, mode, function (err) { + fileio.chmod(path, 0o700, function (err) { // Do something. }); ``` @@ -1167,7 +1127,7 @@ Synchronously changes file permissions. **Example** ```js - fileio.chmodSync(path, mode); + fileio.chmodSync(path, 0o700); ``` @@ -1194,10 +1154,11 @@ Obtains file information based on the file descriptor. This API uses a promise t **Example** ```js + let fd = fileio.openSync(path); fileio.fstat(fd).then(function(stat){ - console.info("File information obtained:"+ JSON.stringify(stat)); + console.info("Obtained file info:"+ JSON.stringify(stat)); }).catch(function(err){ - console.info("Failed to obtain file information. Error:"+ err); + console.info("Failed to obtain file info. Error:"+ err); }); ``` @@ -1307,7 +1268,9 @@ Truncates a file based on the file descriptor. This API uses an asynchronous cal **Example** ```js - fileio.ftruncate(fd, len, function(err){ + let fd = fileio.openSync(path); + let len = 5; + fileio.ftruncate(fd, 5, function(err){ // Do something. }); ``` @@ -1331,6 +1294,8 @@ Synchronously truncates a file based on the file descriptor. **Example** ```js + let fd = fileio.openSync(path); + let len = 5; fileio.ftruncateSync(fd, len); ``` @@ -1347,7 +1312,7 @@ Truncates a file based on the file path. This API uses a promise to return the r | Name| Type | Mandatory| Description | | ------ | ------ | ---- | -------------------------------- | -| path | string | Yes | Application sandbox path of the file to truncate. | +| path | string | Yes | Application sandbox path of the file to truncate.| | len | number | No | File length, in bytes, after truncation.| **Return value** @@ -1359,6 +1324,7 @@ Truncates a file based on the file path. This API uses a promise to return the r **Example** ```js + let len = 5; fileio.truncate(path, len).then(function(){ console.info("File truncated"); }).catch(function(err){ @@ -1386,6 +1352,7 @@ Truncates a file based on the file path. This API uses an asynchronous callback **Example** ```js + let len = 5; fileio.truncate(path, len, function(err){ // Do something. }); @@ -1410,6 +1377,7 @@ Synchronously truncates a file based on the file path. **Example** ```js + let len = 5; fileio.truncateSync(path, len); ``` @@ -1443,9 +1411,9 @@ Reads the text content of a file. This API uses a promise to return the result. ```js fileio.readText(path).then(function(str) { - console.info("Read file text:"+ str); + console.info("Read text:"+ str); }).catch(function(err){ - console.info("Failed to read text. Error:"+ err); + console.info("Failed to read the text. Error:"+ err); }); ``` @@ -1467,13 +1435,13 @@ Reads the text content of a file. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ------------------------------------------------------------ | | filePath | string | Yes | Application sandbox path of the file to read. | -| options | Object | No | The options are as follows:<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **encoding**: format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| +| options | Object | Yes | The options are as follows:<br>- **position** (number): position of the data to read in the file. By default, data is read from the current position.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>- **encoding**: format of the string to be encoded. The default value is **utf-8**, which is the only value supported.| | callback | AsyncCallback<string> | Yes | Callback used to return the content read. | **Example** ```js - fileio.readText(path, function(err, str){ + fileio.readText(path, { position: 1, encoding: 'UTF-8' }, function(err, str){ // Do something. }); ``` @@ -1537,7 +1505,7 @@ Obtains link information. This API uses a promise to return the result. fileio.lstat(path).then(function(stat){ console.info("Got link info:"+ JSON.stringify(stat)); }).catch(function(err){ - console.info("Failed to obtain the link status. Error:"+ err); + console.info("Failed to obtain link info. Error:"+ err); }); ``` @@ -1593,76 +1561,6 @@ Synchronously obtains the link information. ``` -## fileio.read<sup>7+</sup> - -read(buffer: ArrayBuffer, options?: { - position?: number; - offset?: number; - length?: number; -}): Promise<ReadOut> - -Reads data from a file. This API uses a promise to return the result. - -**System capability**: SystemCapability.FileManagement.File.FileIO - -**Parameters** - - | Name | Type | Mandatory| Description | - | ------- | ----------- | ---- | ------------------------------------------------------------ | - | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>Constraints: offset + length <= Buffer size| - -**Return value** - - | Type | Description | - | ---------------------------------- | ------ | - | Promise<[ReadOut](#readout)> | Promise used to return the data read.| - -**Example** - - ```js - fileio.read(new ArrayBuffer(4096)).then(function(readout){ - console.info("Read file data"); - console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); - }).catch(function(err){ - console.info("Failed to read file data. Error:"+ err); - }); - ``` - - -## fileio.read<sup>7+</sup> - -read(buffer: ArrayBuffer, options: { - position?: number; - offset?: number; - length?: number; -}, callback: AsyncCallback<ReadOut>): void - -Reads data from a file. This API uses an asynchronous callback to return the result. - -**System capability**: SystemCapability.FileManagement.File.FileIO - -**Parameters** - - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer | Yes | Buffer used to store the file data read. | - | options | Object | No | The options are as follows:<br>- **offset** (number): position to store the data read in the buffer in reference to the start address of the buffer. The default value is **0**.<br>- **length** (number): length of the data to read. The default value is the buffer length minus the offset.<br>Constraints: offset + length <= Buffer size| - | callback | AsyncCallback<[ReadOut](#readout)> | Yes | Callback invoked when the data is read asynchronously from the file. | - -**Example** - - ```js - let buf = new ArrayBuffer(4096); - fileio.read(buf, function (err, readOut) { - if (readOut) { - console.info("Read file data"); - console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); - } - }); - ``` - - ## fileio.rename<sup>7+</sup> rename(oldPath: string, newPath: string): Promise<void> @@ -1687,6 +1585,8 @@ Renames a file. This API uses a promise to return the result. **Example** ```js + let oldPath = path; + let newPath = oldPath + '123'; fileio.rename(oldPath, newPath).then(function() { console.info("File renamed"); }).catch(function(err){ @@ -1714,6 +1614,8 @@ Renames a file. This API uses an asynchronous callback to return the result. **Example** ```js + let oldPath = path; + let newPath = oldPath + '123'; fileio.rename(oldPath, newPath, function(err){ }); ``` @@ -1737,6 +1639,8 @@ Synchronously renames a file. **Example** ```js + let oldPath = path; + let newPath = oldPath + '123'; fileio.renameSync(oldPath, newPath); ``` @@ -1764,6 +1668,7 @@ Flushes data of a file to disk. This API uses a promise to return the result. **Example** ```js + let fd = fileio.openSync(path); fileio.fsync(fd).then(function(){ console.info("Data flushed"); }).catch(function(err){ @@ -1790,6 +1695,7 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Example** ```js + let fd = fileio.openSync(path); fileio.fsync(fd, function(err){ // Do something. }); @@ -1813,6 +1719,7 @@ Flushes data of a file to disk in synchronous mode. **Example** ```js + let fd = fileio.openSync(path); fileio.fsyncSync(fd); ``` @@ -1840,6 +1747,7 @@ Flushes data of a file to disk. This API uses a promise to return the result. ** **Example** ```js + let fd = fileio.openSync(path); fileio.fdatasync(fd).then(function(err) { console.info("Data flushed"); }).catch(function(err){ @@ -1866,6 +1774,7 @@ Flushes data of a file to disk. This API uses an asynchronous callback to return **Example** ```js + let fd = fileio.openSync(path); fileio.fdatasync (fd, function (err) { // Do something. }); @@ -1889,6 +1798,7 @@ Synchronizes data in a file in synchronous mode. **Example** ```js + let fd = fileio.openSync(path); let stat = fileio.fdatasyncSync(fd); ``` @@ -1917,6 +1827,8 @@ Creates a symbolic link based on the file path. This API uses a promise to retur **Example** ```js + let target = path; + let srcPath = target + 'aaa'; fileio.symlink(target, srcPath).then(function() { console.info("Symbolic link created"); }).catch(function(err){ @@ -1944,6 +1856,8 @@ Creates a symbolic link based on the file path. This API uses an asynchronous ca **Example** ```js + let target = path; + let srcPath = target + 'aaa'; fileio.symlink(target, srcPath, function (err) { // Do something. }); @@ -1968,6 +1882,8 @@ Synchronously creates a symbolic link based on a specified path. **Example** ```js + let target = path; + let srcPath = target + 'aaa'; fileio.symlinkSync(target, srcPath); ``` @@ -2083,7 +1999,7 @@ Creates a temporary directory. This API uses a promise to return the result. fileio.mkdtemp(path + "XXXX").then(function(path){ console.info("Temporary directory created:"+ path); }).catch(function(err){ - console.info("Failed to create a temporary directory. Error:"+ err); + console.info("Failed to create the temporary directory. Error:"+ err); }); ``` @@ -2163,6 +2079,8 @@ Changes file permissions based on the file descriptor. This API uses a promise t **Example** ```js + let fd = fileio.openSync(path); + let mode = 0o700; fileio.fchmod(fd, mode).then(function() { console.info("File permissions changed"); }).catch(function(err){ @@ -2190,6 +2108,8 @@ Changes file permissions based on the file descriptor. This API uses an asynchro **Example** ```js + let fd = fileio.openSync(path); + let mode = 0o700; fileio.fchmod(fd, mode, function (err) { // Do something. }); @@ -2214,6 +2134,8 @@ Synchronously changes the file permissions based on the file descriptor. **Example** ```js + let fd = fileio.openSync(path); + let mode = 0o700; fileio.fchmodSync(fd, mode); ``` @@ -2416,6 +2338,7 @@ Changes the file owner based on the file descriptor. This API uses a promise to **Example** ```js + let fd = fileio.openSync(path); let stat = fileio.statSync(path); fileio.fchown(fd, stat.uid, stat.gid).then(function() { console.info("File owner changed"); @@ -2445,6 +2368,7 @@ Changes the file owner based on the file descriptor. This API uses an asynchrono **Example** ```js + let fd = fileio.openSync(path); let stat = fileio.statSync(path); fileio.fchown(fd, stat.uid, stat.gid, function (err){ // Do something. @@ -2471,6 +2395,7 @@ Synchronously changes the file owner based on the file descriptor. **Example** ```js + let fd = fileio.openSync(path); let stat = fileio.statSync(path); fileio.fchownSync(fd, stat.uid, stat.gid); ``` @@ -2854,7 +2779,7 @@ Closes the stream. This API uses a promise to return the result. ```js let ss= fileio.createStreamSync(path, "r+"); ss.close().then(function(){ - console.info("Stream closed"); + console.info("File stream closed"); }).catch(function(err){ console.info("Failed to close the file stream. Error:"+ err); }); @@ -3102,7 +3027,7 @@ Reads data from the stream. This API uses a promise to return the result. ```js let ss = fileio.createStreamSync(path, "r+"); - ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){ + ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readOut){ console.info("Read data successfully"); console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer))); }).catch(function(err){ @@ -3179,7 +3104,7 @@ Synchronously reads data from the stream. ## Dir -Manages directories. Before calling a method of the **Dir** class, use the [opendir()](#fileioopendir) method synchronously or asynchronously to create a **Dir** instance. +Manages directories. Before calling a method of the **Dir** class, use the **opendir()** method synchronously or asynchronously to create a **Dir** instance. ### read @@ -3449,7 +3374,7 @@ Checks whether a directory entry is a socket. **Example** ```js - let dir = fileio.opendirSync(dpath); + let dir = fileio.opendirSync(path); let isSocket = dir.readSync().isSocket(); ``` diff --git a/en/application-dev/reference/apis/js-apis-formInfo.md b/en/application-dev/reference/apis/js-apis-formInfo.md index 502a8212f54e8cdefa381a8b862f1148e2f73b11..15e434ce7b5e6e29d67749b6d12a1069fb258c75 100644 --- a/en/application-dev/reference/apis/js-apis-formInfo.md +++ b/en/application-dev/reference/apis/js-apis-formInfo.md @@ -1,11 +1,11 @@ # FormInfo +The **FormInfo** module provides widget information and state. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides widget information. - ## Modules to Import ``` @@ -14,15 +14,13 @@ import formInfo from '@ohos.application.formInfo'; ## Required Permissions -None. +None ## FormInfo Describes widget information. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Readable/Writable| Type | Description | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | @@ -43,15 +41,13 @@ SystemCapability.Ability.Form | updateDuration | Read only | string | Widget update period.| | defaultDimension | Read only | number | Default dimension of the widget. | | supportDimensions | Read only | Array<number> | Dimensions supported by the widget. | -| customizeData | Read only | {[key: string]: [value: string]} | Custom data of the widget. | +| customizeData | Read only | {[key: string]: [value: string]} | Custom data of the widget. | ## FormType Enumerates the widget types. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Value | Description | | ----------- | ---- | ------------ | @@ -61,13 +57,11 @@ SystemCapability.Ability.Form Enumerates the color modes supported by the widget. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Value | Description | | ----------- | ---- | ------------ | -| MODE_AUTO | -1 | Automatic mode. | +| MODE_AUTO | -1 | Auto mode. | | MODE_DARK | 0 | Dark mode. | | MODE_LIGHT | 1 | Light mode. | @@ -75,22 +69,18 @@ SystemCapability.Ability.Form Describes the widget state information. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Readable/Writable| Type | Description | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | -| formState | Read only | [FormState](#formstate) | Widget state. | +| formState | Read only | [FormState](#formstate) | Widget state. | | want | Read only | Want | Want text. | ## FormState Enumerates the widget states. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Value | Description | | ----------- | ---- | ------------ | @@ -102,13 +92,11 @@ SystemCapability.Ability.Form Enumerates the widget parameters. -**System capability** - -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form | Name | Value | Description | | ----------- | ---- | ------------ | -| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget. | +| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget.<br>**System API**: This is a system API and cannot be called by third-party applications. | | DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. | | NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. | | MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. | diff --git a/en/application-dev/reference/apis/js-apis-formbindingdata.md b/en/application-dev/reference/apis/js-apis-formbindingdata.md index 622f78b73e55afbe4fdcf8b342597b3ba44edeeb..612b2dc84f23f465a844d73656954bc983c5a233 100644 --- a/en/application-dev/reference/apis/js-apis-formbindingdata.md +++ b/en/application-dev/reference/apis/js-apis-formbindingdata.md @@ -1,5 +1,7 @@ # FormBindingData +The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -26,7 +28,7 @@ Creates a **FormBindingData** object. | Name| Type | Mandatory| Description | | ------ | -------------- | ---- | ------------------------------------------------------------ | -| obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.| +| obj | Object or string| No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.| **Return value** @@ -63,4 +65,4 @@ Describes a **FormBindingData** object. | Name| Readable| Writable| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -------- | -------- | -| data | Yes| No| Object | Yes| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.| +| data | Yes| No| Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.| diff --git a/en/application-dev/reference/apis/js-apis-formerror.md b/en/application-dev/reference/apis/js-apis-formerror.md index 62e062c25eab28cfa018f4971da3e5317db7d448..b5868572cb1d74e528b029609da121a4db0b3ca6 100644 --- a/en/application-dev/reference/apis/js-apis-formerror.md +++ b/en/application-dev/reference/apis/js-apis-formerror.md @@ -1,11 +1,11 @@ # FormError +The **FormError** module provides error codes for widgets. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides widget-related error codes. - ## Modules to Import ``` diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md index cd6b0eaff6f6f35da2f2899efe36312943ee66d8..daea33dbb50edf3aec50c84eee9795339bd9c43a 100644 --- a/en/application-dev/reference/apis/js-apis-formextension.md +++ b/en/application-dev/reference/apis/js-apis-formextension.md @@ -1,12 +1,12 @@ # FormExtension +The **FormExtension** module provides APIs related to Form Extension abilities. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Provides **FormExtension** APIs. - ## Modules to Import ``` @@ -35,15 +35,15 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** - | Name| Type | Mandatory| Description | - | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | - | want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| +| Name| Type | Mandatory| Description | +| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| **Return value** - | Type | Description | - | ------------------------------------------------------------ | ----------------------------------------------------------- | - | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| **Example** @@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------------ | - | formId | string | Yes | ID of the widget that requests to be converted to a normal one.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------ | +| formId | string | Yes | ID of the widget that requests to be converted to a normal one.| **Example** @@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget that requests to be updated.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| formId | string | Yes | ID of the widget that requests to be updated.| **Example** @@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility. **Parameters** - | Name | Type | Mandatory| Description | - | --------- | ------------------------- | ---- | ---------------------------- | - | newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ---------------------------- | +| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| **Example** @@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event. **Parameters** - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ---------------------- | - | formId | string | Yes | ID of the widget that requests the event.| - | message | string | Yes | Event message. | +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ---------------------- | +| formId | string | Yes | ID of the widget that requests the event.| +| message | string | Yes | Event message. | **Example** @@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget to be destroyed.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| formId | string | Yes | ID of the widget to be destroyed.| **Example** @@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| **Example** @@ -225,28 +225,28 @@ Called when the configuration of the environment where the ability is running is } ``` - ## FormExtension.onAcquireFormState +## FormExtension.onAcquireFormState onAcquireFormState?(want: Want): formInfo.FormState; -Called when the widget provider receives the status query result of a specified service widget. By default, the initial state is returned. +Called when the widget provider receives the status query result of a widget. By default, the initial state is returned. **System capability**: SystemCapability.Ability.Form **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.| **Example** ```js - import fromInfo from '@ohos.application.fromInfo' + import formInfo from '@ohos.application.formInfo' class MyFormExtension extends FormExtension { onAcquireFormState(want) { console.log('FormExtension onAcquireFormState, want:' + want); - return fromInfo.FormState.UNKNOWN; + return formInfo.FormState.UNKNOWN; } } ``` diff --git a/en/application-dev/reference/apis/js-apis-formextensioncontext.md b/en/application-dev/reference/apis/js-apis-formextensioncontext.md index 4e877102c65aaf630ee5d5e12eff7d3c9e611b42..f2e1fe143fbac2991698d2dd4244d88b23b0ebd5 100644 --- a/en/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/en/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -1,86 +1,87 @@ # FormExtensionContext -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> The APIs of this module can be used only in the stage model. +The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities. -Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**. +You can use the APIs of this module to start abilities. -## Modules to Import - -```js -import FormExtension from '@ohos.application.FormExtension'; -``` +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the stage model. -## FormExtensionContext.updateForm +## FormExtensionContext.startAbility -updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void +startAbility(want: Want, callback: AsyncCallback<void>): void -Updates a widget. This method uses a callback to return the result. +Starts an ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name | Type | Mandatory| Description | - | --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- | - | formId | string | Yes | ID of the widget that requests to be updated. | - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | - | callback | AsyncCallback\<void> | Yes | Callback used to return the result indicating whether the method is successfully called.| +| 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.| +| callback| AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js - import formBindingData from '@ohos.application.formBindingData' - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2, (data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }); - } - } - - - ``` +```js +var want = { + deviceId: "", + bundleName: "com.example.formstartability", + abilityName: "MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: {} +} +this.context.startAbility(want, function(err) { + console.info(err.code); +}) +``` -## FormExtensionContext.updateForm +## FormExtensionContext.startAbility -updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void> +startAbility(want: Want): Promise<void> -Updates a widget. This method uses a promise to return the result. +Starts an ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name | Type | Mandatory| Description | - | --------------- | ------------------------------------------------------------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget that requests to be updated.| - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | +| 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.| **Return value** - | Type | Description | - | -------------- | --------------------------------- | - | Promise\<void> | Promise returned with the result indicating whether the method is successfully called.| +| Type | Description | +| ------------ | ---------------------------------- | +| Promise\<void> | Promise used to return the result.| **Example** - ```js - import formBindingData from '@ohos.application.formBindingData' - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } - - ``` +```js +var want = { + deviceId: "", + bundleName: "com.example.formstartability", + abilityName: "MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: {} +} +this.context.startAbility(want).then(() => { + console.info("StartAbility Success"); +}).catch((error) => { + console.info("StartAbility failed"); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-formhost.md b/en/application-dev/reference/apis/js-apis-formhost.md index 91ea521d2bcdece8aa8b3f7b4fc7c278db4c2ba1..769b226018f184016164e0866c4020fa5e601c5a 100644 --- a/en/application-dev/reference/apis/js-apis-formhost.md +++ b/en/application-dev/reference/apis/js-apis-formhost.md @@ -1,11 +1,11 @@ # FormHost +The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets, send notifications to widgets, and obtain widget information and status. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -Provides APIs related to the widget host. - ## Modules to Import ``` @@ -24,9 +24,11 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void; Deletes a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -52,9 +54,11 @@ deleteForm(formId: string): Promise<void>; Deletes a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -85,9 +89,11 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void; Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -113,9 +119,11 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback< Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -142,9 +150,11 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>; Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -176,9 +186,11 @@ requestForm(formId: string, callback: AsyncCallback<void>): void; Requests a widget update. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -204,9 +216,11 @@ requestForm(formId: string): Promise<void>; Requests a widget update. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -237,9 +251,11 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void; Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -265,9 +281,11 @@ castTempForm(formId: string): Promise<void>; Converts a temporary widget to a normal one. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -298,9 +316,11 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void Instructs the widget framework to make a widget visible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -326,9 +346,11 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget visible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -359,9 +381,11 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo Instructs the widget framework to make a widget invisible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -387,9 +411,11 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget invisible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -420,9 +446,11 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void& Instructs the widget framework to make a widget updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -448,9 +476,11 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -481,9 +511,11 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void Instructs the widget framework to make a widget not updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget cannot receive updates from the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -509,9 +541,11 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>; Instructs the widget framework to make a widget not updatable. This API uses a promise to return the result. After this API is called, the widget cannot receive updates from the widget provider. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -542,9 +576,9 @@ isSystemReady(callback: AsyncCallback<void>): void; Checks whether the system is ready. This API uses an asynchronous callback to return the result. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -569,9 +603,9 @@ isSystemReady(): Promise<void>; Checks whether the system is ready. This API uses a promise to return the result. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Return value** @@ -596,9 +630,11 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -625,9 +661,11 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; Obtains the widget information provided by all applications on the device. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Return value** @@ -652,9 +690,11 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -682,9 +722,11 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -713,9 +755,11 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI Obtains the widget information provided by a given application on the device. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -746,9 +790,11 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -776,9 +822,11 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>; Deletes invalid widgets from the list. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -809,9 +857,11 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g Obtains the widget state. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -848,6 +898,12 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; Obtains the widget state. This API uses a promise to return the result. +**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type | Mandatory| Description | @@ -860,10 +916,6 @@ Obtains the widget state. This API uses a promise to return the result. | :------------ | :---------------------------------- | | Promise<[FormStateInfo](js-apis-formInfo.md#formstateinfo)> | Promise used to return the widget state.| -**System capability** - -SystemCapability.Ability.Form - **Example** ```js @@ -890,9 +942,9 @@ on(type: "formUninstall", callback: Callback<string>): void; Subscribes to widget uninstall events. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -916,9 +968,9 @@ off(type: "formUninstall", callback?: Callback<string>): void; Unsubscribes from widget uninstall events. -**System capability** +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -942,9 +994,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -971,9 +1025,11 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< Instructs the widgets to make themselves visible. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -1005,9 +1061,11 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM -SystemCapability.Ability.Form +**System capability**: SystemCapability.Ability.Form + +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** @@ -1034,9 +1092,11 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): Instructs the widgets to enable or disable updates. This API uses a promise to return the result. -**System capability** +**Required permissions**: ohos.permission.REQUIRE_FORM + +**System capability**: SystemCapability.Ability.Form -SystemCapability.Ability.Form +**System API**: This is a system API and cannot be called by third-party applications. **Parameters** diff --git a/en/application-dev/reference/apis/js-apis-formprovider.md b/en/application-dev/reference/apis/js-apis-formprovider.md index 0637af7ceb3c1368f242d91d9f4b59566b7f08df..81855948f4994b85d601763ffe5e817a175d3733 100644 --- a/en/application-dev/reference/apis/js-apis-formprovider.md +++ b/en/application-dev/reference/apis/js-apis-formprovider.md @@ -1,6 +1,6 @@ # FormProvider -The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and release a widget release. +The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release. > **NOTE** > @@ -28,11 +28,11 @@ SystemCapability.Ability.Form **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------- | -| formId | string | Yes | ID of a widget. | -| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------- | + | formId | string | Yes | ID of a widget. | + | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -57,16 +57,16 @@ SystemCapability.Ability.Form **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------- | -| formId | string | Yes | ID of a widget. | -| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ------------------------------------- | + | formId | string | Yes | ID of a widget. | + | minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. | **Return value** -| Type | Description | -| ------------- | ---------------------------------- | -| Promise\<void> |Promise used to return the result. | + | Type | Description | + | ------------- | ---------------------------------- | + | Promise\<void> |Promise used to return the result. | **Example** @@ -91,11 +91,11 @@ SystemCapability.Ability.Form **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | -| formId | string | Yes | ID of the widget to update.| -| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | -| callback | AsyncCallback<void> | Yes| Callback used to return the result.| + | Name| Type | Mandatory| Description | + | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | + | formId | string | Yes | ID of the widget to update.| + | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -122,10 +122,10 @@ SystemCapability.Ability.Form **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | -| formId | string | Yes | ID of the widget to update.| -| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | + | Name| Type | Mandatory| Description | + | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | + | formId | string | Yes | ID of the widget to update.| + | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. | **Return value** diff --git a/en/application-dev/reference/apis/js-apis-geolocation.md b/en/application-dev/reference/apis/js-apis-geolocation.md index 01a012065ab52ac2e7a1dc781b608ec865394c31..f15805a326e19b0a579d1da1ae0e44e9937fef6f 100644 --- a/en/application-dev/reference/apis/js-apis-geolocation.md +++ b/en/application-dev/reference/apis/js-apis-geolocation.md @@ -8,8 +8,7 @@ Location services provide basic functions such as GNSS positioning, network posi ## Modules to Import - -``` +```js import geolocation from '@ohos.geolocation'; ``` @@ -23,17 +22,18 @@ Registers a listener for location changes with a location request initiated. **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| | request | LocationRequest | Yes| Location request.| | callback | Callback<[Location](#location)> | Yes| Callback used to return the location change event.| -- Example +**Example** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); @@ -52,16 +52,17 @@ Unregisters the listener for location changes with the corresponding location re **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationChange** indicates a location change event.| | callback | Callback<[Location](#location)> | No| Callback used to return the location change event.| -- Example +**Example** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); @@ -81,18 +82,19 @@ Registers a listener for location service status change events. **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| | callback | Callback<boolean> | Yes| Callback used to return the location service status change event.| -- Example +**Example** - ``` + ```js var locationServiceState = (state) => { - console.log('locationServiceState: ' + state); + console.log('locationServiceState: ' + JSON.stringify(state)); } geolocation.on('locationServiceState', locationServiceState); ``` @@ -108,18 +110,19 @@ Unregisters the listener for location service status change events. **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **locationServiceState** indicates a location service status change event.| | callback | Callback<boolean> | No| Callback used to return the location service status change event.| -- Example +**Example** - ``` + ```js var locationServiceState = (state) => { - console.log('locationServiceState: state: ' + state); + console.log('locationServiceState: state: ' + JSON.stringify(state)); } geolocation.on('locationServiceState', locationServiceState); geolocation.off('locationServiceState', locationServiceState); @@ -136,19 +139,20 @@ Registers a listener for cached GNSS location reports. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| | request | CachedGnssLocationsRequest | Yes| Request for reporting cached GNSS location.| | callback | Callback<boolean> | Yes| Callback used to return cached GNSS locations.| -- Example +**Example** - ``` + ```js var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsReporting: locations: ' + locations); + console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); } var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); @@ -165,18 +169,19 @@ Unregisters the listener for cached GNSS location reports. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **cachedGnssLocationsReporting** indicates reporting of cached GNSS locations.| | callback | Callback<boolean> | No| Callback used to return cached GNSS locations.| -- Example +**Example** - ``` + ```js var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsReporting: locations: ' + locations); + console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); } var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); @@ -194,18 +199,19 @@ Registers a listener for GNSS satellite status change events. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| | callback | Callback<SatelliteStatusInfo> | Yes| Callback used to return GNSS satellite status changes.| -- Example +**Example** - ``` + ```js var gnssStatusCb = (satelliteStatusInfo) => { - console.log('gnssStatusChange: ' + satelliteStatusInfo); + console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); } geolocation.on('gnssStatusChange', gnssStatusCb); ``` @@ -221,17 +227,18 @@ Unregisters the listener for GNSS satellite status change events. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **gnssStatusChange** indicates a GNSS satellite status change.| | callback | Callback<SatelliteStatusInfo> | No| Callback used to return GNSS satellite status changes.| -- Example +**Example** - ``` + ```js var gnssStatusCb = (satelliteStatusInfo) => { - console.log('gnssStatusChange: ' + satelliteStatusInfo); + console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); } geolocation.on('gnssStatusChange', gnssStatusCb); geolocation.off('gnssStatusChange', gnssStatusCb); @@ -248,18 +255,19 @@ Registers a listener for GNSS NMEA message change events. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| | callback | Callback<string> | Yes| Callback used to return GNSS NMEA message changes.| -- Example +**Example** - ``` + ```js var nmeaCb = (str) => { - console.log('nmeaMessageChange: ' + str); + console.log('nmeaMessageChange: ' + JSON.stringify(str)); } geolocation.on('nmeaMessageChange', nmeaCb ); ``` @@ -275,18 +283,19 @@ Unregisters the listener for GNSS NMEA message change events. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **nmeaMessageChange** indicates a GNSS NMEA message change.| | callback | Callback<string> | No| Callback used to return GNSS NMEA message changes.| -- Example +**Example** - ``` + ```js var nmeaCb = (str) => { - console.log('nmeaMessageChange: ' + str); + console.log('nmeaMessageChange: ' + JSON.stringify(str)); } geolocation.on('nmeaMessageChange', nmeaCb); geolocation.off('nmeaMessageChange', nmeaCb); @@ -303,60 +312,38 @@ Registers a listener for status change events of the specified geofence. **System capability**: SystemCapability.Location.Location.Geofence -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| | request | GeofenceRequest | Yes| Geofencing request.| | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.| -- Example +**Example** - ``` - import WantAgent from '@ohos.wantAgent'; - import { OperationType, WantAgentFlags } from '@ohos.wantagent'; - // WantAgent object - var wantAgent; - // getWantAgent callback - function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); - if (err.code == 0) { - wantAgent = data; - } else { - console.info('----getWantAgent failed!----'); - } - } - // WantAgentInfo object - var wantAgentInfo = { + ```js + import geolocation from '@ohos.geolocation'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } } ], - operationType: OperationType.START_ABILITIES, + operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - } - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - geolocation.on('fenceStatusChange', requestInfo, wantAgent); + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; + geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); + }); ``` @@ -370,60 +357,91 @@ Unregisters the listener for status change events of the specified geofence. **System capability**: SystemCapability.Location.Location.Geofence -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value **fenceStatusChange** indicates a geofence status change.| | request | GeofenceRequest | Yes| Geofencing request.| | want | WantAgent | Yes| **WantAgent** used to return geofence (entrance or exit) events.| -- Example +**Example** - ``` - import WantAgent from '@ohos.wantAgent'; - import { OperationType, WantAgentFlags } from '@ohos.wantagent'; - // WantAgent object - var wantAgent; - // getWantAgent callback - function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); - if (err.code == 0) { - wantAgent = data; - } else { - console.info('----getWantAgent failed!----'); - } - } - // WantAgentInfo object - var wantAgentInfo = { + ```js + import geolocation from '@ohos.geolocation'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } } ], - operationType: OperationType.START_ABILITIES, + operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; + geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); + geolocation.off('fenceStatusChange', requestInfo, wantAgentObj); + }); + ``` + + +## geolocation.on('countryCodeChange')<sup>9+</sup> + +on(type: 'countryCodeChange', callback: Callback<CountryCode>) : void; + +Subscribe to country code information reporting events. + +**System capability**: SystemCapability.Location.Location.Core + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is "countrycodechange", which means subscribing to the submission of country code information. | + | callback | Callback<CountryCode> | Yes | Callback is used to receive the country code information report. | + + +**Example** + + ```js + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); } - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - geolocation.on('fenceStatusChange', requestInfo, wantAgent); - geolocation.off('fenceStatusChange', requestInfo, wantAgent); + geolocation.on('countryCodeChange', callback); + ``` + + +## geolocation.off('countryCodeChange')<sup>9+</sup> + +off(type: 'countryCodeChange', callback?: Callback<CountryCode>) : void; + +Unsubscribe from the country code to report events. + +**System capability**: SystemCapability.Location.Location.Core + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is "countrycodechange", which means unsubscribing to the submission of country code information. | + | callback | Callback<CountryCode> | Yes | Callback is used to receive the country code information report. | + + +**Example** + + ```js + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } + geolocation.on('countryCodeChange', callback); + geolocation.off('countryCodeChange', callback); ``` @@ -438,18 +456,24 @@ Obtains the current location. This API uses an asynchronous callback to return t **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.| | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the current location.| -- Example +**Example** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; var locationChange = (err, location) => { - console.log('locationChanger: ' + err + 'data: ' + location); + if (err) { + console.log('locationChanger: err=' + JSON.stringify(err)); + } + if (location) { + console.log('locationChanger: location=' + JSON.stringify(location)); + } }; geolocation.getCurrentLocation(requestInfo, locationChange); geolocation.getCurrentLocation(locationChange); @@ -467,22 +491,24 @@ Obtains the current location. This API uses a promise to return the result. **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | No| Location request.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<[Location](#location)> | Promise used to return the current location.| -- Example +**Example** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; - locationEventListener.getCurrentLocation(requestInfo).then((result) => { + geolocation.getCurrentLocation(requestInfo).then((result) => { console.log('current location: ' + JSON.stringify(result)); }); ``` @@ -498,17 +524,23 @@ Obtains the previous location. This API uses an asynchronous callback to return **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[Location](#location)> | Yes| Callback used to return the previous location.| -- Example +**Example** - ``` + ```js geolocation.getLastLocation((err, data) => { - console.log('getLastLocation: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getLastLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getLastLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -523,15 +555,16 @@ Obtains the previous location. This API uses a promise to return the result. **System capability**: SystemCapability.Location.Location.Core -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<[Location](#location)> | Promise used to return the previous location.| -- Example +**Example** - ``` + ```js geolocation.getLastLocation().then((result) => { console.log('getLastLocation: result: ' + JSON.stringify(result)); }); @@ -549,17 +582,22 @@ Checks whether the location service is enabled. This API uses an asynchronous ca **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.isLocationEnabled((err, data) => { - console.log('isLocationEnabled: ' + err + " data: " + data); + if (err) { + console.log('isLocationEnabled: err=' + JSON.stringify(err)); + } + if (data) { + console.log('isLocationEnabled: data=' + JSON.stringify(data)); + } }); ``` @@ -574,14 +612,15 @@ Checks whether the location service is enabled. This API uses a promise to retur **System capability**: SystemCapability.Location.Location.Core -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| -- Example +**Example** - ``` + ```js geolocation.isLocationEnabled().then((result) => { console.log('promise, isLocationEnabled: ' + result); }); @@ -599,17 +638,22 @@ Requests to enable the location service. This API uses an asynchronous callback **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.requestEnableLocation((err, data) => { - console.log('requestEnableLocation: ' + err + " data: " + data); + if (err) { + console.log('requestEnableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('requestEnableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -624,17 +668,17 @@ Requests to enable the location service. This API uses a promise to return the r **System capability**: SystemCapability.Location.Location.Core -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.requestEnableLocation().then((result) => { - console.log('promise, requestEnableLocation: ' + result); + console.log('promise, requestEnableLocation: ' + JSON.stringify(result)); }); ``` @@ -645,23 +689,28 @@ enableLocation(callback: AsyncCallback<boolean>) : void; Enables the location service. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. -**Permission required**: ohos.permission.LOCATION +**Permission required**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.enableLocation((err, data) => { - console.log('enableLocation: ' + err + " data: " + data); + if (err) { + console.log('enableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('enableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -672,23 +721,23 @@ enableLocation() : Promise<boolean> Enables the location service. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. -**Permission required**: ohos.permission.LOCATION +**Permission required**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Location.Location.Core -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.enableLocation().then((result) => { - console.log('promise, enableLocation: ' + result); + console.log('promise, enableLocation: ' + JSON.stringify(result)); }); ``` @@ -698,23 +747,28 @@ disableLocation(callback: AsyncCallback<boolean>) : void; Disables the location service. This API uses an asynchronous callback to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. -**Permission required**: ohos.permission.LOCATION +**Permission required**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.disableLocation((err, data) => { - console.log('disableLocation: ' + err + " data: " + data); + if (err) { + console.log('disableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('disableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -725,23 +779,23 @@ disableLocation() : Promise<boolean> Disables the location service. This API uses a promise to return the result. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. -**Permission required**: ohos.permission.LOCATION +**Permission required**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Location.Location.Core -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the location service status.| - -- Example +**Example** - ``` + ```js geolocation.disableLocation().then((result) => { - console.log('promise, disableLocation: ' + result); + console.log('promise, disableLocation: ' + JSON.stringify(result)); }); ``` @@ -755,17 +809,22 @@ Checks whether the (reverse) geocoding service is available. This API uses an as **System capability**: SystemCapability.Location.Location.Geocoder -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the (reverse) geocoding service status.| - -- Example +**Example** - ``` + ```js geolocation.isGeoServiceAvailable((err, data) => { - console.log('isGeoServiceAvailable: ' + err + " data: " + data); + if (err) { + console.log('isGeoServiceAvailable: err=' + JSON.stringify(err)); + } + if (data) { + console.log('isGeoServiceAvailable: data=' + JSON.stringify(data)); + } }); ``` @@ -780,22 +839,21 @@ Checks whether the (reverse) geocoding service is available. This API uses a pro **System capability**: SystemCapability.Location.Location.Geocoder -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the (reverse) geocoding service status.| - -- Example +**Example** - ``` + ```js geolocation.isGeoServiceAvailable().then((result) => { - console.log('promise, isGeoServiceAvailable: ' + result); + console.log('promise, isGeoServiceAvailable: ' + JSON.stringify(result)); }); ``` - ## geolocation.getAddressesFromLocation getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void @@ -806,18 +864,24 @@ Converts coordinates into geographic description through reverse geocoding. This **System capability**: SystemCapability.Location.Location.Geocoder -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.| | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to return the reverse geocoding result.| -- Example +**Example** - ``` + ```js var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { - console.log('getAddressesFromLocation: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getAddressesFromLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getAddressesFromLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -832,19 +896,21 @@ Converts coordinates into geographic description through reverse geocoding. This **System capability**: SystemCapability.Location.Location.Geocoder -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | Yes| Reverse geocoding request.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | Promise used to return the reverse geocoding result.| -- Example +**Example** - ``` + ```js var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { console.log('getAddressesFromLocation: ' + JSON.stringify(data)); @@ -862,19 +928,24 @@ Converts geographic description into coordinates through geocoding. This API use **System capability**: SystemCapability.Location.Location.Geocoder -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.| | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | Yes| Callback used to return the geocoding result.| - -- Example +**Example** - ``` + ```js var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { - console.log('getAddressesFromLocationName: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getAddressesFromLocationName: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getAddressesFromLocationName: data=' + JSON.stringify(data)); + } }); ``` @@ -889,19 +960,21 @@ Converts geographic description into coordinates through geocoding. This API use **System capability**: SystemCapability.Location.Location.Geocoder -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | Yes| Geocoding request.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | Callback used to return the geocoding result.| -- Example +**Example** - ``` + ```js var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { console.log('getAddressesFromLocationName: ' + JSON.stringify(result)); @@ -909,7 +982,6 @@ Converts geographic description into coordinates through geocoding. This API use ``` - ## geolocation.getCachedGnssLocationsSize<sup>8+</sup> getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; @@ -920,16 +992,22 @@ Obtains the number of cached GNSS locations. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | Yes| Callback used to return the number of cached GNSS locations. | -- Example +**Example** - ``` + ```js geolocation.getCachedGnssLocationsSize((err, size) => { - console.log('getCachedGnssLocationsSize: err:' + err + " size: " + size); + if (err) { + console.log('getCachedGnssLocationsSize: err=' + JSON.stringify(err)); + } + if (size) { + console.log('getCachedGnssLocationsSize: size=' + JSON.stringify(size)); + } }); ``` @@ -944,16 +1022,17 @@ Obtains the number of cached GNSS locations. **System capability**: SystemCapability.Location.Location.Gnss -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<number> | Promise used to return the number of cached GNSS locations.| -- Example +**Example** - ``` + ```js geolocation.getCachedGnssLocationsSize().then((result) => { - console.log('promise, getCachedGnssLocationsSize: ' + result); + console.log('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result)); }); ``` @@ -968,16 +1047,22 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. **System capability**: SystemCapability.Location.Location.Gnss -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result.| -- Example +**Example** - ``` + ```js geolocation.flushCachedGnssLocations((err, result) => { - console.log('flushCachedGnssLocations: err:' + err + " result: " + result); + if (err) { + console.log('flushCachedGnssLocations: err=' + JSON.stringify(err)); + } + if (result) { + console.log('flushCachedGnssLocations: result=' + JSON.stringify(result)); + } }); ``` @@ -992,16 +1077,17 @@ Obtains all cached GNSS locations and clears the GNSS cache queue. **System capability**: SystemCapability.Location.Location.Gnss -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Promise used to return the operation result.| -- Example +**Example** - ``` + ```js geolocation.flushCachedGnssLocations().then((result) => { - console.log('promise, flushCachedGnssLocations: ' + result); + console.log('promise, flushCachedGnssLocations: ' + JSON.stringify(result)); }); ``` @@ -1016,18 +1102,24 @@ Sends an extended command to the location subsystem. This API can only be called **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | command | LocationCommand | Yes| Extended command (string) to be sent.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result.| -- Example +**Example** - ``` + ```js var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo, (err, result) => { - console.log('sendCommand: err:' + err + " result: " + result); + if (err) { + console.log('sendCommand: err=' + JSON.stringify(err)); + } + if (result) { + console.log('sendCommand: result=' + JSON.stringify(result)); + } }); ``` @@ -1042,22 +1134,24 @@ Sends an extended command to the location subsystem. This API can only be called **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | command | LocationCommand | Yes| Extended command (string) to be sent.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the operation result.| -- Example +**Example** - ``` + ```js var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo).then((result) => { - console.log('promise, sendCommand: ' + result); + console.log('promise, sendCommand: ' + JSON.stringify(result)); }); ``` @@ -1068,23 +1162,29 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&l Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. **Permission required**: ohos.permission.LOCATION **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| -- Example +**Example** - ``` + ```js geolocation.isLocationPrivacyConfirmed(1, (err, result) => { - console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); + if (err) { + console.log('isLocationPrivacyConfirmed: err=' + JSON.stringify(err)); + } + if (result) { + console.log('isLocationPrivacyConfirmed: result=' + JSON.stringify(result)); + } }); ``` @@ -1095,27 +1195,29 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean> Checks whether a user agrees with the privacy statement of the location service. This API can only be called by system applications. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. **Permission required**: ohos.permission.LOCATION **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the result, which indicates whether the user agrees with the privacy statement.| -- Example +**Example** - ``` + ```js geolocation.isLocationPrivacyConfirmed(1).then((result) => { - console.log('promise, isLocationPrivacyConfirmed: ' + result); + console.log('promise, isLocationPrivacyConfirmed: ' + JSON.stringify(result)); }); ``` @@ -1126,24 +1228,30 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. **Permission required**: ohos.permission.LOCATION **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| | callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result.| -- Example +**Example** - ``` + ```js geolocation.setLocationPrivacyConfirmStatus(1, true, (err, result) => { - console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); + if (err) { + console.log('setLocationPrivacyConfirmStatus: err=' + JSON.stringify(err)); + } + if (result) { + console.log('setLocationPrivacyConfirmStatus: result=' + JSON.stringify(result)); + } }); ``` @@ -1154,32 +1262,540 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea Sets the user confirmation status for the privacy statement of the location service. This API can only be called by system applications. -This is a system API and cannot be called by third-party applications. +**System API**: This is a system API and cannot be called by third-party applications. **Permission required**: ohos.permission.LOCATION **System capability**: SystemCapability.Location.Location.Core -- Parameters - | Name| Type| Mandatory| Description| +**Parameters** + + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | Yes| Privacy statement type, for example, privacy statement displayed in the startup wizard or privacy statement displayed when enabling the location service.| | isConfirmed | boolean | Yes| Callback used to return the result, which indicates whether the user agrees with the privacy statement.| -- Return value - | Name| Description| +**Return value** + + | Name| Description| | -------- | -------- | | Promise<boolean> | Callback used to return the operation result.| -- Example +**Example** - ``` + ```js geolocation.setLocationPrivacyConfirmStatus(1, true).then((result) => { - console.log('promise, setLocationPrivacyConfirmStatus: ' + result); + console.log('promise, setLocationPrivacyConfirmStatus: ' + JSON.stringify(result)); + }); + ``` + + +## geolocation.getCountryCode<sup>9+</sup> + +getCountryCode(callback: AsyncCallback<CountryCode>) : void; + +Query the current country code. + +**System capability**: SystemCapability.Location.Location.Core + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<CountryCode> | Yes | Callback is used to receive the country code. | + +**Example**: + + ```js + geolocation.getCountryCode((err, result) => { + if (err) { + console.log('getCountryCode: err=' + JSON.stringify(err)); + } + if (result) { + console.log('getCountryCode: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.getCountryCode<sup>9+</sup> + +getCountryCode() : Promise<CountryCode>; + +Query the current country code. + +**System capability**: SystemCapability.Location.Location.Core + +**Parameters** + +None + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<CountryCode> | return country code. | + +**Example**: + + ```js + geolocation.getCountryCode() + .then((result) => { + console.log('promise, getCountryCode: result=' + JSON.stringify(result)); + }) + .catch((error) => { + console.log('promise, getCountryCode: error=' + JSON.stringify(error)); + }); + ``` + + +## geolocation.enableLocationMock<sup>9+</sup> + +enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback<void>) : void; + +Enable the position simulation function of a scene, and only one scene can be enabled at the same time. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | No | Indicates under what scenario the position simulation function is enabled. | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var request = {"scenario": 0x0301}; + geolocation.enableLocationMock(request, (err, result) => { + if (err) { + console.log('enableLocationMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('enableLocationMock: result=' + JSON.stringify(result)); + } + }); + ``` + +## geolocation.enableLocationMock<sup>9+</sup> + +enableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; + +Enable the position simulation function of a scene, and only one scene can be enabled at the same time. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | No | Indicates which scene's position simulation function is enabled. If this parameter is not carried, it means that the position simulation function of all scenes is enabled. | + + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var request = {"scenario": 0x0301}; + geolocation.enableLocationMock(request) + .then((result) => { + if (result) { + console.log('promise, enableLocationMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, enableLocationMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.disableLocationMock<sup>9+</sup> + +disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback<void>) : void; + +To disable the position simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | No | Indicates to disable the position simulation function of a scene. If this parameter is not carried, it means to disable the position simulation function of all scenes. | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var request = {"scenario": 0x0301}; + geolocation.disableLocationMock(request, (err, result) => { + if (err) { + console.log('disableLocationMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('disableLocationMock: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.disableLocationMock<sup>9+</sup> + +disableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; + +To disable the position simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | No | Indicates to disable the position simulation function of a scene. If this parameter is not carried, it means to disable the position simulation function of all scenes. | + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr, otherwise it will return an error message | + +**Example**: + + ```js + var request = {"scenario": 0x0301}; + geolocation.disableLocationMock(request) + .then((result) => { + if (result) { + console.log('promise, disableLocationMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, disableLocationMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.setMockedLocations<sup>9+</sup> + +setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void>) : void; + +Set the simulated location information, and then report the simulated location at the time interval carried in the interface. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | LocationMockConfig | Yes | Indicates the configuration parameters of location simulation, including the time interval of simulation location reporting and the array of simulation locations. | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations": locations}; + geolocation.setMockedLocations(config, (err, data) => { + if (err) { + console.log('setMockedLocations: err=' + JSON.stringify(err)); + } + if (data) { + console.log('setMockedLocations: data=' + JSON.stringify(data)); + } + }); + ``` + +## geolocation.setMockedLocations<sup>9+</sup> + +setMockedLocations(config: LocationMockConfig) : Promise<void>; + +Set the simulated location information, and then report the simulated location at the time interval carried in the interface. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | LocationMockConfig | Yes | Indicates the configuration parameters of location simulation, including the time interval of simulation location reporting and the array of simulation locations. | + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations":locations}; + geolocation.setMockedLocations(config) + .then((result) => { + if (result) { + console.log('promise, setMockedLocations: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, setMockedLocations: error=' + JSON.stringify(error)); + } + }); + ``` + + + +## geolocation.enableReverseGeocodingMock<sup>9+</sup> + +enableReverseGeocodingMock(callback: AsyncCallback<void>) : void; + +Enable reverse geocoding simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + geolocation.enableReverseGeocodingMock((err, data) => { + if (err) { + console.log('enableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + if (data) { + console.log('enableReverseGeocodingMock: data=' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.enableReverseGeocodingMock<sup>9+</sup> + +enableReverseGeocodingMock() : Promise<void>; + +Enable reverse geocoding simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters**: + +None + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + geolocation.enableReverseGeocodingMock() + .then((result) => { + if (result) { + console.log('promise, enableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, enableReverseGeocodingMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.disableReverseGeocodingMock<sup>9+</sup> + +disableReverseGeocodingMock(callback: AsyncCallback<void>) : void; + +Disable reverse geocoding simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters**: + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message | + +**Example**: + + ```js + geolocation.disableReverseGeocodingMock((err, result) => { + if (err) { + console.log('disableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('disableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.disableReverseGeocodingMock<sup>9+</sup> + +disableReverseGeocodingMock() : Promise<void>; + +Disable reverse geocoding simulation function. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters**: + +None + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + geolocation.disableReverseGeocodingMock() + .then((result) => { + if (result) { + console.log('promise, disableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, disableReverseGeocodingMock: error=' + JSON.stringify(error)); + } }); ``` +## geolocation.setReverseGeocodingMockInfo<sup>9+</sup> + +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, callback: AsyncCallback<void>) : void; + +Set the configuration information of the reverse geocoding simulation function, including the corresponding relationship between location and place name. If the location information is in the configuration information during the subsequent reverse geocoding query, the corresponding place name will be returned. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | mockInfos | Array<ReverseGeocodingMockInfo> | Yes | An array of configuration parameters indicating the inverse geocoding simulation function. The configuration parameters of the inverse geocoding simulation function include a location and a place name. | + | callback | AsyncCallback<void> | Yes | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geolocation.setReverseGeocodingMockInfo(mockInfos, (err, data) => { + if (err) { + console.log('promise, setReverseGeocodingMockInfo, err:' + JSON.stringify(err)); + } + if (data) { + console.log('promise, setReverseGeocodingMockInfo, data:' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.setReverseGeocodingMockInfo<sup>9+</sup> + +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>) : Promise<void>; + +Set the configuration information of the reverse geocoding simulation function, including the corresponding relationship between location and place name. If the location information is in the configuration information during the subsequent reverse geocoding query, the corresponding place name will be returned. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | mockInfos | Array<ReverseGeocodingMockInfo> | Yes | An array of configuration parameters indicating the inverse geocoding simulation function. The configuration parameters of the inverse geocoding simulation function include a location and a place name. | + +**Return value** + + | Name| Description| + | -------- | -------- | + | Promise<void> | It is used to receive the execution result. If the execution is successful, it will return nullptr. Otherwise, it will return an error message. | + +**Example**: + + ```js + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geolocation.setReverseGeocodingMockInfo(mockInfos) + .then((result) => { + if (result) { + console.log('promise, setReverseGeocodingMockInfo: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, setReverseGeocodingMockInfo: error=' + JSON.stringify(error)); + } + }); + ``` + ## LocationRequestPriority @@ -1225,13 +1841,15 @@ Enumerates error codes of the location service. | Name| Default Value| Description| | -------- | -------- | -------- | -| INPUT_PARAMS_ERROR | 101 | Incorrect input parameters.| -| REVERSE_GEOCODE_ERROR | 102 | Failed to call the reverse geocoding API.| -| GEOCODE_ERROR | 103 | Failed to call the geocoding API.| -| LOCATOR_ERROR | 104 | Failed to obtain the location.| -| LOCATION_SWITCH_ERROR | 105 | Failed to change the location service switch.| -| LAST_KNOWN_LOCATION_ERROR | 106 | Failed to obtain the previous location.| -| LOCATION_REQUEST_TIMEOUT_ERROR | 107 | Failed to obtain the location within the specified time.| +| NOT_SUPPORTED<sup>9+</sup> | 100 | Indicates that the interface function is not supported. | +| INPUT_PARAMS_ERROR<sup>7+</sup> | 101 | Incorrect input parameters.| +| REVERSE_GEOCODE_ERROR<sup>7+</sup> | 102 | Failed to call the reverse geocoding API.| +| GEOCODE_ERROR<sup>7+</sup> | 103 | Failed to call the geocoding API.| +| LOCATOR_ERROR<sup>7+</sup> | 104 | Failed to obtain the location.| +| LOCATION_SWITCH_ERROR<sup>7+</sup> | 105 | Failed to change the location service switch.| +| LAST_KNOWN_LOCATION_ERROR<sup>7+</sup> | 106 | Failed to obtain the previous location.| +| LOCATION_REQUEST_TIMEOUT_ERROR<sup>7+</sup> | 107 | Failed to obtain the location within the specified time.| +| QUERY_COUNTRY_CODE_ERROR<sup>9+</sup> | 108 | Indicates that the country code query failed. | ## ReverseGeoCodeRequest @@ -1279,24 +1897,25 @@ Defines a geographic location. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| latitude | number | No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.| -| longitude | number | No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .| -| locale | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| -| placeName | string | No| Landmark of the location.| -| countryCode | string | No| Country code.| -| countryName | string | No| Country name.| -| administrativeArea | string | No| Administrative region name.| -| subAdministrativeArea | string | No| Sub-administrative region name.| -| locality | string | No| Locality information. | -| subLocality | string | No| Sub-locality information. | -| roadName | string | No| Road name.| -| subRoadName | string | No| Auxiliary road information.| -| premises | string | No| House information.| -| postalCode | string | No| Postal code.| -| phoneNumber | string | No| Phone number.| -| addressUrl | string | No| Website URL.| -| descriptions | Array<string> | No| Additional description.| -| descriptionsSize | number | No| Total number of additional descriptions.| +| latitude<sup>7+</sup> | number | No| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.| +| longitude<sup>7+</sup> | number | No| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .| +| locale<sup>7+</sup> | string | No| Language used for the location description. **zh** indicates Chinese, and **en** indicates English.| +| placeName<sup>7+</sup> | string | No| Landmark of the location.| +| countryCode<sup>7+</sup> | string | No| Country code.| +| countryName<sup>7+</sup> | string | No| Country name.| +| administrativeArea<sup>7+</sup> | string | No| Administrative region name.| +| subAdministrativeArea<sup>7+</sup> | string | No| Sub-administrative region name.| +| locality<sup>7+</sup> | string | No| Locality information. | +| subLocality<sup>7+</sup> | string | No| Sub-locality information. | +| roadName<sup>7+</sup> | string | No| Road name.| +| subRoadName<sup>7+</sup> | string | No| Auxiliary road information.| +| premises<sup>7+</sup> | string | No| House information.| +| postalCode<sup>7+</sup> | string | No| Postal code.| +| phoneNumber<sup>7+</sup> | string | No| Phone number.| +| addressUrl<sup>7+</sup> | string | No| Website URL.| +| descriptions<sup>7+</sup> | Array<string> | No| Additional description.| +| descriptionsSize<sup>7+</sup> | number | No| Total number of additional descriptions.| +| isFromMock<sup>9+</sup> | Boolean | No | Indicates whether the geographical name information comes from the reverse geocoding simulation function. | ## LocationRequest @@ -1434,13 +2053,68 @@ Defines a location. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| latitude | number | Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.| -| longitude | number | Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .| -| altitude | number | Yes| Location altitude, in meters.| -| accuracy | number | Yes| Location accuracy, in meters.| -| speed | number | Yes| Speed, in m/s.| -| timeStamp | number | Yes| Location timestamp in the UTC format.| -| direction | number | Yes| Direction information.| -| timeSinceBoot | number | Yes| Location timestamp since boot.| -| additions | Array<string> | No| Additional information.| -| additionSize | number | No| Number of additional descriptions.| +| latitude<sup>7+</sup> | number | Yes| Latitude information. A positive value indicates north latitude, and a negative value indicates south latitude.| +| longitude<sup>7+</sup> | number | Yes| Longitude information. A positive value indicates east longitude , and a negative value indicates west longitude .| +| altitude<sup>7+</sup> | number | Yes| Location altitude, in meters.| +| accuracy<sup>7+</sup> | number | Yes| Location accuracy, in meters.| +| speed<sup>7+</sup> | number | Yes| Speed, in m/s.| +| timeStamp<sup>7+</sup> | number | Yes| Location timestamp in the UTC format.| +| direction<sup>7+</sup> | number | Yes| Direction information.| +| timeSinceBoot<sup>7+</sup> | number | Yes| Location timestamp since boot.| +| additions<sup>7+</sup> | Array<string> | No| Additional information.| +| additionSize<sup>7+</sup> | number | No| Number of additional descriptions.| +| isFromMock<sup>9+</sup> | Boolean | No | Indicates whether the location information comes from the location simulation function. | + + +## ReverseGeocodingMockInfo<sup>9+</sup> + +The configuration information of the reverse geocoding simulation function includes a location information and a place name information. + +**System capability**:SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| location | ReverseGeoCodeRequest | Yes | Indicates longitude and latitude information. | +| geoAddress | GeoAddress | Yes | Represents a geographic location. | + + +## LocationMockConfig<sup>9+</sup> + +The configuration parameters of the location simulation function include the time interval of the simulation position report and the array of simulation locations. + +**System capability**: SystemCapability.Location.Location.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| timeInterval | number | Yes | Indicates the time interval of analog location reporting, in seconds. | +| locations | Array<Location> | Yes | Represents an array of mocked locations. | + + +## CountryCode<sup>9+</sup> + +The country code information structure contains the country code string and the source information of the country code. + +**System capability**: SystemCapability.Location.Location.Core + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| country | string | Yes | Represents the country code string. | +| type | CountryCodeType | Yes | Indicates the source of country code information. | + + +## CountryCodeType<sup>9+</sup> + +Country code source type. + +**System capability**: SystemCapability.Location.Location.Core + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| COUNTRY_CODE_FROM_LOCALE | 1 | The country code obtained from the language configuration information of the globalization module. | +| COUNTRY_CODE_FROM_SIM | 2 | The country code obtained from the SIM card. | +| COUNTRY_CODE_FROM_LOCATION | 3 | Based on the user's location information, the country code is queried through reverse geocoding. | +| COUNTRY_CODE_FROM_NETWORK | 4 | The country code obtained from the cellular network registration information. | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-http.md b/en/application-dev/reference/apis/js-apis-http.md index f1ef654168a4696ee3f0e54e361a5e81ac7dc6a9..9e0e0bf5160d01596d0c6e0969c3cc783712f45a 100644 --- a/en/application-dev/reference/apis/js-apis-http.md +++ b/en/application-dev/reference/apis/js-apis-http.md @@ -1,6 +1,8 @@ # Data Request -> **NOTE** +This module provides the HTTP data request capability. An application can initiate a data request over HTTP. Common HTTP methods include **GET**, **POST**, **OPTIONS**, **HEAD**, **PUT**, **DELETE**, **TRACE**, and **CONNECT**. + +>**NOTE** > >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. > @@ -18,17 +20,17 @@ import http from '@ohos.net.http'; // Each HttpRequest corresponds to an HttpRequestTask object and cannot be reused. let httpRequest = http.createHttp(); -// Subscribe to the HTTP response header, which is returned earlier than HttpRequest. You can subscribe to HTTP Response Header events based on service requirements. -// on('headerReceive', AsyncCallback) will be replaced by on('headersReceive', Callback) in API version 8. 8+ +// Subscribe to the HTTP response header, which is returned earlier than httpRequest. Whether to subscribe to the HTTP response header is up to your decision. +// on('headerReceive', AsyncCallback) is replaced by on('headersReceive', Callback) since API version 8. httpRequest.on('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); httpRequest.request( - // Set the URL of the HTTP request. You need to define the URL. Set the parameters of the request in extraData. + // Customize EXAMPLE_URL on your own. It is up to you whether to add parameters to the URL. "EXAMPLE_URL", { method: http.RequestMethod.POST, // Optional. The default value is http.RequestMethod.GET. - // You can add the header field based on service requirements. + // You can add header fields based on service requirements. header: { 'Content-Type': 'application/json' }, @@ -48,7 +50,7 @@ httpRequest.request( console.info('cookies:' + data.cookies); // 8+ } else { console.info('error:' + JSON.stringify(err)); - // Call the destroy() method to release resources after the call is complete. + // Call the destroy() method to release resources after HttpRequest is complete. httpRequest.destroy(); } } @@ -79,7 +81,7 @@ let httpRequest = http.createHttp(); ## HttpRequest -Defines an **HttpRequest** object. Before invoking HttpRequest APIs, you must call [createHttp\(\)](#httpcreatehttp) to create an **HttpRequestTask** object. +HTTP request task. Before invoking APIs provided by **HttpRequest**, you must call [createHttp\(\)](#httpcreatehttp) to create an **HttpRequestTask** object. ### request @@ -93,9 +95,9 @@ Initiates an HTTP request to a given URL. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------- | ---- | ----------------------- | -| url | string | Yes | URL for initiating an HTTP request.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------- | ---- | ----------------------- | +| url | string | Yes | URL for initiating an HTTP request.| | callback | AsyncCallback\<[HttpResponse](#httpresponse)\> | Yes | Callback used to return the result. | **Example** @@ -169,15 +171,15 @@ Initiates an HTTP request to a given URL. This API uses a promise to return the **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------------------ | ---- | -------------------------------------------------- | -| url | string | Yes | URL for initiating an HTTP request. | +| Name | Type | Mandatory| Description | +| ------- | ------------------ | ---- | ----------------------------------------------- | +| url | string | Yes | URL for initiating an HTTP request. | | options | HttpRequestOptions | Yes | Request options. For details, see [HttpRequestOptions](#httprequestoptions).| **Return value** -| Type | Description | -| :-------------------- | :-------------------------------- | +| Type | Description | +| :------------------------------------- | :-------------------------------- | | Promise<[HttpResponse](#httpresponse)> | Promise used to return the result.| @@ -225,8 +227,7 @@ on\(type: 'headerReceive', callback: AsyncCallback<Object\>\): void Registers an observer for HTTP Response Header events. > **NOTE** -> -> This API has been deprecated. You are advised to use [on\('headersReceive'\)<sup>8+</sup>](#onheadersreceive8) instead. +>This API has been deprecated. You are advised to use [on\('headersReceive'\)<sup>8+</sup>](#onheadersreceive8) instead. **System capability**: SystemCapability.Communication.NetStack @@ -308,7 +309,6 @@ off\(type: 'headersReceive', callback?: Callback<Object\>\): void Unregisters the observer for HTTP Response Header events. > **NOTE** -> >You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. **System capability**: SystemCapability.Communication.NetStack @@ -355,13 +355,13 @@ Specifies the type and value range of the optional parameters in the HTTP reques **System capability**: SystemCapability.Communication.NetStack -| Name | Type | Mandatory| Description | -| -------------- | ------------------------------------ | ---- | ---------------------------------------------------------- | -| method | [RequestMethod](#requestmethod) | No | Request method. | +| Name | Type | Mandatory| Description | +| -------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| method | [RequestMethod](#requestmethod) | No | Request method. | | extraData | string \| Object \| ArrayBuffer<sup>8+</sup> | No | Additional data of the request.<br>- If the HTTP request uses a POST or PUT method, this parameter serves as the content of the HTTP request.<br>- If the HTTP request uses a GET, OPTIONS, DELETE, TRACE, or CONNECT method, this parameter is a supplement to the HTTP request parameters and will be added to the URL when the request is sent.<sup>8+</sup><br>- To pass in a string object, you first need to encode the object on your own.<sup>8+</sup> | -| header | Object | No | HTTP request header. The default value is {'Content-Type': 'application/json'}.| -| readTimeout | number | No | Read timeout duration. The default value is **60000**, in ms. | -| connectTimeout | number | No | Connection timeout interval. The default value is **60000**, in ms. | +| header | Object | No | HTTP request header. The default value is **{'Content-Type': 'application/json'}**. | +| readTimeout | number | No | Read timeout duration. The default value is **60000**, in ms. | +| connectTimeout | number | No | Connection timeout interval. The default value is **60000**, in ms. | ## RequestMethod @@ -388,13 +388,13 @@ Enumerates the response codes for an HTTP request. | Name | Value | Description | | ----------------- | ---- | ------------------------------------------------------------ | -| OK | 200 | "OK." The request has been processed successfully. This return code is generally used for GET and POST requests. | +| OK | 200 | Request succeeded. The request has been processed successfully. This return code is generally used for GET and POST requests. | | CREATED | 201 | "Created." The request has been successfully sent and a new resource is created. | -| ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | +| ACCEPTED | 202 | "Accepted." The request has been accepted, but the processing has not been completed. | | NOT_AUTHORITATIVE | 203 | "Non-Authoritative Information." The request is successful. | | NO_CONTENT | 204 | "No Content." The server has successfully fulfilled the request but there is no additional content to send in the response payload body. | | RESET | 205 | "Reset Content." The server has successfully fulfilled the request and desires that the user agent reset the content. | -| PARTIAL | 206 | "Partial Content." The server has successfully fulfilled the partial GET request for a given resource. | +| PARTIAL | 206 | "Partial Content." The server has successfully fulfilled the partial GET request for a given resource. | | MULT_CHOICE | 300 | "Multiple Choices." The requested resource corresponds to any one of a set of representations. | | MOVED_PERM | 301 | "Moved Permanently." The requested resource has been assigned a new permanent URI and any future references to this resource will be redirected to this URI.| | MOVED_TEMP | 302 | "Moved Temporarily." The requested resource is moved temporarily to a different URI. | @@ -418,7 +418,7 @@ Enumerates the response codes for an HTTP request. | REQ_TOO_LONG | 414 | "Request-URI Too Long." The Request-URI is too long for the server to process. | | UNSUPPORTED_TYPE | 415 | "Unsupported Media Type." The server is unable to process the media format in the request. | | INTERNAL_ERROR | 500 | "Internal Server Error." The server encounters an unexpected error that prevents it from fulfilling the request. | -| NOT_IMPLEMENTED | 501 | "Not Implemented." The server does not support the function required to fulfill the request. | +| NOT_IMPLEMENTED | 501 | "Not Implemented." The server does not support the function required to fulfill the request. | | BAD_GATEWAY | 502 | "Bad Gateway." The server acting as a gateway or proxy receives an invalid response from the upstream server.| | UNAVAILABLE | 503 | "Service Unavailable." The server is currently unable to process the request due to a temporary overload or system maintenance. | | GATEWAY_TIMEOUT | 504 | "Gateway Timeout." The server acting as a gateway or proxy does not receive requests from the remote server within the timeout period. | @@ -433,6 +433,17 @@ Defines the response to an HTTP request. | Name | Type | Mandatory| Description | | -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | | result | string \| Object \| ArrayBuffer<sup>8+</sup> | Yes | Response content returned based on **Content-type** in the response header:<br>- application/json: a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content.<br>- application/octet-stream: ArrayBuffer<br>- Others: string| -| responseCode | [ResponseCode](#responsecode) \| number | Yes | Result code for an HTTP request. If the callback function is successfully executed, a result code defined in [ResponseCode](#responsecode) will be returned. Otherwise, an error code will be returned in the **err** field in **AsyncCallback**. The error code can be one of the following:<br>- 200: common error<br>- 202: parameter error<br>- 300: I/O error| +| responseCode | [ResponseCode](#responsecode) \| number | Yes | Result code for an HTTP request. If the callback function is successfully executed, a result code defined in [ResponseCode](#responsecode) will be returned. Otherwise, an error code will be returned in the **err** field in **AsyncCallback**. For details, see [Error Codes](#error-codes).| | header | Object | Yes | Response header. The return value is a string in JSON format. If you want to use specific content in the response, you need to implement parsing of that content. Common fields and parsing methods are as follows:<br>- Content-Type: header['Content-Type'];<br>- Status-Line: header['Status-Line'];<br>- Date: header.Date/header['Date'];<br>- Server: header.Server/header['Server'];| | cookies<sup>8+</sup> | Array\<string\> | Yes | Cookies returned by the server. | + +## Error Codes + +| Error Code| Description | +| ------ | ------------------------------------------------------------ | +| -1 | Incorrect parameters. | +| 3 | Incorrect URL format. | +| 4 | Built-in request function, protocol, or option not found during build. | +| 5 | Unable to resolve the proxy. | +| 6 | Unable to resolve the host. | +| 7 | Unable to connect to the proxy or host. | diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index 5c45f18dc00dba05a5615311c968f342cd6684d3..0abc724302fcf89b86421b90c0bb507f1894b312 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -117,12 +117,12 @@ setSystemLanguage(language: string): boolean Sets the system language. +This is a system API. + **Permission required**: ohos.permission.UPDATE_CONFIGURATION **System capability**: SystemCapability.Global.I18n -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name | Type | Description | | -------- | ------ | ----- | @@ -211,12 +211,12 @@ setSystemRegion(region: string): boolean Sets the system region. +This is a system API. + **Permission required**: ohos.permission.UPDATE_CONFIGURATION **System capability**: SystemCapability.Global.I18n -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name | Type | Description | | ------ | ------ | ----- | @@ -258,12 +258,12 @@ setSystemLocale(locale: string): boolean Sets the system locale. +This is a system API. + **Permission required**: ohos.permission.UPDATE_CONFIGURATION **System capability**: SystemCapability.Global.I18n -**System API**: This is a system API and cannot be called by third-party applications. - **Parameters** | Name | Type | Description | | ------ | ------ | --------------- | @@ -673,6 +673,32 @@ Formats a phone number. phonenumberfmt.format("15812312312"); ``` +### getLocationName<sup>8+</sup> + +static getLocationName(number: string, locale: string): string + +Obtains the home location of a phone number. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ---------- | +| number | string | Yes | Phone number.| +| locale | string | Yes | Locale ID.| + +**Return value** +| Type | Description | +| ------ | ---------- | +| string | Home location of the phone number.| + +**Example** + ``` + var location = i18n.PhoneNumberFormat.getLocationName('15812312345', 'zh-CN'); + ``` + + + ## PhoneNumberFormatOptions<sup>8+</sup> @@ -1548,3 +1574,135 @@ Obtains the offset between the time zone represented by a **TimeZone** object an var timezone = i18n.getTimeZone(); timezone.getOffset(1234567890); ``` + +### getAvailableIDs<sup>9+</sup> + +static getAvailableIDs(): Array<string> + +Obtains the list of time zone IDs supported by the system. + +**System capability**: SystemCapability.Global.I18n + +**Return value** +| Type | Description | +| ------ | ----------------------- | +| Array<string> | List of time zone IDs supported by the system.| + +**Example** + ``` + var ids = i18n.TimeZone.getAvailableIDs(); + ``` + + +### getAvailableZoneCityIDs<sup>9+</sup> + +static getAvailableZoneCityIDs(): Array<string> + +Obtains the list of time zone city IDs supported by the system. + +**System capability**: SystemCapability.Global.I18n + +**Return value** +| Type | Description | +| ------ | ----------------------- | +| Array<string> | List of time zone city IDs supported by the system.| + +**Example** + ``` + var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs(); + ``` + + +### getCityDisplayName<sup>9+</sup> + +static getCityDisplayName(cityID: string, locale: string): string + +Obtains the localized display of a time zone city in the specified locale. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ----- | +| cityID | string | Yes | Time zone city ID.| +| locale | string | Yes | Locale ID.| + +**Return value** +| Type | Description | +| ------ | ----------------------- | +| string | Localized display of the time zone city in the specified locale.| + +**Example** + ``` + var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); + ``` + + +### getTimezoneFromCity<sup>9+</sup> + +static getTimezoneFromCity(cityID: string): TimeZone + +Obtains the **TimeZone** object corresponding to the specified time zone city ID. + +**System capability**: SystemCapability.Global.I18n + +**Parameters** +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ----- | +| cityID | string | Yes | Time zone city ID.| + +**Return value** +| Type | Description | +| ------ | ----------------------- | +| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.| + +**Example** + ``` + var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai"); + ``` + + +## i18n.setUsingLocalDigit<sup>9+</sup> + +setUsingLocalDigit(flag: boolean): boolean + +Sets whether to turn on the local digit switch. +This is a system API. + +**Permission required**: ohos.permission.UPDATE_CONFIGURATION + +**System capability**: SystemCapability.Global.I18n + +**Parameters** +| Name | Type | Mandatory | Description | +| ------ | ------ | ---- | ----- | +| flag | boolean | Yes | Whether to turn on the local digit switch. The value **true** means to turn on the local digit switch, and the value **false** indicates the opposite.| + +**Return value** +| Type | Description | +| -------- | ------------ | +| boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.| + +**Example** + ``` + var status = i18n.setUsingLocalDigit(true); + ``` + + +## i18n.getUsingLocalDigit<sup>9+</sup> + +getUsingLocalDigit(): boolean + +Checks whether the local digit switch is turned on. + +**System capability**: SystemCapability.Global.I18n + +**Return value** +| Type | Description | +| -------- | ------------ | +| boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.| + +**Example** + ``` + var status = i18n.getUsingLocalDigit(); + ``` diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 85ff0550112bbfc81e22925c3a69ca7ac813cfab..13701cecf67e947c876789d0f1f4acde7f62a601 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -1,5 +1,7 @@ # Image Processing +The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read image pixel data (even in an area). + > **NOTE** > > 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. @@ -11,11 +13,12 @@ import image from '@ohos.multimedia.image'; ``` ## image.createPixelMap<sup>8+</sup> + createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<PixelMap> Creates a **PixelMap** object. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -34,7 +37,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result. ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts) .then((pixelmap) => { @@ -47,7 +50,7 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As Creates a **PixelMap** object. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -61,10 +64,15 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } -image.createPixelMap(color, opts, (pixelmap) => { - }) +image.createPixelMap(color, opts, (error, pixelmap) => { + if(error) { + console.log('Failed to create pixelmap.'); + } else { + console.log('Succeeded in creating pixelmap.'); + } +}) ``` ## PixelMap<sup>7+</sup> @@ -73,11 +81,11 @@ Provides APIs to read or write image pixel map data and obtain image pixel map i ### Attributes -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core -| Name | Type | Readable| Writable| Description | -| ----------------------- | ------- | ---- | ---- | -------------------------- | -| isEditable<sup>7+</sup> | boolean | Yes | No | Whether the image pixel map is editable.| +| Name | Type | Readable| Writable| Description | +| ---------- | ------- | ---- | ---- | -------------------------- | +| isEditable | boolean | Yes | No | Whether the image pixel map is editable.| ### readPixelsToBuffer<sup>7+</sup> @@ -85,24 +93,24 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void> Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ----------- | ---- | ------------------------------------------------------------ | -| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written.| +| Name| Type | Mandatory| Description | +| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- | +| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.| **Return value** | Type | Description | -| :------------- | :---------------------------------------------- | -| Promise\<void> | Promise used to return the operation result. If the operation fails, an error message is returned.| +| -------------- | ----------------------------------------------- | +| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| **Example** ```js -const readBuffer = new ArrayBuffer(400); +const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer).then(() => { console.log('Succeeded in reading image pixel data.'); // Called if the condition is met. }).catch(error => { @@ -116,19 +124,19 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ------------------------------------------------------------ | -| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written.| -| callback | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- | +| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. | **Example** ```js -const readBuffer = new ArrayBuffer(400); +const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer, (err, res) => { if(err) { console.log('Failed to read image pixel data.'); // Called if no condition is met. @@ -144,7 +152,7 @@ readPixels(area: PositionArea): Promise\<void> Reads image pixel map data in an area. This API uses a promise to return the data read. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -156,7 +164,7 @@ Reads image pixel map data in an area. This API uses a promise to return the dat | Type | Description | | :------------- | :-------------------------------------------------- | -| Promise\<void> | Promise used to return the operation result. If the operation fails, an error message is returned.| +| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| **Example** @@ -175,20 +183,20 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void Reads image pixel map data in an area. This API uses an asynchronous callback to return the data read. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------ | ---- | ------------------------------ | | area | [PositionArea](#positionarea7) | Yes | Area from which the image pixel map data will be read. | -| callback | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| **Example** ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (err, pixelmap) => { if(pixelmap == undefined){ @@ -211,7 +219,7 @@ writePixels(area: PositionArea): Promise\<void> Writes image pixel map data to an area. This API uses a promise to return the operation result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -223,13 +231,13 @@ Writes image pixel map data to an area. This API uses a promise to return the op | Type | Description | | :------------- | :-------------------------------------------------- | -| Promise\<void> | Promise used to return the operation result. If the operation fails, an error message is returned.| +| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| **Example** ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts) .then( pixelmap => { @@ -265,21 +273,21 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void Writes image pixel map data to an area. This API uses an asynchronous callback to return the operation result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** | Name | Type | Mandatory| Description | | --------- | ------------------------------ | ---- | ------------------------------ | | area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written. | -| callback: | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| **Example** ```js const area = new ArrayBuffer(400); pixelmap.writePixels(area, (error) => { - if (error!=undefined) { + if (error != undefined) { console.info('Failed to write pixelmap into the specified area.'); } else { const readArea = { @@ -298,7 +306,7 @@ writeBufferToPixels(src: ArrayBuffer): Promise\<void> Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -310,14 +318,14 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj | Type | Description | | -------------- | ----------------------------------------------- | -| Promise\<void> | Promise used to return the operation result. If the operation fails, an error message is returned.| +| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| **Example** ```js const color = new ArrayBuffer(96); const pixelMap = new ArrayBuffer(400); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); pixelMap.writeBufferToPixels(color).then(() => { console.log("Succeeded in writing data from a buffer to a PixelMap."); }).catch((err) => { @@ -331,21 +339,21 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------------ | | src | ArrayBuffer | Yes | Buffer from which the image data will be read. | -| callback | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| **Example** ```js -const color = new ArrayBuffer(96);\ +const color = new ArrayBuffer(96); const pixelMap = new ArrayBuffer(400); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); pixelMap.writeBufferToPixels(color, function(err) { if (err) { console.error("Failed to write data from a buffer to a PixelMap."); @@ -362,7 +370,7 @@ getImageInfo(): Promise\<ImageInfo> Obtains pixel map information of this image. This API uses a promise to return the information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Return value** @@ -387,7 +395,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void Obtains pixel map information of this image. This API uses an asynchronous callback to return the information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** @@ -399,7 +407,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb ```js pixelmap.getImageInfo((imageInfo) => { - console.log("Succeeded in obtaining the image pixel map information.."); + console.log("Succeeded in obtaining the image pixel map information."); }) ``` @@ -407,21 +415,21 @@ pixelmap.getImageInfo((imageInfo) => { getBytesNumberPerRow(): number -Obtains the number of bytes per line of the image pixel map. +Obtains the number of bytes per row of this image pixel map. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Return value** | Type | Description | | ------ | -------------------- | -| number | Number of bytes per line.| +| number | Number of bytes per row.| **Example** ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (err,pixelmap) => { let rowCount = pixelmap.getBytesNumberPerRow(); @@ -432,9 +440,9 @@ image.createPixelMap(color, opts, (err,pixelmap) => { getPixelBytesNumber(): number -Obtains the total number of bytes of the image pixel map. +Obtains the total number of bytes of this image pixel map. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Return value** @@ -448,25 +456,410 @@ Obtains the total number of bytes of the image pixel map. let pixelBytesNumber = pixelmap.getPixelBytesNumber(); ``` +### getDensity<sup>9+</sup> + +getDensity():number + +Obtains the density of this image pixel map. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| ------ | --------------- | +| number | Density of the image pixel map.| + +**Example** + +```js +let getDensity = pixelmap.getDensity(); +``` + +### opacity<sup>9+</sup> + +opacity(rate: number, callback: AsyncCallback\<void>): void + +Sets an opacity rate for this image pixel map. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------ | +| rate | number | Yes | Opacity rate to set. The value ranges from 0 to 1. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.opacity(0.5); +} +``` + +### opacity<sup>9+</sup> + +opacity(rate: number): Promise\<void> + +Sets an opacity rate for this image pixel map. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------- | +| rate | number | Yes | Opacity rate to set. The value ranges from 0 to 1.| + +**Return value** + +| Type | Description | +| -------------- | ----------------------------------------------- | +| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.opacity(0.5); +} +``` + +### createAlphaPixelmap<sup>9+</sup> + +createAlphaPixelmap(): Promise\<PixelMap> + +Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Return value** + +| Type | Description | +| -------------------------------- | --------------------------- | +| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.| + +**Example** + +```js +pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => { + if (alphaPixelMap == undefined) { + console.info('Failed to obtain new pixel map.'); + } else { + console.info('Succeed in obtaining new pixel map.'); + } +}) +``` + +### createAlphaPixelmap<sup>9+</sup> + +createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void + +Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------ | ---- | ------------------------ | +| callback | AsyncCallback\<PixelMap> | Yes | Callback used to return the **PixelMap** object.| + +**Example** + +```js +let pixelMap = await imageSource.createPixelMap(); +if (pixelMap != undefined) { + pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => { + console.info('Failed to obtain new pixel map.'); + }) +} else { + console.info('Succeed in obtaining new pixel map.'); +} +``` + +### scale<sup>9+</sup> + +scale(x: number, y: number, callback: AsyncCallback\<void>): void + +Scales this image based on the input width and height. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------- | +| x | number | Yes | Scaling ratio of the width.| +| y | number | Yes | Scaling ratio of the height.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. | + +**Example** + +```js +async function () { + await pixelMap.scale(2.0, 1.0); +} +``` + +### scale<sup>9+</sup> + +scale(x: number, y: number): Promise\<void> + +Scales this image based on the input width and height. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------- | +| x | number | Yes | Scaling ratio of the width.| +| y | number | Yes | Scaling ratio of the height.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +async function () { + await pixelMap.scale(2.0, 1.0); +} +``` + +### translate<sup>9+</sup> + +translate(x: number, y: number, callback: AsyncCallback\<void>): void + +Translates this image based on the input coordinates. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ----------------------------- | +| x | number | Yes | X coordinate to translate. | +| y | number | Yes | Y coordinate to translate. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.translate(3.0, 1.0); +} +``` + +### translate<sup>9+</sup> + +translate(x: number, y: number): Promise\<void> + +Translates this image based on the input coordinates. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ----------- | +| x | number | Yes | X coordinate to translate.| +| y | number | Yes | Y coordinate to translate.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +async function () { + await pixelMap.translate(3.0, 1.0); +} +``` + +### rotate<sup>9+</sup> + +rotate(angle: number, callback: AsyncCallback\<void>): void + +Rotates this image based on the input angle. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ----------------------------- | +| angle | number | Yes | Angle to rotate. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.rotate(90.0); +} +``` + +### rotate<sup>9+</sup> + +rotate(angle: number): Promise\<void> + +Rotates this image based on the input angle. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ----------------------------- | +| angle | number | Yes | Angle to rotate. | + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +async function () { + await pixelMap.rotate(90.0); +} +``` + +### flip<sup>9+</sup> + +flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): void + +Flips this image horizontally or vertically, or both. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | -------------------- | ---- | ----------------------------- | +| horizontal | boolean | Yes | Whether to flip the image horizontally. | +| vertical | boolean | Yes | Whether to flip the image vertically. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.flip(false, true); +} +``` + +### flip<sup>9+</sup> + +flip(horizontal: boolean, vertical: boolean): Promise\<void> + +Flips this image horizontally or vertically, or both. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------- | ---- | --------- | +| horizontal | boolean | Yes | Whether to flip the image horizontally.| +| vertical | boolean | Yes | Whether to flip the image vertically.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +async function () { + await pixelMap.flip(false, true); +} +``` + +### crop<sup>9+</sup> + +crop(region: Region, callback: AsyncCallback\<void>): void + +Crops this image based on the input size. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ----------------------------- | +| region | [Region](#region7) | Yes | Size of the image after cropping. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| + +**Example** + +```js +async function () { + await pixelMap.crop(3x3); +} +``` + +### crop<sup>9+</sup> + +crop(region: Region): Promise\<void> + +Crops this image based on the input size. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------------------ | ---- | ----------- | +| region | [Region](#region7) | Yes | Size of the image after cropping.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +async function () { + await pixelMap.crop(3x3); +} +``` + ### release<sup>7+</sup> release():Promise\<void> Releases this **PixelMap** object. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Return value** -| Type | Description | -| -------------- | ------------------ | -| Promise\<void> | Promise used to return the operation result.| +| Type | Description | +| -------------- | ------------------------------- | +| Promise\<void> | Promise used to return the result.| **Example** ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (pixelmap) => { pixelmap.release().then(() => { @@ -483,25 +876,23 @@ release(callback: AsyncCallback\<void>): void Releases this **PixelMap** object. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core **Parameters** | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------ | -| callback | AsyncCallback\<void> | Yes | Callback used to return the operation result.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| **Example** ```js const color = new ArrayBuffer(96); -let bufferArr = new Unit8Array(color); +let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (pixelmap) => { pixelmap.release().then(() => { console.log('Succeeded in releasing pixelmap object.'); - }).catch(error => { - console.log('Failed to release pixelmap object.'); }) }) ``` @@ -512,7 +903,7 @@ createImageSource(uri: string): ImageSource Creates an **ImageSource** instance based on the URI. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -533,18 +924,45 @@ let path = this.context.getApplicationContext().fileDirs + "test.jpg"; const imageSourceApi = image.createImageSource(path); ``` +## image.createImageSource<sup>9+</sup> + +createImageSource(uri: string, options: SourceOptions): ImageSource + +Creates an **ImageSource** instance based on the URI. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ----------------------------------- | +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported. | +| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| + +**Return value** + +| Type | Description | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| + +**Example** + +```js +const imageSourceApi = image.createImageSource('/sdcard/test.jpg'); +``` + ## image.createImageSource<sup>7+</sup> createImageSource(fd: number): ImageSource Creates an **ImageSource** instance based on the file descriptor. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------------- | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------- | | fd | number | Yes | File descriptor.| **Return value** @@ -559,13 +977,144 @@ Creates an **ImageSource** instance based on the file descriptor. const imageSourceApi = image.createImageSource(0); ``` +## image.createImageSource<sup>9+</sup> + +createImageSource(fd: number, options: SourceOptions): ImageSource + +Creates an **ImageSource** instance based on the file descriptor. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ----------------------------------- | +| fd | number | Yes | File descriptor. | +| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| + +**Return value** + +| Type | Description | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| + +**Example** + +```js +const imageSourceApi = image.createImageSource(fd); +``` + +## image.createImageSource<sup>9+</sup> + +createImageSource(buf: ArrayBuffer): ImageSource + +Creates an **ImageSource** instance based on the buffer. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------- | ---- | ---------------- | +| buf | ArrayBuffer | Yes | Array of image buffers.| + +**Example** + +```js +const buf = new ArrayBuffer(96); +const imageSourceApi = image.createImageSource(buf); +``` + +## image.createImageSource<sup>9+</sup> + +createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource + +Creates an **ImageSource** instance based on the buffer. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------------------------------- | ---- | ------------------------------------ | +| buf | ArrayBuffer | Yes | Array of image buffers. | +| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| + +**Return value** + +| Type | Description | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| + +**Example** + +```js +const data = new ArrayBuffer(112); +const imageSourceApi = image.createImageSource(data); +``` + +## image.CreateIncrementalSource<sup>9+</sup> + +CreateIncrementalSource(buf: ArrayBuffer): ImageSource + +Creates an **ImageSource** instance in incremental mode based on the buffer. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------| ---- | ----------| +| buf | ArrayBuffer | Yes | Incremental data.| + +**Return value** + +| Type | Description | +| --------------------------- | --------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.| + +**Example** + +```js +const buf = new ArrayBuffer(96); +const imageSourceApi = image.CreateIncrementalSource(buf); +``` + +## image.CreateIncrementalSource<sup>9+</sup> + +CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource + +Creates an **ImageSource** instance in incremental mode based on the buffer. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ------------------------------------ | +| buf | ArrayBuffer | Yes | Incremental data. | +| options | [SourceOptions](#sourceoptions9) | No | Image properties, including the image index and default property value.| + +**Return value** + +| Type | Description | +| --------------------------- | --------------------------------- | +| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.| + +**Example** + +```js +const buf = new ArrayBuffer(96); +const imageSourceApi = image.CreateIncrementalSource(buf); +``` + ## ImageSource Provides APIs to obtain image information. Before calling any API in **ImageSource**, you must use **createImageSource** to create an **ImageSource** instance. ### Attributes -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource | Name | Type | Readable| Writable| Description | | ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | @@ -577,7 +1126,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void Obtains information about an image with the specified index. This API uses an asynchronous callback to return the information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -604,7 +1153,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void Obtains information about this image. This API uses an asynchronous callback to return the information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -626,7 +1175,7 @@ getImageInfo(index?: number): Promise\<ImageInfo> Obtains information about an image with the specified index. This API uses a promise to return the image information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -657,7 +1206,7 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string Obtains the value of a property with the specified index in this image. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -668,8 +1217,8 @@ Obtains the value of a property with the specified index in this image. This API **Return value** -| Type | Description | -| ---------------- | ------------------------------------------------------------ | +| Type | Description | +| ---------------- | ----------------------------------------------------------------- | | Promise\<string> | Promise used to return the property value. If the operation fails, the default value is returned.| **Example** @@ -687,7 +1236,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -714,14 +1263,14 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa Obtains the value of a property in this image. This API uses an asynchronous callback to return the property value in a string. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | -| key | string | Yes | Name of the property. | -| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | Yes | Image properties, including the image index and default property value. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------- | +| key | string | Yes | Name of the property. | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | Yes | Image properties, including the image index and default property value. | | callback | AsyncCallback\<string> | Yes | Callback used to return the property value. If the operation fails, the default value is returned.| **Example** @@ -737,13 +1286,128 @@ imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => { }) ``` +### modifyImageProperty<sup>9+</sup> + +modifyImageProperty(key: string, value: string): Promise\<void> + +Modifies the value of a property in this image. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------ | +| key | string | Yes | Name of the property.| +| value | string | Yes | New value of the property. | + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +imageSourceApi.modifyImageProperty("ImageWidth", "120") + .then(() => { + const w = imageSourceApi.getImageProperty("ImageWidth") + console.info('w', w); + }) +``` + +### modifyImageProperty<sup>9+</sup> + +modifyImageProperty(key: string, value: string, callback: AsyncCallback\<void>): void + +Modifies the value of a property in this image. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------- | ---- | ------------------------------ | +| key | string | Yes | Name of the property. | +| value | string | Yes | New value of the property. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +```js +imageSourceApi.modifyImageProperty("ImageWidth", "120",() => {}) +``` + +### updateData<sup>9+</sup> + +updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise\<void> + +Updates incremental data. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------- | ---- | ------------ | +| buf | ArrayBuffer | Yes | Incremental data. | +| isFinished | boolean | Yes | Whether the update is complete.| +| value | number | No | Offset for data reading. | +| length | number | No | Array length. | + +**Return value** + +| Type | Description | +| -------------- | -------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +const array = new ArrayBuffer(100); +imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => { + console.info('Succeeded in updating data.'); + }) +``` + + +### updateData<sup>9+</sup> + +updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback\<void>): void + +Updates incremental data. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Image.ImageSource + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ------------------- | ---- | -------------------- | +| buf | ArrayBuffer | Yes | Incremental data. | +| isFinished | boolean | Yes | Whether the update is complete. | +| value | number | No | Offset for data reading. | +| length | number | No | Array length. | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +```js +const array = new ArrayBuffer(100); +imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> { + if(data !== undefined){ + console.info('Succeeded in updating data.'); + } + }) +``` + ### createPixelMap<sup>7+</sup> createPixelMap(options?: DecodingOptions): Promise\<PixelMap> Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -773,7 +1437,7 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -784,11 +1448,9 @@ Creates a **PixelMap** object based on the default parameters. This API uses an **Example** ```js -imageSourceApi.createPixelMap(pixelmap => { - console.log('Succeeded in creating pixelmap object.'); -}).catch(error => { - console.log('Failed to create pixelmap object.'); -}) +imageSourceApi.createPixelMap((err, pixelmap) => { + console.info('Succeeded in creating pixelmap object.'); + }) ``` ### createPixelMap<sup>7+</sup> @@ -797,7 +1459,7 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -821,7 +1483,7 @@ release(callback: AsyncCallback\<void>): void Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Parameters** @@ -843,13 +1505,13 @@ release(): Promise\<void> Releases this **ImageSource** instance. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise\<void> | Promise used to return the operation result.| +| Promise\<void> | Promise used to return the result.| **Example** @@ -867,7 +1529,7 @@ createImagePacker(): ImagePacker Creates an **ImagePacker** instance. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Return value** @@ -887,7 +1549,7 @@ Provide APIs to pack images. Before calling any API in **ImagePacker**, you must ### Attributes -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker | Name | Type | Readable| Writable| Description | | ---------------- | -------------- | ---- | ---- | -------------------------- | @@ -899,7 +1561,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr Packs an image. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Parameters** @@ -923,7 +1585,7 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer> Packs an image. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Parameters** @@ -935,8 +1597,8 @@ Packs an image. This API uses a promise to return the result. **Return value** | Type | Description | -| :--------------------------- | :-------------------------------------------- | -| Promise\<ArrayBuffer> | Promise used to return the packed data.| +| ---------------------------- | --------------------------------------------- | +| Promise\<ArrayBuffer> | Promise used to return the packed data.| **Example** @@ -957,7 +1619,7 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB Packs an image. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Parameters** @@ -974,8 +1636,6 @@ let packOpts = { format:"image/jpeg", quality:98 } const pixelMapApi = new ArrayBuffer(400); imagePackerApi.packing(pixelMapApi, packOpts, data => { console.log('Succeeded in packing the image.'); -}).catch(error => { - console.log('Failed to pack the image.'); }) ``` @@ -985,7 +1645,7 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer> Packs an image. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Parameters** @@ -996,8 +1656,8 @@ Packs an image. This API uses a promise to return the result. **Return value** -| Type | Description | -| :--------------------------- | :-------------------------------------------- | +| Type | Description | +| --------------------- | -------------------------------------------- | | Promise\<ArrayBuffer> | Promise used to return the packed data.| **Example** @@ -1019,7 +1679,7 @@ release(callback: AsyncCallback\<void>): void Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Parameters** @@ -1041,12 +1701,12 @@ release(): Promise\<void> Releases this **ImagePacker** instance. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker **Return value** -| Type | Description | -| :------------- | :------------------------------------------------------ | +| Type | Description | +| -------------- | ------------------------------------------------------ | | Promise\<void> | Promise used to return the instance release result. If the operation fails, an error message is returned.| **Example** @@ -1098,11 +1758,11 @@ Before calling any APIs in **ImageReceiver**, you must create an **ImageReceiver **System capability**: SystemCapability.Multimedia.Image.ImageReceiver -| Name | Type | Readable| Writable| Description | -| --------------------- | ---------------------------- | ---- | ---- | ------------------ | -| size<sup>9+</sup> | [Size](#size) | Yes | No | Image size. | -| capacity<sup>9+</sup> | number | Yes | No | Maximum number of images that can be accessed at the same time.| -| format<sup>9+</sup> | [ImageFormat](#imageformat9) | Yes | No | Image format. | +| Name | Type | Readable| Writable| Description | +| -------- | ---------------------------- | ---- | ---- | ------------------ | +| size | [Size](#size) | Yes | No | Image size. | +| capacity | number | Yes | No | Maximum number of images that can be accessed at the same time.| +| format | [ImageFormat](#imageformat9) | Yes | No | Image format. | ### getReceivingSurfaceId<sup>9+</sup> @@ -1192,7 +1852,7 @@ Reads the latest image from the **ImageReceiver** instance. This API uses a prom | Type | Description | | ------------------------- | ------------------ | -| Promise<[Image](#image8)> | Promise used to return the latest image.| +| Promise<[Image](#image9)> | Promise used to return the latest image.| **Example** @@ -1327,11 +1987,11 @@ Provides APIs for basic image operations, including obtaining image information **System capability**: SystemCapability.Multimedia.Image.Core -| Name | Type | Readable| Writable| Description | -| --------------------- | ------------------ | ---- | ---- | -------------------------------------------------- | -| clipRect<sup>9+</sup> | [Region](#region7) | Yes | Yes | Image area to be cropped. | -| size<sup>9+</sup> | [Size](#size) | Yes | No | Image size. | -| format<sup>9+</sup> | number | Yes | No | Image format. For details, see [PixelMapFormat](#pixelmapformat7).| +| Name | Type | Readable| Writable| Description | +| -------- | ------------------ | ---- | ---- | -------------------------------------------------- | +| clipRect | [Region](#region7) | Yes | Yes | Image area to be cropped. | +| size | [Size](#size) | Yes | No | Image size. | +| format | number | Yes | No | Image format. For details, see [PixelMapFormat](#pixelmapformat7).| ### getComponent<sup>9+</sup> @@ -1407,8 +2067,6 @@ The corresponding resources must be released before another image arrives. ```js img.release(() =>{ console.log('release succeeded.'); -}).catch(error => { - console.log('release failed.'); }) ``` @@ -1442,7 +2100,7 @@ img.release().then(() =>{ Describes area information in an image. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name | Type | Readable| Writable| Description | | ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ | @@ -1455,7 +2113,7 @@ Describes area information in an image. Describes image information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name| Type | Readable| Writable| Description | | ---- | ------------- | ---- | ---- | ---------- | @@ -1465,7 +2123,7 @@ Describes image information. Describes the size of an image. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name | Type | Readable| Writable| Description | | ------ | ------ | ---- | ---- | -------------- | @@ -1476,19 +2134,20 @@ Describes the size of an image. Enumerates the pixel formats of images. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core -| Name | Default Value| Description | -| --------- | ------ | ----------------- | -| UNKNOWN | 0 | Unknown format. | -| RGBA_8888 | 3 | RGBA_8888.| -| RGB_565 | 2 | RGB_565. | +| Name | Default Value| Description | +| ---------------------- | ------ | ----------------- | +| UNKNOWN | 0 | Unknown format. | +| RGB_565 | 2 | RGB_565. | +| RGBA_8888 | 3 | RGBA_8888.| +| BGRA_8888<sup>9+</sup> | 4 | BGRA_8888.| ## AlphaType<sup>9+</sup> Enumerates the alpha types of images. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name | Default Value| Description | | -------- | ------ | ----------------------- | @@ -1501,32 +2160,45 @@ Enumerates the alpha types of images. Enumerates the scale modes of images. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name | Default Value| Description | | --------------- | ------ | -------------------------------------------------- | | CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.| | FIT_TARGET_SIZE | 2 | Reduces the image size to the dimensions of the target. | +## SourceOptions<sup>9+</sup> + +Defines image source initialization options. + +**System capability**: SystemCapability.Multimedia.Image.Core + +| Name | Type | Readable| Writable| Description | +| ----------------- | ---------------------------------- | ---- | ---- | ------------------ | +| sourceDensity | number | Yes | Yes | Density of the image source.| +| sourcePixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel format of the image source. | +| sourceSize | [Size](#size) | Yes | Yes | Pixel size of the image source. | + + ## InitializationOptions<sup>8+</sup> Defines pixel map initialization options. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core -| Name | Type | Readable| Writable| Description | -| ---------------------- | ---------------------------------- | ---- | ---- | -------------- | -| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | Yes | Yes | Alpha type. | -| editable | boolean | Yes | Yes | Whether the image is editable. | -| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. | -| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | Yes | Yes | Scale mode. | -| size | [Size](#size) | Yes | Yes | Image size.| +| Name | Type | Readable| Writable| Description | +| ------------------------ | ---------------------------------- | ---- | ---- | -------------- | +| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | Yes | Yes | Alpha type. | +| editable | boolean | Yes | Yes | Whether the image is editable. | +| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. | +| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | Yes | Yes | Scale mode. | +| size | [Size](#size) | Yes | Yes | Image size.| ## DecodingOptions<sup>7+</sup> Defines image decoding options. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource | Name | Type | Readable| Writable| Description | | ------------------ | ---------------------------------- | ---- | ---- | ---------------- | @@ -1542,7 +2214,7 @@ Defines image decoding options. Describes region information. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core | Name| Type | Readable| Writable| Description | | ---- | ------------- | ---- | ---- | ------------ | @@ -1554,18 +2226,18 @@ Describes region information. Defines the option for image packing. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImagePacker -| Name | Type | Readable| Writable| Description | -| ------- | ------ | ---- | ---- | -------------- | -| format | string | Yes | Yes | Format of the packed image. | +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | --------------------------------------------------- | +| format | string | Yes | Yes | Format of the packed image. | | quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.| ## GetImagePropertyOptions<sup>7+</sup> Describes image properties. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.ImageSource | Name | Type | Readable| Writable| Description | | ------------ | ------ | ---- | ---- | ------------ | @@ -1576,18 +2248,18 @@ Describes image properties. Describes the exchangeable image file format (Exif) information of an image. -**System capability**: SystemCapability.Multimedia.Image +**System capability**: SystemCapability.Multimedia.Image.Core -| Name | Default Value | Description | -| ----------------- | ----------------- | -------------------- | -| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. | -| ORIENTATION | "Orientation" | Image orientation. | -| IMAGE_LENGTH | "ImageLength" | Image length. | -| IMAGE_WIDTH | "ImageWidth" | Image width. | -| GPS_LATITUDE | "GPSLatitude" | Image latitude. | -| GPS_LONGITUDE | "GPSLongitude" | Image longitude. | -| GPS_LATITUDE_REF | "GPSLatitudeRef" | Latitude reference, for example, N or S.| -| GPS_LONGITUDE_REF | "GPSLongitudeRef" | Longitude reference, for example, W or E.| +| Name | Default Value | Description | +| ----------------- | ----------------------- | ------------------------ | +| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. | +| ORIENTATION | "Orientation" | Image orientation. | +| IMAGE_LENGTH | "ImageLength" | Image length. | +| IMAGE_WIDTH | "ImageWidth" | Image width. | +| GPS_LATITUDE | "GPSLatitude" | Image latitude. | +| GPS_LONGITUDE | "GPSLongitude" | Image longitude. | +| GPS_LATITUDE_REF | "GPSLatitudeRef" | Latitude reference, for example, N or S. | +| GPS_LONGITUDE_REF | "GPSLongitudeRef" | Longitude reference, for example, W or E. | ## ImageFormat<sup>9+</sup> @@ -1625,3 +2297,45 @@ Describes the color components of an image. | rowStride | number | Yes | No | Row stride. | | pixelStride | number | Yes | No | Pixel stride. | | byteBuffer | ArrayBuffer | Yes | No | Component buffer.| + +## ResponseCode + +Enumerates the response codes returned upon build errors. + +| Name | Value | Description | +| ----------------------------------- | -------- | --------------------------------------------------- | +| ERR_MEDIA_INVALID_VALUE | -1 | Invalid value. | +| SUCCESS | 0 | Operation successful. | +| ERROR | 62980096 | Operation failed. | +| ERR_IPC | 62980097 | IPC error. | +| ERR_SHAMEM_NOT_EXIST | 62980098 | The shared memory does not exist. | +| ERR_SHAMEM_DATA_ABNORMAL | 62980099 | The shared memory is abnormal. | +| ERR_IMAGE_DECODE_ABNORMAL | 62980100 | An error occurs during image decoding. | +| ERR_IMAGE_DATA_ABNORMAL | 62980101 | The input image data is incorrect. | +| ERR_IMAGE_MALLOC_ABNORMAL | 62980102 | An error occurs during image memory allocation. | +| ERR_IMAGE_DATA_UNSUPPORT | 62980103 | Unsupported image type. | +| ERR_IMAGE_INIT_ABNORMAL | 62980104 | An error occurs during image initialization. | +| ERR_IMAGE_GET_DATA_ABNORMAL | 62980105 | An error occurs during image data retrieval. | +| ERR_IMAGE_TOO_LARGE | 62980106 | The image data is too large. | +| ERR_IMAGE_TRANSFORM | 62980107 | An error occurs during image transformation. | +| ERR_IMAGE_COLOR_CONVERT | 62980108 | An error occurs during image color conversion. | +| ERR_IMAGE_CROP | 62980109 | An error occurs during image cropping. | +| ERR_IMAGE_SOURCE_DATA | 62980110 | The image source data is incorrect. | +| ERR_IMAGE_SOURCE_DATA_INCOMPLETE | 62980111 | The image source data is incomplete. | +| ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image format does not match. | +| ERR_IMAGE_UNKNOWN_FORMAT | 62980113 | Unknown image format. | +| ERR_IMAGE_SOURCE_UNRESOLVED | 62980114 | The image source is not parsed. | +| ERR_IMAGE_INVALID_PARAMETER | 62980115 | Invalid image parameter. | +| ERR_IMAGE_DECODE_FAILED | 62980116 | Decoding failed. | +| ERR_IMAGE_PLUGIN_REGISTER_FAILED | 62980117 | Failed to register the plug-in. | +| ERR_IMAGE_PLUGIN_CREATE_FAILED | 62980118 | Failed to create the plug-in. | +| ERR_IMAGE_ENCODE_FAILED | 62980119 | Failed to encode the image. | +| ERR_IMAGE_ADD_PIXEL_MAP_FAILED | 62980120 | Failed to add the image pixel map. | +| ERR_IMAGE_HW_DECODE_UNSUPPORT | 62980121 | Unsupported image hardware decoding. | +| ERR_IMAGE_DECODE_HEAD_ABNORMAL | 62980122 | The image decoding header is incorrect. | +| ERR_IMAGE_DECODE_EXIF_UNSUPPORT | 62980123 | EXIF decoding is not supported. | +| ERR_IMAGE_PROPERTY_NOT_EXIST | 62980124 | The image property does not exist. The error codes for the image start from 150.| +| ERR_IMAGE_READ_PIXELMAP_FAILED | 62980246 | Failed to read the pixel map. | +| ERR_IMAGE_WRITE_PIXELMAP_FAILED | 62980247 | Failed to write the pixel map. | +| ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed. | +| ERR_IMAGE_CONFIG_FAILED | 62980259 | The software parameter setting is incorrect. | diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index c1ec2c787a6f9e47c1c87715b5ea52171dbac85f..178313a1ff1a83a905895656793ff5977a486d0d 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -287,7 +287,7 @@ Defines the information about an input device. | Name | Type | Description | | -------- | ------------------------- | --------------------------------- | -| type | [ChangeType](#changetype) | Device change type, which indicates whether an input device is inserted or removed. | +| type | [ChangedType](#changedtype) | 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.| ## InputDeviceData diff --git a/en/application-dev/reference/apis/js-apis-medialibrary.md b/en/application-dev/reference/apis/js-apis-medialibrary.md index 3d2f6f3e9703e606847e92822c62aa20c2811e8f..91059df152841c2317196bcd8496be2412f2fd30 100644 --- a/en/application-dev/reference/apis/js-apis-medialibrary.md +++ b/en/application-dev/reference/apis/js-apis-medialibrary.md @@ -49,7 +49,9 @@ getMediaLibrary(): MediaLibrary Obtains a **MediaLibrary** instance, which is used to access and modify personal media data such as audios, videos, images, and documents. -> **Note**: This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8) instead. +> **NOTE** +> +> This API is no longer maintained since API version 8. You are advised to use [mediaLibrary.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8) instead. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -99,7 +101,9 @@ media.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); fetchFileResult.getAllObject((err, fileAssetList) => { if (fileAssetList != undefined) { - fileAssetList.forEach(getAllObjectInfo); + fileAssetList.forEach(function(getAllObjectInfo){ + console.info("getAllObjectInfo.displayName :" + getAllObjectInfo.displayName); + }); } }); } @@ -137,7 +141,7 @@ let imagesfetchOp = { selectionArgs: [imageType.toString()], }; media.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ - console.info("getFileAssets successfully:"+ JSON.stringify(dir)); + console.info("getFileAssets successfully: image number is "+ fetchFileResult.getCount()); }).catch(function(err){ console.info("getFileAssets failed with error:"+ err); }); @@ -161,7 +165,7 @@ Subscribes to the media library changes. This API uses an asynchronous callback **Example** ``` -mediaLibrary.on('imageChange', () => { +media.on('imageChange', () => { // image file had changed, do something }) ``` @@ -449,7 +453,9 @@ storeMediaAsset(option: MediaAssetOption, callback: AsyncCallback<string>) Stores a media asset. This API uses an asynchronous callback to return the URI that stores the media asset. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -485,7 +491,9 @@ storeMediaAsset(option: MediaAssetOption): Promise<string> Stores a media asset. This API uses a promise to return the URI that stores the media asset. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -524,7 +532,9 @@ startImagePreview(images: Array<string>, index: number, callback: AsyncCal 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. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **\<Image>** component can be used to render and display local and online images. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -566,7 +576,9 @@ startImagePreview(images: Array<string>, callback: AsyncCallback<void&g 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. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **<Image\>** component can be used to render and display local images and network images. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -606,7 +618,9 @@ startImagePreview(images: Array<string>, index?: number): Promise<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 a promise to return the execution result. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use the **\<[Image](../arkui-ts/ts-basic-components-image.md)>** component instead. The **<Image\>** component can be used to render and display local images and network images. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -651,7 +665,9 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback<Array< Starts media selection. This API uses an asynchronous callback to return the list of URIs that store the selected media assets. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos). **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -666,7 +682,7 @@ Starts media selection. This API uses an asynchronous callback to return the lis ``` let option = { - type : "image", + type : "media", count : 2 }; mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { @@ -686,7 +702,9 @@ startMediaSelect(option: MediaSelectOption): Promise<Array<string>> Starts media selection. This API uses a promise to return the list of URIs that store the selected media assets. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use the system app Gallery instead. Gallery is a built-in visual resource access application that provides features such as image and video management and browsing. For details about how to use Gallery, visit [OpenHarmony/applications_photos](https://gitee.com/openharmony/applications_photos). **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -706,7 +724,7 @@ Starts media selection. This API uses a promise to return the list of URIs that ``` let option = { - type : "image", + type : "media", count : 2 }; mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { @@ -745,7 +763,7 @@ Provides APIs for encapsulating file asset attributes. | width | number | Yes | No | Image width, in pixels. | | height | number | Yes | No | Image height, in pixels. | | orientation | number | Yes | Yes | Image display direction (clockwise rotation angle, for example, 0, 90, or 180, in degrees).| -| duration<sup>8+</sup> | number | Yes | No | Duration, in seconds. | +| duration<sup>8+</sup> | number | Yes | No | Duration, in ms. | | albumId | number | Yes | No | ID of the album to which the file belongs. | | albumUri<sup>8+</sup> | string | Yes | No | URI of the album to which the file belongs. | | albumName | string | Yes | No | Name of the album to which the file belongs. | @@ -771,6 +789,7 @@ Checks whether this file asset is a directory. This API uses an asynchronous cal ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -806,6 +825,7 @@ Checks whether this file asset is a directory. This API uses a promise to return ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -843,6 +863,7 @@ Commits the modification in this file asset to the database. This API uses an as ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -879,6 +900,7 @@ Commits the modification in this file asset to the database. This API uses a pro ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -899,9 +921,11 @@ open(mode: string, callback: AsyncCallback<number>): 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. +> **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**) +**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -919,7 +943,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - asset = await media.createAsset(mediaType, "image00003.jpg", path); + const asset = await media.createAsset(mediaType, "image00003.jpg", path); asset.open('rw', (openError, fd) => { if(fd > 0){ asset.close(fd); @@ -936,9 +960,11 @@ open(mode: string): Promise<number> 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. +> **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**) +**Required permissions**: ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -946,7 +972,7 @@ Note: Currently, the write operations are mutually exclusive. After the write op | 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).| **Return value** @@ -961,7 +987,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - asset = await media.createAsset(mediaType, "image00003.jpg", path); + const asset = await media.createAsset(mediaType, "image00003.jpg", path); asset.open('rw') .then((fd) => { console.info('File fd!' + fd); @@ -978,7 +1004,7 @@ close(fd: number, callback: AsyncCallback<void>): void Closes this file asset. This API uses an asynchronous callback 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 or ohos.permission.WRITE_MEDIA **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -993,6 +1019,7 @@ Closes this file asset. This API uses an asynchronous callback to return the res ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1002,13 +1029,19 @@ async function example() { }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.close(fd, (closeErr) => { - if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); - } else { - console.info("=======asset.close success====>"); - } + asset.open('rw').then((fd) => { + console.info('File fd!' + fd); + asset.close(fd, (closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + } else { + console.info("=======asset.close success====>"); + } + }); + }) + .catch((err) => { + console.info('File err!' + err); }); } ``` @@ -1019,7 +1052,7 @@ close(fd: number): Promise<void> 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 or ohos.permission.WRITE_MEDIA **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -1039,6 +1072,7 @@ Closes this file asset. This API uses a promise to return the result. ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1048,14 +1082,20 @@ async function example() { }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.close(fd).then((closeErr) => { - if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + asset.open('rw').then((fd) => { + console.info('File fd!' + fd); + asset.close(fd).then((closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); - } else { - console.info("=======asset.close success====>"); - } + } else { + console.info("=======asset.close success====>"); + } + }); + }) + .catch((err) => { + console.info('File err!' + err); }); } ``` @@ -1080,6 +1120,7 @@ Obtains the thumbnail of this file asset. This API uses an asynchronous callback ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1116,6 +1157,7 @@ Obtains the thumbnail of this file asset, with the thumbnail size passed. This A ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1123,6 +1165,7 @@ async function example() { order: fileKeyObj.DATE_ADDED + " DESC", extendArgs: "", }; + let size = { width: 720, height: 720 }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size, (err, pixelmap) => { @@ -1157,6 +1200,7 @@ Obtains the thumbnail of this file asset, with the thumbnail size passed. This A ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1164,6 +1208,7 @@ async function example() { order: fileKeyObj.DATE_ADDED + " DESC", extendArgs: "", }; + let size = { width: 720, height: 720 }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size) @@ -1197,6 +1242,7 @@ Favorites or unfavorites this file asset. This API uses an asynchronous callback ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1238,6 +1284,7 @@ Favorites or unfavorites this file asset. This API uses a promise to return the ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1275,6 +1322,7 @@ Checks whether this file asset is favorited. This API uses an asynchronous callb ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1314,6 +1362,7 @@ Checks whether this file asset is favorited. This API uses a promise to return t ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1354,6 +1403,7 @@ Files in the trash are not actually deleted. You can set **isTrash** to **false* ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1398,6 +1448,7 @@ Files in the trash are not actually deleted. You can set **isTrash** to **false* ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1435,6 +1486,7 @@ Checks whether this file asset is in the trash. This API uses an asynchronous ca ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1448,7 +1500,7 @@ async function example() { function isTrashCallBack(err, isTrash) { if (isTrash == true) { console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); - asset.trash(true, trashCallBack); + asset.trash(true, istrashCallBack); } else { console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); @@ -1479,6 +1531,7 @@ Checks whether this file asset is in the trash. This API uses a promise to retur ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1518,6 +1571,8 @@ Obtains the total number of files in the result set. ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.FILE; let getFileCountOneOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [fileType.toString()], @@ -1547,6 +1602,7 @@ Checks whether the cursor is in the last row of the result set. ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1584,6 +1640,7 @@ Releases and invalidates this **FetchFileResult** instance. Other APIs in this i ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1614,6 +1671,7 @@ Obtains the first file asset in the result set. This API uses an asynchronous ca ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1622,12 +1680,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getFirstObject((err, value) => { + fetchFileResult.getFirstObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1650,6 +1708,7 @@ Obtains the first file asset in the result set. This API uses a promise to retur ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1672,8 +1731,6 @@ async function example() { Obtains the next file asset in the result set. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.READ_MEDIA - **System capability**: SystemCapability.Multimedia.MediaLibrary.Core **Parameters** @@ -1686,6 +1743,7 @@ Obtains the next file asset in the result set. This API uses an asynchronous cal ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1694,12 +1752,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getNextObject((err, value) => { + fetchFileResult.getNextObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1710,8 +1768,6 @@ async function example() { Obtains the next file asset in the result set. This API uses a promise to return the result. -**Required permissions**: ohos.permission.READ_MEDIA - **System capability**: SystemCapability.Multimedia.MediaLibrary.Core **Return value** @@ -1724,6 +1780,7 @@ Obtains the next file asset in the result set. This API uses a promise to return ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1734,7 +1791,7 @@ async function example() { let fetchFileResult = await media.getFileAssets(getImageOp); const fetchCount = fetchFileResult.getCount(); console.info('mediaLibraryTest : count:' + fetchCount); - fileAsset = await fetchFileResult.getNextObject(); + let fileAsset = await fetchFileResult.getNextObject(); } ``` @@ -1756,6 +1813,7 @@ Obtains the last file asset in the result set. This API uses an asynchronous cal ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1764,12 +1822,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getLastObject((err, value) => { + fetchFileResult.getLastObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1792,6 +1850,7 @@ Obtains the last file asset in the result set. This API uses a promise to return ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1823,6 +1882,7 @@ Obtains a file asset with the specified index in the result set. This API uses a ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1831,12 +1891,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getPositionObject(0, (err, value) => { + fetchFileResult.getPositionObject(0, (err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1847,8 +1907,6 @@ getPositionObject(index: number): Promise<FileAsset> Obtains a file asset with the specified index in the result set. This API uses a promise to return the result. -**Required permissions**: ohos.permission.READ_MEDIA - **System capability**: SystemCapability.Multimedia.MediaLibrary.Core **Parameters** @@ -1867,6 +1925,7 @@ Obtains a file asset with the specified index in the result set. This API uses a ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1875,12 +1934,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getPositionObject(1, (err, value) => { + fetchFileResult.getPositionObject(1, (err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1891,8 +1950,6 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void Obtains all the file assets in the result set. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.READ_MEDIA - **System capability**: SystemCapability.Multimedia.MediaLibrary.Core **Parameters** @@ -1905,6 +1962,7 @@ Obtains all the file assets in the result set. This API uses an asynchronous cal ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1913,12 +1971,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getAllObject((err, value) => { + fetchFileResult.getAllObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1941,6 +1999,7 @@ Obtains all the file assets in the result set. This API uses a promise to return ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -2068,6 +2127,10 @@ async function example() { selections: '', selectionArgs: [], }; + let fileNoArgsfetchOp = { + selections: '', + selectionArgs: [], + } const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const album = albumList[0]; album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); @@ -2107,6 +2170,10 @@ async function example() { selections: '', selectionArgs: [], }; + let fileNoArgsfetchOp = { + selections: '', + selectionArgs: [], + } const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const album = albumList[0]; album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){ @@ -2120,8 +2187,9 @@ async function example() { ## PeerInfo<sup>8+</sup> Describes information about a registered device. +This is a system API. -**System capability**: SystemCapability.Multimedia.MediaLibrary.Core +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore | Name | Type | Readable| Writable| Description | | ---------- | -------------------------- | ---- | ---- | ---------------- | @@ -2138,12 +2206,12 @@ Enumerates media types. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value| Description| -| ----- | ------ | ---- | -| FILE | 1 | File.| -| IMAGE | 3 | Image.| -| VIDEO | 4 | Video.| -| AUDIO | 5 | Audio.| +| Name | Description| +| ----- | ---- | +| FILE | File.| +| IMAGE | Image.| +| VIDEO | Video.| +| AUDIO | Audio.| ## FileKey<sup>8+</sup> @@ -2166,7 +2234,7 @@ Enumerates key file information. | TITLE | title | Title in the file. | | ARTIST | artist | Artist of the file. | | AUDIOALBUM | audio_album | Audio album. | -| DURATION | duration | Duration, in seconds. | +| DURATION | duration | Duration, in ms. | | WIDTH | width | Image width, in pixels. | | HEIGHT | height | Image height, in pixels. | | ORIENTATION | orientation | Image display direction (clockwise rotation angle, for example, 0, 90, and 180, in degrees).| @@ -2179,30 +2247,31 @@ Enumerates directory types. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core -| Name | Default Value| Description | -| ------------- | ------ | ------------------ | -| DIR_CAMERA | 0 | Directory of camera files.| -| DIR_VIDEO | 1 | Directory of video files. | -| DIR_IMAGE | 2 | Directory of image files. | -| DIR_AUDIO | 3 | Directory of audio files. | -| DIR_DOCUMENTS | 4 | Directory of documents. | -| DIR_DOWNLOAD | 5 | Download directory. | +| Name | Description | +| ------------- | ------------------ | +| DIR_CAMERA | Directory of camera files.| +| DIR_VIDEO | Directory of video files. | +| DIR_IMAGE | Directory of image files. | +| DIR_AUDIO | Directory of audio files. | +| DIR_DOCUMENTS | Directory of documents. | +| DIR_DOWNLOAD | Download directory. | ## DeviceType<sup>8+</sup> Enumerates device types. +This is a system API. -**System capability**: SystemCapability.Multimedia.MediaLibrary.Core +**System capability**: SystemCapability.Multimedia.MediaLibrary.DistributedCore -| Name | Default Value| Description | -| ------------ | ------ | ---------- | -| TYPE_UNKNOWN | 0 | Unknown.| -| TYPE_LAPTOP | 1 | Laptop.| -| TYPE_PHONE | 2 | Phone. | -| TYPE_TABLET | 3 | Tablet. | -| TYPE_WATCH | 4 | Smart watch. | -| TYPE_CAR | 5 | Vehicle-mounted device. | -| TYPE_TV | 6 | TV. | +| Name | Description | +| ------------ | ---------- | +| TYPE_UNKNOWN | Unknown.| +| TYPE_LAPTOP | Laptop.| +| TYPE_PHONE | Phone. | +| TYPE_TABLET | Tablet. | +| TYPE_WATCH | Smart watch. | +| TYPE_CAR | Vehicle-mounted device. | +| TYPE_TV | TV. | ## MediaFetchOptions<sup>7+</sup> @@ -2222,6 +2291,7 @@ Describes options for fetching media files. ## Size<sup>8+</sup> Describes the image size. +**System capability**: SystemCapability.Multimedia.MediaLibrary.Core | Name | Type | Readable | Writable | Description | | ------ | ------ | ---- | ---- | -------- | @@ -2232,7 +2302,9 @@ Describes the image size. Implements the media asset option. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core @@ -2247,7 +2319,9 @@ Implements the media asset option. Describes media selection option. -> **NOTE**<br>This API is deprecated since API version 9. +> **NOTE** +> +> This API is deprecated since API version 9. **System capability**: SystemCapability.Multimedia.MediaLibrary.Core diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md index 94fb115434d6860cb2096586d48f0c981ea9a30a..b981d28061d45feb313dbaf7ea0709d6f198e0e8 100644 --- a/en/application-dev/reference/apis/js-apis-missionManager.md +++ b/en/application-dev/reference/apis/js-apis-missionManager.md @@ -1,12 +1,11 @@ # missionManager +The **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground. > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground. - ## Modules to Import ``` @@ -23,8 +22,12 @@ registerMissionListener(listener: MissionListener): number; Registers a listener to observe the mission status. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -59,8 +62,12 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void> Deregisters a mission status listener. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -93,8 +100,12 @@ unregisterMissionListener(listenerId: number): Promise<void>; Deregisters a mission status listener. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -132,8 +143,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M Obtains the information about a given mission. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -166,8 +181,12 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>; Obtains the information about a given mission. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -198,8 +217,12 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr Obtains information about all missions. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -227,8 +250,12 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn Obtains information about all missions. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -259,8 +286,12 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback& Obtains the snapshot of a given mission. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -294,8 +325,12 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps Obtains the snapshot of a given mission. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -334,8 +369,12 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void; Locks a given mission. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -367,8 +406,12 @@ lockMission(missionId: number): Promise<void>; Locks a given mission. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -405,8 +448,12 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void; Unlocks a given mission. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -438,8 +485,12 @@ unlockMission(missionId: number): Promise<void>; Unlocks a given mission. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -480,8 +531,12 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void; Clears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -513,8 +568,12 @@ clearMission(missionId: number): Promise<void>; Clears a given mission, regardless of whether it is locked. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -552,8 +611,12 @@ clearAllMissions(callback: AsyncCallback<void>): void; Clears all unlocked missions. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Example** ```js @@ -571,8 +634,12 @@ clearAllMissions(): Promise<void>; Clears all unlocked missions. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Return value** | Type| Description| @@ -595,8 +662,12 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void Switches a given mission to the foreground. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -628,8 +699,12 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -662,8 +737,12 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result. +**Required permission**: ohos.permission.MANAGE_MISSIONS + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -699,7 +778,9 @@ Switches a given mission to the foreground, with the startup parameters for the Describes the mission information. -**System capability**: SystemCapability.Ability.AbilityBase +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**System API**: This is a system API and cannot be called by third-party applications. | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | @@ -710,4 +791,4 @@ Describes the mission information. | want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.| | label | string | Yes| Yes| Label of the mission.| | iconPath | string | Yes| Yes| Path of the mission icon.| -| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device. | +| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device.| diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index 6e1eab82dbbd426d7e1facd48a0516d981658f28..ec63d11121dcd5138d11d7a2e1898833deaaf9c7 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -1,5 +1,6 @@ # Network Connection Management +The network connection management module provides basic network management capabilities. You can obtain the default active data network or the list of all active data networks, enable or disable the airplane mode, and obtain network capability information. > **NOTE** > @@ -79,7 +80,7 @@ Checks whether the default data network is activated. This API uses an asynchron ```js connection.hasDefaultNet(function (error, has) { console.log(JSON.stringify(error)) - console.log(has) + console.log('has: ' + has) }) ``` @@ -101,7 +102,7 @@ Checks whether the default data network is activated. This API uses a promise to ```js connection.hasDefaultNet().then(function (has) { - console.log(has) + console.log('has: ' + has) }) ``` @@ -167,7 +168,7 @@ Obtains connection properties of the network corresponding to given network hand | Name | Type | Mandatory| Description | | --------- | ------------------------------------------------------------ | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| | callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | Yes | Callback used to return the result. | **Example** @@ -195,7 +196,7 @@ Obtains connection properties of the network corresponding to **netHandle**. Thi | Name | Type | Mandatory| Description | | --------- | ----------------------- | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| **Return Value** @@ -227,7 +228,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th | Name | Type | Mandatory| Description | | --------- | --------------------------------------------------- | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| | callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | Yes | Callback used to return the result. | **Example** @@ -255,7 +256,7 @@ Obtains capability information of the network corresponding to **netHandle**. Th | Name | Type | Mandatory| Description | | --------- | ----------------------- | ---- | ---------------- | -| netHandle | [NetHandle](#nethandle) | Yes | Network handle.| +| netHandle | [NetHandle](#nethandle) | Yes | Handle of the data network.| **Return Value** @@ -446,6 +447,105 @@ connection.getAddressesByName(host).then(function (addresses) { }) ``` + +## connection.enableAirplaneMode + +enableAirplaneMode(callback: AsyncCallback\<void>): void + +Enables the airplane mode. This API uses an asynchronous callback to return the result. + +This is a system API. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +connection.enableAirplaneMode(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## connection.enableAirplaneMode + +enableAirplaneMode(): Promise\<void> + +Enables the airplane mode. This API uses a promise to return the result. + +This is a system API. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +connection.enableAirplaneMode().then(function (error) { + console.log(JSON.stringify(error)) +}) +``` + + +## connection.disableAirplaneMode + +disableAirplaneMode(callback: AsyncCallback\<void>): void + +Disables the airplane mode. This API uses an asynchronous callback to return the result. + +This is a system API. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | + +**Example** + +```js +connection.disableAirplaneMode(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## connection.disableAirplaneMode + +disableAirplaneMode(): Promise\<void> + +Disables the airplane mode. This API uses a promise to return the result. + +This is a system API. + +**System capability**: SystemCapability.Communication.NetManager.Core + +**Return value** + +| Type | Description | +| ------------------------------------------- | ----------------------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +```js +connection.disableAirplaneMode().then(function (error) { + console.log(JSON.stringify(error)) +}) +``` + + ## connection.createNetConnection createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection @@ -476,7 +576,7 @@ let netConnection = connection.createNetConnection() // Cellular network let netConnectionCellular = connection.createNetConnection({ netCapabilities: { - bearerTypes: [NetBearType.BEARER_CELLULAR] + bearerTypes: [connection.NetBearType.BEARER_CELLULAR] } }) ``` @@ -497,7 +597,7 @@ Registers a listener for **netAvailable** events. | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netAvailable**.<br>**netAvailable**: event indicating that the data network is available.| +| type | string | Yes | Event type. The value is fixed at **netAvailable**.<br>**netAvailable**: event indicating that the data network is available.| | callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. | **Example** @@ -520,7 +620,7 @@ Registers a listener for **netCapabilitiesChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that he network capabilities have changed.| +| type | string | Yes | Event type. The value is fixed at **netCapabilitiesChange**.<br>**netCapabilitiesChange**: event indicating that network capabilities have changed.| | callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | Yes | Callback used to return the result. | **Example** @@ -543,7 +643,7 @@ Registers a listener for **netConnectionPropertiesChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netConnectionPropertiesChange**.<br>**netConnectionPropertiesChange**: event indicating that network connection properties have changed.| +| type | string | Yes | Event type. The value is fixed at **netConnectionPropertiesChange**.<br>**netConnectionPropertiesChange**: event indicating that network connection properties have changed.| | callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | Yes | Callback used to return the result. | **Example** @@ -566,7 +666,7 @@ Registers a listener for **netBlockStatusChange** events. | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netBlockStatusChange**.<br>**netBlockStatusChange**: event indicating a change in the network blocking status.| +| type | string | Yes | Event type. The value is fixed at **netBlockStatusChange**.<br>**netBlockStatusChange**: event indicating a change in the network blocking status.| | callback | Callback<{ netHandle: [NetHandle](#nethandle), blocked: boolean }> | Yes | Callback used to return the result. | **Example** @@ -589,7 +689,7 @@ Registers a listener for **netLost** events. | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netLost**.<br>netLost: event indicating that the network is interrupted or normally disconnected.| +| type | string | Yes | Event type. The value is fixed at **netLost**.<br>netLost: event indicating that the network is interrupted or normally disconnected.| | callback | Callback\<[NetHandle](#nethandle)> | Yes | Callback used to return the result. | **Example** @@ -613,7 +713,7 @@ Registers a listener for **netUnavailable** events. | Name | Type | Mandatory| Description | | -------- | --------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value is fixed to **netUnavailable**.<br>**netUnavailable**: event indicating that the network is unavailable.| +| type | string | Yes | Event type. The value is fixed at **netUnavailable**.<br>**netUnavailable**: event indicating that the network is unavailable.| | callback | Callback\<void> | Yes | Callback used to return the result. | **Example** @@ -908,4 +1008,4 @@ Defines the network address. | ------- | ------ | ------------------------------ | | address | string | Network address. | | family | number | Address family identifier. The value is **1** for IPv4 and **2** for IPv6. The default value is **1**.| -| port | number | Port number. The value ranges from **0** to **65535**. | \ No newline at end of file +| port | number | Port number. The value ranges from **0** to **65535**. | diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md index b68d1dc35be314220feb88ba2d67a3429ce75c58..a6fcacc4333ab0aa48dae7cd8b629e1e77bb399f 100644 --- a/en/application-dev/reference/apis/js-apis-observer.md +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -1,5 +1,7 @@ # Observer +The observer module provides event subscription management functions. You can register or unregister an observer that listens for the following events: network status change, signal status change, call status change, cellular data connection status, uplink and downlink data flow status of cellular data services, and SIM status change. + >**NOTE** > >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. @@ -15,7 +17,7 @@ import observer from '@ohos.telephony.observer' on\(type: \'networkStateChange\', callback: Callback<NetworkState\>\): void; -Registers an observer for network status change events. This API uses an asynchronous callback to return the execution result. +Registers an observer for network status change events. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -41,7 +43,7 @@ observer.on('networkStateChange', data =>{ on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callback<NetworkState\>\): void; -Registers an observer for network status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the execution result. +Registers an observer for network status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -68,9 +70,7 @@ observer.on('networkStateChange', {slotId: 0}, data =>{ off\(type: \'networkStateChange\', callback?: Callback<NetworkState\>\): void; -Unregisters the observer for network status change events. This API uses an asynchronous callback to return the execution result. - -**Required permission**: ohos.permission.GET_NETWORK_INFO +Unregisters the observer for network status change events. This API uses an asynchronous callback to return the result. >**NOTE** > @@ -101,7 +101,7 @@ observer.off('networkStateChange'); on\(type: \'signalInfoChange\', callback: Callback<Array<SignalInformation\>\>): void; -Registers an observer for signal status change events. This API uses an asynchronous callback to return the execution result. +Registers an observer for signal status change events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -125,7 +125,7 @@ observer.on('signalInfoChange', data =>{ on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback<Array<SignalInformation\>\>): void; -Registers an observer for signal status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the execution result. +Registers an observer for signal status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -150,7 +150,7 @@ observer.on('signalInfoChange', {slotId: 0}, data =>{ off\(type: \'signalInfoChange\', callback?: Callback<Array<SignalInformation\>\>): void; -Unregisters the observer for signal status change events. This API uses an asynchronous callback to return the execution result. +Unregisters the observer for signal status change events. This API uses an asynchronous callback to return the result. >**NOTE** > @@ -182,9 +182,7 @@ observer.off('signalInfoChange'); on(type: 'callStateChange', callback: Callback\<{ state: CallState, number: string }\>): void; -Registers an observer for call status change events. This API uses an asynchronous callback to return the execution result. - -**Required permission**: ohos.permission.READ_CALL_LOG +Registers an observer for call status change events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -208,9 +206,7 @@ observer.on('callStateChange', value =>{ on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ state:CallState, number: string }>): void; -Registers an observer for call status change events. This API uses an asynchronous callback to return the execution result. - -**Required permission**: ohos.permission.READ_CALL_LOG +Registers an observer for call status change events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -235,9 +231,7 @@ observer.on('callStateChange', {slotId: 0}, value =>{ off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: string }>): void; -Unregisters the observer for call status change events. This API uses an asynchronous callback to return the execution result. - -**Required permission**: ohos.permission.READ_CALL_LOG +Unregisters the observer for call status change events. This API uses an asynchronous callback to return the result. >**NOTE** > @@ -269,7 +263,7 @@ observer.off('callStateChange'); on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: DataConnectState, network: RatType}\>\): void; -Registers an observer for connection status change events of the cellular data link. This API uses an asynchronous callback to return the result. +Registers an observer for connection status change events of the cellular data connection.This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -277,7 +271,7 @@ Registers an observer for connection status change events of the cellular data l | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Connection status change event of the cellular data link. | +| type | string | Yes | Connection status change event of the cellular data connection. | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| **Example** @@ -293,7 +287,7 @@ observer.on('cellularDataConnectionStateChange', value =>{ on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, callback: Callback\<{ state: DataConnectState, network: RatType }\>\): void; -Registers an observer for connection status change events of the cellular data link over the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Registers an observer for connection status change events of the cellular data connection over the SIM card in the specified slot. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.StateRegistry @@ -301,7 +295,7 @@ Registers an observer for connection status change events of the cellular data l | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Connection status change event of the cellular data link. | +| type | string | Yes | Connection status change event of the cellular data connection. | | slotId | number | Yes | Card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2 | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | Yes | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| @@ -318,7 +312,7 @@ observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: DataConnectState, network: RatType}\>\): void; -Unregisters the observer for connection status change events of the cellular data link. This API uses an asynchronous callback to return the result. +Unregisters the observer for connection status change events of the cellular data connection.This API uses an asynchronous callback to return the result. >**NOTE** > @@ -330,7 +324,7 @@ Unregisters the observer for connection status change events of the cellular dat | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Connection status change event of the cellular data link. | +| type | string | Yes | Connection status change event of the cellular data connection. | | callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#dataconnectstate), network: [RatType](js-apis-radio.md#radiotechnology) }\> | No | Callback used to return the result. For details, see [DataConnectState](js-apis-telephony-data.md#dataconnectstate) and [RadioTechnology](js-apis-radio.md#radiotechnology).| **Example** diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index 7135d5666d3884667c0d7dee8ac98d832bf410ab..e1dbb5f4a54b3936dc4b52e76ab5ad0fc0a39265 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -20,7 +20,7 @@ Obtains an **AccountManager** instance. **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | --------------------------------- | ------------------------ | | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| @@ -92,7 +92,7 @@ This is a system API and cannot be called by third-party applications. | ------- | ------ | ---- | -------------------- | | localId | number | Yes | ID of the OS account to activate.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :---------------------------------- | @@ -141,7 +141,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :--------------------- | :----------------------------------------------------------- | @@ -202,7 +202,7 @@ Checks whether an OS account is activated. This API uses a promise to return the | ------- | ------ | ---- | ------------ | | localId | number | Yes | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :--------------------- | :----------------------------------------------------------- | @@ -266,7 +266,7 @@ Checks whether the specified constraint is enabled for an OS account. This API u | localId | number | Yes | ID of the target OS account. | | constraint | string | Yes | [Constraint](#constraints) specified.| -**Return Value** +**Return value** | Type | Description | | :--------------------- | :----------------------------------------------------------- | @@ -316,7 +316,7 @@ Checks whether this OS account is a test account. This API uses a promise to ret **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :--------------------- | :----------------------------------------------------------- | @@ -400,7 +400,7 @@ Checks whether an OS account has been verified. This API uses a promise to retur | ------- | ------ | ---- | ------------------ | | localId | number | No | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :--------------------- | :----------------------------------------------------------- | @@ -467,7 +467,7 @@ This is a system API and cannot be called by third-party applications. | ------- | ------ | ---- | -------------------- | | localId | number | Yes | ID of the OS account to remove.| -**Return Value** +**Return value** | Type | Description | | :------------------ | :---------------------------------- | @@ -540,7 +540,7 @@ This is a system API and cannot be called by third-party applications. | constraints | Array<string> | Yes | List of [constraints](#constraints) to set or remove.| | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :---------------------------------- | @@ -608,7 +608,7 @@ This is a system API and cannot be called by third-party applications. | localId | number | Yes | ID of the target OS account.| | localName | string | Yes | Account name to set. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :---------------------------------- | @@ -663,7 +663,7 @@ Obtains the number of OS accounts created. This API uses a promise to return the **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -712,7 +712,7 @@ Obtains the ID of the OS account to which the current process belongs. This API **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -769,7 +769,7 @@ Obtains the OS account ID based on the process UID. This API uses a promise to r | ------ | ------ | ---- | --------- | | uid | number | Yes | Process UID.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -831,7 +831,7 @@ Obtains the OS account ID based on domain account information. This API uses a p | ---------- | --------------------------------------- | ---- | ------------ | | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -885,7 +885,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -946,7 +946,7 @@ Obtains all constraints enabled for an OS account. This API uses a promise to re | ------- | ------ | ---- | ------------ | | localId | number | Yes | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :--------------------------------- | :----------------------------------------------------------- | @@ -1004,7 +1004,7 @@ This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS -**Return Value** +**Return value** | Type | Description | | :---------------------------------------------------------- | :----------------------------------------------------------- | @@ -1056,7 +1056,7 @@ Obtains information about all activated OS accounts. This API uses a promise to **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :--------------------------------- | :----------------------------------------------------------- | @@ -1122,7 +1122,7 @@ This is a system API and cannot be called by third-party applications. | localName | string | Yes | Name of the OS account to create.| | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| -**Return Value** +**Return value** | Type | Description | | :--------------------------------------------- | :----------------------------------------------------------- | @@ -1189,7 +1189,7 @@ This is a system API and cannot be called by third-party applications. | type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.| | domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. | -**Return Value** +**Return value** | Type | Description | | :--------------------------------------------- | :----------------------------------------------------------- | @@ -1243,7 +1243,7 @@ Obtains information about the OS account to which the current process belongs. T **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :--------------------------------------------- | :----------------------------------------------------------- | @@ -1308,7 +1308,7 @@ This is a system API and cannot be called by third-party applications. | ------- | ------ | ---- | -------------------- | | localId | number | Yes | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :--------------------------------------------- | :----------------------------------------------------------- | @@ -1358,7 +1358,7 @@ Obtains the type of the OS account to which the current process belongs. This AP **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :--------------------------------------------- | :----------------------------------------------------------- | @@ -1411,7 +1411,7 @@ Obtains the ID of this distributed virtual device. This API uses a promise to re **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1476,7 +1476,7 @@ This is a system API and cannot be called by third-party applications. | ------- | ------ | ---- | ------------ | | localId | number | Yes | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1547,7 +1547,7 @@ This is a system API and cannot be called by third-party applications. | localId | number | Yes | ID of the target OS account.| | photo | string | Yes | Profile photo information. | -**Return Value** +**Return value** | Type | Description | | :------------------ | :---------------------------------- | @@ -1609,7 +1609,7 @@ Obtains the OS account ID based on the SN. This API uses a promise to return the | ------------ | ------ | ---- | ---------- | | serialNumber | number | Yes | Account SN.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1667,7 +1667,7 @@ Obtains the SN of an OS account based on the account ID. This API uses a promise | ------- | ------ | ---- | ------------ | | localId | number | Yes | ID of the target OS account.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1787,7 +1787,7 @@ This is a system API and cannot be called by third-party applications. | ------- | ------ | ---- | ------------ | | uid | number | Yes | Process UID.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1836,7 +1836,7 @@ This is a system API and cannot be called by third-party applications. **System capability**: SystemCapability.Account.OsAccount -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | @@ -1898,7 +1898,7 @@ This is a system API and cannot be called by third-party applications. | localId | number | Yes | ID of the target OS account.| | constraint | string | Yes | Name of the [constraint](#constraints) to query.| -**Return Value** +**Return value** | Type | Description | | :-------------------- | :----------------------------------------------------------- | diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index 12f2fd80bdd78b13c59b1684f080ac2798a9c436..ac0152abec3ed642d7e0cc61af6aa2ab5d7c5e3f 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -1,4 +1,6 @@ -# ParticleAbility +# particleAbility + +The **particleAbility** module provides APIs for Service abilities. You can use the APIs to start and terminate a Particle ability, obtain a **dataAbilityHelper** object, connect the current ability to a specific Service ability, and disconnect the current ability from a specific Service ability. > **NOTE** > diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md index f0d3ed2f0ce6e5e84883f38b7d9441b74dae5ae4..d133b1b37776187ac1120f42ead17e98273f0db4 100644 --- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -1,19 +1,13 @@ # PermissionRequestResult +The **PermissionRequestResult** module provides the result of a permission request. + > **NOTE** > -> 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. +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Provides the permission request result. - -## Modules to Import - -```js -import Ability from '@ohos.application.Ability' -``` - -## How to Use +## Usage The permission request result is obtained through an **AbilityStage** instance. diff --git a/en/application-dev/reference/apis/js-apis-privacyManager.md b/en/application-dev/reference/apis/js-apis-privacyManager.md index e06a5536a8754922e0e82d14162296124f498665..42cf66fea697004eafe45bc775146e0aa77ce8ad 100644 --- a/en/application-dev/reference/apis/js-apis-privacyManager.md +++ b/en/application-dev/reference/apis/js-apis-privacyManager.md @@ -1,11 +1,11 @@ # Privacy Management -Provides APIs for privacy management, such as management of permission usage records. +The **PrivacyManager** module provides APIs for privacy management, such as management of permission usage records. > **NOTE** -> -> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> - The APIs of this module are system APIs and cannot be called by third-party applications. +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module are system APIs and cannot be called by third-party applications. ## Modules to Import @@ -19,7 +19,6 @@ import privacyManager from '@ohos.privacyManager'; addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number): Promise<number> Adds a permission usage record when an application protected by the permission is called by another service or application. This API uses a promise to return the result. - The permission usage record includes the application identity of the invoker, name of the permission used, and number of successful and failed accesses to the application. **Required permissions**: ohos.permission.PERMISSION_USED_STATS (available only to system applications) @@ -41,10 +40,6 @@ The permission usage record includes the application identity of the invoker, na | :------------ | :---------------------------------- | | Promise<number> | Promise used to return the result. If **0** is returned, the record is added successfully. If **-1** is returned, the record fails to be added.| -``` - -``` - **Example** ```js @@ -59,7 +54,6 @@ privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number, callback: AsyncCallback<number>): void Adds a permission usage record when an application protected by the permission is called by another service or application. This API uses an asynchronous callback to return the result. - The permission usage record includes the application identity of the invoker, name of the permission used, and number of successful and failed accesses to the application. **Required permissions**: ohos.permission.PERMISSION_USED_STATS (available only to system applications) @@ -202,7 +196,7 @@ Represents the permission usage records of all applications. ## BundleUsedRecord -Represents the application access records of an application. +Represents the permission access records of an application. **System capability**: SystemCapability.Security.AccessToken @@ -212,11 +206,11 @@ Represents the application access records of an application. | isRemote | boolean | No | Whether the token ID belongs to a remote device. The default value is **false**.| | deviceId | string | No | ID of the device hosting the target application. | | bundleName | string | No | Bundle name of the target application.| -| permissionRecords | Array<[PermissionUsedRecord](#PermissionUsedRecord)> | No | Permission usage records of the specified application obtained. | +| permissionRecords | Array<[PermissionUsedRecord](#PermissionUsedRecord)> | No | Permission usage records of the target application. | ## PermissionUsedRecord -Represents the access records of a permission. +Represents the usage records of a permission. **System capability**: SystemCapability.Security.AccessToken @@ -225,8 +219,8 @@ Represents the access records of a permission. | permissionName | string | No | Name of the permission. | | accessCount | number | No | Total number of times that the permission is accessed.| | rejectCount | number | No | Total number of times that the access to the permission is rejected.| -| lastAccessTime | number | No | Last time when the permission was accessed, in ms.| -| lastRejectTime | number | No | Last time when the access to the permission was rejected, in ms.| +| lastAccessTime | number | No | Last time when the permission was accessed, accurate to ms.| +| lastRejectTime | number | No | Last time when the access to the permission was rejected, accurate to ms.| | lastAccessDuration | number | No | Last access duration, in ms.| | accessRecords | Array<[UsedRecordDetail](#usedrecorddetail)> | No | Access records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. | | rejectRecords | Array<[UsedRecordDetail](#usedrecorddetail)> | No | Rejected records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. | diff --git a/en/application-dev/reference/apis/js-apis-process.md b/en/application-dev/reference/apis/js-apis-process.md index e73c4fe303ebeaac19274d5214085fb8646fa651..98d55f53e7f3c51f33fc9505fccf33df846c9ef6 100755 --- a/en/application-dev/reference/apis/js-apis-process.md +++ b/en/application-dev/reference/apis/js-apis-process.md @@ -1,6 +1,7 @@ # Obtaining Process Information ->  **NOTE** +> **NOTE** +> > 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. @@ -92,7 +93,7 @@ This is a system API and cannot be called by third-party applications. ```js var child = process.runCmd('ls'); var result = child.wait(); -child.getOutput.then(val=>{ +child.getOutput().then(val=>{ console.log("child.getOutput = " + val); }) ``` @@ -119,7 +120,7 @@ This is a system API and cannot be called by third-party applications. ```js var child = process.runCmd('madir test.text'); var result = child.wait(); -child.getErrorOutput.then(val=>{ +child.getErrorOutput().then(val=>{ console.log("child.getErrorOutput= " + val); }) ``` @@ -286,7 +287,7 @@ Obtains the thread priority based on the specified TID. **Example** ```js -var tid = process.getTid(); +var tid = process.tid; var pres = process.getThreadPriority(tid); ``` @@ -409,7 +410,7 @@ This is a system API and cannot be called by third-party applications. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | timeout | number | No| Maximum running time (in ms) of the child process. When the running time of the child process exceeds the value of this parameter, the parent process sends a **killSignal** to the child process to terminate it. The default value is **0**.| -| killSignal | number \| string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.| +| killSignal | number \| string | No| Signal sent to the child process when the running time of a child process exceeds the timeout period. The default value is **SIGTERM**.| | maxBuffer | number | No| Maximum buffer size for the standard input and output of the child process. When the size is exceeded, the child process will be terminated. The default value is **1024 \* 1024**.| **Return value** @@ -617,5 +618,5 @@ Sends a signal to the specified process to terminate it. ```js var pres = process.pid -var result = that.kill(28, pres) +var result = process.kill(28, pres) ``` diff --git a/en/application-dev/reference/apis/js-apis-processrunninginfo.md b/en/application-dev/reference/apis/js-apis-processrunninginfo.md index 24fb9f15a5427a450ea907bb296c43f3d3f55a91..e26e01dc8f8d7fbb6472d11217f1156ceb1b41b8 100644 --- a/en/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -1,16 +1,10 @@ # ProcessRunningInfo +The **ProcessRunningInfo** module provides process running information. + > **NOTE** > -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - -Provides process running information. - -## Modules to Import - -```js -import appManager from '@ohos.application.appManager' -``` +> 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. ## Usage @@ -23,7 +17,6 @@ appManager.getProcessRunningInfos((error,data) => { }); ``` - ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index b8cbdcc23c001aa24aebe7dfaae2ca06a0fae706..5b371ea07267732eb69de7676cab7f6057954275 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -1,5 +1,7 @@ # Radio +The radio module provides basic network search management functions. You can obtain the radio access technology (RAT) used in the CS and PS domains, network status, current network selection mode, ISO country code of the registered network, ID of the slot in which the primary card is located, list of signal strengths of the registered network, carrier name, and IMEI, MEID, and unique device ID of the SIM card in the specified slot. Besides, you can check whether the current device supports 5G\(NR\) and whether the radio service is enabled on the primary SIM card. + >**NOTE** > >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. @@ -15,7 +17,7 @@ import radio from '@ohos.telephony.radio' getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>\): void -Obtains the radio access technology (RAT) used by the CS and PS domains for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. +Obtains the RAT used in the CS and PS domains for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -42,7 +44,7 @@ radio.getRadioTech(slotId, (err, data) =>{ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\> -Obtains the RAT used by the CS and PS domains for the SIM card in the specified slot. This API uses a promise to return the result. +Obtains the RAT used in the CS and PS domains for the SIM card in the specified slot. This API uses a promise to return the result. **Required permission**: ohos.permission.GET_NETWORK_INFO @@ -573,7 +575,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------------------------- | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| -| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| +| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | **Example** @@ -607,7 +609,7 @@ This is a system API. | Type | Description | | --------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index 335e31cdb21bacd975db26b726f503c0a44e431d..3abc771bff725718ccd5df3eb0334331701faea4 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -2,7 +2,8 @@ The resource management module provides APIs to obtain information about the current device configuration (including the language, region, screen direction, and MCC/MNC) and device capability (including the device type and resolution). -> **NOTE**<br> +> **NOTE** +> > 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. @@ -12,9 +13,9 @@ The resource management module provides APIs to obtain information about the cur import resourceManager from '@ohos.resourceManager'; ``` -## Usage +## How to Use -Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its APIs without first importing the required bundle. This method, however, is not applicable to the FA model. +Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This method, however, is not applicable to the FA model. ``` this.context.resourceManager; @@ -26,14 +27,14 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void Obtains the **ResourceManager** object of this application. This API uses an asynchronous callback to return the result. -This API is used only in the FA model. +This API can be used only in the FA model. **System capability**: SystemCapability.Global.ResourceManager **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------------------------- | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the result.| **Example** ``` @@ -59,7 +60,7 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage Obtains the **ResourceManager** object of an application based on the specified bundle name. This API uses an asynchronous callback to return the result. -This API is used only in the FA model. +This API can be used only in the FA model. **System capability**: SystemCapability.Global.ResourceManager @@ -67,7 +68,7 @@ This API is used only in the FA model. | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ----------------------------- | | bundleName | string | Yes | Bundle name of the target application. | -| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the result.| **Example** ``` @@ -82,7 +83,7 @@ getResourceManager(): Promise<ResourceManager> Obtains the **ResourceManager** object of this application. This API uses a promise to return the result. -This API is used only in the FA model. +This API can be used only in the FA model. **System capability**: SystemCapability.Global.ResourceManager @@ -113,7 +114,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> Obtains the **ResourceManager** object of an application based on the specified bundle name. This API uses a promise to return the result. -This API is used only in the FA model. +This API can be used only in the FA model. **System capability**: SystemCapability.Global.ResourceManager @@ -229,21 +230,34 @@ resourceManager.getResourceManager((error, mgr) => { ## RawFileDescriptor<sup>8+</sup> -Defines the descriptor information of the raw file.<br> +Defines the descriptor of the raw file.<br> **System capability**: SystemCapability.Global.ResourceManager | Name | Type | Description | | ------ | ------ | ------------------ | -| fd | number | Descriptor of a raw file.| -| offset | number | Offset to the start position of the raw file. | +| fd | number | Descriptor of the raw file.| +| offset | number | Start offset of the raw file. | | length | number | Length of the raw file. | +## Resource<sup>9+</sup> + +Defines the resource information of an application. + +**System capability**: SystemCapability.Global.ResourceManager + +| Name | Type | Description | +| ------ | ------ | ------------------ | +| bundleName | string | Bundle name of the application.| +| moduleName | string | Module name of the application. | +| id | number | Resource ID. | + ## ResourceManager Defines the capability of accessing application resources. -> **NOTE**<br> +> **NOTE** +> > - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. > > - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**. @@ -261,7 +275,7 @@ Obtains the string corresponding to the specified resource ID. This API uses an | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | --------------- | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` @@ -307,6 +321,68 @@ Obtains the string corresponding to the specified resource ID. This API uses a p ``` +### getString<sup>9+</sup> + +getString(resource: Resource, callback: AsyncCallback<string>): void + +Obtains the string corresponding to the specified resource object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | --------------- | +| resource | [Resource](#resource9) | Yes | Resource object. | +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.string.test').id + }; + this.context.resourceManager.getString(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + ``` + +### getString<sup>9+</sup> + +getString(resource: Resource): Promise<string> + +Obtains the string corresponding to the specified resource object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| Promise<string> | Promise used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.string.test').id + }; + this.context.resourceManager.getString(resource).then(value => { + let str = value; + }).catch(error => { + console.log("getstring promise error is " + error); + }); + ``` + ### getStringArray getStringArray(resId: number, callback: AsyncCallback<Array<string>>): void @@ -319,7 +395,7 @@ Obtains the string array corresponding to the specified resource ID. This API us | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------------- | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the result.| **Example** ``` @@ -364,6 +440,67 @@ Obtains the string array corresponding to the specified resource ID. This API us }); ``` +### getStringArray<sup>9+</sup> + +getStringArray(resource: Resource, callback: AsyncCallback<Array<string>>): void + +Obtains the string array corresponding to the specified resource object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | --------------- | +| resource | [Resource](#resource9) | Yes | Resource object. | +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.strarray.test').id + }; + this.context.resourceManager.getStringArray(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let strArray = value; + } + }); + ``` + +### getStringArray<sup>9+</sup> + +getStringArray(resource: Resource): Promise<Array<string>> + +Obtains the string array corresponding to the specified resource object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| Promise<Array<string>> | Promise used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.strarray.test').id + }; + this.context.resourceManager.getStringArray(resource).then(value => { + let strArray = value; + }).catch(error => { + console.log("getStringArray promise error is " + error); + }); + ``` ### getMedia @@ -377,7 +514,7 @@ Obtains the content of the media file corresponding to the specified resource ID | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ------------------ | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the result.| **Example** ``` @@ -422,6 +559,67 @@ Obtains the content of the media file corresponding to the specified resource ID }); ``` +### getMedia<sup>9+</sup> + +getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void + +Obtains the content of the media file corresponding to the specified resource object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | --------------- | +| resource | [Resource](#resource9) | Yes | Resource object. | +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.media.test').id + }; + this.context.resourceManager.getMedia(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + ``` + +### getMedia<sup>9+</sup> + +getMedia(resource: Resource): Promise<Uint8Array> + +Obtains the content of the media file corresponding to the specified resource object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| Promise<Uint8Array> | Promise used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.media.test').id + }; + this.context.resourceManager.getMedia(resource).then(value => { + let media = value; + }).catch(error => { + console.log("getMedia promise error is " + error); + }); + ``` ### getMediaBase64 @@ -435,7 +633,7 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ------------------------ | | resId | number | Yes | Resource ID. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` @@ -480,6 +678,68 @@ Obtains the Base64 code of the image corresponding to the specified resource ID. }); ``` +### getMediaBase64<sup>9+</sup> + +getMediaBase64(resource: Resource, callback: AsyncCallback<string>): void + +Obtains the Base64 code of the image corresponding to the specified resource object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ------------------------ | +| resource | [Resource](#resource9) | Yes | Resource object. | +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.media.test').id + }; + this.context.resourceManager.getMediaBase64(resource, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let media = value; + } + }); + ``` + +### getMediaBase64<sup>9+</sup> + +getMediaBase64(resource: Resource): Promise<string> + +Obtains the Base64 code of the image corresponding to the specified resource object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | -------------------- | +| Promise<string> | Promise used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.media.test').id + }; + this.context.resourceManager.getMediaBase64(resource).then(value => { + let media = value; + }).catch(error => { + console.log("getMediaBase64 promise error is " + error); + }); + ``` + ### getConfiguration @@ -492,7 +752,7 @@ Obtains the device configuration. This API uses an asynchronous callback to retu **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ------------------------- | -| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<[Configuration](#configuration)> | Yes | Callback used to return the result.| **Example** ``` @@ -546,7 +806,7 @@ Obtains the device capability. This API uses an asynchronous callback to return **Parameters** | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<[DeviceCapability](#devicecapability)> | Yes | Callback used to return the result.| **Example** ``` @@ -593,7 +853,7 @@ Obtains the device capability. This API uses a promise to return the result. getPluralString(resId: number, num: number, callback: AsyncCallback<string>): void -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. +Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -601,8 +861,8 @@ Obtains the specified number of singular-plural strings corresponding to the spe | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ------------------------------- | | resId | number | Yes | Resource ID. | -| num | number | Yes | Number that determines the plural or singular form. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| num | number | Yes | Number. | +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` @@ -622,7 +882,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe getPluralString(resId: number, num: number): Promise<string> -Obtains the specified number of singular-plural strings corresponding to the specified resource ID. This API uses a promise to return the result. +Obtains the singular-plural string corresponding to the specified resource ID based on the specified number. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -630,7 +890,7 @@ Obtains the specified number of singular-plural strings corresponding to the spe | Name | Type | Mandatory | Description | | ----- | ------ | ---- | ----- | | resId | number | Yes | Resource ID.| -| num | number | Yes | Number that determines the plural or singular form. | +| num | number | Yes | Number. | **Return value** | Type | Description | @@ -648,6 +908,70 @@ Obtains the specified number of singular-plural strings corresponding to the spe }); ``` +### getPluralString<sup>9+</sup> + +getPluralString(resource: Resource, num: number, callback: AsyncCallback<string>): void + +Obtains the singular-plural string corresponding to the specified resource object based on the specified number. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ------------------------------- | +| resource | [Resource](#resource9) | Yes | Resource object. | +| num | number | Yes | Number. | +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.plural.test').id + }; + this.context.resourceManager.getPluralString(resource, 1, (error, value) => { + if (error != null) { + console.log("error is " + error); + } else { + let str = value; + } + }); + ``` + +### getPluralString<sup>9+</sup> + +getPluralString(resource: Resource, num: number): Promise<string> + +Obtains the singular-plural string corresponding to the specified resource object based on the specified number. This API uses a promise to return the result. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| +| num | number | Yes | Number. | + +**Return value** +| Type | Description | +| --------------------- | ------------------------- | +| Promise<string> | Promise used to return the result.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.plural.test').id + }; + this.context.resourceManager.getPluralString(resource, 1).then(value => { + let str = value; + }).catch(error => { + console.log("getPluralString promise error is " + error); + }); + ``` + ### getRawFile<sup>8+</sup> getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void @@ -660,7 +984,7 @@ Obtains the content of the raw file in the **resources/rawfile** directory. This | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ----------------------- | | path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the result.| **Example** ``` @@ -716,7 +1040,7 @@ Obtains the descriptor of the raw file in the **resources/rawfile** directory. T | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | -------------------------------- | | path | string | Yes | Path of the raw file. | -| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | Yes | Callback used to return the result.| **Example** ``` @@ -776,7 +1100,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th | Name | Type | Mandatory | Description | | -------- | ------------------------- | ---- | ----------- | | path | string | Yes | Path of the raw file.| -| callback | AsyncCallback<void> | Yes | Asynchronous callback used to return the result. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ``` @@ -805,7 +1129,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th **Return value** | Type | Description | | ------------------- | ---- | -| Promise<void> | No value is returned.| +| Promise<void> | Promise that returns no value.| **Example** ``` @@ -822,7 +1146,7 @@ Closes the descriptor of the raw file in the **resources/rawfile** directory. Th release() -Releases the created **resourceManager**. +Releases a created **resourceManager** object. **System capability**: SystemCapability.Global.ResourceManager @@ -845,11 +1169,11 @@ Obtains the string corresponding to the specified resource name. This API uses a | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | --------------- | | resName | string | Yes | Resource name. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` - resourceManager.getStringByName("test", (error, value) => { + this.context.resourceManager.getStringByName("test", (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -874,11 +1198,11 @@ Obtains the string corresponding to the specified resource name. This API uses a **Return value** | Type | Description | | --------------------- | ----------- | -| Promise<string> | String corresponding to the resource name.| +| Promise<string> | Promise used to return the result.| **Example** ``` - resourceManager.getStringByName("test").then(value => { + this.context.resourceManager.getStringByName("test").then(value => { let string = value; }).catch(error => { console.log("getStringByName promise error is " + error); @@ -897,11 +1221,11 @@ Obtains the string array corresponding to the specified resource name. This API | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ----------------- | | resName | string | Yes | Resource name. | -| callback | AsyncCallback<Array<string>> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<Array<string>> | Yes | Callback used to return the result.| **Example** ``` - resourceManager.getStringArrayByName("test", (error, value) => { + this.context.resourceManager.getStringArrayByName("test", (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -930,7 +1254,7 @@ Obtains the string array corresponding to the specified resource name. This API **Example** ``` - resourceManager.getStringArrayByName("test").then(value => { + this.context.resourceManager.getStringArrayByName("test").then(value => { let strArray = value; }).catch(error => { console.log("getStringArrayByName promise error is " + error); @@ -949,11 +1273,11 @@ Obtains the content of the media file corresponding to the specified resource na | Name | Type | Mandatory | Description | | -------- | ------------------------------- | ---- | ------------------ | | resName | string | Yes | Resource name. | -| callback | AsyncCallback<Uint8Array> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<Uint8Array> | Yes | Callback used to return the result.| **Example** ``` - resourceManager.getMediaByName("test", (error, value) => { + this.context.resourceManager.getMediaByName("test", (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -982,7 +1306,7 @@ Obtains the content of the media file corresponding to the specified resource na **Example** ``` - resourceManager.getMediaByName("test").then(value => { + this.context.resourceManager.getMediaByName("test").then(value => { let media = value; }).catch(error => { console.log("getMediaByName promise error is " + error); @@ -1001,11 +1325,11 @@ Obtains the Base64 code of the image corresponding to the specified resource nam | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ------------------------ | | resName | string | Yes | Resource name. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` - resourceManager.getMediaBase64ByName("test", (error, value) => { + this.context.resourceManager.getMediaBase64ByName("test", (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -1034,7 +1358,7 @@ Obtains the Base64 code of the image corresponding to the specified resource nam **Example** ``` - resourceManager.getMediaByName("test").then(value => { + this.context.resourceManager.getMediaBase64ByName("test").then(value => { let media = value; }).catch(error => { console.log("getMediaBase64ByName promise error is " + error); @@ -1045,7 +1369,7 @@ Obtains the Base64 code of the image corresponding to the specified resource nam getPluralStringByName(resName: string, num: number, callback: AsyncCallback<string>): void -Obtains the plural string corresponding to the specified resource name. This API uses an asynchronous callback to return the result. +Obtains the plural string corresponding to the specified resource name based on the specified number. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -1053,12 +1377,12 @@ Obtains the plural string corresponding to the specified resource name. This API | Name | Type | Mandatory | Description | | -------- | --------------------------- | ---- | ------------------------------- | | resName | string | Yes | Resource name. | -| num | number | Yes | Number that determines the plural or singular form. | -| callback | AsyncCallback<string> | Yes | Asynchronous callback used to return the result.| +| num | number | Yes | Number. | +| callback | AsyncCallback<string> | Yes | Callback used to return the result.| **Example** ``` - resourceManager.getPluralStringByName("test", 1, (error, value) => { + this.context.resourceManager.getPluralStringByName("test", 1, (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -1071,7 +1395,7 @@ Obtains the plural string corresponding to the specified resource name. This API getPluralStringByName(resName: string, num: number): Promise<string> -Obtains the plural string corresponding to the specified resource name. This API uses a promise to return the result. +Obtains the plural string corresponding to the specified resource name based on the specified number. This API uses a promise to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -1079,7 +1403,7 @@ Obtains the plural string corresponding to the specified resource name. This API | Name | Type | Mandatory | Description | | ------- | ------ | ---- | ----- | | resName | string | Yes | Resource name.| -| num | number | Yes | Number that determines the plural or singular form. | +| num | number | Yes | Number. | **Return value** | Type | Description | @@ -1088,7 +1412,7 @@ Obtains the plural string corresponding to the specified resource name. This API **Example** ``` - resourceManager.getPluralStringByName("test", 1).then(value => { + this.context.resourceManager.getPluralStringByName("test", 1).then(value => { let str = value; }).catch(error => { console.log("getPluralStringByName promise error is " + error); @@ -1115,7 +1439,35 @@ Obtains the string corresponding to the specified resource ID. This API returns **Example** ``` - resourceManager.getStringSync($r('app.string.test').id); + this.context.resourceManager.getStringSync($r('app.string.test').id); + ``` + +### getStringSync<sup>9+</sup> + +getStringSync(resource: Resource): string + +Obtains the string corresponding to the specified resource object. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| string | String corresponding to the resource object.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.string.test').id + }; + this.context.resourceManager.getStringSync(resource); ``` ### getStringByNameSync<sup>9+</sup> @@ -1138,10 +1490,10 @@ Obtains the string corresponding to the specified resource name. This API return **Example** ``` - resourceManager.getStringByNameSync("test"); + this.context.resourceManager.getStringByNameSync("test"); ``` - ### getBoolean<sup>9+</sup> +### getBoolean<sup>9+</sup> getBoolean(resId: number): boolean @@ -1161,7 +1513,34 @@ Obtains the Boolean result corresponding to the specified resource ID. This API **Example** ``` - resourceManager.getBoolean($r('app.boolean.boolean_test').id); + this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id); + ``` +### getBoolean<sup>9+</sup> + +getBoolean(resource: Resource): boolean + +Obtains the Boolean result corresponding to the specified resource object. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| boolean | Boolean result corresponding to the specified resource object.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.boolean.boolean_test').id + }; + this.context.resourceManager.getBoolean(resource); ``` ### getBooleanByName<sup>9+</sup> @@ -1184,10 +1563,10 @@ Obtains the Boolean result corresponding to the specified resource name. This AP **Example** ``` - resourceManager.getBooleanByName("boolean_test"); + this.context.resourceManager.getBooleanByName("boolean_test"); ``` - ### getNumber<sup>9+</sup> +### getNumber<sup>9+</sup> getNumber(resId: number): number @@ -1207,8 +1586,36 @@ Obtains the integer or float value corresponding to the specified resource ID. T **Example** ``` - resourceManager.getNumber($r('app.integer.integer_test').id); - resourceManager.getNumber($r('app.float.float_test').id); + this.context.resourceManager.getNumber($r('app.integer.integer_test').id); + this.context.resourceManager.getNumber($r('app.float.float_test').id); + ``` + +### getNumber<sup>9+</sup> + +getNumber(resource: Resource): number + +Obtains the integer or float value corresponding to the specified resource object. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resource | [Resource](#resource9) | Yes | Resource object.| + +**Return value** +| Type | Description | +| --------------------- | ----------- | +| number | Integer or float value corresponding to the specified resource object.| + +**Example** + ``` + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.integer.integer_test').id + }; + this.context.resourceManager.getNumber(resource); ``` ### getNumberByName<sup>9+</sup> @@ -1231,6 +1638,6 @@ Obtains the integer or float value corresponding to the specified resource name. **Example** ``` - resourceManager.getNumberByName("integer_test"); - resourceManager.getNumberByName("float_test"); + this.context.resourceManager.getNumberByName("integer_test"); + this.context.resourceManager.getNumberByName("float_test"); ``` diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md index 40076077bd258dab549dbcb46e16a7137961c107..ac9435450c7e47d70deb11ed0a5b7249eea8f368 100644 --- a/en/application-dev/reference/apis/js-apis-router.md +++ b/en/application-dev/reference/apis/js-apis-router.md @@ -1,9 +1,12 @@ # Page Routing +The **Router** module provides APIs to access pages through URLs. You can use the APIs to navigate to a specified page in an application, replace the current page with another one in an application, and return to the previous page or a specified page. + > **NOTE** > > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase. +> +> - Page routing APIs can be invoked only after page rendering is complete. Do not call these APIs in **onInit** and **onReady** when the page is still in the rendering phase. ## Modules to Import @@ -11,10 +14,6 @@ import router from '@ohos.router' ``` -## Required Permissions - -None. - ## router.push push(options: RouterOptions): void @@ -24,44 +23,50 @@ Navigates to a specified page in the application. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters.| **Example** - ```js - // Current page - export default { - pushPage() { - router.push({ - url: 'pages/routerpage2/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] - }, - }, - }); - } - } - ``` - ```js - // routerpage2 page - export default { - data: { - data1: 'default', - data2: { - data3: [1, 2, 3] - } +```js +router.push({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] }, - onInit() { - console.info('showData1:' + this.data1); - console.info('showData3:' + this.data2.data3); - } - } - ``` + }, +}); +``` +## router.push<sup>9+</sup> + +push(options: RouterOptions, mode: RouterMode): void + +Navigates to a specified page in the application. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** +| Name | Type | Mandatory| Description | +| ----------------- | ------------------------------- | ---- | -------------------- | +| options | [RouterOptions](#routeroptions) | Yes | Page routing parameters. | +| mode<sup>9+</sup> | [RouterMode](#routermode9) | Yes | Routing mode.| + +**Example** +```js +router.push({ + url: 'pages/routerpage2/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +},router.RouterMode.Standard); +``` ## router.replace @@ -72,37 +77,45 @@ Replaces the current page with another one in the application and destroys the c **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | Yes| Description of the new page.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | Yes | Description of the new page.| **Example** - ```js - // Current page - export default { - replacePage() { - router.replace({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, - }); - } - } - ``` +```js +router.replace({ + url: 'pages/detail', + params: { + data1: 'message', + }, +}); +``` - ```js - // detail page - export default { - data: { - data1: 'default' - }, - onInit() { - console.info('showData1:' + this.data1) - } - } - ``` + ## router.replace<sup>9+</sup> + +replace(options: RouterOptions, mode: RouterMode): void + +Replaces the current page with another one in the application and destroys the current page. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** +| Name | Type | Mandatory| Description | +| ----------------- | ------------------------------- | ---- | -------------------- | +| options | [RouterOptions](#routeroptions) | Yes | Description of the new page. | +| mode<sup>9+</sup> | [RouterMode](#routermode9) | Yes | Routing mode.| + +**Example** + +```js +router.replace({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, +}, router.RouterMode.Standard); +``` ## router.back @@ -113,59 +126,15 @@ Returns to the previous page or a specified page. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | Yes| Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| +| Name | Type | Mandatory| Description | +| ------- | ------------------------------- | ---- | ------------------------------------------------------------ | +| options | [RouterOptions](#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.| **Example** - ```js - // index page - export default { - indexPushPage() { - router.push({ - url: 'pages/detail/detail', - }); - } - } - ``` - - ```js - // detail page - export default { - detailPushPage() { - router.push({ - url: 'pages/mall/mall', - }); - } - } - ``` - - ```js - // Navigate from the mall page to the detail page through router.back(). - export default { - mallBackPage() { - router.back(); - } - } - ``` - ```js - // Navigate from the detail page to the index page through router.back(). - export default { - defaultBack() { - router.back(); - } - } - ``` - - ```js - // Return to the detail page through router.back(). - export default { - backToDetail() { - router.back({uri:'pages/detail/detail'}); - } - } - ``` +```js +router.back({url:'pages/detail'}); +``` ## router.clear @@ -176,13 +145,10 @@ Clears all historical pages in the stack and retains only the current page at th **System capability**: SystemCapability.ArkUI.ArkUI.Full **Example** - ```js - export default { - clearPage() { - router.clear(); - } - }js - ``` + +```js +router.clear(); +``` ## router.getLength @@ -193,19 +159,15 @@ Obtains the number of pages in the current stack. **System capability**: SystemCapability.ArkUI.ArkUI.Full **Return value** -| Type| Description| -| -------- | -------- | +| Type | Description | +| ------ | ---------------------------------- | | string | Number of pages in the stack. The maximum value is **32**.| **Example** - ```js - export default { - getLength() { - var size = router.getLength(); - console.log('pages stack size = ' + size); - } - } - ``` +```js +var size = router.getLength(); +console.log('pages stack size = ' + size); +``` ## router.getState @@ -220,28 +182,26 @@ Obtains state information about the current page. | Type | Description | | --------------------------- | -------------- | | [RouterState](#routerstate) | Page routing state.| +**Example** + +```js +var page = router.getState(); +console.log('current index = ' + page.index); +console.log('current name = ' + page.name); +console.log('current path = ' + page.path); +``` + ## RouterState + Describes the page routing state. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name| Type| Description| -| -------- | -------- | -------- | -| index | number | Index of the current page in the stack.<br>>  **NOTE**<br>> The index starts from 1 from the bottom to the top of the stack.| -| name | string | Name of the current page, that is, the file name.| -| path | string | Path of the current page.| - -**Example** - ```js - export default { - getState() { - var page = router.getState(); - console.log('current index = ' + page.index); - console.log('current name = ' + page.name); - console.log('current path = ' + page.path); - } - } - ``` +| Name | Type | Description | +| ----- | ------ | ------------------------------------------------------------ | +| index | number | Index of the current page in the stack. The index starts from 1 from the bottom to the top of the stack.| +| name | string | Name of the current page, that is, the file name. | +| path | string | Path of the current page. | ## router.enableAlertBeforeBackPage @@ -252,26 +212,16 @@ Enables the display of a confirm dialog box before returning to the previous pag **System capability**: SystemCapability.ArkUI.ArkUI.Full **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.| +| Name | Type | Mandatory| Description | +| ------- | ----------------------------------------- | ---- | ------------------ | +| options | [EnableAlertOptions](#enablealertoptions) | Yes | Description of the dialog box.| **Example** - ```js - export default { - enableAlertBeforeBackPage() { - router.enableAlertBeforeBackPage({ - message: 'Message Info', - success: function() { - console.log('success'); - }, - fail: function() { - console.log('fail'); - }, - }); - } - } + ```js + router.enableAlertBeforeBackPage({ + message: 'Message Info' + }); ``` ## EnableAlertOptions @@ -279,9 +229,9 @@ Describes the confirm dialog box. **System capability**: SystemCapability.ArkUI.ArkUI.Full -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| message | string | Yes| Content displayed in the confirm dialog box.| +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ---------------- | +| message | string | Yes | Content displayed in the confirm dialog box.| ## router.disableAlertBeforeBackPage @@ -292,13 +242,9 @@ Disables the display of a confirm dialog box before returning to the previous pa **System capability**: SystemCapability.ArkUI.ArkUI.Full **Example** - ```js - export default { - disableAlertBeforeBackPage() { - router.disableAlertBeforeBackPage(); - } - } - ``` +```js +router.disableAlertBeforeBackPage(); +``` ## router.getParams @@ -316,122 +262,141 @@ Obtains the parameters passed from the page that initiates redirection to the cu **Example** -- Web-like example - ```js - // Current page - export default { - pushPage() { - router.push({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, - }); - } +``` +router.getParams(); +``` + +## RouterOptions + +Describes the page routing options. + +**System capability**: SystemCapability.ArkUI.ArkUI.Lite + +| Name | Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| url | string | Yes | URI of the destination page, in either of the following formats:<br>- Absolute path of the page. The value is available in the pages list in the **config.json** file, for example:<br>- pages/index/index<br>- pages/detail/detail<br>- Particular path. If the URI is a slash (/), the home page is displayed. | +| params | Object | No | Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.| + + + > **NOTE** + > + > The page routing stack supports a maximum of 32 pages. + +## RouterMode<sup>9+</sup> + +Enumerates the routing modes. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +| Name | Description | +| -------- | ------------------------------------------------------------ | +| Standard | Standard mode. | +| Single | Singleton mode.<br>If the URL of the target page already exists in the page stack, the page closest to the top of the stack is moved as a new page to the top of the stack.<br>If the URL of the target page does not exist in the page stack, the page is redirected to in standard mode.| + +## Examples + +### JavaScript-based Web-like Development Paradigm + +```js +// Current page +export default { + pushPage() { + router.push({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, + }); } - ``` - ```js - // detail page - export default { - onInit() { - console.info('showData1:' + router.getParams().data1); - } +} +``` +```js +// detail page +export default { + onInit() { + console.info('showData1:' + router.getParams()[data1]); } - ``` +} +``` -- Declarative example +### TypeScript-based Declarative Development Paradigm - ```ts - // Navigate to the target page through router.push with the params parameter carried. - import router from '@ohos.router' - - @Entry - @Component - struct Index { - async routePage() { - let options = { - url: 'pages/second', - params: { - text: 'This is the value on the first page.', - data: { - array: [12, 45, 78] - }, - } - } - try { - await router.push(options) - } catch (err) { - console.info(` fail callback, code: ${err.code}, msg: ${err.msg}`) +```ts +// Navigate to the target page through router.push with the params parameter carried. +import router from '@ohos.router' + +@Entry +@Component +struct Index { + async routePage() { + let options = { + url: 'pages/second', + params: { + text: 'This is the value on the first page.', + data: { + array: [12, 45, 78] + }, } } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('This is the first page.') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ top: 20 }) - .backgroundColor('#ccc') - .onClick(() => { - this.routePage() - }) - } - .width('100%') - .height('100%') + try { + await router.push(options) + } catch (err) { + console.info(` fail callback, code: ${err.code}, msg: ${err.msg}`) } } - ``` - ```ts - // Receive the transferred parameters on the second page. - import router from '@ohos.router' - - @Entry - @Component - struct Second { - private content: string = "This is the second page." - @State text: string = router.getParams()['text'] - @State data: any = router.getParams()['data'] - @State secondData : string = '' - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('This is the first page.') .fontSize(50) .fontWeight(FontWeight.Bold) - Text(this.text) - .fontSize(30) - .onClick(()=>{ - this.secondData = (this.data.array[1]).toString() - }) - .margin({top:20}) - Text('Value from the first page '+'' + this.secondData) - .fontSize(20) - .margin({top:20}) - .backgroundColor('red') - } - .width('100%') - .height('100%') + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ top: 20 }) + .backgroundColor('#ccc') + .onClick(() => { + this.routePage() + }) } + .width('100%') + .height('100%') } - ``` - -## RouterOptions - -Describes the page routing options. - -**System capability**: SystemCapability.ArkUI.ArkUI.Lite - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| url | string | Yes| URI of the destination page, in either of the following formats:<br>- Absolute path of the page. The value is available in the pages list in the config.json file, for example:<br> - pages/index/index<br> - pages/detail/detail<br>- Particular path. If the URI is a slash (/), the home page is displayed.| -| params | Object | No| Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.| +} +``` +```ts +// Receive the transferred parameters on the second page. +import router from '@ohos.router' - >  **NOTE** - > The page routing stack supports a maximum of 32 pages. +@Entry +@Component +struct Second { + private content: string = "This is the second page." + @State text: string = router.getParams()['text'] + @State data: any = router.getParams()['data'] + @State secondData : string = '' + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text(this.text) + .fontSize(30) + .onClick(()=>{ + this.secondData = (this.data.array[1]).toString() + }) + .margin({top:20}) + Text('Value from the first page '+'' + this.secondData) + .fontSize(20) + .margin({top:20}) + .backgroundColor('red') + } + .width('100%') + .height('100%') + } +} +``` diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index d75b957512e60e55aacfac1fdce2fdf063eb9c56..832d9754db5e41a11d38b020e77673ee5fe4d346 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -1,8 +1,10 @@ # Screen Lock Management +The **screenlock** module is a system module in OpenHarmony. It provides APIs for screen lock applications to subscribe to screen lock status changes as well as callbacks for them to receive the results. It also provides APIs for third-party applications to unlock the screen, obtain the screen locked status, and check whether a lock screen password has been set. + > **NOTE** > -> The initial APIs of this module are supported since API version … Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -73,6 +75,7 @@ Checks whether a device is in secure mode. This API uses an asynchronous callbac **System capability**: SystemCapability.MiscServices.ScreenLock + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -125,6 +128,7 @@ Unlocks the screen. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -174,10 +178,12 @@ Subscribes to screen lock status changes. **System capability**: SystemCapability.MiscServices.ScreenLock +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit. | +| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.| | callback | Callback\<void\> | Yes| Callback used to return the result.| **Example** @@ -196,10 +202,12 @@ Subscribes to screen lock status changes. **System capability**: SystemCapability.MiscServices.ScreenLock +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes| Event type.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.| +| type | string | Yes| Event type.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.| | callback | Callback\<number\> | Yes| Callback used to return the result. | **Example** @@ -217,11 +225,13 @@ Subscribes to screen lock status changes. **System capability**: SystemCapability.MiscServices.ScreenLock +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes| Event type.<br>- **'screenlockEnabled'**: Screen lock is enabled.| -| callback | Callback\<boolean\> | Yes| Callback used to return the result. | +| type | string | Yes| Event type.<br>- **"screenlockEnabled"**: Screen lock is enabled.| +| callback | Callback\<boolean\> | Yes| Callback used to return the result.| **Example** @@ -240,10 +250,12 @@ Unsubscribes from screen lock status changes. **System capability**: SystemCapability.MiscServices.ScreenLock +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit.<br>- **'screenlockEnabled'**: Screen lock is enabled.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.| +| type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.<br>- **"screenlockEnabled"**: Screen lock is enabled.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.| | callback | Callback\<void\> | Yes| Callback used to return the result.| **Example** @@ -262,11 +274,13 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac **System capability**: SystemCapability.MiscServices.ScreenLock +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| event | String | Yes| Event type.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.| -| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.| +| event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.| +| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.| | callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result.| **Example** @@ -279,18 +293,19 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac ## screenlock.sendScreenLockEvent<sup>9+</sup> -sendScreenLockEvent(event: String, parameter: number): Promise<boolean> +sendScreenLockEvent(event: String, parameter: number): Promise\<boolean\> Sends an event to the screen lock service. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock -**Parameters** +**System API**: This is a system API and cannot be called by third-party applications. +**Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| event | String | Yes| Event type.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.| -| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.| +| event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.| +| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.| **Return value** | Type| Description| @@ -300,7 +315,7 @@ Sends an event to the screen lock service. This API uses a promise to return the **Example** ```js - screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((err, result) => { + screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { console.log('sending result:' + result); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-screen.md b/en/application-dev/reference/apis/js-apis-screen.md new file mode 100644 index 0000000000000000000000000000000000000000..94f5f3cb5e532f3e28f221addb164358589b1754 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-screen.md @@ -0,0 +1,718 @@ +# Screen +The **Screen** module implements basic screen management. You can use the APIs of this module to obtain a **Screen** object, listen for screen changes, and create and destroy virtual screens. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. +## Modules to Import + +```js +import screen from '@ohos.screen'; +``` + +## screen.getAllScreens + +getAllScreens(callback: AsyncCallback<Array<Screen>>): void + +Obtains all screens. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback<Array<[Screen](#screen)>> | Yes | Callback used to return all the **Screen** objects obtained.| + +**Example** + +```js +var screenClass = null; +screen.getAllScreens((err, data) => { + if (err.code) { + console.error('Failed to get all screens . Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting all screens . Data:' + JSON.stringify(data)); + screenClass = data[0]; +}); +``` +## screen.getAllScreens + +getAllScreens(): Promise<Array<Screen>> + +Obtains all screens. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** +| Type | Description | +| --------------------------------------------- | ----------------------------------------- | +| Promise<Array<[Screen](#screen)>> | Promise used to return all the **Screen** objects obtained.| + +**Example** +```js +var screenClass = null; +let promise = screen.getAllScreens(); +promise.then((data) => { + screenClass = data[0]; + console.log('Succeeded in getting all screens . Data:'+ JSON.stringify(data)); +}).catch((err) => { + console.log('Failed to get all screens . Cause: ' + JSON.stringify(err)); +}); +``` +## screen.on('connect' | 'disconnect' | 'change') +on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number>): void + +Subscribes to events related to the screen state. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| --------- | ---------------------- | ---- | ------------------------------------------------------------ | +| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.| +| callback | Callback<number> | Yes | Callback used to return the screen ID. | + +**Example** +```js +var callback = (data) => { + console.info('Register the callback for screen changes. Data: ' + JSON.stringify(data)) +}; +screen.on("connect", callback); +``` +## screen.off('connect' | 'disconnect' | 'change') +off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<number>): void + +Unsubscribes from events related to the screen state. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| --------- | ---------------------- | ---- | ------------------------------------------------------------ | +| eventType | string | Yes | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.| +| callback | Callback<number> | No | Callback used to return the screen ID. | + +**Example** +```js +var callback = (data) => { + console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data)) +}; +screen.off("connect", callback); +``` + +## screen.makeExpand +makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number>): void + +Sets the screen to the expanded mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------ | ---- | -------------------------------- | +| options | Array<[ExpandOption](#expandoption)> | Yes | Parameters for expanding the screen. | +| callback | Callback<number> | Yes | Callback used to return the group ID of the expanded screens.| + +**Example** + +```js +var groupId = null; +screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}], (err, data) => { + if (err.code) { + console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err)); + return; + } + groupId = data; + console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data)); +}); +``` + +## screen.makeExpand +makeExpand(options:Array<ExpandOption>): Promise<number> + +Sets the screen to the expanded mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------ | ---- | ------------------------ | +| options | Array<[ExpandOption](#expandoption)> | Yes | Parameters for expanding the screen.| + +**Return value** +| Type | Description | +| --------------------- | ----------------------------------- | +| Promise<number> | Promise used to return the group ID of the expanded screens.| + +**Example** +```js +screen.makeExpand([{screenId: 0, startX: 0, startY: 0}, {screenId: 1, startX: 1080, startY: 0}]).then((data) => { + console.info('Succeeded in making screens as expand-screen.Data:' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to make screens as expand-screen. Cause:' + JSON.stringify(err)); +}); +``` + +## screen.makeMirror +makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncCallback<number>): void + +Sets screen mirroring. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------- | ---- |-----------------| +| mainScreen | number | Yes | ID of the primary screen. | +| mirrorScreen | Array<number> | Yes | IDs of secondary screens. | +| callback | AsyncCallback<number> | Yes | Callback used to return the group ID of the secondary screens.| + +**Example** +```js +var mainScreenId = 0; +var mirrorScreenIds = [1, 2, 3]; +screen.makeMirror(mainScreenId, mirrorScreenIds, (err, data) => { + if (err.code) { + console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data)); +}); +``` + +## screen.makeMirror +makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<number> + +Sets screen mirroring. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------- | ---- |-----------| +| mainScreen | number | Yes | ID of the primary screen. | +| mirrorScreen | Array<number> | Yes | IDs of secondary screens.| + +**Return value** +| Type | Description | +| --------------------- | ----------------------------------- | +| Promise<number> | Promise used to return the group ID of the secondary screens.| + +**Example** +```js +var mainScreenId = 0; +var mirrorScreenIds = [1, 2, 3]; +screen.makeMirror(mainScreenId, mirrorScreenIds).then((data) => { + console.info('Succeeded in making screens as mirror-screen.Data:' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to make screens as mirror-screen.Cause:' + JSON.stringify(err)); +}); +``` + +## screen.createVirtualScreen +createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Screen>): void + +Creates a virtual screen. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN (mandatory when **VirtualScreenOption.surfaceId** is valid; available only to system applications) + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ---------------------------------- | +| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters. | +| callback | AsyncCallback<[Screen](#screen)> | Yes | Callback used to return the created virtual screen.| + +**Example** +```js +var screenClass = null; +screen.createVirtualScreen({ + name: 'screen01', + width: 1080, + height: 2340, + density: 2, + surfaceId: '' +}, (err, data) => { + if (err.code) { + console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err)); + return; + } + screenClass = data; + console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data)); +}); +``` + +## screen.createVirtualScreen +createVirtualScreen(options:VirtualScreenOption): Promise<Screen> + +Creates a virtual screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN (mandatory when **VirtualScreenOption.surfaceId** is valid available only to system applications) + +**Parameters** +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------- | ---- | ------------------------ | +| options | [VirtualScreenOption](#virtualscreenoption) | Yes | Virtual screen parameters.| + +**Return value** + +| Type | Description | +| -------------------------------- | ------------------------------------- | +| Promise<[Screen](#screen)> | Promise used to return the created virtual screen.| + +**Example** +```js +var screenClass = null; +screen.createVirtualScreen({ + name: 'screen01', + width: 1080, + height: 2340, + density: 2, + surfaceId: '' +}).then((data) => { + screenClass = data; + console.info('Succeeded in creating virtual screen.Data:' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to create virtual screen.Cause:' + JSON.stringify(err)); +}); +``` + +## screen.destroyVirtualScreen +destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void + +Destroys a virtual screen. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------------------------------------------ | +| screenId | number | Yes | Screen ID. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** +```js +var screenId = 1; +screen.destroyVirtualScreen(screenId, (err,data) => { + if (err.code) { + console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying virtual screen.'); +}); +``` + +## screen.destroyVirtualScreen +destroyVirtualScreen(screenId:number): Promise<void> + +Destroys a virtual screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ---------- | +| screenId | number | Yes | Screen ID.| + +**Return value** +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +var screenId = 1; +screen.destroyVirtualScreen(screenId).then((data) => { + console.info('Succeeded in destroying virtual screen.'); +}).catch((err) => { + console.error('Failed to destroy virtual screen.Cause:' + JSON.stringify(err)); +}); +``` + +## screen.setVirtualScreenSurface +setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void + +Sets the surface for a virtual screen. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications) + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| screenId | number | Yes | Screen ID. | +| surfaceId | string | Yes | Surface ID. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** + +```js +var screenId = 1; +var surfaceId = '2048'; +screen.setVirtualScreenSurface(screenId, surfaceId, (err,data) => { + if (err.code) { + console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting surface for the virtual screen.'); +}); +``` + +## screen.setVirtualScreenSurface +setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void> + +Sets the surface for a virtual screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications) + +**Parameters** +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------- | +| screenId | number | Yes | Screen ID. | +| surfaceId | string | Yes | Surface ID.| + +**Return value** +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +var screenId = 1; +var surfaceId = '2048'; +screen.setVirtualScreenSurface(screenId, surfaceId).then((data) => { + console.info('Succeeded in setting surface for the virtual screen.'); +}).catch((err) => { + console.error('Failed to set surface for the virtual screen. Cause:' + JSON.stringify(err)); +}); +``` + +## screen.isScreenRotationLocked +isScreenRotationLocked(): Promise<boolean> + +Checks whether auto rotate is locked. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Return value** +| Type | Description | +| ---------------------- | ------------------------------------- | +| Promise<boolean> | Promise used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.| + +**Example** +```js +screen.isScreenRotationLocked().then((isLocked) => { + console.info('Succeeded in getting screen rotation lock status. isLocked:'+ JSON.stringify(isLocked)); +}).catch((err) => { + console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err)); +}); +``` + +## screen.isScreenRotationLocked +isScreenRotationLocked(callback: AsyncCallback<boolean>): void + +Checks whether auto rotate is locked. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.| + +**Example** + +```js +screen.isScreenRotationLocked((err, isLocked) => { + if (err.code) { + console.error('Failed to get screen rotation lock status. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting screen rotation lock status. isLocked:' + JSON.stringify(isLocked)); +}); +``` + +## screen.setScreenRotationLocked +setScreenRotationLocked(isLocked: boolean): Promise<void> + +Sets whether to lock auto rotate. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------- | +| isLocked | boolean | Yes | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite.| + +**Return value** +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +var isLocked = false; +screen.setScreenRotationLocked(isLocked).then((data) => { + console.info('Succeeded in setting whether to lock screen rotation'); +}).catch((err) => { + console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err)); +}); +``` + +## screen.setScreenRotationLocked +setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback<void>): void + +Sets whether to lock auto rotate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| isLocked | boolean | Yes | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** + +```js +var isLocked = false; +screen.setScreenRotationLocked(isLocked, (err, data) => { + if (err.code) { + console.error('Failed to set whether to lock screen rotation. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting whether to lock screen rotation.'); +}); +``` + +## ExpandOption +Defines the parameters for expanding a screen. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| -------- | -------- | ---- | ---- | ------------------- | +| screenId | number | Yes | Yes | Screen ID. | +| startX | number | Yes | Yes | Start X coordinate of the screen.| +| startY | number | Yes | Yes | Start Y coordinate of the screen.| + +## VirtualScreenOption +Defines virtual screen parameters. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| --------- | -------- | ---- | ---- | ------------------------- | +| name | string | Yes | Yes | Name of a virtual screen. | +| width | number | Yes | Yes | Width of the virtual screen. | +| height | number | Yes | Yes | Height of the virtual screen. | +| density | number | Yes | Yes | Density of the virtual screen. | +| surfaceId | string | Yes | Yes | Surface ID of the virtual screen.| + +## Screen +Implements a **Screen** instance. + +Before calling any API in **Screen**, you must use **[getAllScreens()](#screengetallscreens)** or **[createVirtualScreen()](#screencreatevirtualscreen)** to obtain a **Screen** instance. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Readable| Writable| Description | +| ----------------- | ---------------------------------------------- | ---- | ---- | ---------------------- | +| id | number | Yes | No | Screen ID. | +| parent | number | Yes | No | ID of the group to which a screen belongs. | +| supportedModeInfo | Array<[ScreenModeInfo](#screenmodeinfo)> | Yes | No | Mode set supported by the screen. | +| activeModeIndex | number | Yes | No | Index of the active screen mode.| +| orientation | [Orientation](#orientation) | Yes | No | Screen orientation. | + +### setOrientation +setOrientation(orientation: Orientation, callback: AsyncCallback<void>): void + +Sets the screen orientation. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| orientation | [Orientation](#orientation) | Yes | Screen orientation. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the screen orientation is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** +```js +screenClass.setOrientation(screen.Orientation.VERTICAL, (err, data) => { + if (err.code) { + console.error('Failed to setOrientation VERTICAL. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting Orientation VERTICAL. data: ' + JSON.stringify(data)); +}) +``` +### setOrientation +setOrientation(orientation: Orientation): Promise<void> + +Sets the screen orientation. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------- | +| orientation | [Orientation](#orientation) | Yes | Screen orientation.| + +**Return value** +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +let promise = screenClass.setOrientation(screen.Orientation.VERTICAL); +promise.then((data) => { + console.info('Succeeded in setting Orientation VERTICAL. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to set Orientation VERTICAL. Cause: ' + JSON.stringify(err)); +}) +``` +### setScreenActiveMode +setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): void + +Sets the active mode of the screen. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| modeIndex | number | Yes | Index of the mode to set. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** + +```js +var modeIndex = 0; +screenClass.setScreenActiveMode(modeIndex, (err, data) => { + if (err.code) { + console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting ScreenActiveMode 0. data: ' + JSON.stringify(data)); +}) +``` +### setScreenActiveMode +setScreenActiveMode(modeIndex: number): Promise<void> + +Sets the active mode of the screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ---------- | +| modeIndex | number | Yes | Index of the mode to set.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +var modeIndex = 0; +let promise = screenClass.setScreenActiveMode(modeIndex); +promise.then((data) => { + console.info('Succeeded in setting ScreenActiveMode 0. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to set ScreenActiveMode 0. Cause: ' + JSON.stringify(err)); +}) +``` + +### setDensityDpi +setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void; + +Sets the pixel density of the screen. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | +| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.| + +**Example** +```js +var densityDpi = 320; +screenClass.setDensityDpi(densityDpi, (err, data) => { + if (err.code) { + console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeed in setting DensityDpi 320. data: ' + JSON.stringify(data)); +}) +``` + +### setDensityDpi +setDensityDpi(densityDpi: number): Promise<void> + +Sets the pixel density of the screen. This API uses a promise to return the result. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------------------------------- | +| densityDpi | number | Yes | Pixel density. The value ranges from 80 to 640.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise that returns no value.| + +**Example** +```js +var densityDpi = 320; +var promise = screenClass.setDensityDpi(densityDpi); +promise.then((data) => { + console.info('Succeeded in setting DensityDpi 320. Data: ' + JSON.stringify(data)); +}).catch((err) => { + console.error('Failed to set DensityDpi 320. Cause: ' + JSON.stringify(err)); +}) +``` + +## Orientation +Enumerates the screen orientations. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Value | Description | +| ------------------ | ---- | -------------------------------- | +| UNSPECIFIED | 0 | Unspecified. The screen orientation is determined by the system.| +| VERTICAL | 1 | Vertical. | +| HORIZONTAL | 2 | Horizontal. | +| REVERSE_VERTICAL | 3 | Reverse vertical. | +| REVERSE_HORIZONTAL | 4 | Reverse horizontal. | + +## ScreenModeInfo +Defines the screen mode information. + +**System capability**: SystemCapability.WindowManager.WindowManager.Core + +| Name | Type| Readable| Writable| Description | +| ----------- | -------- | ---- | ---- | -------------------------------------------------- | +| id | number | Yes | Yes | Mode ID. The supported mode is determined by the device resolution and refresh rate.| +| width | number | Yes | Yes | Screen width. | +| height | number | Yes | Yes | Screen height. | +| refreshRate | number | Yes | Yes | Screen refresh rate. | diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 5e2d47e03ba31ab4bae9118e3dc373359d56da11..7f83f0250c209dbd6b5d57970fe7beb8d9b9a494 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -1,5 +1,5 @@ # Screenshot -Provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen. +The **Screenshot** module provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen. > **NOTE** > @@ -57,7 +57,7 @@ Describes the size of the screen region to capture. save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void -Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result. +Takes a screenshot and saves it as a **PixelMap** object. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -67,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | **Example** @@ -98,7 +98,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal save(options?: ScreenshotOptions): Promise<image.PixelMap> -Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result. +Takes a screenshot and saves it as a **PixelMap** object. This API uses a promise to return the result. **System capability**: SystemCapability.WindowManager.WindowManager.Core @@ -108,7 +108,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro | Name | Type | Mandatory| Description | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot settings consist of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set the parameters separately.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-securityLabel.md b/en/application-dev/reference/apis/js-apis-securityLabel.md index a2219288f3b852337ee03ab9f7003adf02dd51b4..86ae51122132f39ce30fe8df4bebc626c8e07d3f 100644 --- a/en/application-dev/reference/apis/js-apis-securityLabel.md +++ b/en/application-dev/reference/apis/js-apis-securityLabel.md @@ -1,10 +1,10 @@ # Security Label -The secuityLabel module provides APIs to manage file data security levels, including obtaining and setting file data security levels. - > **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. +The **secuityLabel** module provides APIs to manage file data security levels, including obtaining and setting file data security levels. + ## Modules to Import ```js @@ -13,12 +13,15 @@ import securityLabel from '@ohos.securityLabel'; ## Usage -Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md). +Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox as follows: ```js import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); -let path = context.getFilesDir(); +let path = ''; +context.getFilesDir().then((data) => { + path = data; +}) ``` ## securityLabel.setSecurityLabel diff --git a/en/application-dev/reference/apis/js-apis-service-extension-ability.md b/en/application-dev/reference/apis/js-apis-service-extension-ability.md index b66c29fe1834b589ee9ffd32eb598e5c53dc2e0a..388657b05dce3f05601cc88123ff2d64adbf127b 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-ability.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-ability.md @@ -1,12 +1,12 @@ # ServiceExtensionAbility +The **ServiceExtensionAbility** module provides APIs for Service Extension abilities. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Provides APIs related to **ServiceExtension**. - ## Modules to Import ``` @@ -21,24 +21,28 @@ None. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +**System API**: This is a system API and cannot be called by third-party applications. + +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.| +| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.| ## ServiceExtensionAbility.onCreate onCreate(want: Want): void; -Called when an extension is created to initialize the service logic. +Called when a Service Extension ability is created to initialize the service logic. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Example** @@ -55,10 +59,12 @@ Called when an extension is created to initialize the service logic. onDestroy(): void; -Called when this extension is destroyed to clear resources. +Called when this Service Extension ability is destroyed to clear resources. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Example** ```js @@ -74,16 +80,18 @@ Called when this extension is destroyed to clear resources. onRequest(want: Want, startId: number): void; -Called after **onCreate** is invoked when an ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started. +Called after **onCreate** is invoked when a Service Extension ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| - | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.| +| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| **Example** @@ -100,21 +108,23 @@ Called after **onCreate** is invoked when an ability is started by calling **sta onConnect(want: Want): rpc.RemoteObject; -Called after **onCreate** is invoked when an ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client. +Called after **onCreate** is invoked when a Service Extension ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Return value** - | Type| Description| - | -------- | -------- | - | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| +| Type| Description| +| -------- | -------- | +| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| **Example** @@ -140,15 +150,17 @@ Called after **onCreate** is invoked when an ability is started by calling **con onDisconnect(want: Want): void; -Called when the ability is disconnected. +Called when this Service Extension ability is disconnected. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| **Example** @@ -159,3 +171,82 @@ Called when the ability is disconnected. } } ``` + +## ServiceExtensionAbility.onReconnect + +onReconnect(want: Want): void; + +Called when this Service Extension ability is reconnected. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.| + +**Example** + + ```js + class ServiceExt extends ServiceExtension { + onDisconnect(want) { + console.log('onDisconnect, want:' + want.abilityName); + } + } + ``` + +## ServiceExtensionAbility.onConfigurationUpdated + +onConfigurationUpdated(config: Configuration): void; + +Called when the configuration of this Service Extension ability is updated. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| + +**Example** + + ```js + class ServiceExt extends ServiceExtension { + onConfigurationUpdated(config) { + console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); + } + } + ``` + +## ServiceExtensionAbility.dump + +dump(params: Array\<string>): Array\<string>; + +Dumps the client information. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| params | Array\<string> | Yes| Parameters in the form of a command.| + +**Example** + + ```js + class ServiceExt extends ServiceExtension { + dump(params) { + console.log('dump, params:' + JSON.stringify(params)); + return ["params"] + } + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index 518167d562ba8801223e206ad5b35ea07ea94936..241a8bf17f94a3362fe6d12d4662b139c4c4cd8b 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -1,16 +1,25 @@ # ServiceExtensionContext +The **ServiceExtensionContext** module, inherited from **ExtensionContext**, provides context for Service Extension abilities. + +You can use the APIs of this module to start, terminate, connection, and disconnect abilities. + > **NOTE** > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. -Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**. +## Usage -## Modules to Import +Before using the **ServiceExtensionContext** module, you must define a child class that inherits from **ServiceExtensionAbility**. -``` -import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; +```js + import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ServiceExtensionAbility { + onCreate() { + let context = this.context; + } + } ``` ## startAbility @@ -21,6 +30,8 @@ Starts an ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -31,34 +42,30 @@ Starts an ability. This API uses a callback to return the result. **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility"}; - this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringify(err)); - }); - } - } - + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility"}; + this.context.startAbility(want, (err) => { + console.log('startAbility result:' + JSON.stringify(err)); + }); ``` +## startAbility -## ServiceExtensionContext.startAbility - -startAbility(want: Want): Promise<void>; +startAbility(want: Want, options?: StartOptions): Promise\<void>; Starts an ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| + | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| **Return value** @@ -69,24 +76,428 @@ Starts an ability. This API uses a promise to return the result. **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility" - }; - this.context.startAbility(want).then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - } - } - - + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility" + }; + this.context.startAbility(want).then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + + ``` + +## startAbility + +startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void + +Starts an ability. This API uses a callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var options = { + windowMode: 0, + }; + this.context.startAbility(want, options, (error) => { + console.log("error.code = " + error.code) + }) + ``` + +## ServiceExtensionContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startAbilityWithAccount(want, accountId, (err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }); + ``` + + +## ServiceExtensionContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void\>): void; + +Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityWithAccount(want, accountId, options, (err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }); + ``` + + +## ServiceExtensionContext.startAbilityWithAccount + +startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void>; + +Starts an ability with the account ID specified. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + windowMode: 0, + }; + this.context.startAbilityWithAccount(want, accountId, options) + .then((data) => { + console.log('---------- startAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startAbilityWithAccount fail, err: -----------', err); + }) ``` +## ServiceExtensionContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +Starts a new Service Extension ability. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want, (err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want): Promise\<void>; + +Starts a new Service Extension ability. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want) + .then((data) => { + console.log('---------- startServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +Starts a new Service Extension ability with the account ID specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +Starts a new Service Extension ability with the account ID specified. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +Stops Service Extension abilities in the same application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want, (err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want): Promise\<void>; + +Stops Service Extension abilities in the same application. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want) + .then((data) => { + console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +Stops Service Extension abilities in the same application with the account ID specified. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +Stops Service Extension abilities in the same application with the account ID specified. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` ## ServiceExtensionContext.terminateSelf @@ -96,6 +507,8 @@ Terminates this ability. This API uses a callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -105,19 +518,11 @@ Terminates this ability. This API uses a callback to return the result. **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringify(err)); - }); - } - } - - + this.context.terminateSelf((err) => { + console.log('terminateSelf result:' + JSON.stringify(err)); + }); ``` - ## ServiceExtensionContext.terminateSelf terminateSelf(): Promise<void>; @@ -126,6 +531,8 @@ Terminates this ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Return value** | Type| Description| @@ -135,20 +542,13 @@ Terminates this ability. This API uses a promise to return the result. **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - this.context.terminateSelf().then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - } -} - + this.context.terminateSelf().then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); ``` - ## ServiceExtensionContext.connectAbility connectAbility(want: Want, options: ConnectOptions): number; @@ -157,12 +557,14 @@ Connects this ability to a Service ability. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| - | options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| + | options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| **Return value** @@ -174,17 +576,58 @@ Connects this ability to a Service ability. ```js let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility" + "bundleName": "com.example.myapp", + "abilityName": "MyAbility" }; let options = { - onConnect: function(elementName, proxy) {}, - onDisConnect: function(elementName) {}, - onFailed: function(code) {} + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { console.log('----------- onFailed -----------') } } let connection = this.context.connectAbility(want,options); ``` +## ServiceExtensionContext.connectAbilityWithAccount + +connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + +Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect this ability to another ability. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| accountId | number | Yes| ID of the account.| +| options | ConnectOptions | No| Remote object instance.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Result code of the ability connection.| + +**Example** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + var options = { + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { console.log('----------- onFailed -----------') } + } + const result = this.context.connectAbilityWithAccount(want, accountId, options); + console.log('----------- connectAbilityResult: ------------', result); + ``` ## ServiceExtensionContext.disconnectAbility @@ -194,6 +637,8 @@ Disconnects this ability from the Service ability. This API uses a callback to r **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -204,21 +649,13 @@ Disconnects this ability from the Service ability. This API uses a callback to r **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let connection=1 - this.context.disconnectAbility(connection, (err) => { + let connection=1 + this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility. console.log('terminateSelf result:' + JSON.stringify(err)); - }); - } - } - - + }); ``` - ## ServiceExtensionContext.disconnectAbility disconnectAbility(connection: number): Promise<void>; @@ -227,6 +664,8 @@ Disconnects this ability from the Service ability. This API uses a promise to re **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| @@ -242,29 +681,11 @@ Disconnects this ability from the Service ability. This API uses a promise to re **Example** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let connection=1 - this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. + let connection=1 + this.context.disconnectAbility(connection).then((data) => { + // connection is the return value of connectAbility. console.log('success:' + JSON.stringify(data)); - }).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringify(error)); - }); - } - } - + }); ``` - - -## ConnectOptions - -Defines the **ConnectOptions** data structure. - -**System capability**: SystemCapability.Ability.AbilityRuntime.Core - -| Name| Description| -| -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| -| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| -| onFailed(code: number) | Called when the connection fails.| diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index acad2c7f0223074ef134389ddeac17b8f8d47455..41a4cfc71c77ff92c77b4b16ed19de9af6395bd3 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -1,5 +1,7 @@ # SIM Management +The SIM management module provides basic SIM card management functions. You can obtain the name, number, ISO country code, home PLMN number, service provider name, SIM card status, type, installation status, activation status, and lock status of the SIM card in the specified slot. Besides, you can set the name, number, and lock status of the SIM card, activate or deactivate the SIM card, and change the PIN or unlock the PIN or PUK of the SIM card. + >**NOTE** > >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. @@ -520,7 +522,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | -------------------------------------- | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| -| callback | AsyncCallback\<[IccAccountInfo](#IccAccountInfo7)\> | Yes | Callback used to return the result. For details, see [IccAccountInfo](#IccAccountInfo7).| +| callback | AsyncCallback\<[IccAccountInfo](#IccAccountInfo7)\> | Yes | Callback used to return the result. | **Example** @@ -672,7 +674,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result. | **Example** @@ -737,7 +739,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result. | **Example** @@ -867,7 +869,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result. | **Example** @@ -994,7 +996,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result. | **Example** @@ -1057,7 +1059,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index 11fdf806794469274ea30ee3b4797b42f9041965..25069b318add375d68d97084e45b08c1f69f3804 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -1,5 +1,7 @@ # SMS +The SMS module provides basic SMS management functions. You can create and send SMS messages, and obtain and set the default SIM card for sending and receiving SMS messages. Besides, you can obtain and set the SMSC address, and check whether the current device can send and receive SMS messages. + >**NOTE** > >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. @@ -206,7 +208,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise\<void\> | Promise that returns no value. | +| Promise\<void\> | Promise used to return the result. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md index 093d6cb8b578e66b4213d2f247a95c7c0b9a8643..5606a2e64372c3e002815d535f59851718e535e9 100644 --- a/en/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -1,12 +1,12 @@ # App Storage Statistics -The storageStatistics module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data. - > **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. > - API version 9 is a canary version for trial use. The APIs of this version may be unstable. +The **storageStatistics** module provides APIs for obtaining storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data. + ## Modules to Import ```js @@ -470,7 +470,7 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description| | ---------- | ------ | ---- | ---- | - | userId | string | No | User ID.<br>Value:<br>- Set this parameter to the ID of the user to be queried.<br>- If no value is specified, information about the current user is queried.| + | userId | number | No | User ID.<br>Value:<br>- Set this parameter to the ID of the user to be queried.<br>- If no value is specified, information about the current user is queried.| **Return value** @@ -481,7 +481,7 @@ This is a system API and cannot be called by third-party applications. **Example** ```js - let userId = ""; + let userId = 1; storageStatistics.getUserStorageStats(userId).then(function(StorageStats){ console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); }).catch(function(err){ @@ -507,13 +507,13 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | ---------- | ------------------------------------ | ---- | -------------------------- | - | userId | string | No | User ID.<br>Value:<br>- Set this parameter to the ID of the user to be queried.<br>- If no value is specified, information about the current user is queried. | + | userId | number | No | User ID.<br>Value:<br>- Set this parameter to the ID of the user to be queried.<br>- If no value is specified, information about the current user is queried. | | callback | callback:AsyncCallback<[StorageStats](#StorageStats)> | Yes | Callback invoked to return the information obtained.| **Example** ```js - let userId = ""; + let userId = 1; storageStatistics.getUserStorageStats(userId, function(error, StorageStats){ // Do something. console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats)); diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md index 309e32bdae7af66c7ca14802f734ccca0ccdbb99..4a711c1f7cbf0defdbcd9ea0c28a08e981c594a9 100644 --- a/en/application-dev/reference/apis/js-apis-telephony-data.md +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -1,5 +1,7 @@ # Cellular Data +The cellular data module provides basic mobile data management functions. You can obtain and set the default slot of the SIM card used for mobile data, and obtain the uplink and downlink connection status of cellular data services and connection status of the packet switched (PS) domain. Besides, you can check whether cellular data services and data roaming are enabled. + >**NOTE** > >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. @@ -78,7 +80,7 @@ This is a system API. | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------------------------------------------ | | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.| -| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object. | +| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. | **Example** @@ -110,7 +112,7 @@ This is a system API. | Type | Description | | -------------- | ------------------------------- | -| Promise<\void\> | Promise that returns no value. | +| Promise<\void\> | Promise used to return the result. | **Example** @@ -174,7 +176,7 @@ promise.then((data) => { getCellularDataState(callback: AsyncCallback\<DataConnectState\>): void -Obtains the connection status of the packet switched (PS) domain. This API uses an asynchronous callback to return the result. +Obtains the connection status of the PS domain. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Telephony.CellularData @@ -342,14 +344,14 @@ Defines the cellular data flow type. ## DataConnectState -Describes the connection status of a cellular data link. +Describes the connection status of a cellular data connection. **System capability**: SystemCapability.Telephony.CellularData | Name | Value | Description | | ----------------------- | ---- | -------------------------- | -| DATA_STATE_UNKNOWN | -1 | The status of the cellular data link is unknown. | -| DATA_STATE_DISCONNECTED | 0 | The cellular data link is disconnected. | -| DATA_STATE_CONNECTING | 1 | The cellular data link is being connected.| -| DATA_STATE_CONNECTED | 2 | The cellular data link is connected. | -| DATA_STATE_SUSPENDED | 3 | The cellular data link is suspended. | +| DATA_STATE_UNKNOWN | -1 | The status of the cellular data connection is unknown. | +| DATA_STATE_DISCONNECTED | 0 | The cellular data connection is disconnected. | +| DATA_STATE_CONNECTING | 1 | The cellular data connection is being established.| +| DATA_STATE_CONNECTED | 2 | The cellular data connection is established. | +| DATA_STATE_SUSPENDED | 3 | The cellular data connection is suspended. | diff --git a/en/application-dev/reference/apis/js-apis-testRunner.md b/en/application-dev/reference/apis/js-apis-testRunner.md index 717c8448a00518b777b882fa7a49d7aca4509e11..bc65de36ea0283d025deb74006dd428d7adefbd7 100644 --- a/en/application-dev/reference/apis/js-apis-testRunner.md +++ b/en/application-dev/reference/apis/js-apis-testRunner.md @@ -1,5 +1,9 @@ # TestRunner +The **TestRunner** module provides a test framework. You can use the APIs of this module to prepare the unit test environment and run test cases. + +To implement your own unit test framework, extend this class and override its APIs. + > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,8 +14,6 @@ import TestRunner from '@ohos.application.testRunner' ``` - - ## TestRunner.onPrepare onPrepare(): void @@ -23,10 +25,11 @@ Prepares the unit test environment to run test cases. **Example** ```js -export default class UserTestRunner extends TestRunner { +export default class UserTestRunner implements TestRunner { onPrepare() { console.log("Trigger onPrepare") } +onRun(){} }; ``` @@ -43,9 +46,10 @@ Runs test cases. **Example** ```js -export default class UserTestRunner extends TestRunner { - onRun() { - console.log("Trigger onRun") +export default class UserTestRunner implements TestRunner { + onPrepare() { + console.log("Trigger onRun") } +onRun(){} }; ``` diff --git a/en/application-dev/reference/apis/js-apis-timer.md b/en/application-dev/reference/apis/js-apis-timer.md index d144a95db8f59ca0605fd228b351380afe6feac8..f9e174b5147370f465e140d03aeba6b3802380a0 100644 --- a/en/application-dev/reference/apis/js-apis-timer.md +++ b/en/application-dev/reference/apis/js-apis-timer.md @@ -3,13 +3,6 @@ ## setTimeout -## Modules to Import - - -``` -import Time from '@ohos.Time'; -``` - setTimeout(handler[,delay[,…args]]): number Sets a timer for the system to call a function after the timer goes off. diff --git a/en/application-dev/reference/apis/js-apis-uiappearance.md b/en/application-dev/reference/apis/js-apis-uiappearance.md new file mode 100644 index 0000000000000000000000000000000000000000..3bac964627675b3475e273551d06b146636b410d --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-uiappearance.md @@ -0,0 +1,106 @@ +# UI Appearance + +The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time. + +> **NOTE** +> +> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. + + +## Modules to Import + +```ts +import uiAppearance from '@ohos.uiAppearance' +``` + + +## DarkMode + +Enumerates the color modes. + + +**System capability**: SystemCapability.ArkUI.UiAppearance + +| Name| Value| Description| +| -- | -- | -- | +| ALWAYS_DARK | 0 | The system is always in dark mode. | +| ALWAYS_LIGHT | 1 | The system is always in light mode.| + + +## uiAppearance.setDarkMode + +setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void + +Sets the system color mode. This API uses an asynchronous callback to return the result. + +**Permission required**: ohos.permission.UPDATE_CONFIGURATION + +**System capability**: SystemCapability.ArkUI.UiAppearance + +**Parameters** +| Name| Type| Mandatory| Description| +| -- | -- | -- | -- | +| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| +| callback | AsyncCallback\<void>| Yes| Callback used to return the result.| + +**Example** + ```ts +uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => { + console.info(`${err}`); +}) + ``` + + +## uiAppearance.setDarkMode + +setDarkMode(mode: DarkMode): Promise\<void>; + +Sets the system color mode. This API uses a promise to return the result. + +**Permission required**: ohos.permission.UPDATE_CONFIGURATION + +**System capability**: SystemCapability.ArkUI.UiAppearance + +**Parameters** +| Name| Type| Mandatory| Description| +| -- | -- | -- | -- | +| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| + +**Return value** + +| Type | Description | +| ------ | ------------------------------ | +| Promise\<void> | Promise that returns no value.| + +**Example** + ```ts +uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { + console.log('Set dark-mode successfully.'); +}).catch((err) => { + console.log(`Set dark-mode failed, ${err}`); +}); + ``` + + +## uiAppearance.getDarkMode + +getDarkMode(): DarkMode; + +Obtains the system color mode. + +**Permission required**: ohos.permission.UPDATE_CONFIGURATION + +**System capability**: SystemCapability.ArkUI.UiAppearance + +**Return value** +| Type| Description| +| -- | -- | +|[DarkMode](#darkmode) | Color mode obtained.| + +**Example** + ```ts +let darkMode = uiAppearance.getDarkMode(); +console.log(`Get dark-mode ${darkMode}`); + ``` diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index 251c1d59b610f4d01372186d0e40d0521cf62ca8..64d76026eeb3981fd589401d71f599fc2112f9dd 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -1,8 +1,5 @@ # Update ->  **NOTE** -> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. - The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. There are two types of updates: SD card update and over the air (OTA) update. @@ -10,135 +7,180 @@ There are two types of updates: SD card update and over the air (OTA) update. - The SD card update depends on the update packages and SD cards. - The OTA update depends on the server deployed by the device manufacturer for managing update packages. The OTA server IP address is passed by the caller. The request interface is fixed and developed by the device manufacturer. +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs provided by this module are system APIs. + ## Modules to Import ```js import update from '@ohos.update' ``` -## Required Permissions - -None - -## update.getUpdater +## update.getOnlineUpdater -getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater +getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater -Obtains the **Updater** object for local update. +Obtains an **OnlineUpdater** object. **System capability**: SystemCapability.Update.UpdateService **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | --------------------------- | --------- | ------------ | -| upgradeFile | string | Yes | Update file. | -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | +| Name | Type | Mandatory | Description | +| ----------- | --------------------------- | ---- | ---- | +| upgradeInfo | [UpgradeInfo](#upgradeinfo) | Yes | **UpgradeInfo** object.| **Return value** -| Type | Description | -| ------------------- | ------------------- | -| [Updater](#updater) | **Updater** object. | +| Type | Description | +| ------------------- | ---- | +| [Updater](#updater) | **OnlineUpdater** object.| **Example** ``` try { - let updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); + var upgradeInfo = { + upgradeApp: "com.ohos.ota.updateclient", + businessType: { + vendor: update.BusinessVendor.PUBLIC, + subType: update.BusinessSubType.FIRMWARE + } + } + let updater = update.getOnlineUpdater(upgradeInfo); } catch(error) { - console.error(" Fail to get updater error: " + error); + console.error(`Fail to get updater error: ${error}`); } ``` -## update.getUpdaterForOther +## update.getRestorer -getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater +getRestorer(): Restorer -Obtains the **Updater** object for the device to be updated. +Obtains a **Restorer** object for restoring factory settings. **System capability**: SystemCapability.Update.UpdateService -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | --------------------------- | --------- | --------------------- | -| upgradeFile | string | Yes | Update file. | -| device | string | Yes | Device to be updated. | -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | **Return value** -| Type | Description | -| ------------------- | ------------------- | -| [Updater](#updater) | **Updater** object. | +| Type | Description | +| ------------------- | ---- | +| [Restorer](#restorer) | **Restorer** object for restoring factory settings.| **Example** ``` try { - let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); + let restorer = update.getRestorer(); } catch(error) { - console.error(" Fail to get updater error: " + error); + console.error(`Fail to get restorer: ${error}`); } ``` -## update.getUpdaterFromOther +## update.getLocalUpdater -getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater +getLocalUpdater(): LocalUpdater -Obtains the **Updater** object from another device for the device to be updated. +Obtains a **LocalUpdater** object. **System capability**: SystemCapability.Update.UpdateService -**Parameters** - -| Name | Type | Mandatory | Description | -| ----------- | --------------------------- | --------- | --------------------- | -| upgradeFile | string | Yes | Update file. | -| device | string | Yes | Device to be updated. | -| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | - **Return value** -| Type | Description | -| ------------------- | ------------------- | -| [Updater](#updater) | **Updater** object. | +| Type | Description | +| ------------------- | ---- | +| [LocalUpdater](#localupdater) | **LocalUpdater** object.| **Example** ``` try { - let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); + let localUpdater = update.getLocalUpdater(); } catch(error) { - console.error(" Fail to get updater error: " + error); + console.error(`Fail to get localUpdater error: ${error}`); } ``` ## Updater +### checkNewVersion + +checkNewVersion(callback: AsyncCallback\<CheckResult>): void + +Checks whether a new version is available. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<[CheckResult](#checkresult)> | Yes | Callback used to return the result.| + +**Example** + +``` +updater.checkNewVersion((err, result) => { + console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`); +}); +``` + +### checkNewVersion + +checkNewVersion(): Promise\<CheckResult> + +Checks whether a new version is available. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<[CheckResult](#checkresult)> | Promise used to return the result.| + +**Example** + +``` +updater.checkNewVersion().then(result => { + console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`); + // Version digest information + console.log(`checkNewVersion versionDigestInfo: ${result.newVersionInfo.versionDigestInfo.versionDigest}`); +}).catch(err => { + console.log(`checkNewVersion promise error ${JSON.stringify(err)}`); +}); +``` + ### getNewVersionInfo getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void -Obtains the new version information. This function uses an asynchronous callback to return the result. +Obtains information about the new version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | Yes | Callback used to return the result.| **Example** ``` -updater.getNewVersionInfo(info => { - console.log("getNewVersionInfo success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); +updater.getNewVersionInfo((err, info) => { + console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); + console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`); }); ``` @@ -146,451 +188,1562 @@ updater.getNewVersionInfo(info => { getNewVersionInfo(): Promise\<NewVersionInfo> -Obtains the new version information. This function uses a promise to return the result. +Obtains information about the new version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.| **Example** ``` -updater.getNewVersionInfo().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); +updater.getNewVersionInfo().then(info => { + console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); + console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`); }).catch(err => { - console.log("getNewVersionInfo promise error: " + err.code); + console.log(`getNewVersionInfo promise error ${JSON.stringify(err)}`); }); ``` -### checkNewVersion +### getNewVersionDescription -checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void +getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void -Checks whether the current version is the latest. This function uses an asynchronous callback to return the result. +Obtains the description file of the new version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| +| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes | Callback used to return the result.| **Example** ``` -updater.checkNewVersion(info => { - console.log("checkNewVersion success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options of the description file +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // Standard format + language: "zh-cn" // Chinese +} + +updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => { + console.log(`getNewVersionDescription info ${JSON.stringify(info)}`); + console.log(`getNewVersionDescription err ${JSON.stringify(err)}`); }); ``` -### checkNewVersion +### getNewVersionDescription + +getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>; + +Obtains the description file of the new version. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.| + +**Example** -checkNewVersion(): Promise\<NewVersionInfo> +``` +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options of the description file +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // Standard format + language: "zh-cn" // Chinese +} + +updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => { + console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`); +}).catch(err => { + console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`); +}); +``` + +### getCurrentVersionInfo + +getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void + +Obtains information about the current version. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** -Checks whether the current version is the latest. This function uses a promise to return the result. +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | Yes | Callback used to return the result.| + +**Example** + +``` +updater.getCurrentVersionInfo((err, info) => { + console.log(`info osVersion = ${info?.osVersion}`); + console.log(`info deviceName = ${info?.deviceName}`); + console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); +}); +``` + +### getCurrentVersionInfo + +getCurrentVersionInfo(): Promise\<CurrentVersionInfo> + +Obtains information about the current version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Return value** -| Type | Description | -| ---------------------------------------- | ---------------------------------------- | -| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise used to return the result.| **Example** ``` -updater.checkNewVersion().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); +updater.getCurrentVersionInfo().then(info => { + console.log(`info osVersion = ${info.osVersion}`); + console.log(`info deviceName = ${info.deviceName}`); + console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); }).catch(err => { - console.log("checkNewVersion promise error: " + err.code); + console.log(`getCurrentVersionInfo promise error ${JSON.stringify(err)}`); }); ``` -### verifyUpdatePackage +### getCurrentVersionDescription -verifyUpdatePackage(upgradeFile: string, certsFile: string): void +getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void -Verifies whether the update package is valid. +Obtains the description file of the current version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ------ | --------- | ---------------------------------------- | -| upgradeFile | string | Yes | Path of the update package to be verified. | -| certsFile | string | Yes | Certificate path. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| +| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | Yes | Callback used to return the result.| **Example** ``` -updater.on("verifyProgress", callback => { - console.info('on verifyProgress ' + callback.percent); +// Options of the description file +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // Standard format + language: "zh-cn" // Chinese +} + +updater.getCurrentVersionDescription(descriptionOptions, (err, info) => { + console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`); + console.log(`getCurrentVersionDescription err ${JSON.stringify(err)}`); }); -update.verifyUpdatePackage("XXX", "XXX"); ``` -### rebootAndCleanUserData<sup>8+</sup> +### getCurrentVersionDescription -rebootAndCleanUserData(): Promise\<number> +getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>> -Reboots the device and clears the user partition data. This function uses a promise to return the result. +Obtains the description file of the current version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | Yes | Options of the description file.| + **Return value** -| Type | Description | -| ---------------- | ---------------------------------------- | -| Promise\<number> | Promise used to return the execution result. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise used to return the result.| **Example** ``` -updater.rebootAndCleanUserData().then(result => { - console.log("rebootAndCleanUserData " + result); +// Options of the description file +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // Standard format + language: "zh-cn" // Chinese +} + +updater.getCurrentVersionDescription(descriptionOptions).then(info => { + console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`); }).catch(err => { - console.info("rebootAndCleanUserData promise error: " + err.code); + console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`); }); ``` -### rebootAndCleanUserData<sup>8+</sup> +### getTaskInfo -rebootAndCleanUserData(callback: AsyncCallback\<number>): void +getTaskInfo(callback: AsyncCallback\<TaskInfo>): void -Reboots the device and clears the user partition data. This function uses a promise to return the result. +Obtains information about the update task. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback\<number> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<[TaskInfo](#taskinfo)> | Yes | Callback used to return the result.| **Example** ``` -updater.rebootAndCleanUserData(result => { - console.log("rebootAndCleanUserData ", result) +updater.getTaskInfo((err, info) => { + console.log(`getTaskInfo isexistTask= ${info?.existTask}`); }); ``` -### applyNewVersion +### getTaskInfo -applyNewVersion(): Promise\<number> +getTaskInfo(): Promise\<TaskInfo> -Installs the update package. This function uses a promise to return the result. +Obtains information about the update task. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Return value** -| Type | Description | -| ---------------- | ---------------------------------------- | -| Promise\<number> | Promise used to return the execution result. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<[TaskInfo](#taskinfo)> | Promise used to return the result.| **Example** ``` -updater.applyNewVersion().then(result => { - console.log("appVewVersion ", result) +updater.getTaskInfo().then(info => { + console.log(`getTaskInfo isexistTask= ${info.existTask}`); }).catch(err => { - console.info("applyNewVersion promise error: " + err.code); + console.log(`getTaskInfo promise error ${JSON.stringify(err)}`); }); ``` -### applyNewVersion +### download -applyNewVersion(callback: AsyncCallback\<number>): void +download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, callback: AsyncCallback\<void>): void -Installs the update package. This function uses a promise to return the result. +Downloads the new version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback\<number> | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ``` -updater.applyNewVersion(result => { - console.log("applyNewVersion ", result) +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Download options +var downloadOptions = { + allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network + order: update.Order.DOWNLOAD // Download +} +updater.download(versionDigestInfo, downloadOptions, (err) => { + console.log(`download error ${JSON.stringify(err)}`); }); ``` ### download -download(): void +download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions): Promise\<void> -Downloads the new version and displays the download process. +Downloads the new version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| downloadOptions | [DownloadOptions](#downloadoptions) | Yes | Download options.| + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + **Example** ``` -updater.on("downloadProgress", progress => { - console.log("downloadProgress on" + progress); - console.log(`downloadProgress status: ` + progress.status); - console.log(`downloadProgress percent: ` + progress.percent); +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Download options +var downloadOptions = { + allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network + order: update.Order.DOWNLOAD // Download +} +updater.download(versionDigestInfo, downloadOptions).then(() => { + console.log(`download start`); +}).catch(err => { + console.log(`download error ${JSON.stringify(err)}`); }); -updater.download(); ``` -### upgrade +### resumeDownload + +resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback\<void>): void + +Resumes download of the new version. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| + +**Example** + +``` +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for resuming download +var resumeDownloadOptions = { + allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network +} +updater.resumeDownload(versionDigestInfo, resumeDownloadOptions, (err) => { + console.log(`resumeDownload error ${JSON.stringify(err)}`); +}); +``` -upgrade():void +### resumeDownload -Starts an update. +resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void> + +Resumes download of the new version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | Yes | Options for resuming download.| + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + **Example** ``` -updater.on("upgradeProgress", progress => { - console.log("upgradeProgress on" + progress); - console.log(`upgradeProgress status: ` + progress.status); - console.log(`upgradeProgress percent: ` + progress.percent); +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for resuming download +var resumeDownloadOptions = { + allowNetwork: update.NetType.CELLULAR, // Whether to allow download over data network +} +updater.resumeDownload(versionDigestInfo, resumeDownloadOptions).then(value => { + console.log(`resumeDownload start`); +}).catch(err => { + console.log(`resumeDownload error ${JSON.stringify(err)}`); }); -updater.upgrade(); ``` -### setUpdatePolicy +### pauseDownload -setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void +pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback\<void>): void -Sets the update policy. This function uses an asynchronous callback to return the result. +Pauses download of the new version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | -| callback | Callback used to return the execution result. | Yes | Callback used to return the execution result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ``` -// Set the update policy. -let policy = { - autoDownload: false, - autoDownloadNet: true, - mode: 2, - autoUpgradeInterval: [ 2, 3 ], - autoUpgradeCondition: 2 +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for pausing download +var pauseDownloadOptions = { + isAllowAutoResume: true // Whether to allow automatic resuming of download } -updater.setUpdatePolicy(policy, result => { - console.log("setUpdatePolicy ", result) +updater.pauseDownload(versionDigestInfo, pauseDownloadOptions, (err) => { + console.log(`pauseDownload error ${JSON.stringify(err)}`); }); ``` -### setUpdatePolicy +### pauseDownload -setUpdatePolicy(policy: UpdatePolicy): Promise\<number> +pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise\<void> -Sets the update policy. This function uses a promise to return the result. +Resumes download of the new version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ----------------------------- | --------- | --------------------- | -| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | Yes | Options for pausing download.| **Return value** -| Type | Description | -| ---------------- | ---------------------------------------- | -| Promise\<number> | Promise used to return the execution result. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| **Example** ``` -let policy = { - autoDownload: false, - autoDownloadNet: true, - mode: 2, - autoUpgradeInterval: [ 2, 3 ], - autoUpgradeCondition: 2 +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for pausing download +var pauseDownloadOptions = { + isAllowAutoResume: true // Whether to allow automatic resuming of download } -updater.setUpdatePolicy(policy).then(result => - console.log("setUpdatePolicy ", result) -).catch(err => { - console.log("setUpdatePolicy promise error: " + err.code); +updater.pauseDownload(versionDigestInfo, pauseDownloadOptions).then(value => { + console.log(`pauseDownload`); +}).catch(err => { + console.log(`pauseDownload error ${JSON.stringify(err)}`); }); ``` -### getUpdatePolicy +### upgrade -getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void +upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, callback: AsyncCallback\<void>): void -Obtains the update policy. This function uses an asynchronous callback to return the result. +Updates the version. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| **Example** ``` -updater.getUpdatePolicy(policy => { - console.log("getUpdatePolicy success"); - console.log(`policy autoDownload = ` + policy.autoDownload); - console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); - console.log(`policy mode = ` + policy.mode); +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Installation options +var upgradeOptions = { + order: update.Order.INSTALL // Installation command +} +updater.upgrade(versionDigestInfo, upgradeOptions, (err) => { + console.log(`upgrade error ${JSON.stringify(err)}`); }); ``` -### getUpdatePolicy +### upgrade -getUpdatePolicy(): Promise\<UpdatePolicy> +upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): Promise\<void> -Obtains the update policy. This function uses a promise to return the result. +Updates the version. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | Yes | Update options.| + **Return value** -| Type | Description | -| --------------------------------------- | ---------------------------------------- | -| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy. | +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| **Example** ``` -updater.getUpdatePolicy().then(value => { - console.log(`info autoDownload = ` + value.autoDownload); - console.log(`info autoDownloadNet = ` + value.autoDownloadNet); - console.log(`info mode = ` + value.mode); +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Installation options +var upgradeOptions = { + order: update.Order.INSTALL // Installation command +} +updater.upgrade(versionDigestInfo, upgradeOptions).then(() => { + console.log(`upgrade start`); }).catch(err => { - console.log("getUpdatePolicy promise error: " + err.code); + console.log(`upgrade error ${JSON.stringify(err)}`); }); ``` -## UpdateTypes +### clearError + +clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback\<void>): void -Enumerates update types. +Clears errors. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Description | -| ----- | ------------- | -| OTA | OTA update. | -| patch | Patch update. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| clearOptions | [ClearOptions](#clearoptions) | Yes | Clear options.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| + +**Example** + +``` +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for clearing errors +var clearOptions = { + status: update.UpgradeStatus.UPGRADE_FAIL, +} +updater.clearError(versionDigestInfo, clearOptions, (err) => { + console.log(`clearError error ${JSON.stringify(err)}`); +}); +``` -## PackageTypes +### clearError -Enumerates update package types. +clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void> + +Clears errors. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| -------------------- | ------------- | --------------------------------------- | -| PACKAGE_TYPE_NORMAL | 1 | Common update package. | -| PACKAGE_TYPE_BASE | 2 | Basic update package. | -| PACKAGE_TYPE_CUST | 3 | Custom update package. | -| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. | -| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package. | -| PACKAGE_TYPE_VERSION | 6 | Version update package. | -| PACKAGE_TYPE_PATCH | 7 | Patch package. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information.| +| clearOptions | [ClearOptions](#clearoptions) | Yes | Update options.| + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + +**Example** + +``` +// Version digest information +var versionDigestInfo = { + versionDigest: "versionDigest" // Version digest information in the check result +} + +// Options for clearing errors +var clearOptions = { + status: update.UpgradeStatus.UPGRADE_FAIL, +} +updater.clearError(versionDigestInfo, clearOptions).then(() => { + console.log(`clearError success`); +}).catch(err => { + console.log(`clearError error ${JSON.stringify(err)}`); +}); +``` + +### getUpgradePolicy -## InstallMode +getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void -Enumerates update modes. +Obtains the update policy. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ------------- | ----------------- | -| INSTALL_MODE_NORMAL | 0 | Normal update. | -| INSTALL_MODE_NIGHT | 1 | Update at night. | -| INSTALL_MODE_AUTO | 2 | Automatic update. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | Yes | Callback used to return the result.| + +**Example** + +``` +updater.getUpgradePolicy((err, policy) => { + console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`); + console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`); +}); +``` + +### getUpgradePolicy -## NewVersionStatus +getUpgradePolicy(): Promise\<UpgradePolicy> -Enumerates new version check results. +Obtains the update policy. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Default Value | Description | -| ------------------- | ------------- | ---------------------------------------- | -| VERSION_STATUS_ERR | -1 | System error while checking for the new version. | -| VERSION_STATUS_NEW | 0 | New version detected. | -| VERSION_STATUS_NONE | 1 | No new version detected. | -| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Return value** + +| Type | Description | +| --------------------------------------- | ----------------- | +| Promise\<[UpgradePolicy](#upgradepolicy)> | Promise used to return the result.| + +**Example** + +``` +updater.getUpgradePolicy().then(policy => { + console.log(`policy downloadStrategy = ${policy.downloadStrategy}`); + console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`); +}).catch(err => { + console.log(`getUpgradePolicy promise error ${JSON.stringify(err)}`); +}); +``` -## UpdatePolicy +### setUpgradePolicy -Defines the update policy. +setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void + +Sets the update policy. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------------- | --------------------------- | --------- | ------------------------------------ | -| autoDownload | bool | Yes | Automatic update switch. | -| installMode | [InstallMode](#installmode) | Yes | Update mode. | -| autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) -## NewVersionInfo +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ---------- | +| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| -Defines the new version information. +**Example** + +``` +let policy = { + downloadStrategy: false, + autoUpgradeStrategy: false, + autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes +} +updater.setUpgradePolicy(policy, (err) => { + console.log(`setUpgradePolicy result: ${err}`); +}); +``` + +### setUpgradePolicy + +setUpgradePolicy(policy: UpgradePolicy): Promise\<void> + +Sets the update policy. This API uses a promise to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| --------------- | ---------------------------------------- | --------- | -------------------------------- | -| status | [NewVersionStatus](#newversionstatus) | Yes | Update status. | -| errMsg | string | Yes | Error message. | -| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result. | -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) -## CheckResult +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ----------------------------- | ---- | ------ | +| policy | [UpgradePolicy](#upgradepolicy) | Yes | Update policy.| + +**Return value** + +| Type | Description | +| ---------------- | --------------- | +| Promise\<void> | Promise used to return the result.| -Defines the version check result. +**Example** + +``` +let policy = { + downloadStrategy: false, + autoUpgradeStrategy: false, + autoUpgradePeriods: [ { start: 120, end: 240 } ] // Automatic update period, in minutes +} +updater.setUpgradePolicy(policy).then(() => { + console.log(`setUpgradePolicy success`); +}).catch(err => { + console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`); +}); +``` + +### terminateUpgrade + +terminateUpgrade(callback: AsyncCallback\<void>): void + +Terminates the update. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------- | ----------------------------- | --------- | --------------------------------- | -| versionName | string | Yes | Version name. | -| versionCode | number | Yes | Version code. | -| size | number | Yes | Version size. | -| verifyInfo | string | Yes | Version verification information. | -| packageType | [PackageTypes](#packagetypes) | Yes | Version type. | -| descriptionId | string | Yes | Version description information. | +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) -## DescriptionInfo +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| + +**Example** + +``` +updater.terminateUpgrade((err) => { + console.log(`terminateUpgrade error ${JSON.stringify(err)}`); +}); +``` + +### terminateUpgrade + +terminateUpgrade(): Promise\<void> + +Terminates the update. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + +**Example** + +``` +updater.terminateUpgrade().then(() => { + console.log(`terminateUpgrade success`); +}).catch(err => { + console.log(`terminateUpgrade error ${JSON.stringify(err)}`); +}); +``` + + +### on +on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void + +Enables listening for update events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| + +**Example** + +``` +var eventClassifyInfo = { + eventClassify: update.EventClassify.TASK, // Listening for update events + extraInfo: "" +} + +updater.on(eventClassifyInfo, (eventInfo) => { + console.log("updater on " + JSON.stringify(eventInfo)); +}); +``` + +### off +off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void + +Disables listening for update events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | No | Event callback.| + +**Example** + +``` +var eventClassifyInfo = { + eventClassify: update.EventClassify.TASK, // Listening for update events + extraInfo: "" +} + +updater.off(eventClassifyInfo, (eventInfo) => { + console.log("updater off " + JSON.stringify(eventInfo)); +}); +``` + +## Restorer + +### factoryReset + +factoryReset(callback: AsyncCallback\<void>): void + +Restores factory settings. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.FACTORY_RESET (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| + +**Example** + +``` +restorer.factoryReset((err) => { + console.log(`factoryReset error ${JSON.stringify(err)}`); +}); +``` + +### factoryReset + +factoryReset(): Promise\<void> + +Restores factory settings. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.FACTORY_RESET (a system permission) + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + +**Example** + +``` +restorer.factoryReset().then(() => { + console.log(`factoryReset success`); +}).catch(err => { + console.log(`factoryReset error ${JSON.stringify(err)}`); +}); +``` + +## LocalUpdater + +### verifyUpgradePackage + +verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<void>): void + +Verifies the update package. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file.| +| certsFile | string | Yes | Path of the certificate file.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| + +**Example** + +``` +var upgradeFile = { + fileType: update.ComponentType.OTA, // OTA package + filePath: "path" // Path of the local update package +} + +localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => { + console.log(`factoryReset error ${JSON.stringify(err)}`); +}); +``` + +### verifyUpgradePackage + +verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void> + +Verifies the update package. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| upgradeFile | [UpgradeFile](#upgradefile) | Yes | Update file.| +| certsFile | string | Yes | Path of the certificate file.| + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise used to return the result.| + +**Example** + +``` +var upgradeFile = { + fileType: update.ComponentType.OTA, // OTA package + filePath: "path" // Path of the local update package +} +localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => { + console.log(`verifyUpgradePackage success`); +}).catch(err => { + console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`); +}); +``` + +### applyNewVersion +applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: AsyncCallback\<void>): void + +Installs the update package. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| upgradeFile | Array<[UpgradeFile](#upgradefile)> | Yes | Update file.| +| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.| + +**Example** + +``` +var upgradeFiles = [{ + fileType: update.ComponentType.OTA, // OTA package + filePath: "path" // Path of the local update package +}] + +localUpdater.applyNewVersion(upgradeFiles, (err) => { + console.log(`applyNewVersion error ${JSON.stringify(err)}`); +}); +``` + +### applyNewVersion + +applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void> + +Installs the update package. This API uses a promise to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Required permission**: ohos.permission.UPDATE_SYSTEM (a system permission) + +**Return value** + +| Type | Description | +| ---------------------------------------- | ---------------- | +| Promise\<void> | Promise that returns no value.| + +**Example** + +``` +var upgradeFiles = [{ + fileType: update.ComponentType.OTA, // OTA package + filePath: "path" // Path of the local update package +}] +localUpdater.applyNewVersion(upgradeFiles).then(() => { + console.log(`applyNewVersion success`); +}).catch(err => { + console.log(`applyNewVersion error ${JSON.stringify(err)}`); +}); +``` + +### on +on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void + +Enables listening for update events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| + +**Example** + +``` +var eventClassifyInfo = { + eventClassify: update.EventClassify.TASK, // Listening for update events + extraInfo: "" +} + +function onTaskUpdate(eventInfo) { + console.log(`on eventInfo id `, eventInfo.eventId); +} + +localUpdater.on(eventClassifyInfo, onTaskUpdate); +``` + +### off +off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void + +Disables listening for update events. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Update.UpdateService + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | Yes | Event information.| +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | Yes | Event callback.| + +**Example** + +``` +var eventClassifyInfo = { + eventClassify: update.EventClassify.TASK, // Listening for update events + extraInfo: "" +} + +function onTaskUpdate(eventInfo) { + console.log(`on eventInfo id `, eventInfo.eventId); +} + +localUpdater.off(eventClassifyInfo, onTaskUpdate); +``` + +## UpgradeInfo + +Represents update information. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| upgradeApp | string | Yes | Application package name. | +| businessType | [BusinessType](#businesstype) | Yes | Update service type. | + +## BusinessType + +Enumerates update service types. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| vendor | [BusinessVendor](#businessvendor) | Yes | Application vendor. | +| subType | [BusinessSubType](#businesssubtype) | Yes | Update service sub-type. | + +## CheckResult + +Represents the package check result. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| isExistNewVersion | bool | Yes | Whether a new version is available. | +| newVersionInfo | [NewVersionInfo](#newversioninfo) | No | Information about the new version. | + +## NewVersionInfo + +Represents information about the new version. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components. | + +## VersionDigestInfo + +Represents version digest information. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| versionDigest | string | Yes | Version digest information. | + +## VersionComponent + +Represents a version component. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| componentId | number | Yes | Component ID. | +| componentType | [ComponentType](#componentyype) | Yes | Component type. | +| upgradeAction | [UpgradeAction](#upgradeaction) | Yes | Update mode. | +| displayVersion | string | Yes | Display version number. | +| innerVersion | string | Yes | Internal version number. | +| size | number | Yes | Update package size. | +| effectiveMode | [EffectiveMode](#effectivemode) | Yes | Effective mode. | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the version description file. | + +## DescriptionOptions + +Represents options of the description file. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| format | [DescriptionFormat](#descriptionformat) | Yes | Format of the description file. | +| language | string | Yes | Language of the description file. | + +## ComponentDescription + +Represents a component description file. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| componentId | string | Yes | Component ID. | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | Yes | Information about the description file. | + +## DescriptionInfo + +Represents information about the version description file. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| descriptionType | [DescriptionType](#descriptiontype) | Yes | Type of the description file. | +| content | string | Yes | Content of the description file. | + +## CurrentVersionInfo + +Represents information about the current version. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| osVersion | string | Yes | System version number. | +| deviceName | string | Yes | Device name. | +| versionComponents | Array\<[VersionComponent](#vesioncomponent)> | No | Version components. | + +## DownloadOptions + +Represents download options. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| allowNetwork | [NetType](#nettype) | Yes | Network type. | +| order | [Order](#order) | Yes | Update command. | + +## ResumeDownloadOptions + +Represents options for resuming download. + +**System capability**: SystemCapability.Update.UpdateService + +| Parameter | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| allowNetwork | [NetType](#nettype) | Yes | Network type. | + +## PauseDownloadOptions + +Represents options for pausing download. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| isAllowAutoResume | bool | Yes | Whether to allow automatic resuming of download. | + +## UpgradeOptions + +Represents update options. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| order | [Order](#order) | Yes | Update command. | + +## ClearOptions + +Represents options for clearing errors. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| status | [UpgradeStatus](#upgradestatus) | Yes | Error status. | + +## UpgradePolicy + +Represents an update policy. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| downloadStrategy | bool | Yes | Automatic download policy. | +| autoUpgradeStrategy | bool | Yes | Automatic update policy. | +| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | Yes | Automatic update period.| + +## UpgradePeriod + +Represents a period for automatic update. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| start | number | Yes | Start time. | +| end | number | Yes | End time. | + +## TaskInfo + +Represents task information. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| existTask | bool | Yes | Whether a task exists. | +| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | + +## EventInfo + +Represents event information. + +**System capability**: SystemCapability.Update.UpdateService + +| Parameter | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| eventId | [EventId](#eventid) | Yes | Event ID. | +| taskBody | [TaskBody](#taskinfo) | Yes | Task data. | + +## TaskBody + +Represents task data. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | Yes | Version digest information. | +| status | [UpgradeStatus](#upgradestatus) | Yes | Update status. | +| subStatus | number | No | Sub-status. | +| progress | number | Yes | Progress. | +| installMode | number | Yes | Installation mode. | +| errorMessages | Array\<[ErrorMessage](#errormessage)> | No | Error message. | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | Yes | Version components. | + +## ErrorMessage + +Represents an error message. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| errorCode | number | Yes | Error code. | +| errorMessage | string | Yes | Error description. | + +## EventClassifyInfo + +Represents event type information. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| eventClassify | [EventClassify](#eventclassify) | Yes | Event type. | +| extraInfo | string | Yes | Additional information. | + +## UpgradeFile + +Represents an update file. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Type | Mandatory | Description | +| ------------------- | --------------------------- | ---- | ------- | +| fileType | [ComponentType](#componenttype) | Yes | File type. | +| filePath | string | Yes | File path. | + +## UpgradeTaskCallback + +### (eventInfo: [EventInfo](#eventinfo)): void + +Event callback. + +**System capability**: SystemCapability.Update.UpdateService + +| Parameter | Type | Mandatory | Description | +| --------------- | ---------------------------------------- | ---- | ---- | +| eventInfo | [EventInfo](#eventinfo) | Yes | Event information.| + +## BusinessVendor + +Device vendor. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| PUBLIC | "public" | Open source. | + +## BusinessSubType + +Represents an update type. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| FIRMWARE | 1 | Firmware. | + +## ComponentType + +Represents a component type. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| OTA | 1 | Firmware. | + +## UpgradeAction + +Represents an update mode. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| UPGRADE | "upgrade" | Differential package. | +| RECOVERY | "recovery" | Recovery package. | + +## EffectiveMode + +Represents an effective mode. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| COLD | 1 | Cold update. | +| LIVE | 2 | Live update. | +| LIVE_AND_COLD | 3 | Hybrid live and cold update. | + +## DescriptionType + +Represents a description file type. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| CONTENT | 0 | Content. | +| URI | 1 | Link. | + +## DescriptionFormat + +Represents a description file format. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| STANDARD | 0 | Standard format. | +| SIMPLIFIED | 1 | Simple format. | + +## NetType + +Enumerates network types. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| CELLULAR | 1 | Data network. | +| METERED_WIFI | 2 | Wi-Fi hotspot. | +| NOT_METERED_WIFI | 4 | Non Wi-Fi hotspot. | +| WIFI | 6 | WIFI | +| CELLULAR_AND_WIFI | 7 | Data network and Wi-Fi. | + +## Order + +Represents an update command. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| DOWNLOAD | 1 | Download. | +| INSTALL | 2 | Install. | +| DOWNLOAD_AND_INSTALL | 3 | Download and install. | +| APPLY | 4 | Apply. | +| INSTALL_AND_APPLY | 6 | Install and apply. | + +## UpgradeStatus + +Enumerates update states. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| WAITING_DOWNLOAD | 20 | Waiting for download. | +| DOWNLOADING | 21 | Downloading. | +| DOWNLOAD_PAUSED | 22 | Download paused. | +| DOWNLOAD_FAIL | 23 | Download failed. | +| WAITING_INSTALL | 30 | Waiting for installation. | +| UPDATING | 31 | Updating. | +| WAITING_APPLY | 40 | Waiting for applying the update. | +| APPLYING | 21 | Applying the update. | +| UPGRADE_SUCCESS | 50 | Update succeeded. | +| UPGRADE_FAIL | 51 | Update failed. | + +## EventClassify + +Represents an event type. + +**System capability**: SystemCapability.Update.UpdateService + +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| TASK | 0x01000000 | Task event. | + +## EventId -Defines the version description information. +Enumerates event IDs. **System capability**: SystemCapability.Update.UpdateService -| Name | Type | Mandatory | Description | -| ------------- | ------ | --------- | ------------------------------ | -| descriptionId | string | Yes | Version ID information. | -| content | string | Yes | Version changelog information. | +| Name | Default Value | Description | +| ------------------- | ---- | -------- | +| EVENT_TASK_BASE | 0x01000000 | Indicates a task event. | +| EVENT_TASK_RECEIVE | 0x01000001 | Indicates that a task is received. | +| EVENT_TASK_CANCEL | 0x01000010 | Indicates that a task is cancelled. | +| EVENT_DOWNLOAD_WAIT | 0x01000011 | Indicates the state of waiting for the download. | +| EVENT_DOWNLOAD_START | 0x01000100 | Indicates that the download starts. | +| EVENT_DOWNLOAD_UPDATE | 0x01000101 | Indicates the download progress update. | +| EVENT_DOWNLOAD_PAUSE | 0x01000110 | Indicates that the download is paused. | +| EVENT_DOWNLOAD_RESUME | 0x01000111 | Indicates that the download is resumed. | +| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | Indicates that the download succeeded. | +| EVENT_DOWNLOAD_FAIL | 0x01001001 | Indicates that the download failed. | +| EVENT_UPGRADE_WAIT | 0x01001010 | Indicates the state of waiting for the update. | +| EVENT_UPGRADE_START | 0x01001011 | Indicates that the update starts. | +| EVENT_UPGRADE_UPDATE | 0x01001100 | Indicates that the update is in progress. | +| EVENT_APPLY_WAIT | 0x01001101 | Indicates the state of waiting for applying the update. | +| EVENT_APPLY_START | 0x01001110 | Indicates the state of applying the update. | +| EVENT_UPGRADE_SUCCESS | 0x01001111 | Indicates that the update succeeded. | +| EVENT_UPGRADE_FAIL | 0x01010000 | Indicates that the update failed. | diff --git a/en/application-dev/reference/apis/js-apis-uri.md b/en/application-dev/reference/apis/js-apis-uri.md index a6c8823599cfee6dba5288e6555d6c618fd414c8..60fd45f98209c718374e4a2633b074a531aa719c 100644 --- a/en/application-dev/reference/apis/js-apis-uri.md +++ b/en/application-dev/reference/apis/js-apis-uri.md @@ -72,8 +72,8 @@ Obtains the query string applicable to this URI. **Example** ```js -const uri = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); -uri.toString() +const result = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); +result.toString() ``` diff --git a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md deleted file mode 100644 index 6bbf0f941909786361f651546a3fab9fe129c69c..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ /dev/null @@ -1,86 +0,0 @@ -# uriPermissionManager - -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. - - -Implements URI permission management. - - -## Modules to Import - - -``` -import UriPermissionManager from '@ohos.application.uriPermissionManager'; -``` - - -## uriPermissionManager.verifyUriPermission - -verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback<number>): void - -Checks whether an application has the permission specified by **flag** for an URI. This API uses a callback to return the result. - -**System capability**: - -SystemCapability.Ability.AbilityRuntime.Core - -**Parameters** - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| - | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.| - | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| - | callback | AsyncCallback<number> | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| - -**Example** - - ```js - import WantConstant from '@ohos.ability.wantConstant'; - let accessTokenId =1 - let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - UriPermissionManager.verifyUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => { - console.log("result.code = " + result.code) - }) // accessTokenId is obtained through the **BundleManager** API. - ``` - - -## uriPermissionManager.verifyUriPermission - -verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise<number> - -Checks whether an application has the permission specified by **flag** for an URI. This API uses a callback to return the result. - -**System capability**: - -SystemCapability.Ability.AbilityRuntime.Core - -**Parameters** - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.| - | flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.| - | accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.| - -**Return value** - - | Type| Description| - | -------- | -------- | - | Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.| - -**Example** - - ```js - import WantConstant from '@ohos.ability.wantConstant'; - let accessTokenId =1 - let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId) - .then((data) => { - console.log('Verification succeeded.' + data) - }).catch((error) => { - console.log('Verification failed.'); - }) - ``` diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index fd826706700190a3d2f042a155cca1a2e1c96b81..55694ec1cb024a25affa93feca40b2a73ef38234 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -1,6 +1,7 @@ # URL String Parsing -> **NOTE**<br> +> **NOTE** +> > 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. @@ -25,13 +26,13 @@ Creates a **URLSearchParams** instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record<string, string>**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object | +| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:<br>- **string[][]**: two-dimensional string array<br>- **Record<string, string>**: list of objects<br>- **string**: string<br>- **URLSearchParams**: object| **Example** ```js var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); -var objectParams1 = new Url.URLSearchParams({"fod" : 1 , "bard" : 2}); +var objectParams1 = new Url.URLSearchParams({"fod" : '1' , "bard" : '2'}); var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); var params = new Url.URLSearchParams(urlObject.search); @@ -48,17 +49,17 @@ Appends a key-value pair into the query string. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the key-value pair to append. | - | value | string | Yes | Value of the key-value pair to append. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key of the key-value pair to append.| +| value | string | Yes| Value of the key-value pair to append.| **Example** ```js let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); -paramsObject.append('fod', 3); +paramsObject.append('fod', '3'); ``` @@ -72,9 +73,9 @@ Deletes key-value pairs of the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the key-value pairs to delete. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key of the key-value pairs to delete.| **Example** @@ -95,23 +96,23 @@ Obtains all the key-value pairs based on the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to obtain all key-value pairs. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key specified to obtain all key-value pairs.| **Return value** - | Type | Description | - | -------- | -------- | - | string[] | All key-value pairs matching the specified key. | +| Type| Description| +| -------- | -------- | +| string[] | All key-value pairs matching the specified key.| **Example** ```js -let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); -paramsObject.append('fod', 3); // Add a second value for the fod parameter. -console.log(params.getAll('fod')) // Output ["1","3"]. +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let params = new Url.URLSearchParams(urlObject.search.slice(1)); +params.append('fod', '3'); // Add a second value for the fod parameter. +console.log(params.getAll('fod').toString()) // Output ["1","3"]. ``` @@ -125,9 +126,9 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<[string, string]> | ES6 iterator. | +| Type| Description| +| -------- | -------- | +| IterableIterator<[string, string]> | ES6 iterator.| **Example** @@ -149,18 +150,18 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. | - | thisArg | Object | No | Value to use when the callback is invoked. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance.| +| thisArg | Object | No| Value to use when the callback is invoked.| **Table 1** callbackfn parameter description - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | string | Yes | Value that is currently traversed. | - | key | string | Yes | Key that is currently traversed. | - | searchParams | Object | Yes | Instance that invokes the **forEach** method. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | string | Yes| Value that is currently traversed.| +| key | string | Yes| Key that is currently traversed.| +| searchParams | Object | Yes| Instance that invokes the **forEach** method.| **Example** @@ -182,24 +183,23 @@ Obtains the value of the first key-value pair based on the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to obtain the value. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key specified to obtain the value.| **Return value** - | Type | Description | - | -------- | -------- | - | string | Returns the value of the first key-value pair if obtained. | - | null | Returns null if no value is obtained. | +| Type| Description| +| -------- | -------- | +| string | Returns the value of the first key-value pair if obtained.| +| null | Returns null if no value is obtained.| **Example** ```js -var paramsOject = new Url.URLSearchParams(document.location.search.substring(1)); +var paramsOject = new Url.URLSearchParams('name=Jonathan&age=18'); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 -var address = paramsOject.get("address"); // null ``` @@ -213,15 +213,15 @@ Checks whether a key has a value. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to search for its value. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key specified to search for its value.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value exists; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value exists; returns **false** otherwise.| **Example** @@ -242,17 +242,17 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the value to set. | - | value | string | Yes | Value to set. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Key of the value to set.| +| value | string | Yes| Value to set.| **Example** ```js let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); -paramsObject.set('baz', 3); // Add a third parameter. +paramsObject.set('baz', '3'); // Add a third parameter. ``` @@ -283,9 +283,9 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs. **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs. | +| Type| Description| +| -------- | -------- | +| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs.| **Example** @@ -307,9 +307,9 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs. **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs. | +| Type| Description| +| -------- | -------- | +| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs.| **Example** @@ -331,9 +331,9 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<[string, string]> | ES6 iterator. | +| Type| Description| +| -------- | -------- | +| IterableIterator<[string, string]> | ES6 iterator.| **Example** @@ -355,16 +355,16 @@ Obtains search parameters that are serialized as a string and, if necessary, per **Return value** - | Type | Description | - | -------- | -------- | - | string | String of serialized search parameters, which is percent-encoded if necessary. | +| Type| Description| +| -------- | -------- | +| string | String of serialized search parameters, which is percent-encoded if necessary.| **Example** ```js let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); let params = new Url.URLSearchParams(url.search.slice(1)); -params.append('fod', 3); +params.append('fod', '3'); console.log(params.toString()); ``` @@ -401,10 +401,10 @@ Creates a URL. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | url | string | Yes | Input object. | - | base | string \ | URL | No | Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| url | string | Yes| Input object.| +| base | string \| URL | No| Input parameter, which can be any of the following:<br>- **string**: string<br>- **URL**: string or object| **Example** @@ -434,9 +434,9 @@ Converts the parsed URL into a string. **Return value** - | Type | Description | - | -------- | -------- | - | string | Website address in a serialized string. | +| Type| Description| +| -------- | -------- | +| string | Website address in a serialized string.| **Example** @@ -456,12 +456,12 @@ Converts the parsed URL into a JSON string. **Return value** - | Type | Description | - | -------- | -------- | - | string | Website address in a serialized string. | +| Type| Description| +| -------- | -------- | +| string | Website address in a serialized string.| **Example** ```js const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() -``` \ No newline at end of file +``` diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 63beaae8031c42ad274d2e151dad4c029f799761..71b0490ea8c610dc0169222042ec7770c19d0a83 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -1,6 +1,9 @@ # USB -> **NOTE**<br> +This module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control. + +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -126,8 +129,8 @@ Checks whether the application has the permission to access the device. - **Example** ```js - let divicesName="1-1"; - let bool = usb.hasRight(divicesName); + let devicesName="1-1"; + let bool = usb.hasRight(devicesName); console.log(bool); ``` @@ -152,8 +155,8 @@ Requests the temporary permission for the application to access the USB device. - **Example** ```js - let divicesName="1-1"; - usb.requestRight(divicesName).then((ret) => { + let devicesName="1-1"; + usb.requestRight(devicesName).then((ret) => { console.log(`requestRight = ${JSON.stringify(ret)}`); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md index 56ac3823f29e6cee7efa13094d4becf5528fa854..d98f43faaf7bc2a575cfa80907a776d9436bfbff 100644 --- a/en/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -1,5 +1,7 @@ # User Authentication +The **userIAM.userAuth** module provides user authentication capabilities in identity authentication scenarios, such as device unlocking, payment, and app login. + > **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. @@ -10,26 +12,7 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; ``` -## Example - -```js -// API version 6 -import userIAM_userAuth from '@ohos.userIAM.userAuth'; - -export default { - startAuth() { - console.info("start auth"); - let auth = userIAM_userAuth.getAuthenticator(); - auth.execute("FACE_ONLY", "S2").then((code)=>{ - console.info("auth success"); - // Add the logic to be executed when the authentication is successful. - }).catch((code)=>{ - console.error("auth fail, code = " + code); - // Add the logic to be executed when the authentication fails. - }); - } -} -``` +## Sample Code ```js // API version 8 @@ -106,133 +89,25 @@ export default { } ``` -## userIAM_userAuth.getAuthenticator<sup>(deprecated)</sup> - -getAuthenticator(): Authenticator - -> **NOTE**<br> -> This API is not longer maintained since API version 8. You are advised to use [constructor](#constructor8). - -Obtains an **Authenticator** object for user authentication. - -**Required permissions**: ohos.permission.ACCESS_BIOMETRIC - -**System capability**: SystemCapability.UserIAM.UserAuth.Core - -**Return value** -| Type | Description | -| ----------------------------------------- | ------------ | -| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained.| - -**Example** - ```js - let authenticator = userIAM_userAuth.getAuthenticator(); - ``` - -## Authenticator<sup>(deprecated)</sup> - -> **NOTE**<br> -> This object is not longer maintained since API version 8. You are advised to use [UserAuth](#userauth8). - -Provides methods to manage an **Authenticator** object. - - -### execute<sup>(deprecated)</sup> - -execute(type: string, level: string, callback: AsyncCallback<number>): void - -> **NOTE**<br> -> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). - -Performs user authentication. This API uses asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ACCESS_BIOMETRIC - -**System capability**: SystemCapability.UserIAM.UserAuth.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| -| callback | AsyncCallback<number> | No | Callback used to return the result. | - - Parameters returned in callback - -| Type | Description | -| ------ | ------------------------------------------------------------ | -| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated).| - -**Example** - ```js - authenticator.execute("FACE_ONLY", "S2", (code)=>{ - if (code == userIAM_userAuth.AuthenticationResult.SUCCESS) { - console.info("auth success"); - return; - } - console.error("auth fail, code = " + code); - }) - ``` - - -### execute<sup>(deprecated)</sup> - -execute(type:string, level:string): Promise<number> - -> **NOTE**<br> -> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). - -Performs user authentication. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ACCESS_BIOMETRIC - -**System capability**: SystemCapability.UserIAM.UserAuth.Core - -**Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------------------------------ | -| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| -| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| - -**Return value** -| Type | Description | -| --------------------- | ------------------------------------------------------------ | -| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated).| - -**Example** - ```js -let authenticator = userIAM_userAuth.getAuthenticator(); -authenticator.execute("FACE_ONLY", "S2").then((code)=>{ - console.info("auth success"); -}).catch((code)=>{ - console.error("auth fail, code = " + code); -}); -``` - -## AuthenticationResult<sup>(deprecated)</sup> - -> **NOTE**<br> -> This parameter is not longer maintained since API version 8. You are advised to use [ResultCode](#resultcode8). - -Enumerates the authentication results. +// API version 6 +import userIAM_userAuth from '@ohos.userIAM.userAuth'; -**System capability**: SystemCapability.UserIAM.UserAuth.Core +export default { + startAuth() { + console.info("start auth"); + let auth = userIAM_userAuth.getAuthenticator(); + auth.execute("FACE_ONLY", "S2").then((code)=>{ + console.info("auth success"); + // Add the logic to be executed when the authentication is successful. + }).catch((code)=>{ + console.error("auth fail, code = " + code); + // Add the logic to be executed when the authentication fails. + }); + } +} +``` -| Name | Default Value| Description | -| ------------------ | ------ | -------------------------- | -| NO_SUPPORT | -1 | The device does not support the current authentication mode.| -| SUCCESS | 0 | The authentication is successful. | -| COMPARE_FAILURE | 1 | The feature comparison failed. | -| CANCELED | 2 | The authentication was canceled by the user. | -| TIMEOUT | 3 | The authentication has timed out. | -| CAMERA_FAIL | 4 | The camera failed to start. | -| BUSY | 5 | The authentication service is not available. Try again later. | -| INVALID_PARAMETERS | 6 | The authentication parameters are invalid. | -| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold.| -| NOT_ENROLLED | 8 | No authentication credential is registered. | -| GENERAL_ERROR | 100 | Other errors. | ## UserAuth<sup>8+</sup> @@ -607,3 +482,131 @@ Enumerates the trust levels of the authentication result. | ATL2 | 20000 | Trust level 2.| | ATL3 | 30000 | Trust level 3.| | ATL4 | 40000 | Trust level 4.| + +## userIAM_userAuth.getAuthenticator<sup>(deprecated)</sup> + +getAuthenticator(): Authenticator + +> **NOTE**<br> +> This API is not longer maintained since API version 8. You are advised to use [constructor](#constructor8). + +Obtains an **Authenticator** object for user authentication. + +**Required permissions**: ohos.permission.ACCESS_BIOMETRIC + +**System capability**: SystemCapability.UserIAM.UserAuth.Core + +**Return value** +| Type | Description | +| ----------------------------------------- | ------------ | +| [Authenticator](#authenticatordeprecated) | **Authenticator** object obtained.| + +**Example** + ```js + let authenticator = userIAM_userAuth.getAuthenticator(); + ``` + +## Authenticator<sup>(deprecated)</sup> + +> **NOTE**<br> +> This object is not longer maintained since API version 8. You are advised to use [UserAuth](#userauth8). + +Provides methods to manage an **Authenticator** object. + + +### execute<sup>(deprecated)</sup> + +execute(type: string, level: string, callback: AsyncCallback<number>): void + +> **NOTE**<br> +> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). + +Performs user authentication. This API uses asynchronous callback to return the result. + +**Required permissions**: ohos.permission.ACCESS_BIOMETRIC + +**System capability**: SystemCapability.UserIAM.UserAuth.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| +| callback | AsyncCallback<number> | No | Callback used to return the result. | + + Parameters returned in callback + +| Type | Description | +| ------ | ------------------------------------------------------------ | +| number | Authentication result. For details, see [AuthenticationResult](#authenticationresultdeprecated).| + +**Example** + ```js + authenticator.execute("FACE_ONLY", "S2", (code)=>{ + if (code == userIAM_userAuth.AuthenticationResult.SUCCESS) { + console.info("auth success"); + return; + } + console.error("auth fail, code = " + code); + }) + ``` + + +### execute<sup>(deprecated)</sup> + +execute(type:string, level:string): Promise<number> + +> **NOTE**<br> +> This API is not longer maintained since API version 8. You are advised to use [auth](#auth8). + +Performs user authentication. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.ACCESS_BIOMETRIC + +**System capability**: SystemCapability.UserIAM.UserAuth.Core + +**Parameters** +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Authentication type. Only **FACE_ONLY** is supported.<br>**ALL** is reserved and not supported by the current version.| +| level | string | Yes | Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).<br>Devices capable of 3D facial recognition support S3 and lower-level authentication.<br>Devices capable of 2D facial recognition support S2 and lower-level authentication.| + +**Return value** +| Type | Description | +| --------------------- | ------------------------------------------------------------ | +| Promise<number> | Promise used to return the authentication result, which is a number. For details, see [AuthenticationResult](#authenticationresultdeprecated).| + +**Example** + +```js +let authenticator = userIAM_userAuth.getAuthenticator(); +authenticator.execute("FACE_ONLY", "S2").then((code)=>{ + console.info("auth success"); +}).catch((code)=>{ + console.error("auth fail, code = " + code); +}); +``` + +## AuthenticationResult<sup>(deprecated)</sup> + +> **NOTE**<br> +> This parameter is not longer maintained since API version 8. You are advised to use [ResultCode](#resultcode8). + +Enumerates the authentication results. + +**System capability**: SystemCapability.UserIAM.UserAuth.Core + +| Name | Default Value| Description | +| ------------------ | ------ | -------------------------- | +| NO_SUPPORT | -1 | The device does not support the current authentication mode.| +| SUCCESS | 0 | The authentication is successful. | +| COMPARE_FAILURE | 1 | The feature comparison failed. | +| CANCELED | 2 | The authentication was canceled by the user. | +| TIMEOUT | 3 | The authentication has timed out. | +| CAMERA_FAIL | 4 | The camera failed to start. | +| BUSY | 5 | The authentication service is not available. Try again later. | +| INVALID_PARAMETERS | 6 | The authentication parameters are invalid. | +| LOCKED | 7 | The user account is locked because the number of authentication failures has reached the threshold.| +| NOT_ENROLLED | 8 | No authentication credential is registered. | +| GENERAL_ERROR | 100 | Other errors. | diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 2ac8daeb3799908d57a5b7a2c5fd456dcfee8f59..afa1c20bcd4eace98512772fb3cd7160d23a5b92 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -61,7 +61,7 @@ Obtains detailed information about a system error code. **Example** ```js - var errnum = 10; // 10 is the system error code. + var errnum = 10; // 10 is a system error code. var result = util.getErrorString(errnum); console.log("result = " + result); ``` @@ -91,23 +91,29 @@ Calls back an asynchronous function. In the callback, the first parameter indica async function promiseFn() { return Promise.reject('value'); } + var err = "type err"; var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { console.log(err); console.log(ret); - }) + }, err) ``` -## util.promiseWrapper +## util.promiseWrapper<sup>(deprecated)</sup> promiseWrapper(original: (err: Object, value: Object) => void): Object +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use **[util.promisify9+](#utilpromisify9)** instead. + Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | original | Function | Yes| Asynchronous function.| @@ -119,19 +125,47 @@ Processes an asynchronous function and returns a promise version. **Example** ```js - function aysnFun(str1, str2, callback) { - if (typeof str1 === 'string' && typeof str2 === 'string') { - callback(null, str1 + str2); - } else { - callback('type err'); - } + function aysnFun() { + return 0; } - let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World'); - newPromiseObj.then(res => { - console.log(res); + let newPromiseObj = util.promiseWrapper(aysnFun); + newPromiseObj().then(res => { + console.log(res); }) ``` +## util.promisify<sup>9+</sup> + +promisify(original: (err: Object, value: Object) => void): Function + +Processes an asynchronous function and returns a promise. + +**System capability**: SystemCapability.Utils.Lang + +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| + +**Return value** +| Type| Description| +| -------- | -------- | +| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise.| + +**Example** + ```js + function aysnFun(str1, str2) { + if (typeof str1 === 'object' && typeof str2 === 'object') { + return str2 + } else { + return str1 + } + } + let newPromiseObj = util.promisify(aysnFun); + newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => { + console.log(res); + }) + ``` ## TextDecoder @@ -184,7 +218,7 @@ Decodes the input content. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| input | Unit8Array | Yes| Uint8Array to decode.| +| input | Uint8Array | Yes| Uint8Array to decode.| | options | Object | No| Options related to decoding.| **Table 2** options @@ -287,10 +321,11 @@ Stores the UTF-8 encoded text. **Example** ```js - var that = new util.TextEncoder(); - var buffer = new ArrayBuffer(4); - this.dest = new Uint8Array(buffer); - var result = that.encodeInto("abcd", this.dest); + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(4) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('abcd', dest) ``` ## RationalNumber<sup>8+</sup> @@ -337,7 +372,7 @@ Creates a **RationalNumber** object based on the given string. **Example** ```js var rationalNumber = new util.RationalNumber(1,2); - var rational = rationalNumer.creatRationalFromString("3/4"); + var rational = util.RationalNumber.createRationalFromString("3/4"); ``` @@ -362,7 +397,7 @@ Compares this **RationalNumber** object with a given object. **Example** ```js var rationalNumber = new util.RationalNumber(1,2); - var rational = rationalNumer.creatRationalFromString("3/4"); + var rational = util.RationalNumber.createRationalFromString("3/4"); var result = rationalNumber.compareTo(rational); ``` @@ -408,7 +443,7 @@ Checks whether this **RationalNumber** object equals the given object. **Example** ```js var rationalNumber = new util.RationalNumber(1,2); - var rational = rationalNumer.creatRationalFromString("3/4"); + var rational = util.RationalNumber.createRationalFromString("3/4"); var result = rationalNumber.equals(rational); ``` @@ -435,7 +470,7 @@ Obtains the greatest common divisor of two specified integers. **Example** ```js var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.getCommonDivisor(4,6); + var result = util.RationalNumber.getCommonDivisor(4,6); ``` @@ -672,7 +707,7 @@ Clears key-value pairs from this buffer. The **afterRemoval()** method will be c ```js var pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.size(); + var result = pro.length; pro.clear(); ``` @@ -954,14 +989,6 @@ Performs subsequent operations after a value is removed. { super(); } - static getInstance() - { - if(this.instance == null) - { - this.instance = new ChildLruBuffer(); - } - return this.instance; - } afterRemoval(isEvict, key, value, newValue) { if (isEvict === false) @@ -970,7 +997,8 @@ Performs subsequent operations after a value is removed. } } } - ChildLruBuffer.getInstance().afterRemoval(false,10,30,null); + var lru = new ChildLruBuffer(); + lru.afterRemoval(false,10,30,null); ``` @@ -1063,7 +1091,7 @@ Obtains a two-dimensional array in key-value pairs. ```js var pro = new util.LruBuffer(); pro.put(2,10); - var result = pro[symbol.iterator](); + var result = pro[Symbol.iterator](); ``` @@ -1551,7 +1579,7 @@ Encodes the input content asynchronously. var rarray = new Uint8Array([99,122,69,122]); that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - console.log(val[i]) + console.log(val[i].toString()) } }) ``` @@ -1610,7 +1638,7 @@ Decodes the input content asynchronously. var rarray = new Uint8Array([115,49,51]); that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - console.log(val[i]) + console.log(val[i].toString()) } }) ``` @@ -1654,7 +1682,7 @@ Checks whether the input value is of the **ArrayBuffer** type. **Example** ```js var that = new util.types(); - var result = that.isAnyArrayBuffer(new ArrayBuffer([])); + var result = that.isAnyArrayBuffer(new ArrayBuffer(0)); ``` @@ -1734,7 +1762,7 @@ Checks whether the input value is of the **ArrayBuffer** type. **Example** ```js var that = new util.types(); - var result = that.isArrayBuffer(new ArrayBuffer([])); + var result = that.isArrayBuffer(new ArrayBuffer(0)); ``` @@ -1885,8 +1913,7 @@ Checks whether the input value is of the **native external** type. **Example** ```js var that = new util.types(); - const data = util.createExternalType(); - var result = that.isExternal(data); + var result = that.isExternal(true); ``` diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md index 75dda908af3e32140bf7c94b92ff73117be0ad7e..15fd2c4fcdeb681b4ace2dc49d521f54e08014f5 100644 --- a/en/application-dev/reference/apis/js-apis-wallpaper.md +++ b/en/application-dev/reference/apis/js-apis-wallpaper.md @@ -1,7 +1,9 @@ # Wallpaper -> **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. +> **NOTE** +> +> 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. ## Modules to Import @@ -465,7 +467,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses an a }).catch((error) => { console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); }); - ``` +``` ## wallpaper.setWallpaper @@ -520,7 +522,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses a pr }).catch((error) => { console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); }); - ``` +``` ## wallpaper.getFile<sup>8+</sup> @@ -528,7 +530,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE **System capability**: SystemCapability.MiscServices.Wallpaper @@ -557,7 +559,7 @@ getFile(wallpaperType: WallpaperType): Promise<number> Obtains the wallpaper of the specified type. This API uses a promise to return the result. -**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE **System capability**: SystemCapability.MiscServices.Wallpaper @@ -636,7 +638,7 @@ Obtains the pixel image for the wallpaper of the specified type. This API uses a **Example** ```js - wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { + wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data); console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data)); }).catch((err) => { @@ -695,9 +697,9 @@ Unsubscribes from the wallpaper color change event. wallpaper.on('colorChange', listener); // Unsubscribe from the listener. wallpaper.off('colorChange', listener); -//Unsubscribe from all subscriptions of the colorChange type. +// Unsubscribe from all subscriptions of the colorChange type. wallpaper.off('colorChange'); -``` + ``` ## RgbaColor diff --git a/en/application-dev/reference/apis/js-apis-wantAgent.md b/en/application-dev/reference/apis/js-apis-wantAgent.md index c6a89b78715f1a819cd04a11f67a0609a98aa4f9..5421d20c5fc129c726f31deaae6610d2bdc28d2e 100644 --- a/en/application-dev/reference/apis/js-apis-wantAgent.md +++ b/en/application-dev/reference/apis/js-apis-wantAgent.md @@ -1,5 +1,7 @@ # WantAgent +The **WantAgent** module provides APIs for triggering, canceling, and comparing **WantAgent** objects. You can use the APIs to create a **WantAgent** object, and obtain the user ID, bundle name, and want information of the object. + > **NOTE** > > 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. @@ -418,6 +420,8 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name | Readable| Writable| Type | Mandatory| Description | @@ -490,6 +494,8 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name | Readable| Writable| Type | Mandatory| Description | @@ -704,7 +710,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur | Name | Readable| Writable| Type | Mandatory| Description | | ----------- | --- | ---- | ----------------------------- | ---- | ------------------------------- | -| agent | Yes | No | WantAgent | Yes | **WantAgent** object to trigger. | +| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. | | triggerInfo | Yes | No | TriggerInfo | Yes | **TriggerInfo** object. | | callback | Yes | No | AsyncCallback\<CompleteData\> | Yes | Callback used to return the result.| @@ -1052,7 +1058,7 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => { | Name | Readable| Writable| Type | Mandatory| Description | | -------------- | --- | ---- | ------------------------------- | ---- | ---------------------- | | wants | Yes | Yes | Array\<Want\> | Yes | Array of all **Want** objects. | -| operationType | Yes | Yes | wantAgent.OperationType | Yes | Action type. | +| operationType | Yes | Yes | wantAgent.OperationType | Yes | Operation type. | | requestCode | Yes | Yes | number | Yes | Request code defined by the user.| | wantAgentFlags | Yes | Yes | Array<wantAgent.WantAgentFlags> | No | Array of flags for using the **WantAgent** object. | | extraInfo | Yes | Yes | {[key: string]: any} | No | Extra information. | diff --git a/en/application-dev/reference/apis/js-apis-webgl.md b/en/application-dev/reference/apis/js-apis-webgl.md index e71562765f7b0a4330cfce26a8c57f835f8ed055..95738321bc5717e97657191b416e3ceca220d75d 100644 --- a/en/application-dev/reference/apis/js-apis-webgl.md +++ b/en/application-dev/reference/apis/js-apis-webgl.md @@ -1,11 +1,13 @@ -# webgl - -> **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. +# WebGL +The **WebGL** module provides the graphics drawing capability, such as processing the graphics position and color. This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set. For more information, see [WebGL™](https://www.khronos.org/registry/webgl/specs/latest/1.0/). +> **NOTE** +> +> 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. + ## Invoking Method @@ -37,7 +39,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); **System capability**: SystemCapability.Graphic.Graphic2D.WebGL - **Table 1** Type +**Table 1** Type | Name| Type| | -------- | -------- | @@ -61,11 +63,11 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); | WebGLPowerPreference | string | -## Interface +## APIs **System capability**: SystemCapability.Graphic.Graphic2D.WebGL - **Table 2** Interface +**Table 2** APIs | Name| | -------- | @@ -566,7 +568,7 @@ WebGLRenderingContextOverloads | bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | | compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | | compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void; | | texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | | texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | | texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | diff --git a/en/application-dev/reference/apis/js-apis-webgl2.md b/en/application-dev/reference/apis/js-apis-webgl2.md index 386d1c53dad0df97a9fd0fbbeac33aec45492d5c..0052505dfb6d127a7081b35b01f3b302b74b2deb 100644 --- a/en/application-dev/reference/apis/js-apis-webgl2.md +++ b/en/application-dev/reference/apis/js-apis-webgl2.md @@ -1,11 +1,13 @@ -# webgl2 - -> **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. +# WebGL2 +The **WebGL2** module supports graphics drawing, such as processing the graphics position and color. WebGL2 provides enhanced capabilities in the rendering pipeline and shader language than WebGL. This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set. For more information, see [WebGL™](https://www.khronos.org/registry/webgl/specs/latest/2.0/). +> **NOTE** +> +> 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. + ## Invoking Method @@ -37,7 +39,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); **System capability**: SystemCapability.Graphic.Graphic2D.WebGL2 - **Table 1** Type +**Table 1** Type | Name| Type| | -------- | -------- | @@ -47,11 +49,11 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); | Uint32List | array | -## Interface +## APIs **System capability**: SystemCapability.Graphic.Graphic2D.WebGL2 - **Table 2** Interface +**Table 2** APIs | Name| | -------- | @@ -71,409 +73,409 @@ WebGL2RenderingContextBase ### Attributes - | Name| Type| Mandatory| +| Name| Type| Mandatory| | -------- | -------- | -------- | -| READ_BUFFER | GLenum | Yes| -| UNPACK_ROW_LENGTH | GLenum | Yes| -| UNPACK_SKIP_ROWS | GLenum | Yes| -| UNPACK_SKIP_PIXELS | GLenum | Yes| -| PACK_ROW_LENGTH | GLenum | Yes| -| PACK_SKIP_ROWS | GLenum | Yes| -| PACK_SKIP_PIXELS | GLenum | Yes| -| COLOR | GLenum | Yes| -| DEPTH | GLenum | Yes| -| STENCIL | GLenum | Yes| -| RED | GLenum | Yes| -| RGB8 | GLenum | Yes| -| RGBA8 | GLenum | Yes| -| RGB10_A2 | GLenum | Yes| -| TEXTURE_BINDING_3D | GLenum | Yes| -| UNPACK_SKIP_IMAGES | GLenum | Yes| -| UNPACK_IMAGE_HEIGHT | GLenum | Yes| -| TEXTURE_3D | GLenum | Yes| -| TEXTURE_WRAP_R | GLenum | Yes| -| MAX_3D_TEXTURE_SIZE | GLenum | Yes| -| UNSIGNED_INT_2_10_10_10_REV | GLenum | Yes| -| MAX_ELEMENTS_VERTICES | GLenum | Yes| -| MAX_ELEMENTS_INDICES | GLenum | Yes| -| TEXTURE_MIN_LOD | GLenum | Yes| -| TEXTURE_MAX_LOD | GLenum | Yes| -| TEXTURE_BASE_LEVEL | GLenum | Yes| -| TEXTURE_MAX_LEVEL | GLenum | Yes| -| MIN | GLenum | Yes| -| MAX | GLenum | Yes| -| DEPTH_COMPONENT24 | GLenum | Yes| -| MAX_TEXTURE_LOD_BIAS | GLenum | Yes| -| TEXTURE_COMPARE_MODE | GLenum | Yes| -| TEXTURE_COMPARE_FUNC | GLenum | Yes| -| CURRENT_QUERY | GLenum | Yes| -| QUERY_RESULT | GLenum | Yes| -| QUERY_RESULT_AVAILABLE | GLenum | Yes| -| STREAM_READ | GLenum | Yes| -| STREAM_COPY | GLenum | Yes| -| STATIC_READ | GLenum | Yes| -| STATIC_COPY | GLenum | Yes| -| DYNAMIC_READ | GLenum | Yes| -| DYNAMIC_COPY | GLenum | Yes| -| MAX_DRAW_BUFFERS | GLenum | Yes| -| DRAW_BUFFER0 | GLenum | Yes| -| DRAW_BUFFER1 | GLenum | Yes| -| DRAW_BUFFER2 | GLenum | Yes| -| DRAW_BUFFER3 | GLenum | Yes| -| DRAW_BUFFER4 | GLenum | Yes| -| DRAW_BUFFER5 | GLenum | Yes| -| DRAW_BUFFER6 | GLenum | Yes| -| DRAW_BUFFER7 | GLenum | Yes| -| DRAW_BUFFER8 | GLenum | Yes| -| DRAW_BUFFER9 | GLenum | Yes| -| DRAW_BUFFER10 | GLenum | Yes| -| DRAW_BUFFER11 | GLenum | Yes| -| DRAW_BUFFER12 | GLenum | Yes| -| DRAW_BUFFER13 | GLenum | Yes| -| DRAW_BUFFER14 | GLenum | Yes| -| DRAW_BUFFER15 | GLenum | Yes| -| MAX_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes| -| MAX_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes| -| SAMPLER_3D | GLenum | Yes| -| SAMPLER_2D_SHADOW | GLenum | Yes| -| FRAGMENT_SHADER_DERIVATIVE_HINT | GLenum | Yes| -| PIXEL_PACK_BUFFER | GLenum | Yes| -| PIXEL_UNPACK_BUFFER | GLenum | Yes| -| PIXEL_PACK_BUFFER_BINDING | GLenum | Yes| -| PIXEL_UNPACK_BUFFER_BINDING | GLenum | Yes| -| FLOAT_MAT2x3 | GLenum | Yes| -| FLOAT_MAT2x4 | GLenum | Yes| -| FLOAT_MAT3x2 | GLenum | Yes| -| FLOAT_MAT3x4 | GLenum | Yes| -| FLOAT_MAT4x2 | GLenum | Yes| -| FLOAT_MAT4x3 | GLenum | Yes| -| SRGB | GLenum | Yes| -| SRGB8 | GLenum | Yes| -| SRGB8_ALPHA8 | GLenum | Yes| -| COMPARE_REF_TO_TEXTURE | GLenum | Yes| -| RGBA32F | GLenum | Yes| -| RGB32F | GLenum | Yes| -| RGBA16F | GLenum | Yes| -| RGB16F | GLenum | Yes| -| VERTEX_ATTRIB_ARRAY_INTEGER | GLenum | Yes| -| MAX_ARRAY_TEXTURE_LAYERS | GLenum | Yes| -| MIN_PROGRAM_TEXEL_OFFSET | GLenum | Yes| -| MAX_PROGRAM_TEXEL_OFFSET | GLenum | Yes| -| MAX_VARYING_COMPONENTS | GLenum | Yes| -| TEXTURE_2D_ARRAY | GLenum | Yes| -| TEXTURE_BINDING_2D_ARRAY | GLenum | Yes| -| R11F_G11F_B10F | GLenum | Yes| -| UNSIGNED_INT_10F_11F_11F_REV | GLenum | Yes| -| RGB9_E5 | GLenum | Yes| -| UNSIGNED_INT_5_9_9_9_REV | GLenum | Yes| -| TRANSFORM_FEEDBACK_BUFFER_MODE | GLenum | Yes| -| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | GLenum | Yes| -| TRANSFORM_FEEDBACK_VARYINGS | GLenum | Yes| -| TRANSFORM_FEEDBACK_BUFFER_START | GLenum | Yes| -| TRANSFORM_FEEDBACK_BUFFER_SIZE | GLenum | Yes| -| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | GLenum | Yes| -| RASTERIZER_DISCARD | GLenum | Yes| -| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | GLenum | Yes| -| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | GLenum | Yes| -| INTERLEAVED_ATTRIBS | GLenum | Yes| -| SEPARATE_ATTRIBS | GLenum | Yes| -| TRANSFORM_FEEDBACK_BUFFER | GLenum | Yes| -| TRANSFORM_FEEDBACK_BUFFER_BINDING | GLenum | Yes| -| RGBA32UI | GLenum | Yes| -| RGB32UI | GLenum | Yes| -| RGBA16UI | GLenum | Yes| -| RGB16UI | GLenum | Yes| -| RGBA8UI | GLenum | Yes| -| RGB8UI | GLenum | Yes| -| RGBA32I | GLenum | Yes| -| RGB32I | GLenum | Yes| -| RGBA16I | GLenum | Yes| -| RGB16I | GLenum | Yes| -| RGBA8I | GLenum | Yes| -| RGB8I | GLenum | Yes| -| RED_INTEGER | GLenum | Yes| -| RGB_INTEGER | GLenum | Yes| -| RGBA_INTEGER | GLenum | Yes| -| SAMPLER_2D_ARRAY | GLenum | Yes| -| SAMPLER_2D_ARRAY_SHADOW | GLenum | Yes| -| SAMPLER_CUBE_SHADOW | GLenum | Yes| -| UNSIGNED_INT_VEC2 | GLenum | Yes| -| UNSIGNED_INT_VEC3 | GLenum | Yes| -| UNSIGNED_INT_VEC4 | GLenum | Yes| -| INT_SAMPLER_2D | GLenum | Yes| -| INT_SAMPLER_3D | GLenum | Yes| -| INT_SAMPLER_CUBE | GLenum | Yes| -| INT_SAMPLER_2D_ARRAY | GLenum | Yes| -| UNSIGNED_INT_SAMPLER_2D | GLenum | Yes| -| UNSIGNED_INT_SAMPLER_3D | GLenum | Yes| -| UNSIGNED_INT_SAMPLER_CUBE | GLenum | Yes| -| UNSIGNED_INT_SAMPLER_2D_ARRAY | GLenum | Yes| -| DEPTH_COMPONENT32F | GLenum | Yes| -| DEPTH32F_STENCIL8 | GLenum | Yes| -| FLOAT_32_UNSIGNED_INT_24_8_REV | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_RED_SIZE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | GLenum | Yes| -| FRAMEBUFFER_DEFAULT | GLenum | Yes| -| UNSIGNED_INT_24_8 | GLenum | Yes| -| DEPTH24_STENCIL8 | GLenum | Yes| -| UNSIGNED_NORMALIZED | GLenum | Yes| -| DRAW_FRAMEBUFFER_BINDING | GLenum | Yes| -| READ_FRAMEBUFFER | GLenum | Yes| -| DRAW_FRAMEBUFFER | GLenum | Yes| -| READ_FRAMEBUFFER_BINDING | GLenum | Yes| -| RENDERBUFFER_SAMPLES | GLenum | Yes| -| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | GLenum | Yes| -| MAX_COLOR_ATTACHMENTS | GLenum | Yes| -| COLOR_ATTACHMENT1 | GLenum | Yes| -| COLOR_ATTACHMENT2 | GLenum | Yes| -| COLOR_ATTACHMENT3 | GLenum | Yes| -| COLOR_ATTACHMENT4 | GLenum | Yes| -| COLOR_ATTACHMENT5 | GLenum | Yes| -| COLOR_ATTACHMENT6 | GLenum | Yes| -| COLOR_ATTACHMENT7 | GLenum | Yes| -| COLOR_ATTACHMENT8 | GLenum | Yes| -| COLOR_ATTACHMENT9 | GLenum | Yes| -| COLOR_ATTACHMENT10 | GLenum | Yes| -| COLOR_ATTACHMENT11 | GLenum | Yes| -| COLOR_ATTACHMENT12 | GLenum | Yes| -| COLOR_ATTACHMENT13 | GLenum | Yes| -| COLOR_ATTACHMENT14 | GLenum | Yes| -| COLOR_ATTACHMENT15 | GLenum | Yes| -| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | GLenum | Yes| -| MAX_SAMPLES | GLenum | Yes| -| HALF_FLOAT | GLenum | Yes| -| RG | GLenum | Yes| -| RG_INTEGER | GLenum | Yes| -| R8 | GLenum | Yes| -| RG8 | GLenum | Yes| -| R16F | GLenum | Yes| -| R32F | GLenum | Yes| -| RG16F | GLenum | Yes| -| RG32F | GLenum | Yes| -| R8I | GLenum | Yes| -| R8UI | GLenum | Yes| -| R16I | GLenum | Yes| -| R16UI | GLenum | Yes| -| R32I | GLenum | Yes| -| R32UI | GLenum | Yes| -| RG8I | GLenum | Yes| -| RG8UI | GLenum | Yes| -| RG16I | GLenum | Yes| -| RG16UI | GLenum | Yes| -| RG32I | GLenum | Yes| -| RG32UI | GLenum | Yes| -| VERTEX_ARRAY_BINDING | GLenum | Yes| -| R8_SNORM | GLenum | Yes| -| RG8_SNORM | GLenum | Yes| -| RGB8_SNORM | GLenum | Yes| -| SIGNED_NORMALIZED | GLenum | Yes| -| COPY_READ_BUFFER | GLenum | Yes| -| COPY_WRITE_BUFFER | GLenum | Yes| -| COPY_READ_BUFFER_BINDING | GLenum | Yes| -| COPY_WRITE_BUFFER_BINDING | GLenum | Yes| -| UNIFORM_BUFFER | GLenum | Yes| -| UNIFORM_BUFFER_BINDING | GLenum | Yes| -| UNIFORM_BUFFER_START | GLenum | Yes| -| UNIFORM_BUFFER_SIZE | GLenum | Yes| -| MAX_VERTEX_UNIFORM_BLOCKS | GLenum | Yes| -| MAX_FRAGMENT_UNIFORM_BLOCKS | GLenum | Yes| -| MAX_COMBINED_UNIFORM_BLOCKS | GLenum | Yes| -| MAX_UNIFORM_BUFFER_BINDINGS | GLenum | Yes| -| MAX_UNIFORM_BLOCK_SIZE | GLenum | Yes| -| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes| -| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes| -| UNIFORM_BUFFER_OFFSET_ALIGNMENT | GLenum | Yes| -| ACTIVE_UNIFORM_BLOCKS | GLenum | Yes| -| UNIFORM_TYPE | GLenum | Yes| -| UNIFORM_SIZE | GLenum | Yes| -| UNIFORM_BLOCK_INDEX | GLenum | Yes| -| UNIFORM_OFFSET | GLenum | Yes| -| UNIFORM_ARRAY_STRIDE | GLenum | Yes| -| UNIFORM_MATRIX_STRIDE | GLenum | Yes| -| UNIFORM_IS_ROW_MAJOR | GLenum | Yes| -| UNIFORM_BLOCK_BINDING | GLenum | Yes| -| UNIFORM_BLOCK_DATA_SIZE | GLenum | Yes| -| UNIFORM_BLOCK_ACTIVE_UNIFORMS | GLenum | Yes| -| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | GLenum | Yes| -| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | GLenum | Yes| -| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | GLenum | Yes| -| INVALID_INDEX | GLenum | Yes| -| MAX_VERTEX_OUTPUT_COMPONENTS | GLenum | Yes| -| MAX_FRAGMENT_INPUT_COMPONENTS | GLenum | Yes| -| MAX_SERVER_WAIT_TIMEOUT | GLenum | Yes| -| OBJECT_TYPE | GLenum | Yes| -| SYNC_CONDITION | GLenum | Yes| -| SYNC_STATUS | GLenum | Yes| -| SYNC_FLAGS | GLenum | Yes| -| SYNC_FENCE | GLenum | Yes| -| SYNC_GPU_COMMANDS_COMPLETE | GLenum | Yes| -| UNSIGNALED | GLenum | Yes| -| SIGNALED | GLenum | Yes| -| ALREADY_SIGNALED | GLenum | Yes| -| TIMEOUT_EXPIRED | GLenum | Yes| -| CONDITION_SATISFIED | GLenum | Yes| -| WAIT_FAILED | GLenum | Yes| -| SYNC_FLUSH_COMMANDS_BIT | GLenum | Yes| -| VERTEX_ATTRIB_ARRAY_DIVISOR | GLenum | Yes| -| ANY_SAMPLES_PASSED | GLenum | Yes| -| ANY_SAMPLES_PASSED_CONSERVATIVE | GLenum | Yes| -| SAMPLER_BINDING | GLenum | Yes| -| RGB10_A2UI | GLenum | Yes| -| INT_2_10_10_10_REV | GLenum | Yes| -| TRANSFORM_FEEDBACK | GLenum | Yes| -| TRANSFORM_FEEDBACK_PAUSED | GLenum | Yes| -| TRANSFORM_FEEDBACK_ACTIVE | GLenum | Yes| -| TRANSFORM_FEEDBACK_BINDING | GLenum | Yes| -| TEXTURE_IMMUTABLE_FORMAT | GLenum | Yes| -| MAX_ELEMENT_INDEX | GLenum | Yes| -| TEXTURE_IMMUTABLE_LEVELS | GLenum | Yes| -| TIMEOUT_IGNORED | GLint64 | Yes| -| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | GLenum | Yes| +| READ_BUFFER | GLenum | Yes| +| UNPACK_ROW_LENGTH | GLenum | Yes| +| UNPACK_SKIP_ROWS | GLenum | Yes| +| UNPACK_SKIP_PIXELS | GLenum | Yes| +| PACK_ROW_LENGTH | GLenum | Yes| +| PACK_SKIP_ROWS | GLenum | Yes| +| PACK_SKIP_PIXELS | GLenum | Yes| +| COLOR | GLenum | Yes| +| DEPTH | GLenum | Yes| +| STENCIL | GLenum | Yes| +| RED | GLenum | Yes| +| RGB8 | GLenum | Yes| +| RGBA8 | GLenum | Yes| +| RGB10_A2 | GLenum | Yes| +| TEXTURE_BINDING_3D | GLenum | Yes| +| UNPACK_SKIP_IMAGES | GLenum | Yes| +| UNPACK_IMAGE_HEIGHT | GLenum | Yes| +| TEXTURE_3D | GLenum | Yes| +| TEXTURE_WRAP_R | GLenum | Yes| +| MAX_3D_TEXTURE_SIZE | GLenum | Yes| +| UNSIGNED_INT_2_10_10_10_REV | GLenum | Yes| +| MAX_ELEMENTS_VERTICES | GLenum | Yes| +| MAX_ELEMENTS_INDICES | GLenum | Yes| +| TEXTURE_MIN_LOD | GLenum | Yes| +| TEXTURE_MAX_LOD | GLenum | Yes| +| TEXTURE_BASE_LEVEL | GLenum | Yes| +| TEXTURE_MAX_LEVEL | GLenum | Yes| +| MIN | GLenum | Yes| +| MAX | GLenum | Yes| +| DEPTH_COMPONENT24 | GLenum | Yes| +| MAX_TEXTURE_LOD_BIAS | GLenum | Yes| +| TEXTURE_COMPARE_MODE | GLenum | Yes| +| TEXTURE_COMPARE_FUNC | GLenum | Yes| +| CURRENT_QUERY | GLenum | Yes| +| QUERY_RESULT | GLenum | Yes| +| QUERY_RESULT_AVAILABLE | GLenum | Yes| +| STREAM_READ | GLenum | Yes| +| STREAM_COPY | GLenum | Yes| +| STATIC_READ | GLenum | Yes| +| STATIC_COPY | GLenum | Yes| +| DYNAMIC_READ | GLenum | Yes| +| DYNAMIC_COPY | GLenum | Yes| +| MAX_DRAW_BUFFERS | GLenum | Yes| +| DRAW_BUFFER0 | GLenum | Yes| +| DRAW_BUFFER1 | GLenum | Yes| +| DRAW_BUFFER2 | GLenum | Yes| +| DRAW_BUFFER3 | GLenum | Yes| +| DRAW_BUFFER4 | GLenum | Yes| +| DRAW_BUFFER5 | GLenum | Yes| +| DRAW_BUFFER6 | GLenum | Yes| +| DRAW_BUFFER7 | GLenum | Yes| +| DRAW_BUFFER8 | GLenum | Yes| +| DRAW_BUFFER9 | GLenum | Yes| +| DRAW_BUFFER10 | GLenum | Yes| +| DRAW_BUFFER11 | GLenum | Yes| +| DRAW_BUFFER12 | GLenum | Yes| +| DRAW_BUFFER13 | GLenum | Yes| +| DRAW_BUFFER14 | GLenum | Yes| +| DRAW_BUFFER15 | GLenum | Yes| +| MAX_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes| +| MAX_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes| +| SAMPLER_3D | GLenum | Yes| +| SAMPLER_2D_SHADOW | GLenum | Yes| +| FRAGMENT_SHADER_DERIVATIVE_HINT | GLenum | Yes| +| PIXEL_PACK_BUFFER | GLenum | Yes| +| PIXEL_UNPACK_BUFFER | GLenum | Yes| +| PIXEL_PACK_BUFFER_BINDING | GLenum | Yes| +| PIXEL_UNPACK_BUFFER_BINDING | GLenum | Yes| +| FLOAT_MAT2x3 | GLenum | Yes| +| FLOAT_MAT2x4 | GLenum | Yes| +| FLOAT_MAT3x2 | GLenum | Yes| +| FLOAT_MAT3x4 | GLenum | Yes| +| FLOAT_MAT4x2 | GLenum | Yes| +| FLOAT_MAT4x3 | GLenum | Yes| +| SRGB | GLenum | Yes| +| SRGB8 | GLenum | Yes| +| SRGB8_ALPHA8 | GLenum | Yes| +| COMPARE_REF_TO_TEXTURE | GLenum | Yes| +| RGBA32F | GLenum | Yes| +| RGB32F | GLenum | Yes| +| RGBA16F | GLenum | Yes| +| RGB16F | GLenum | Yes| +| VERTEX_ATTRIB_ARRAY_INTEGER | GLenum | Yes| +| MAX_ARRAY_TEXTURE_LAYERS | GLenum | Yes| +| MIN_PROGRAM_TEXEL_OFFSET | GLenum | Yes| +| MAX_PROGRAM_TEXEL_OFFSET | GLenum | Yes| +| MAX_VARYING_COMPONENTS | GLenum | Yes| +| TEXTURE_2D_ARRAY | GLenum | Yes| +| TEXTURE_BINDING_2D_ARRAY | GLenum | Yes| +| R11F_G11F_B10F | GLenum | Yes| +| UNSIGNED_INT_10F_11F_11F_REV | GLenum | Yes| +| RGB9_E5 | GLenum | Yes| +| UNSIGNED_INT_5_9_9_9_REV | GLenum | Yes| +| TRANSFORM_FEEDBACK_BUFFER_MODE | GLenum | Yes| +| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | GLenum | Yes| +| TRANSFORM_FEEDBACK_VARYINGS | GLenum | Yes| +| TRANSFORM_FEEDBACK_BUFFER_START | GLenum | Yes| +| TRANSFORM_FEEDBACK_BUFFER_SIZE | GLenum | Yes| +| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | GLenum | Yes| +| RASTERIZER_DISCARD | GLenum | Yes| +| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | GLenum | Yes| +| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | GLenum | Yes| +| INTERLEAVED_ATTRIBS | GLenum | Yes| +| SEPARATE_ATTRIBS | GLenum | Yes| +| TRANSFORM_FEEDBACK_BUFFER | GLenum | Yes| +| TRANSFORM_FEEDBACK_BUFFER_BINDING | GLenum | Yes| +| RGBA32UI | GLenum | Yes| +| RGB32UI | GLenum | Yes| +| RGBA16UI | GLenum | Yes| +| RGB16UI | GLenum | Yes| +| RGBA8UI | GLenum | Yes| +| RGB8UI | GLenum | Yes| +| RGBA32I | GLenum | Yes| +| RGB32I | GLenum | Yes| +| RGBA16I | GLenum | Yes| +| RGB16I | GLenum | Yes| +| RGBA8I | GLenum | Yes| +| RGB8I | GLenum | Yes| +| RED_INTEGER | GLenum | Yes| +| RGB_INTEGER | GLenum | Yes| +| RGBA_INTEGER | GLenum | Yes| +| SAMPLER_2D_ARRAY | GLenum | Yes| +| SAMPLER_2D_ARRAY_SHADOW | GLenum | Yes| +| SAMPLER_CUBE_SHADOW | GLenum | Yes| +| UNSIGNED_INT_VEC2 | GLenum | Yes| +| UNSIGNED_INT_VEC3 | GLenum | Yes| +| UNSIGNED_INT_VEC4 | GLenum | Yes| +| INT_SAMPLER_2D | GLenum | Yes| +| INT_SAMPLER_3D | GLenum | Yes| +| INT_SAMPLER_CUBE | GLenum | Yes| +| INT_SAMPLER_2D_ARRAY | GLenum | Yes| +| UNSIGNED_INT_SAMPLER_2D | GLenum | Yes| +| UNSIGNED_INT_SAMPLER_3D | GLenum | Yes| +| UNSIGNED_INT_SAMPLER_CUBE | GLenum | Yes| +| UNSIGNED_INT_SAMPLER_2D_ARRAY | GLenum | Yes| +| DEPTH_COMPONENT32F | GLenum | Yes| +| DEPTH32F_STENCIL8 | GLenum | Yes| +| FLOAT_32_UNSIGNED_INT_24_8_REV | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_RED_SIZE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | GLenum | Yes| +| FRAMEBUFFER_DEFAULT | GLenum | Yes| +| UNSIGNED_INT_24_8 | GLenum | Yes| +| DEPTH24_STENCIL8 | GLenum | Yes| +| UNSIGNED_NORMALIZED | GLenum | Yes| +| DRAW_FRAMEBUFFER_BINDING | GLenum | Yes| +| READ_FRAMEBUFFER | GLenum | Yes| +| DRAW_FRAMEBUFFER | GLenum | Yes| +| READ_FRAMEBUFFER_BINDING | GLenum | Yes| +| RENDERBUFFER_SAMPLES | GLenum | Yes| +| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | GLenum | Yes| +| MAX_COLOR_ATTACHMENTS | GLenum | Yes| +| COLOR_ATTACHMENT1 | GLenum | Yes| +| COLOR_ATTACHMENT2 | GLenum | Yes| +| COLOR_ATTACHMENT3 | GLenum | Yes| +| COLOR_ATTACHMENT4 | GLenum | Yes| +| COLOR_ATTACHMENT5 | GLenum | Yes| +| COLOR_ATTACHMENT6 | GLenum | Yes| +| COLOR_ATTACHMENT7 | GLenum | Yes| +| COLOR_ATTACHMENT8 | GLenum | Yes| +| COLOR_ATTACHMENT9 | GLenum | Yes| +| COLOR_ATTACHMENT10 | GLenum | Yes| +| COLOR_ATTACHMENT11 | GLenum | Yes| +| COLOR_ATTACHMENT12 | GLenum | Yes| +| COLOR_ATTACHMENT13 | GLenum | Yes| +| COLOR_ATTACHMENT14 | GLenum | Yes| +| COLOR_ATTACHMENT15 | GLenum | Yes| +| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | GLenum | Yes| +| MAX_SAMPLES | GLenum | Yes| +| HALF_FLOAT | GLenum | Yes| +| RG | GLenum | Yes| +| RG_INTEGER | GLenum | Yes| +| R8 | GLenum | Yes| +| RG8 | GLenum | Yes| +| R16F | GLenum | Yes| +| R32F | GLenum | Yes| +| RG16F | GLenum | Yes| +| RG32F | GLenum | Yes| +| R8I | GLenum | Yes| +| R8UI | GLenum | Yes| +| R16I | GLenum | Yes| +| R16UI | GLenum | Yes| +| R32I | GLenum | Yes| +| R32UI | GLenum | Yes| +| RG8I | GLenum | Yes| +| RG8UI | GLenum | Yes| +| RG16I | GLenum | Yes| +| RG16UI | GLenum | Yes| +| RG32I | GLenum | Yes| +| RG32UI | GLenum | Yes| +| VERTEX_ARRAY_BINDING | GLenum | Yes| +| R8_SNORM | GLenum | Yes| +| RG8_SNORM | GLenum | Yes| +| RGB8_SNORM | GLenum | Yes| +| SIGNED_NORMALIZED | GLenum | Yes| +| COPY_READ_BUFFER | GLenum | Yes| +| COPY_WRITE_BUFFER | GLenum | Yes| +| COPY_READ_BUFFER_BINDING | GLenum | Yes| +| COPY_WRITE_BUFFER_BINDING | GLenum | Yes| +| UNIFORM_BUFFER | GLenum | Yes| +| UNIFORM_BUFFER_BINDING | GLenum | Yes| +| UNIFORM_BUFFER_START | GLenum | Yes| +| UNIFORM_BUFFER_SIZE | GLenum | Yes| +| MAX_VERTEX_UNIFORM_BLOCKS | GLenum | Yes| +| MAX_FRAGMENT_UNIFORM_BLOCKS | GLenum | Yes| +| MAX_COMBINED_UNIFORM_BLOCKS | GLenum | Yes| +| MAX_UNIFORM_BUFFER_BINDINGS | GLenum | Yes| +| MAX_UNIFORM_BLOCK_SIZE | GLenum | Yes| +| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes| +| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes| +| UNIFORM_BUFFER_OFFSET_ALIGNMENT | GLenum | Yes| +| ACTIVE_UNIFORM_BLOCKS | GLenum | Yes| +| UNIFORM_TYPE | GLenum | Yes| +| UNIFORM_SIZE | GLenum | Yes| +| UNIFORM_BLOCK_INDEX | GLenum | Yes| +| UNIFORM_OFFSET | GLenum | Yes| +| UNIFORM_ARRAY_STRIDE | GLenum | Yes| +| UNIFORM_MATRIX_STRIDE | GLenum | Yes| +| UNIFORM_IS_ROW_MAJOR | GLenum | Yes| +| UNIFORM_BLOCK_BINDING | GLenum | Yes| +| UNIFORM_BLOCK_DATA_SIZE | GLenum | Yes| +| UNIFORM_BLOCK_ACTIVE_UNIFORMS | GLenum | Yes| +| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | GLenum | Yes| +| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | GLenum | Yes| +| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | GLenum | Yes| +| INVALID_INDEX | GLenum | Yes| +| MAX_VERTEX_OUTPUT_COMPONENTS | GLenum | Yes| +| MAX_FRAGMENT_INPUT_COMPONENTS | GLenum | Yes| +| MAX_SERVER_WAIT_TIMEOUT | GLenum | Yes| +| OBJECT_TYPE | GLenum | Yes| +| SYNC_CONDITION | GLenum | Yes| +| SYNC_STATUS | GLenum | Yes| +| SYNC_FLAGS | GLenum | Yes| +| SYNC_FENCE | GLenum | Yes| +| SYNC_GPU_COMMANDS_COMPLETE | GLenum | Yes| +| UNSIGNALED | GLenum | Yes| +| SIGNALED | GLenum | Yes| +| ALREADY_SIGNALED | GLenum | Yes| +| TIMEOUT_EXPIRED | GLenum | Yes| +| CONDITION_SATISFIED | GLenum | Yes| +| WAIT_FAILED | GLenum | Yes| +| SYNC_FLUSH_COMMANDS_BIT | GLenum | Yes| +| VERTEX_ATTRIB_ARRAY_DIVISOR | GLenum | Yes| +| ANY_SAMPLES_PASSED | GLenum | Yes| +| ANY_SAMPLES_PASSED_CONSERVATIVE | GLenum | Yes| +| SAMPLER_BINDING | GLenum | Yes| +| RGB10_A2UI | GLenum | Yes| +| INT_2_10_10_10_REV | GLenum | Yes| +| TRANSFORM_FEEDBACK | GLenum | Yes| +| TRANSFORM_FEEDBACK_PAUSED | GLenum | Yes| +| TRANSFORM_FEEDBACK_ACTIVE | GLenum | Yes| +| TRANSFORM_FEEDBACK_BINDING | GLenum | Yes| +| TEXTURE_IMMUTABLE_FORMAT | GLenum | Yes| +| MAX_ELEMENT_INDEX | GLenum | Yes| +| TEXTURE_IMMUTABLE_LEVELS | GLenum | Yes| +| TIMEOUT_IGNORED | GLint64 | Yes| +| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | GLenum | Yes| ### Methods - | Method| Return Value Type| +| Method| Return Value Type| | -------- | -------- | -| copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) | void | -| getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint) | void | -| blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum) | void | -| framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture \| null, level: GLint, layer: GLint) | void | -| invalidateFramebuffer(target: GLenum, attachments: GLenum[]) | void | -| invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| readBuffer(src: GLenum) | void | -| getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum) | any | -| renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | -| texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | -| texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei) | void | -| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | -| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null) | void | -| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | -| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | -| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null, srcOffset?: GLuint) | void | -| copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | -| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | -| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | -| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | -| getFragDataLocation(program: WebGLProgram, name: string) | GLint | -| uniform1ui(location: WebGLUniformLocation \| null, v0: GLuint) | void | -| uniform2ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint) | void | -| uniform3ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint) | void | -| uniform4ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint) | void | -| uniform1uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform2uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform3uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform4uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix3x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix4x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix2x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix4x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix2x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix3x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint) | void | -| vertexAttribI4iv(index: GLuint, values: Int32List) | void | -| vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint) | void | -| vertexAttribI4uiv(index: GLuint, values: Uint32List) | void | -| vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr) | void | -| vertexAttribDivisor(index: GLuint, divisor: GLuint) | void | -| drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) | void | -| drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei) | void | -| drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr) | void | -| drawBuffers(buffers: GLenum[]) | void | -| clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint) | void | -| clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint) | void | -| clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint) | void | -| clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint) | void | -| createQuery() | WebGLQuery \| null | -| deleteQuery(query: WebGLQuery \| null) | void | -| isQuery(query: WebGLQuery \| null) | GLboolean | -| beginQuery(target: GLenum, query: WebGLQuery) | void | -| endQuery(target: GLenum) | void | -| getQuery(target: GLenum, pname: GLenum) | WebGLQuery \| null | -| getQueryParameter(query: WebGLQuery, pname: GLenum) | any | -| createSampler() | WebGLSampler \| null | -| deleteSampler(sampler: WebGLSampler \| null) | void | -| isSampler(sampler: WebGLSampler \| null) | GLboolean | -| bindSampler(unit: GLuint, sampler: WebGLSampler \| null) | void | -| samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint) | void | -| samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat) | void; | -| getSamplerParameter(sampler: WebGLSampler, pname: GLenum) | any | -| fenceSync(condition: GLenum, flags: GLbitfield) | WebGLSync \| null | -| isSync(sync: WebGLSync \| null) | GLboolean | -| deleteSync(sync: WebGLSync \| null) | void | -| clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64) | GLenum | -| waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64) | void | -| getSyncParameter(sync: WebGLSync, pname: GLenum) | any | -| createTransformFeedback() | WebGLTransformFeedback \| null | -| deleteTransformFeedback(tf: WebGLTransformFeedback \| null) | void | -| isTransformFeedback(tf: WebGLTransformFeedback \| null) | GLboolean | -| bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback \| null) | void | -| beginTransformFeedback(primitiveMode: GLenum) | void | -| endTransformFeedback() | void | -| transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum) | void | -| getTransformFeedbackVarying(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | -| pauseTransformFeedback() | void | -| resumeTransformFeedback() | void | -| bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null) | void | -| bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null, offset: GLintptr, size: GLsizeiptr) | void | -| getIndexedParameter(target: GLenum, index: GLuint) | any | -| getUniformIndices(program: WebGLProgram, uniformNames: string[]) | GLuint[] \| null | -| getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum) | any | -| getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string) | GLuint | -| getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum) | any | -| getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint) | string \| null | -| uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint) | void | -| createVertexArray() | WebGLVertexArrayObject \| null | -| deleteVertexArray(vertexArray: WebGLVertexArrayObject \| null) | void | -| isVertexArray(vertexArray: WebGLVertexArrayObject \| null) | GLboolean | -| bindVertexArray(array: WebGLVertexArrayObject \| null) | void | +| copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) | void | +| getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint) | void | +| blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum) | void | +| framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture \| null, level: GLint, layer: GLint) | void | +| invalidateFramebuffer(target: GLenum, attachments: GLenum[]) | void | +| invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| readBuffer(src: GLenum) | void | +| getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum) | any | +| renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null, srcOffset?: GLuint) | void | +| copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| getFragDataLocation(program: WebGLProgram, name: string) | GLint | +| uniform1ui(location: WebGLUniformLocation \| null, v0: GLuint) | void | +| uniform2ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint) | void | +| uniform3ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint) | void | +| uniform4ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint) | void | +| uniform1uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint) | void | +| vertexAttribI4iv(index: GLuint, values: Int32List) | void | +| vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint) | void | +| vertexAttribI4uiv(index: GLuint, values: Uint32List) | void | +| vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr) | void | +| vertexAttribDivisor(index: GLuint, divisor: GLuint) | void | +| drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) | void | +| drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei) | void | +| drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr) | void | +| drawBuffers(buffers: GLenum[]) | void | +| clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint) | void | +| clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint) | void | +| clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint) | void | +| clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint) | void | +| createQuery() | WebGLQuery \| null | +| deleteQuery(query: WebGLQuery \| null) | void | +| isQuery(query: WebGLQuery \| null) | GLboolean | +| beginQuery(target: GLenum, query: WebGLQuery) | void | +| endQuery(target: GLenum) | void | +| getQuery(target: GLenum, pname: GLenum) | WebGLQuery \| null | +| getQueryParameter(query: WebGLQuery, pname: GLenum) | any | +| createSampler() | WebGLSampler \| null | +| deleteSampler(sampler: WebGLSampler \| null) | void | +| isSampler(sampler: WebGLSampler \| null) | GLboolean | +| bindSampler(unit: GLuint, sampler: WebGLSampler \| null) | void | +| samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint) | void | +| samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat) | void; | +| getSamplerParameter(sampler: WebGLSampler, pname: GLenum) | any | +| fenceSync(condition: GLenum, flags: GLbitfield) | WebGLSync \| null | +| isSync(sync: WebGLSync \| null) | GLboolean | +| deleteSync(sync: WebGLSync \| null) | void | +| clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64) | GLenum | +| waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64) | void | +| getSyncParameter(sync: WebGLSync, pname: GLenum) | any | +| createTransformFeedback() | WebGLTransformFeedback \| null | +| deleteTransformFeedback(tf: WebGLTransformFeedback \| null) | void | +| isTransformFeedback(tf: WebGLTransformFeedback \| null) | GLboolean | +| bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback \| null) | void | +| beginTransformFeedback(primitiveMode: GLenum) | void | +| endTransformFeedback() | void | +| transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum) | void | +| getTransformFeedbackVarying(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| pauseTransformFeedback() | void | +| resumeTransformFeedback() | void | +| bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null) | void | +| bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null, offset: GLintptr, size: GLsizeiptr) | void | +| getIndexedParameter(target: GLenum, index: GLuint) | any | +| getUniformIndices(program: WebGLProgram, uniformNames: string[]) | GLuint[] \| null | +| getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum) | any | +| getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string) | GLuint | +| getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum) | any | +| getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint) | string \| null | +| uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint) | void | +| createVertexArray() | WebGLVertexArrayObject \| null | +| deleteVertexArray(vertexArray: WebGLVertexArrayObject \| null) | void | +| isVertexArray(vertexArray: WebGLVertexArrayObject \| null) | GLboolean | +| bindVertexArray(array: WebGLVertexArrayObject \| null) | void | ## WebGL2RenderingContextOverloads WebGL2RenderingContextOverloads - | Method| Return Value Type| +| Method| Return Value Type| | -------- | -------- | -| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | -| bufferData(target: GLenum, srcData: BufferSource \| null, usage: GLenum) | void | -| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource) | void | -| bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint) | void | -| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | -| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | -| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | -| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | -| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | -| uniform1fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform2fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform3fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform4fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform1iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform2iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform3iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniform4iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView \| null) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint) | void | +| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | +| bufferData(target: GLenum, srcData: BufferSource \| null, usage: GLenum) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource) | void | +| bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| uniform1fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform1iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView \| null) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint) | void | diff --git a/en/application-dev/reference/apis/js-apis-wifi.md b/en/application-dev/reference/apis/js-apis-wifi.md index 875607d4fd022e5a9e91359bde83ee4d1d70a69b..602a3b7e2a318119b1e8dbfa80a59fdc65a6bede 100644 --- a/en/application-dev/reference/apis/js-apis-wifi.md +++ b/en/application-dev/reference/apis/js-apis-wifi.md @@ -21,9 +21,9 @@ Checks whether the WLAN is activated. **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the WLAN is activated; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the WLAN is activated; returns **false** otherwise.| ## wifi.scan @@ -37,41 +37,41 @@ Starts a scan for WLAN. **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the scan is successful; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the scan is successful; returns **false** otherwise.| ## wifi.getScanInfos getScanInfos(): Promise<Array<WifiScanInfo>> -Obtains the scan result. This method uses a promise to return the result. +Obtains the scan result. This API uses a promise to return the result. -**Required permissions**: ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION +**Required permissions**: at least one of ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.| +| **Type**| **Description**| +| -------- | -------- | +| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the hotspots detected.| ## wifi.getScanInfos getScanInfos(callback: AsyncCallback<Array<WifiScanInfo>>): void -Obtains the scan result. This method uses an asynchronous callback to return the result. +Obtains the scan result. This API uses an asynchronous callback to return the result. **Required permissions**: at least one of ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the hotspots detected.| **Example** ```js @@ -126,10 +126,12 @@ Represents WLAN hotspot information. | bssid | string | Read only| Basic service set identifier (BSSID) of the hotspot.| | capabilities | string | Read only| Hotspot capabilities.| | securityType | [WifiSecurityType](#WifiSecurityType) | Read only| WLAN security type.| -| rssi | number | Read only| Signal strength of the hotspot, in dBm.| +| rssi | number | Read only| Received signal strength indicator (RSSI) of the hotspot, in dBm.| | band | number | Read only| Frequency band of the WLAN access point (AP).| | frequency | number | Read only| Frequency of the WLAN AP.| | channelWidth | number | Read only| Bandwidth of the WLAN AP.| +| centerFrequency0 | number | Read only| Center frequency.| +| centerFrequency1 | number | Read only| Center frequency.| | timestamp | number | Read only| Timestamp.| @@ -150,7 +152,7 @@ Enumerates the WLAN security types. addUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> -Adds untrusted WLAN configuration. This method uses a promise to return the result. +Adds untrusted WLAN configuration. This API uses a promise to return the result. **Required permissions**: ohos.permission.SET_WIFI_INFO @@ -159,14 +161,14 @@ Adds untrusted WLAN configuration. This method uses a promise to return the resu SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| ## WifiDeviceConfig @@ -174,120 +176,120 @@ Represents the WLAN configuration. | **Name**| **Type**| **Readable/Writable**| **Description**| | -------- | -------- | -------- | -------- | -| ssid | string | Read only| Hotspot SSID, in UTF-8 format.| +| ssid | string | Read only| Hotspot service set identifier (SSID), in UTF-8 format.| | bssid | string | Read only| BSSID of the hotspot.| | preSharedKey | string | Read only| Private key of the hotspot.| | isHiddenSsid | boolean | Read only| Whether to hide the network.| -| securityType | [WifiSecurityType](#WifiSecurityType) | Read only| Security type| +| securityType | [WifiSecurityType](#WifiSecurityType) | Read only| Security type.| ## wifi.addUntrustedConfig<sup>7+</sup> addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -Adds untrusted WLAN configuration. This method uses an asynchronous callback to return the result. +Adds untrusted WLAN configuration. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.SET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| - | callback | AsyncCallback<boolean> | Yes| Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.| +| callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| ## wifi.removeUntrustedConfig<sup>7+</sup> removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> -Removes untrusted WLAN configuration. This method uses a promise to return the result. +Removes untrusted WLAN configuration. This API uses a promise to return the result. **Required permissions**: ohos.permission.SET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove. | **Return value** - | **Type**| **Description**| - | -------- | -------- | - | Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| +| **Type**| **Description**| +| -------- | -------- | +| Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| ## wifi.removeUntrustedConfig<sup>7+</sup> removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -Removes untrusted WLAN configuration. This method uses an asynchronous callback to return the result. +Removes untrusted WLAN configuration. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.SET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.| - | callback | AsyncCallback<boolean> | Yes| Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove. | +| callback | AsyncCallback<boolean> | Yes| Callback used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.| ## wifi.getSignalLevel getSignalLevel(rssi: number, band: number): number -Obtains the WLAN signal strength. +Obtains the WLAN signal level. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | rssi | number | Yes| Signal strength of the hotspot, in dBm.| - | band | number | Yes| Frequency band of the WLAN AP.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| rssi | number | Yes| RSSI of the hotspot, in dBm. | +| band | number | Yes| Frequency band of the WLAN AP.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | number | Signal strength obtained. The value range is [0, 4].| +| **Type**| **Description**| +| -------- | -------- | +| number | Signal level obtained. The value range is [0, 4].| ## wifi.getLinkedInfo getLinkedInfo(): Promise<WifiLinkedInfo> -Obtains WLAN connection information. This method uses a promise to return the result. +Obtains WLAN connection information. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiLinkedInfo](#WifiLinkedInfo)> | Promise used to return the WLAN connection information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiLinkedInfo](#WifiLinkedInfo)> | Promise used to return the WLAN connection information obtained.| ## wifi.getLinkedInfo getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void -Obtains WLAN connection information. This method uses a callback to return the result. +Obtains WLAN connection information. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiLinkedInfo](#WifiLinkedInfo)> | Yes| Callback invoked to return the WLAN connection information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiLinkedInfo](#WifiLinkedInfo)> | Yes| Callback invoked to return the WLAN connection information obtained.| **Example** ```js @@ -317,11 +319,11 @@ Represents the WLAN connection information. | -------- | -------- | -------- | -------- | | ssid | string | Read only| Hotspot SSID, in UTF-8 format.| | bssid | string | Read only| BSSID of the hotspot.| -| rssi | number | Read only| Signal strength of the hotspot, in dBm.| +| rssi | number | Read only| RSSI of the hotspot, in dBm. | | band | number | Read only| Frequency band of the WLAN AP.| | linkSpeed | number | Read only| Speed of the WLAN AP.| | frequency | number | Read only| Frequency of the WLAN AP.| -| isHidden | boolean | Read only| Whether the WLAN AP is hidden.| +| isHidden | boolean | Read only| Whether to hide the WLAN AP.| | isRestricted | boolean | Read only| Whether to restrict data volume at the WLAN AP.| | macAddress | string | Read only| MAC address of the device.| | ipAddress | number | Read only| IP address of the device that sets up the WLAN connection.| @@ -355,9 +357,9 @@ Checks whether the WLAN is connected. **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| ## wifi.isFeatureSupported<sup>7+</sup> @@ -372,14 +374,14 @@ Checks whether the device supports the specified WLAN feature. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | featureId | number | Yes| Feature ID.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| featureId | number | Yes| Feature ID.| **Return value** - | **Type**| **Description**| - | -------- | -------- | - | boolean | Returns **true** if the feature is supported; returns **false** otherwise.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| **Feature IDs** @@ -408,9 +410,9 @@ Obtains IP information. **System capability**: SystemCapability.Communication.WiFi.STA **Return value** - | **Type**| **Description**| - | -------- | -------- | - | [IpInfo](#IpInfo) | IP information obtained.| +| **Type**| **Description**| +| -------- | -------- | +| [IpInfo](#IpInfo) | IP information obtained.| ## IpInfo<sup>7+</sup> @@ -439,41 +441,41 @@ Obtains the country code. **System capability**: SystemCapability.Communication.WiFi.Core **Return value** - | **Type**| **Description**| - | -------- | -------- | - | string | Country code obtained.| +| **Type**| **Description**| +| -------- | -------- | +| string | Country code obtained.| ## wifi.getP2pLinkedInfo<sup>8+</sup> getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo> -Obtains peer-to-peer (P2P) connection information. This method uses a promise to return the result. +Obtains peer-to-peer (P2P) connection information. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Promise used to return the P2P connection information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Promise used to return the P2P connection information obtained.| ## wifi.getP2pLinkedInfo<sup>8+</sup> getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void -Obtains P2P connection information. This method uses a callback to return the result. +Obtains P2P connection information. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Yes| Callback used to return the P2P connection information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Yes| Callback used to return the P2P connection information obtained.| ## WifiP2pLinkedInfo<sup>8+</sup> @@ -483,8 +485,8 @@ Represents the WLAN connection information. | Name| Type| Readable/Writable| Description| | -------- | -------- | -------- | -------- | | connectState | [P2pConnectState](#P2pConnectState) | Read only| P2P connection state.| -| isGroupOwner | boolean | Read only| Whether it is a group.| -| groupOwnerAddr | string | Read only| MAC address of the group.| +| isGroupOwner | boolean | Read only| Whether it is a group owner.| +| groupOwnerAddr | string | Read only| MAC address of the group owner.| ## P2pConnectState<sup>8+</sup> @@ -501,33 +503,62 @@ Enumerates the P2P connection states. getCurrentGroup(): Promise<WifiP2pGroupInfo> -Obtains the current P2P group information. This method uses a promise to return the result. +Obtains the current P2P group information. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Promise used to return the P2P group information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Promise used to return the P2P group information obtained.| ## wifi.getCurrentGroup<sup>8+</sup> getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void -Obtains the P2P group information. This method uses an asynchronous callback to return the result. +Obtains the P2P group information. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Yes| Callback used to return the P2P group information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | Yes| Callback used to return the P2P group information obtained.| + +## wifi.getP2pGroups<sup>9+</sup> + +getP2pGroups(): Promise<Array<WifiP2pGroupInfo> + +Obtains information about all P2P groups. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + +**System capability**: SystemCapability.Communication.WiFi.P2P + +**Return value** +| Type| Description| +| -------- | -------- | +| Promise< Array<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> > | Information about all created P2P groups obtained.| + +## wifi.getP2pGroups<sup>9+</sup> + +getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>): void + +Obtains information about all P2P groups. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + +**System capability**: SystemCapability.Communication.WiFi.P2P +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback< Array<[WifiP2pGroupInfo](#WifiP2pGroupInfo)>> | Yes| Callback invoked to return the P2P group information obtained.| ## WifiP2pGroupInfo<sup>8+</sup> @@ -574,33 +605,63 @@ Enumerates the device states. getP2pPeerDevices(): Promise<WifiP2pDevice[]> -Obtains the list of peer devices in a P2P connection. This method uses a promise to return the result. +Obtains the list of peer devices in a P2P connection. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[WifiP2pDevice[]](#WifiP2pDevice)> | Promise used to return the peer device list obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pDevice[]](#WifiP2pDevice)> | Promise used to return the peer device list obtained.| ## wifi.getP2pPeerDevices<sup>8+</sup> getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void -Obtains the list of peer devices in a P2P connection. This method uses an asynchronous callback to return the result. +Obtains the list of peer devices in a P2P connection. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pDevice[]](#WifiP2pDevice)> | Yes| Callback used to return the peer device list obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pDevice[]](#WifiP2pDevice)> | Yes| Callback used to return the peer device list obtained.| + +## wifi.getP2pLocalDevice<sup>9+</sup> + +getP2pLocalDevice(): Promise<WifiP2pDevice> + +Obtains local device information. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG + +**System capability**: SystemCapability.Communication.WiFi.P2P + +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<[WifiP2pDevice](#WifiP2pDevice)> | Promise used to return the local device information obtained.| + + +## wifi.getP2pLocalDevice<sup>8+</sup> + +getP2pLocalDevice(callback: AsyncCallback<WifiP2pDevice>): void + +Obtains local device information. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG + +**System capability**: SystemCapability.Communication.WiFi.P2P +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<[WifiP2pDevice](#WifiP2pDevice)> | Yes| Callback invoked to returnthe local device information obtained.| ## wifi.createGroup<sup>8+</sup> @@ -614,14 +675,14 @@ Creates a P2P group. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Group configuration.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Group configuration.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## WifiP2PConfig<sup>8+</sup> @@ -650,16 +711,16 @@ Enumerates the P2P group bandwidths. removeGroup(): boolean; -Removes a P2P group. +Removes this P2P group. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## wifi.p2pConnect<sup>8+</sup> @@ -674,14 +735,14 @@ Sets up a P2P connection. **Parameters** - | **Name**| **Type**| Mandatory| **Description**| - | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Connection configuration.| +| **Name**| **Type**| Mandatory| **Description**| +| -------- | -------- | -------- | -------- | +| config | [WifiP2PConfig](#WifiP2PConfig) | Yes| Connection configuration.| **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| **Example** @@ -762,9 +823,9 @@ Cancels this P2P connection. **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## wifi.startDiscoverDevices<sup>8+</sup> @@ -778,9 +839,9 @@ Starts to discover devices. **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## wifi.stopDiscoverDevices<sup>8+</sup> @@ -794,9 +855,9 @@ Stops discovering devices. **System capability**: SystemCapability.Communication.WiFi.P2P **Return value** - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## wifi.on('wifiStateChange')<sup>7+</sup> @@ -810,10 +871,10 @@ Registers the WLAN state change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN state.| **WLAN states** @@ -836,10 +897,10 @@ Unregisters the WLAN state change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiStateChange**.| - | callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiStateChange**.| +| callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| **Example** ```js @@ -850,10 +911,10 @@ Unregisters the WLAN state change events. console.info("Receive power state change event: " + result); } - // Register event + // Register an event. wifi.on(WIFI_POWER_STATE, recvPowerNotifyFunc); - // Unregister event + // Unregister an event. wifi.off(WIFI_POWER_STATE, recvPowerNotifyFunc); ``` @@ -869,10 +930,10 @@ Registers the WLAN connection state change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiConnectionChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN connection state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiConnectionChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN connection state.| **WLAN connection states** @@ -893,10 +954,10 @@ Unregisters the WLAN connection state change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiConnectionChange**.| - | callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiConnectionChange**.| +| callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('wifiScanStateChange')<sup>7+</sup> @@ -910,10 +971,10 @@ Registers the WLAN scan state change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiScanStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the WLAN scan state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiScanStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the WLAN scan state.| **WLAN scan states** @@ -952,10 +1013,10 @@ Registers the RSSI change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiRssiChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the RSSI, in dBm.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiRssiChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the RSSI, in dBm.| ## wifi.off('wifiRssiChange')<sup>7+</sup> @@ -969,10 +1030,10 @@ Unregisters the RSSI change events. **System capability**: SystemCapability.Communication.WiFi.STA **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **wifiRssiChange**.| - | callback | Callback<number> | No| Callback used to return the RSSI, in dBm. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **wifiRssiChange**.| +| callback | Callback<number> | No| Callback used to return the RSSI, in dBm. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('hotspotStateChange')<sup>7+</sup> @@ -986,10 +1047,10 @@ Registers the hotspot state change events. **System capability**: SystemCapability.Communication.WiFi.AP.Core **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **hotspotStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the hotspot state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **hotspotStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the hotspot state.| **Hotspot states** @@ -1012,10 +1073,10 @@ Unregisters the hotspot state change events. **System capability**: SystemCapability.Communication.WiFi.AP.Core **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **hotspotStateChange**.| - | callback | Callback<number> | No| Callback used to return the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **hotspotStateChange**.| +| callback | Callback<number> | No| Callback used to return the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pStateChange')<sup>8+</sup> @@ -1029,10 +1090,10 @@ Registers the P2P state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pStateChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the P2P state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pStateChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the P2P state.| **P2P states** @@ -1055,10 +1116,10 @@ Unregisters the P2P state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pStateChange**.| - | callback | Callback<number> | No| Callback used to return the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pStateChange**.| +| callback | Callback<number> | No| Callback used to return the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pConnectionChange')<sup>8+</sup> @@ -1072,10 +1133,10 @@ Registers the P2P connection state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pConnectionChange**.| - | callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Yes| Callback invoked to return the P2P connection state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pConnectionChange**.| +| callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | Yes| Callback invoked to return the P2P connection state.| ## wifi.off('p2pConnectionChange')<sup>8+</sup> @@ -1089,10 +1150,10 @@ Unregisters the P2P connection state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pConnectionChange**.| - | callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | No| Callback used to return the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pConnectionChange**.| +| callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | No| Callback used to return the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pDeviceChange')<sup>8+</sup> @@ -1106,10 +1167,10 @@ Registers the P2P device state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDeviceChange**.| - | callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | Yes| Callback invoked to return the P2P device state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDeviceChange**.| +| callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | Yes| Callback invoked to return the P2P device state.| ## wifi.off('p2pDeviceChange')<sup>8+</sup> @@ -1123,10 +1184,10 @@ Unregisters the P2P device state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDeviceChange**.| - | callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | No| Callback used to return the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDeviceChange**.| +| callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | No| Callback used to return the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pPeerDeviceChange')<sup>8+</sup> @@ -1140,10 +1201,10 @@ Registers the P2P peer device state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| - | callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | Yes| Callback invoked to return the P2P peer device state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| +| callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | Yes| Callback invoked to return the P2P peer device state.| ## wifi.off('p2pPeerDeviceChange')<sup>8+</sup> @@ -1157,10 +1218,10 @@ Unregisters the P2P peer device state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| - | callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | No| Callback used to return the P2P peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| +| callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | No| Callback used to return the P2P peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pPersistentGroupChange')<sup>8+</sup> @@ -1174,10 +1235,10 @@ Registers the P2P persistent group state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| - | callback | Callback<void> | Yes| Callback invoked to return the P2P persistent group state.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| +| callback | Callback<void> | Yes| Callback invoked to return the P2P persistent group state.| ## wifi.off('p2pPersistentGroupChange')<sup>8+</sup> @@ -1191,27 +1252,27 @@ Unregisters the P2P persistent group state change events. **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| - | callback | Callback<void> | No| Callback used to return the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| +| callback | Callback<void> | No| Callback used to return the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| ## wifi.on('p2pDiscoveryChange')<sup>8+</sup> on(type: "p2pDiscoveryChange", callback: Callback<number>): void -Registers the P2P discovered device state change events. +Registers the P2P device discovery state change events. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| - | callback | Callback<number> | Yes| Callback invoked to return the state of the P2P discovered device.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| +| callback | Callback<number> | Yes| Callback invoked to return the P2P device discovery state.| **P2P discovered device states** @@ -1225,14 +1286,14 @@ Registers the P2P discovered device state change events. off(type: "p2pDiscoveryChange", callback?: Callback<number>): void -Unregisters the P2P discovered device state change events. +Unregisters the P2P device discovery state change events. **Required permissions**: ohos.permission.GET_WIFI_INFO **System capability**: SystemCapability.Communication.WiFi.P2P **Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| - | callback | Callback<number> | No| Callback used to return the state of the P2P discovered device. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| +| callback | Callback<number> | No| Callback used to return the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index f22c9988cf123f79225babf014b089bb98e6247a..21e43edc10b5e4fd5acf567ceabb822f26935ade 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -1,6 +1,7 @@ # XML Parsing and Generation ->  **NOTE**<br> +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -146,7 +147,7 @@ thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); thatSer.setAttributes("importance", "high"); thatSer.setText("Happy"); -endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table> +thatSer.endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table> ``` diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index 521ca33eff38eb7656529f0f32b85f4a7d37f35a..46e4b416c4bc0ee3389c493a540e2a7bb375bd3a 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -1,111 +1,105 @@ # JavaScript-based Web-like Development Paradigm -- Components - - Common - - [Universal Attributes](js-components-common-attributes.md) - - [Universal Styles](js-components-common-styles.md) - - [Universal Events](js-components-common-events.md) - - [Universal Methods](js-components-common-methods.md) - - [Animation Styles](js-components-common-animation.md) - - [Gradient Styles](js-components-common-gradient.md) - - [Transition Styles](js-components-common-transition.md) - - [Media Query](js-components-common-mediaquery.md) - - [Custom Font Styles](js-components-common-customizing-font.md) - - [Atomic Layout](js-components-common-atomic-layout.md) +- Universal Component Information + - [Universal Attributes](js-components-common-attributes.md) + - [Universal Styles](js-components-common-styles.md) + - [Universal Events](js-components-common-events.md) + - [Universal Methods](js-components-common-methods.md) + - [Animation Styles](js-components-common-animation.md) + - [Gradient Styles](js-components-common-gradient.md) + - [Transition Styles](js-components-common-transition.md) + - [Media Query](js-components-common-mediaquery.md) + - [Custom Font Styles](js-components-common-customizing-font.md) + - [Atomic Layout](js-components-common-atomic-layout.md) +- Container Components + - [badge](js-components-container-badge.md) + - [dialog](js-components-container-dialog.md) + - [div](js-components-container-div.md) + - [form](js-components-container-form.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [list-item-group](js-components-container-list-item-group.md) + - [panel](js-components-container-panel.md) + - [popup](js-components-container-popup.md) + - [refresh](js-components-container-refresh.md) + - [stack](js-components-container-stack.md) + - [stepper](js-components-container-stepper.md) + - [stepper-item](js-components-container-stepper-item.md) + - [swiper](js-components-container-swiper.md) + - [tabs](js-components-container-tabs.md) + - [tab-bar](js-components-container-tab-bar.md) + - [tab-content](js-components-container-tab-content.md) +- Basic Components + - [button](js-components-basic-button.md) + - [chart](js-components-basic-chart.md) + - [divider](js-components-basic-divider.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [label](js-components-basic-label.md) + - [marquee](js-components-basic-marquee.md) + - [menu](js-components-basic-menu.md) + - [option](js-components-basic-option.md) + - [picker](js-components-basic-picker.md) + - [picker-view](js-components-basic-picker-view.md) + - [piece](js-components-basic-piece.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [rating](js-components-basic-rating.md) + - [richtext](js-components-basic-richtext.md) + - [search](js-components-basic-search.md) + - [select](js-components-basic-select.md) + - [slider](js-components-basic-slider.md) + - [span](js-components-basic-span.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) + - [textarea](js-components-basic-textarea.md) + - [toolbar](js-components-basic-toolbar.md) + - [toolbar-item](js-components-basic-toolbar-item.md) + - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) + - [xcomponent](js-components-basic-xcomponent.md) +- Media Components + - [video](js-components-media-video.md) +- Canvas Components + - [canvas](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) + - [Image](js-components-canvas-image.md) + - [CanvasGradient](js-components-canvas-canvasgradient.md) + - [ImageData](js-components-canvas-imagedata.md) + - [Path2D](js-components-canvas-path2d.md) + - [ImageBitmap](js-components-canvas-imagebitmap.md) + - [OffscreenCanvas](js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D](js-offscreencanvasrenderingcontext2d.md) +- Grid Components + - [Basic Concepts](js-components-grid-basic-concepts.md) + - [grid-container](js-components-grid-container.md) + - [grid-row](js-components-grid-row.md) + - [grid-col](js-components-grid-col.md) +- SVG Components + - [Universal Attributes](js-components-svg-common-attributes.md) + - [svg](js-components-svg.md) + - [rect](js-components-svg-rect.md) + - [circle](js-components-svg-circle.md) + - [ellipse](js-components-svg-ellipse.md) + - [path](js-components-svg-path.md) + - [line](js-components-svg-line.md) + - [polyline](js-components-svg-polyline.md) + - [polygon](js-components-svg-polygon.md) + - [text](js-components-svg-text.md) + - [tspan](js-components-svg-tspan.md) + - [textPath](js-components-svg-textpath.md) + - [animate](js-components-svg-animate.md) + - [animateMotion](js-components-svg-animatemotion.md) + - [animateTransform](js-components-svg-animatetransform.md) - - Container Component - - [badge](js-components-container-badge.md) - - [dialog](js-components-container-dialog.md) - - [div](js-components-container-div.md) - - [form](js-components-container-form.md) - - [list](js-components-container-list.md) - - [list-item](js-components-container-list-item.md) - - [list-item-group](js-components-container-list-item-group.md) - - [panel](js-components-container-panel.md) - - [popup](js-components-container-popup.md) - - [refresh](js-components-container-refresh.md) - - [stack](js-components-container-stack.md) - - [stepper](js-components-container-stepper.md) - - [stepper-item](js-components-container-stepper-item.md) - - [swiper](js-components-container-swiper.md) - - [tabs](js-components-container-tabs.md) - - [tab-bar](js-components-container-tab-bar.md) - - [tab-content](js-components-container-tab-content.md) - - - Basic Components - - [button](js-components-basic-button.md) - - [chart](js-components-basic-chart.md) - - [divider](js-components-basic-divider.md) - - [image](js-components-basic-image.md) - - [image-animator](js-components-basic-image-animator.md) - - [input](js-components-basic-input.md) - - [label](js-components-basic-label.md) - - [marquee](js-components-basic-marquee.md) - - [menu](js-components-basic-menu.md) - - [option](js-components-basic-option.md) - - [picker](js-components-basic-picker.md) - - [picker-view](js-components-basic-picker-view.md) - - [piece](js-components-basic-piece.md) - - [progress](js-components-basic-progress.md) - - [qrcode](js-components-basic-qrcode.md) - - [rating](js-components-basic-rating.md) - - [richtext](js-components-basic-richtext.md) - - [search](js-components-basic-search.md) - - [select](js-components-basic-select.md) - - [slider](js-components-basic-slider.md) - - [span](js-components-basic-span.md) - - [switch](js-components-basic-switch.md) - - [text](js-components-basic-text.md) - - [textarea](js-components-basic-textarea.md) - - [toolbar](js-components-basic-toolbar.md) - - [toolbar-item](js-components-basic-toolbar-item.md) - - [toggle](js-components-basic-toggle.md) - - [web](js-components-basic-web.md) - - [xcomponent](js-components-basic-xcomponent.md) - - Media Components - - [video](js-components-media-video.md) - - - Canvas Components - - [canvas](js-components-canvas-canvas.md) - - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) - - [Image](js-components-canvas-image.md) - - [CanvasGradient](js-components-canvas-canvasgradient.md) - - [ImageData](js-components-canvas-imagedata.md) - - [Path2D](js-components-canvas-path2d.md) - - [ImageBitmap](js-components-canvas-imagebitmap.md) - - [OffscreenCanvas](js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D](js-offscreencanvasrenderingcontext2d.md) - - - Grid - - [Basic Concepts](js-components-grid-basic-concepts.md) - - [grid-container](js-components-grid-container.md) - - [grid-row](js-components-grid-row.md) - - [grid-col](js-components-grid-col.md) - - - SVG Components - - [Universal Attributes](js-components-svg-common-attributes.md) - - [svg](js-components-svg.md) - - [rect](js-components-svg-rect.md) - - [circle](js-components-svg-circle.md) - - [ellipse](js-components-svg-ellipse.md) - - [path](js-components-svg-path.md) - - [line](js-components-svg-line.md) - - [polyline](js-components-svg-polyline.md) - - [polygon](js-components-svg-polygon.md) - - [text](js-components-svg-text.md) - - [tspan](js-components-svg-tspan.md) - - [textPath](js-components-svg-textpath.md) - - [animate](js-components-svg-animate.md) - - [animateMotion](js-components-svg-animatemotion.md) - - [animateTransform](js-components-svg-animatetransform.md) - Custom Components - - [Basic Usage](js-components-custom-basic-usage.md) - - [Style Inheritance](js-components-custom-style.md) - - [Custom Events](js-components-custom-events.md) - - [props](js-components-custom-props.md) - - [Event Parameter](js-components-custom-event-parameter.md) - - [slot](js-components-custom-slot.md) - - [Lifecycle Definition](js-components-custom-lifecycle.md) -- Appendix - - [Type Attributes](js-appendix-types.md) + - [Basic Usage](js-components-custom-basic-usage.md) + - [Style Inheritance](js-components-custom-style.md) + - [Custom Events](js-components-custom-events.md) + - [props](js-components-custom-props.md) + - [Event Parameter](js-components-custom-event-parameter.md) + - [slot](js-components-custom-slot.md) + - [Lifecycle Definition](js-components-custom-lifecycle.md) +- [Data Type Attributes](js-appendix-types.md) diff --git a/en/application-dev/reference/arkui-js/js-appendix-types.md b/en/application-dev/reference/arkui-js/js-appendix-types.md index b491d59c5fef5c948bf5119fcac48e302a83f3ff..335bb726f6a1e9d3cd86adf0b5d54c493f4eb15e 100644 --- a/en/application-dev/reference/arkui-js/js-appendix-types.md +++ b/en/application-dev/reference/arkui-js/js-appendix-types.md @@ -1,4 +1,4 @@ -# Type Attributes +# Data Type Attributes ## Length Type diff --git a/en/application-dev/reference/arkui-js/js-components-basic-input.md b/en/application-dev/reference/arkui-js/js-components-basic-input.md index 283e9aae6e5ad9a4e4cb72abf1e3cc716c1c40d0..1f10982593566d8ad21467a9613d260ab6e6a3ec 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-input.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-input.md @@ -1,610 +1,239 @@ -# input<a name="EN-US_TOPIC_0000001173324647"></a> +# input -The **<input\>** component provides an interactive interface to receive user input. It can be a radio button, check box, button, single-line text box, and more. +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions<a name="section11257113618419"></a> +The **\<input>** component provides an interactive interface to receive user input. It can be a radio button, check box, button, single-line text box, and more. + +## Required Permissions None -## Child Component<a name="section9288143101012"></a> + +## Child Components Not supported -## Attributes<a name="section2907183951110"></a> - -In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. - -<a name="table20633101642315"></a> -<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aa872998ac2d84843a3c5161889afffef"><a name="aa872998ac2d84843a3c5161889afffef"></a><a name="aa872998ac2d84843a3c5161889afffef"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.2"><p id="ab2111648ee0e4f6d881be8954e7acaab"><a name="ab2111648ee0e4f6d881be8954e7acaab"></a><a name="ab2111648ee0e4f6d881be8954e7acaab"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="10.48%" id="mcps1.1.6.1.3"><p id="ab377d1c90900478ea4ecab51e9a058af"><a name="ab377d1c90900478ea4ecab51e9a058af"></a><a name="ab377d1c90900478ea4ecab51e9a058af"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.6.1.4"><p id="p824610360217"><a name="p824610360217"></a><a name="p824610360217"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="35.76%" id="mcps1.1.6.1.5"><p id="a1d574a0044ed42ec8a2603bc82734232"><a name="a1d574a0044ed42ec8a2603bc82734232"></a><a name="a1d574a0044ed42ec8a2603bc82734232"></a>Triggered when</p> -</th> -</tr> -</thead> -<tbody><tr id="row634417439274"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p72442555275"><a name="p72442555275"></a><a name="p72442555275"></a>type</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p324455511276"><a name="p324455511276"></a><a name="p324455511276"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p16244055182716"><a name="p16244055182716"></a><a name="p16244055182716"></a>text</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p3244155102714"><a name="p3244155102714"></a><a name="p3244155102714"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p924475517275"><a name="p924475517275"></a><a name="p924475517275"></a>Type of the input component. Available values include <span id="ph15675399414"><a name="ph15675399414"></a><a name="ph15675399414"></a><strong id="b83541911123611"><a name="b83541911123611"></a><a name="b83541911123611"></a>text</strong>, <strong id="b156006161365"><a name="b156006161365"></a><a name="b156006161365"></a>email</strong>, <strong id="b1389319187364"><a name="b1389319187364"></a><a name="b1389319187364"></a>date</strong>, <strong id="b17253623133610"><a name="b17253623133610"></a><a name="b17253623133610"></a>time</strong>, <strong id="b694311245368"><a name="b694311245368"></a><a name="b694311245368"></a>number</strong>, <strong id="b8826192763614"><a name="b8826192763614"></a><a name="b8826192763614"></a>password</strong>, </span><strong id="b157607296367"><a name="b157607296367"></a><a name="b157607296367"></a>button</strong>, <strong id="b192811231193612"><a name="b192811231193612"></a><a name="b192811231193612"></a>checkbox</strong>, and <strong id="b39501932123616"><a name="b39501932123616"></a><a name="b39501932123616"></a>radio</strong>.</p> -<p id="p1524485513274"><a name="p1524485513274"></a><a name="p1524485513274"></a>The <strong id="b59971579367"><a name="b59971579367"></a><a name="b59971579367"></a>text</strong>, <strong id="b412925983614"><a name="b412925983614"></a><a name="b412925983614"></a>email</strong>, <strong id="b42617014378"><a name="b42617014378"></a><a name="b42617014378"></a>date</strong>, <strong id="b1395915173720"><a name="b1395915173720"></a><a name="b1395915173720"></a>time</strong>, <strong id="b11407333711"><a name="b11407333711"></a><a name="b11407333711"></a>number</strong>, and <strong id="b12487347379"><a name="b12487347379"></a><a name="b12487347379"></a>password</strong> types can be dynamically switched and modified. </p> -<p id="p17244175532712"><a name="p17244175532712"></a><a name="p17244175532712"></a>The <strong id="b66701121123710"><a name="b66701121123710"></a><a name="b66701121123710"></a>button</strong>, <strong id="b1772519228379"><a name="b1772519228379"></a><a name="b1772519228379"></a>checkbox</strong>, and <strong id="b3750102423713"><a name="b3750102423713"></a><a name="b3750102423713"></a>radio</strong> types cannot be dynamically modified. Available values include:</p> -<a name="ul324417555275"></a><a name="ul324417555275"></a><ul id="ul324417555275"><li><strong id="b312413331652"><a name="b312413331652"></a><a name="b312413331652"></a>button</strong>: a button that can be clicked</li><li><strong id="b203263812249"><a name="b203263812249"></a><a name="b203263812249"></a>checkbox</strong>: a check box</li><li><strong id="b8292121938"><a name="b8292121938"></a><a name="b8292121938"></a>radio</strong>: a radio button that allows users to select one from multiple others with the same name</li><li><strong id="b166864913293"><a name="b166864913293"></a><a name="b166864913293"></a>text</strong>: a single-line text field</li><li><strong id="b18160637657"><a name="b18160637657"></a><a name="b18160637657"></a>email</strong>: a field used for an email address</li><li><strong id="b161243814516"><a name="b161243814516"></a><a name="b161243814516"></a>date</strong>: date control, including the year, month, and day, but excluding time</li><li><strong id="b1644983911514"><a name="b1644983911514"></a><a name="b1644983911514"></a>time</strong>: time control, without the time zone</li><li><strong id="b5368840559"><a name="b5368840559"></a><a name="b5368840559"></a>number</strong>: field for entering digits</li><li><strong id="b362814111511"><a name="b362814111511"></a><a name="b362814111511"></a>password</strong>: password field, in which characters will be shielded<div class="note" id="note45664136102"><a name="note45664136102"></a><a name="note45664136102"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1551717289101"><a name="p1551717289101"></a><a name="p1551717289101"></a>For wearables, only <strong id="b21340211936"><a name="b21340211936"></a><a name="b21340211936"></a>button</strong>, <strong id="b14107223132"><a name="b14107223132"></a><a name="b14107223132"></a>radio</strong>, and <strong id="b1093818254310"><a name="b1093818254310"></a><a name="b1093818254310"></a>checkbox</strong> types are supported.</p> -</div></div> -</li></ul> -</td> -</tr> -<tr id="row43454437272"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p5245185582713"><a name="p5245185582713"></a><a name="p5245185582713"></a>checked</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p202456551277"><a name="p202456551277"></a><a name="p202456551277"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1245165520272"><a name="p1245165520272"></a><a name="p1245165520272"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p6245855172718"><a name="p6245855172718"></a><a name="p6245855172718"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p12245115512279"><a name="p12245115512279"></a><a name="p12245115512279"></a>Whether the <strong id="b142024206232"><a name="b142024206232"></a><a name="b142024206232"></a><input></strong> component is selected. This attribute is valid only when <strong id="b12202112072313"><a name="b12202112072313"></a><a name="b12202112072313"></a>type</strong> is set to <strong id="b16202162042314"><a name="b16202162042314"></a><a name="b16202162042314"></a>checkbox</strong> or <strong id="b202037208232"><a name="b202037208232"></a><a name="b202037208232"></a>radio</strong>.</p> -</td> -</tr> -<tr id="row834544342712"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p19245855182719"><a name="p19245855182719"></a><a name="p19245855182719"></a>name</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p2245955192720"><a name="p2245955192720"></a><a name="p2245955192720"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p14245115502719"><a name="p14245115502719"></a><a name="p14245115502719"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p32451755182718"><a name="p32451755182718"></a><a name="p32451755182718"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p20245135542717"><a name="p20245135542717"></a><a name="p20245135542717"></a>Name of the input component.</p> -</td> -</tr> -<tr id="row18345124342713"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p0245185592712"><a name="p0245185592712"></a><a name="p0245185592712"></a>value</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p1224525518275"><a name="p1224525518275"></a><a name="p1224525518275"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p5245115582715"><a name="p5245115582715"></a><a name="p5245115582715"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p624515512278"><a name="p624515512278"></a><a name="p624515512278"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p0245255112710"><a name="p0245255112710"></a><a name="p0245255112710"></a>Value of the input component. When <strong id="b13677653019"><a name="b13677653019"></a><a name="b13677653019"></a>type</strong> is <strong id="b136511685302"><a name="b136511685302"></a><a name="b136511685302"></a>radio</strong>, this attribute is mandatory and the value must be unique for radio buttons with the same name.</p> -</td> -</tr> -<tr id="row1360803719278"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p52451955152716"><a name="p52451955152716"></a><a name="p52451955152716"></a>placeholder</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p2246135512274"><a name="p2246135512274"></a><a name="p2246135512274"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p12462557277"><a name="p12462557277"></a><a name="p12462557277"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p6246125562716"><a name="p6246125562716"></a><a name="p6246125562716"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p4246205572711"><a name="p4246205572711"></a><a name="p4246205572711"></a>Content of the hint text. This attribute is available only when the component type is set to <strong id="b29081929613"><a name="b29081929613"></a><a name="b29081929613"></a>text</strong>, <strong id="b15573141610"><a name="b15573141610"></a><a name="b15573141610"></a>email</strong>, <strong id="b1367410610620"><a name="b1367410610620"></a><a name="b1367410610620"></a>date</strong>, <strong id="b1258719818618"><a name="b1258719818618"></a><a name="b1258719818618"></a>time</strong>, <strong id="b128485356122"><a name="b128485356122"></a><a name="b128485356122"></a>number</strong>, or <strong id="b1921103313122"><a name="b1921103313122"></a><a name="b1921103313122"></a>password</strong>.</p> -</td> -</tr> -<tr id="row10729734112719"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p524615562717"><a name="p524615562717"></a><a name="p524615562717"></a>maxlength</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p4246165562713"><a name="p4246165562713"></a><a name="p4246165562713"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1246135522711"><a name="p1246135522711"></a><a name="p1246135522711"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p13246185517271"><a name="p13246185517271"></a><a name="p13246185517271"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p1224635514274"><a name="p1224635514274"></a><a name="p1224635514274"></a>Maximum number of characters that can be entered in the input box. If no value is specified, the number of characters is not limited.</p> -</td> -</tr> -<tr id="row1125513210279"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p14246125513277"><a name="p14246125513277"></a><a name="p14246125513277"></a>enterkeytype</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p7246055112718"><a name="p7246055112718"></a><a name="p7246055112718"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1324615552276"><a name="p1324615552276"></a><a name="p1324615552276"></a>default</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p10246115514272"><a name="p10246115514272"></a><a name="p10246115514272"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p1824635502717"><a name="p1824635502717"></a><a name="p1824635502717"></a>Dynamic modification is not supported.</p> -<p id="p12246255112712"><a name="p12246255112712"></a><a name="p12246255112712"></a>Available values include:</p> -<a name="ul52461055142716"></a><a name="ul52461055142716"></a><ul id="ul52461055142716"><li>default</li><li>next</li><li>go</li><li>done</li><li>send</li><li>Search</li></ul> -<div class="note" id="note1524765512720"><a name="note1524765512720"></a><a name="note1524765512720"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p124795592715"><a name="p124795592715"></a><a name="p124795592715"></a>The soft keyboard is automatically collapsed after you click the <strong id="b1861043823418"><a name="b1861043823418"></a><a name="b1861043823418"></a>Enter</strong> button, except when <strong id="b2064315920354"><a name="b2064315920354"></a><a name="b2064315920354"></a>next</strong> is displayed for the button.</p> -</div></div> -</td> -</tr> -<tr id="row2461329122714"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p8247655162711"><a name="p8247655162711"></a><a name="p8247655162711"></a>headericon</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p18247145520271"><a name="p18247145520271"></a><a name="p18247145520271"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p824715572713"><a name="p824715572713"></a><a name="p824715572713"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p2247135582717"><a name="p2247135582717"></a><a name="p2247135582717"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p20247755102711"><a name="p20247755102711"></a><a name="p20247755102711"></a>Icon resource path before text input. This icon does not support click events and is unavailable for <strong id="b87532361769"><a name="b87532361769"></a><a name="b87532361769"></a>button</strong>, <strong id="b15753163612613"><a name="b15753163612613"></a><a name="b15753163612613"></a>checkbox</strong>, and <strong id="b17754736663"><a name="b17754736663"></a><a name="b17754736663"></a>radio</strong> types. The supported icon image formats are JPG, PNG, and SVG.</p> -</td> -</tr> -<tr id="row16836876325"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p983712712329"><a name="p983712712329"></a><a name="p983712712329"></a>showcounter<sup id="sup19271132920334"><a name="sup19271132920334"></a><a name="sup19271132920334"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p178371971325"><a name="p178371971325"></a><a name="p178371971325"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p28374743210"><a name="p28374743210"></a><a name="p28374743210"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p6837677327"><a name="p6837677327"></a><a name="p6837677327"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p11837472328"><a name="p11837472328"></a><a name="p11837472328"></a>Whether to display the character counter for an input box. This attribute takes effect only when <strong id="b2518112655814"><a name="b2518112655814"></a><a name="b2518112655814"></a>maxlength</strong> is set.</p> -</td> -</tr> -<tr id="row07211971743"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p177221571244"><a name="p177221571244"></a><a name="p177221571244"></a>menuoptions<sup id="sup154944401542"><a name="sup154944401542"></a><a name="sup154944401542"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p8722157248"><a name="p8722157248"></a><a name="p8722157248"></a>Array<<a href="#table83621954963">MenuOption</a>></p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p167221878414"><a name="p167221878414"></a><a name="p167221878414"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p197227713411"><a name="p197227713411"></a><a name="p197227713411"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p207221573417"><a name="p207221573417"></a><a name="p207221573417"></a>Menu options displayed after users touch the <strong id="b3847114112495"><a name="b3847114112495"></a><a name="b3847114112495"></a>More</strong> button.</p> -</td> -</tr> -<tr id="row45541828184811"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p95550281483"><a name="p95550281483"></a><a name="p95550281483"></a>autofocus<sup id="sup1775142235010"><a name="sup1775142235010"></a><a name="sup1775142235010"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p1955511286485"><a name="p1955511286485"></a><a name="p1955511286485"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p6555192874812"><a name="p6555192874812"></a><a name="p6555192874812"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p3555142844817"><a name="p3555142844817"></a><a name="p3555142844817"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p135551628184820"><a name="p135551628184820"></a><a name="p135551628184820"></a>Whether to automatically obtain the focus.</p> -<div class="note" id="note9175194313116"><a name="note9175194313116"></a><a name="note9175194313116"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p554143517446"><a name="p554143517446"></a><a name="p554143517446"></a>This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the <strong id="b435318566233"><a name="b435318566233"></a><a name="b435318566233"></a>focus</strong> method call (for about 100–500 ms) in <strong id="b1336020563235"><a name="b1336020563235"></a><a name="b1336020563235"></a>onActive</strong>.</p> -</div></div> -</td> -</tr> -<tr id="row1261993119486"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p16196311485"><a name="p16196311485"></a><a name="p16196311485"></a>selectedstart<sup id="sup151911922125019"><a name="sup151911922125019"></a><a name="sup151911922125019"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p126191631104819"><a name="p126191631104819"></a><a name="p126191631104819"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p7619163110489"><a name="p7619163110489"></a><a name="p7619163110489"></a>-1</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p1619123120488"><a name="p1619123120488"></a><a name="p1619123120488"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p9619113118488"><a name="p9619113118488"></a><a name="p9619113118488"></a>Start position for text selection.</p> -</td> -</tr> -<tr id="row1823083417484"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p42301334184813"><a name="p42301334184813"></a><a name="p42301334184813"></a>selectedend<sup id="sup759182155017"><a name="sup759182155017"></a><a name="sup759182155017"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p1523013444810"><a name="p1523013444810"></a><a name="p1523013444810"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1823053404815"><a name="p1823053404815"></a><a name="p1823053404815"></a>-1</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p162301434104819"><a name="p162301434104819"></a><a name="p162301434104819"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p2023014344489"><a name="p2023014344489"></a><a name="p2023014344489"></a>End position for text selection.</p> -</td> -</tr> -<tr id="row6428183714485"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p11428837134811"><a name="p11428837134811"></a><a name="p11428837134811"></a>softkeyboardenabled<sup id="sup135541120205017"><a name="sup135541120205017"></a><a name="sup135541120205017"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p18428837114816"><a name="p18428837114816"></a><a name="p18428837114816"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p124281037144812"><a name="p124281037144812"></a><a name="p124281037144812"></a>true</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p842823714486"><a name="p842823714486"></a><a name="p842823714486"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p1642873734813"><a name="p1642873734813"></a><a name="p1642873734813"></a>Whether to display the soft keyboard during editing.</p> -</td> -</tr> -<tr id="row18278391483"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p10827143911483"><a name="p10827143911483"></a><a name="p10827143911483"></a>showpasswordicon<sup id="sup65401815115011"><a name="sup65401815115011"></a><a name="sup65401815115011"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p882719398489"><a name="p882719398489"></a><a name="p882719398489"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1082753994811"><a name="p1082753994811"></a><a name="p1082753994811"></a>true</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p13827183954817"><a name="p13827183954817"></a><a name="p13827183954817"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p10828939174817"><a name="p10828939174817"></a><a name="p10828939174817"></a>Whether to display the icon at the end of the password text box. The setting is valid only when <strong id="b8922113173716"><a name="b8922113173716"></a><a name="b8922113173716"></a>type</strong> is set to <strong id="b17325183893716"><a name="b17325183893716"></a><a name="b17325183893716"></a>password</strong>.</p> -</td> -</tr> -</tbody> -</table> - -**Table 1** MenuOption<sup>5+</sup> - -<a name="table83621954963"></a> -<table><thead align="left"><tr id="row536212545619"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p143621541967"><a name="p143621541967"></a><a name="p143621541967"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p936215541620"><a name="p936215541620"></a><a name="p936215541620"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p23626541665"><a name="p23626541665"></a><a name="p23626541665"></a>Triggered when</p> -</th> -</tr> -</thead> -<tbody><tr id="row5362254461"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p33631541265"><a name="p33631541265"></a><a name="p33631541265"></a>icon</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p536311543619"><a name="p536311543619"></a><a name="p536311543619"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p73631954762"><a name="p73631954762"></a><a name="p73631954762"></a>Path of the icon for a menu option.</p> -</td> -</tr> -<tr id="row136319547613"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p12363654367"><a name="p12363654367"></a><a name="p12363654367"></a>content</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1936312549617"><a name="p1936312549617"></a><a name="p1936312549617"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1036311548616"><a name="p1036311548616"></a><a name="p1036311548616"></a>Text content of a menu option.</p> -</td> -</tr> -</tbody> -</table> - -## Styles<a name="section066012492913"></a> - -In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. - -<a name="table168129500519"></a> -<table><thead align="left"><tr id="row3812115020515"><th class="cellrowborder" valign="top" width="23.11768823117688%" id="mcps1.1.6.1.1"><p id="p178128502053"><a name="p178128502053"></a><a name="p178128502053"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="20.537946205379463%" id="mcps1.1.6.1.2"><p id="p781295016511"><a name="p781295016511"></a><a name="p781295016511"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="22.757724227577242%" id="mcps1.1.6.1.3"><p id="p178126501150"><a name="p178126501150"></a><a name="p178126501150"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.58924107589241%" id="mcps1.1.6.1.4"><p id="p19812950754"><a name="p19812950754"></a><a name="p19812950754"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="25.997400259974%" id="mcps1.1.6.1.5"><p id="p381218501456"><a name="p381218501456"></a><a name="p381218501456"></a>Triggered when</p> -</th> -</tr> -</thead> -<tbody><tr id="row581317501655"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p12813750459"><a name="p12813750459"></a><a name="p12813750459"></a>color</p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p148132501751"><a name="p148132501751"></a><a name="p148132501751"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p16813350256"><a name="p16813350256"></a><a name="p16813350256"></a>#e6000000</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p1481311501514"><a name="p1481311501514"></a><a name="p1481311501514"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p138135501758"><a name="p138135501758"></a><a name="p138135501758"></a>Font color of the single-line text box or button.</p> -</td> -</tr> -<tr id="row13813175013515"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p118131250153"><a name="p118131250153"></a><a name="p118131250153"></a>font-size</p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p19813155013512"><a name="p19813155013512"></a><a name="p19813155013512"></a><length></p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p88134501155"><a name="p88134501155"></a><a name="p88134501155"></a>16px</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p381305019519"><a name="p381305019519"></a><a name="p381305019519"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p148131050253"><a name="p148131050253"></a><a name="p148131050253"></a>Font size of the single-line text box or button. </p> -</td> -</tr> -<tr id="row481312502519"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p3813050954"><a name="p3813050954"></a><a name="p3813050954"></a>allow-scale</p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p138139503518"><a name="p138139503518"></a><a name="p138139503518"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p181455012517"><a name="p181455012517"></a><a name="p181455012517"></a>true</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p8814145015518"><a name="p8814145015518"></a><a name="p8814145015518"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p12814195013511"><a name="p12814195013511"></a><a name="p12814195013511"></a>Whether the font size changes with the system's font size settings.</p> -<div class="note" id="note1781416501358"><a name="note1781416501358"></a><a name="note1781416501358"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p13814145011511"><a name="p13814145011511"></a><a name="p13814145011511"></a>If the <strong id="b524714361237"><a name="b524714361237"></a><a name="b524714361237"></a>config-changes</strong> tag of <strong id="b19256136236"><a name="b19256136236"></a><a name="b19256136236"></a>fontSize</strong> is configured for abilities in the <strong id="b32576360318"><a name="b32576360318"></a><a name="b32576360318"></a>config.json</strong> file, the setting takes effect without application restart.</p> -</div></div> -</td> -</tr> -<tr id="row781413506518"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p581410501158"><a name="p581410501158"></a><a name="p581410501158"></a>placeholder-color</p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p1781419501555"><a name="p1781419501555"></a><a name="p1781419501555"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p4814450854"><a name="p4814450854"></a><a name="p4814450854"></a>#99000000</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p12814350357"><a name="p12814350357"></a><a name="p12814350357"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p138140501751"><a name="p138140501751"></a><a name="p138140501751"></a>Color of the hint text in the single-line text box. This attribute is available when the component type is set to <strong id="b1165245531811"><a name="b1165245531811"></a><a name="b1165245531811"></a>text</strong>, <strong id="b7887185781818"><a name="b7887185781818"></a><a name="b7887185781818"></a>email</strong>, <strong id="b662675991816"><a name="b662675991816"></a><a name="b662675991816"></a>date</strong>, <strong id="b104879121919"><a name="b104879121919"></a><a name="b104879121919"></a>time</strong>, <strong id="b936871841920"><a name="b936871841920"></a><a name="b936871841920"></a>number</strong>, or <strong id="b6737912171919"><a name="b6737912171919"></a><a name="b6737912171919"></a>password</strong>.</p> -</td> -</tr> -<tr id="row58141650752"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p1381435012518"><a name="p1381435012518"></a><a name="p1381435012518"></a>font-weight</p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p98141250450"><a name="p98141250450"></a><a name="p98141250450"></a>number | string</p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p198141507512"><a name="p198141507512"></a><a name="p198141507512"></a>normal</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p20814185015510"><a name="p20814185015510"></a><a name="p20814185015510"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p1281455014516"><a name="p1281455014516"></a><a name="p1281455014516"></a>Font weight of the single-line text box or button. For details, see <a href="js-components-basic-text.md#section5775351116">font-weight</a> of the <strong id="b131111751153712"><a name="b131111751153712"></a><a name="b131111751153712"></a>text</strong> component.</p> -</td> -</tr> -<tr id="row1167411433019"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p18674104193019"><a name="p18674104193019"></a><a name="p18674104193019"></a>caret-color<sup id="sup628114393018"><a name="sup628114393018"></a><a name="sup628114393018"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="20.537946205379463%" headers="mcps1.1.6.1.2 "><p id="p13674194173010"><a name="p13674194173010"></a><a name="p13674194173010"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="22.757724227577242%" headers="mcps1.1.6.1.3 "><p id="p12674164113010"><a name="p12674164113010"></a><a name="p12674164113010"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.58924107589241%" headers="mcps1.1.6.1.4 "><p id="p5674114183020"><a name="p5674114183020"></a><a name="p5674114183020"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="25.997400259974%" headers="mcps1.1.6.1.5 "><p id="p18674134153015"><a name="p18674134153015"></a><a name="p18674134153015"></a>Color of the input cursor.</p> -</td> -</tr> -</tbody> -</table> - -## Events<a name="section1721512551218"></a> - -In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. - -- When the input component type is set to **text**, **email**, **date**, **time**, **number**, or **password**, the following events are supported. - - <a name="table9215955923"></a> - <table><thead align="left"><tr id="row02158552029"><th class="cellrowborder" valign="top" width="24.852485248524854%" id="mcps1.1.4.1.1"><p id="p1121618551728"><a name="p1121618551728"></a><a name="p1121618551728"></a>Name</p> - </th> - <th class="cellrowborder" valign="top" width="29.552955295529554%" id="mcps1.1.4.1.2"><p id="p182161855921"><a name="p182161855921"></a><a name="p182161855921"></a>Parameter</p> - </th> - <th class="cellrowborder" valign="top" width="45.5945594559456%" id="mcps1.1.4.1.3"><p id="p921685513212"><a name="p921685513212"></a><a name="p921685513212"></a>Triggered when</p> - </th> - </tr> - </thead> - <tbody><tr id="row102168555217"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p1221625514210"><a name="p1221625514210"></a><a name="p1221625514210"></a>change</p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p8216155822"><a name="p8216155822"></a><a name="p8216155822"></a>{ value:inputValue }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p18216135511213"><a name="p18216135511213"></a><a name="p18216135511213"></a>Triggered when the content entered in the text box changes. The most recent text entered by the user is returned.</p> - <div class="note" id="note32161955422"><a name="note32161955422"></a><a name="note32161955422"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p521616551527"><a name="p521616551527"></a><a name="p521616551527"></a>If you change the <strong id="b0472428225"><a name="b0472428225"></a><a name="b0472428225"></a>value</strong> attribute directly, this event will not be triggered.</p> - </div></div> - </td> - </tr> - <tr id="row152166550212"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p1121695515215"><a name="p1121695515215"></a><a name="p1121695515215"></a>enterkeyclick</p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p15216115511211"><a name="p15216115511211"></a><a name="p15216115511211"></a>{ value:enterKey }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p162165551211"><a name="p162165551211"></a><a name="p162165551211"></a>Triggered when the <strong id="b151716216246"><a name="b151716216246"></a><a name="b151716216246"></a>Enter</strong> key on a soft keyboard is pressed. The type of the <strong id="b141714218245"><a name="b141714218245"></a><a name="b141714218245"></a>Enter</strong> key is returned, which is of the number type. Available values are as follows:</p> - <a name="ul121665519215"></a><a name="ul121665519215"></a><ul id="ul121665519215"><li><strong id="b1548345132518"><a name="b1548345132518"></a><a name="b1548345132518"></a>2</strong>: returned if <strong id="b184901156253"><a name="b184901156253"></a><a name="b184901156253"></a>enterkeytype</strong> is <strong id="b124911657254"><a name="b124911657254"></a><a name="b124911657254"></a>go</strong>.</li><li><strong id="b751686253"><a name="b751686253"></a><a name="b751686253"></a>3</strong>: returned if <strong id="b1052188112512"><a name="b1052188112512"></a><a name="b1052188112512"></a>enterkeytype</strong> is <strong id="b18524802520"><a name="b18524802520"></a><a name="b18524802520"></a>search</strong>.</li><li><strong id="b746419112510"><a name="b746419112510"></a><a name="b746419112510"></a>4</strong>: returned if <strong id="b74652910250"><a name="b74652910250"></a><a name="b74652910250"></a>enterkeytype</strong> is <strong id="b13465189132516"><a name="b13465189132516"></a><a name="b13465189132516"></a>send</strong>.</li><li><strong id="b14743131042519"><a name="b14743131042519"></a><a name="b14743131042519"></a>5</strong>: returned if <strong id="b16743121016252"><a name="b16743121016252"></a><a name="b16743121016252"></a>enterkeytype</strong> is <strong id="b0744191012516"><a name="b0744191012516"></a><a name="b0744191012516"></a>next</strong>.</li><li><strong id="b133514143257"><a name="b133514143257"></a><a name="b133514143257"></a>6</strong>: returned if <strong id="b113411814112516"><a name="b113411814112516"></a><a name="b113411814112516"></a>enterkeytype</strong> is <strong id="b334151416257"><a name="b334151416257"></a><a name="b334151416257"></a>default</strong>, <strong id="b1934281412257"><a name="b1934281412257"></a><a name="b1934281412257"></a>done</strong>, or is not set.</li></ul> - </td> - </tr> - <tr id="row1121715551027"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p92175551422"><a name="p92175551422"></a><a name="p92175551422"></a>translate<sup id="sup13217195510219"><a name="sup13217195510219"></a><a name="sup13217195510219"></a>5+</sup></p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p321795510218"><a name="p321795510218"></a><a name="p321795510218"></a>{ value: selectedText }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p92171455627"><a name="p92171455627"></a><a name="p92171455627"></a>Triggered when users click the translate button in the pop menu displayed after they select a text segment. The selected text content is returned.</p> - </td> - </tr> - <tr id="row1821711551524"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p1321711551229"><a name="p1321711551229"></a><a name="p1321711551229"></a>share<sup id="sup182171255223"><a name="sup182171255223"></a><a name="sup182171255223"></a>5+</sup></p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p92171555228"><a name="p92171555228"></a><a name="p92171555228"></a>{ value: selectedText }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p122171055425"><a name="p122171055425"></a><a name="p122171055425"></a>Triggered when users click the share button in the pop menu displayed after they select a text segment. The selected text content is returned.</p> - </td> - </tr> - <tr id="row1921717551028"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p1821716555210"><a name="p1821716555210"></a><a name="p1821716555210"></a>search<sup id="sup20217175516211"><a name="sup20217175516211"></a><a name="sup20217175516211"></a>5+</sup></p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p1421715514216"><a name="p1421715514216"></a><a name="p1421715514216"></a>{ value: selectedText }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p20217175515210"><a name="p20217175515210"></a><a name="p20217175515210"></a>Triggered when users click the search button in the pop menu displayed after they select a text segment. The selected text content is returned.</p> - </td> - </tr> - <tr id="row2021725516220"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p521715553212"><a name="p521715553212"></a><a name="p521715553212"></a>optionselect<sup id="sup122171855227"><a name="sup122171855227"></a><a name="sup122171855227"></a>5+</sup></p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p721885513216"><a name="p721885513216"></a><a name="p721885513216"></a>{ index:optionIndex, value: selectedText }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p721812557212"><a name="p721812557212"></a><a name="p721812557212"></a>Triggered when users click a menu option in the pop menu displayed after they select a text segment. This event is valid only when the <strong id="b168471038173918"><a name="b168471038173918"></a><a name="b168471038173918"></a>menuoptions</strong> attribute is set. The option index and selected text content are returned.</p> - </td> - </tr> - <tr id="row1180295735010"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p17803157175014"><a name="p17803157175014"></a><a name="p17803157175014"></a>selectchange<sup id="sup774434715119"><a name="sup774434715119"></a><a name="sup774434715119"></a>6+</sup></p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p13803157185013"><a name="p13803157185013"></a><a name="p13803157185013"></a>{ start: number, end: number }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p4803155719505"><a name="p4803155719505"></a><a name="p4803155719505"></a>Triggered when the text selection changes.</p> - </td> - </tr> - </tbody> - </table> - -- When the input component type is set to **checkbox** or **radio**, the following events are supported. - - <a name="table722013552211"></a> - <table><thead align="left"><tr id="row1220145519211"><th class="cellrowborder" valign="top" width="24.852485248524854%" id="mcps1.1.4.1.1"><p id="p1220755621"><a name="p1220755621"></a><a name="p1220755621"></a>Name</p> - </th> - <th class="cellrowborder" valign="top" width="29.552955295529554%" id="mcps1.1.4.1.2"><p id="p322014550213"><a name="p322014550213"></a><a name="p322014550213"></a>Parameter</p> - </th> - <th class="cellrowborder" valign="top" width="45.5945594559456%" id="mcps1.1.4.1.3"><p id="p322117554212"><a name="p322117554212"></a><a name="p322117554212"></a>Triggered when</p> - </th> - </tr> - </thead> - <tbody><tr id="row1622118559216"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p922116551422"><a name="p922116551422"></a><a name="p922116551422"></a>change</p> - </td> - <td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p1322185512210"><a name="p1322185512210"></a><a name="p1322185512210"></a>{ checked:true | false }</p> - </td> - <td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p1822119551024"><a name="p1822119551024"></a><a name="p1822119551024"></a>Triggered when the checked status of the <strong id="b13256373400"><a name="b13256373400"></a><a name="b13256373400"></a>checkbox</strong> or <strong id="b17332143714015"><a name="b17332143714015"></a><a name="b17332143714015"></a>radio</strong> button changes.</p> - </td> - </tr> - </tbody> - </table> - - -## Methods<a name="section47669296127"></a> - -In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. - -<a name="t75606345ece64f818511af2963b4522d"></a> -<table><thead align="left"><tr id="rf7e96304e96b4abcada899f917623b50"><th class="cellrowborder" valign="top" width="16.88%" id="mcps1.1.4.1.1"><p id="abdd98ec01df046a7ac2f66a3fa4eda04"><a name="abdd98ec01df046a7ac2f66a3fa4eda04"></a><a name="abdd98ec01df046a7ac2f66a3fa4eda04"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="29.12%" id="mcps1.1.4.1.2"><p id="afa86bf0c638b4860a91ea0e6255b7744"><a name="afa86bf0c638b4860a91ea0e6255b7744"></a><a name="afa86bf0c638b4860a91ea0e6255b7744"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="54%" id="mcps1.1.4.1.3"><p id="aa7783f4706e8434493b6e941e0100652"><a name="aa7783f4706e8434493b6e941e0100652"></a><a name="aa7783f4706e8434493b6e941e0100652"></a>Triggered when</p> -</th> -</tr> -</thead> -<tbody><tr id="r51da7a66ad844356a54fc7d198bbc496"><td class="cellrowborder" valign="top" width="16.88%" headers="mcps1.1.4.1.1 "><p id="a37c62c3017bc4b85813051fedae5523a"><a name="a37c62c3017bc4b85813051fedae5523a"></a><a name="a37c62c3017bc4b85813051fedae5523a"></a>focus</p> -</td> -<td class="cellrowborder" valign="top" width="29.12%" headers="mcps1.1.4.1.2 "><p id="a0fa3cdedaab94e11b1c1df493e671084"><a name="a0fa3cdedaab94e11b1c1df493e671084"></a><a name="a0fa3cdedaab94e11b1c1df493e671084"></a>{focus:true|false}: If <strong id="b42842569136"><a name="b42842569136"></a><a name="b42842569136"></a>focus</strong> is not passed, the default value <strong id="b95941968149"><a name="b95941968149"></a><a name="b95941968149"></a>true</strong> is used.</p> -</td> -<td class="cellrowborder" valign="top" width="54%" headers="mcps1.1.4.1.3 "><p id="abc7c81f1669e4e27bdc255ddf7c24167"><a name="abc7c81f1669e4e27bdc255ddf7c24167"></a><a name="abc7c81f1669e4e27bdc255ddf7c24167"></a>Obtains or loses the focus of a component. When the component type is set to text, email, date, time, number, or password, the input method can be displayed or collapsed.</p> -</td> -</tr> -<tr id="row17342754165611"><td class="cellrowborder" valign="top" width="16.88%" headers="mcps1.1.4.1.1 "><p id="p1343054115615"><a name="p1343054115615"></a><a name="p1343054115615"></a>showError</p> -</td> -<td class="cellrowborder" valign="top" width="29.12%" headers="mcps1.1.4.1.2 "><p id="p153431354175613"><a name="p153431354175613"></a><a name="p153431354175613"></a>{ error: string }</p> -</td> -<td class="cellrowborder" valign="top" width="54%" headers="mcps1.1.4.1.3 "><p id="p1034315465618"><a name="p1034315465618"></a><a name="p1034315465618"></a>Displays the error message. This attribute is available when the component type is set to text, email, date, time, number, or password.</p> -</td> -</tr> -<tr id="row4919162415418"><td class="cellrowborder" valign="top" width="16.88%" headers="mcps1.1.4.1.1 "><p id="p191914240419"><a name="p191914240419"></a><a name="p191914240419"></a>delete<sup id="sup1636182514275"><a name="sup1636182514275"></a><a name="sup1636182514275"></a>6+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="29.12%" headers="mcps1.1.4.1.2 "><p id="p209201424104119"><a name="p209201424104119"></a><a name="p209201424104119"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="54%" headers="mcps1.1.4.1.3 "><p id="p2920424124118"><a name="p2920424124118"></a><a name="p2920424124118"></a>Deletes the text content based on the current cursor position when the input component type is set to <strong id="b4497036164114"><a name="b4497036164114"></a><a name="b4497036164114"></a>text</strong>, <strong id="b3497173619415"><a name="b3497173619415"></a><a name="b3497173619415"></a>email</strong>, <strong id="b949716360414"><a name="b949716360414"></a><a name="b949716360414"></a>date</strong>, <strong id="b5497236154118"><a name="b5497236154118"></a><a name="b5497236154118"></a>time</strong>, <strong id="b649783615419"><a name="b649783615419"></a><a name="b649783615419"></a>number</strong>, or <strong id="b1749743654115"><a name="b1749743654115"></a><a name="b1749743654115"></a>password</strong>. If the current input component does not have a cursor, the last character is deleted and the cursor is displayed by default.</p> -</td> -</tr> -</tbody> -</table> - -## Example Code<a name="section106355275448"></a> - -1. Single-line text box - - ``` - <!-- xxx.hml --> - <div class="content"> - <input id="input" class="input" type="text" value="" maxlength="20" enterkeytype="send" - headericon="/common/search.svg" placeholder="Please input text" onchange="change" - onenterkeyclick="enterkeyClick"> - </input> - <input class="button" type="button" value="Submit" onclick="buttonClick"></input> - </div> - ``` - - ``` - /* xxx.css */ - .content { - width: 60%; - flex-direction: column; - align-items: center; - } - .input { - placeholder-color: gray; - } - .button { - background-color: gray; - margin-top: 20px; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - change(e){ - prompt.showToast({ - message: "value: " + e.value, - duration: 3000, - }); - }, - enterkeyClick(e){ - prompt.showToast({ - message: "enterkey clicked", - duration: 3000, - }); - }, - buttonClick(e){ - this.$element("input").showError({ - error: 'error text' - }); - }, - } - ``` - -  - -2. Common button - - ``` - <!-- xxx.hml --> - <div class="div-button"> - <input class="button" type="button" value="Input-Button"></input> - </div> - ``` - - ``` - /* xxx.css */ - .div-button { - flex-direction: column; - align-items: center; - - - } - .button { - margin-top: 30px; - width: 280px; - } - ``` - -  - -3. Check box - - ``` - <!-- xxx.hml --> - <div class="content"> - <input onchange="checkboxOnChange" checked="true" type="checkbox"></input> - - </div> - ``` - - ``` - /* xxx.css */ - .content{ - width: 100%; - height: 200px; - - - align-items: center; - justify-content: center; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - checkboxOnChange(e) { - prompt.showToast({ - message:'checked: ' + e.checked, - duration: 3000, - }); - } - } - ``` - -  - -4. Radio button - - ``` - <!-- xxx.hml --> - <div class="content"> - <input type="radio" checked='true' name="radioSample" value="radio1" onchange="onRadioChange('radio1')"></input> - <input type="radio" checked='false' name="radioSample" value="radio2" onchange="onRadioChange('radio2')"></input> - <input type="radio" checked='false' name="radioSample" value="radio3" onchange="onRadioChange('radio3')"></input> - </div> - ``` - - ``` - /* xxx.css */ - .content{ - width: 100%; - height: 200px; - justify-content: center; - align-items: center; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - onRadioChange(inputValue, e) { - if (inputValue === e.value) { - prompt.showToast({ - message: 'The chosen radio is ' + e.value, - duration: 3000, - }); - } - } - } - ``` - -  +## Attributes + +In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. + +| Name | Type | Default Value | Mandatory| Description | +| -------------------------------- | ----------------------- | --------- | ---- | ------------------------------------------------------------ | +| type | string | text<br>| No | Type of the input component. Available values include **text**, **email**, **date**, **time**, **number**, **password**, **button**, **checkbox**, and **radio**.<br>The **text**, **email**, **date**, **time**, **number**, and **password** types can be dynamically switched and modified.<br>The **button**, **checkbox**, and **radio** types cannot be dynamically modified. <br>- **button**: a button that can be clicked.<br>- **checkbox**: a check box.<br>- **radio**: a radio button that allows users to select one from multiple others with the same name.<br>- **text**: a single-line text field.<br>- **email**: a field used for an email address.<br>- **date**: date component, including the year, month, and day, but excluding time.<br>- **time**: time component, without the time zone.<br>- **number**: field for entering digits.<br>- **password**: password field, in which characters will be shielded.| +| checked | boolean | false | No | Whether the **\<input>** component is selected. This attribute is valid only when **type** is set to **checkbox** or **radio**. | +| name | string | - | No | Name of the **\<input>** component.<br>This attribute is mandatory when **type** is set to **radio**. | +| value | string | - | No | Value of the **\<input>** component. When **type** is **radio**, this attribute is mandatory and the value must be unique for radio buttons with the same name.| +| placeholder | string | - | No | Content of the hint text. This attribute is available only when the component type is set to **text**, **email**, **date**, **time**, **number**, or **password**.| +| maxlength | number | - | No | Maximum number of characters that can be entered in the input box. The empty value indicates no limit.| +| enterkeytype | string | default | No | Type of the **Enter** key on the soft keyboard. The value cannot be dynamically updated.<br>Available values include:<br>- default<br>- next<br>- go<br>- done<br>- send<br>- search<br>Except for the **next** type, clicking the Enter key hides the soft keyboard.| +| headericon | string | - | No | Icon resource path before text input. This icon does not support click events and is unavailable for **button**, **checkbox**, and **radio** types. The supported icon image formats are JPG, PNG, and SVG.| +| showcounter<sup>5+</sup> | boolean | false | No | Whether to display the character counter for an input box. This attribute takes effect only when **maxlength** is set. | +| menuoptions<sup>5+</sup> | Array<MeunOption> | - | No | Menu options displayed after users click the **More** button. | +| autofocus<sup>6+</sup> | boolean | false | No | Whether to automatically obtain focus.<br>This attribute setting does not take effect on the application home page. You can enable a text box on the home page to automatically obtain focus, by delaying the **focus** method call (for about 100–500 ms) in **onActive**.| +| selectedstart<sup>6+</sup> | number | -1 | No | Start position for text selection. | +| selectedend<sup>6+</sup> | number | -1 | No | End position for text selection. | +| softkeyboardenabled<sup>6+</sup> | boolean | true | No | Whether to display the soft keyboard during editing. | +| showpasswordicon<sup>6+</sup> | boolean | true | No | Whether to display the icon at the end of the password text box. This attribute is available only when **type** is set to **password**. | + +**Table 1** MenuOption<sup>5+</sup> + +| Name | Type | Description | +| ------- | ------ | ----------- | +| icon | string | Path of the icon for a menu option.| +| content | string | Text content of a menu option.| + + +## Styles + +In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported. + +| Name | Type | Default Value | Mandatory| Description | +| ------------------------ | -------------------------- | ---------- | ---- | ------------------------------------------------------------ | +| color | <color> | \#e6000000 | No | Font color of the single-line text box or button. | +| font-size | <length> | 16px | No | Font size of the single-line text box or button. | +| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.| +| placeholder-color | <color> | \#99000000 | No | Color of the hint text in the single-line text box. This attribute is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**.| +| font-weight | number \| string | normal | No | Font weight of the single-line text box or button. For details, see **font-weight** of the [**\<text>** component](../arkui-js/js-components-basic-text.md).| +| caret-color<sup>6+</sup> | <color> | - | No | Color of the input cursor. | + + +## Events + +In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported. + +- When **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**, the following events are supported. + | Name | Parameter | Description | + | ------------------------- | ---------------------------------------- | ---------------------------------------- | + | change | {<br> value: inputValue<br> } | Triggered when the content entered in the input box changes. The most recent content entered by the user is returned.<br>If you change the **value** attribute directly, this event will not be triggered.| + | enterkeyclick | {<br> value: enterKey<br> } | Triggered when the **Enter** key on the soft keyboard is clicked. The type of the **Enter** key is returned, which is of the number type. Available values are as follows:<br>- **2**: returned if **enterkeytype** is **go**.<br>- **3**: returned if **enterkeytype** is **search**.<br>- **4**: returned if **enterkeytype** is **send**.<br>- **5**: returned if **enterkeytype** is **next**.<br>- **6**: returned if **enterkeytype** is **default**, **done**, or is not set.| + | translate<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the translate button in the menu displayed after they select a text segment. The selected text content is returned.| + | share<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the share button in the menu displayed after they select a text segment. The selected text content is returned.| + | search<sup>5+</sup> | {<br> value: selectedText<br> } | Triggered when users click the search button in the menu displayed after they select a text segment. The selected text content is returned.| + | optionselect<sup>5+</sup> | {<br> index: optionIndex,<br> value: selectedText<br> } | Triggered when users click a menu option in the menu displayed after they select a text segment. This event is valid only when the **menuoptions** attribute is set. The option index and selected text content are returned.| + | selectchange<sup>6+</sup> | {<br>start: number,<br>end: number<br> } | Triggered when the text selection changes. | + +- When **type** is set to **checkbox** or **radio**, the following events are supported. + | Name | Parameter | Description | + | ------ | ---------------------------------------- | ---------------------------------------- | + | change | {<br> checked:true \| false <br>} | Triggered when the checked status of the **checkbox** or **radio** button changes.| + +## Methods + +In addition to the [universal methods](../arkui-js/js-components-common-methods.md), the following methods are supported. + +| Name | Parameter | Description | +| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| focus | {<br> focus: true\|false<br> }:<br>If **focus** is not passed, the default value **true** is used.| Obtains or loses focus. When **type** is set to **text**, **email**, **date**, **time**, **number**, or password, the input method can be displayed or hidden.| +| showError | {<br> error: string <br>} | Displays the error message. This attribute is available when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**.| +| delete<sup>6+</sup> | - | Deletes the text content based on the current cursor position when **type** is set to **text**, **email**, **date**, **time**, **number**, or **password**; deletes the last character and displays the cursor if the current input component does not have a cursor.| + +## Example + +1. Single-line text box + ```html + <!-- xxx.hml --> + <div class="content"> + <input id="input" class="input" type="text" value="" maxlength="20" enterkeytype="send" + headericon="/common/search.svg" placeholder="Please input text" onchange="change" + onenterkeyclick="enterkeyClick"> + </input> + <input class="button" type="button" value="Submit" onclick="buttonClick"></input> + </div> + ``` + + ```css + /* xxx.css */ + .content { + width: 60%; + flex-direction: column; + align-items: center; + } + .input { + placeholder-color: gray; + } + .button { + background-color: gray; + margin-top: 20px; + } + ``` + + ```js + // xxx.js + import prompt from '@system.prompt' + export default { + change(e){ + prompt.showToast({ + message: "value: " + e.value, + duration: 3000, + }); + }, + enterkeyClick(e){ + prompt.showToast({ + message: "enterkey clicked", + duration: 3000, + }); + }, + buttonClick(e){ + this.$element("input").showError({ + error: 'error text' + }); + }, + } + ``` + +  + +2. Common button + ```html + <!-- xxx.hml --> + <div class="div-button"> + <input class="button" type="button" value="Input-Button"></input> + </div> + ``` + + ```css + /* xxx.css */ + .div-button { + flex-direction: column; + align-items: center; + } + .button { + margin-top: 30px; + width: 280px; + } + ``` + +  + +3. Check box + ```html + <!-- xxx.hml --> + <div class="content"> + <input onchange="checkboxOnChange" checked="true" type="checkbox"></input> + </div> + ``` + + ```css + /* xxx.css */ + .content{ + width: 100%; + height: 200px; + align-items: center; + justify-content: center; + } + ``` + + ```js + // xxx.js + import prompt from '@system.prompt' + export default { + checkboxOnChange(e) { + prompt.showToast({ + message:'checked: ' + e.checked, + duration: 3000, + }); + } + } + ``` + +  + +4. Radio button + ```html + <!-- xxx.hml --> + <div class="content"> + <input type="radio" checked='true' name="radioSample" value="radio1" onchange="onRadioChange('radio1')"></input> + <input type="radio" checked='false' name="radioSample" value="radio2" onchange="onRadioChange('radio2')"></input> + <input type="radio" checked='false' name="radioSample" value="radio3" onchange="onRadioChange('radio3')"></input> + </div> + ``` + + ```css + /* xxx.css */ + .content{ + width: 100%; + height: 200px; + justify-content: center; + align-items: center; + } + ``` + + ```js + // xxx.js + import prompt from '@system.prompt' + export default { + onRadioChange(inputValue, e) { + if (inputValue === e.value) { + prompt.showToast({ + message: 'The chosen radio is ' + e.value, + duration: 3000, + }); + } + } + } + ``` + +  diff --git a/en/application-dev/reference/arkui-js/js-components-basic-marquee.md b/en/application-dev/reference/arkui-js/js-components-basic-marquee.md index 6f8ba597ae293c90835bc5d867ebcb91eaa733ab..9f13895436ce5f1104994f9d6956deba5e04a928 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-marquee.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-marquee.md @@ -1,215 +1,69 @@ -# marquee<a name="EN-US_TOPIC_0000001173324593"></a> +# marquee -The **<marquee\>** component displays single-line scrolling text. +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +> Since API version 6, the text scrolls only when its width exceeds the width of the **\<marquee>** component. -## Required Permissions<a name="section11257113618419"></a> +The **\<marquee>** component is used to display a scrolling piece of text. + +## Required Permissions None -## Child Component<a name="section9288143101012"></a> + +## Child Components Not supported -## Attributes<a name="section2907183951110"></a> -In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. +## Attributes -<a name="table20633101642315"></a> -<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aa872998ac2d84843a3c5161889afffef"><a name="aa872998ac2d84843a3c5161889afffef"></a><a name="aa872998ac2d84843a3c5161889afffef"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.2"><p id="ab2111648ee0e4f6d881be8954e7acaab"><a name="ab2111648ee0e4f6d881be8954e7acaab"></a><a name="ab2111648ee0e4f6d881be8954e7acaab"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="10.48%" id="mcps1.1.6.1.3"><p id="ab377d1c90900478ea4ecab51e9a058af"><a name="ab377d1c90900478ea4ecab51e9a058af"></a><a name="ab377d1c90900478ea4ecab51e9a058af"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.6.1.4"><p id="p824610360217"><a name="p824610360217"></a><a name="p824610360217"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="35.76%" id="mcps1.1.6.1.5"><p id="a1d574a0044ed42ec8a2603bc82734232"><a name="a1d574a0044ed42ec8a2603bc82734232"></a><a name="a1d574a0044ed42ec8a2603bc82734232"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row4159854131011"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p17480906111"><a name="p17480906111"></a><a name="p17480906111"></a>scrollamount</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p11480105116"><a name="p11480105116"></a><a name="p11480105116"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p9480809115"><a name="p9480809115"></a><a name="p9480809115"></a>6</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p1848070181110"><a name="p1848070181110"></a><a name="p1848070181110"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p164801809111"><a name="p164801809111"></a><a name="p164801809111"></a>Maximum length of each scroll.</p> -</td> -</tr> -<tr id="row66871514109"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p84809019113"><a name="p84809019113"></a><a name="p84809019113"></a>loop</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p548000141112"><a name="p548000141112"></a><a name="p548000141112"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p8480208113"><a name="p8480208113"></a><a name="p8480208113"></a>-1</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p1948090161115"><a name="p1948090161115"></a><a name="p1948090161115"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p164801031110"><a name="p164801031110"></a><a name="p164801031110"></a>Number of rolling times. If this parameter is not set, the default value <strong id="b94021459245"><a name="b94021459245"></a><a name="b94021459245"></a>-1</strong> is used. When the value is less than or equal to <strong id="b415127958"><a name="b415127958"></a><a name="b415127958"></a>0</strong>, the marquee scrolls continuously.</p> -</td> -</tr> -<tr id="row192934491109"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p44801808116"><a name="p44801808116"></a><a name="p44801808116"></a>direction</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p114809011116"><a name="p114809011116"></a><a name="p114809011116"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p1248015019119"><a name="p1248015019119"></a><a name="p1248015019119"></a>left</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p11480150191112"><a name="p11480150191112"></a><a name="p11480150191112"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p64801707115"><a name="p64801707115"></a><a name="p64801707115"></a>Direction in which the marquee scrolls, which can be <strong id="b13301427193515"><a name="b13301427193515"></a><a name="b13301427193515"></a>left</strong> or <strong id="b970462943510"><a name="b970462943510"></a><a name="b970462943510"></a>right</strong>.</p> -</td> -</tr> -</tbody> -</table> +In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. -## Styles<a name="section14898114221220"></a> +| Name | Type | Default Value | Mandatory | Description | +| ------------ | ------ | ---- | ---- | ---------------------------------------- | +| scrollamount | number | 6 | No | Maximum length of each scroll. | +| loop | number | -1 | No | Number of rolling times. If this parameter is not set, the default value **-1** is used. When the value is less than or equal to **0**, the marquee scrolls continuously.| +| direction | string | left | No | Direction in which the marquee scrolls, which can be **left** or **right**. | -In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. -<a name="table155966253920"></a> -<table><thead align="left"><tr id="row195961025998"><th class="cellrowborder" valign="top" width="20.137986201379864%" id="mcps1.1.6.1.1"><p id="p1759616251194"><a name="p1759616251194"></a><a name="p1759616251194"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="13.968603139686032%" id="mcps1.1.6.1.2"><p id="p759613251897"><a name="p759613251897"></a><a name="p759613251897"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="18.358164183581643%" id="mcps1.1.6.1.3"><p id="p1659619251099"><a name="p1659619251099"></a><a name="p1659619251099"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.519248075192481%" id="mcps1.1.6.1.4"><p id="p45961225998"><a name="p45961225998"></a><a name="p45961225998"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="40.01599840015999%" id="mcps1.1.6.1.5"><p id="p14596142511915"><a name="p14596142511915"></a><a name="p14596142511915"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row16597162517910"><td class="cellrowborder" valign="top" width="20.137986201379864%" headers="mcps1.1.6.1.1 "><p id="p2059717251991"><a name="p2059717251991"></a><a name="p2059717251991"></a>color</p> -</td> -<td class="cellrowborder" valign="top" width="13.968603139686032%" headers="mcps1.1.6.1.2 "><p id="p75977251899"><a name="p75977251899"></a><a name="p75977251899"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="18.358164183581643%" headers="mcps1.1.6.1.3 "><p id="p859714251891"><a name="p859714251891"></a><a name="p859714251891"></a>#e5000000</p> -</td> -<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p185974256916"><a name="p185974256916"></a><a name="p185974256916"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p15973251294"><a name="p15973251294"></a><a name="p15973251294"></a>Font color of the scrolling text.</p> -</td> -</tr> -<tr id="row6597525594"><td class="cellrowborder" valign="top" width="20.137986201379864%" headers="mcps1.1.6.1.1 "><p id="p359710255920"><a name="p359710255920"></a><a name="p359710255920"></a>font-size</p> -</td> -<td class="cellrowborder" valign="top" width="13.968603139686032%" headers="mcps1.1.6.1.2 "><p id="p11597112510915"><a name="p11597112510915"></a><a name="p11597112510915"></a><length></p> -</td> -<td class="cellrowborder" valign="top" width="18.358164183581643%" headers="mcps1.1.6.1.3 "><p id="p45974252096"><a name="p45974252096"></a><a name="p45974252096"></a>37.5</p> -</td> -<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p359711251697"><a name="p359711251697"></a><a name="p359711251697"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p8597132516911"><a name="p8597132516911"></a><a name="p8597132516911"></a>Font size of the scrolling text. </p> -</td> -</tr> -<tr id="row1859816259917"><td class="cellrowborder" valign="top" width="20.137986201379864%" headers="mcps1.1.6.1.1 "><p id="p1259882514916"><a name="p1259882514916"></a><a name="p1259882514916"></a>allow-scale</p> -</td> -<td class="cellrowborder" valign="top" width="13.968603139686032%" headers="mcps1.1.6.1.2 "><p id="p17598182515919"><a name="p17598182515919"></a><a name="p17598182515919"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="18.358164183581643%" headers="mcps1.1.6.1.3 "><p id="p145981525999"><a name="p145981525999"></a><a name="p145981525999"></a>true</p> -</td> -<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p145981252096"><a name="p145981252096"></a><a name="p145981252096"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p7598192511919"><a name="p7598192511919"></a><a name="p7598192511919"></a>Whether the font size changes with the system's font size settings.</p> -<div class="note" id="note185981525290"><a name="note185981525290"></a><a name="note185981525290"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1259842517919"><a name="p1259842517919"></a><a name="p1259842517919"></a>If the <strong id="b1536242895218"><a name="b1536242895218"></a><a name="b1536242895218"></a>config-changes</strong> tag of <strong id="b6367152819525"><a name="b6367152819525"></a><a name="b6367152819525"></a>fontSize</strong> is configured for abilities in the <strong id="b2367228115217"><a name="b2367228115217"></a><a name="b2367228115217"></a>config.json</strong> file, the setting takes effect without application restart.</p> -</div></div> -</td> -</tr> -<tr id="row659811251296"><td class="cellrowborder" valign="top" width="20.137986201379864%" headers="mcps1.1.6.1.1 "><p id="p155983256912"><a name="p155983256912"></a><a name="p155983256912"></a>font-weight</p> -</td> -<td class="cellrowborder" valign="top" width="13.968603139686032%" headers="mcps1.1.6.1.2 "><p id="p155982251699"><a name="p155982251699"></a><a name="p155982251699"></a>number | string</p> -</td> -<td class="cellrowborder" valign="top" width="18.358164183581643%" headers="mcps1.1.6.1.3 "><p id="p16598125093"><a name="p16598125093"></a><a name="p16598125093"></a>normal</p> -</td> -<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p8598172512913"><a name="p8598172512913"></a><a name="p8598172512913"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p75985251598"><a name="p75985251598"></a><a name="p75985251598"></a>Font weight of the scrolling text. For details, see <a href="js-components-basic-text.md#section5775351116">font-weight</a> of the <strong id="b19548144111381"><a name="b19548144111381"></a><a name="b19548144111381"></a>text</strong> component.</p> -</td> -</tr> -<tr id="row155991725398"><td class="cellrowborder" valign="top" width="20.137986201379864%" headers="mcps1.1.6.1.1 "><p id="p1359915259911"><a name="p1359915259911"></a><a name="p1359915259911"></a>font-family</p> -</td> -<td class="cellrowborder" valign="top" width="13.968603139686032%" headers="mcps1.1.6.1.2 "><p id="p17599112517917"><a name="p17599112517917"></a><a name="p17599112517917"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="18.358164183581643%" headers="mcps1.1.6.1.3 "><p id="p115993251911"><a name="p115993251911"></a><a name="p115993251911"></a>sans-serif</p> -</td> -<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p id="p145994259915"><a name="p145994259915"></a><a name="p145994259915"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p1459972510914"><a name="p1459972510914"></a><a name="p1459972510914"></a>Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font that exists in the system or the font specified by <a href="js-components-common-customizing-font.md">Custom Font Styles</a> in the family is selected as the font for the text. </p> -</td> -</tr> -</tbody> -</table> +## Styles -## Events<a name="section3892191911214"></a> +In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported. -In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. +| Name | Type | Default Value | Mandatory | Description | +| ----------- | -------------------------- | ---------- | ---- | ---------------------------------------- | +| color | <color> | \#e5000000 | No | Font color of the scrolling text. | +| font-size | <length> | 37.5 | No | Font size of the scrolling text. | +| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.| +| font-weight | number \| string | normal | No | Font weight of the scrolling text. For details, see **font-weight** of the **[\<text> component](../arkui-js/js-components-basic-text.md#styles)**.| +| font-family | string | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](../arkui-js/js-components-common-customizing-font.md) is used for the text.| -<a name="table84827284164"></a> -<table><thead align="left"><tr id="row8483172891613"><th class="cellrowborder" valign="top" width="24.852485248524854%" id="mcps1.1.4.1.1"><p id="a426b8903842d48fa8012a24ff3c997eb"><a name="a426b8903842d48fa8012a24ff3c997eb"></a><a name="a426b8903842d48fa8012a24ff3c997eb"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="29.552955295529554%" id="mcps1.1.4.1.2"><p id="a53448ba47e5e4ae9bf7774c90820e970"><a name="a53448ba47e5e4ae9bf7774c90820e970"></a><a name="a53448ba47e5e4ae9bf7774c90820e970"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="45.5945594559456%" id="mcps1.1.4.1.3"><p id="add489ff50c444f24b759162c7f4bad9a"><a name="add489ff50c444f24b759162c7f4bad9a"></a><a name="add489ff50c444f24b759162c7f4bad9a"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row16168174591613"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p2558953141613"><a name="p2558953141613"></a><a name="p2558953141613"></a>bounce(Rich)</p> -</td> -<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p10558253161617"><a name="p10558253161617"></a><a name="p10558253161617"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p65581539160"><a name="p65581539160"></a><a name="p65581539160"></a>Triggered when the marquee scrolls to the end.</p> -</td> -</tr> -<tr id="row101671442171616"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p15585534167"><a name="p15585534167"></a><a name="p15585534167"></a>finish(Rich)</p> -</td> -<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p145584535165"><a name="p145584535165"></a><a name="p145584535165"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p18558125361620"><a name="p18558125361620"></a><a name="p18558125361620"></a>Triggered when the marquee finishes the specified number of scrollings (value of the <strong id="b1030012198368"><a name="b1030012198368"></a><a name="b1030012198368"></a>loop</strong> attribute). It can be triggered only when the <strong id="b15990247163611"><a name="b15990247163611"></a><a name="b15990247163611"></a>loop</strong> attribute is set to a number greater than 0.</p> -</td> -</tr> -<tr id="row9227173721610"><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p id="p35585536166"><a name="p35585536166"></a><a name="p35585536166"></a>start(Rich)</p> -</td> -<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p id="p5558115318166"><a name="p5558115318166"></a><a name="p5558115318166"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p id="p1955817532168"><a name="p1955817532168"></a><a name="p1955817532168"></a>Triggered when the marquee starts to scroll.</p> -</td> -</tr> -</tbody> -</table> -## Methods<a name="section47669296127"></a> +## Events -In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. +In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported. -<a name="ta27ae6832ab647a880ab27801368ec17"></a> -<table><thead align="left"><tr id="r00746cc3f4244fd7bf405d1640b42842"><th class="cellrowborder" valign="top" width="16.689999999999998%" id="mcps1.1.4.1.1"><p id="a6853bf471a534d9185a46033e5301a3c"><a name="a6853bf471a534d9185a46033e5301a3c"></a><a name="a6853bf471a534d9185a46033e5301a3c"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="6.5600000000000005%" id="mcps1.1.4.1.2"><p id="a2f6b46265ccd412b8be977c934e2e06e"><a name="a2f6b46265ccd412b8be977c934e2e06e"></a><a name="a2f6b46265ccd412b8be977c934e2e06e"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="76.75%" id="mcps1.1.4.1.3"><p id="ab97e815e4f734c4290f4f7cb608e45d4"><a name="ab97e815e4f734c4290f4f7cb608e45d4"></a><a name="ab97e815e4f734c4290f4f7cb608e45d4"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="rfd984b5dab4c419fb56fb95b53614076"><td class="cellrowborder" valign="top" width="16.689999999999998%" headers="mcps1.1.4.1.1 "><p id="a650170fd03b64d42894295d360ad74dd"><a name="a650170fd03b64d42894295d360ad74dd"></a><a name="a650170fd03b64d42894295d360ad74dd"></a>start</p> -</td> -<td class="cellrowborder" valign="top" width="6.5600000000000005%" headers="mcps1.1.4.1.2 "><p id="a634a82d9b27a449891db2c1e04622259"><a name="a634a82d9b27a449891db2c1e04622259"></a><a name="a634a82d9b27a449891db2c1e04622259"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="76.75%" headers="mcps1.1.4.1.3 "><p id="a8ab976e5b8344f9b9849843a5b30128a"><a name="a8ab976e5b8344f9b9849843a5b30128a"></a><a name="a8ab976e5b8344f9b9849843a5b30128a"></a>Starts scrolling.</p> -</td> -</tr> -<tr id="r15b7a1086fd047ea984b9cb4955dd98c"><td class="cellrowborder" valign="top" width="16.689999999999998%" headers="mcps1.1.4.1.1 "><p id="aab35a49bf5d440958734b6b30ae5c129"><a name="aab35a49bf5d440958734b6b30ae5c129"></a><a name="aab35a49bf5d440958734b6b30ae5c129"></a>stop</p> -</td> -<td class="cellrowborder" valign="top" width="6.5600000000000005%" headers="mcps1.1.4.1.2 "><p id="aaf270b3435ba4d1ba5c038066d3d08a8"><a name="aaf270b3435ba4d1ba5c038066d3d08a8"></a><a name="aaf270b3435ba4d1ba5c038066d3d08a8"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="76.75%" headers="mcps1.1.4.1.3 "><p id="a4ea339c3428f474696fe3491579ac922"><a name="a4ea339c3428f474696fe3491579ac922"></a><a name="a4ea339c3428f474696fe3491579ac922"></a>Stops scrolling.</p> -</td> -</tr> -</tbody> -</table> +| Name | Parameter | Description | +| ------------ | ---- | ---------------------------------------- | +| bounce(Rich) | - | Triggered when the marquee scrolls to the end. | +| finish(Rich) | - | Triggered when the marquee finishes the specified number of scrollings (value of the **loop** attribute). It can be triggered only when the **loop** attribute is set to a number greater than 0.| +| start(Rich) | - | Triggered when the marquee starts to scroll. | -## Example Code<a name="section198211501414"></a> +## Methods -``` +In addition to the [universal methods](../arkui-js/js-components-common-methods.md), the following methods are supported. + +| Name | Parameter | Description | +| ----- | ---- | ----- | +| start | - | Starts scrolling.| +| stop | - | Stops scrolling.| + + +## Example + +```html <!-- xxx.hml --> <div class="container"> <marquee id="customMarquee" class="customMarquee" scrollamount="{{scrollAmount}}" loop="{{loop}}"direction="{{marqueeDir}}" @@ -221,7 +75,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -252,7 +106,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` -``` +```js // xxx.js export default { data: { @@ -279,5 +133,4 @@ export default { } ``` - - + diff --git a/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md b/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md index 7c925bad746aad5bbade92971de79b1a8063d071..426e227f9009c06b9e6c82f3344719c9d988e948 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md @@ -1,577 +1,128 @@ -# picker-view<a name="EN-US_TOPIC_0000001127125108"></a> +# picker-view -The **<picker-view\>** component provides the view that shows an embedded scrollable selector on the screen. +> **NOTE** +> +> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. -## Child Components<a name="section54292411343"></a> +The **\<picker-view>** component provides the view that shows an embedded scrollable selector on the screen. + + +## Child Components Not supported -## Attributes<a name="section121957126347"></a> - -In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. - -<a name="table20633101642315"></a> -<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p id="aa872998ac2d84843a3c5161889afffef"><a name="aa872998ac2d84843a3c5161889afffef"></a><a name="aa872998ac2d84843a3c5161889afffef"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.2"><p id="ab2111648ee0e4f6d881be8954e7acaab"><a name="ab2111648ee0e4f6d881be8954e7acaab"></a><a name="ab2111648ee0e4f6d881be8954e7acaab"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="10.48%" id="mcps1.1.6.1.3"><p id="ab377d1c90900478ea4ecab51e9a058af"><a name="ab377d1c90900478ea4ecab51e9a058af"></a><a name="ab377d1c90900478ea4ecab51e9a058af"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.1.6.1.4"><p id="p824610360217"><a name="p824610360217"></a><a name="p824610360217"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="35.76%" id="mcps1.1.6.1.5"><p id="a1d574a0044ed42ec8a2603bc82734232"><a name="a1d574a0044ed42ec8a2603bc82734232"></a><a name="a1d574a0044ed42ec8a2603bc82734232"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row6290565914"><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p id="p136971571796"><a name="p136971571796"></a><a name="p136971571796"></a>type</p> -</td> -<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p id="p36971373918"><a name="p36971373918"></a><a name="p36971373918"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p id="p3697774912"><a name="p3697774912"></a><a name="p3697774912"></a>text</p> -</td> -<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.1.6.1.4 "><p id="p12697377919"><a name="p12697377919"></a><a name="p12697377919"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="35.76%" headers="mcps1.1.6.1.5 "><p id="p126974719915"><a name="p126974719915"></a><a name="p126974719915"></a>Type of the scrollable selector, which cannot be changed dynamically. Available values are as follows:</p> -<a name="ul16977711916"></a><a name="ul16977711916"></a><ul id="ul16977711916"><li><strong id="b184817616590"><a name="b184817616590"></a><a name="b184817616590"></a>text</strong>: text selector</li><li><strong id="b116831455916"><a name="b116831455916"></a><a name="b116831455916"></a>time</strong>: time selector</li><li><strong id="b42691554144215"><a name="b42691554144215"></a><a name="b42691554144215"></a>date</strong>: date selector</li><li><strong id="b540355819423"><a name="b540355819423"></a><a name="b540355819423"></a>datetime</strong>: date and time selector</li><li><strong id="b222813410439"><a name="b222813410439"></a><a name="b222813410439"></a>multi-text</strong>: multi-column text selector</li></ul> -</td> -</tr> -</tbody> -</table> - -Text selector \(**type** is **text**\) - -<a name="ta708bd4856a044b79bae50a2ce6981b8"></a> -<table><thead align="left"><tr id="re08662644cee4140ad0d5bac7978cd9b"><th class="cellrowborder" valign="top" width="24.007599240075994%" id="mcps1.1.6.1.1"><p id="af5b093e471ec47119f04bf2fe91b6f64"><a name="af5b093e471ec47119f04bf2fe91b6f64"></a><a name="af5b093e471ec47119f04bf2fe91b6f64"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="10.808919108089192%" id="mcps1.1.6.1.2"><p id="a8c2c2f6a645749b7852ec7dcadaca702"><a name="a8c2c2f6a645749b7852ec7dcadaca702"></a><a name="a8c2c2f6a645749b7852ec7dcadaca702"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="8.62913708629137%" id="mcps1.1.6.1.3"><p id="aa63c3dd750aa44fb9ec9031e632f4f5f"><a name="aa63c3dd750aa44fb9ec9031e632f4f5f"></a><a name="aa63c3dd750aa44fb9ec9031e632f4f5f"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.14928507149285%" id="mcps1.1.6.1.4"><p id="aee9661e3366543aeac6aa37e48de4c87"><a name="aee9661e3366543aeac6aa37e48de4c87"></a><a name="aee9661e3366543aeac6aa37e48de4c87"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="49.4050594940506%" id="mcps1.1.6.1.5"><p id="a2dc04c78fce4402d9dead84ab8412bb3"><a name="a2dc04c78fce4402d9dead84ab8412bb3"></a><a name="a2dc04c78fce4402d9dead84ab8412bb3"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="re8122915226c4596b2bffeae21e37b10"><td class="cellrowborder" valign="top" width="24.007599240075994%" headers="mcps1.1.6.1.1 "><p id="p64901432865"><a name="p64901432865"></a><a name="p64901432865"></a>range</p> -</td> -<td class="cellrowborder" valign="top" width="10.808919108089192%" headers="mcps1.1.6.1.2 "><p id="p194901326610"><a name="p194901326610"></a><a name="p194901326610"></a>Array</p> -</td> -<td class="cellrowborder" valign="top" width="8.62913708629137%" headers="mcps1.1.6.1.3 "><p id="p16490183216616"><a name="p16490183216616"></a><a name="p16490183216616"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.14928507149285%" headers="mcps1.1.6.1.4 "><p id="p12490132765"><a name="p12490132765"></a><a name="p12490132765"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.4050594940506%" headers="mcps1.1.6.1.5 "><p id="p879110395507"><a name="p879110395507"></a><a name="p879110395507"></a>Value range of the text selector.</p> -<div class="note" id="note195791919121"><a name="note195791919121"></a><a name="note195791919121"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p11957191913124"><a name="p11957191913124"></a><a name="p11957191913124"></a>Use the data binding mode, for example, range = {{data}}. Declare the corresponding variable <strong id="b1056351631112"><a name="b1056351631112"></a><a name="b1056351631112"></a>data: ["15", "20", "25"]</strong> in JavaScript.</p> -</div></div> -</td> -</tr> -<tr id="row2068183074711"><td class="cellrowborder" valign="top" width="24.007599240075994%" headers="mcps1.1.6.1.1 "><p id="p54902321765"><a name="p54902321765"></a><a name="p54902321765"></a>selected</p> -</td> -<td class="cellrowborder" valign="top" width="10.808919108089192%" headers="mcps1.1.6.1.2 "><p id="p24901321469"><a name="p24901321469"></a><a name="p24901321469"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.62913708629137%" headers="mcps1.1.6.1.3 "><p id="p14901932863"><a name="p14901932863"></a><a name="p14901932863"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="7.14928507149285%" headers="mcps1.1.6.1.4 "><p id="p1049018321869"><a name="p1049018321869"></a><a name="p1049018321869"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.4050594940506%" headers="mcps1.1.6.1.5 "><p id="p649017329613"><a name="p649017329613"></a><a name="p649017329613"></a>Default value of the text selector. The value is the index of <strong id="b121361525737"><a name="b121361525737"></a><a name="b121361525737"></a>range</strong>.</p> -</td> -</tr> -<tr id="row1045119531711"><td class="cellrowborder" valign="top" width="24.007599240075994%" headers="mcps1.1.6.1.1 "><p id="p54526530112"><a name="p54526530112"></a><a name="p54526530112"></a>indicatorprefix</p> -</td> -<td class="cellrowborder" valign="top" width="10.808919108089192%" headers="mcps1.1.6.1.2 "><p id="p24521553119"><a name="p24521553119"></a><a name="p24521553119"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.62913708629137%" headers="mcps1.1.6.1.3 "><p id="p14524531315"><a name="p14524531315"></a><a name="p14524531315"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.14928507149285%" headers="mcps1.1.6.1.4 "><p id="p134526535117"><a name="p134526535117"></a><a name="p134526535117"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.4050594940506%" headers="mcps1.1.6.1.5 "><p id="p114526534115"><a name="p114526534115"></a><a name="p114526534115"></a>Prefix field added when a value is specified for the text selector.</p> -</td> -</tr> -<tr id="row115191458171210"><td class="cellrowborder" valign="top" width="24.007599240075994%" headers="mcps1.1.6.1.1 "><p id="p2052015584123"><a name="p2052015584123"></a><a name="p2052015584123"></a>indicatorsuffix</p> -</td> -<td class="cellrowborder" valign="top" width="10.808919108089192%" headers="mcps1.1.6.1.2 "><p id="p0520458141213"><a name="p0520458141213"></a><a name="p0520458141213"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.62913708629137%" headers="mcps1.1.6.1.3 "><p id="p25201358191214"><a name="p25201358191214"></a><a name="p25201358191214"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.14928507149285%" headers="mcps1.1.6.1.4 "><p id="p952085813124"><a name="p952085813124"></a><a name="p952085813124"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.4050594940506%" headers="mcps1.1.6.1.5 "><p id="p175201958121212"><a name="p175201958121212"></a><a name="p175201958121212"></a>Suffix field added when a value is specified for the text selector.</p> -</td> -</tr> -</tbody> -</table> - -Time selector \(**type** is **time**\) - -<a name="table89366820719"></a> -<table><thead align="left"><tr id="row49367819714"><th class="cellrowborder" valign="top" width="24%" id="mcps1.1.6.1.1"><p id="p1493614815715"><a name="p1493614815715"></a><a name="p1493614815715"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="10.83%" id="mcps1.1.6.1.2"><p id="p2936881677"><a name="p2936881677"></a><a name="p2936881677"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="8.61%" id="mcps1.1.6.1.3"><p id="p79362815719"><a name="p79362815719"></a><a name="p79362815719"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.1499999999999995%" id="mcps1.1.6.1.4"><p id="p12936584719"><a name="p12936584719"></a><a name="p12936584719"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="49.41%" id="mcps1.1.6.1.5"><p id="p15936198876"><a name="p15936198876"></a><a name="p15936198876"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row2937108277"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.1.6.1.1 "><p id="p077212191171"><a name="p077212191171"></a><a name="p077212191171"></a>containsecond</p> -</td> -<td class="cellrowborder" valign="top" width="10.83%" headers="mcps1.1.6.1.2 "><p id="p1177214198714"><a name="p1177214198714"></a><a name="p1177214198714"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="8.61%" headers="mcps1.1.6.1.3 "><p id="p87721619275"><a name="p87721619275"></a><a name="p87721619275"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.1499999999999995%" headers="mcps1.1.6.1.4 "><p id="p127721919372"><a name="p127721919372"></a><a name="p127721919372"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.41%" headers="mcps1.1.6.1.5 "><p id="p13773101919719"><a name="p13773101919719"></a><a name="p13773101919719"></a>Whether seconds are contained.</p> -</td> -</tr> -<tr id="row1293719814712"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.1.6.1.1 "><p id="p577314191171"><a name="p577314191171"></a><a name="p577314191171"></a>selected</p> -</td> -<td class="cellrowborder" valign="top" width="10.83%" headers="mcps1.1.6.1.2 "><p id="p177735196711"><a name="p177735196711"></a><a name="p177735196711"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.61%" headers="mcps1.1.6.1.3 "><p id="p127734191714"><a name="p127734191714"></a><a name="p127734191714"></a><span id="ph61411732205214"><a name="ph61411732205214"></a><a name="ph61411732205214"></a>Current time</span></p> -</td> -<td class="cellrowborder" valign="top" width="7.1499999999999995%" headers="mcps1.1.6.1.4 "><p id="p16773151914716"><a name="p16773151914716"></a><a name="p16773151914716"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.41%" headers="mcps1.1.6.1.5 "><p id="p5241145091814"><a name="p5241145091814"></a><a name="p5241145091814"></a>Default value of the time selector, in the format of HH:mm.</p> -<p id="p57739191974"><a name="p57739191974"></a><a name="p57739191974"></a>If seconds are contained, the format is HH:mm:ss.</p> -</td> -</tr> -<tr id="row3976191332214"><td class="cellrowborder" valign="top" width="24%" headers="mcps1.1.6.1.1 "><p id="p095363112111"><a name="p095363112111"></a><a name="p095363112111"></a>hours</p> -</td> -<td class="cellrowborder" valign="top" width="10.83%" headers="mcps1.1.6.1.2 "><p id="p6953193114218"><a name="p6953193114218"></a><a name="p6953193114218"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="8.61%" headers="mcps1.1.6.1.3 "><p id="p16934121142417"><a name="p16934121142417"></a><a name="p16934121142417"></a>24<sup id="sup169341019245"><a name="sup169341019245"></a><a name="sup169341019245"></a>1-4</sup></p> -<p id="p81051142202817"><a name="p81051142202817"></a><a name="p81051142202817"></a>-<sup id="sup14229658122718"><a name="sup14229658122718"></a><a name="sup14229658122718"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="7.1499999999999995%" headers="mcps1.1.6.1.4 "><p id="p0953193112117"><a name="p0953193112117"></a><a name="p0953193112117"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.41%" headers="mcps1.1.6.1.5 "><p id="p1095393116216"><a name="p1095393116216"></a><a name="p1095393116216"></a>Time format used by the time selector. Available values include:</p> -<a name="ul11382144442112"></a><a name="ul11382144442112"></a><ul id="ul11382144442112"><li><strong id="b793617752019"><a name="b793617752019"></a><a name="b793617752019"></a>12</strong>: displayed in 12-hour format and distinguished by a.m. and p.m.</li><li><strong id="b273115197214"><a name="b273115197214"></a><a name="b273115197214"></a>24</strong>: displayed in 24-hour format<div class="note" id="note189471313104"><a name="note189471313104"></a><a name="note189471313104"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p9947193114104"><a name="p9947193114104"></a><a name="p9947193114104"></a>The default value is the most commonly-used hour format in the current locale. <sup id="sup319942110314"><a name="sup319942110314"></a><a name="sup319942110314"></a>5+</sup></p> -</div></div> -</li></ul> -</td> -</tr> -</tbody> -</table> - -Date selector \(**type** is **date**\) - -<a name="table174784493618"></a> -<table><thead align="left"><tr id="row54789491561"><th class="cellrowborder" valign="top" width="24.000000000000004%" id="mcps1.1.6.1.1"><p id="p14781849561"><a name="p14781849561"></a><a name="p14781849561"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="10.810000000000002%" id="mcps1.1.6.1.2"><p id="p447834912613"><a name="p447834912613"></a><a name="p447834912613"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="8.63%" id="mcps1.1.6.1.3"><p id="p12479749564"><a name="p12479749564"></a><a name="p12479749564"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.15%" id="mcps1.1.6.1.4"><p id="p13479749560"><a name="p13479749560"></a><a name="p13479749560"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="49.410000000000004%" id="mcps1.1.6.1.5"><p id="p247913495610"><a name="p247913495610"></a><a name="p247913495610"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row1047910498616"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p167682562062"><a name="p167682562062"></a><a name="p167682562062"></a>start</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p67689566612"><a name="p67689566612"></a><a name="p67689566612"></a><time></p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p1576817561266"><a name="p1576817561266"></a><a name="p1576817561266"></a>1970-1-1</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p476819561368"><a name="p476819561368"></a><a name="p476819561368"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p87681568618"><a name="p87681568618"></a><a name="p87681568618"></a>Start date of the date selector, in the format of YYYY-MM-DD.</p> -</td> -</tr> -<tr id="row3479549162"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p117686568615"><a name="p117686568615"></a><a name="p117686568615"></a>end</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p19768115614615"><a name="p19768115614615"></a><a name="p19768115614615"></a><time></p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p27686569618"><a name="p27686569618"></a><a name="p27686569618"></a>2100-12-31</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p1076912564617"><a name="p1076912564617"></a><a name="p1076912564617"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p1176915562611"><a name="p1176915562611"></a><a name="p1176915562611"></a>End date of the date selector, in the format of YYYY-MM-DD.</p> -</td> -</tr> -<tr id="row147919493619"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p20769056565"><a name="p20769056565"></a><a name="p20769056565"></a>selected</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p1376935613619"><a name="p1376935613619"></a><a name="p1376935613619"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p177694568616"><a name="p177694568616"></a><a name="p177694568616"></a>Current date</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p076925617611"><a name="p076925617611"></a><a name="p076925617611"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p17695564620"><a name="p17695564620"></a><a name="p17695564620"></a>Default value of the date selector, in the format of YYYY-MM-DD.</p> -</td> -</tr> -<tr id="row106371036261"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p2238125117139"><a name="p2238125117139"></a><a name="p2238125117139"></a>lunar<sup id="sup6301324133317"><a name="sup6301324133317"></a><a name="sup6301324133317"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p023825181319"><a name="p023825181319"></a><a name="p023825181319"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p18238115116134"><a name="p18238115116134"></a><a name="p18238115116134"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p0238851121311"><a name="p0238851121311"></a><a name="p0238851121311"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p14238195141316"><a name="p14238195141316"></a><a name="p14238195141316"></a>Whether the pop-up window displays the lunar calendar.</p> -</td> -</tr> -<tr id="row11239329191713"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p13816132171719"><a name="p13816132171719"></a><a name="p13816132171719"></a>lunarswitch</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p2081653261720"><a name="p2081653261720"></a><a name="p2081653261720"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p1816103221715"><a name="p1816103221715"></a><a name="p1816103221715"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p1181663281714"><a name="p1181663281714"></a><a name="p1181663281714"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p781663212178"><a name="p781663212178"></a><a name="p781663212178"></a>Whether to display the lunar calendar switch in the date selector. When this switch is displayed, you can switch between the lunar calendar and Gregorian calendar. Turn on the switch to display the lunar calendar, and turn off the switch to hide the lunar calendar. </p> -<div class="note" id="note1688512355211"><a name="note1688512355211"></a><a name="note1688512355211"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p488582345212"><a name="p488582345212"></a><a name="p488582345212"></a></p> -</div></div> -</td> -</tr> -</tbody> -</table> - -Date and time selector \(**type** is **datetime**\) - -<a name="table1188511392120"></a> -<table><thead align="left"><tr id="row16886193915128"><th class="cellrowborder" valign="top" width="24.000000000000004%" id="mcps1.1.6.1.1"><p id="p58868399129"><a name="p58868399129"></a><a name="p58868399129"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="10.810000000000002%" id="mcps1.1.6.1.2"><p id="p19886739161213"><a name="p19886739161213"></a><a name="p19886739161213"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="8.63%" id="mcps1.1.6.1.3"><p id="p138864393128"><a name="p138864393128"></a><a name="p138864393128"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.15%" id="mcps1.1.6.1.4"><p id="p288653914122"><a name="p288653914122"></a><a name="p288653914122"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="49.410000000000004%" id="mcps1.1.6.1.5"><p id="p1886193931212"><a name="p1886193931212"></a><a name="p1886193931212"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row288753919128"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p20887539141215"><a name="p20887539141215"></a><a name="p20887539141215"></a>selected</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p788753910126"><a name="p788753910126"></a><a name="p788753910126"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p16887539111214"><a name="p16887539111214"></a><a name="p16887539111214"></a>Current date and time</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p4887203911129"><a name="p4887203911129"></a><a name="p4887203911129"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p33848571013"><a name="p33848571013"></a><a name="p33848571013"></a>Default value of the date and time selector. The value can be in the format of MM-DD-HH-mm or YYYY-MM-DD-HH-mm. If the year is not set, the current year is used by default. The value you set is the date selected by default in the pop-up window.</p> -</td> -</tr> -<tr id="row25569188246"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p7249338141710"><a name="p7249338141710"></a><a name="p7249338141710"></a>hours</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p1814251913247"><a name="p1814251913247"></a><a name="p1814251913247"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p51424195244"><a name="p51424195244"></a><a name="p51424195244"></a>24<sup id="sup1626816180414"><a name="sup1626816180414"></a><a name="sup1626816180414"></a>1-4</sup></p> -<p id="p52731028173117"><a name="p52731028173117"></a><a name="p52731028173117"></a>-<sup id="sup627311285313"><a name="sup627311285313"></a><a name="sup627311285313"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p171426196242"><a name="p171426196242"></a><a name="p171426196242"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p1314251932418"><a name="p1314251932418"></a><a name="p1314251932418"></a>Time format used by the date and time selector. Available values include:</p> -<a name="ul15923173119204"></a><a name="ul15923173119204"></a><ul id="ul15923173119204"><li><strong id="b113902010491"><a name="b113902010491"></a><a name="b113902010491"></a>12</strong>: displayed in 12-hour format and distinguished by a.m. and p.m.</li><li><strong id="b930736675"><a name="b930736675"></a><a name="b930736675"></a>24</strong>: displayed in 24-hour format<div class="note" id="note1880145011113"><a name="note1880145011113"></a><a name="note1880145011113"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1988165031111"><a name="p1988165031111"></a><a name="p1988165031111"></a>The default value is the most commonly-used hour format in the current locale. <sup id="sup11183114910314"><a name="sup11183114910314"></a><a name="sup11183114910314"></a>5+</sup></p> -</div></div> -</li></ul> -</td> -</tr> -<tr id="row1742363212240"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p1820281519182"><a name="p1820281519182"></a><a name="p1820281519182"></a>lunar<sup id="sup370711541116"><a name="sup370711541116"></a><a name="sup370711541116"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p9202131571819"><a name="p9202131571819"></a><a name="p9202131571819"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p520313152182"><a name="p520313152182"></a><a name="p520313152182"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p142031715201812"><a name="p142031715201812"></a><a name="p142031715201812"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p16203181541812"><a name="p16203181541812"></a><a name="p16203181541812"></a>Whether the pop-up window displays the lunar calendar.</p> -</td> -</tr> -<tr id="row34576125180"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p120351520182"><a name="p120351520182"></a><a name="p120351520182"></a>lunarswitch</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p5203415171819"><a name="p5203415171819"></a><a name="p5203415171819"></a>boolean</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p120317151181"><a name="p120317151181"></a><a name="p120317151181"></a>false</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p16203115101819"><a name="p16203115101819"></a><a name="p16203115101819"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p12203111510184"><a name="p12203111510184"></a><a name="p12203111510184"></a>Whether to display the lunar calendar switch in the date and time selector. When this switch is displayed, you can switch between the lunar calendar and Gregorian calendar. Turn on the switch to display the lunar calendar, and turn off the switch to hide the lunar calendar. </p> -<div class="note" id="note11541837195218"><a name="note11541837195218"></a><a name="note11541837195218"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p454119371529"><a name="p454119371529"></a><a name="p454119371529"></a> -</div></div> -</td> -</tr> -</tbody> -</table> - -Multi-column text selector \(**type** is **multi-text**\) - -<a name="table1886619321772"></a> -<table><thead align="left"><tr id="row198671332179"><th class="cellrowborder" valign="top" width="24.000000000000004%" id="mcps1.1.6.1.1"><p id="p168677321871"><a name="p168677321871"></a><a name="p168677321871"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="10.810000000000002%" id="mcps1.1.6.1.2"><p id="p38670322711"><a name="p38670322711"></a><a name="p38670322711"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="8.63%" id="mcps1.1.6.1.3"><p id="p178670321276"><a name="p178670321276"></a><a name="p178670321276"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="7.15%" id="mcps1.1.6.1.4"><p id="p9867183215719"><a name="p9867183215719"></a><a name="p9867183215719"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="49.410000000000004%" id="mcps1.1.6.1.5"><p id="p168671324711"><a name="p168671324711"></a><a name="p168671324711"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row3757154961319"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p12757204951314"><a name="p12757204951314"></a><a name="p12757204951314"></a>columns</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p13757124918137"><a name="p13757124918137"></a><a name="p13757124918137"></a>number</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p0757144914132"><a name="p0757144914132"></a><a name="p0757144914132"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p14757149111317"><a name="p14757149111317"></a><a name="p14757149111317"></a>Yes</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p1675884931313"><a name="p1675884931313"></a><a name="p1675884931313"></a>Number of columns in the multi-column text selector.</p> -</td> -</tr> -<tr id="row3867103214710"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p793074416717"><a name="p793074416717"></a><a name="p793074416717"></a>range</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p793010441976"><a name="p793010441976"></a><a name="p793010441976"></a>Two-dimensional array</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p7930174418712"><a name="p7930174418712"></a><a name="p7930174418712"></a>-</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p2930444971"><a name="p2930444971"></a><a name="p2930444971"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p139301644675"><a name="p139301644675"></a><a name="p139301644675"></a>Items of the multi-column text selector. <strong id="b164211558164916"><a name="b164211558164916"></a><a name="b164211558164916"></a>range</strong> is a two-dimensional array that indicates the number of columns. Each item in the array indicates the data of each column, for example, <strong id="b1751216441149"><a name="b1751216441149"></a><a name="b1751216441149"></a>[["a","b"], ["c","d"]]</strong>.</p> -<div class="note" id="note112201642121219"><a name="note112201642121219"></a><a name="note112201642121219"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p8220114221212"><a name="p8220114221212"></a><a name="p8220114221212"></a>Use the data binding mode, for example, range = {{data}}. Declare the corresponding variable <strong id="b4470649201410"><a name="b4470649201410"></a><a name="b4470649201410"></a>data: [["a","b"], ["c","d"]]</strong> in the JavaScript.</p> -</div></div> -</td> -</tr> -<tr id="row18671332572"><td class="cellrowborder" valign="top" width="24.000000000000004%" headers="mcps1.1.6.1.1 "><p id="p693016441273"><a name="p693016441273"></a><a name="p693016441273"></a>selected</p> -</td> -<td class="cellrowborder" valign="top" width="10.810000000000002%" headers="mcps1.1.6.1.2 "><p id="p159306448720"><a name="p159306448720"></a><a name="p159306448720"></a>Array</p> -</td> -<td class="cellrowborder" valign="top" width="8.63%" headers="mcps1.1.6.1.3 "><p id="p18930544471"><a name="p18930544471"></a><a name="p18930544471"></a>0,0,0,...</p> -</td> -<td class="cellrowborder" valign="top" width="7.15%" headers="mcps1.1.6.1.4 "><p id="p69305448719"><a name="p69305448719"></a><a name="p69305448719"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="49.410000000000004%" headers="mcps1.1.6.1.5 "><p id="p12930144373"><a name="p12930144373"></a><a name="p12930144373"></a>Default value of the multi-column text selector, which is an array consisting of the indexes of the selected items in each column.</p> -</td> -</tr> -</tbody> -</table> - -## Styles<a name="section198061172344"></a> - -In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. - -<a name="table94919235408"></a> -<table><thead align="left"><tr id="row1349111237406"><th class="cellrowborder" valign="top" width="23.11768823117688%" id="mcps1.1.6.1.1"><p id="p13491122316409"><a name="p13491122316409"></a><a name="p13491122316409"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="20.477952204779523%" id="mcps1.1.6.1.2"><p id="p649192317408"><a name="p649192317408"></a><a name="p649192317408"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="10.47895210478952%" id="mcps1.1.6.1.3"><p id="p1849162384015"><a name="p1849162384015"></a><a name="p1849162384015"></a>Default Value</p> -</th> -<th class="cellrowborder" valign="top" width="5.909409059094091%" id="mcps1.1.6.1.4"><p id="p449162318408"><a name="p449162318408"></a><a name="p449162318408"></a>Mandatory</p> -</th> -<th class="cellrowborder" valign="top" width="40.01599840015999%" id="mcps1.1.6.1.5"><p id="p12491102344016"><a name="p12491102344016"></a><a name="p12491102344016"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row114923234409"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p1849262316408"><a name="p1849262316408"></a><a name="p1849262316408"></a>color</p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p1249252318405"><a name="p1249252318405"></a><a name="p1249252318405"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p9492162315401"><a name="p9492162315401"></a><a name="p9492162315401"></a>#ffffff</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p134923233404"><a name="p134923233404"></a><a name="p134923233404"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p84926239401"><a name="p84926239401"></a><a name="p84926239401"></a>Font color of a candidate item.</p> -</td> -</tr> -<tr id="row1249232316406"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p14492122354013"><a name="p14492122354013"></a><a name="p14492122354013"></a>font-size</p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p249222310403"><a name="p249222310403"></a><a name="p249222310403"></a><length></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p1149212231402"><a name="p1149212231402"></a><a name="p1149212231402"></a>16px</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p1849282317409"><a name="p1849282317409"></a><a name="p1849282317409"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p19492112316406"><a name="p19492112316406"></a><a name="p19492112316406"></a>Font size of a candidate item. The value is of the length type, in pixels.</p> -</td> -</tr> -<tr id="row1249262314017"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p54925236401"><a name="p54925236401"></a><a name="p54925236401"></a>selected-color</p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p449219234408"><a name="p449219234408"></a><a name="p449219234408"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p54924238408"><a name="p54924238408"></a><a name="p54924238408"></a>#ff0a69f7</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p949242334013"><a name="p949242334013"></a><a name="p949242334013"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p20492152334010"><a name="p20492152334010"></a><a name="p20492152334010"></a>Font color of the selected item.</p> -</td> -</tr> -<tr id="row10492423134013"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p174938237409"><a name="p174938237409"></a><a name="p174938237409"></a>selected-font-size</p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p9493182314010"><a name="p9493182314010"></a><a name="p9493182314010"></a><length></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p16493223104019"><a name="p16493223104019"></a><a name="p16493223104019"></a>20px</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p74931223124013"><a name="p74931223124013"></a><a name="p74931223124013"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p449342311407"><a name="p449342311407"></a><a name="p449342311407"></a>Font size of the selected item. The value is of the length type, in pixels.</p> -</td> -</tr> -<tr id="row84941623134017"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p104941323114011"><a name="p104941323114011"></a><a name="p104941323114011"></a>disappear-color<sup id="sup54941523144015"><a name="sup54941523144015"></a><a name="sup54941523144015"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p349412319400"><a name="p349412319400"></a><a name="p349412319400"></a><color></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p14942236409"><a name="p14942236409"></a><a name="p14942236409"></a>#ffffff</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p10494123164013"><a name="p10494123164013"></a><a name="p10494123164013"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p20494323144012"><a name="p20494323144012"></a><a name="p20494323144012"></a>Font color of the items that gradually disappear. Disappearing items are the top option and bottom option of a column containing five options in total.</p> -<div class="note" id="note682125718522"><a name="note682125718522"></a><a name="note682125718522"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p17821185711521"><a name="p17821185711521"></a><a name="p17821185711521"></a></p> -</div></div> -</td> -</tr> -<tr id="row1949432318405"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p1549419237407"><a name="p1549419237407"></a><a name="p1549419237407"></a>disappear-font-size<sup id="sup0494132313404"><a name="sup0494132313404"></a><a name="sup0494132313404"></a>5+</sup></p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p144940238404"><a name="p144940238404"></a><a name="p144940238404"></a><length></p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p64941023194020"><a name="p64941023194020"></a><a name="p64941023194020"></a>14px</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p1949522364020"><a name="p1949522364020"></a><a name="p1949522364020"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p1549532364020"><a name="p1549532364020"></a><a name="p1549532364020"></a>Font size of the items that gradually disappear. Disappearing items are the top option and bottom option of a column containing five options in total.</p> -<div class="note" id="note17211975317"><a name="note17211975317"></a><a name="note17211975317"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1821895535"><a name="p1821895535"></a><a name="p1821895535"></a></p> -</div></div> -</td> -</tr> -<tr id="row19495152311405"><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p id="p154951237400"><a name="p154951237400"></a><a name="p154951237400"></a>font-family</p> -</td> -<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p id="p3495192316402"><a name="p3495192316402"></a><a name="p3495192316402"></a>string</p> -</td> -<td class="cellrowborder" valign="top" width="10.47895210478952%" headers="mcps1.1.6.1.3 "><p id="p8495172324010"><a name="p8495172324010"></a><a name="p8495172324010"></a>sans-serif</p> -</td> -<td class="cellrowborder" valign="top" width="5.909409059094091%" headers="mcps1.1.6.1.4 "><p id="p134951723154010"><a name="p134951723154010"></a><a name="p134951723154010"></a>No</p> -</td> -<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p id="p124957233408"><a name="p124957233408"></a><a name="p124957233408"></a>Font type of an item. Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the font specified by <a href="js-components-common-customizing-font.md">Custom Font Styles</a> is used for the text</p> -</td> -</tr> -</tbody> -</table> - -## Events<a name="section103398253399"></a> + +## Attributes + +In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported. + +| Name | Type | Default Value | Mandatory | Description | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| type | string | text | No | Type of the scrollable selector, which cannot be changed dynamically. Available values are as follows:<br>- **text**: text selector.<br>- **time**: time selector.<br>- **date**: date selector.<br>- **datetime**: date and time selector.<br>- **multi-text**: multi-column text selector.| + +Text selector (**type** is **text**) + +| Name | Type | Default Value | Mandatory | Description | +| --------------- | ------ | ---- | ---- | ---------------------------------------- | +| range | Array | - | No | Value range of the text selector.<br>Use the data binding mode, for example, `range = {{data}}`. Declare the corresponding variable `data: ["15", "20", "25"]` in JavaScript.| +| selected | string | 0 | No | Default value of the text selector. The value is the index of **range**. | +| indicatorprefix | string | - | No | Prefix field added when a value is specified for the text selector. | +| indicatorsuffix | string | - | No | Suffix field added when a value is specified for the text selector. | + +Time selector (**type** is **time**) + +| Name | Type | Default Value | Mandatory | Description | +| ------------- | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| containsecond | boolean | false | No | Whether seconds are contained. | +| selected | string | Current time | No | Default value of the time selector, in the format of HH:mm.<br>If seconds are contained, the format is HH:mm:ss.| +| hours | number | 24<sup>1-4</sup> | No | Time format used by the time selector. Available values are as follows:<br>- **12**: displayed in 12-hour format and distinguished by a.m. and p.m.<br>- **24**: displayed in 24-hour format.<br>Since API version 5, the default value is the most commonly-used hour format in the current locale.| + +Date selector (**type** is **date**) + +| Name | Type | Default Value | Mandatory | Description | +| ------------------ | ------------ | ---------- | ---- | ---------------------------------------- | +| start | <time> | 1970-1-1 | No | Start date of the date selector, in the format of YYYY-MM-DD. | +| end | <time> | 2100-12-31 | No | End date of the date selector, in the format of YYYY-MM-DD. | +| selected | string | Current date | No | Default value of the date selector, in the format of YYYY-MM-DD. | +| lunar<sup>5+</sup> | boolean | false | No | Whether the pop-up window displays the lunar calendar. | +| lunarswitch | boolean | false | No | Whether to display the lunar calendar switch in the date selector. When this switch is displayed, the user can switch between the lunar calendar and Gregorian calendar. Turn on the switch to display the lunar calendar, and turn off the switch to hide the lunar calendar.| + +Date and time selector (**type** is **datetime**) + +| Name | Type | Default Value | Mandatory | Description | +| ------------------ | ------- | ----------------------------------- | ---- | ---------------------------------------- | +| selected | string | Current date and time | No | Default value of the date and time selector. The value can be in the format of MM-DD-HH-mm or YYYY-MM-DD-HH-mm. If the year is not set, the current year is used by default. The value you set is the date selected by default in the pop-up window.| +| hours | number | 24<sup>1-4</sup> | No | Time format used by the date and time selector. Available values are as follows:<br>- **12**: displayed in 12-hour format and distinguished by a.m. and p.m.<br>- **24**: displayed in 24-hour format.<br>Since API version 5, the default value is the most commonly-used hour format in the current locale.| +| lunar<sup>5+</sup> | boolean | false | No | Whether the pop-up window displays the lunar calendar. | +| lunarswitch | boolean | false | No | Whether to display the lunar calendar switch in the date and time selector. When this switch is displayed, the user can switch between the lunar calendar and Gregorian calendar. Turn on the switch to display the lunar calendar, and turn off the switch to hide the lunar calendar.| + +Multi-column text selector (**type** is **multi-text**) + +| Name | Type | Default Value | Mandatory | Description | +| -------- | ------- | --------- | ---- | ---------------------------------------- | +| columns | number | - | Yes | Number of columns in the multi-column text selector. | +| range | Two-dimensional array| - | No | Items of the multi-column text selector. The value is a two-dimensional array that indicates the number of columns. Each item in the array indicates the data of each column, for example, **[["a", "b"], ["c", "d"]]**.<br>Use the data binding mode, for example, `range = {{data}}`. Declare the corresponding variable `data: ["15", "20", "25"]` in JavaScript.| +| selected | Array | [0,0,0,…]| No | Default value of the multi-column text selector, which is an array consisting of the indexes of the selected items in each column.| + + +## Styles + +In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported. + +| Name | Type | Default Value | Mandatory | Description | +| -------------------------------- | -------------- | ---------- | ---- | ---------------------------------------- | +| color | <color> | \#ffffff | No | Font color of a candidate item. | +| font-size | <length> | 16px | No | Font size of a candidate item. The value is of the length type, in pixels. | +| selected-color | <color> | #ff0a69f7 | No | Font color of the selected item. | +| selected-font-size | <length> | 20px | No | Font size of the selected item. The value is of the length type, in pixels. | +| disappear-color<sup>5+</sup> | <color> | \#ffffff | No | Font color of the items that gradually disappear. Disappearing items are the top option and bottom option of a column containing five options in total. | +| disappear-font-size<sup>5+</sup> | <length> | 14px | No | Font size of the items that gradually disappear. Disappearing items are the top option and bottom option of a column containing five options in total. | +| font-family | string | sans-serif | No | Font family of the selector, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](../arkui-js/js-components-common-customizing-font.md) is used for the text.| + + +## Events The following events are supported. -Text selector \(**type** is **text**\) - -<a name="table17339225123915"></a> -<table><thead align="left"><tr id="row1339925143920"><th class="cellrowborder" valign="top" width="16.16161616161616%" id="mcps1.1.4.1.1"><p id="p8340925103911"><a name="p8340925103911"></a><a name="p8340925103911"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="41.41414141414141%" id="mcps1.1.4.1.2"><p id="p2340325113912"><a name="p2340325113912"></a><a name="p2340325113912"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="42.42424242424242%" id="mcps1.1.4.1.3"><p id="p1534013255394"><a name="p1534013255394"></a><a name="p1534013255394"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row15340192543910"><td class="cellrowborder" valign="top" width="16.16161616161616%" headers="mcps1.1.4.1.1 "><p id="p334016258395"><a name="p334016258395"></a><a name="p334016258395"></a>change</p> -</td> -<td class="cellrowborder" valign="top" width="41.41414141414141%" headers="mcps1.1.4.1.2 "><p id="p93401725183918"><a name="p93401725183918"></a><a name="p93401725183918"></a>{ newValue: newValue, newSelected: newSelected }</p> -</td> -<td class="cellrowborder" valign="top" width="42.42424242424242%" headers="mcps1.1.4.1.3 "><p id="p17340122515397"><a name="p17340122515397"></a><a name="p17340122515397"></a>Triggered when a value is specified for the text selector.</p> -</td> -</tr> -</tbody> -</table> - -Time selector \(**type** is **time**\) - -<a name="table13340325133918"></a> -<table><thead align="left"><tr id="row20340125143918"><th class="cellrowborder" valign="top" width="16.16161616161616%" id="mcps1.1.4.1.1"><p id="p14340152533917"><a name="p14340152533917"></a><a name="p14340152533917"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="41.41414141414141%" id="mcps1.1.4.1.2"><p id="p1634082553920"><a name="p1634082553920"></a><a name="p1634082553920"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="42.42424242424242%" id="mcps1.1.4.1.3"><p id="p134072523914"><a name="p134072523914"></a><a name="p134072523914"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row1434032553920"><td class="cellrowborder" valign="top" width="16.16161616161616%" headers="mcps1.1.4.1.1 "><p id="p3341625183910"><a name="p3341625183910"></a><a name="p3341625183910"></a>change</p> -</td> -<td class="cellrowborder" valign="top" width="41.41414141414141%" headers="mcps1.1.4.1.2 "><p id="p1634122513911"><a name="p1634122513911"></a><a name="p1634122513911"></a>{ hour: hour, minute: minute<span id="ph734120255396"><a name="ph734120255396"></a><a name="ph734120255396"></a>, [second:second] </span>}</p> -</td> -<td class="cellrowborder" valign="top" width="42.42424242424242%" headers="mcps1.1.4.1.3 "><p id="p4341225133916"><a name="p4341225133916"></a><a name="p4341225133916"></a>Triggered when a value is specified for the time selector.</p> -<p id="p1341192514397"><a name="p1341192514397"></a><a name="p1341192514397"></a>If seconds are contained, the value contains hour, minute, and second.</p> -</td> -</tr> -</tbody> -</table> - -Date selector \(**type** is **date**\) - -<a name="table103414254397"></a> -<table><thead align="left"><tr id="row234142553912"><th class="cellrowborder" valign="top" width="15.370000000000001%" id="mcps1.1.4.1.1"><p id="p7341125153916"><a name="p7341125153916"></a><a name="p7341125153916"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="34.22%" id="mcps1.1.4.1.2"><p id="p1834182593915"><a name="p1834182593915"></a><a name="p1834182593915"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="50.41%" id="mcps1.1.4.1.3"><p id="p5341142593910"><a name="p5341142593910"></a><a name="p5341142593910"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row83411325103912"><td class="cellrowborder" valign="top" width="15.370000000000001%" headers="mcps1.1.4.1.1 "><p id="p6341122553914"><a name="p6341122553914"></a><a name="p6341122553914"></a>change</p> -</td> -<td class="cellrowborder" valign="top" width="34.22%" headers="mcps1.1.4.1.2 "><p id="p17341192563911"><a name="p17341192563911"></a><a name="p17341192563911"></a>{ year:year, month:month, day:day }</p> -</td> -<td class="cellrowborder" valign="top" width="50.41%" headers="mcps1.1.4.1.3 "><p id="p103419259392"><a name="p103419259392"></a><a name="p103419259392"></a>Triggered when a value is specified for the date selector.</p> -</td> -</tr> -</tbody> -</table> - -Date and time selector \(**type** is **datetime**\) - -<a name="table6342192514395"></a> -<table><thead align="left"><tr id="row43421725183919"><th class="cellrowborder" valign="top" width="15.370000000000001%" id="mcps1.1.4.1.1"><p id="p17342325173911"><a name="p17342325173911"></a><a name="p17342325173911"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="34.22%" id="mcps1.1.4.1.2"><p id="p63421825113915"><a name="p63421825113915"></a><a name="p63421825113915"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="50.41%" id="mcps1.1.4.1.3"><p id="p634217257395"><a name="p634217257395"></a><a name="p634217257395"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row1234216257392"><td class="cellrowborder" valign="top" width="15.370000000000001%" headers="mcps1.1.4.1.1 "><p id="p5342725203916"><a name="p5342725203916"></a><a name="p5342725203916"></a>change</p> -</td> -<td class="cellrowborder" valign="top" width="34.22%" headers="mcps1.1.4.1.2 "><p id="p20342132512395"><a name="p20342132512395"></a><a name="p20342132512395"></a>{ year:year, month:month, day:day, hour:hour, minute:minute }</p> -</td> -<td class="cellrowborder" valign="top" width="50.41%" headers="mcps1.1.4.1.3 "><p id="p11342102563910"><a name="p11342102563910"></a><a name="p11342102563910"></a>Triggered when a value is specified for the date and time selector.</p> -</td> -</tr> -</tbody> -</table> - -Multi-text selector \(**type** is **multi-text**\) - -<a name="table5342325203913"></a> -<table><thead align="left"><tr id="row153422255390"><th class="cellrowborder" valign="top" width="13.969999999999999%" id="mcps1.1.4.1.1"><p id="p153431725153916"><a name="p153431725153916"></a><a name="p153431725153916"></a>Name</p> -</th> -<th class="cellrowborder" valign="top" width="36.9%" id="mcps1.1.4.1.2"><p id="p11343102523916"><a name="p11343102523916"></a><a name="p11343102523916"></a>Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="49.13%" id="mcps1.1.4.1.3"><p id="p16343925193913"><a name="p16343925193913"></a><a name="p16343925193913"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row103430256392"><td class="cellrowborder" valign="top" width="13.969999999999999%" headers="mcps1.1.4.1.1 "><p id="p19343122514399"><a name="p19343122514399"></a><a name="p19343122514399"></a>columnchange</p> -</td> -<td class="cellrowborder" valign="top" width="36.9%" headers="mcps1.1.4.1.2 "><p id="p12343102573913"><a name="p12343102573913"></a><a name="p12343102573913"></a>{ column:column, newValue:newValue, newSelected:newSelected }</p> -</td> -<td class="cellrowborder" valign="top" width="49.13%" headers="mcps1.1.4.1.3 "><p id="p1534352593917"><a name="p1534352593917"></a><a name="p1534352593917"></a>Triggered when the value of a column in the multi-column selector changes. <strong id="b3821122445914"><a name="b3821122445914"></a><a name="b3821122445914"></a>column</strong> indicates the column whose value has changed, <strong id="b15827124135915"><a name="b15827124135915"></a><a name="b15827124135915"></a>newValue</strong> indicates the selected value, and <strong id="b782722495913"><a name="b782722495913"></a><a name="b782722495913"></a>newSelected</strong> indicates the index of the selected value.</p> -</td> -</tr> -</tbody> -</table> - -## Methods<a name="section718304515396"></a> +Text selector (**type** is **text**) + +| Name | Parameter | Description | +| ------ | ---------------------------------------- | --------------- | +| change | { newValue: newValue, newSelected: newSelected } | Triggered when a value is specified for the text selector.| + +Time selector (**type** is **time**) + +| Name | Parameter | Description | +| ------ | ---------------------------------------- | ------------------------------- | +| change | { hour: hour, minute: minute, [second:second]} | Triggered when a value is specified for the time selector.<br>If seconds are contained, the value contains hour, minute, and second.| + +Date selector (**type** is **date**) + +| Name | Parameter | Description | +| ------ | ---------------------------------------- | --------------- | +| change | { year:year, month:month, day:day } | Triggered when a value is specified for the date selector.| + +Date and time selector (**type** is **datetime**) + +| Name | Parameter | Description | +| ------ | ---------------------------------------- | ----------------- | +| change | { year:year, month:month, day:day, hour:hour, minute:minute } | Triggered when a value is specified for the date and time selector.| + +Multi-text selector (**type** is **multi-text**) + +| Name | Parameter | Description | +| ------------ | ---------------------------------------- | ---------------------------------------- | +| columnchange | { column:column, newValue:newValue, newSelected:newSelected } | Triggered when the value of a column in the multi-column selector changes. <br>**column**: column whose value has changed. <br>**newValue**: selected value. <br>**newSelected**: index of the selected value.| + + +## Methods Not supported -## Example Code<a name="section738534695417"></a> -``` +## Example + +```html <!-- xxx.hml --> <div class="container" @swipe="handleSwipe"> <text class="title"> @@ -581,7 +132,7 @@ Not supported </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -603,7 +154,7 @@ Not supported } ``` -``` +```js /* xxx.js */ export default { data: { @@ -633,5 +184,4 @@ export default { } ``` - - + diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 6b9270ec688ba6470e5bcde047ea964c15b209bb..a487890669ef23b80304bf82afff664a2008da05 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -1,133 +1,138 @@ # TypeScript-based Declarative Development Paradigm -- Components - - Universal Components - - Universal Events - - [Click Event](ts-universal-events-click.md) - - [Touch Event](ts-universal-events-touch.md) - - [Show/Hide Event](ts-universal-events-show-hide.md) - - [Drag/Drop Event](ts-universal-events-drag-drop.md) - - [Key Event](ts-universal-events-key.md) - - [Focus Event](ts-universal-focus-event.md) - - [Mouse Event](ts-universal-mouse-key.md) - - [Component Area Change Event](ts-universal-component-area-change-event.md) - - Universal Attributes - - [Size](ts-universal-attributes-size.md) - - [Location](ts-universal-attributes-location.md) - - [Layout Constraints](ts-universal-attributes-layout-constraints.md) - - [Flex Layout](ts-universal-attributes-flex-layout.md) - - [Border](ts-universal-attributes-border.md) - - [Background](ts-universal-attributes-background.md) - - [Opacity](ts-universal-attributes-opacity.md) - - [Visibility](ts-universal-attributes-visibility.md) - - [Enable/Disable](ts-universal-attributes-enable.md) - - [Overlay](ts-universal-attributes-overlay.md) - - [Z-order Control](ts-universal-attributes-z-order.md) - - [Transformation](ts-universal-attributes-transformation.md) - - [Image Effect Configuration](ts-universal-attributes-image-effect.md) - - [Shape Clipping](ts-universal-attributes-sharp-clipping.md) - - [Text Style](ts-universal-attributes-text-style.md) - - [Grid](ts-universal-attributes-grid.md) - - [Gradient Color](ts-universal-attributes-gradient-color.md) - - [Popup Control](ts-universal-attributes-popup.md) - - [Menu Control](ts-universal-attributes-menu.md) - - [Click Control](ts-universal-attributes-click.md) - - [Focus Control](ts-universal-attributes-focus.md) - - [Hover Effect](ts-universal-attributes-hover-effect.md) - - [Component ID](ts-universal-attributes-component-id.md) - - [Touch Target](ts-universal-attributes-touch-target.md) - - [Polymorphic Style](ts-universal-attributes-polymorphic-style.md) - - Gesture Processing - - [Gesture Binding Methods](ts-gesture-settings.md) - - Basic Gestures - - [TapGesture](ts-basic-gestures-tapgesture.md) - - [LongPressGesture](ts-basic-gestures-longpressgesture.md) - - [PanGesture](ts-basic-gestures-pangesture.md) - - [PinchGesture](ts-basic-gestures-pinchgesture.md) - - [RotationGesture](ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](ts-basic-gestures-swipegesture.md) - - [Combined Gestures](ts-combined-gestures.md) - - Basic Components - - [Blank](ts-basic-components-blank.md) - - [Button](ts-basic-components-button.md) - - [Checkbox](ts-basic-components-checkbox.md) - - [CheckboxGroup](ts-basic-components-checkboxgroup.md) - - [DataPanel](ts-basic-components-datapanel.md) - - [DatePicker](ts-basic-components-datepicker.md) - - [Divider](ts-basic-components-divider.md) - - [Gauge](ts-basic-components-gauge.md) - - [Image](ts-basic-components-image.md) - - [ImageAnimator](ts-basic-components-imageanimator.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) - - [Marquee](ts-basic-components-marquee.md) - - [Navigation](ts-basic-components-navigation.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - - [Progress](ts-basic-components-progress.md) - - [QRCode](ts-basic-components-qrcode.md) - - [Radio](ts-basic-components-radio.md) - - [Rating](ts-basic-components-rating.md) - - [RichText](ts-basic-components-richtext.md) - - [ScrollBar](ts-basic-components-scrollbar.md) - - [Search](ts-basic-components-search.md) - - [Select](ts-basic-components-select.md) - - [Slider](ts-basic-components-slider.md) - - [Span](ts-basic-components-span.md) - - [Stepper](ts-basic-components-stepper.md) - - [StepperItem](ts-basic-components-stepperitem.md) - - [Text](ts-basic-components-text.md) - - [TextArea](ts-basic-components-textarea.md) - - [TextClock](ts-basic-components-textclock.md) - - [TextInput](ts-basic-components-textinput.md) - - [TextPicker](ts-basic-components-textpicker.md) - - [TextTimer](ts-basic-components-texttimer.md) - - [TimePicker](ts-basic-components-timepicker.md) - - [Toggle](ts-basic-components-toggle.md) - - [Web](ts-basic-components-web.md) - - [XComponent](ts-basic-components-xcomponent.md) - - Container Components - - [AlphabetIndexer](ts-container-alphabet-indexer.md) - - [Badge](ts-container-badge.md) - - [Column](ts-container-column.md) - - [ColumnSplit](ts-container-columnsplit.md) - - [Counter](ts-container-counter.md) - - [Flex](ts-container-flex.md) - - [GridContainer](ts-container-gridcontainer.md) - - [Grid](ts-container-grid.md) - - [GridItem](ts-container-griditem.md) - - [List](ts-container-list.md) - - [ListItem](ts-container-listitem.md) - - [Navigator](ts-container-navigator.md) - - [Panel](ts-container-panel.md) - - [Refresh](ts-container-refresh.md) - - [Row](ts-container-row.md) - - [RowSplit](ts-container-rowsplit.md) - - [Scroll](ts-container-scroll.md) - - [SideBarContainer](ts-container-sidebarcontainer.md) - - [Stack](ts-container-stack.md) - - [Swiper](ts-container-swiper.md) - - [Tabs](ts-container-tabs.md) - - [TabContent](ts-container-tabcontent.md) - - Media Components - - [Video](ts-media-components-video.md) - - Drawing Components - - [Circle](ts-drawing-components-circle.md) - - [Ellipse](ts-drawing-components-ellipse.md) - - [Line](ts-drawing-components-line.md) - - [Polyline](ts-drawing-components-polyline.md) - - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) - - [Rect](ts-drawing-components-rect.md) - - [Shape](ts-drawing-components-shape.md) - - Canvas Components - - [Canvas](ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](ts-components-canvas-lottie.md) - - [Path2D](ts-components-canvas-path2d.md) - - [CanvasGradient](ts-components-canvas-canvasgradient.md) - - [ImageBitmap](ts-components-canvas-imagebitmap.md) - - [ImageData](ts-components-canvas-imagedata.md) +- Universal Component Information + - Universal Events + - [Click Event](ts-universal-events-click.md) + - [Touch Event](ts-universal-events-touch.md) + - [Show/Hide Event](ts-universal-events-show-hide.md) + - [Drag/Drop Event](ts-universal-events-drag-drop.md) + - [Key Event](ts-universal-events-key.md) + - [Focus Event](ts-universal-focus-event.md) + - [Mouse Event](ts-universal-mouse-key.md) + - [Component Area Change Event](ts-universal-component-area-change-event.md) + - [Visible Area Change Event](ts-universal-component-visible-area-change-event.md) + - Universal Attributes + - [Size](ts-universal-attributes-size.md) + - [Location](ts-universal-attributes-location.md) + - [Layout Constraints](ts-universal-attributes-layout-constraints.md) + - [Flex Layout](ts-universal-attributes-flex-layout.md) + - [Border](ts-universal-attributes-border.md) + - [Border Image](ts-universal-attributes-border-image.md) + - [Background](ts-universal-attributes-background.md) + - [Opacity](ts-universal-attributes-opacity.md) + - [Visibility](ts-universal-attributes-visibility.md) + - [Enable/Disable](ts-universal-attributes-enable.md) + - [Overlay](ts-universal-attributes-overlay.md) + - [Z-order Control](ts-universal-attributes-z-order.md) + - [Transformation](ts-universal-attributes-transformation.md) + - [Image Effect Configuration](ts-universal-attributes-image-effect.md) + - [Shape Clipping](ts-universal-attributes-sharp-clipping.md) + - [Text Style](ts-universal-attributes-text-style.md) + - [Grid](ts-universal-attributes-grid.md) + - [Gradient Color](ts-universal-attributes-gradient-color.md) + - [Popup Control](ts-universal-attributes-popup.md) + - [Menu Control](ts-universal-attributes-menu.md) + - [Click Control](ts-universal-attributes-click.md) + - [Focus Control](ts-universal-attributes-focus.md) + - [Hover Effect](ts-universal-attributes-hover-effect.md) + - [Component ID](ts-universal-attributes-component-id.md) + - [Touch Target](ts-universal-attributes-touch-target.md) + - [Polymorphic Style](ts-universal-attributes-polymorphic-style.md) + - Gesture Processing + - [Gesture Binding Methods](ts-gesture-settings.md) + - Basic Gestures + - [TapGesture](ts-basic-gestures-tapgesture.md) + - [LongPressGesture](ts-basic-gestures-longpressgesture.md) + - [PanGesture](ts-basic-gestures-pangesture.md) + - [PinchGesture](ts-basic-gestures-pinchgesture.md) + - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) + - [Combined Gestures](ts-combined-gestures.md) +- Basic Components + - [Blank](ts-basic-components-blank.md) + - [Button](ts-basic-components-button.md) + - [Checkbox](ts-basic-components-checkbox.md) + - [CheckboxGroup](ts-basic-components-checkboxgroup.md) + - [DataPanel](ts-basic-components-datapanel.md) + - [DatePicker](ts-basic-components-datepicker.md) + - [Divider](ts-basic-components-divider.md) + - [Gauge](ts-basic-components-gauge.md) + - [Image](ts-basic-components-image.md) + - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Marquee](ts-basic-components-marquee.md) + - [Navigation](ts-basic-components-navigation.md) + - [PatternLock](ts-basic-components-patternlock.md) + - [PluginComponent](ts-basic-components-plugincomponent.md) + - [Progress](ts-basic-components-progress.md) + - [QRCode](ts-basic-components-qrcode.md) + - [Radio](ts-basic-components-radio.md) + - [Rating](ts-basic-components-rating.md) + - [RemoteWindow](ts-basic-components-remotewindow.md) + - [RichText](ts-basic-components-richtext.md) + - [ScrollBar](ts-basic-components-scrollbar.md) + - [Search](ts-basic-components-search.md) + - [Select](ts-basic-components-select.md) + - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) + - [Stepper](ts-basic-components-stepper.md) + - [StepperItem](ts-basic-components-stepperitem.md) + - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextClock](ts-basic-components-textclock.md) + - [TextInput](ts-basic-components-textinput.md) + - [TextPicker](ts-basic-components-textpicker.md) + - [TextTimer](ts-basic-components-texttimer.md) + - [TimePicker](ts-basic-components-timepicker.md) + - [Toggle](ts-basic-components-toggle.md) + - [Web](ts-basic-components-web.md) + - [XComponent](ts-basic-components-xcomponent.md) +- Container Components + - [AbilityComponent](ts-container-ability-component.md) + - [AlphabetIndexer](ts-container-alphabet-indexer.md) + - [Badge](ts-container-badge.md) + - [Column](ts-container-column.md) + - [ColumnSplit](ts-container-columnsplit.md) + - [Counter](ts-container-counter.md) + - [Flex](ts-container-flex.md) + - [GridContainer](ts-container-gridcontainer.md) + - [Grid](ts-container-grid.md) + - [GridItem](ts-container-griditem.md) + - [List](ts-container-list.md) + - [ListItem](ts-container-listitem.md) + - [Navigator](ts-container-navigator.md) + - [Panel](ts-container-panel.md) + - [Refresh](ts-container-refresh.md) + - [RelativeContainer](ts-container-relativecontainer.md) + - [Row](ts-container-row.md) + - [RowSplit](ts-container-rowsplit.md) + - [Scroll](ts-container-scroll.md) + - [SideBarContainer](ts-container-sidebarcontainer.md) + - [Stack](ts-container-stack.md) + - [Swiper](ts-container-swiper.md) + - [Tabs](ts-container-tabs.md) + - [TabContent](ts-container-tabcontent.md) +- Media Components + + - [Video](ts-media-components-video.md) +- Drawing Components + - [Circle](ts-drawing-components-circle.md) + - [Ellipse](ts-drawing-components-ellipse.md) + - [Line](ts-drawing-components-line.md) + - [Polyline](ts-drawing-components-polyline.md) + - [Polygon](ts-drawing-components-polygon.md) + - [Path](ts-drawing-components-path.md) + - [Rect](ts-drawing-components-rect.md) + - [Shape](ts-drawing-components-shape.md) +- Canvas Components + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](ts-components-canvas-lottie.md) + - [Path2D](ts-components-canvas-path2d.md) + - [CanvasGradient](ts-components-canvas-canvasgradient.md) + - [ImageBitmap](ts-components-canvas-imagebitmap.md) + - [ImageData](ts-components-canvas-imagedata.md) - Animation - [AnimatorProperty](ts-animatorproperty.md) - [Explicit Animation](ts-explicit-animation.md) diff --git a/en/application-dev/reference/arkui-ts/figures/borderImageGradient.png b/en/application-dev/reference/arkui-ts/figures/borderImageGradient.png new file mode 100644 index 0000000000000000000000000000000000000000..edf91d4844deeee4f997f65d2d88b45bf7ff7f1d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/borderImageGradient.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif index 52fed39eeae057043dbd00abce9ff29d2c35a56a..15849e6bc210ed2bb7f7a798b145c9794972643c 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193499234.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_visible_area_change.gif b/en/application-dev/reference/arkui-ts/figures/en-us_visible_area_change.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b82bc987ff6d8bbe42f00e73148b35c445fa8c8 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_visible_area_change.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/relativecontainer.png b/en/application-dev/reference/arkui-ts/figures/relativecontainer.png new file mode 100644 index 0000000000000000000000000000000000000000..ebe9c3c7f6ba5ba6756b61f757894cc3f69014bf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/relativecontainer.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md index 3eeec830107e6896a2bb07ba4cdb0a31028ecae6..af6866db3835823c394d536f5f0b5efcb4213c22 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -6,7 +6,7 @@ > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **<Blank>** component supports automatic filling of the empty part of the container along the main axis. This component is valid only when the parent component is **<Row>** or **<Column>**. +The **\<Blank>** component supports automatic filling of the empty part of the container along the main axis. This component is valid only when the parent component is **\<Row>** or **\<Column>**. ## Required Permissions @@ -24,7 +24,7 @@ Not supported Blank(min?: Length) - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | | min | Length | No | 0 | Minimum size of the **<Blank>** component in the container along the main axis. | @@ -33,9 +33,10 @@ Blank(min?: Length) | Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| color | Color | 0x00000000 | Color to fill the blank. | +| color | [ResourceColor](../../ui/ts-types.md) | 0x00000000 | Color to fill the blank. | -> **NOTE**<br> +> **NOTE** +> > Universal attribute methods are not supported. diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md index 42ac10339280af072effe49c7850c0a5fc1087d3..5f7d75d5406fd705e5a0716ff9d94fd3dd73de22 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -1,13 +1,12 @@ # Button +The **\<Button>** component can be used to create different types of buttons. -> **NOTE**<br> +> **NOTE** +> > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **<Button>** component represents a component that can trigger actions. - - ## Required Permissions None @@ -30,15 +29,15 @@ Supported | stateEffect | boolean | No | true | Whether to enable the state switchover effect when a button is pressed. When the state is set to **false**, the state switchover effect is disabled. | -- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean }) +- Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean }) - Creates a button component based on text content. In this case, the **<Button>** component cannot contain child components. + Creates a button component based on text content. In this case, the **\<Button>** component cannot contain child components. - **Table 2** value parameters + **Table 2** Parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | label | string | No | - | Button text. | + | label | [ResourceStr](../../ui/ts-types.md) | No | - | Button text. | | options | Object | No | - | For details, see the **options** parameters. | @@ -54,8 +53,8 @@ Supported | Name | Description | | -------- | -------- | | Capsule | Capsule-type button (the round corner is half of the height by default). | -| Circle | Circle button. | -| Normal | Normal button (without rounded corners by default). | +| Circle | Circle button. | +| Normal | Normal button (without rounded corners by default). | > **NOTE** > - The rounded corner of a button is set by using [Border](ts-universal-attributes-border.md). (The rounded corner cannot be set by using a border API.) @@ -67,7 +66,8 @@ Supported ## Example -``` +```ts +// xxx.ets @Entry @Component struct ButtonExample { @@ -78,6 +78,7 @@ struct ButtonExample { Button('Ok', { type: ButtonType.Normal, stateEffect: true }).borderRadius(8).backgroundColor(0x317aff).width(90) Button({ type: ButtonType.Normal, stateEffect: true }) { Row() { + // You are advised to reference an image by using $r to create a Resource object. Image($r('app.media.loading')).width(20).height(20).margin({ left: 12 }) Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 }) }.alignItems(VerticalAlign.Center) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md index 88231686024e14774633850d6707b8c5c3e77080..d506add310a3c52839d8f688d9493cace324c7c5 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -1,83 +1,101 @@ # Image +The **\<Image>** component is used to render and display local and online images. -> **NOTE**<br> +> **NOTE** +> > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **<Image>** component is used to render and display images. - - ## Required Permissions -ohos.permission.INTERNET (using Internet images) +To use online images, you need to add the **ohos.permission.INTERNET** permission to the corresponding abilities in the **config.json** (for the FA model) or **module.json5** file (for the stage model). + +``` +"abilities": [ + { + ... + "permissions": ["ohos.permission.INTERNET"], + ... + } +] +``` ## Child Components -None +Not supported ## APIs -Image(value: {uri: string | PixelMap}) +Image(src: string | PixelMap | Resource) -- Parameters - | Name | Type | Mandatory | Default Value | Description | - | -------- | -------- | -------- | -------- | -------- | - | uri | string | Yes | - | Image URI. Both local and Internal URIs are supported. | +Obtains an image from the specified source for subsequent rendering and display. +**Parameters** + +| Name| Type | Mandatory| Default Value| Description | +| ------ | ------------------------------------------------------------ | ---- | ------ | ------------------------------------------------------------ | +| src | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](../../ui/ts-types.md) | Yes | - | Image source. Both local and online images are supported.<br>When using resources referenced using a relative path, for example, `Image("common/test.jpg")`, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use `$r` to reference image resources that need to be used globally.<br>\- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is `data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, where `[base64 data]` is a Base64 string.<br/>\- The value can also be a path starting with `dataability://`, which is used to access the image path provided by a Data ability. | ## Attributes -| Name | Type | Default Value | Description | -| -------- | -------- | -------- | -------- | -| alt | string | - | Placeholder image displayed during loading. Both local and Internal URIs are supported. | -| objectFit | ImageFit | ImageFit.Cover | Image scale type. | -| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat enums) | ImageRepeat.NoRepeat | Whether the image is repeated.<br/>>  **NOTE**<br/>> - This attribute is not applicable to SVG images. | -| interpolation | ImageInterpolation | ImageInterpolation.None | Interpolation effect of the image. This attribute is valid only when the image is zoomed in.<br/>>  **NOTE**<br/>> - This attribute is not applicable to SVG images.<br/>> <br/>> - This attribute is not applicable to a **PixelMap** object. | -| renderMode | ImageRenderMode | ImageRenderMode.Original | Rendering mode of the image.<br/>>  **NOTE**<br/>> - This attribute is not applicable to SVG images. | -| sourceSize | {<br/>width: number,<br/>height: number<br/>} | - | Decoding size of the image. The original image is decoded into an image of the specified size. If the value is of the number type, the unit px is used.<br/>>  **NOTE**<br/>> This attribute is not applicable to a **PixelMap** object. | -| syncLoad<sup>8+</sup> | boolean | false | Whether to load images synchronously. By default, images are loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder diagram is not displayed. | - -- ImageFit enums - | Name | Description | - | -------- | -------- | - | Cover | The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | - | Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | - | Fill | The video content is resized to fill the display area while retaining its aspect ratio. | - | None | The original size is retained. Generally, this enum is used together with the **objectRepeat** attribute. | - | ScaleDown | The image content is displayed with its aspect ratio retained. The size is smaller than or equal to the original size. | - -- ImageInterpolation enums - | Name | Description | - | -------- | -------- | - | None | Interpolation image data is not used. | - | High | The interpolation image data is used at the high level. The use of the interpolation image data may affect the image rendering speed. | - | Medium | The interpolation image data is used at the medium level. | - | Low | The interpolation image data is used at the low level. | - -- ImageRenderMode enums - | Name | Description | - | -------- | -------- | - | Original | The image is rendered based on the original image, including the color. | - | Template | The image is rendered as a template image, and its color is ignored. | +In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. + +| Name | Type | Default Value | Description | +| --------------------- | ---------------------------------------- | ------------------------ | ---------------------------------------- | +| alt | string \| [Resource](../../ui/ts-types.md) | - | Placeholder image displayed during loading. Both local and Internet URIs are supported. | +| objectFit | [ImageFit](#imagefit-enums) | ImageFit.Cover | Image scale type. | +| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | NoRepeat | Whether the image is repeated.<br>**NOTE**<br>This attribute is not applicable to SVG images. | +| interpolation | [ImageInterpolation](#imageinterpolation) | ImageInterpolation.None | Interpolation effect of the image. This attribute is valid only when the image is zoomed in.<br>**NOTE**<br>This attribute is not applicable to SVG images or **PixelMap** objects. | +| renderMode | [ImageRenderMode](#imagerendermode) | ImageRenderMode.Original | Rendering mode of the image.<br>**NOTE**<br>This attribute is not applicable to SVG images. | +| sourceSize | {<br>width: number,<br>height: number<br>} | - | Decoding size of the image. The original image is decoded into an image of the specified size, in px.<br>**NOTE**<br>This attribute is not applicable to **PixelMap** objects. | +| syncLoad<sup>8+</sup> | boolean | false | Whether to load images synchronously. By default, images are loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder diagram is not displayed. | + +### ImageFit + +| Name | Description | +| --------- | -------------------------------- | +| Cover | The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | +| Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | +| Fill | The image is scaled to fill the display area, and its aspect ratio is not retained. | +| None | The image is displayed in its original size. Generally, this enum is used together with the **objectRepeat** attribute.| +| ScaleDown | The image is displayed with its aspect ratio retained, in a size smaller than or equal to the original size. | + +### ImageInterpolation +| Name | Description | +| ------ | ------------------------- | +| None | Interpolation image data is not used. | +| High | The interpolation image data is used at the high level, which may affect the image rendering speed.| +| Medium | The interpolation image data is used at the medium level. | +| Low | The interpolation image data is used at the low level. | + +### ImageRenderMode + +| Name | Description | +| -------- | --------------------- | +| Original | The image is rendered based on the original image, including the color. | +| Template | The image is rendered as a template image, and its color is ignored.| ## Events -| Name | Description | -| -------- | -------- | -| onComplete(callback: (event?: { width: number, height: number, componentWidth: number, componentHeight: number, loadingStatus: number }) => void) | Triggered when an image is successfully loaded. The loaded image is returned. | -| onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void) | An exception occurs during image loading. | -| onFinish(callback: () => void) | If the source file to be loaded is an SVG image, this callback is invoked when the SVG animation playback is complete. If the animation is an infinite loop, this callback is not triggered. | +In addition to the universal events (ts-universal-events-click.md), the following events are supported. +| Name | Description | +| ---------------------------------------- | ---------------------------------------- | +| onComplete(callback: (event?: { width: number, height: number, componentWidth: number,<br> componentHeight: number, loadingStatus: number }) => void) | Triggered when an image is successfully loaded. The size of the loaded image is returned.<br>- **width**: width of the image, in pixels.<br>- **height**: height of the image, in pixels.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>- **loadingStatus**: image loading status.<br>| +| onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void) | Triggered when an exception occurs during image loading.<br>- **componentWidth**: width of the container component, in pixels.<br>- **componentHeight**: height of the container component, in pixels.<br>| +| onFinish(callback: () => void) | Triggered when the animation playback in the loaded SVG image is complete. If the animation is an infinite loop, this callback is not triggered.| ## Example +### Loading Images -``` -// Image1 +Load and display different types of images and set the scale type of the images. + +```ts @Entry @Component struct ImageExample1 { @@ -143,9 +161,9 @@ struct ImageExample1 {  +### Setting Attributes -``` -// Image2 +```ts @Entry @Component struct ImageExample2 { @@ -163,12 +181,12 @@ struct ImageExample2 { .border({ width: 1 }).borderStyle(BorderStyle.Dashed) .overlay('Template', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) } - + Text('alt').fontSize(12).fontColor(0xcccccc).width('96%').height(30) Image('') .alt($r('app.media.Image_none')) .width(100).height(100).border({ width: 1 }).borderStyle(BorderStyle.Dashed) - + Text('sourceSize').fontSize(12).fontColor(0xcccccc).width('96%') Row({ space: 50 }) { Image($r('app.media.img_example')) @@ -188,7 +206,7 @@ struct ImageExample2 { .border({ width: 1 }).borderStyle(BorderStyle.Dashed) .overlay('w:200 h:200', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) } - + Text('objectRepeat').fontSize(12).fontColor(0xcccccc).width('96%').height(30) Row({ space: 5 }) { Image($r('app.media.ic_health_heart')) @@ -211,18 +229,18 @@ struct ImageExample2 {  +### Invoking Events -``` -// Image3 +```ts @Entry @Component struct ImageExample3 { @State width: number = 0 @State height: number = 0 - private on: Resource = $r('app.media.wifi_on') - private off: Resource = $r('app.media.wifi_off') - private on2off: Resource = $r('app.media.wifi_on2off') - private off2on: Resource = $r('app.media.wifi_off2on') + private on: Resource = $r('app.media.image_on') + private off: Resource = $r('app.media.image_off') + private on2off: Resource = $r('app.media.image_on2off') + private off2on: Resource = $r('app.media.image_off2on') @State src: Resource = this.on build() { @@ -237,6 +255,7 @@ struct ImageExample3 { }) .objectFit(ImageFit.Cover) .height(180).width(180) + // Obtain the size of an image after the image loading is complete. .onComplete((msg: { width: number,height: number }) => { this.width = msg.width this.height = msg.height @@ -249,7 +268,7 @@ struct ImageExample3 { offset: { x: 0, y: 20 } }) } - + // Add a click event so that a specific image is loaded upon clicking. Image(this.src) .width(120).height(120) .onClick(() => { diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index 435ab557cbe82515bf73b9a5a613c08f14dafae3..3aea124c118a3387fda7f601ee740b95dd2097a5 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -1,4 +1,4 @@ -# ImageAnimator +ImageAnimator The **\<ImageAnimator>** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. @@ -23,47 +23,47 @@ ImageAnimator() ## Attributes -| Name | Type | Default Value | Mandatory | Description | -| -------- | -------- | -------- | -------- | -------- | -| images | Array<{<br>src:string,<br>width?:Length,<br>height?:Length,<br>top?:Length,<br>left?:Length,<br>duration?:number<br>}> | [] | Yes | Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:<br>**src**: image path. The image format can be SVG, PNG, or JPG.<br>**width**: image width.<br>**height**: image height.<br>**top**: vertical coordinate of the image relative to the upper left corner of the component.<br>**left**: horizontal coordinate of the image relative to the upper left corner of the component.<br>**duration**: playback duration of the image, in ms. | -| state | AnimationStatus | AnimationStatus.Initial | No | Playback status of the animation. The default status is **Initial**. | -| duration | number | 1000 | No | Playback duration, in ms. The default duration is 1000 ms. When the duration is **0**, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid. | -| reverse | boolean | false | No | Playback sequence. The value **false** indicates that images are played from the first one to the last one, and **true** indicates that images are played from the last one to the first one. | -| fixedSize | boolean | true | No | Whether the image size is the same as the component size. **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. **false**: The width, height, top, and left attributes of each image must be set separately. | -| preDecode | number | 0 | No | Whether to enable pre-decoding. The default value **0** indicates that pre-decoding is disabled. If this attribute is set to **2**, two images following the currently playing frame will be cached in advance to improve performance. | -| fillMode | FillMode | FillMode.Forwards | No | Status before and after the animation starts. For details about the options, see **FillMode**. | -| iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | +| Name | Type | Default Value | Mandatory | Description | +| ---------- | ---------------------------------------- | ----------------------- | --------- | ---------------------------------------- | +| images | Array<{<br>src:string,<br>width?:Length,<br>height?:Length,<br>top?:Length,<br>left?:Length,<br>duration?:number<br>}> | [] | Yes | Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:<br>**src**: image path. The image format can be SVG, PNG, or JPG.<br>**width**: image width.<br>**height**: image height.<br>**top**: vertical coordinate of the image relative to the upper left corner of the component.<br>**left**: horizontal coordinate of the image relative to the upper left corner of the component.<br>**duration**: playback duration of the image, in ms. | +| state | AnimationStatus | AnimationStatus.Initial | No | Playback status of the animation. The default status is **Initial**. | +| duration | number | 1000 | No | Playback duration, in ms. The default duration is 1000 ms. When the duration is **0**, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid. | +| reverse | boolean | false | No | Playback sequence. The value **false** indicates that images are played from the first one to the last one, and **true** indicates that images are played from the last one to the first one. | +| fixedSize | boolean | true | No | Whether the image size is the same as the component size. **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. **false**: The width, height, top, and left attributes of each image must be set separately. | +| preDecode | number | 0 | No | Whether to enable pre-decoding. The default value **0** indicates that pre-decoding is disabled. If this attribute is set to **2**, two images following the currently playing frame will be cached in advance to improve performance. | +| fillMode | FillMode | FillMode.Forwards | No | Status before and after the animation starts. For details about the options, see **FillMode**. | +| iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | - ImageFrameInfo - | Name| Type| Default Value| Mandatory| Description| - | -------- | -------- | -------- | -------- | -------- | - | src | string \| [Resource](.../ui/ts-types.md#resource-type)<sup>9+</sup>| "" | Yes| Image path. The image format can be .svg, .png, or .jpg.| - | width | [Length](.../ui/ts-types.md#length-type)| 0 | No| Image width.| - | height | [Length](.../ui/ts-types.md#length-type)| 0 | No| Image height.| - | top | [Length](.../ui/ts-types.md#length-type)| 0 | No| Vertical coordinate of the image relative to the upper left corner of the component.| - | left | [Length](.../ui/ts-types.md#length-type)| 0 | No| Horizontal coordinate of the image relative to the upper left corner of the component.| - | duration | number | 0 | No| Playback duration of each image frame, in milliseconds.| + | Name | Type | Default Value | Mandatory | Description | + | -------- | ---------------------------------------- | ------------- | --------- | ---------------------------------------- | + | src | string \| [Resource](../../ui/ts-types.md)<sup>9+</sup> | "" | Yes | Image path. The image format can be .svg, .png, or .jpg. | + | width | [Length](../../ui/ts-types.md) | 0 | No | Image width. | + | height | [Length](../../ui/ts-types.md) | 0 | No | Image height. | + | top | [Length](../../ui/ts-types.md) | 0 | No | Vertical coordinate of the image relative to the upper left corner of the component. | + | left | [Length](../../ui/ts-types.md) | 0 | No | Horizontal coordinate of the image relative to the upper left corner of the component. | + | duration | number | 0 | No | Playback duration of each image frame, in milliseconds. | - AnimationStatus enums - | Name | Description | - | -------- | -------- | + | Name | Description | + | ------- | -------------------------------------- | | Initial | The animation is in the initial state. | - | Running | The animation is being played. | - | Paused | The animation is paused. | - | Stopped | The animation is stopped. | + | Running | The animation is being played. | + | Paused | The animation is paused. | + | Stopped | The animation is stopped. | - FillMode enums - | Name | Description | - | -------- | -------- | - | None | After the playback is complete, the animation restores to the initial state. | + | Name | Description | + | -------- | ---------------------------------------- | + | None | After the playback is complete, the animation restores to the initial state. | | Forwards | After the playback is complete, the animation remains in the end state. | ## Events -| Name | Description | -| -------- | -------- | -| onStart() => void | Triggered when the animation starts to play. | -| onPause() => void | Triggered when the animation playback is paused. | +| Name | Description | +| --------------------- | ---------------------------------------- | +| onStart() => void | Triggered when the animation starts to play. | +| onPause() => void | Triggered when the animation playback is paused. | | onRepeat() => void | Triggered when the animation playback is repeated. | | onCancel() => void | Triggered when the animation playback is canceled. | | onFinish() => void | Triggered when the animation playback is complete. | diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md index 757050181d0b2828e0dc806b3f06d170c554ef74..dc89934a2760b1c67f84ca216530d0c3a58752e9 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -1,11 +1,12 @@ # Marquee -> **NOTE**<br> -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -The **\<Marquee>** component is used to display a scrolling piece of text. +The **\<Marquee>** component is used to display a scrolling piece of text. The text is scrolled only when its width exceeds the width of the **\<Marquee>** component. ## Required Permissions @@ -15,7 +16,7 @@ None ## Child Components -None +Not supported ## APIs @@ -23,28 +24,29 @@ None Marquee(value: { start: boolean, step?: number, loop?: number, fromStart?: boolean, src: string }) - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | start | boolean | Yes | - | Whether to start scrolling. | - | step | number | No | 6 | Scrolling step. | - | loop | number | No | -1 | Number of times the marquee will scroll. If the value is less than or equal to **0**, the marquee will scroll continuously. | - | fromStart | boolean | No | true | Whether the text scrolls from the start. | - | src | string | Yes | - | Text to scroll. | + | start | boolean | Yes| - | Whether to start scrolling.| + | step | number | No| 6 | Scrolling step.| + | loop | number | No| -1 | Number of times the marquee will scroll. If the value is less than or equal to **0**, the marquee will scroll continuously.| + | fromStart | boolean | No| true | Whether the text scrolls from the start.| + | src | string | Yes| - | Text to scroll.| ## Events -| Name | Description | +| Name| Description| | -------- | -------- | -| onStart(callback: () => void) | Triggered when the marquee starts scrolling. | -| onBounce(callback: () => void) | Triggered when the marquee has reached the end. | -| onFinish(callback: () => void) | Triggered when the marquee has finished scrolling. | +| onStart(callback: () => void) | Triggered when the marquee starts scrolling.| +| onBounce(callback: () => void) | Triggered when the marquee has reached the end.| +| onFinish(callback: () => void) | Triggered when the marquee has finished scrolling.| ## Example -``` +```ts +// xxx.ets @Entry @Component struct MarqueeExample { @@ -63,6 +65,7 @@ struct MarqueeExample { fromStart: this.fromStart, src: this.src }) + .width(400) .fontColor(Color.White) .fontSize(50) .allowScale(false) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md b/en/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md new file mode 100644 index 0000000000000000000000000000000000000000..ed83909a33d4735264f6d832cf20066d7869d671 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md @@ -0,0 +1,75 @@ +# RemoteWindow + +**\<RemoteWindow>** is a component used to control the application window, providing the component animator and application window linkage animator during application startup and exit. + +> **NOTE** +> +> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. +> +> This component is a system API. + +## Child Components + +Not supported + +## APIs + +RemoteWindow(target: WindowAnimationTarget) + +Creates a **\<RemoteWindow>** through a window animation object. + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | target | [WindowAnimationTarget](#windowanimationtarget) | Yes| - | Description of the animation window to control.| + +## WindowAnimationTarget +Implements a target window, which is used to remotely control the animation. + +| Name | Type | Description| +| ------- | ------ | ----------------------- | +| bundleName | string | Process corresponding to the animation window.| +| abilityName | string | Ability corresponding to the animation window.| +| windowBounds | [RRect](#rrect) | Actual size of the animation window.| + +## RRect +Implements a rounded rectangle. + +| Name | Type | Description| +| ------- | ------ | ----------------------- | +| left | number | Horizontal coordinate of the upper left corner of the animation window relative to the screen.| +| top | number | Vertical coordinate of the upper left corner of the animation window relative to the screen.| +| width | number | Width of the animation window.| +| height | number | Height of the animation window.| +| radius | number | Radius of the rounded corner of the animation window.| + +## Attributes + +The [universal attributes](ts-universal-attributes-size.md) are supported. + +## Events + +The [universal events](ts-universal-events-click.md) are supported. + +## Example + +```ts +// xxx.ets +@Entry +@Component +struct RemoteWindowExample { + @State target: WindowAnimationTarget = undefined // Obtained through windowAnimationManager + + build() { + Column() { + RemoteWindow(this.target) + .translate({x:100, y:200}) + .scale({x:0.5, y:0.5}) + .opacity(0.8) + .position({x:px2vp(this.target?.windowBounds.left), y:px2vp(this.target?.windowBounds.top)}) + .width(px2vp(this.target?.windowBounds.width)) + .height(px2vp(this.target?.windowBounds.height)) + } + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-search.md b/en/application-dev/reference/arkui-ts/ts-basic-components-search.md index 7ea05b944a8783a03ce702eac0c904cb5d35760c..386f5aa23c7467f88e77d0c34647f2467af903b3 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -1,10 +1,10 @@ # Search -The **\<Search>** component provides an input area for users to search. > **NOTE** > > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +The **\<Search>** component provides an input area for users to search. ## Required Permissions @@ -24,7 +24,7 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | -------- | -------- | -------- | -------- | -------- | | value | string | No| - | Text input in the search text box. | | placeholder | string | No | - | Text displayed when there is no input. | - | icon | string | No| - | Path to the search icon. By default, the system search icon is used. The supported icon formats are svg, jpg, and png. | + | icon | string | No| - | Path to the search icon. By default, the system search icon is used. The supported icon formats are .svg, .jpg, and .png. | | controller | SearchController | No| - | Controller. | @@ -36,7 +36,6 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | placeholderColor | [ResourceColor](../../ui/ts-types.md) | - | Placeholder text color. | | placeholderFont | [Font](../../ui/ts-types.md) | - | Placeholder text style. | | textFont | [Font](../../ui/ts-types.md) | - | Text font for the search text box. | -| copyOption<sup>9+</sup> | boolean\|[CopyOption](ts-basic-components-text.md) | true | Whether copy and paste is allowed. | ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md index 2758e99f0cdba7ed1a7722cd10a4ed6c68438466..a98e84fffd5816a22445daa66833cb47d0dbae88 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -1,15 +1,15 @@ # Text -> **NOTE**<br/> -> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - - The **\<Text>** component is used to display a piece of textual information. +> **NOTE** +> +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + ## Required Permissions -N/A +None ## Child Components @@ -32,8 +32,8 @@ Text(content?: string) | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | | textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text.| -| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters. | -| maxLines | number | Infinity | Maximum number of lines in the text.| +| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br/><br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with `maxLines` to take effect.| +| maxLines | number | Infinity | Maximum number of lines in the text.<br>**NOTE**<br/><br>By default, text is automatically folded. If this parameter is specified, the text does not exceed the specified number of lines. If there is extra text, you can use `textOverflow` to specify the truncation mode.| | lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.| | decoration | {<br>type: TextDecorationType,<br>color?: Color<br>} | {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.| | baselineOffset | Length | - | Offset of the text baseline.| @@ -78,7 +78,7 @@ Text(content?: string) | LocalDevice | Intra-device copy and paste is allowed.| | CrossDevice | Cross-device copy and paste is allowed.| -> **NOTE**<br/> +> **NOTE**<br/> > If the **\<Text>** component contains both the text and the **\<Span>** child component, only the content in **\<Span>** is displayed. diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md index 0c8193971e4b765b36e7064a2041ec9b646c9332..39890e59e22c1a8736a566e280d08df9c5be1181 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md @@ -1,11 +1,12 @@ # TimePicker -> **NOTE**<br> -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - The **\<TimePicker>** component allows users to select a time from the given range. +> **NOTE**<br> +> +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + ## Required Permissions @@ -14,7 +15,7 @@ No ## Child Components -No +Not supported ## APIs @@ -54,11 +55,12 @@ Creates a time picker whose default time range is from 00:00 to 23:59. ### Time Picker -``` +```ts +// xxx.ets @Entry @Component struct TimePickerExample { - private selectedTime: Date = new Date('08-00') + private selectedTime: Date = new Date('7/22/2022 8:00:00') build() { Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 7b91e7865dd58ad62ceedf02afc37944f54cf89e..d625528c2c4f1cd857ae04585201d5507bb70ff8 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -20,14 +20,14 @@ CanvasRenderingContext2D(setting: RenderingContextSetting) ### RenderingContextSettings -RenderingContextSettings(antialias?: bool) +RenderingContextSettings(antialias?: boolean) Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing. - Parameters | Name | Type | Mandatory | Default Value | Description | | --------- | ---- | --------- | ------------- | -------------------------------- | - | antialias | bool | No | false | Whether antialiasing is enabled. | + | antialias | boolean | No | false | Whether antialiasing is enabled. | ## Attributes @@ -1771,17 +1771,17 @@ drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sWidth: number, Draws an image. - Parameters - | Name | Type | Mandatory | Default Value | Description | - | ------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see ImageBitmap or PixelMap. | - | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | - | sWidth | number | No | 0 | Target width to crop the source image. | - | sHeight | number | No | 0 | Target height to crop the source image. | - | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | - | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | - | dWidth | number | No | 0 | Width of the drawing area. | - | dHeight | number | No | 0 | Height of the drawing area. | + | Name | Type | Mandatory | Default Value | Description | + | ------- | ------------------------------------------------------------ | --------- | ------------- | ------------------------------------------------------------ | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see ImageBitmap or PixelMap. | + | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sWidth | number | No | 0 | Target width to crop the source image. | + | sHeight | number | No | 0 | Target height to crop the source image. | + | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | + | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | + | dWidth | number | No | 0 | Width of the drawing area. If the width of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former. | + | dHeight | number | No | 0 | Height of the drawing area. If the height of the drawing area is different from that of the cropped image, the latter will be stretched or compressed to the former. | - Example diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md index cc6e43dbc45b9c35dcda68aee838d64de2c60802..c520530cb00102c4d30eaf36d1f25b27c5bb968b 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md @@ -1,17 +1,17 @@ # ImageBitmap -> **NOTE**<br> +> **NOTE** +> > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -**CanvasImageData** stores pixel data rendered on a canvas. +An **ImageBitmap** object stores pixel data rendered on a canvas. ## Attributes -| Name | Type | Description | +| Name | Type | Description | | -------- | -------- | -------- | | width | number | Actual width of the rectangle on the canvas, in pixels. | | height | number | Actual height of the rectangle on the canvas, in pixels. | -| data | <Uint8ClampedArray> | A one-dimensional array of color values. The values range from 0 to 255. | diff --git a/en/application-dev/reference/arkui-ts/ts-container-ability-component.md b/en/application-dev/reference/arkui-ts/ts-container-ability-component.md new file mode 100644 index 0000000000000000000000000000000000000000..3cd3e3914611b396a1fb5bf1a132374b651a005f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-ability-component.md @@ -0,0 +1,114 @@ +# AbilityComponent + +> **NOTE** +> +> This component is supported since API version 9. +> +> The APIs of this module are system APIs and cannot be called by third-party applications. + + +**\<AbilityComponent>** is a container for independently displaying an ability. + +## Constraints + +Using **\<AbilityComponent>** requires a signature and related permissions. + +**\<AbilityComponent>** is rendered independently and cannot be overlaid with other display content. + +**\<AbilityComponent>** cannot process input events. Events are directly distributed to the internal ability for processing without passing through the current ability. + +Only width and height can be set for **\<AbilityComponent>**. These attributes are mandatory and cannot be dynamically updated. + +The ability to be started must be resizeable. + +The ability to start must be set not to display on the recent tasks screen. + +## Required Permissions + +ohos.permission.INFUSE_EVENTS + +ohos.permission.CONTROL_ABILITY_STACKS + +ohos.permission.INTEGRATED_ABILITY + +ohos.permission.INTEGRATED_INTERIOR_WINDOW + + +## Child Components + +Not supported + + +## APIs + +AbilityComponent(value: {want : Want, controller? : AbilityController}) + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | want | [Want](../../reference/apis/js-apis-application-Want.md) | Yes| - | Description of the default ability to load.| + | controller | [AbilityController](#abilityController) | No| - | Ability controller.| + + +## Events + +| Name| Description| +| -------- | -------- | +| onReady() => void | Called when this **\<AbilityComponent>** is started. You can then use APIs in the **\<AbilityComponent>**.| +| onDestroy() => void | Called when this **\<AbilityComponent>** is destroyed.| +| onAbilityCreated(name: string) => void | Called when the specified ability is loaded.| +| onAbilityMoveToFont() => void | Called when this ability is moved to the foreground.| +| onAbilityWillRemove() => void | Called when this ability is about to be removed.| + +## AbilityController + +Implements an ability controller, which provides the control APIs for **\<AbilityComponent>**. + +| Name | Description | +| --------------------------------------- | ------------------------------------------------------------ | +| startAbility() => want | Loads an ability inside the **\<AbilityComponent>**.<br>**want**: description of the ability to be loaded.| +| preformBackPress() => void | Performs a return operation inside the **\<AbilityComponent>**. | +| getStackCount() => void | Obtains the number of tasks in the internal task stack of the **\<AbilityComponent>**. | + + +## Example + +```ts +// xxx.ets +@Entry +@Component +struct MyComponent { + @State controller: AbilityController = new AbilityController() + + build() { + Column() { + AbilityComponent({ + want: { + bundleName: '', + abilityName: '' + }, + controller: this.controller + }) + .onReady(() => { + console.log('AbilityComponent ready'); + }) + .onDestory(() => { + console.log('AbilityComponent destory'); + }) + Button("Start New") + .onClick(() => { + this.controller.startAbility({ + bundleName: '', + abilityName: '' + }); + }) + Button("Back") + .onClick(() => { + if (this.controller.getStacjCount() > 1) { + this.controller.preformBackPress(); + } + }) + } + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-container-list.md b/en/application-dev/reference/arkui-ts/ts-container-list.md index 5d11634e3bae94e58ac0589451c9076c7c356ecc..adfcea2c3e0b11eb554a0077bb9e794ea1ca6973 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-list.md +++ b/en/application-dev/reference/arkui-ts/ts-container-list.md @@ -21,13 +21,14 @@ This component contains the child component [\<ListItem>](ts-container-listitem. ## APIs -List(value:{space?: number, initialIndex?: number}) +List(value:{space?: number | string, initialIndex?: number, scroller?: Scroller}) - Parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | space | number | No | 0 | Spacing between list items. | - | initialIndex | number | No | 0 | Item displayed at the beginning of the component when the current list is loaded for the first time, that is, the first item to be displayed. If the configured sequence number is greater than the sequence number of the last item, the setting does not take effect. | + | space | number \| string | No | 0 | Spacing between list items. | + | initialIndex | number | No | 0 | Item displayed at the beginning of the viewport when the current list is loaded for the first time, that is, the first item to be displayed. If the value set is greater than the sequence number of the last item, the setting does not take effect. | + | scroller | [Scroller](ts-container-scroll.md#scroller) | No | - | Controller bound to the list to control the scrolling. | ## Attributes @@ -36,8 +37,8 @@ List(value:{space?: number, initialIndex?: number}) | -------- | -------- | -------- | -------- | | listDirection | [Axis](ts-appendix-enums.md#axis-enums) | Vertical | Direction in which the list items are arranged. For details, see **Axis** enums. | | divider | {<br>strokeWidth: Length,<br>color?:Color,<br>startMargin?: Length,<br>endMargin?: Length<br>} | - | Style of the divider for the list items. By default, there is no divider.<br>**strokeWidth**: stroke width of the divider.<br>**color**: color of the divider.<br>**startMargin**: distance between the divider and the start of the list.<br>**endMargin**: distance between the divider and the end of the list. | -| editMode | boolean | false | Whether the **<List>** component is in editable mode. | -| edgeEffect | EdgeEffect | EdgeEffect.Spring | Sliding effect. For details, see EdgeEffect enums. | +| editMode | boolean | false | Whether the **\<List>** component is in editable mode. | +| edgeEffect | EdgeEffect | EdgeEffect.Spring | Sliding effect. For details, see **EdgeEffect enums**. | | chainAnimation | boolean | false | Whether to display chained animations on this list when it slides or its top and bottom are dragged. The list items are separated with even space, and one item animation starts after the previous animation during basic sliding interactions. The chained animation effect is similar with spring physics.<br>- **false**: No chained animations are displayed.<br>- **true**: Chained animations are displayed. | | multiSelectable<sup>8+</sup> | boolean | false | Whether to enable mouse frame selection.<br>- **false**: The mouse frame selection is disabled.<br>- **true**: The mouse frame selection is enabled. | | restoreId<sup>8+</sup> | number | - | Migration ID of the component. During application migration, the status of the component is migrated to the component with the same migration ID on the peer end.<br>For a **<\List>** component, the status includes the item serial number displayed at the start position. | @@ -48,7 +49,7 @@ List(value:{space?: number, initialIndex?: number}) | Name | Description | | -------- | -------- | | Spring | Similar to the physical dynamic effect of a spring. After scrolling to the edge, the user can continue to scroll for a distance based on the initial speed or by touching the knob of the scrollbar. After the user releases their hand, the knob is rebounded. | - | None | No effect after the scrollbar is moved to the edge. | + | None | No effect when the list is scrolled to the edge. | - ListItemAlign enums @@ -64,7 +65,8 @@ List(value:{space?: number, initialIndex?: number}) | Name | Description | | -------- | -------- | | onItemDelete(index: number) => boolean | Triggered when a list item is deleted. | -| onScrollIndex(firstIndex: number, lastIndex: number) => void | Triggered when the start position and end position of the current list are changed. | +| onScrollBegin<sup>9+</sup>(dx: number, dy: number) => { dxRemain: number, dyRemain: number } | Triggered when scrolling starts.<br/>Parameters:<br/>- **dx**: amount by which the list will scroll in the horizontal direction.<br/>- **dy**: amount by which the list will scroll in the vertical direction.<br/>Return value:<br/>- **dxRemain**: remaining amount by which the list can scroll in the horizontal direction.<br/>- **dyRemain**: remaining amount by which the list can scroll in the vertical direction. | +| onScrollIndex(firstIndex: number, lastIndex: number) => void | Triggered when the start position and end position of the current list are changed. | > **NOTE** > @@ -106,9 +108,9 @@ struct ListExample { }.editable(true) }, item => item) } - .listDirection(Axis.Vertical) // Arrangement direction - .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // Divider line - .edgeEffect(EdgeEffect.None) // No effect when sliding to the edge + .listDirection(Axis.Vertical) // Direction in which the list items are arranged. + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // Style of the divider for the list items. + .edgeEffect(EdgeEffect.None) // No effect when the list is scrolled to the edge. .chainAnimation(false) // Chained animations are disabled. .onScrollIndex((firstIndex: number, lastIndex: number) => { console.info('first' + firstIndex) @@ -166,7 +168,7 @@ struct ListLanesExample { .lanes({ minLength: 40, maxLength: 60 }) .alignListItem(this.alignListItem) - Button("Change alignListItem: "+ this.alignListItem).onClick(() => { + Button("Change alignListItem:" + this.alignListItem).onClick(() => { if (this.alignListItem == ListItemAlign.Start) { this.alignListItem = ListItemAlign.Center } else if (this.alignListItem == ListItemAlign.Center) { @@ -179,3 +181,4 @@ struct ListLanesExample { } } ``` + diff --git a/en/application-dev/reference/arkui-ts/ts-container-refresh.md b/en/application-dev/reference/arkui-ts/ts-container-refresh.md index 2392680bc520832629d8763fb9eee5e28b946bf7..92aa736e68b028b7c188e12005badf7e967ab8ba 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-refresh.md +++ b/en/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -1,9 +1,10 @@ # Refresh -> **NOTE**<br/> -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + The **\<Refresh>** component is a container that provides the pull-to-refresh feature. -The **<Refresh\>** component is used to refresh a page through a pull-down gesture. +> **NOTE** +> +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -19,11 +20,11 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri - Parameters - | Name | Value Type | Mandatory | Default Value | Description | + | Name| Value Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | refreshing | boolean | Yes| - | Whether the current component is being refreshed. | - | offset | Length | No| 16 | Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture. | - | friction | number | No| 62 | Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100. <br/>- **0**: The **<Refresh\>** component is not sensitive to the pull-down gesture. <br/>- **100**: The **<Refresh\>** component is highly sensitive to the pull-down gesture. <br/>- Value greater than **100**: The **<Refresh\>** component is much more sensitive to the pull-down gesture. | + | refreshing | boolean | Yes| - | Whether the current component is being refreshed.| + | offset | Length | No| 16 | Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture.| + | friction | number \| string | No| 62 | Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.<br>- **0** indicates that the **\<Refresh>** component is not sensitive to the pull-down gesture.<br>- **100** indicates that the **\<Refresh>** component is highly sensitive to the pull-down gesture.<br>- A larger value indicates a more sensitive response of the **\<Refresh>** component to the pull-down gesture.| @@ -32,23 +33,24 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri | Name| Description| | -------- | -------- | -| onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes. <br/>**state** indicates the refresh status. | -| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state. | +| onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes.<br>**state**: refresh status.| +| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.| - RefreshStatus enums - | Name | Description | + | Name| Description| | -------- | -------- | - | Inactive | The component is not pulled down. This is the default value. | - | Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh. | - | OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh. | - | Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state. | - | Done | The refresh is complete, and the component returns to the initial state (top). | + | Inactive | The component is not pulled down. This is the default value.| + | Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh.| + | OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh.| + | Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state.| + | Done | The refresh is complete, and the component returns to the initial state (top).| ## Example -``` +```ts +// xxx.ets @Entry @Component struct RefreshExample { diff --git a/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md b/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md new file mode 100644 index 0000000000000000000000000000000000000000..d5eae8e6a05272aeecf9685a2a87da55cbc8d007 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-relativecontainer.md @@ -0,0 +1,92 @@ +# RelativeContainer + +The **\<RelativeContainer>** component is used for element alignment in complex scenarios. + +> **NOTE** +> +> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. + + + +## Rules + + * Components in a container are aligned horizontally or vertically. + * Alignment modes in the horizontal direction can be left, center, or right, achieved by the **HorizontalAlign.Start**, **HorizontalAlign.Center**, and **HorizontalAlign.End** attributes of the container, respectively. + * Alignment modes in the vertical direction can be top, center, or bottom, achieved by the **VerticalAlign.Top**, **VerticalAlign.Center**, and **VerticalAlign.Bottom** attributes of the container, respectively. + * A child component can set the container or another child component as the anchor point. + * An ID must be set for the child components in the **\<RelativeContainer>**. The container ID is fixed at **__container__**. + * By default, a child component without an ID is positioned in the upper left corner of the container. + * Three positions in a direction of the child component can use three positions in the same direction of the container or another child components as anchor points. When anchor points are set for more than two positions in the same direction, the third position is skipped. + * When anchor points are set for more than two positions in the same direction, the width and height of the child component do not take effect. + * If offset is required after the alignment, it can be set through **offset**. + * Exceptions + * When a mutual or circular dependency occurs, all child components in the container are not drawn. + * If anchors are set for more than two positions in the same direction but the anchor positions are reversed, the size of the child component is 0, that is, the child component is not drawn. + +## Required Permissions + +None + + +## Child Components + +Multiple child components are supported. + + +## APIs + +RelativeContainer() + +## Example + +```ts +@Entry +@Component +struct Index { + + build() { + Row() { + Button("Extra button").width(100).height(50) + RelativeContainer() { + Button("Button 1").width(120).height(30) + .alignRules({ + middle: { anchor: "__container__", align: HorizontalAlign.Center }, + }) + .id("bt1").borderWidth(1).borderColor(Color.Black) + Text("This is text 2").fontSize(20).padding(10) + .alignRules({ + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, + top: { anchor: "bt1", align: VerticalAlign.Bottom }, + right:{ anchor: "bt1", align: HorizontalAlign.Center } + }).id("tx2").borderWidth(1).borderColor(Color.Black).height(30) + + LoadingProgress().color(Color.Blue) + .alignRules({ + left: { anchor: "bt1", align: HorizontalAlign.End }, + top: { anchor: "tx2", align: VerticalAlign.Center }, + bottom: { anchor: "__container__", align: VerticalAlign.Bottom } + }).id("lp3").borderWidth(1).borderColor(Color.Black) + .height(30).width(30) + + Gauge({ value: 50, min: 0, max: 100 }) + .startAngle(210).endAngle(150) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) + .strokeWidth(20) + .width(50).height(50) + .alignRules({ + left: { anchor: "tx2", align: HorizontalAlign.End }, + right:{ anchor: "__container__", align: HorizontalAlign.End }, + top: { anchor: "__container__", align: VerticalAlign.Top }, + bottom: { anchor: "lp3", align: VerticalAlign.Top } + }).id("g4").borderWidth(1).borderColor(Color.Black) + + } + .width(200).height(200) + .backgroundColor(Color.Orange) + + } + .height('100%') + } +} +``` + diff --git a/en/application-dev/reference/arkui-ts/ts-container-swiper.md b/en/application-dev/reference/arkui-ts/ts-container-swiper.md index 0e72a05681396dc2a4bc086c31ce0ff8ed827282..f72c10f4bceb9efde139745d420411703b0e3c9c 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -2,6 +2,7 @@ > **NOTE**<br> +> > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -23,9 +24,9 @@ This component can contain child components. Swiper(value:{controller?: SwiperController}) - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | controller | [SwiperController](#swipercontroller) | No | null | Controller bound to the component to control the page switching. | + | controller | [SwiperController](#swipercontroller) | No | null | Controller bound to the component to control the page switching. | ## Attributes @@ -36,36 +37,38 @@ Swiper(value:{controller?: SwiperController}) | autoPlay | boolean | false | Whether to enable automatic playback for child component switching. If this attribute is **true**, the indicator dots do not take effect. | | interval | number | 3000 | Interval for automatic playback, in ms. | | indicator | boolean | true | Whether to enable the navigation dots. | -| loop | boolean | true | Whether to enable loop playback. | +| loop | boolean | true | Whether to enable loop playback.<br>The value **true** means to enable loop playback. When **LazyForEach** is used, it is recommended that the number of the components to load exceed 5. | | duration | number | 400 | Duration of the animation for switching child components, in ms. | | vertical | boolean | false | Whether vertical swiping is used. | | itemSpace | Length | 0 | Space between child components. | | cachedCount<sup>8+</sup> | number | 1 | Number of child components to be cached. | | disableSwipe<sup>8+</sup> | boolean | false | Whether to disable the swipe feature. | | curve<sup>8+</sup> | [Curve](ts-animatorproperty.md) \| Curves | Curve.Ease | Animation curve. The ease-in/ease-out curve is used by default. For details about common curves, see [Curve enums](ts-animatorproperty.md). You can also create custom curves ([interpolation curve objects](ts-interpolation-calculation.md)) by using APIs provided by the interpolation calculation module. | +| indicatorStyle<sup>8+</sup> | {<br/>left?: Length,<br/>top?: Length,<br/>right?: Length,<br/>bottom?: Length,<br/>size?: Length,<br/>color?: Color,<br/>selectedColor?: Color<br/>} | - | Style of the navigation dots indicator.<br/>- **left**: distance between the navigation dots indicator and the left edge of the **\<Swiper>** component.<br/>- **top**: distance between the navigation dots indicator and the top edge of the **\<Swiper>** component.<br/>- **right**: distance between the navigation dots indicator and the right edge of the **\<Swiper>** component.<br/>- **bottom**: distance between the navigation dots indicator and the right edge of the **\<Swiper>** component.<br/>- **size**: diameter of the navigation dots indicator.<br/>- **color**: color of the navigation dots indicator.<br/>- **selectedColor**: color of the selected navigation dot. | -### SwiperController +## SwiperController Controller of the **<Swiper\>** component. You can bind this object to the **<Swiper\>** component and use it to control page switching. -| Name | Description | +| Name | Description | | -------- | -------- | -| showNext():void | Turns to the next page. | -| showPrevious():void | Turns to the previous page. | +| showNext():void | Turns to the next page. | +| showPrevious():void | Turns to the previous page. | ## Events -| Name | Description | +| Name | Description | | -------- | -------- | -| onChange( index: number) => void | Triggered when the index of the currently displayed component changes. | +| onChange( index: number) => void | Triggered when the index of the currently displayed component changes. | ## Example -``` +```ts +// xxx.ets class MyDataSource implements IDataSource { private list: number[] = [] private listener: DataChangeListener @@ -96,7 +99,7 @@ struct SwiperExample { private swiperController: SwiperController = new SwiperController() private data: MyDataSource = new MyDataSource([]) - private aboutToAppear(): void { + aboutToAppear(): void { let list = [] for (var i = 1; i <= 10; i++) { list.push(i.toString()); diff --git a/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md b/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md index d980bdefeade3492743ebb874675a85ebc34bb75..71c1839a5615a1970668fab8c60f69e2051c8f98 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md @@ -1,7 +1,8 @@ # Action Sheet -> **NOTE**<br> +> **NOTE** +> > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. @@ -17,25 +18,25 @@ None show(options: { paramObject1}) -Defines and shows the action sheet. +Defines and shows an action sheet. - paramObject1 parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | title | string \|[Resource](../../ui/ts-types.md#resource) | No | None | Title of the dialog box. | - | message | string \|[Resource](../../ui/ts-types.md#resource) | | | Content of the dialog box. | + | title | string \|[Resource](../../ui/ts-types.md) | No | None | Title of the dialog box. | + | message | string \|[Resource](../../ui/ts-types.md) | | | Content of the dialog box. | | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | - | confirm | {<br/>value: string \|[Resource](../../ui/ts-types.md#resource),<br>action: () => void<br/>} | number | string | Text content of the confirm button and callback upon button clicking.<br/>**value**: button text.<br/>**action**: callback upon button clicking. | + | confirm | {<br/>value: string \| [Resource](../../ui/ts-types.md),<br/>action: () => void<br/>} | No | - | Text content of the confirm button and callback upon button clicking.<br/>**value**: button text.<br/>**action**: callback upon button clicking. | | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | - | 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/>} | No | - | Offset of the dialog box relative to the alignment position. | - | sheets | Array<SheetInfo> | Yes | - | Options in the dialog box. Each option supports the image, text, and callback. | + | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {<br/>dx: Length,<br/>dy: Length<br/>} | No | {<br/>dx: 0,<br/>dy: 0<br/>} | Offset of the dialog box relative to the alignment position. | + | sheets | Array<SheetInfo> | Yes | - | Options in the dialog box. Each option supports the image, text, and callback. | - SheetInfo parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | title | string | Yes | - | Sheet text. | - | icon | string | No | None | Sheet icon. | + | title | string \| [Resource](../../ui/ts-types.md) | Yes | - | Sheet text. | + | icon | string \| [Resource](../../ui/ts-types.md) | No | None | Sheet icon. | | action | ()=>void | Yes | - | Callback when the sheet is selected. | @@ -43,10 +44,11 @@ Defines and shows the action sheet. -``` +```ts +// xxx.ets @Entry @Component -struct ActionSheetExapmle { +struct ActionSheetExample { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Button('Click to Show ActionSheet') diff --git a/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md index e8330691116919aa6824a67358abe3441af63795..30ea8acfedfb262bc209160405da7bb6bcfaa0fc 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md @@ -1,8 +1,9 @@ # Alert Dialog Box -> **NOTE**<br> -> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **<AlertDialog\>** component is used to display an alert dialog box. You can set the text content and response callback for an alert dialog box as needed. @@ -10,40 +11,41 @@ The **<AlertDialog\>** component is used to display an alert dialog box. You can ## Attributes -| Name | Type | Default Value | Description | +| Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| show | options: { paramObject1\| paramObject2} | - | Defines and displays the **<AlertDialog\>** component. | +| show | options: { paramObject1 \| paramObject2} | - | Defines and displays the **<AlertDialog\>** component. | - paramObject1 parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | title | string \|[Resource](../../ui/ts-types.md#resource) | | | Title of a dialog box. | - | message | string \|[Resource](../../ui/ts-types.md#resource) | | | Content of the dialog box. | + | title | string \| [Resource](../../ui/ts-types.md) | No | - | Title of a dialog box. | + | message | string \| [Resource](../../ui/ts-types.md) | Yes | - | Content of the dialog box. | | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | - | confirm | {<br/>value: string \|[Resource](../../ui/ts-types.md#resource),<br>fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),<br/>backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),<br>action: () => void<br/>} <br/> | | | Text content, text color, background color, and click callback of the confirm button. | + | confirm | {<br/>value: string \| [Resource](../../ui/ts-types.md),<br>fontColor?: Color\| number \| string \| [Resource](../../ui/ts-types.md),<br/>backgroundColor?:Color \| number \| string \| [Resource](../../ui/ts-types.md),<br>action: () => void<br/>} <br/> | No | - | Text content, text color, background color, and click callback of the confirm button. | | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | - | 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. | + | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {<br/>dx: Length \| [Resource](../../ui/ts-types.md),<br/>dy: Length \| [Resource](../../ui/ts-types.md)<br/>} | No | - | Offset of the dialog box relative to the alignment position. | | gridCount | number | No | - | Number of grid columns occupied by the width of the dialog box. | - paramObject2 parameters | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | title | string \|[Resource](../../ui/ts-types.md#resource) | No | - | Title of a dialog box. | - | message | string \|[Resource](../../ui/ts-types.md#resource) | Yes | - | Content of the dialog box. | + | title | string \| [Resource](../../ui/ts-types.md) | No | - | Title of a dialog box. | + | message | string \| [Resource](../../ui/ts-types.md) | Yes | - | Content of the dialog box. | | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | - | primaryButton | {<br/>value: string \|[Resource](../../ui/ts-types.md#resource),<br>fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),<br/>backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),<br>action: () => void<br/>} <br/> | | | Text content, text color, background color, and click callback of the primary button. | - | secondaryButton | {<br/>value: string \|[Resource](../../ui/ts-types.md#resource),<br>fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),<br/>backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),<br>action: () => void<br/>} <br/> | | | Text content, text color, background color, and click callback of the secondary button. | + | primaryButton | {<br/>value: string \| [Resource](../../ui/ts-types.md),<br>fontColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md),<br/>backgroundColor?:Color \| number\| string\| [Resource](../../ui/ts-types.md),<br>action: () => void<br/>} <br/> | No | - | Text content, text color, background color, and click callback of the primary button. | + | secondaryButton | {<br/>value: string \|[Resource](../../ui/ts-types.md),<br>fontColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md),<br/>backgroundColor?:Color \| number\| string\| [Resource](../../ui/ts-types.md),<br>action: () => void<br/>} <br/> | No | - | Text content, text color, background color, and click callback of the secondary button. | | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | - | 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. | + | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {<br/>dx: Length \| [Resource](../../ui/ts-types.md),<br/>dy: Length \| [Resource](../../ui/ts-types.md)<br/>} | No | - | Offset of the dialog box relative to the alignment position. | | gridCount | number | No | - | Number of grid columns occupied by the width of the dialog box. | ## Example -``` +```ts +// xxx.ets @Entry @Component struct AlertDialogExample { diff --git a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md index 67d034e063b70c2447d488356a8b75094e516426..410181d6801fb0a478419b90f7c5e3659ab5715a 100644 --- a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md @@ -1,12 +1,12 @@ # Motion Path Animation +You can apply a motion path animation to a component, by setting the motion path of the component in a translation animation. > **NOTE** > > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The attributes below can be used to set the motion path of the component in a translation animation. ## Attributes @@ -19,7 +19,8 @@ The attributes below can be used to set the motion path of the component in a tr ## Example -``` +```ts +// xxx.ets @Entry @Component struct MotionPathExample { diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md index 4c39157590da1869b95471dea321cd72fbd212fe..0ebc3483be4382bf5d48644fe1e4cedd397a406b 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -1,21 +1,20 @@ # Transition of Shared Elements +Shared element transition can be used for transition between pages, for example, transition from an image on the current page to the next page. > **NOTE** +> > This animationis supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -Transition of shared elements can be used for transition between pages, for example, transition from an image on the current page to the next page. - - -## Type +## Attributes | Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | | sharedTransition | id: string,<br/>options?: Object | - | If the same ID is configured for a component on the two pages, this shared component is transited. If this parameter is set to an empty string, no shared elements are transited. | - options parameters - | Name | Type | Default Value | Mandatory | Description | + | Name | Type | Default Value | Mandatory | Description | | -------- | -------- | -------- | -------- | -------- | | duration | number | 1000 | No | Animation duration, in ms. The default duration is 1000 ms. | | curve | Curve \| Curves | Linear | No | The default curve is linear. For details about the valid values, see **Curve enums**. | diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 160187ab4a3dfce60d7284b42692f6946e488de6..2d898fce4e7f38e51709bd983a6d8092219f5809 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -1,13 +1,12 @@ # Background +You can set the background of a component. ->  **NOTE** +> **NOTE** +> > This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The attributes in this topic are used to set the background color of a component. - - ## Required Permissions None @@ -18,24 +17,25 @@ None | Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| backgroundColor | Color | - | Background color of a component. | -| backgroundImage | src: string,<br/>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat-enums) | - | **src**: image address, which can be the address of an Internet or a local image. (SVG images are not supported.)<br/>**repeat**: whether the background image is repeatedly used. By default, the background image is not repeatedly used. | +| backgroundColor | [ResourceColor](../../ui/ts-types.md) | - | Background color of a component. | +| backgroundImage | src: [ResourceStr](../../ui/ts-types.md),<br/>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat-enums) | - | **src**: image address, which can be the address of an Internet or a local image. (SVG images are not supported.)<br/>**repeat**: whether the background image is repeatedly used. By default, the background image is not repeatedly used. | | backgroundImageSize | {<br/>width?: Length,<br/>height?: Length<br/>} \| ImageSize | Auto | Width and height of the background image. When the input is a **{width: Length, height: Length}** object, if only one attribute is set, the other attribute is the set value multiplied by the original aspect ratio of the image. By default, the original image aspect ratio remains unchanged. | | backgroundImagePosition | {<br/>x?: Length,<br/>y?: Length<br/>} \| [Alignment](ts-appendix-enums.md#alignment-enums) | {<br/>x: 0,<br/>y: 0<br/>} | Position of the background image in the component. | - ImageSize enums - | Name | Description | + | Name | Description | | -------- | -------- | - | Cover | Default value. The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | - | Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | - | Auto | The original image aspect ratio is retained. | + | Cover | Default value. The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | + | Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | + | Auto | The original image aspect ratio is retained. | ## Example -``` +```ts +// xxx.ets @Entry @Component struct BackgroundExample { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md new file mode 100644 index 0000000000000000000000000000000000000000..99d6a8384c15983023fde9b5de43de530aa678fc --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md @@ -0,0 +1,95 @@ +# Border Image +You can draw an image around a component. +> **NOTE** +> +> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. +## Required Permissions + +None + + +## Attributes + + +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| source | string \| [Resource](../../ui/ts-types.md) \| [linearGradient](ts-universal-attributes-gradient-color.md) | - | Source or gradient color of the border image.| +| slice | Length \| EdgeWidth | 0 | Slice width of the border image.| +| width | Length \| EdgeWidth | 0 | Width of the border image.| +| outset | Length \| EdgeWidth | 0 | Amount by which the border image is extended beyond the border box.| +| RepeatMode | RepeatMode | RepeatMode.Stretch | Repeat mode of the border image.| +| fill | boolean | false | Whether to fill the center of the border image. | +- EdgeWidth + + At least one parameter must be passed to reference an **EdgeWidth** object. + | Name| Type| Mandatory| Default Value |Description| + | -------- | -------- |-------- |-------- |-------- | + | left | Length | No| 0 | Distance on the left.| + | right | Length | No| 0 | Distance on the right.| + | top | Length | No| 0 | Distance at the top.| + | bottom | Length | No| 0 | Distance on the bottom.| +- RepeatMode + | Name| Description| + | -------- | -------- | + | Repeat | The source image's slices are tiled. Tiles beyond the border box will be clipped.| + | Stretch | The source image's slices stretched to fill the border box.| + | Round | The source image's slices are tiled to fill the border box. Tiles may be compressed when needed.| + | Space | The source image's slices are tiled to fill the border box. Extra space will be filled in between tiles.| + +## Example + +```ts +// xxx.ets +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('This is\nborderImage.').textAlign(TextAlign.Center) + .borderImage({ + source: "borderOrigin.png", + slice: {top:"31%", bottom:"31%", left:"31%", right:"31%"}, + width: {top:"20px", bottom:"20px", left:"20px", right:"20px"}, + outset: {top:"5px", bottom:"5px", left:"5px", right:"5px"}, + repeat: RepeatMode.Repeat, + fill: false + }); + } + .width('100%') + } + .height('100%') + } +} +``` + + + + +```ts +// xxx.ets +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('This is\ngradient color.').textAlign(TextAlign.Center) + .borderImage({ + source: {angle:90, + direction: GradientDirection.Left, + colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]]}, + slice: {top:10, bottom:10, left:10, right:10}, + width: {top:"10px", bottom:"10px", left: "10px", right:"10px"}, + repeat: RepeatMode.Stretch, + fill: false + }); + } + .width('100%') + } + .height('100%') + } +} +``` + + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md index f530a14d3a73a1fbd35503c2b6198bb48b77543f..f37f499e123b4b282ed24136951cece34446b314 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md @@ -1,16 +1,20 @@ # Border -You can set border styles for components. > **NOTE** > > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > > The border of a component is displayed above the content of its child components since API version 9. + +You can set border styles for components. + + ## Required Permissions None + ## Attributes @@ -27,11 +31,25 @@ None | -------- | -------- | -------- | -------- | -------- | | width | [Length](../../ui/ts-types.md) | 0 | No| Border width.| | color | [ResourceColor](../../ui/ts-types.md) | 'Black' | No| Border color.| - | radius | [Length](../../ui/ts-types.md) | 0 | No| Border radius.| + | radius | [Length](../../ui/ts-types.md)\| EdgeRadiuses<sup>9+</sup> | 0 | No| Border radius.| | style | BorderStyle | BorderStyle.Solid | No| Border style.| +- EdgeRadiuses<sup>9+</sup> + + To reference this object, at least one parameter must be passed. + + | Name | Type| Mandatory| Default Value| Description | + | ----------- | -------- | ---- | ------ | ---------------- | + | topLeft | length | No | 0 | Radius of the upper-left rounded corner.| + | topRight | length | No | 0 | Radius of the upper-right rounded corner.| + | bottomLeft | length | No | 0 | Radius of the lower-left rounded corner.| + | bottomRight | length | No | 0 | Radius of the lower-right rounded corner.| + + + - BorderStyle enums + | Name| Description| | -------- | -------- | | Dotted | Dotted border. The radius of a dot is half of **borderWidth**.| @@ -52,6 +70,10 @@ struct BorderExample { Text('dashed') .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10) .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + Text('dashed') + .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE) + .borderRadius({ topLeft: 10, topRight: 20, bottomLeft: 30, bottomRight: 60 }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) // Dotted border Text('dotted') .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted }) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md index 4e27ab2eb1aaf983c0128787925377339d67ad3e..d049ce9afe2f55887fd50d445ae950f14850f200 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md @@ -1,8 +1,10 @@ # Component ID +**id** identifies a component uniquely within an application. This module provides APIs for obtaining the attributes of or sending events to the component with the specified ID. ->  **NOTE** -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. +> **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. ## Required Permissions @@ -12,93 +14,250 @@ None ## Attributes - | Name | Type | Default Value | Description | +| Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| id | string | '' | Unique ID of the component. The uniqueness is ensured by the user. | +| id | string | '' | Unique ID you assigned to the component.| ## APIs -### getInspectorByKey +### getInspectorByKey<sup>9+</sup> getInspectorByKey(id: string): string Obtains all attributes of the component with the specified ID, excluding the information about child components. - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | id | string | Yes | - | ID of the component whose attributes are to be obtained. | + | id | string | Yes| - | ID of the component whose attributes are to be obtained.| - Return value - | Type | Description | + | Type| Description| | -------- | -------- | - | string | JSON string of the component attribute list. | + | string | JSON string of the component attribute list.| +### getInspectorTree<sup>9+</sup> -### sendEventByKey +getInspectorTree(): string + +Obtains the component tree and component attributes. + +- Return value + + | Type | Description | + | ------ | ---------------------------------- | + | string | JSON string of the component tree and component attribute list.| + +### sendEventByKey<sup>9+</sup> sendEventByKey(id: string, action: number, params: string): boolean Sends an event to the component with the specified ID. - Parameters - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | id | string | Yes | - | ID of the component for which the event is to be sent. | - | action | number | Yes | - | Type of the event to be sent. The options are as follows:<br/>- Click event: 10.<br/>- LongClick: 11. | - | params | string | Yes | - | Event parameters. If there is no parameter, pass an empty string **""**. | + | id | string | Yes| - | ID of the component to which the event is to be sent.| + | action | number | Yes| - | Type of the event to be sent. The options are as follows:<br>- **10**: click event.<br>- **11**: long-click event.| + | params | string | Yes| - | Event parameters. If there is no parameter, pass an empty string **""**.| - Return value - | Type | Description | + | Type| Description| | -------- | -------- | - | boolean | Returns **false** if the component with the specified ID cannot be found; returns **true** otherwise. | + | boolean | Returns **true** if the component with the specified ID is found; returns **false** otherwise.| + +### sendTouchEvent<sup>9+</sup> + +sendTouchEvent(event: TouchObject): boolean + +Sends a touch event. + +- Parameters + + | Name | Type | Mandatory| Default Value| Description | + | ----- | ----------- | ---- | ------ | ------------------------------------------------------------ | + | event | TouchObject | Yes | - | Location where a touch event is triggered. For details, see [TouchEvent](ts-universal-events-touch.md#touchevent).| + +- Return value + + | Type | Description | + | ------- | ------------------------------------------- | + | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.| + +### sendKeyEvent<sup>9+</sup> + +sendKeyEvent(event: KeyEvent): boolean + +Sends a key event. + +- Parameters + + | Name | Type | Mandatory| Default Value| Description | + | ----- | -------- | ---- | ------ | ------------------------------------------------------------ | + | event | KeyEvent | Yes | - | Key event. For details, see [KeyEvent](ts-universal-events-key.md#keyevent).| + +- Return value + + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.| + +### sendMouseEvent<sup>9+</sup> + +sendMouseEvent(event: MouseEvent): boolean + +Sends a mouse event. + +- Parameters + + | Name | Type | Mandatory| Default Value| Description | + | ----- | ---------- | ---- | ------ | ------------------------------------------------------------ | + | event | MouseEvent | Yes | - | Mouse event. For details, see [MouseEvent](ts-universal-mouse-key.md#mouseevent).| + +- Return value + | Type | Description | + | ------- | --------------------------------------------- | + | boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.| ## Example - -``` +```ts +// xxx.ets +class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } +} + @Entry @Component struct IdExample { + @State text: string = '' + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { - Text('click') - .fontSize(25) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }).onClick(() => { + Text('onKeyTab').fontSize(25).fontWeight(FontWeight.Bold) + }.margin({ top: 20 }).backgroundColor('#0D9FFB') + .onKeyEvent(() => { + this.text = "onKeyTab" + }) + + Button() { + Text('click to start').fontSize(25).fontWeight(FontWeight.Bold) + }.margin({ top: 20 }) + .onClick(() => { console.info(getInspectorByKey("click")) console.info(getInspectorTree()) + this.text = "Button 'click to start' is clicked" setTimeout(() => { - sendEventByKey("longclick", 11, "") + sendEventByKey("longClick", 11, "") }, 2000) }).id('click') Button() { - Text('longclick') - .fontSize(25) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') + Text('longClick').fontSize(25).fontWeight(FontWeight.Bold) + }.margin({ top: 20 }).backgroundColor('#0D9FFB') .gesture( - LongPressGesture().onActionEnd(() => { - console.info('long clicked') - })) - .id('longclick') + LongPressGesture().onActionEnd(() => { + console.info('long clicked') + this.text = "Button 'longClick' is longclicked" + setTimeout(() => { + let rect = Utils.getComponentRect('onTouch') + let touchPoint: TouchObject = { + id: 1, + x: rect.left + (rect.right - rect.left) / 2, + y: rect.top + (rect.bottom - rect.top) / 2, + type: TouchType.Down, + screenX: rect.left + (rect.right - rect.left) / 2, + screenY: rect.left + (rect.right - rect.left) / 2, + } + sendTouchEvent(touchPoint) + touchPoint.type = TouchType.Up + sendTouchEvent(touchPoint) + }, 2000) + })).id('longClick') + + Button() { + Text('onTouch').fontSize(25).fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule).margin({ top: 20 }) + .onClick(() => { + console.info('onTouch is clicked') + this.text = "Button 'onTouch' is clicked" + setTimeout(() => { + let rect = Utils.getComponentRect('onMouse') + let mouseEvent: MouseEvent = { + button: MouseButton.Left, + action: MouseAction.Press, + x: rect.left + (rect.right - rect.left) / 2, + y: rect.top + (rect.bottom - rect.top) / 2, + screenX: rect.left + (rect.right - rect.left) / 2, + screenY: rect.top + (rect.bottom - rect.top) / 2, + timestamp: 1, + target: { + area: { + width: 1, + height: 1, + position: { + x: 1, + y: 1 + }, + globalPosition: { + x: 1, + y: 1 + } + } + }, + source: SourceType.Mouse + } + sendMouseEvent(mouseEvent) + }, 2000) + }).id('onTouch') + + Button() { + Text('onMouse').fontSize(25).fontWeight(FontWeight.Bold) + }.margin({ top: 20 }).backgroundColor('#0D9FFB') + .onMouse(() => { + console.info('onMouse') + this.text = "Button 'onMouse' in onMouse" + setTimeout(() => { + let keyEvent: KeyEvent = { + type: KeyType.Down, + keyCode: 2049, + keyText: 'tab', + keySource: 4, + deviceId: 0, + metaKey: 0, + timestamp: 0 + } + sendKeyEvent(keyEvent) + }, 2000) + }).id('onMouse') + + Text(this.text).fontSize(25).padding(15) } - .width('100%') - .height('100%') + .width('100%').height('100%') } } ``` diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index abba7c987d32cb45c0fe1513c0d8adeb02a7cc33..934cb61fd75f6508e22d0f10c88507c1ce9c01bc 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -1,7 +1,9 @@ # Gradient Color +Create a more gorgeous look for a component by applying a gradient color effect to it. ->  **NOTE** +> **NOTE** +> > This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -15,31 +17,32 @@ None | Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| linearGradient | {<br/>angle?: [Angle](../../ui/ts-types.md),<br/>direction?:GradientDirection,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | Linear gradient.<br/>**angle**: angle of the linear gradient.<br/>**direction**: direction of the linear gradient.<br/>**colors**: description of the gradient colors.<br/>**repeating**: whether the colors are repeated. | +| linearGradient | {<br/>angle?: [Angle](../../ui/ts-types.md),<br/>direction?:GradientDirection,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | Linear gradient.<br/>**angle**: angle of the linear gradient.<br/>**direction**: direction of the linear gradient. It does not take effect when **angle** is set.<br/>**colors**: description of the gradient colors.<br/>**repeating**: whether the colors are repeated. | | sweepGradient | {<br/>center: Point,<br/>start?: angle,<br/>end?: angle,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | Angle gradient.<br/>**center**: center point of the angle gradient.<br/>**start**: start point of the angle gradient.<br/>**end**: end point of the angle gradient.<br/>**colors**: description of the gradient colors.<br/>**repeating**: whether the colors are repeated. | | radialGradient | {<br/>center: Point,<br/>radius: Length,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating: boolean<br/>} | - | Radial gradient.<br/>**center**: center point of the radial gradient.<br/>**radius**: radius of the radial gradient.<br/>**colors**: description of the gradient colors.<br/>**repeating**: whether the colors are repeated. | +- GradientDirection -- GradientDirection enums - **GradientDirection** is used to describe the gradient direction. + Enumerates the gradient directions. - | Name | Description | + | Name | Description | | -------- | -------- | - | Left | The gradient direction is from right to left. | - | Top | The gradient direction is from bottom to top. | - | Right | The gradient direction is from left to right. | - | Bottom | The gradient direction is from top to bottom. | - | LeftTop | The gradient direction is upper left. | - | LeftBottom | The gradient direction is lower left. | - | RightTop | The gradient direction is upper right. | - | RightBottom | The gradient direction is lower right. | - | None | No gradient. | + | Left | The gradient direction is from right to left. | + | Top | The gradient direction is from bottom to top. | + | Right | The gradient direction is from left to right. | + | Bottom | The gradient direction is from top to bottom. | + | LeftTop | The gradient direction is upper left. | + | LeftBottom | The gradient direction is lower left. | + | RightTop | The gradient direction is upper right. | + | RightBottom | The gradient direction is lower right. | + | None | No gradient. | ## Example -``` +```ts +// xxx.ets @Entry @Component struct ColorGradientExample { @@ -51,7 +54,6 @@ struct ColorGradientExample { .height(50) .linearGradient({ angle: 90, - direction: GradientDirection.Left, colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]] }) Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index d37d1d1f1421a570c749484e59fd3f9ef9883952..d322c63560b3fc012d6dd089b6bf7227e7ee8fea 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -1,7 +1,10 @@ # Menu Control ->  **NOTE** -> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +This module provides APIs for binding a menu – a vertical list of items – to a component. This menu is displayed by long-pressing, clicking, or right-clicking the component. + +> **NOTE** +> +> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -12,29 +15,30 @@ None ## Attributes -| Name | Type | Default Value | Description | -| ---------------------------- | ---------------------------------------- | ------------- | ---------------------------------------- | -| bindMenu | Array<MenuItem> \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu bound to the component, which is displayed when you click the component. Textual and custom menu items are supported. | -| bindContextMenu<sup>8+</sup> | content: [CustomBuilder](../../ui/ts-types.md)<br>responseType: ResponseType | - | Context menu bound to the component, which is displayed when you long-press or right-click the component. Only custom menu items are supported. | +| Name | Type | Default Value | Description | +| ---------------------------- | ---------------------------------------- | ---- | ---------------------------------- | +| bindMenu | Array<MenuItem> \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu bound to the component, which is displayed when you click the component. Textual and custom menu items are supported.| +| bindContextMenu<sup>8+</sup> | content: [CustomBuilder](../../ui/ts-types.md),<br>responseType: ResponseType | - | Context menu bound to the component, which is displayed when you long-press or right-click the component. Only custom menu items are supported. | - MenuItem - | Name | Type | Description | - | ------ | ------------- | ---------------------------------------- | - | value | string | Menu item text. | - | action | () => void | Action triggered when a menu item is clicked. | + | Name | Type | Description | + | ------ | ----------------------- | ----------- | + | value | string | Menu item text. | + | action | () => void | Action triggered when a menu item is clicked.| - ResponseType<sup>8+</sup> - | Value | Description | - | ---------- | ---------------------------------------- | - | LongPress | The menu is displayed when the component is long-pressed. | - | RightClick | The menu is displayed when the component is right-clicked. | + | Value | Description | + | ---------- | ------------- | + | LongPress | The menu is displayed when the component is long-pressed. | + | RightClick | The menu is displayed when the component is right-clicked.| ## Example #### Menu with Textual Menu Items -``` +```ts +// xxx.ets @Entry @Component struct MenuExample { @@ -66,7 +70,8 @@ struct MenuExample { #### Menu with Custom Menu Items -``` +```ts +// xxx.ets import router from '@system.router'; @Entry @@ -116,7 +121,8 @@ struct MenuExample { #### Context Menu (Displayed Upon Right-Clicking) -``` +```ts +// xxx.ets @Entry @Component struct ContextMenuExample { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index 03c5ded62399d33dbc21e73048585e98b5a937ad..8f9d11414c869b9222137b212d56a590feb017d4 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -1,11 +1,12 @@ # Opacity ->  **NOTE** +> **NOTE** +> > This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The attributes described in this topic are used to set the opacity of a component. +You can set the opacity of a component. ## Required Permissions @@ -16,15 +17,16 @@ None ## Attributes - | Name | Type | Default Value | Description | +| Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| opacity | number | 1 | Opacity of a component. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | +| opacity | number \| [Resource](../../ui/ts-types.md) | 1 | Opacity of a component. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | ## Example - -``` + +```ts +// xxx.ets @Entry @Component struct OpacityExample { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 9d801b2503cc4225907879d5eba7596c120db3b6..5be81d94fdc351f56722eb6a106ca5c0157b658e 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -1,8 +1,10 @@ # Popup Control +The popup attribute defines the popup displayed when a component is clicked. ->  **NOTE** -> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -13,48 +15,52 @@ None ## Attributes -| Name | Type | Default Value | Description | +| Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| bindPopup | show: boolean,<br/>popup: PopupOptions \| CustomPopupOptions | - | Settings of the popup bound to a component.<br/>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br/>**popup**: parameters of the current popup. | +| bindPopup | show: boolean,<br>popup: PopupOptions \| CustomPopupOptions | - | Settings of the popup bound to a component.<br>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br>**popup**: parameters of the popup.| -- PopupOptions attributes - | Name | Type | Mandatory | Default Value | Description | +- PopupOptions + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | message | string | Yes | - | Content of the popup message. | - | placementOnTop | boolean | No | false | Whether to display the popup above the component. The default value is **false**. | - | primaryButton | {<br/>value: string,<br/>action: () => void<br/>} | No | - | First button.<br/>**value**: text of the primary button in the popup.<br/>**action**: callback function for clicking the primary button. | - | secondaryButton | {<br/>value: string,<br/>action: () => void<br/>} | No | - | Second button.<br/>**value**: text of the secondary button in the popup.<br/>**action**: callback function for clicking the secondary button. | - | onStateChange | (isVisible: boolean) => void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | + | message | string | Yes| - | Content of the popup message.| + | placementOnTop | boolean | No| false | Whether to display the popup above the component. The default value is **false**.| + | primaryButton | {<br>value: string,<br>action: () => void<br>} | No| - | Primary button.<br>**value**: text of the primary button in the popup.<br>**action**: callback for clicking the primary button.| + | secondaryButton | {<br>value: string,<br>action: () => void<br>} | No| - | Secondary button.<br>**value**: text of the secondary button in the popup.<br>**action**: callback for clicking the secondary button.| + | onStateChange | (isVisible: boolean) => void | No| - | Callback for the popup status change event. The parameter **isVisible** indicates whether the popup is visible.| - CustomPopupOptions<sup>8+</sup> - | Name | Type | Mandatory | Default Value | Description | + | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | - | builder | () => any | Yes | - | Builder of the tooltip content. | - | placement | Placement | No | Placement.Bottom | Preferred position of the tooltip component. If the set position is insufficient for holding the component, it will be automatically adjusted. | - | maskColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip mask. | - | popupColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip. | - | enableArrow | boolean | No | true | Whether to display arrows. Arrows are displayed only for tooltips in the up and down directions. | - | autoCancel | boolean | No | true | Whether to automatically close the tooltip when an operation is performed on the page. | - | onStateChange | (isVisible: boolean) => void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | + | builder | () => any | Yes| - | Builder of the popup content.| + | placement | Placement | No| Placement.Bottom | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.| + | maskColor | [ResourceColor](../../ui/ts-types.md) | No| - | Color of the popup mask.| + | popupColor | [ResourceColor](../../ui/ts-types.md) | No| - | Color of the popup.| + | enableArrow | boolean | No| true | Whether to display an arrow.<br>Since API version 9, if the location set for the arrow is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left** and the popup height is less than the arrow width (32 vp), the arrow will not be displayed.| + | autoCancel | boolean | No| true | Whether to automatically close the popup when an operation is performed on the page.| + | onStateChange | (isVisible: boolean) => void | No| - | Callback for the popup status change event. The parameter **isVisible** indicates whether the popup is visible.| - Placement<sup>8+</sup> enums - | Name | Description | + | Name| Description| | -------- | -------- | - | Left | The tooltip is on the left of the component. | - | Right | The tooltip is on the right of the component. | - | Top | The tooltip is on the top of the component. | - | Bottom | The tooltip is at the bottom of the component. | - | TopLeft | The tooltip is in the upper left corner of the component. | - | TopRight | The tooltip is in the upper right corner of the component. | - | BottomLeft | The tooltip is in the lower left corner of the component. | - | BottomRight | The tooltip is in the lower right corner of the component. | + | Left | The popup is on the left of the component, vertically aligned with the component on the left.| + | Right | The popup is on the right of the component, vertically aligned with the component on the right.| + | Top | The popup is at the top of the component, horizontally aligned with the component at the top.| + | Bottom | The popup is at the bottom of the component, horizontally aligned with the component at the bottom.| + | TopLeft | The popup is at the top of the component and, since API version 9, aligned with the left of the component.| + | TopRight | The popup is at the top of the component and, since API version 9, aligned with the right of the component.| + | BottomLeft | The popup is at the bottom of the component and, since API version 9, aligned with the left of the component.| + | BottomRight | The popup is at the bottom of the component and, since API version 9, aligned with the right of the component.| + | LeftTop<sup>9+</sup> | The popup is on the left of the component and aligned with the top of the component.| + | LeftBottom<sup>9+</sup> | The popup is on the left of the component and aligned with the bottom of the component.| + | RightTop<sup>9+</sup> | The popup is on the right of the component and aligned with the top of the component.| + | RightBottom<sup>9+</sup> | The popup is on the right of the component and aligned with the bottom of the component.| ## Example - -``` +```ts +// xxx.ets @Entry @Component struct PopupExample { @@ -65,7 +71,7 @@ struct PopupExample { @Builder popupBuilder() { Row({ space: 2 }) { Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 }) - Text('Custom Popup').fontSize(12) + Text('Custom Popup').fontSize(10) }.width(100).height(50).backgroundColor(Color.White) } diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md index e0468dfe5e7d39816efc9e8a6c10a08a3412321c..8fe71bfe50f7c85128ee538c02ff8e63d2a6fda9 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md @@ -1,7 +1,8 @@ # Shape Clipping ->  **NOTE** +> **NOTE** +> > This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -13,16 +14,17 @@ None ## Attributes - | Name | Type | Default Value | Description | +| Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| clip | Shape \| boolean | false | Specifies a clip mode. The value **Shape** indicates that the current component is cropped based on the specified shape. The value **boolean** specifies whether to clip the component based on the edge outline. | -| mask | Shape | - | Adds a mask of the specified shape to the current component. | +| clip | Shape \| boolean | false | Clip mode. The value **Shape** indicates that the current component is cropped based on the specified shape. The value **boolean** specifies whether to clip the component based on the edge outline. | +| mask | Shape | - | Mask of the specified shape for the current component. | ## Example - -``` + +```ts +// xxx.ets @Entry @Component struct ClipAndMaskExample { @@ -30,24 +32,24 @@ struct ClipAndMaskExample { Column({ space: 5 }) { Text('clip').fontSize(9).width('90%').fontColor(0xCCCCCC) // Clip the image by using a circle with a diameter of 280px. - Image('/comment/bg.jpg') + Image($r('app.media.example')) .clip(new Circle({ width: 80, height: 80 })) .width('500px').height('280px') Row() { - Image('/comment/bg.jpg').width('500px').height('280px') + Image($r('app.media.example')).width('500px').height('280px') } .clip(true) .borderRadius(20) Text('mask').fontSize(9).width('90%').fontColor(0xCCCCCC) // Add a 500 px x 280 px mask to the image. - Image('/comment/bg.jpg') + Image($r('app.media.example')) .mask(new Rect({ width: '500px', height: '280px' }).fill(Color.Gray)) .width('500px').height('280px') // Add a 280 px x 280 px circle mask to the image. - Image('/comment/bg.jpg') + Image($r('app.media.example')) .mask(new Circle({ width: '280px', height: '280px' }).fill(Color.Gray)) .width('500px').height('281px') } diff --git a/en/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md b/en/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md new file mode 100644 index 0000000000000000000000000000000000000000..578c036839453f869b190c89331efe0a81122555 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md @@ -0,0 +1,121 @@ +# Visible Area Change Event + +The visible area change event of a component refers to the change in the visual portion of a component on the screen. It can be used to determine whether the component is completely or partially displayed on the screen. It is usually applicable to scenarios such as advertisement exposure tracing. + +> **NOTE** +> +> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + + +## Events + +| Name| Description| +| -------- | -------- | +| onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | Called when the visual area of the component changes.<br>- **ratios**: threshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen) to the component's total area. This callback is invoked when the ratio of the component's visible area to its total area is greater than or less than the threshold. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value **0.0** or **1.0** will be used.<br>- **isVisible**: indicates whether the ratio of the component's visible area to its total area is greater than the threshold. The value **true** means that the ratio is greater than the threshold, and **false** means that the ratio is less than the threshold.<br>- **currentRatio**: ratio of the component's visible area to its total area when this callback is invoked.| + + +## Example + +```ts +// xxx.ets +@Entry +@Component +struct ScrollExample { + scroller: Scroller = new Scroller() + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State testTextStr: string = "test" + @State testRowStr: string = "test" + + build() { + Column() { + Column() { + Text(this.testTextStr) + .fontSize(20) + + Text(this.testRowStr) + .fontSize(20) + } + .height(100) + .backgroundColor(Color.Gray) + .opacity(0.3) + + Scroll(this.scroller) { + Column() { + Text("Test Text Visible Change") + .fontSize(20) + .height(200) + .margin({ top: 50, bottom: 20 }) + .backgroundColor(Color.Green) + // Set ratios to [0.0, 1.0] to invoke the callback when the component is fully visible or invisible on screen. + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { + console.info("Test Text isVisible: " + isVisible + ", currentRatio:" + currentRatio) + if (isVisible && currentRatio >= 1.0) { + console.info("Test Text is fully visible. currentRatio:" + currentRatio) + this.testTextStr = "Test Text is fully visible" + } + + if (!isVisible && currentRatio <= 0.0) { + console.info("Test Text is completely invisible.") + this.testTextStr = "Test Text is completely invisible" + } + }) + + Row() { + Text("Test Row Visible Change") + .fontSize(20) + .margin({ bottom: 20 }) + + } + .height(200) + .backgroundColor(Color.Yellow) + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { + console.info("Test Row isVisible:" + isVisible + ", currentRatio:" + currentRatio) + if (isVisible && currentRatio >= 1.0) { + console.info("Test Row is fully visible.") + this.testRowStr = "Test Row is fully visible" + } + + if (!isVisible && currentRatio <= 0.0) { + console.info("Test Row is is completely invisible.") + this.testRowStr = "Test Row is is completely invisible" + } + }) + + ForEach(this.arr, (item) => { + Text(item.toString()) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, item => item) + + }.width('100%') + } + .backgroundColor(0x317aff) + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.On) + .scrollBarColor(Color.Gray) + .scrollBarWidth(30) + .onScroll((xOffset: number, yOffset: number) => { + console.info(xOffset + ' ' + yOffset) + }) + .onScrollEdge((side: Edge) => { + console.info('To the edge') + }) + .onScrollEnd(() => { + console.info('Scroll Stop') + }) + + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} +``` + + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md index 086a32f23befd0ce05d6f925ce99c9216b7c738b..cc1d167f4d0ab24526632050ac5f8c63f0cd4e00 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -1,10 +1,11 @@ # Click Event +A click event is triggered when a component is clicked. -> **NOTE**<br> +> **NOTE** +> > This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - ## Required Permissions None @@ -12,12 +13,12 @@ None ## Events -| Name | Bubble Supported | Description | +| Name | Bubbling Supported | Description | | -------- | -------- | -------- | | onClick(callback: (event?: ClickEvent) => void) | No | Called when a click event occurs. For details about the event parameters, see [ClickEvent](#clickevent). | -### ClickEvent +## ClickEvent | Name | Type | Description | | -------- | -------- | -------- | @@ -25,30 +26,30 @@ None | screenY | number | Y coordinate of the click relative to the upper edge of the screen. | | x | number | X coordinate of the click relative to the left edge of the component being clicked. | | y | number | Y coordinate of the click relative to the upper edge of the component being clicked. | -| target<sup>8+</sup> | EventTarget | Target element that is clicked. | +| target<sup>8+</sup> | [EventTarget](#eventtarget8) | Target element that is clicked. | | timestamp | number | Timestamp of the event. | -- EventTarget<sup>8+</sup> attributes +## EventTarget<sup>8+</sup> - | Name | Type | Description | - | -------- | -------- | -------- | - | area | Area | Area information of the target element.| +| Name | Type | Description | +| -------- | -------- | -------- | +| area | [Area](#area8) | Area information of the target element.| -- Area<sup>8+</sup> attributes +## Area<sup>8+</sup> - | Name | Type | Description | - | -------- | -------- | -------- | - | width | number | Width of the target element, in vp. | - | height | number | Height of the target element, in vp. | - | position | Position | Position of the upper left corner of the target element relative to that of the parent element. | - | globalPosition | Position | Position of the upper left corner of the target element relative to that of the page. | +| Name | Type | Description | +| -------- | -------- | -------- | +| width | number | Width of the target element, in vp. | +| height | number | Height of the target element, in vp. | +| position | [Position](#position8) | Position of the upper left corner of the target element relative to that of the parent element. | +| globalPosition | [Position](#position8) | Position of the upper left corner of the target element relative to that of the page. | -- Position<sup>8+</sup> attributes +## Position<sup>8+</sup> - | Name | Type | Description | - | -------- | -------- | -------- | - | x | number | X-coordinate, in vp. | - | y | number | Y-coordinate, in vp. | +| Name | Type | Description | +| -------- | -------- | -------- | +| x | number | X-coordinate, in vp. | +| y | number | Y-coordinate, in vp. | ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index a08f165f89dd50aeb15d582710a0cbfa58d1baca..be73b9cfd5f7484201fe44544d5d440e35786693 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -1,30 +1,31 @@ -# Drag/Drop Event +# Drag Event +A drag event is triggered when a component is dragged. > **NOTE** > > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Events -| Name | Bubble Supported | Description | +| Name | Bubbling Supported | Description | | -------- | -------- | -------- | -| onDragStart(callback: (event: DragEvent, extraParams?: string) =>\|[Custom Builder](../../ui/ts-types.md)) | No | Triggered when the component bound to the event is dragged for the first time.<br/>-**event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>-**extraParams**: additional information about the drag event. For details, see extraParam.<br/>Return value: object being dragged, which is used for prompts displayed when the object is dragged.<br/>**NOTE**<br/>> - A drag event can be triggered by a 150 ms long press.<br/>> - If the duration of a long-press gesture is set to less than or equal to 150 ms, the callback for the long-press gesture takes precedence. Otherwise, the callback for the drag event takes precedence. | -| onDragEnter(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item enters a valid drop target.<br/>-**event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>-**extraParams**: additional information about the drag event. For details, see extraParam.<br/>**NOTE**<br/>This event is valid only when the **onDrop** event is listened to. | -| onDragMove(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item moves in a valid drop target.<br/>-**event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>-**extraParams**: additional information about the drag event. For details, see extraParam.<br/>**NOTE**<br/>This event is valid only when the **onDrop** event is listened to. | -| onDragLeave(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item leaves a valid drop target.<br/>-**event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>-**extraParams**: additional information about the drag event. For details, see extraParam.<br/>**NOTE**<br/>This event is valid only when the **onDrop** event is listened to. | -| onDrop(callback: (event:DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item is dropped on a valid drop target.<br/>-**event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>-**extraParams**: additional information about the drag event. For details, see extraParam. | +| onDragStart(callback: (event: DragEvent, extraParams?: string) =>\|[Custom Builder](../../ui/ts-types.md)) | No | Triggered when the component bound to the event is dragged for the first time.<br/>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>- **extraParams**: additional information about the drag event. For details, see **extraParam**.<br/>Return value: object being dragged, which is used for prompts displayed when the object is dragged.<br/>A drag event can be triggered by a 150 ms long press.<br/>If the duration of a long-press gesture is set to less than or equal to 150 ms, the callback for the long-press gesture takes precedence. Otherwise, the callback for the drag event takes precedence. | +| onDragEnter(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item enters a valid drop target.<br/>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>- **extraParams**: additional information about the drag event. For details, see **extraParam**.<br/>This event is valid only when the **onDrop** event is listened to. | +| onDragMove(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item moves in a valid drop target.<br/>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>- **extraParams**: additional information about the drag event. For details, see **extraParam**.<br/>This event is valid only when the **onDrop** event is listened to. | +| onDragLeave(callback: (event: DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item leaves a valid drop target.<br/>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>- **extraParams**: additional information about the drag event. For details, see **extraParam**.<br/>This event is valid only when the **onDrop** event is listened to. | +| onDrop(callback: (event:DragEvent, extraParams?: string) => void) | No | Triggered when the dragged item is dropped on a valid drop target.<br/>- **event**: information about the drag event, including the coordinates of the item that is being dragged.<br/>- **extraParams**: additional information about the drag event. For details, see **extraParam**. | - extraParam + Returns additional information required for dragging an item. - + **extraParam** is a string converted from a JSON object. You can obtain the following attributes using the JSON object converted from **Json.parse**. | Name | Type | Description | | -------- | -------- | -------- | - | selectedIndex | number | Index of the dragged item in the parent container. The value of **selectedindex** starts from **0**.<br/>**NOTE**<br/>This attribute is valid only in the **ListItem** component. | - | insertIndex | number | Index of the element into which the dragged item is dropped in the **List** component. The value of **insertIndex** starts from **0**.<br/>**NOTE**<br/>This attribute is valid only in the drag event of the **List** component. | + | selectedIndex | number | Index of the dragged item in the parent container. The value of **selectedIndex** starts from **0**.<br/>This attribute is valid only in the **\<ListItem>** component. | + | insertIndex | number | Index of the element into which the dragged item is dropped in the **List** component. The value of **insertIndex** starts from **0**.<br/>This attribute is valid only in the drag event of the **\<List>** component. | ### DragEvent diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md index ca5694f8efd070b2ed5eab223f44474b03a54bb5..77f563ad5781a1acbd502023a4be8d2e965247a8 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -1,8 +1,10 @@ # Key Event +A key event is triggered when a component interacts with a keyboard, remote control, or any other input device with keys. ->  **NOTE** -> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Required Permissions @@ -12,58 +14,61 @@ None ## Events -| Name | Bubble Supported | Description | +| Name | Bubbling Supported | Description | | -------- | -------- | -------- | -| onKeyEvent(event: (event?: KeyEvent) => void) | Yes | Called when a key event occurs. For details about the event parameters, see [KeyEvent Object](#KeyEvent Object). | +| onKeyEvent(event: (event?: KeyEvent) => void) | Yes | Called when a key event occurs. For details about **event**, see [KeyEvent](#keyevent). | -### KeyEvent Object +## KeyEvent - Attributes - | Name | Type | Description | + | Name | Type | Description | | -------- | -------- | -------- | - | type | KeyType | Type of a key. | - | keyCode | number | Key code. | - | keyText | string | Key value. | - | keySource | KeySource | Type of the input device that triggers the key event. | - | deviceId | number | ID of the input device that triggers the key event. | - | metaKey | number | State of the metakey when the key is pressed. The value **1** means the pressed state, and **0** means the unpressed state. | - | timestamp | number | Timestamp when the key is pressed. | + | type | [KeyType](#keytype-enums) | Type of a key. | + | keyCode | number | Key code. | + | keyText | string | Key value. | + | keySource | [KeySource](#keysource-enums) | Type of the input device that triggers the key event. | + | deviceId | number | ID of the input device that triggers the key event. | + | metaKey | number | State of the metakey when the key is pressed. The value **1** means the pressed state, and **0** means the unpressed state. | + | timestamp | number | Timestamp when the key is pressed. | - APIs - | Name | Description | + | Name | Description | | -------- | -------- | - | stopPropagation(): void | Stops the event from bubbling upwards or downwards. | + | stopPropagation(): void | Stops the event from bubbling upwards or downwards. | -- KeyType enums - | Name | Description | - | -------- | -------- | - | Down | The key is pressed. | - | Up | The key is released. | +## KeyType Enums +| Name | Description | +| -------- | -------- | +| Down | The key is pressed. | +| Up | The key is released. | -- KeySource enums - | Name | Description | - | -------- | -------- | - | Unknown | Unknown input device. | - | Keyboard | The input device is a keyboard. | -- Common KeyCode description - | Value | Behavior | Physical Button | - | -------- | -------- | -------- | - | 19 | Upward | Up button. | - | 20 | Downward | Down button. | - | 21 | Leftward | Left button. | - | 22 | Rightward | Right button. | - | 23 | OK | **OK** key on a remote control. | - | 66 | OK | **Enter** key on a keyboard. | - | 160 | OK | **Enter** button on the numeric keypad. | +## KeySource Enums +| Name | Description | +| -------- | -------- | +| Unknown | Unknown input device. | +| [KeyCode](#common-keycode-enums) | The input device is a keyboard. | + +## Common KeyCode Enums + +| Value | Behavior | Physical Button | +| -------- | -------- | -------- | +| 19 | Upward | Up button. | +| 20 | Downward | Down button. | +| 21 | Leftward | Left button. | +| 22 | Rightward | Right button. | +| 23 | OK | **OK** key on a remote control. | +| 66 | OK | **Enter** key on a keyboard. | +| 160 | OK | **Enter** button on the numeric keypad. | ## Example -``` +```ts +// xxx.ets @Entry @Component struct KeyEventExample { diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md index ea64017630aeb9e7b8ffaa5960a2d18ab9839fa2..58833a25b0ee0a8aa36c37c81c9a31d0954d0bf3 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -1,7 +1,9 @@ # Touch Event +A touch event is triggered when a finger is pressed, slides, or is lifted from a component. -> **NOTE**<br> +> **NOTE** +> > This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -12,51 +14,51 @@ None ## Events -| Name | Pop-up | Description | -| -------- | -------- | -------- | -| onTouch(callback: (event?: TouchEvent) => void) | Yes | Invoked when a touch action is triggered. For details about the event parameters, see [TouchEvent](#touchevent). | +| Name | Bubbling Supported| Description | +| ---------------------------------------- | ---- | ---------------------------------------- | +| onTouch(callback: (event?: TouchEvent) => void) | Yes | Invoked when a touch action is triggered. For details about **event**, see [TouchEvent](#touchevent).| -### TouchEvent +## TouchEvent - Attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | type | TouchType | Type of a touch event. | - | touches | Array<TouchObject> | All finger information. | - | changedTouches | Array<TouchObject> | Finger information changed. | - | timestamp | number | Timestamp of the event. | - | target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md) | Target of the event. | + | Name | Type | Description | + | ------------------- | ---------------------------------------- | ------------ | + | type | TouchType | Type of the touch event. | + | touches | Array<[TouchObject](#touchobject)> | All finger information. | + | changedTouches | Array<[TouchObject](#touchobject)> | Finger information changed.| + | timestamp | number | Timestamp of the event. | + | target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8) | Target of the event. | + - APIs - | Name | Description | - | -------- | -------- | - | stopPropagation(): void | Pop-up of the stop event. | + | Name | Description | + | ---------------------- | ------- | + | stopPropagation(): void| Stops the event from bubbling upwards or downwards.| -- TouchObject - | Name | Type | Description | - | -------- | -------- | -------- | - | type | TouchType | Type of a touch event. | - | id | number | Unique identifier of a finger. | - | screenX | number | X coordinate of the touch point relative to the left edge of the screen. | - | screenY | number | Y coordinate of the touch point relative to the upper edge of the device screen. | - | x | number | X coordinate of the touch point relative to the left edge of the element to touch. | - | y | number | Y coordinate of the touch point relative to the upper edge of the element to touch. | +## TouchObject +| Name | Type | Description | +| ------- | --------------------------- | ------------------- | +| type | [TouchType](#touchtype-enums) | Type of the touch event. | +| id | number | Unique identifier of a finger. | +| screenX | number | X-coordinate of the touch point relative to the left edge of the screen. | +| screenY | number | Y-coordinate of the touch point relative to the upper edge of the device screen. | +| x | number | X-coordinate of the touch point relative to the left edge of the element being touched. | +| y | number | Y-coordinate of the touch point relative to the upper edge of the element being touched. | -- TouchType - | Name | Description | - | -------- | -------- | - | Down | Trigger a touch event when a finger is pressed. | - | Up | Trigger a touch event when a finger is lifted. | - | Move | Trigger a touch event when a finger moves on the screen in pressed state. | - | Cancel | Trigger an event when a touch event is canceled. | +## TouchType Enums +| Name | Description | +| ------ | --------------- | +| Down | A finger is pressed. | +| Up | A finger is lifted. | +| Move | A finger moves on the screen in pressed state.| +| Cancel | A touch event is canceled. | ## Example - ```ts // xxx.ets @Entry diff --git a/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md index c7a488006883bf0c32f4693025f41ce7d659b2df..4174d6b266df6c9988aba4224ddabaed16dc7faf 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -1,7 +1,9 @@ # Mouse Event +If an action triggers multiple events, the order of these events is fixed. By default, mouse events are transmitted transparently. ->  **NOTE** +> **NOTE** +> > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. @@ -12,48 +14,47 @@ None ## Events - | Name | Bubble Supported | Description | +| Name | Bubbling Supported | Description | | -------- | -------- | -------- | -| onHover(callback: (isHover: boolean) => void) | No | Triggered when the mouse cursor enters or leaves the component.<br/>**isHover**: whether the mouse cursor hovers over the component. The value **true** means that the mouse cursor enters the component, and the value **false** means that the mouse cursor leaves the component. | -| onMouse(callback: (event?: MouseEvent) => void) | Yes | Triggered when the component is clicked by a mouse button or the mouse cursor moves on the component. The **event** parameter indicates the timestamp, mouse button, action, coordinates of the clicked point on the entire screen, and coordinates of the clicked point relative to the component when the event is triggered. | - - -### MouseEvent - -- Attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | timestamp | number | Timestamp when the event is triggered. | - | screenX | number | X-coordinate of the clicked point relative to the upper left corner of the screen. | - | screenY | number | Y-coordinate of the clicked point relative to the upper left corner of the screen. | - | x | number | X-coordinate of the clicked point relative to the upper left corner of the component. | - | y | number | Y-coordinate of the clicked point relative to the upper left corner of the component. | - | button | MouseButton | Mouse button. | - | action | MouseAction | Event action. | - - -- MouseButton attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | Left | number | Left mouse button. | - | Right | number | Right mouse button. | - | Middle | number | Middle mouse button. | - | Back | number | Back button on the left of the mouse. | - | Forward | number | Forward button on the left of the mouse. | - | None | number | No button. | - -- MouseAction attributes - | Name | Type | Description | - | -------- | -------- | -------- | - | Press | number | The mouse button is pressed. | - | Release | number | The mouse button is released. | - | Move | number | The mouse cursor moves. | +| onHover(callback: (isHover: boolean) => void) | No | Triggered when the mouse cursor enters or leaves the component.<br/>**isHover**: whether the mouse cursor hovers over the component. The value **true** means that the mouse cursor enters the component, and the value **false** means that the mouse cursor leaves the component. | +| onMouse(callback: (event?: MouseEvent) => void) | Yes | Triggered when the component is clicked by a mouse button or the mouse cursor moves on the component. The **event** parameter indicates the timestamp, mouse button, action, coordinates of the clicked point on the entire screen, and coordinates of the clicked point relative to the component when the event is triggered. | + + +## MouseEvent + +| Name | Type | Description | +| -------- | -------- | -------- | +| timestamp | number | Timestamp when the event is triggered. | +| screenX | number | X-coordinate of the clicked point relative to the upper left corner of the screen. | +| screenY | number | Y-coordinate of the clicked point relative to the upper left corner of the screen. | +| x | number | X-coordinate of the clicked point relative to the upper left corner of the component. | +| y | number | Y-coordinate of the clicked point relative to the upper left corner of the component. | +| button | [MouseButton](#mousebutton) | Mouse button. | +| action | [MouseAction](#mouseaction) | Event action. | + +## MouseButton +| Name | Type | Description | +| -------- | -------- | -------- | +| Left | number | Left mouse button. | +| Right | number | Right mouse button. | +| Middle | number | Middle mouse button. | +| Back | number | Back button on the left of the mouse. | +| Forward | number | Forward button on the left of the mouse. | +| None | number | No button. | + +## MouseAction +| Name | Type | Description | +| -------- | -------- | -------- | +| Press | number | The mouse button is pressed. | +| Release | number | The mouse button is released. | +| Move | number | The mouse cursor moves. | ## Example - -``` + +```ts +// xxx.ets @Entry @Component struct MouseEventExample { diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index 0eefcc9175b85437a425d73dd9c7759adf649674..f6ef8fc8ba202071cfa01c1f559e35d4654e5230 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -24,9 +24,13 @@ The table below lists only the API used in this guide. For more information, see ## Declaring Permissions -### config.json +Declare the permissions required by the app one by one in the project configuration file. The app cannot obtain the permissions that are not declared in the configuration file. The ability framework provides two models: Feature Ability (FA) model and stage model. For more information, see [Ability Framework Overview](../ability/ability-brief.md). -Declare the permissions required by the app one by one in the **config.json** file. The app can obtain permissions that have been declared in the **config.json** file. +Note that the app bundle structure and configuration file vary with the ability framework model. + +### FA Model + +For the apps based on the FA model, declare the required permissions in the **config.json** file. **Description of config.json** @@ -40,6 +44,41 @@ Declare the permissions required by the app one by one in the **config.json** fi **Example** +```json +{ + "module" : { + "reqPermissions":[ + { + "name" : "ohos.permission.PERMISSION1", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when":"inuse" + } + }, + { + "name" : "ohos.permission.PERMISSION2", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when":"always" + } + } + ], + } +} +``` + +### Stage Model + +For the apps based on the stage model, declare the required permissions in the **module.json5** file. + +**Example** + ```json { "module" : { @@ -68,11 +107,12 @@ Declare the permissions required by the app one by one in the **config.json** fi } } ``` + ## Declaring the ACL The permission level of **ohos.permission.PERMISSION2** is **system_basic**, which is higher than the app's APL. In this case, use the ACL. -In addition to declaring all the permissions in the **config.json** file, you must declare the permissions whose levels are higher than the app's APL in the app's [profile](../quick-start/app-provision-structure.md). In this example, declare the permission under the **acls** field: +In addition to declaring all the permissions in the configuration file, you must declare the permissions whose levels are higher than the app's APL in the app's [profile](../quick-start/app-provision-structure.md). In this example, declare the permission under the **acls** field: ```json { "version-name": "1.0.0", diff --git a/en/application-dev/security/accesstoken-overview.md b/en/application-dev/security/accesstoken-overview.md index f4241cadfe3ccb2e42d6ee1ccebcd3c61598fa28..4537e67fa429ba019ae00074e2dc55c283b690e8 100644 --- a/en/application-dev/security/accesstoken-overview.md +++ b/en/application-dev/security/accesstoken-overview.md @@ -1,6 +1,5 @@ # Access Control Overview -## 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. 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. @@ -12,9 +11,9 @@ App permissions are used to protect the following objects: 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. +Currently, ATM verifies app permissions 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. -## How to Develop +## Permission Workflow Determine the permissions required for an app to access data or perform an operation. Declare the required permissions in the app installation package. @@ -22,12 +21,34 @@ Determine whether the required permissions need to be authorized by users. If ye After the user grants permissions to the app, the app can access the data or perform the operation. -The figure below shows the process. +The figure below shows the permission workflow.  +1. Refer to the figure below for the process of applying for app permissions. + + + +1. For details about the mapping between the application Ability Privilege Level (APL) and permission level, see [Permission Levels](#permission-levels). + +2. The permission authorization modes include user_grant (permission granted by the user) and system_grant (permission granted by the system). For details, see [Permission Authorization Modes](#permission-authorization-mode). + +3. A low-level app can have a high-level permission by using the Access Control List (ACL). For details, see [ACL](#acl). + ## When to Use +### Basic Principles + +Observe the following principles for permission management: + +- 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 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 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](permission-list.md). Custom permissions are not allowed for apps currently. + ### Scenarios The following describes two common scenarios. @@ -46,25 +67,13 @@ The following describes two common scenarios. 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 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 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 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. - ## Permission Levels To protect user privacy, ATM defines different permission levels based on the sensitivity of the data involved or the security threat of the ability. -### App APL +### App APLs -The ability privilege level (APL) defines the priority of the app permission requested. Apps of different APLs can apply for permissions of different levels. +The APL defines the priority of the app permission requested. Apps of different APLs can apply for permissions of different levels. The table below describes the APLs. @@ -78,7 +87,7 @@ 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 +### Levels of Permissions The permissions open to apps vary with the permission level. The permission levels include the following in ascending order of seniority. @@ -100,33 +109,6 @@ The permissions open to apps vary with the permission level. The permission leve The permissions of this type are not open to any app currently. -### ACL - -As described above, permission levels and app APLs are in one-to-one correspondence. In principle, **an app with a lower APL cannot apply for higher permissions by default**. - -The Access Control List (ACL) makes low-level apps have high-level permissions. - -**Example** - -The APL of app A is normal. App A needs to have permission B (system_basic level) and permission C (normal level). - -In this case, you can use the ACL to grant permission B to app A. - -For details, see [Using the ACL](#using-the-acl). -For details about whether the ACL is enabled for a permission, see [Permission List](permission-list.md). - -### Using the ACL - -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 must declare the ACL. - -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#declaring-the-acl). The subsequent steps of authorization are the same. - -**NOTE** - -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 Authorization Modes Permissions can be classified into the following types based on the authorization mode: @@ -151,15 +133,15 @@ Permissions can be classified into the following types based on the authorizatio 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. +- For a system_grant permission, you need to [declare the permission](accesstoken-guidelines.md#declaring-permissions) in the configuration file. The permission will be pre-granted when the app is installed. -- For a user_grant permission, you need to [declare the permission](accesstoken-guidelines.md) in the **config.json** file, and a dialog box needs to be displayed to request user authorization during the running of the app. +- For a user_grant permission, you need to [declare the permission](accesstoken-guidelines.md#declaring-permissions) in the configuration file and trigger user authorization through a dialog box during the running of the app. ### Permission Authorization Process (user_grant) The procedure is as follows: -1. In the **config.json** file, declare the permissions required by the app. For details, see [Access Control Development](accesstoken-guidelines.md). +1. In the configuration file, declare the permissions required by the app. For details, see [Access Control Development](accesstoken-guidelines.md). 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. @@ -170,7 +152,33 @@ The procedure is as follows: **Precautions** - 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). - 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. + +## ACL + +As described above, permission levels and app APLs are in one-to-one correspondence. In principle, **an app with a lower APL cannot apply for higher permissions by default**. + +The ACL makes low-level apps have high-level permissions. + +**Example** + +The APL of app A is normal. App A needs to have permission B (system_basic level) and permission C (normal level). + +In this case, you can use the ACL to grant permission B to app A. + +For details, see [Using the ACL](#using-the-acl). +For details about whether a permission can be enabled through the ACL, see the [Permission List](permission-list.md). + +### Using the ACL + +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 must declare the ACL. + +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#declaring-the-acl). The subsequent steps of authorization are the same. + +**NOTE** + +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). diff --git a/en/application-dev/security/figures/permission-workflow.png b/en/application-dev/security/figures/permission-workflow.png index 03d329c575e822c92f0dc4b9d0323e1a90405073..db44f9d26d422c2eff640ca123a4d2ede0b91b72 100644 Binary files a/en/application-dev/security/figures/permission-workflow.png and b/en/application-dev/security/figures/permission-workflow.png differ diff --git a/en/application-dev/security/permission-list.md b/en/application-dev/security/permission-list.md index 0d9fc7021fe8972192d01483183e8237f0174b35..9578c8d43b2a216171ec36c2f5056600d4e3ab9f 100644 --- a/en/application-dev/security/permission-list.md +++ b/en/application-dev/security/permission-list.md @@ -1,14 +1,8 @@ # Permission List -On the basis of the [principles for app permission management](accesstoken-overview.md#basic-principles), apply for permissions for an app by following the procedure illustrated in the figure below. +Before applying for required permissions, read and understand the [permission workflow](accesstoken-overview.md#permission-workflow). Then, determine whether the app can apply for the target permissions based on the table below. - - -1. For details about the mapping between the app's ability privilege level (APL) and permission level, see [Permission Levels](accesstoken-overview.md#permission-levels). -2. Permissions can be authorized by the user (user_grant) or the system (system_grant). For details, see [Permission Authorization Modes](accesstoken-overview.md#permission-authorization-modes). -3. In principle, an app with a lower APL cannot apply for higher permissions by default. The Access Control List (ACL) makes low-level apps have high-level permissions. For details, see [ACL](accesstoken-overview.md#acl). - -The following lists the permissions defined by the system. For details about permission usage examples, see [Access Control Development](accesstoken-guidelines.md). +For details about permission usage examples, see [Access Control Development](accesstoken-guidelines.md). | Permission | APL | Authorization Mode | Enable ACL| Description | | -------------------------------------------------------- | ------------ | ------------ | ------- | ------------------------------------------------------------ | @@ -26,10 +20,7 @@ The following lists the permissions defined by the system. For details about per | 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. | @@ -106,7 +97,7 @@ The following lists the permissions defined by the system. For details about per | 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.PERMISSION_USED_STATS | system_basic | 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-powered 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. | @@ -136,3 +127,7 @@ The following lists the permissions defined by the system. For details about per | 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. | | ohos.permission.ACCESS_IDS | system_core | system_grant | TRUE | Allows an app to query the unique identifier of a device. | +| ohos.permission.DUMP | system_core | system_grant | TRUE | Allows the basic system information and SA service information to be exported. | +| ohos.permission.DISTRIBUTED_SOFTBUS_CENTER | system_basic | system_grant | FALSE | Allows networking between different devices. | +| ohos.permission.ACCESS_DLP_FILE | system_core | system_grant | TRUE | Allows configuration and management of the permissions on .dlp files. | +| ohos.permission.PROVISIONING_MESSAGE | system_core | system_grant | TRUE | Allows activiation of the Super Device Manager application. | diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index acc4bd0613c1741db03277fffecce33195c592df..ffe375386fc9f02537b5d522ecb4df6dade55f5e 100644 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -1,6 +1,79 @@ # UI Development - [ArkUI Overview](arkui-overview.md) +- TypeScript-based Declarative Development Paradigm + - [Overview](ui-ts-overview.md) + - Framework Overview + - File Organization + - [Directory Structure](ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) + - ["js" Tag](ts-framework-js-tag.md) + - Resource Management + - [Resource File Categories](ui-ts-basic-resource-file-categories.md) + - [Accessing Resources](ts-resource-access.md) + - [Pixel Units](ts-pixel-units.md) + - [Types](ts-types.md) + - Declarative Syntax + - [Overview](ts-syntax-intro.md) + - General UI Description Specifications + - [Basic Concepts](ts-general-ui-concepts.md) + - Declarative UI Description Specifications + - [Configuration Without Parameters](ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) + + - [Attribute Configuration](ts-attribution-configuration.md) + - [Event Configuration](ts-event-configuration.md) + - [Child Component Configuration](ts-child-component-configuration.md) + - Componentization + - [@Component](ts-component-based-component.md) + - [@Entry](ts-component-based-entry.md) + - [@Preview](ts-component-based-preview.md) + - [@Builder](ts-component-based-builder.md) + - [@Extend](ts-component-based-extend.md) + - [@CustomDialog](ts-component-based-customdialog.md) + - [@Styles](ts-component-based-styles.md) + - About UI State Management + - [Basic Concepts](ts-ui-state-mgmt-concepts.md) + - Managing Component States + - [@State](ts-component-states-state.md) + - [@Prop](ts-component-states-prop.md) + - [@Link](ts-component-states-link.md) + - Managing Application States + - [AppStorage](ts-application-states-appstorage.md) + - [LocalStorage](ui-ts-local-storage.md) + - [PersistentStorage](ts-application-states-apis-persistentstorage.md) + - [Environment](ts-application-states-apis-environment.md) + - Managing Other States + - [@Observed and @ObjectLink](ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ts-other-states-consume-provide.md) + - [@Watch](ts-other-states-watch.md) + - About Rendering Control Syntax + - [if/else](ts-rending-control-syntax-if-else.md) + - [ForEach](ts-rending-control-syntax-foreach.md) + - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) + - About @Component + - [build Function](ts-function-build.md) + - [Initialization of Custom Components' Member Variables](ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) + - [Component Creation and Re-initialization](ts-component-creation-re-initialization.md) + - [About Syntactic Sugar](ts-syntactic-sugar.md) + - Common Component Development Guidelines + - [Button](ui-ts-basic-components-button.md) + - [Web](ui-ts-components-web.md) + - Common Layout Development Guidelines + - [Flex Layout](ui-ts-layout-flex.md) + - [Grid Layout](ui-ts-layout-grid-container.md) + - [Media Query](ui-ts-layout-mediaquery.md) + - Experiencing the Declarative UI + - [Creating a Declarative UI Project](ui-ts-creating-project.md) + - [Getting to Know Components](ui-ts-components.md) + - [Creating a Simple Page](ui-ts-creating-simple-page.md) + - Defining Page Layout and Connection + - [Building a Food Data Model](ui-ts-building-data-model.md) + - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) + - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) + - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) + - JavaScript-based Web-like Development Paradigm - [Overview](ui-js-overview.md) - Framework @@ -73,74 +146,3 @@ - [Animation Effect](ui-js-animate-dynamic-effects.md) - [Animation Frame](ui-js-animate-frame.md) - [Custom Components](ui-js-custom-components.md) -- TypeScript-based Declarative Development Paradigm - - [Overview](ui-ts-overview.md) - - Framework Overview - - File Organization - - [Directory Structure](ts-framework-directory.md) - - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) - - ["js" Tag](ts-framework-js-tag.md) - - Resource Access - - [Accessing Application Resources](ts-application-resource-access.md) - - [Accessing System Resources](ts-system-resource-access.md) - - [Media Resource Types](ts-media-resource-type.md) - - [Pixel Units](ts-pixel-units.md) - - [Types](ts-types.md) - - Declarative Syntax - - [Overview](ts-syntax-intro.md) - - General UI Description Specifications - - [Basic Concepts](ts-general-ui-concepts.md) - - Declarative UI Description Specifications - - [Configuration Without Parameters](ts-parameterless-configuration.md) - - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) - - [Attribute Configuration](ts-attribution-configuration.md) - - [Event Configuration](ts-event-configuration.md) - - [Child Component Configuration](ts-child-component-configuration.md) - - Componentization - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - [@Styles](ts-component-based-styles.md) - - About UI State Management - - [Basic Concepts](ts-ui-state-mgmt-concepts.md) - - Managing Component States - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - Managing Application States - - [AppStorage](ts-application-states-appstorage.md) - - [PersistentStorage](ts-application-states-apis-persistentstorage.md) - - [Environment](ts-application-states-apis-environment.md) - - Managing Other States - - [@Observed and @ObjectLink](ts-other-states-observed-objectlink.md) - - [@Consume and @Provide](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - About Rendering Control Syntax - - [if/else](ts-rending-control-syntax-if-else.md) - - [ForEach](ts-rending-control-syntax-foreach.md) - - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) - - About @Component - - [build Function](ts-function-build.md) - - [Initialization of Custom Components' Member Variables](ts-custom-component-initialization.md) - - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) - - [Component Creation and Re-initialization](ts-component-creation-re-initialization.md) - - [About Syntactic Sugar](ts-syntactic-sugar.md) - - Common Component Development Guidelines - - [Button](ui-ts-basic-components-button.md) - - [Web](ui-ts-components-web.md) - - Common Layout Development Guidelines - - [Flex Layout](ui-ts-layout-flex.md) - - [Grid Layout](ui-ts-layout-grid-container.md) - - [Media Query](ui-ts-layout-mediaquery.md) - - Experiencing the Declarative UI - - [Creating a Declarative UI Project](ui-ts-creating-project.md) - - [Getting to Know Components](ui-ts-components.md) - - [Creating a Simple Page](ui-ts-creating-simple-page.md) - - Defining Page Layout and Connection - - [Building a Food Data Model](ui-ts-building-data-model.md) - - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) - - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) - - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) diff --git a/en/application-dev/ui/figures/create-resource-file-1.png b/en/application-dev/ui/figures/create-resource-file-1.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d82caac558cd58b78aba3014b6ac60148f6bc8 Binary files /dev/null and b/en/application-dev/ui/figures/create-resource-file-1.png differ diff --git a/en/application-dev/ui/figures/create-resource-file-2.png b/en/application-dev/ui/figures/create-resource-file-2.png new file mode 100644 index 0000000000000000000000000000000000000000..b4d23e8dc15bafbb08ca691575ce2ea9fe989e91 Binary files /dev/null and b/en/application-dev/ui/figures/create-resource-file-2.png differ diff --git a/en/application-dev/ui/figures/create-resource-file-3.png b/en/application-dev/ui/figures/create-resource-file-3.png new file mode 100644 index 0000000000000000000000000000000000000000..566653c5e49753e1f04d0d6b5b5c3e931f4354b5 Binary files /dev/null and b/en/application-dev/ui/figures/create-resource-file-3.png differ diff --git a/en/application-dev/ui/figures/en-us_image_tab.gif b/en/application-dev/ui/figures/en-us_image_tab.gif new file mode 100644 index 0000000000000000000000000000000000000000..fde104516f23c4dcc56b3c9f54334d7ee40925a6 Binary files /dev/null and b/en/application-dev/ui/figures/en-us_image_tab.gif differ diff --git a/en/application-dev/ui/ts-application-states-appstorage.md b/en/application-dev/ui/ts-application-states-appstorage.md index 66f9e82115b072ad38370fce857bf3009ed81146..ac77b40dd5c85a7494e094b8dc698715786413f8 100644 --- a/en/application-dev/ui/ts-application-states-appstorage.md +++ b/en/application-dev/ui/ts-application-states-appstorage.md @@ -62,7 +62,7 @@ struct ComponentA { @StorageProp('languageCode') lang: string = 'en' private label: string = 'count' - private aboutToAppear() { + aboutToAppear() { this.label = (this.lang === 'en') ? 'Number' : 'Count' } diff --git a/en/application-dev/ui/ts-component-based-builder.md b/en/application-dev/ui/ts-component-based-builder.md index a07b244ffdc2bd9105102058e6881b14289fdf34..d626bde6074c5e3db373a00f3a78bf6e554cf46f 100644 --- a/en/application-dev/ui/ts-component-based-builder.md +++ b/en/application-dev/ui/ts-component-based-builder.md @@ -4,16 +4,17 @@ The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md). -``` +```ts +// xxx.ets @Entry @Component struct CompA { - size : number = 100; + size1 : number = 100; @Builder SquareText(label: string) { Text(label) - .width(1 * this.size) - .height(1 * this.size) + .width(1 * this.size1) + .height(1 * this.size1) } @Builder RowOfSquareTexts(label1: string, label2: string) { @@ -21,8 +22,8 @@ struct CompA { this.SquareText(label1) this.SquareText(label2) } - .width(2 * this.size) - .height(1 * this.size) + .width(2 * this.size1) + .height(1 * this.size1) } build() { @@ -32,12 +33,12 @@ struct CompA { this.SquareText("B") // or as long as tsc is used } - .width(2 * this.size) - .height(1 * this.size) + .width(2 * this.size1) + .height(1 * this.size1) this.RowOfSquareTexts("C", "D") } - .width(2 * this.size) - .height(2 * this.size) + .width(2 * this.size1) + .height(2 * this.size1) } } ``` @@ -51,7 +52,8 @@ In certain circumstances, you may need to add a specific function, such as a cli ### Component Initialization Through Parameters When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`). -``` +```ts +// xxx.ets @Component struct CustomContainer { header: string = ""; @@ -100,7 +102,8 @@ struct CustomContainerUser { In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute. Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**. -``` +```ts +// xxx.ets @Component struct CustomContainer { header: string = ""; diff --git a/en/application-dev/ui/ts-component-based-component.md b/en/application-dev/ui/ts-component-based-component.md index f247caa2887a59cdbb96e33ba23f22f7ed3137de..ad484fb9561da9cee1b4a57825c1228a8ee2c092 100644 --- a/en/application-dev/ui/ts-component-based-component.md +++ b/en/application-dev/ui/ts-component-based-component.md @@ -13,16 +13,17 @@ A struct decorated by @Component has the componentization capability and can ser - Data-driven update: The UI of custom components can be automatically updated based on the data of state variables. -For details about componentization, see [About @Component](ts-function-build.md). +For details about componentization, see [About @Component](ts-custom-component-initialization.md). ->  **NOTE**: -> - The build method must be defined for a custom component. -> +> **NOTE** +> +> - The **build** method must be defined for a custom component. +> > - Custom constructors are prohibited for custom components. -The following code illustrates how to create a custom component named MyComponent: +The following code illustrates how to create a custom component named **MyComponent**: ``` @Component @@ -37,10 +38,10 @@ struct MyComponent { ``` -The build method of MyComponent is executed during initial rendering. When the component status changes, the build method will be executed again. +The **build** method of **MyComponent** is executed during initial rendering. When the component status changes, the build method will be executed again. -The following code illustrates how to use MyComponent: +The following code illustrates how to use **MyComponent**: ``` @Component @@ -55,8 +56,7 @@ struct ParentComponent { } ``` - -MyComponent can be applied multiple times and reused in different components, as shown in the code below: +**MyComponent** can be applied multiple times and reused in different components, as shown in the code below: ``` @Component @@ -76,11 +76,11 @@ struct ParentComponent { } } - private aboutToAppear() { + aboutToAppear() { console.log('ParentComponent: Just created, about to become rendered first time.') } - private aboutToDisappear() { + aboutToDisappear() { console.log('ParentComponent: About to be removed from the UI.') } } diff --git a/en/application-dev/ui/ts-custom-component-initialization.md b/en/application-dev/ui/ts-custom-component-initialization.md index 2dcb83e536762e8ca424a346c1132bcc2380fefd..9c68e81b41aeac32ff00f545a70df3f69c64fcd4 100644 --- a/en/application-dev/ui/ts-custom-component-initialization.md +++ b/en/application-dev/ui/ts-custom-component-initialization.md @@ -6,14 +6,14 @@ The member variables of a component can be initialized in either of the followin - Local initialization. For example: - ``` + ```ts @State counter: Counter = new Counter() ``` - Initialization using constructor parameters. For example: - ``` - MyComponent(counter: $myCounter) + ```ts + MyComponent({counter: $myCounter}) ``` @@ -73,43 +73,57 @@ As indicated by the preceding table: ## Example -``` +```ts +// xxx.ets +class ClassA { + public a:number + constructor(a: number) { + this.a = a + } +} @Entry @Component struct Parent { - @State parentState: ClassA = new ClassA() - build() { - Row() { - CompA({aState: new ClassA, aLink: $parentState}) // valid - CompA({aLink: $parentState}) // valid - CompA() // invalid, @Link aLink remains uninitialized - CompA({aLink: new ClassA}) // invalid, @Link aLink must be a reference ($) to either @State or @Link variable - } + @State parentState: ClassA = new ClassA(1) + + build() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aState: new ClassA(2), aLink: $parentState }) + } + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aLink: $parentState }) + } + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aState: new ClassA(3), aLink: $parentState }) + } } + } } @Component struct CompA { - @State aState: boolean = false // must initialize locally - @Link aLink: ClassA // must not initialize locally - - build() { - Row() { - CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, - bProp: this.aState}) // valid init a @Prop with value of a @State - CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean - bProp: false}) // valid init a @Prop by constants value - } + @State aState: any = false + @Link aLink: ClassA + + build() { + Column() { + CompB({ bLink: $aLink, bProp: this.aState }) + CompB({ bLink: $aState, bProp: false }) } + } } @Component struct CompB { - @Link bLink: ClassA = new ClassA() // invalid, must not initialize locally - @Prop bProp: boolean = false // invalid must not initialize locally - - build() { - ... - } + @Link bLink: ClassA + @Prop bProp: boolean + + build() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Text(JSON.stringify(this.bLink.a)).fontSize(30) + Text(JSON.stringify(this.bProp)).fontSize(30).fontColor(Color.Red) + }.margin(10) + } } ``` diff --git a/en/application-dev/ui/ts-media-resource-type.md b/en/application-dev/ui/ts-media-resource-type.md deleted file mode 100644 index cd64dcc25e64e0d1b4923be2c0bd3c23ccfcad4b..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-media-resource-type.md +++ /dev/null @@ -1,21 +0,0 @@ -# Media Resource Types - - - -- Image resource types - | Format| File Name Extension| - | -------- | -------- | - | JPEG | .jpg | - | PNG | .png | - | GIF | .gif | - | SVG | .svg | - | WEBP | .webp | - | BMP | .bmp | - -- Audio and video resource types - | Format| File Name Extension| - | -------- | -------- | - | H.263 | .3gp <br>.mp4 | - | H.264 AVC <br> Baseline Profile (BP) | .3gp <br>.mp4 | - | MPEG-4 SP | .3gp | - | VP8 | .webm <br> .mkv | diff --git a/en/application-dev/ui/ts-application-resource-access.md b/en/application-dev/ui/ts-resource-access.md similarity index 57% rename from en/application-dev/ui/ts-application-resource-access.md rename to en/application-dev/ui/ts-resource-access.md index 037607029e6b842b1f4c32bf2ed2657f1dd64a94..82d53954d3fc86878a48222e449428faf1a341d1 100644 --- a/en/application-dev/ui/ts-application-resource-access.md +++ b/en/application-dev/ui/ts-resource-access.md @@ -1,61 +1,72 @@ # Accessing Application Resources -## Resource Definition +## Accessing Application Resources -Application resources are defined in the project's **resources** directory, which is organized as follows: +To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. -- Level-1: **base** sub-directory, qualifiers sub-directories, and **rawfile** sub-directory - - The **base** sub-directory is a default directory. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced. - - You need to create qualifiers sub-directories on your own. The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-). - - When the resources in the **rawfile** sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the **rawfile** sub-directory. +When referencing resources in the **rawfile** sub-directory, use the `"$rawfile('filename')"` format. Currently, **$rawfile** allows only the **\<Image>** component to reference image resources. **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash (/). -- Level-2: resource sub-directories - - Resource sub-directories store basic elements such as character strings, colors, and floating point numbers, and resource files such as media files. - - Supported files and resource types are listed in the table below. - | File Name| Resource Type| - | -------- | -------- | - | color.json | Color resource.| - | float.json | Resources such as spacing, rounded corners, and fonts.| - | string.json | String resource.| - | plural.json | String resource.| - | media directory| Image resource.| +> **NOTE** +> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined. + In the **.ets** file, you can use the resources defined in the **resources** directory. -## Referencing Resources +```ts +Text($r('app.string.string_hello')) + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} -To reference an application resource in a project, use the `"$r('app.type.name')"` format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type (or the location where the resource is stored). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. +Text($r('app.string.string_world')) + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} -When referencing resources in the **rawfile** sub-directory, use the `"$rawfile('filename')"` format. Currently, **$rawfile** allows only the **\<Image>** component to reference image resources. **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash (/). +Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} ->  **NOTE** -> Resource descriptors accept only strings, such as `'app.type.name'`, and cannot be combined. +Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter indicates the plural resource, and the second parameter indicates the number of plural resources. The third parameter indicates the substitute of %d. + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Image($r('app.media.my_background_image')) // Reference media resources. + +Image($rawfile('test.png')) // Reference an image in the rawfile directory. +Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile directory. +``` -## Example -Some custom resources in the **base** sub-directory are as follows: +## Accessing System Resources +System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. + + +To reference a system resource, use the "$r('sys.type.resource_id')" format. Wherein: sys indicates a system resource; type indicates the resource type, which can be color, float, string, or media; resource_id indicates the resource ID, which is determined when the system resource is provided. For details about available system resource IDs. + +```ts +Text('Hello') + .fontColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize($r('sys.float.ohos_id_text_size_headline1')) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) +Image($r('sys.media.ohos_app_icon')) + .border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) + .margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) + .height(200) + .width(300) ``` - resources - ├─ base - │ ├─ element - │ │ ├─ color.json - │ │ ├─ string.json - │ │ └─ float.json - │ └─ media - │ └─ my_background_image.png - └─ rawfile - ├─ test.png - └─ newDir - └─ newTest.png -``` +## Resource File Examples The content of the **color.json** file is as follows: -``` +```json { "color": [ { @@ -73,7 +84,7 @@ The content of the **color.json** file is as follows: The content of the **float.json** file is as follows: -``` +```json { "float":[ { @@ -91,7 +102,7 @@ The content of the **float.json** file is as follows: The content of the **string.json** file is as follows: -``` +```json { "string":[ { @@ -113,7 +124,7 @@ The content of the **string.json** file is as follows: The content of the **plural.json** file is as follows: -``` +```json { "plural":[ { @@ -132,40 +143,3 @@ The content of the **plural.json** file is as follows: ] } ``` - - In the **.ets** file, you can use the resources defined in the **resources** directory. - -``` -Text($r('app.string.string_hello')) - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.string.string_world')) - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter indicates the plural resource, and the second parameter indicates the number of plural resources. The third parameter indicates the substitute of %d. - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Image($r('app.media.my_background_image')) // Reference media resources. - -Image($rawfile('test.png')) // Reference an image in the rawfile directory. - -Image($rawfile('newDir/newTest.png')) // Reference an image in the rawfile directory. -``` - - -## Samples - -The following sample is provided to help you better understand how to access application resources: - -- [`ResourceManager`: eTS Resource Management (API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/ResourceManager) diff --git a/en/application-dev/ui/ts-system-resource-access.md b/en/application-dev/ui/ts-system-resource-access.md deleted file mode 100644 index 185817fe20bb30af764179facf9cc43fa740d0a4..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-system-resource-access.md +++ /dev/null @@ -1,20 +0,0 @@ -# Accessing System Resources - - -System resources include colors, rounded corners, fonts, spacing, character strings, and images. By using system resources, you can develop different applications with the same visual style. - - -To reference a system resource, use the "$r('sys.type.resource_id')" format. Wherein: sys indicates a system resource; type indicates the resource type, which can be color, float, string, or media; resource_id indicates the resource ID, which is determined when the system resource is provided. For details about available system resource IDs. - -``` -Text('Hello') - .fontColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize($r('sys.float.ohos_id_text_size_headline1')) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) -Image($r('sys.media.ohos_app_icon')) - .border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) - .margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) - .height(200) - .width(300) -``` diff --git a/en/application-dev/ui/ui-js-animate-transform.md b/en/application-dev/ui/ui-js-animate-transform.md index 3b6fe35a82a50468f5321d3d97eb98a55a3c87ff..a9b74278cc196e9150bdcd6d15983efe5bbcac12 100644 --- a/en/application-dev/ui/ui-js-animate-transform.md +++ b/en/application-dev/ui/ui-js-animate-transform.md @@ -586,16 +586,4 @@ You can set multiple transform attributes at the same time to apply different tr > > - When using the shorthand notion, note that the animation effect varies according to the sequence of the style values. > -> - The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. -## Samples - -The following samples are provided to help you better understand how to develop animations with the **transform** attribute: - -- [`JsAnimation`: Animation App (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation) -- [`JsAnimationStyle`: JS Animation and Custom Font Styles (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimationStyle) - -- [`Clock`: Clock (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock) - -- [Animation Styles (JavaScaript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo) - -- [Common Image Operations](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo) \ No newline at end of file +> - The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-component-tabs.md b/en/application-dev/ui/ui-js-component-tabs.md index 9583e28c33e486ed92bef6289ed7c43ccad364d1..fe3f9f0cf1463d5b42a7e0840c6112c957d2b53b 100644 --- a/en/application-dev/ui/ui-js-component-tabs.md +++ b/en/application-dev/ui/ui-js-component-tabs.md @@ -319,11 +319,4 @@ export default { } ``` - - - -## Samples - -The following sample is provided to help you better understand how to develop the **<tabs>** component: - -[`Tabs`: Tabs (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs) \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-canvas.md b/en/application-dev/ui/ui-js-components-canvas.md index f1d935f866c29f06ee98109bbea1adf659003995..3c6f3c174c10ac4596cd86e9fe9045991922b34a 100644 --- a/en/application-dev/ui/ui-js-components-canvas.md +++ b/en/application-dev/ui/ui-js-components-canvas.md @@ -139,10 +139,3 @@ export default { >  **NOTE**<br/> > The **<canvas>** component cannot be created in **onInit** or **onReady**. - -## Samples - -The following sample is provided to help you better understand how to develop the **\<canvas>** component: - -[`JsCanvas`: \<canvas> (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsCanvas) - diff --git a/en/application-dev/ui/ui-js-components-chart.md b/en/application-dev/ui/ui-js-components-chart.md index 9db89430bdc5ce1f214a38aaef75a058b193adcf..3d23a4f275d8701bcd398094ff2cd191526aa47f 100644 --- a/en/application-dev/ui/ui-js-components-chart.md +++ b/en/application-dev/ui/ui-js-components-chart.md @@ -615,9 +615,4 @@ export default { ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<chart>** component: - -[`Chart`: chart (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-dialog.md b/en/application-dev/ui/ui-js-components-dialog.md index c13d5ce75c14622fee913049508c71d67e6902d1..024dcf2ecdc7b175bc42a0d95dd034a964d9e324 100644 --- a/en/application-dev/ui/ui-js-components-dialog.md +++ b/en/application-dev/ui/ui-js-components-dialog.md @@ -328,9 +328,4 @@ export default { ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<dialog>** component: - -[`JsDialog`: JS Dialog Box (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-list.md b/en/application-dev/ui/ui-js-components-list.md index 8981d4f7c0f1f61bd65e50c1f10a5513837a7dd0..ee26a8b65886736e619c65defbd038e121682e12 100644 --- a/en/application-dev/ui/ui-js-components-list.md +++ b/en/application-dev/ui/ui-js-components-list.md @@ -318,9 +318,4 @@ export default { ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<list>** component: - -[`JsList`: JSList Offerings (API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsList) \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-stepper.md b/en/application-dev/ui/ui-js-components-stepper.md index caccc7f25503e11f2ac4a4da450524d7b89f052d..4ab5951f921892c6576bce38a8c9f64525967631 100644 --- a/en/application-dev/ui/ui-js-components-stepper.md +++ b/en/application-dev/ui/ui-js-components-stepper.md @@ -411,9 +411,4 @@ export default { } ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<stepper>** component: - -[`StepNavigator`: StepNavigator (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/StepNavigator) \ No newline at end of file + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-swiper.md b/en/application-dev/ui/ui-js-components-swiper.md index d240e96baa6d8d1765d9af5a506855838f483547..7a5514ed2c330c0be3882718247fc92ddf1a6c24 100644 --- a/en/application-dev/ui/ui-js-components-swiper.md +++ b/en/application-dev/ui/ui-js-components-swiper.md @@ -368,9 +368,4 @@ export default { } ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<swiper>** component: - -- [`Swiper`: Swiper (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Swiper) + \ No newline at end of file diff --git a/en/application-dev/ui/ui-js-components-text.md b/en/application-dev/ui/ui-js-components-text.md index f058773e25d50b45a0adb6a3fc1860ea1d3e480b..76a777c7ddb20c58120f25bcc6d8a4277c557142 100644 --- a/en/application-dev/ui/ui-js-components-text.md +++ b/en/application-dev/ui/ui-js-components-text.md @@ -286,9 +286,4 @@ export default { } ``` - -## Samples - -The following sample is provided to help you better understand how to develop the **<text>** component: - -- [`JsTextComponents`: JavaScript Basic Components (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsBasicComponents) + \ No newline at end of file diff --git a/en/application-dev/ui/ui-ts-basic-resource-file-categories.md b/en/application-dev/ui/ui-ts-basic-resource-file-categories.md new file mode 100644 index 0000000000000000000000000000000000000000..4187772091b33aafc9eb0cd7f4d9747757b165e1 --- /dev/null +++ b/en/application-dev/ui/ui-ts-basic-resource-file-categories.md @@ -0,0 +1,127 @@ +# Resource File Categories + + +## resources Directory + +All the application resource files, such as strings, images, and audio files, are stored in the **resources** directory, allowing you to easily access, use, and maintain them. The **resources** directory consists of two types of sub-directories: the **base** sub-directory and qualifiers sub-directories, and the **rawfile** sub-directory. For details, see Categories of the **resources** directory. + +Example of the **resources** directory: + +``` +resources +|---base // Default sub-directory +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---en_GB-vertical-car-mdpi // Example of a qualifiers sub-directory, which needs to be created on your own +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---rawfile // Default sub-directory +``` + +**Table 1** Categories of the **resources** directory + +| Category | base and Qualifiers Sub-directories | rawfile Sub-directory | +| ----------- | ---------------------------------------- | ---------------------------------------- | +| Structure | Sub-directories are structured in two levels. The directory name must comply with specified naming conventions so that its target resource file in the correct directory can be matched based on the device status.<br> The **base** sub-directory and qualifiers sub-directories are the first level of sub-directories under **resources**.<br>- The **base** sub-directory is generated by default. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced.<br>- You need to create qualifiers sub-directories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).<br>Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.<br>However, resource files in the **rawfile** sub-directory will not be matched based on the device status. | +| Compilation | Resource files in the sub-directories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | +| Reference | Resource files in the sub-directories are referenced based on the resource type and resource name. | Resource files in the sub-directories are referenced based on the specified file path and file name. | + + +## Qualifiers Sub-directories + +The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-). When creating a qualifiers sub-directory, you need to understand the directory naming conventions and the rules for matching qualifiers sub-directories and the device status. + +**Naming Conventions for Qualifiers Sub-directories** + +- Qualifiers are ordered in the following sequence: *MCC*MNC-language_script_country/region-screen orientation-device type-color mode-screen density_. You can select one or multiple qualifiers to name your sub-directory based on your application scenarios and device characteristics. + +- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. + +- Value range of qualifiers: The value of each qualifier must meet the requirements. Otherwise, the resource files in the sub-directory cannot be matched. + + **Table 2** Requirements for qualifier values + + | Qualifier Type | Description and Value Range | + | ------------------ | ---------------------------------------- | + | MCC&MNC | Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (*) in between or be used independently. For example, **mcc460** represents China, and **mcc460*mnc00** represents China Mobile.<br>For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions). | + | Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.<br>For details about the value range, refer to **ISO 639** (codes for the representation of names of languages). | + | Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, **Hans** indicates simplified Chinese and **Hant** indicates traditional Chinese.<br>For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts). | + | Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, **CN** indicates China and **GB** indicates the United Kingdom.<br>For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions). | + | Screen orientation | Indicates the screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation | + | Device type | Indicates the device type. The value can be:<br>- **car**: head units<br>- **tv**: smart TVs<br>- **wearable**: wearables | + | Color mode | Indicates the color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode | + | Screen density | Indicates the screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640]. | + +**Rules for Matching Qualifiers Sub-directories and Device Resources** + +- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density + +- If the qualifiers sub-directories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the sub-directories can be used for matching the device resources. For example, the qualifiers sub-directory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**. + + +## Resource Group Sub-directories + +You can create resource group sub-directories (including element, media, animation, layout, graphic, and profile) in the **base** and qualifiers sub-directories to store resource files of specific types. For details, see Resource group sub-directories. + +**Table 3** Resource group sub-directories + +| Resource Group Sub-directory | Description | Resource File | +| ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| element | Element resources. Each type of data is represented by a JSON file. The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integer<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data | It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.json | +| media | Media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | +| profile | Other types of files, which are stored in their raw formats. | The file name can be customized. | + +### Media Resource Types + +Table 4 Image resource types +| Format| File Name Extension| +| -------- | -------- | +| JPEG | .jpg | +| PNG | .png | +| GIF | .gif | +| SVG | .svg | +| WEBP | .webp | +| BMP | .bmp | + +Table 5 Audio and video resource types +| Format| File Name Extension| +| -------- | -------- | +| H.263 | .3gp <br>.mp4 | +| H.264 AVC <br> Baseline Profile (BP) | .3gp <br>.mp4 | +| MPEG-4 SP | .3gp | +| VP8 | .webm <br> .mkv | +## Creating a Resource File + +You can create a sub-directory and its files under the **resources** directory based on the above descriptions of the qualifiers sub-directories and resource group sub-directories. + +DevEco Studio provides a wizard for you to create resource directories and resource files. + +- Creating a Resource Directory and Resource File + + Right-click the **resources** directory and choose **New > Resource File**. + + If no qualifier is selected, the file is created in a resource type sub-directory under **base**. If one or more qualifiers are selected, the system automatically generates a sub-directory and creates the file in this sub-directory. + + The created sub-directory is automatically named in the format of **Qualifiers.Resource type**. For example, if you create a sub-directory by setting **Orientation** to **Vertical** and **Resource type** to **Graphic**, the system automatically generates a sub-directory named **vertical.graphic**. + +  + +- Creating a Resource Directory + + Right-click the **resources** directory and choose **New > Resource Directory**. This operation creates a sub-directory only. + + Select a resource group type and set qualifiers. Then the system automatically generates the sub-directory name. The sub-directory is automatically named in the format of **Qualifiers.Resource group**. For example, if you create a sub-directory by setting **Orientation** to **Vertical** and **Resource type** to **Graphic**, the system automatically generates a sub-directory named **vertical.graphic**. + +  + +- Creating a Resource File + + Right-click a sub-directory under **resources** and choose **New > XXX Resource File**. This operation creates a resource file under this sub-directory. + + For example, you can create an element resource file in the **element** sub-directory. + +  diff --git a/en/application-dev/ui/ui-ts-creating-simple-page.md b/en/application-dev/ui/ui-ts-creating-simple-page.md index 4e9ee4b92152eade3066c4a79cb328cf8b998a57..6c934f4c56b2c66f59d746fc1752e4acf24131bf 100644 --- a/en/application-dev/ui/ui-ts-creating-simple-page.md +++ b/en/application-dev/ui/ui-ts-creating-simple-page.md @@ -7,7 +7,8 @@ In this section, we will develop an infographic food details page, by building c ## Building the Stack Layout 1. Create a food name. - Delete the code of the build method in the project template, create a <Stack> component, and place the **\<Text>** component in the braces of the **\<Stack>** component so that the <Text> component becomes a child component of the <Stack> component. A **\<Stack>** component consists of one or more child components. The latter child component overwrites the former one. + + Delete the code of the **build** method in the project template, create a **\<Stack>** component, and place the **\<Text>** component in the braces of the **\<Stack>** component. When the **\<Stack>** component contains multiple child components, the latter child component overwrites the former one. ``` @Entry @@ -23,10 +24,11 @@ In this section, we will develop an infographic food details page, by building c } ``` -  + 2. Display food pictures. - Create an **\<Image>** component and specify a URL for it. The **\<Image>** and **\<Text>** components are mandatory. To display the **\<Text>** component above the **\<Image>** component, you need to declare the **\<Image>** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\<Image>** component to reference image resources. + + Create an **\<Image>** component and specify a URL for it. The **\<Image>** and **\<Text>** components are mandatory. To display the **\<Text>** component above the **\<Image>** component, you need to declare the **\<Image>** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where **filename** indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\<Image>** component to reference image resources. ``` @Entry @@ -46,9 +48,10 @@ In this section, we will develop an infographic food details page, by building c  3. Access images through resources. - In addition to specifying the image path, you can also use the media resource symbol $r to reference resources based on the resource qualifier rules in the resources folder. Right-click the resources folder, choose **New** > **Resource Directory**, and set **Resource Type** to **Media (image resource)**. Place Tomato.png in the media folder. - You can then can reference the application resource in the ` "$r('app.type.name')"` format, that is, `$r('app.media.Tomato')`. + In addition to specifying the image path, you can also use the media resource symbol `$r` to reference resources in the **resources** folder based on the resource qualifier rules. Right-click the **resources** folder, choose **New** > **Resource Directory**, and set **Resource Type** to **Media (image resource)**. + + Place **Tomato.png** in the **media** folder. You can then can reference the application resource in the `$r('app.type.name')` format, that is, `$r('app.media.Tomato')`. ``` @@ -68,30 +71,31 @@ In this section, we will develop an infographic food details page, by building c } ``` -4. Set the width and height of the image, and set the objectFit attribute of the image to ImageFit.Contain, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary.If the image fills the entire screen, the possible causes are as follows: +4. Set the width and height of the image, and set the **objectFit** attribute of the image to **ImageFit.Contain**, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary. If the image fills the entire screen, the possible causes are as follows: + 1. The width and height of the image are not set. 2. The default attribute of **objectFit** of the image is **ImageFit.Cover**, that is, the image is zoomed in or zoomed out to fill the entire display boundary with the aspect ratio locked. - - ``` - @Entry - @Component - struct MyComponent { - build() { - Stack() { - Image($r('app.media.Tomato')) - .objectFit(ImageFit.Contain) - .height(357) - Text('Tomato') - .fontSize(26) - .fontWeight(500) + + ``` + @Entry + @Component + struct MyComponent { + build() { + Stack() { + Image($r('app.media.Tomato')) + .objectFit(ImageFit.Contain) + .height(357) + Text('Tomato') + .fontSize(26) + .fontWeight(500) + } } } - } - ``` + ```  ​ -5. Set the food image and name layout. Set the alignment mode of the stack to bottom alignment. By default, the stack is center aligned. Set **alignContent** to **Alignment.BottomStart**. Similar to **FontWeight**, **Alignment** is a built-in enumeration type provided by the framework. +5. Set the food image and name layout. Set **alignContent** to **Alignment.BottomStart**. Similar to **FontWeight**, **Alignment** is a built-in enumeration type provided by the framework. ``` @Entry @@ -112,9 +116,9 @@ In this section, we will develop an infographic food details page, by building c  -6. You can change the background color of the food image by setting the background color of the stack. You can set the background color in either of the following ways: - 1. By using the built-in enumeration value of Color provided by the framework. For example, **backgroundColor(Color.Red)** indicates that the background color is set to red. - 2. By using the parameter of the string type. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting **backgroundColor(??\#0000FF??)** and set the background color to white by setting **backgroundColor(??rgb(255, 255, 255)??)**. +6. You can change the background color of the food image by setting the background color of the **\<Stack>** component in either of the following ways: + 1. Using the built-in **Color** enums provided by the framework. For example, **backgroundColor(Color.Red)** indicates that the background color is set to red. + 2. Using the string-type parameter. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting **backgroundColor(??\#0000FF??)** and set the background color to white by setting **backgroundColor(??rgb(255, 255, 255)??)**. ``` @@ -163,7 +167,7 @@ In this section, we will develop an infographic food details page, by building c  -8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component. +8. Adjust the structure between components and semanticize component names. Create the **FoodDetail** page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component. A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. @@ -202,7 +206,7 @@ In this section, we will develop an infographic food details page, by building c You can use the Flex layout to build a food composition table. In this way you do not need to worry about the width and height calculation. The size of different cells can be flexibly set based on the proportion. -1. Create a **ContentTable** component as a child component of the FoodDetail component. +1. Create a **ContentTable** component as a child component of the **FoodDetail** component. ``` @Component @@ -239,13 +243,13 @@ You can use the Flex layout to build a food composition table. In this way you d } ``` -2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition. +2. Create a Flex component to display two food composition categories in the tomato: **Calories** and **Nutrition**. -Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C. + **Calories** contains information about calories. **Nutrition** contains information about protein, fat, carbohydrates, and vitamin C. -Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally. + Create the **Calories** class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three **\<Text>** child components, which represent the category name (**Calories**), content name (**Calories**), and contain value (**17 kcal**), respectively. By default, child components in the Flex component are arranged horizontally. - In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided. + In the following example, code of **FoodImageDisplay** is omitted, and only code of **ContentTable** is provided. ``` @@ -281,14 +285,14 @@ Create the Calories class. Create a Flex component and set its height to 280, an  -3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). +3. Adjust the layout and set the proportion (**layoutWeight**) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space **flexGrow(1)**. ``` @Component struct FoodImageDisplay { build() { Stack({ alignContent: Alignment.BottomStart }) { - Image($m('Tomato.png')) + Image($r('app.media.Tomato')) .objectFit(ImageFit.Contain) .height(357) Text('Tomato') @@ -337,7 +341,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an  -4. Create the **Nutrient** class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces. +4. Create the **Nutrient** class in a similar process. **Nutrition** consists of four parts: **Protein**, **Fat**, **Carbohydrates**, and **VitaminC**. The names of the last three parts are omitted in the table and represented by spaces. Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**. @@ -442,7 +446,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an Currently, all food groups are declared, resulting in code duplication and redundancy. You can use @Builder to build a custom method and abstract the same UI structure declaration. The @Builder decorated method and the build method for the @Component decorated component are used to declare some UI rendering structures and comply with the same eTS syntax. You can define one or more methods decorated by @Builder, but a component decorated by @Component can have only one build method. - Declare the IngredientItem method decorated by @Builder in ContentTable to declare the UI descriptions for the category name, content name, and content value. + Declare the **IngredientItem** method decorated by @Builder in **ContentTable** to declare the UI descriptions for the category name, content name, and content value. ``` @@ -455,9 +459,6 @@ Create the Calories class. Create a Flex component and set its height to 280, an .fontWeight(FontWeight.Bold) .layoutWeight(1) Flex({ alignItems: ItemAlign.Center }) { - Circle({width: 6, height: 6}) - .margin({right: 12}) - .fill(colorValue) Text(name) .fontSize(17.4) .flexGrow(1) @@ -470,7 +471,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an } ``` -When the ` IngredientItem` API is called in the build method of ContentTable, ` this ` needs to be used to invoke the method in the scope of the component to distinguish the global method call. + When the `IngredientItem` API is called in the **build** method of **ContentTable**, `this` needs to be used to invoke the method in the scope of the component to distinguish the global method call. ``` @@ -491,7 +492,7 @@ When the ` IngredientItem` API is called in the build method of ContentTable, } ``` -The overall code of the ContentTable component is as follows: + The overall code of the **ContentTable** component is as follows: ``` diff --git a/en/application-dev/ui/ui-ts-local-storage.md b/en/application-dev/ui/ui-ts-local-storage.md new file mode 100644 index 0000000000000000000000000000000000000000..5be4242deb84d124be1cc9c1323f10885ce6adb1 --- /dev/null +++ b/en/application-dev/ui/ui-ts-local-storage.md @@ -0,0 +1,345 @@ +# LocalStorage + +> **NOTE** +> +> This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. + +**LocalStorage** is a storage unit in an application. Its lifecycle is determined by the ability to which it is bound. **LocalStorage** provides storage for variable and non-variable state attributes within the scope of an application. The variable and non-variable state attributes work together to build an application UI, including the UI of abilities. + +Application layer: Multiple **LocalStorage** instances can be created for an application. Each ability of an application corresponds to a **LocalStorage** instance. + +Ability: An application can have multiple abilities. Only one **LocalStorage** instance can be allocated to the child components of an ability. Once allocated a **LocalStorage** instance, the child components have access to objects stored in the **LocalStorage**. + +A component can access only one **LocalStorage** instance, and a **LocalStorage** instance can be allocated to multiple components. + +## @LocalStorageLink Decorator + +Two-way data binding can be established between a component and the **LocalStorage** through the component's state variable decorated by **@LocalStorageLink(*key*)**. Wherein, **key** is the attribute key value in the **LocalStorage**. When a component that contains a **@LocalStorageLink** decorated state variable is created, the state variable is initialized with the initial value of the **LocalStorage**. If no initial value is assigned for the **LocalStorage**, the state variable will use the value defined by **@LocalStorageLink**. Changes made to this variable in the component will be first synchronized to the **LocalStorage**, and then to other components of the bound ability. + +## @LocalStorageProp Decorator + +One-way data binding can be established between a component and the **LocalStorage** through the component's state variable decorated by **@LocalStorageLink(*key*)**. Wherein, **key** is the attribute key value in the **LocalStorage**. When a component that contains a **@LocalStorageProp** decorated state variable is created, the state variable is initialized with the value predefined in the **LocalStorage**. Changes made to the value in the **LocalStorage** will cause all UI components of the bound ability to update the state. + +> **NOTE** +> +> If a **LocalStorage** instance has initial values assigned when being created, these values will be used for the **@LocalStorageLink** and **@LocalStorageProp** decorated state variables in the component. Otherwise, the initial values assigned for **@LocalStorageLink** and **@LocalStorageProp** will be used instead. + +## LocalStorage APIs + +### constructor + +constructor(initializingProperties?: Object) + +Creates and initializes a **LocalStorage** instance. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| ---------------------- | ------ | :--: | ------ | ------------------------------------------------------------ | +| initializingProperties | Object | No | - | Object attributes and their values returned by **object.keys(obj)**.| + + + +### has + +has(propName: string): boolean + +Checks whether the **LocalStorage** contains the specified attribute value. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | -------------- | +| propName | string | Yes | - | Attribute value.| + +**Return value** + +| Type | Description | +| ------- | -------------------------- | +| boolean | Whether the attribute value is contained.| + + + +### get + +get\<T>(propName: string): T + +Obtains the value corresponding to the given key. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | ------------------- | +| propName | string | Yes | - | Key of the value to obtain.| + +**Return value** + +| Type | Description | +| -------------- | ------------------------------------------------------- | +| T \| undefined | Returns the value if it is found; returns **undefined** otherwise.| + + + +### set + +set\<T>(propName: string, newValue: T): boolean + +Sets the value for the given key. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | ----------------- | +| propName | string | Yes | - | Key of the value to set. | +| newValue | T | Yes | - | Value to set.| + +**Return value** + +| Type | Description | +| ------- | ----------------------------------------------------- | +| boolean | Returns **true** if the value is successfully set for the key; returns **false** otherwise.| + + + +### setOrCreate + +setOrCreate\<T>(propName: string, newValue: T): boolean + +Creates or updates the value for the given key. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | ----------------------- | +| propName | string | Yes | - | Key of the value to create or update.| +| newValue | T | Yes | - | Value to create or update.| + +**Return value** + +| Type | Description | +| ------- | ------------------------------------------------------------ | +| boolean | Updates the value of the attribute and returns **true** if an attribute that has the same name as the specified key exists; creates an attribute with the specified value as its default value and returns **false** otherwise. **true** cannot be returned for **undefined** or **null**.| + + + +### link + +link\<T>(propName: string): T + +Establishes two-way data binding between an attribute and this **LocalStorage** instance. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | ---------------------- | +| propName | string | Yes | - | Key of the target attribute.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------------------------------ | +| T | Returns the two-way data binding if an attribute that has the same name as the specified key exists; returns **undefined** otherwise.| + + + +### setAndLink + +setAndLink\<T>(propName: string, defaultValue: T): T + +Establishes two-way data binding between an attribute and this **LocalStorage** instance. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| ------------ | ------ | :--: | ------ | -------------------- | +| propName | string | Yes | - | Key of the target attribute. | +| defaultValue | T | Yes | - | Default value of the target attribute to set.| + +**Return value** + +| Type | Description | +| ------------------------------------- | ------------------------------------------------------------ | +| [@Link](ts-component-states-link.md)| Returns the two-way data binding if an attribute that has the same name as the specified key exists; creates an attribute with the specified value as its default value and returns the attribute otherwise.| + + + +### prop + +prop\<T>(propName: string): T + +Establishes one-way data binding with an attribute to update its status. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | ----------------------- | +| propName | string | Yes | - | Key of the target attribute.| + +**Return value** + +| Type | Description | +| ------------------------------------ | ------------------------------------------------------------ | +| [@Prop](ts-component-states-prop.md) | Returns the one-way data binding if an attribute that has the same name as the specified key exists; returns **undefined** otherwise. Note that the variables returned are immutable variables, which are applicable to variable and immutable state variables.| + + + +### setAndProp + +setAndProp\<T>(propName: string, defaultValue: T): T + +Works in a way similar to the **Prop** API and sets up one-way data binding with the **localStorage**. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| ------------ | ------ | :--: | ------ | --------------------------- | +| propName | string | Yes | - | Key value in the key-value pair to be saved.| +| defaultValue | T | Yes | - | Default value created. | + +**Return value** + +| Type | Description | +| ------------------------------------ | ------------------------------------------------------------ | +| [@Prop](ts-component-states-prop.md) | Returns the value corresponding to the key if the current key is stored in the **LocalStorage**; creates and returns a **Prop** instance corresponding to the default value if the key has not been created.| + + + +### delete + +delete(propName: string): boolean + +Deletes the key-value pair specified by key. + +**Parameters** + +| Name | Type | Mandatory| Default Value| Description | +| -------- | ------ | :--: | ------ | --------------------- | +| propName | string | Yes | - | Key value of the attribute to be deleted.| + +**Return value** + +| Type | Description | +| ------- | ------------------------------------------------------------ | +| boolean | Deletes the key-value pair for the specified key. Returns **true** if the key-value pair exists and is successfully deleted; returns **false** otherwise.| + + + +### keys + +keys(): IterableIterator\<string> + +Searches for all keys. + +**Return value** + +| Type | Description | +| ------------- | ---------------------------- | +| array\<string> | Returns an array of strings containing all keys.| + + + +### size + +size(): number + +Number of existing key-value pairs. + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| number | Number of key-value pairs.| + + + +### Clear + +clear(): boolean + +Deletes all attributes. + +**Return value** + +| Type | Description | +| ------- | ------------------------------------------------------------ | +| boolean | Deletes all attributes. If any of the attributes is being referenced by a state variable, **false** is returned.| + +### Example 1 (Creating a LocalStorage in an Ability) + +```javascript +import Ability from '@ohos.appLication.Ability' +export default class MainAbility extends Ability { + storage : LocalStorage + onCreate(want) { + this.storage = new LocalStorage(); + this.storage.setOrCreate("storageSimpleProp",121); + console.log("[Demo MainAbility onCreate]"); + globalThis.abilityWant = want; + } + onDestroy() { + console.log("[Demo MainAbility onDestroy]") + } + onWindowStageCreate(windowStage) { + windowStage.setUIContent(this.context,"pages/index",this.storage) + } + onWindowStageDestroy() { + console.log("[Demo] MainAbility onWindoeStageDestroy") + } + onForeground() { + console.log("[Demo] MainAbility onForeground") + } + onBackground() { + console.log("[Demo] MainAbility onBackground") + } +} +``` + +The @Component decorated component obtains data. + +``` +let storage = LocalStorage.GetShared() +@Entry(storage) +@Component +struct LocalStorageComponent { + @LocalStorageLink("storageSimpleProp") simpleVarName: number = 0 + build() { + Column(){ + Text(this.simpleVarName.toString()) + .onClick(()=>{ + this.simpleVarName +=1; + }) + Text(JSON.stringify(this.simpleVarName)) + .fontSize(50) + } + .height(500) + } +} +``` + +### Example 2 (Defining LocalStorage on the Entry Page) + +``` +let storage = new LocalStorage({"PropA":47}); +@Entry(storage) +@Component +struct ComA { + @LocalStorageLink("PropA") storLink : number = 1; + build() { + Column() { + Text(`Parent from LocalStorage $(this.storLink)`) + .onClick(()=>this.storLink+=1) + Child() + } + } +} + + +@Component +struct Child{ + @LocalStorageLink("PropA") storLink : number = 1; + build() { + Text(`Parent from LocalStorage $(this.storLink)`) + .onClick(()=>this.storLink1+=1) + } +} +``` diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 0395b61b66797ddc7409bde4239fcb0d650a9fbb..0726f2d6fc16127147536e0a1c260db5a7a1c06d 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -11,8 +11,8 @@ - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - - [Resource File Categories](quick-start/basic-resource-file-categories.md) - [SysCap](quick-start/syscap.md) + - [HarmonyAppProvision Configuration File](quick-start/app-provision-structure.md) - Development - Ability Development - [Ability Framework Overview](ability/ability-brief.md) @@ -22,7 +22,7 @@ - [Page Ability Development](ability/fa-pageability.md) - [Service Ability Development](ability/fa-serviceability.md) - [Data Ability Development](ability/fa-dataability.md) - - [FA Widget Development](ability/fa-formability.md) + - [FA Widget Development](ability/fa-formability.md) - Stage Model - [Stage Model Overview](ability/stage-brief.md) - [Ability Development](ability/stage-ability.md) @@ -36,7 +36,78 @@ - [Test Framework Usage](ability/ability-delegator.md) - UI Development - [ArkUI Overview](ui/arkui-overview.md) - - JavaScript-based Web-Like Development Paradigm + - TypeScript-based Declarative Development Paradigm + - [Overview](ui/ui-ts-overview.md) + - Framework Overview + - File Organization + - [Directory Structure](ui/ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ui/ts-framework-file-access-rules.md) + - ["js" Tag](ui/ts-framework-js-tag.md) + - Resource Management + - [Resource File Categories](ui/ui-ts-basic-resource-file-categories.md) + - [Accessing Resources](ui/ts-resource-access.md) + - [Pixel Units](ui/ts-pixel-units.md) + - [Types](ui/ts-types.md) + - Declarative Syntax + - [Overview](ui/ts-syntax-intro.md) + - General UI Description Specifications + - [Basic Concepts](ui/ts-general-ui-concepts.md) + - Declarative UI Description Specifications + - [Configuration Without Parameters](ui/ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ui/ts-configuration-with-mandatory-parameters.md) + - [Attribute Configuration](ui/ts-attribution-configuration.md) + - [Event Configuration](ui/ts-event-configuration.md) + - [Child Component Configuration](ui/ts-child-component-configuration.md) + - Componentization + - [@Component](ui/ts-component-based-component.md) + - [@Entry](ui/ts-component-based-entry.md) + - [@Preview](ui/ts-component-based-preview.md) + - [@Builder](ui/ts-component-based-builder.md) + - [@Extend](ui/ts-component-based-extend.md) + - [@CustomDialog](ui/ts-component-based-customdialog.md) + - [@Styles](ui/ts-component-based-styles.md) + - About UI State Management + - [Basic Concepts](ui/ts-ui-state-mgmt-concepts.md) + - Managing Component States + - [@State](ui/ts-component-states-state.md) + - [@Prop](ui/ts-component-states-prop.md) + - [@Link](ui/ts-component-states-link.md) + - Managing Application States + - [AppStorage](ui/ts-application-states-appstorage.md) + - [LocalStorage](ui/ui-ts-local-storage.md) + - [PersistentStorage](ui/ts-application-states-apis-persistentstorage.md) + - [Environment](ui/ts-application-states-apis-environment.md) + - Managing Other States + - [@Observed and @ObjectLink](ui/ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ui/ts-other-states-consume-provide.md) + - [@Watch](ui/ts-other-states-watch.md) + - About Rendering Control Syntax + - [if/else](ui/ts-rending-control-syntax-if-else.md) + - [ForEach](ui/ts-rending-control-syntax-foreach.md) + - [LazyForEach](ui/ts-rending-control-syntax-lazyforeach.md) + - About @Component + - [build Function](ui/ts-function-build.md) + - [Initialization of Custom Components' Member Variables](ui/ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md) + - [Component Creation and Re-initialization](ui/ts-component-creation-re-initialization.md) + - [About Syntactic Sugar](ui/ts-syntactic-sugar.md) + - Common Component Development Guidelines + - [Button](ui/ui-ts-basic-components-button.md) + - [Web](ui/ui-ts-components-web.md) + - Common Layout Development Guidelines + - [Flex Layout](ui/ui-ts-layout-flex.md) + - [Grid Layout](ui/ui-ts-layout-grid-container.md) + - [Media Query](ui/ui-ts-layout-mediaquery.md) + - Experiencing the Declarative UI + - [Creating a Declarative UI Project](ui/ui-ts-creating-project.md) + - [Getting to Know Components](ui/ui-ts-components.md) + - [Creating a Simple Page](ui/ui-ts-creating-simple-page.md) + - Defining Page Layout and Connection + - [Building a Food Data Model](ui/ui-ts-building-data-model.md) + - [Building a Food Category List Layout](ui/ui-ts-building-category-list-layout.md) + - [Building a Food Category Grid Layout](ui/ui-ts-building-category-grid-layout.md) + - [Implementing Page Redirection and Data Transmission](ui/ui-ts-page-redirection-data-transmission.md) + - JavaScript-based Web-like Development Paradigm - [Overview](ui/ui-js-overview.md) - Framework - [File Organization](ui/js-framework-file.md) @@ -59,7 +130,7 @@ - [Adding a Container](ui/ui-js-building-ui-layout-external-container.md) - [Adding Interactions](ui/ui-js-building-ui-interactions.md) - [Developing Animations](ui/ui-js-building-ui-animation.md) - - [Defining Events](ui/ui-js-building-ui-event.md) + - [Defining Gesture Events](ui/ui-js-building-ui-event.md) - [Defining Page Routes](ui/ui-js-building-ui-routes.md) - Common Component Development Guidelines - Container Components @@ -108,435 +179,278 @@ - [Animation Effect](ui/ui-js-animate-dynamic-effects.md) - [Animation Frame](ui/ui-js-animate-frame.md) - [Custom Components](ui/ui-js-custom-components.md) - - TypeScript-based Declarative Development Paradigm - - [Overview](ui/ui-ts-overview.md) - - Framework Overview - - File Organization - - [Directory Structure](ui/ts-framework-directory.md) - - [Rules for Accessing Application Code Files](ui/ts-framework-file-access-rules.md) - - ["js" Tag](ui/ts-framework-js-tag.md) - - Resource Access - - [Accessing Application Resources](ui/ts-application-resource-access.md) - - [Accessing System Resources](ui/ts-system-resource-access.md) - - [Media Resource Types](ui/ts-media-resource-type.md) - - [Pixel Units](ui/ts-pixel-units.md) - - [Types](ui/ts-types.md) - - Declarative Syntax - - [Overview](ui/ts-syntax-intro.md) - - General UI Description Specifications - - [Basic Concepts](ui/ts-general-ui-concepts.md) - - Declarative UI Description Specifications - - [Configuration Without Parameters](ui/ts-parameterless-configuration.md) - - [Configuration with Mandatory Parameters](ui/ts-configuration-with-mandatory-parameters.md) - - [Attribution Configuration](ui/ts-attribution-configuration.md) - - [Event Configuration](ui/ts-event-configuration.md) - - [Child Component Configuration](ui/ts-child-component-configuration.md) - - Componentization - - [@Component](ui/ts-component-based-component.md) - - [@Entry](ui/ts-component-based-entry.md) - - [@Preview](ui/ts-component-based-preview.md) - - [@Builder](ui/ts-component-based-builder.md) - - [@Extend](ui/ts-component-based-extend.md) - - [@CustomDialog](ui/ts-component-based-customdialog.md) - - [@Styles](ui/ts-component-based-styles.md) - - About UI State Management - - [Basic Concepts](ui/ts-ui-state-mgmt-concepts.md) - - Managing Component States - - [@State](ui/ts-component-states-state.md) - - [@Prop](ui/ts-component-states-prop.md) - - [@Link](ui/ts-component-states-link.md) - - Managing Application States - - [AppStorage](ui/ts-application-states-appstorage.md) - - [PersistentStorage](ui/ts-application-states-apis-persistentstorage.md) - - [Environment](ui/ts-application-states-apis-environment.md) - - Managing Other States - - [@observed and @objectLink](ui/ts-other-states-observed-objectlink.md) - - [@Consume and @Provide](ui/ts-other-states-consume-provide.md) - - [@Watch](ui/ts-other-states-watch.md) - - About Rendering Control Syntax - - [if/else](ui/ts-rending-control-syntax-if-else.md) - - [ForEach](ui/ts-rending-control-syntax-foreach.md) - - [LazyForEach](ui/ts-rending-control-syntax-lazyforeach.md) - - About @Component - - [build Function](ui/ts-function-build.md) - - [Initialization of Custom Components' Member Variables](ui/ts-custom-component-initialization.md) - - [Custom Component Lifecycle Callbacks](ui/ts-custom-component-lifecycle-callbacks.md) - - [Example: Component Creation and Re-Initialization](ui/ts-component-creation-re-initialization.md) - - [Syntactic Sugar](ui/ts-syntactic-sugar.md) - - Common Component Development Guidelines - - [Button](ui/ui-ts-basic-components-button.md) - - [Web](ui/ui-ts-components-web.md) - - Common Layout Development Guidelines - - [Flex Layout](ui/ui-ts-layout-flex.md) - - [Grid Layout](ui/ui-ts-layout-grid-container.md) - - [Media Query](ui/ui-ts-layout-mediaquery.md) - - Experiencing the Declarative UI - - [Creating a Declarative UI Project](ui/ui-ts-creating-project.md) - - [Getting to Know Components](ui/ui-ts-components.md) - - [Creating a Simple Page](ui/ui-ts-creating-simple-page.md) - - Defining Page Layout and Connection - - [Building a Food Data Model](ui/ui-ts-building-data-model.md) - - [Building a Food Category List Layout](ui/ui-ts-building-category-list-layout.md) - - [Building a Food Category Grid Layout](ui/ui-ts-building-category-grid-layout.md) - - [Implementing Page Redirection and Data Transmission](ui/ui-ts-page-redirection-data-transmission.md) - - Basic Functions - - Common Event and Notification - - [Common Event and Notification Overview](notification/notification-brief.md) - - Common Event - - [Common Event Development](notification/common-event.md) - - Notification - - [Notification Development](notification/notification.md) - - Debugging Tools - - [Debugging Assistant Usage](notification/assistant-guidelines.md) - - Window Manager - - Window - - [Window Overview](windowmanager/window-overview.md) - - [Window Development](windowmanager/window-guidelines.md) - - Display - - [Display Overview](windowmanager/display-overview.md) - - [Display Development](windowmanager/display-guidelines.md) - - Screenshot - - [Screenshot Overview](windowmanager/screenshot-overview.md) - - [Screenshot Development](windowmanager/screenshot-guidelines.md) - - WebGL - - [WebGL Overview](webgl/webgl-overview.md) - - [WebGL Development](webgl/webgl-guidelines.md) - - Media - - Audio - - [Audio Overview](media/audio-overview.md) - - [Audio Playback Development](media/audio-playback.md) - - [Audio Recording Development](media/audio-recorder.md) - - [Audio Rendering Development](media/audio-renderer.md) - - [Audio Capture Development](media/audio-capturer.md) - - Video - - [Video Playback Development](media/video-playback.md) - - [Video Recording Development](media/video-recorder.md) - - Image - - [Image Development](media/image.md) - - Security - - User Authentication - - [User Authentication Overview](security/userauth-overview.md) - - [User Authentication Development](security/userauth-guidelines.md) - - Key Management - - [HUKS Overview](security/huks-overview.md) - - [HUKS Development](security/huks-guidelines.md) - - hapsigner - - [hapsigner Guide](security/hapsigntool-guidelines.md) - - Access Control - - [Access Control Overview](security/accesstoken-overview.md) - - [Access Control Development](security/accesstoken-guidelines.md) - - Connectivity - - Network Management - - [Network Management Overview](connectivity/net-mgmt-overview.md) - - [HTTP Data Request](connectivity/http-request.md) - - [WebSocket Connection](connectivity/websocket-connection.md) - - [Socket Connection](connectivity/socket-connection.md) - - IPC & RPC - - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) - - [IPC & RPC Development](connectivity/ipc-rpc-development-guideline.md) - - [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md) - - Telephony - - [Telephony Service Overview](telephony/telephony-overview.md) - - [Redirecting to the Dial Screen](telephony/jumping-to-the-dial-screen.md) - - [Obtaining Current Cellular Network Signal Information](telephony/cellular-network-signal-info.md) - - Data Management - - Distributed Data Service - - [Distributed Data Service Overview](database/database-mdds-overview.md) - - [Distributed Data Service Development](database/database-mdds-guidelines.md) - - Relational Database - - [RDB Overview](database/database-relational-overview.md) - - [RDB Development](database/database-relational-guidelines.md) - - Lightweight Data Store - - [Lightweight Data Store Overview](database/database-preference-overview.md) - - [Lightweight Data Store Development](database/database-preference-guidelines.md) - - Distributed Data Object - - [Distributed Data Object Overview](database/database-distributedobject-overview.md) - - [Distributed Data Object Development](database/database-distributedobject-guidelines.md) + - Common Event and Notification + + - [Common Event and Notification Overview](notification/notification-brief.md) + - [Common Event Development](notification/common-event.md) + - [Notification Development](notification/notification-guidelines.md) - Agent-Powered Scheduled Reminder - - [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) - - [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - [Agent-Powered Scheduled Reminder Overview](notification/background-agent-scheduled-reminder-overview.md) + - [Agent-Powered Scheduled Reminder Development](notification/background-agent-scheduled-reminder-guide.md) + - [Debugging Assistant Usage](notification/assistant-guidelines.md) + - Window Manager + - Window + - [Window Overview](windowmanager/window-overview.md) + - [Window Development](windowmanager/window-guidelines.md) + - Display + - [Display Overview](windowmanager/display-overview.md) + - [Display Development](windowmanager/display-guidelines.md) + - Screenshot + - [Screenshot Overview](windowmanager/screenshot-overview.md) + - [Screenshot Development](windowmanager/screenshot-guidelines.md) + - WebGL + - [WebGL Overview](webgl/webgl-overview.md) + - [WebGL Development](webgl/webgl-guidelines.md) + - Media + + - Audio + - [Audio Overview](media/audio-overview.md) + - [Audio Playback Development](media/audio-playback.md) + - [Audio Recording Development](media/audio-recorder.md) + - [Audio Rendering Development](media/audio-renderer.md) + - [Audio Capture Development](media/audio-capturer.md) + - [OpenSL ES Audio Playback Development](media/opensles-playback.md) + - [OpenSL ES Audio Recording Development](media/opensles-capture.md) + - [Audio Interruption Mode Development](media/audio-interruptmode.md) + - Video + - [Video Playback Development](media/video-playback.md) + - [Video Recording Development](media/video-recorder.md) + - Image + - [Image Development](media/image.md) + - Camera + - [Camera Development](media/camera.md) + - Security + + - Access Control + - [Access Control Overview](security/accesstoken-overview.md) + - [Access Control Development](security/accesstoken-guidelines.md) + - [Permission List](security/permission-list.md) + - User Authentication + - [User Authentication Overview](security/userauth-overview.md) + - [User Authentication Development](security/userauth-guidelines.md) + - Key Management + - [HUKS Overview](security/huks-overview.md) + - [HUKS Development](security/huks-guidelines.md) + - hapsigner + - [hapsigner Overview](security/hapsigntool-overview.md) + - [hapsigner Guide](security/hapsigntool-guidelines.md) + - Connectivity + - Network Management + - [Network Management Overview](connectivity/net-mgmt-overview.md) + - [HTTP Data Request](connectivity/http-request.md) + - [WebSocket Connection](connectivity/websocket-connection.md) + - [Socket Connection](connectivity/socket-connection.md) + - IPC & RPC + - [IPC & RPC Overview](connectivity/ipc-rpc-overview.md) + - [IPC & RPC Development](connectivity/ipc-rpc-development-guideline.md) + - [Subscribing to State Changes of a Remote Object](connectivity/subscribe-remote-state.md) + - Telephony + - [Telephony Service Overview](telephony/telephony-overview.md) + - [Redirecting to the Dial Screen](telephony/jumping-to-the-dial-screen.md) + - [Obtaining Current Cellular Network Signal Information](telephony/cellular-network-signal-info.md) + - Data Management + - Distributed Data Service + - [Distributed Data Service Overview](database/database-mdds-overview.md) + - [Distributed Data Service Development](database/database-mdds-guidelines.md) + - Relational Database + - [RDB Overview](database/database-relational-overview.md) + - [RDB Development](database/database-relational-guidelines.md) + - Preferences + - [Preferences Overview](database/database-preference-overview.md) + - [Preferences Development](database/database-preference-guidelines.md) + - Distributed Data Object + - [Distributed Data Object Overview](database/database-distributedobject-overview.md) + - [Distributed Data Object Development](database/database-distributedobject-guidelines.md) + - Task Management - Background Task Management - - [Background Task Management Overview](background-task-management/background-task-overview.md) - - [Background Task Management Development](background-task-management/background-task-dev-guide.md) + - [Background Task Management Overview](task-management/background-task-overview.md) + - [Background Task Management Development](task-management/background-task-dev-guide.md) - Work Scheduler - - [Work Scheduler Overview](work-scheduler/work-scheduler-overview.md) - - [Work Scheduler Development](work-scheduler/work-scheduler-dev-guide.md) - - Device - - USB Service - - [USB Service Overview](device/usb-overview.md) - - [USB Service Development](device/usb-guidelines.md) - - Location - - [Location Overview](device/device-location-overview.md) - - [Obtaining Device Location Information](device/device-location-info.md) - - [Geocoding and Reverse Geocoding Capabilities](device/device-location-geocoding.md) - - Sensor - - [Sensor Overview](device/sensor-overview.md) - - [Sensor Development](device/sensor-guidelines.md) - - Vibrator - - [Vibrator Overview](device/vibrator-overview.md) - - [Vibrator Development](device/vibrator-guidelines.md) - - Update - - [Sample Server Overview](device/sample-server-overview.md) - - [Sample Server Development](device/sample-server-guidelines.md) - - Device Usage Statistics - - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) - - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) - - DFX - - Application Event Logging - - [Overview of Application Event Logging](dfx/hiappevent-overview.md) - - [Development of Application Event Logging](dfx/hiappevent-guidelines.md) - - Performance Tracing - - [Overview of Performance Tracing](dfx/hitracemeter-overview.md) - - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) - - Distributed Call Chain Tracing - - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) - - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) - - Internationalization - - [Internationalization Overview](internationalization/international-overview.md) - - [Internationalization Development (intl)](internationalization/intl-guidelines.md) - - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) - - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) - - Native APIs - - [Using Native APIs in Application Projects](napi/napi-guidelines.md) + - [Work Scheduler Overview](task-management/work-scheduler-overview.md) + - [Work Scheduler Development](task-management/work-scheduler-dev-guide.md) + - Device + - USB Service + - [USB Service Overview](device/usb-overview.md) + - [USB Service Development](device/usb-guidelines.md) + - Location + - [Location Overview](device/device-location-overview.md) + - [Obtaining Device Location Information](device/device-location-info.md) + - [Geocoding and Reverse Geocoding Capabilities](device/device-location-geocoding.md) + - Sensor + - [Sensor Overview](device/sensor-overview.md) + - [Sensor Development](device/sensor-guidelines.md) + - Vibrator + - [Vibrator Overview](device/vibrator-overview.md) + - [Vibrator Development](device/vibrator-guidelines.md) + - Update Service + - [Sample Server Overview](device/sample-server-overview.md) + - [Sample Server Development](device/sample-server-guidelines.md) + - Device Usage Statistics + - [Device Usage Statistics Overview](device-usage-statistics/device-usage-statistics-overview.md) + - [Device Usage Statistics Development](device-usage-statistics/device-usage-statistics-dev-guide.md) + - DFX + - Application Event Logging + - [Overview of Application Event Logging](dfx/hiappevent-overview.md) + - [Development of Application Event Logging](dfx/hiappevent-guidelines.md) + - Performance Tracing + - [Overview of Performance Tracing](dfx/hitracemeter-overview.md) + - [Development of Performance Tracing](dfx/hitracemeter-guidelines.md) + - Distributed Call Chain Tracing + - [Overview of Distributed Call Chain Tracing](dfx/hitracechain-overview.md) + - [Development of Distributed Call Chain Tracing](dfx/hitracechain-guidelines.md) + - Error Management + - [Development of Error Manager](dfx/errormanager-guidelines.md) + - Internationalization + - [Internationalization Overview](internationalization/international-overview.md) + - [Internationalization Development (intl)](internationalization/intl-guidelines.md) + - [Internationalization Development (i18n)](internationalization/i18n-guidelines.md) + - [OpenHarmony IDL Specifications and User Guide](IDL/idl-guidelines.md) + - Native APIs + - [Using Native APIs in Application Projects](napi/napi-guidelines.md) + - [Drawing Development](napi/drawing-guidelines.md) + - [Native Window Development](napi/native-window-guidelines.md) + - [Raw File Development](napi/rawfile-guidelines.md) - Tools - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - [Codelabs](https://gitee.com/openharmony/codelabs) - API References - - Component Reference (JavaScript-based Web-like Development Paradigm) - - Components - - Common - - [Universal Attributes](reference/arkui-js/js-components-common-attributes.md) - - [Universal Styles](reference/arkui-js/js-components-common-styles.md) - - [Universal Events](reference/arkui-js/js-components-common-events.md) - - [Universal Methods](reference/arkui-js/js-components-common-methods.md) - - [Animation Styles](reference/arkui-js/js-components-common-animation.md) - - [Gradient Styles](reference/arkui-js/js-components-common-gradient.md) - - [Transition Styles](reference/arkui-js/js-components-common-transition.md) - - [Media Query](reference/arkui-js/js-components-common-mediaquery.md) - - [Custom Font Styles](reference/arkui-js/js-components-common-customizing-font.md) - - [Atomic Layout](reference/arkui-js/js-components-common-atomic-layout.md) - - Container Components - - [badge](reference/arkui-js/js-components-container-badge.md) - - [dialog](reference/arkui-js/js-components-container-dialog.md) - - [div](reference/arkui-js/js-components-container-div.md) - - [form](reference/arkui-js/js-components-container-form.md) - - [list](reference/arkui-js/js-components-container-list.md) - - [list-item](reference/arkui-js/js-components-container-list-item.md) - - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) - - [panel](reference/arkui-js/js-components-container-panel.md) - - [popup](reference/arkui-js/js-components-container-popup.md) - - [refresh](reference/arkui-js/js-components-container-refresh.md) - - [stack](reference/arkui-js/js-components-container-stack.md) - - [stepper](reference/arkui-js/js-components-container-stepper.md) - - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) - - [swiper](reference/arkui-js/js-components-container-swiper.md) - - [tabs](reference/arkui-js/js-components-container-tabs.md) - - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) - - [tab-content](reference/arkui-js/js-components-container-tab-content.md) - - Basic Components - - [button](reference/arkui-js/js-components-basic-button.md) - - [chart](reference/arkui-js/js-components-basic-chart.md) - - [divider](reference/arkui-js/js-components-basic-divider.md) - - [image](reference/arkui-js/js-components-basic-image.md) - - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) - - [input](reference/arkui-js/js-components-basic-input.md) - - [label](reference/arkui-js/js-components-basic-label.md) - - [marquee](reference/arkui-js/js-components-basic-marquee.md) - - [menu](reference/arkui-js/js-components-basic-menu.md) - - [option](reference/arkui-js/js-components-basic-option.md) - - [picker](reference/arkui-js/js-components-basic-picker.md) - - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) - - [piece](reference/arkui-js/js-components-basic-piece.md) - - [progress](reference/arkui-js/js-components-basic-progress.md) - - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) - - [rating](reference/arkui-js/js-components-basic-rating.md) - - [richtext](reference/arkui-js/js-components-basic-richtext.md) - - [search](reference/arkui-js/js-components-basic-search.md) - - [select](reference/arkui-js/js-components-basic-select.md) - - [slider](reference/arkui-js/js-components-basic-slider.md) - - [span](reference/arkui-js/js-components-basic-span.md) - - [switch](reference/arkui-js/js-components-basic-switch.md) - - [text](reference/arkui-js/js-components-basic-text.md) - - [textarea](reference/arkui-js/js-components-basic-textarea.md) - - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) - - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) - - [toggle](reference/arkui-js/js-components-basic-toggle.md) - - [web](reference/arkui-js/js-components-basic-web.md) - - Media Components - - [video](reference/arkui-js/js-components-media-video.md) - - Canvas Components - - [canvas](reference/arkui-js/js-components-canvas-canvas.md) - - [CanvasRenderingContext2D](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - - [Image](reference/arkui-js/js-components-canvas-image.md) - - [CanvasGradient](reference/arkui-js/js-components-canvas-canvasgradient.md) - - [ImageData](reference/arkui-js/js-components-canvas-imagedata.md) - - [Path2D](reference/arkui-js/js-components-canvas-path2d.md) - - [ImageBitmap](reference/arkui-js/js-components-canvas-imagebitmap.md) - - [OffscreenCanvas](reference/arkui-js/js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - - Grid - - [Basic Concepts](reference/arkui-js/js-components-grid-basic-concepts.md) - - [grid-container](reference/arkui-js/js-components-grid-container.md) - - [grid-row](reference/arkui-js/js-components-grid-row.md) - - [grid-col](reference/arkui-js/js-components-grid-col.md) - - SVG Components - - [Universal Attributes](reference/arkui-js/js-components-svg-common-attributes.md) - - [svg](reference/arkui-js/js-components-svg.md) - - [rect](reference/arkui-js/js-components-svg-rect.md) - - [circle](reference/arkui-js/js-components-svg-circle.md) - - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) - - [path](reference/arkui-js/js-components-svg-path.md) - - [line](reference/arkui-js/js-components-svg-line.md) - - [polyline](reference/arkui-js/js-components-svg-polyline.md) - - [polygon](reference/arkui-js/js-components-svg-polygon.md) - - [text](reference/arkui-js/js-components-svg-text.md) - - [tspan](reference/arkui-js/js-components-svg-tspan.md) - - [textPath](reference/arkui-js/js-components-svg-textpath.md) - - [animate](reference/arkui-js/js-components-svg-animate.md) - - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) - - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - - Custom Components - - [Basic Usage](reference/arkui-js/js-components-custom-basic-usage.md) - - [Custom Events](reference/arkui-js/js-components-custom-events.md) - - [props](reference/arkui-js/js-components-custom-props.md) - - [Event Parameter](reference/arkui-js/js-components-custom-event-parameter.md) - - [slot](reference/arkui-js/js-components-custom-slot.md) - - [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md) - - Appendix - - [Type Attributes](reference/arkui-js/js-appendix-types.md) - Component Reference (TypeScript-based Declarative Development Paradigm) - - Components - - Universal Components - - Universal Events - - [Click Event](reference/arkui-ts/ts-universal-events-click.md) - - [Touch](reference/arkui-ts/ts-universal-events-touch.md) - - [Show/Hide Event](reference/arkui-ts/ts-universal-events-show-hide.md) - - [Drag/Drop Event](reference/arkui-ts/ts-universal-events-drag-drop.md) - - [Key Event](reference/arkui-ts/ts-universal-events-key.md) - - [Focus Event](reference/arkui-ts/ts-universal-focus-event.md) - - [Mouse Event](reference/arkui-ts/ts-universal-mouse-key.md) - - [Component Area Change Event](reference/arkui-ts/ts-universal-component-area-change-event.md) - - Universal Attributes - - [Size](reference/arkui-ts/ts-universal-attributes-size.md) - - [Location](reference/arkui-ts/ts-universal-attributes-location.md) - - [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - - [Flex Layout](reference/arkui-ts/ts-universal-attributes-flex-layout.md) - - [Border Configuration](reference/arkui-ts/ts-universal-attributes-border.md) - - [Background](reference/arkui-ts/ts-universal-attributes-background.md) - - [Opacity](reference/arkui-ts/ts-universal-attributes-opacity.md) - - [Visibility](reference/arkui-ts/ts-universal-attributes-visibility.md) - - [Enable/Disable](reference/arkui-ts/ts-universal-attributes-enable.md) - - [Overlay](reference/arkui-ts/ts-universal-attributes-overlay.md) - - [Z-order Control](reference/arkui-ts/ts-universal-attributes-z-order.md) - - [Transformation](reference/arkui-ts/ts-universal-attributes-transformation.md) - - [Image Effect Configuration](reference/arkui-ts/ts-universal-attributes-image-effect.md) - - [Shape Clipping](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) - - [Text Style](reference/arkui-ts/ts-universal-attributes-text-style.md) - - [Grid](reference/arkui-ts/ts-universal-attributes-grid.md) - - [Gradient Color](reference/arkui-ts/ts-universal-attributes-gradient-color.md) - - [Popup Control](reference/arkui-ts/ts-universal-attributes-popup.md) - - [Menu Control](reference/arkui-ts/ts-universal-attributes-menu.md) - - [Click Control](reference/arkui-ts/ts-universal-attributes-click.md) - - [Focus Control](reference/arkui-ts/ts-universal-attributes-focus.md) - - [Hover Effect](reference/arkui-ts/ts-universal-attributes-hover-effect.md) - - [Component ID](reference/arkui-ts/ts-universal-attributes-component-id.md) - - [Touch Target](reference/arkui-ts/ts-universal-attributes-touch-target.md) - - [Polymorphic Style](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) - - Gesture Processing - - [Gesture Binding Methods](reference/arkui-ts/ts-gesture-settings.md) - - Basic Gestures - - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) - - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) - - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) - - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) - - [Combined Gestures](reference/arkui-ts/ts-combined-gestures.md) - - Basic Components - - [Blank](reference/arkui-ts/ts-basic-components-blank.md) - - [Button](reference/arkui-ts/ts-basic-components-button.md) - - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) - - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) - - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) - - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - - [Divider](reference/arkui-ts/ts-basic-components-divider.md) - - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) - - [Image](reference/arkui-ts/ts-basic-components-image.md) - - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - - [Progress](reference/arkui-ts/ts-basic-components-progress.md) - - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - - [Rating](reference/arkui-ts/ts-basic-components-rating.md) - - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - - [Search](reference/arkui-ts/ts-basic-components-search.md) - - [Select](reference/arkui-ts/ts-basic-components-select.md) - - [Slider](reference/arkui-ts/ts-basic-components-slider.md) - - [Span](reference/arkui-ts/ts-basic-components-span.md) - - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) - - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - - [Text](reference/arkui-ts/ts-basic-components-text.md) - - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) - - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) - - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) - - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [Web](reference/arkui-ts/ts-basic-components-web.md) - - [XComponent](reference/arkui-ts/ts-basic-components-xcomponent.md) - - Container Components - - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - - [Badge](reference/arkui-ts/ts-container-badge.md) - - [Column](reference/arkui-ts/ts-container-column.md) - - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) - - [Counter](reference/arkui-ts/ts-container-counter.md) - - [Flex](reference/arkui-ts/ts-container-flex.md) - - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - - [Grid](reference/arkui-ts/ts-container-grid.md) - - [GridItem](reference/arkui-ts/ts-container-griditem.md) - - [List](reference/arkui-ts/ts-container-list.md) - - [ListItem](reference/arkui-ts/ts-container-listitem.md) - - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Panel](reference/arkui-ts/ts-container-panel.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - - [Row](reference/arkui-ts/ts-container-row.md) - - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - - [Stack](reference/arkui-ts/ts-container-stack.md) - - [Swiper](reference/arkui-ts/ts-container-swiper.md) - - [Tabs](reference/arkui-ts/ts-container-tabs.md) - - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - Media Components - - [Video](reference/arkui-ts/ts-media-components-video.md) - - Drawing Components - - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) - - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) - - [Line](reference/arkui-ts/ts-drawing-components-line.md) - - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) - - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) - - [Path](reference/arkui-ts/ts-drawing-components-path.md) - - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) - - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) - - Canvas Components - - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) - - [Path2D](reference/arkui-ts/ts-components-canvas-path2d.md) - - [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md) - - [ImageBitmap](reference/arkui-ts/ts-components-canvas-imagebitmap.md) - - [ImageData](reference/arkui-ts/ts-components-canvas-imagedata.md) + - Universal Component Information + - Universal Events + - [Click Event](reference/arkui-ts/ts-universal-events-click.md) + - [Touch Event](reference/arkui-ts/ts-universal-events-touch.md) + - [Show/Hide Event](reference/arkui-ts/ts-universal-events-show-hide.md) + - [Drag/Drop Event](reference/arkui-ts/ts-universal-events-drag-drop.md) + - [Key Event](reference/arkui-ts/ts-universal-events-key.md) + - [Focus Event](reference/arkui-ts/ts-universal-focus-event.md) + - [Mouse Event](reference/arkui-ts/ts-universal-mouse-key.md) + - [Component Area Change Event](reference/arkui-ts/ts-universal-component-area-change-event.md) + - [Visible Area Change Event](reference/arkui-ts/ts-universal-component-visible-area-change-event.md) + - Universal Attributes + - [Size](reference/arkui-ts/ts-universal-attributes-size.md) + - [Location](reference/arkui-ts/ts-universal-attributes-location.md) + - [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + - [Flex Layout](reference/arkui-ts/ts-universal-attributes-flex-layout.md) + - [Border](reference/arkui-ts/ts-universal-attributes-border.md) + - [Border Image](reference/arkui-ts/ts-universal-attributes-border-image.md) + - [Background](reference/arkui-ts/ts-universal-attributes-background.md) + - [Opacity](reference/arkui-ts/ts-universal-attributes-opacity.md) + - [Visibility](reference/arkui-ts/ts-universal-attributes-visibility.md) + - [Enable/Disable](reference/arkui-ts/ts-universal-attributes-enable.md) + - [Overlay](reference/arkui-ts/ts-universal-attributes-overlay.md) + - [Z-order Control](reference/arkui-ts/ts-universal-attributes-z-order.md) + - [Transformation](reference/arkui-ts/ts-universal-attributes-transformation.md) + - [Image Effect Configuration](reference/arkui-ts/ts-universal-attributes-image-effect.md) + - [Shape Clipping](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + - [Text Style](reference/arkui-ts/ts-universal-attributes-text-style.md) + - [Grid](reference/arkui-ts/ts-universal-attributes-grid.md) + - [Gradient Color](reference/arkui-ts/ts-universal-attributes-gradient-color.md) + - [Popup Control](reference/arkui-ts/ts-universal-attributes-popup.md) + - [Menu Control](reference/arkui-ts/ts-universal-attributes-menu.md) + - [Click Control](reference/arkui-ts/ts-universal-attributes-click.md) + - [Focus Control](reference/arkui-ts/ts-universal-attributes-focus.md) + - [Hover Effect](reference/arkui-ts/ts-universal-attributes-hover-effect.md) + - [Component ID](reference/arkui-ts/ts-universal-attributes-component-id.md) + - [Touch Target](reference/arkui-ts/ts-universal-attributes-touch-target.md) + - [Polymorphic Style](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) + - Gesture Processing + - [Gesture Binding Methods](reference/arkui-ts/ts-gesture-settings.md) + - Basic Gestures + - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) + - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) + - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) + - [Combined Gestures](reference/arkui-ts/ts-combined-gestures.md) + - Basic Components + - [Blank](reference/arkui-ts/ts-basic-components-blank.md) + - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) + - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) + - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) + - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) + - [Image](reference/arkui-ts/ts-basic-components-image.md) + - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) + - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) + - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) + - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) + - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) + - [Progress](reference/arkui-ts/ts-basic-components-progress.md) + - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Radio](reference/arkui-ts/ts-basic-components-radio.md) + - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [RemoteWindow](reference/arkui-ts/ts-basic-components-remotewindow.md) + - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [Search](reference/arkui-ts/ts-basic-components-search.md) + - [Select](reference/arkui-ts/ts-basic-components-select.md) + - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) + - [Text](reference/arkui-ts/ts-basic-components-text.md) + - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) + - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) + - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) + - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) + - [Web](reference/arkui-ts/ts-basic-components-web.md) + - [XComponent](reference/arkui-ts/ts-basic-components-xcomponent.md) + - Container Components + - [AbilityComponent](reference/arkui-ts/ts-container-ability-component.md) + - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) + - [Badge](reference/arkui-ts/ts-container-badge.md) + - [Column](reference/arkui-ts/ts-container-column.md) + - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) + - [Counter](reference/arkui-ts/ts-container-counter.md) + - [Flex](reference/arkui-ts/ts-container-flex.md) + - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) + - [Grid](reference/arkui-ts/ts-container-grid.md) + - [GridItem](reference/arkui-ts/ts-container-griditem.md) + - [List](reference/arkui-ts/ts-container-list.md) + - [ListItem](reference/arkui-ts/ts-container-listitem.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) + - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) + - [RelativeContainer](reference/arkui-ts/ts-container-relativecontainer.md) + - [Row](reference/arkui-ts/ts-container-row.md) + - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) + - [Scroll](reference/arkui-ts/ts-container-scroll.md) + - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) + - [Stack](reference/arkui-ts/ts-container-stack.md) + - [Swiper](reference/arkui-ts/ts-container-swiper.md) + - [Tabs](reference/arkui-ts/ts-container-tabs.md) + - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - Media Components + - [Video](reference/arkui-ts/ts-media-components-video.md) + - Drawing Components + - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) + - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) + - [Line](reference/arkui-ts/ts-drawing-components-line.md) + - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) + - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) + - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) + - Canvas Components + - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D](reference/arkui-ts/ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) + - [Path2D](reference/arkui-ts/ts-components-canvas-path2d.md) + - [CanvasGradient](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [ImageBitmap](reference/arkui-ts/ts-components-canvas-imagebitmap.md) + - [ImageData](reference/arkui-ts/ts-components-canvas-imagedata.md) - Animation - - [Attribute Animation](reference/arkui-ts/ts-animatorproperty.md) + - [AnimatorProperty](reference/arkui-ts/ts-animatorproperty.md) - [Explicit Animation](reference/arkui-ts/ts-explicit-animation.md) - Transition Animation - [Page Transition](reference/arkui-ts/ts-page-transition-animation.md) @@ -546,7 +460,7 @@ - [Matrix Transformation](reference/arkui-ts/ts-matrix-transformation.md) - [Interpolation Calculation](reference/arkui-ts/ts-interpolation-calculation.md) - Global UI Methods - - Dialog Box + - Pop-up Window - [Alert Dialog Box](reference/arkui-ts/ts-methods-alert-dialog-box.md) - [Action Sheet](reference/arkui-ts/ts-methods-action-sheet.md) - [Custom Dialog Box](reference/arkui-ts/ts-methods-custom-dialog-box.md) @@ -554,52 +468,160 @@ - [Time Picker Dialog Box](reference/arkui-ts/ts-methods-timepicker-dialog.md) - [Text Picker Dialog Box](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [Menu](reference/arkui-ts/ts-methods-menu.md) - - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) + - [Built-in Enums](reference/arkui-ts/ts-appendix-enums.md) + - Component Reference (JavaScript-based Web-like Development Paradigm) + - Universal Component Information + - [Universal Attributes](reference/arkui-js/js-components-common-attributes.md) + - [Universal Styles](reference/arkui-js/js-components-common-styles.md) + - [Universal Events](reference/arkui-js/js-components-common-events.md) + - [Universal Methods](reference/arkui-js/js-components-common-methods.md) + - [Animation Styles](reference/arkui-js/js-components-common-animation.md) + - [Gradient Styles](reference/arkui-js/js-components-common-gradient.md) + - [Transition Styles](reference/arkui-js/js-components-common-transition.md) + - [Media Query](reference/arkui-js/js-components-common-mediaquery.md) + - [Custom Font Styles](reference/arkui-js/js-components-common-customizing-font.md) + - [Atomic Layout](reference/arkui-js/js-components-common-atomic-layout.md) + - Container Component + - [badge](reference/arkui-js/js-components-container-badge.md) + - [dialog](reference/arkui-js/js-components-container-dialog.md) + - [div](reference/arkui-js/js-components-container-div.md) + - [form](reference/arkui-js/js-components-container-form.md) + - [list](reference/arkui-js/js-components-container-list.md) + - [list-item](reference/arkui-js/js-components-container-list-item.md) + - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) + - [panel](reference/arkui-js/js-components-container-panel.md) + - [popup](reference/arkui-js/js-components-container-popup.md) + - [refresh](reference/arkui-js/js-components-container-refresh.md) + - [stack](reference/arkui-js/js-components-container-stack.md) + - [stepper](reference/arkui-js/js-components-container-stepper.md) + - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) + - [swiper](reference/arkui-js/js-components-container-swiper.md) + - [tabs](reference/arkui-js/js-components-container-tabs.md) + - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) + - [tab-content](reference/arkui-js/js-components-container-tab-content.md) + - Basic Components + - [button](reference/arkui-js/js-components-basic-button.md) + - [chart](reference/arkui-js/js-components-basic-chart.md) + - [divider](reference/arkui-js/js-components-basic-divider.md) + - [image](reference/arkui-js/js-components-basic-image.md) + - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) + - [input](reference/arkui-js/js-components-basic-input.md) + - [label](reference/arkui-js/js-components-basic-label.md) + - [marquee](reference/arkui-js/js-components-basic-marquee.md) + - [menu](reference/arkui-js/js-components-basic-menu.md) + - [option](reference/arkui-js/js-components-basic-option.md) + - [picker](reference/arkui-js/js-components-basic-picker.md) + - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) + - [piece](reference/arkui-js/js-components-basic-piece.md) + - [progress](reference/arkui-js/js-components-basic-progress.md) + - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) + - [rating](reference/arkui-js/js-components-basic-rating.md) + - [richtext](reference/arkui-js/js-components-basic-richtext.md) + - [search](reference/arkui-js/js-components-basic-search.md) + - [select](reference/arkui-js/js-components-basic-select.md) + - [slider](reference/arkui-js/js-components-basic-slider.md) + - [span](reference/arkui-js/js-components-basic-span.md) + - [switch](reference/arkui-js/js-components-basic-switch.md) + - [text](reference/arkui-js/js-components-basic-text.md) + - [textarea](reference/arkui-js/js-components-basic-textarea.md) + - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) + - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) + - [toggle](reference/arkui-js/js-components-basic-toggle.md) + - [web](reference/arkui-js/js-components-basic-web.md) + - [xcomponent](reference/arkui-js/js-components-basic-xcomponent.md) + - Media Components + - [video](reference/arkui-js/js-components-media-video.md) + - Canvas Components + - [canvas](reference/arkui-js/js-components-canvas-canvas.md) + - [CanvasRenderingContext2D](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + - [Image](reference/arkui-js/js-components-canvas-image.md) + - [CanvasGradient](reference/arkui-js/js-components-canvas-canvasgradient.md) + - [ImageData](reference/arkui-js/js-components-canvas-imagedata.md) + - [Path2D](reference/arkui-js/js-components-canvas-path2d.md) + - [ImageBitmap](reference/arkui-js/js-components-canvas-imagebitmap.md) + - [OffscreenCanvas](reference/arkui-js/js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + - Grid Components + - [Basic Concepts](reference/arkui-js/js-components-grid-basic-concepts.md) + - [grid-container](reference/arkui-js/js-components-grid-container.md) + - [grid-row](reference/arkui-js/js-components-grid-row.md) + - [grid-col](reference/arkui-js/js-components-grid-col.md) + - SVG Components + - [Universal Attributes](reference/arkui-js/js-components-svg-common-attributes.md) + - [svg](reference/arkui-js/js-components-svg.md) + - [rect](reference/arkui-js/js-components-svg-rect.md) + - [circle](reference/arkui-js/js-components-svg-circle.md) + - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) + - [path](reference/arkui-js/js-components-svg-path.md) + - [line](reference/arkui-js/js-components-svg-line.md) + - [polyline](reference/arkui-js/js-components-svg-polyline.md) + - [polygon](reference/arkui-js/js-components-svg-polygon.md) + - [text](reference/arkui-js/js-components-svg-text.md) + - [tspan](reference/arkui-js/js-components-svg-tspan.md) + - [textPath](reference/arkui-js/js-components-svg-textpath.md) + - [animate](reference/arkui-js/js-components-svg-animate.md) + - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) + - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) + - Custom Components + - [Basic Usage](reference/arkui-js/js-components-custom-basic-usage.md) + - [Style Inheritance](reference/arkui-js/js-components-custom-style.md) + - [Custom Events](reference/arkui-js/js-components-custom-events.md) + - [props](reference/arkui-js/js-components-custom-props.md) + - [Event Parameter](reference/arkui-js/js-components-custom-event-parameter.md) + - [slot](reference/arkui-js/js-components-custom-slot.md) + - [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md) + - [Data Type Attributes](reference/arkui-js/js-appendix-types.md) - APIs + - [API Reference Document Description](reference/apis/development-intro.md) - Ability Framework - - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) - - [@ohos.ability.errorCode ](reference/apis/js-apis-ability-errorCode.md) - - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) - - [@ohos.application.Ability](reference/apis/js-apis-application-ability.md) - - [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md) - - [@ohos.application.abilityDelegatorRegistry](reference/apis/js-apis-abilityDelegatorRegistry.md) - - [@ohos.application.AbilityStage ](reference/apis/js-apis-application-abilitystage.md) - - [@ohos.application.appManager](reference/apis/js-apis-appmanager.md) - - [@ohos.application.Configuration](reference/apis/js-apis-configuration.md) - - [@ohos.application.ConfigurationConstant](reference/apis/js-apis-configurationconstant.md) - - [@ohos.ability.featureAbility](reference/apis/js-apis-featureAbility.md) - - [@ohos.application.formBindingData](reference/apis/js-apis-formbindingdata.md) - - [@ohos.application.FormExtension](reference/apis/js-apis-formextension.md) - - [@ohos.application.formError](reference/apis/js-apis-formerror.md) - - [@ohos.application.formHost](reference/apis/js-apis-formhost.md) - - [@ohos.application.formInfo](reference/apis/js-apis-formInfo.md) - - [@ohos.application.missionManager](reference/apis/js-apis-missionManager.md) - - [@ohos.application.formProvider](reference/apis/js-apis-formprovider.md) - - [@ohos.ability.particleAbility](reference/apis/js-apis-particleAbility.md) - - [@ohos.application.ServiceExtensionAbility](reference/apis/js-apis-service-extension-ability.md) - - [@ohos.application.StartOptions](reference/apis/js-apis-application-StartOptions.md) - - [@ohos.application.StaticSubscriberExtensionAbility](reference/apis/js-apis-application-staticSubscriberExtensionAbility.md) - - [@ohos.application.uriPermissionManager](reference/apis/js-apis-uripermissionmanager.md) - - [@ohos.application.Want](reference/apis/js-apis-application-Want.md) - - [@ohos.wantAgent](reference/apis/js-apis-wantAgent.md) - - [dataAbilityHelper](reference/apis/js-apis-dataAbilityHelper.md) - - [context](reference/apis/js-apis-Context.md) - - [AbilityContext](reference/apis/js-apis-ability-context.md) - - [abilityDelegator](reference/apis/js-apis-application-abilityDelegator.md) - - [abilityDelegatorArgs](reference/apis/js-apis-application-abilityDelegatorArgs.md) - - [abilityMonitor](reference/apis/js-apis-application-abilityMonitor.md) - - [AbilityRunningInfo](reference/apis/js-apis-abilityrunninginfo.md) - - [AbilityStageContext](reference/apis/js-apis-abilitystagecontext.md) - - [Context](reference/apis/js-apis-application-context.md) - - [ExtensionContext](reference/apis/js-apis-extension-context.md) - - [ExtensionRunningInfo](reference/apis/js-apis-extensionrunninginfo.md) - - [FormExtensionContext](reference/apis/js-apis-formextensioncontext.md) - - [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md) - - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) - - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) - - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) - - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) - - Common Event and Notification + - FA Model + - [@ohos.ability.featureAbility](reference/apis/js-apis-featureAbility.md) + - [@ohos.ability.particleAbility](reference/apis/js-apis-particleAbility.md) + - [dataAbilityHelper](reference/apis/js-apis-dataAbilityHelper.md) + - [context](reference/apis/js-apis-Context.md) + - Stage Model + - [@ohos.application.Ability](reference/apis/js-apis-application-ability.md) + - [@ohos.application.AbilityConstant](reference/apis/js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage](reference/apis/js-apis-application-abilitystage.md) + - [@ohos.application.abilityLifecycleCallback](reference/apis/js-apis-application-abilityLifecycleCallback.md) + - [@ohos.application.DataShareExtensionAbility](reference/apis/js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.FormExtension](reference/apis/js-apis-formextension.md) + - [@ohos.application.ServiceExtensionAbility](reference/apis/js-apis-service-extension-ability.md) + - [@ohos.application.StartOptions](reference/apis/js-apis-application-StartOptions.md) + - [@ohos.application.StaticSubscriberExtensionAbility](reference/apis/js-apis-application-staticSubscriberExtensionAbility.md) + - [AbilityContext](reference/apis/js-apis-ability-context.md) + - [ApplicationContext](reference/apis/js-apis-application-applicationContext.md) + - [AbilityStageContext](reference/apis/js-apis-abilitystagecontext.md) + - [Context](reference/apis/js-apis-application-context.md) + - [ExtensionContext](reference/apis/js-apis-extension-context.md) + - [FormExtensionContext](reference/apis/js-apis-formextensioncontext.md) + - [PermissionRequestResult](reference/apis/js-apis-permissionrequestresult.md) + - [ServiceExtensionContext](reference/apis/js-apis-service-extension-context.md) + - FA and Stage Models + - [@ohos.ability.dataUriUtils](reference/apis/js-apis-DataUriUtils.md) + - [@ohos.ability.errorCode](reference/apis/js-apis-ability-errorCode.md) + - [@ohos.ability.wantConstant](reference/apis/js-apis-ability-wantConstant.md) + - [@ohos.application.abilityDelegatorRegistry](reference/apis/js-apis-abilityDelegatorRegistry.md) + - [@ohos.application.appManager](reference/apis/js-apis-appmanager.md) + - [@ohos.application.Configuration](reference/apis/js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant](reference/apis/js-apis-configurationconstant.md) + - [@ohos.application.formBindingData](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.formError](reference/apis/js-apis-formerror.md) + - [@ohos.application.formHost](reference/apis/js-apis-formhost.md) + - [@ohos.application.formInfo](reference/apis/js-apis-formInfo.md) + - [@ohos.application.missionManager](reference/apis/js-apis-missionManager.md) + - [@ohos.application.formProvider](reference/apis/js-apis-formprovider.md) + - [@ohos.application.Want](reference/apis/js-apis-application-Want.md) + - [@ohos.wantAgent](reference/apis/js-apis-wantAgent.md) + - [abilityDelegator](reference/apis/js-apis-application-abilityDelegator.md) + - [abilityDelegatorArgs](reference/apis/js-apis-application-abilityDelegatorArgs.md) + - [abilityMonitor](reference/apis/js-apis-application-abilityMonitor.md) + - [AbilityRunningInfo](reference/apis/js-apis-abilityrunninginfo.md) + - [ExtensionRunningInfo](reference/apis/js-apis-extensionrunninginfo.md) + - [MissionSnapshot](reference/apis/js-apis-application-MissionSnapshot.md) + - [ProcessRunningInfo](reference/apis/js-apis-processrunninginfo.md) + - [shellCmdResult](reference/apis/js-apis-application-shellCmdResult.md) + - Common Event and Notification - [@ohos.commonEvent](reference/apis/js-apis-commonEvent.md) - [@ohos.events.emitter](reference/apis/js-apis-emitter.md) - [@ohos.notification](reference/apis/js-apis-notification.md) @@ -607,15 +629,25 @@ - [EventHub](reference/apis/js-apis-eventhub.md) - Bundle Management - [@ohos.bundle](reference/apis/js-apis-Bundle.md) - - [@ohos.bundleState ](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.bundle.defaultAppManager](reference/apis/js-apis-bundle-defaultAppManager.md) + - [@ohos.bundleState](reference/apis/js-apis-deviceUsageStatistics.md) - [@ohos.zlib](reference/apis/js-apis-zlib.md) + - [AbilityInfo](reference/apis/js-apis-bundle-AbilityInfo.md) + - [ApplicationInfo](reference/apis/js-apis-bundle-ApplicationInfo.md) + - [BundleInfo](reference/apis/js-apis-bundle-BundleInfo.md) + - [CustomizeData](reference/apis/js-apis-bundle-CustomizeData.md) + - [ElementName](reference/apis/js-apis-bundle-ElementName.md) + - [ExtensionAbilityInfo](reference/apis/js-apis-bundle-ExtensionAbilityInfo.md) + - [HapModuleInfo](reference/apis/js-apis-bundle-HapModuleInfo.md) + - [Metadata](reference/apis/js-apis-bundle-Metadata.md) + - [ModuleInfo](reference/apis/js-apis-bundle-ModuleInfo.md) - UI Page - [@ohos.animator](reference/apis/js-apis-animator.md) - [@ohos.mediaquery](reference/apis/js-apis-mediaquery.md) - [@ohos.prompt](reference/apis/js-apis-prompt.md) - [@ohos.router](reference/apis/js-apis-router.md) - Graphics - - [@ohos.display ](reference/apis/js-apis-display.md) + - [@ohos.display](reference/apis/js-apis-display.md) - [@ohos.screenshot](reference/apis/js-apis-screenshot.md) - [@ohos.window](reference/apis/js-apis-window.md) - [webgl](reference/apis/js-apis-webgl.md) @@ -630,25 +662,30 @@ - [@ohos.i18n](reference/apis/js-apis-i18n.md) - [@ohos.intl](reference/apis/js-apis-intl.md) - [@ohos.resourceManager](reference/apis/js-apis-resource-manager.md) - - Resource Scheduling + - Resource Scheduling - [@ohos.backgroundTaskManager](reference/apis/js-apis-backgroundTaskManager.md) - - [@ohos.workScheduler ](reference/apis/js-apis-workScheduler.md) + - [@ohos.workScheduler](reference/apis/js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - Custom Management - [@ohos.configPolicy](reference/apis/js-apis-config-policy.md) - [@ohos.enterpriseDeviceManager](reference/apis/js-apis-enterprise-device-manager.md) + - [@ohos.EnterpriseAdminExtensionAbility](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - Security - [@ohos.abilityAccessCtrl](reference/apis/js-apis-abilityAccessCtrl.md) - - [@ohos.security.huks ](reference/apis/js-apis-huks.md) - - [@ohos.userIAM.userAuth ](reference/apis/js-apis-useriam-userauth.md) + - [@ohos.privacyManager](reference/apis/js-apis-privacyManager.md) + - [@ohos.security.huks](reference/apis/js-apis-huks.md) + - [@ohos.userIAM.userAuth](reference/apis/js-apis-useriam-userauth.md) - [@system.cipher](reference/apis/js-apis-system-cipher.md) - Data Management - - [@ohos.data.dataAbility ](reference/apis/js-apis-data-ability.md) + - [@ohos.data.dataAbility](reference/apis/js-apis-data-ability.md) + - [@ohos.data.dataShare](reference/apis/js-apis-data-dataShare.md) + - [@ohos.data.dataSharePredicates](reference/apis/js-apis-data-dataSharePredicates.md) + - [@ohos.data.dataShareResultSet](reference/apis/js-apis-data-DataShareResultSet.md) - [@ohos.data.distributedData](reference/apis/js-apis-distributed-data.md) - [@ohos.data.distributedDataObject](reference/apis/js-apis-data-distributedobject.md) - [@ohos.data.preferences](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb](reference/apis/js-apis-data-rdb.md) - - [@ohos.settings](reference/apis/js-apis-settings.md) + - [@ohos.data.ValuesBucket](reference/apis/js-apis-data-ValuesBucket.md) - [resultSet](reference/apis/js-apis-data-resultset.md) - File Management - [@ohos.document](reference/apis/js-apis-document.md) @@ -658,7 +695,8 @@ - [@ohos.statfs](reference/apis/js-apis-statfs.md) - [@ohos.storageStatistics](reference/apis/js-apis-storage-statistics.md) - [@ohos.volumeManager](reference/apis/js-apis-volumemanager.md) - - Telephony + - [@ohos.securityLabel](reference/apis/js-apis-securityLabel.md) + - Telephony Service - [@ohos.contact](reference/apis/js-apis-contact.md) - [@ohos.telephony.call](reference/apis/js-apis-call.md) - [@ohos.telephony.observer](reference/apis/js-apis-observer.md) @@ -671,10 +709,13 @@ - [@ohos.net.http](reference/apis/js-apis-http.md) - [@ohos.request](reference/apis/js-apis-request.md) - [@ohos.net.socket](reference/apis/js-apis-socket.md) - - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) + - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) - Connectivity - [@ohos.bluetooth](reference/apis/js-apis-bluetooth.md) - [@ohos.connectedTag](reference/apis/js-apis-connectedTag.md) + - [@ohos.nfc.cardEmulation](reference/apis/js-apis-cardEmulation.md) + - [@ohos.nfc.controller](reference/apis/js-apis-nfcController.md) + - [@ohos.nfc.tag](reference/apis/js-apis-nfcTag.md) - [@ohos.rpc](reference/apis/js-apis-rpc.md) - [@ohos.wifi](reference/apis/js-apis-wifi.md) - [@ohos.wifiext](reference/apis/js-apis-wifiext.md) @@ -685,6 +726,7 @@ - [@ohos.hichecker](reference/apis/js-apis-hichecker.md) - [@ohos.hidebug](reference/apis/js-apis-hidebug.md) - [@ohos.hilog](reference/apis/js-apis-hilog.md) + - [@ohos.hiSysEvent](reference/apis/js-apis-hisysevent.md) - [@ohos.hiTraceChain](reference/apis/js-apis-hitracechain.md) - [@ohos.hiTraceMeter](reference/apis/js-apis-hitracemeter.md) - [@ohos.inputMethod](reference/apis/js-apis-inputmethod.md) @@ -695,18 +737,24 @@ - [@ohos.wallpaper](reference/apis/js-apis-wallpaper.md) - [Timer](reference/apis/js-apis-timer.md) - Device Management - - [@ohos.batteryInfo ](reference/apis/js-apis-battery-info.md) + - [@ohos.batteryInfo](reference/apis/js-apis-battery-info.md) - [@ohos.brightness](reference/apis/js-apis-brightness.md) - [@ohos.deviceInfo](reference/apis/js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager](reference/apis/js-apis-device-manager.md) - [@ohos.geolocation](reference/apis/js-apis-geolocation.md) - [@ohos.multimodalInput.inputConsumer](reference/apis/js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputEvent](reference/apis/js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient](reference/apis/js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor](reference/apis/js-apis-inputmonitor.md) + - [@ohos.multimodalInput.keyCode](reference/apis/js-apis-keycode.md) + - [@ohos.multimodalInput.keyEvent](reference/apis/js-apis-keyevent.md) + - [@ohos.multimodalInput.mouseEvent](reference/apis/js-apis-mouseevent.md) + - [@ohos.multimodalInput.touchEvent](reference/apis/js-apis-touchevent.md) - [@ohos.power](reference/apis/js-apis-power.md) - [@ohos.runningLock](reference/apis/js-apis-runninglock.md) - [@ohos.sensor](reference/apis/js-apis-sensor.md) + - [@ohos.settings](reference/apis/js-apis-settings.md) - [@ohos.systemParameter](reference/apis/js-apis-system-parameter.md) - [@ohos.thermal](reference/apis/js-apis-thermal.md) - [@ohos.update](reference/apis/js-apis-update.md) diff --git a/en/contribute/OpenHarmony-hdf-coding-guide.md b/en/contribute/OpenHarmony-hdf-coding-guide.md index 84deab62a8cea60e9cd9febfe50ab8df0b3dc2f7..2349d0148c5b4c2bd3128afbe5e4b5f026ae5222 100644 --- a/en/contribute/OpenHarmony-hdf-coding-guide.md +++ b/en/contribute/OpenHarmony-hdf-coding-guide.md @@ -190,7 +190,7 @@ root { [Description] The HDF places the same type of devices in the same host. You can develop and deploy the driver functionalities of the host by layer, so that one driver has multiple nodes. The following figure shows the HDF driver model. - + Place devices of the same type in the same host. When adding a device, check whether the host of the same type already exists. If such a host already exists, configure the device in the host. Do not configure the same host again. A device belongs to only one driver. Therefore, do not configure the same device in different hosts. diff --git a/en/contribute/documentation-contribution.md b/en/contribute/documentation-contribution.md index 8a5eb74e52b929e155418875cef25dfde9ebdc15..430587fe0ffa3386cf17d64f49af4f9d7f1e2bd4 100755 --- a/en/contribute/documentation-contribution.md +++ b/en/contribute/documentation-contribution.md @@ -17,7 +17,7 @@ OpenHarmony has the right to modify the adopted content according to the communi [Creative Commons License version 4.0](https://creativecommons.org/licenses/by/4.0/legalcode) -## Contribution Methods<a name = contribution-methods></a> +## Contribution Methods ### Submitting Issues for Existing Documents @@ -65,7 +65,7 @@ You are welcome to contribute documents to the release. For details, see [Writin You are welcome to share your experience and expertise with other developers to help them get started. For example, you can contribute tutorials and FAQs by using the following templates: -- [Tutorial Template](template/tutorial-template.md). You can contribute tutorials in the `contribute/tutorial` folder. -- [FAQ Template](template/faq-template.md). You can contribute FAQs in the `contribute/faqs` folder. +- [Tutorial Template](https://gitee.com/openharmony/docs/blob/master/en/contribute/template/tutorial-template.md). You can contribute tutorials in the `contribute/tutorial` folder. +- [FAQ Template](https://gitee.com/openharmony/docs/blob/master/en/contribute/template/faq-template.md). You can contribute FAQs in the `contribute/faqs` folder. More writing templates are available in the **contribute** folder in the **Docs** repository. diff --git a/en/contribute/template/concept-overview-template.md b/en/contribute/template/concept-overview-template.md deleted file mode 100644 index 76b46ec93252db454751976d43397c821ea20f4e..0000000000000000000000000000000000000000 --- a/en/contribute/template/concept-overview-template.md +++ /dev/null @@ -1,111 +0,0 @@ -# Overview Template - -## Basic Concepts - -***[Writing Requirements]*** - -*Mandatory. Describe basic concepts related to a development task to help developers better understand the task. The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* - -| Requirement| Satisfied or Not| -| -------- | -------- | -| Common concepts in the industry are not described.| | -| Common terms in the industry, rather than internal terms, are used.| | - - -***[Example]*** - - -The XX system provides the audio module for your application to implement audio-related features, including audio playback, recording, and volume management. - - -It is considered good practice that you understand the following concepts before starting application development: - - -- Sampling - Sampling is a process where analog signals are converted into digital signals that can be represented by 0101. - -- Sampling rate - Sampling rate is the number of samples extracted from a continuous signal per second to form a discrete signal. It is measured in Hz. Generally, human hearing range is from 20 Hz to 20 kHz. Common audio sampling rates include 8 kHz, 11.025 kHz, 22.05 kHz, 16 kHz, 37.8 kHz, 44.1 kHz, 48 kHz, 96 kHz, and 192 kHz. - -- Channel - Channels refer to different spatial positions where independent audio signals are recorded or played. The number of channels is the number of audio sources used during audio recording, or the number of speakers used for audio playback. - -- Audio frame - Audio data is in stream form. For the convenience of audio algorithm processing and transmission, it is generally agreed that a data amount in a unit of 2.5 to 60 milliseconds is one audio frame. This unit is called sampling time, and its length is specific to codecs and the application requirements. - - -## Working Principles - -***[Writing Requirements]*** - -*Optional. You can delete this section if the working principles are simple and the basic concepts in the **Overview** section are enough for understanding.* - -*Describe the implementation principles, for example, the time for calling the APIs and triggering callbacks related to key steps, to help developers better understand the basic operation principles, carry out development tasks, and locate problems.* - -*The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* - -| Requirement| Satisfied or Not| -| -------- | -------- | -| Only principles related to the development task are described.| | -| Supplementary graphics are used, such as sequence diagrams and flowcharts. The text description is consistent with the figure description.| | - -***[Example 1]*** - -- Semaphore initialization: The system allocates memory for the semaphores configured (the value of *N* can be configured by users and is limited by the memory), initializes all semaphores to be unused semaphores, and adds them to a linked list for the system to use. - -- Semaphore creation: The system obtains a semaphore from the linked list of unused semaphores and assigns an initial value to the semaphore. - -- Semaphore request: If the counter value is greater than 0, the system allocates a semaphore, decreases the value by 1, and returns a success message. Otherwise, the system blocks the task and adds the task to the end of a task queue waiting for semaphores. The wait timeout period can be set. - -- When a semaphore is released, if there is no task waiting for it, the counter is increased by 1. Otherwise, the first task in the wait queue is woken up. - -- Semaphore deletion: The system sets a semaphore in use to the unused state and inserts it to the linked list of unused semaphores. - -- Semaphore allows only a specified number of tasks to access a shared resource at a time. When the number of tasks accessing the resource reaches the limit, other tasks will be blocked until the semaphore is released. - - -***[Example 2]*** - -**Working Principles of Mutexes** - -In a multi-task environment, multiple tasks may access the same shared resource. However, certain shared resources are not shared, and can only be accessed exclusively by tasks. A mutex can be used to address this issue. - -When non-shared resources are accessed by a task, the mutex is locked. Other tasks will be blocked until the mutex is released by the task. The mutex allows only one task to access the shared resources at a time, ensuring integrity of operations on the shared resources. - - - -## Limitations and Constraints - -***[Writing Requirements]*** - -*Mandatory. Describe the constraints of the development task and the negative impact of the constraints, including but not limited to the following:* - -- ***Function Limitations*** - - *Application scope of the function (specify scenarios that are not supported)* - - *Specification limitations* - -- ***Operation Limitations*** - - - *Operations on known issues* - - *Potentially risky operations (such as performance deterioration)* - - *Operations that may cause performance deterioration* - -*The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* - -| Requirement| Satisfied or Not| -| -------- | -------- | -| The function limitations or operation restrictions are clearly specified.| | -| Only constraints that affect task development or user experience are described.| | -| Operations that are prone to errors are described in the procedure but not described in this section.| | - -***[Example]*** - -**Limitations and Constraints on Mutexes:** - -- Two tasks cannot lock the same mutex. If a task attempts to lock a mutex held by another task, the task will be blocked until the mutex is unlocked. - -- Mutexes cannot be used in the interrupt service program. - -- When using the LiteOS-A kernel, the xx system must ensure real-time task scheduling and avoid long-time task blocking. Therefore, a mutex must be released as soon as possible. - -- When a mutex is held by a task, the task priority cannot be changed by using APIs such as **LOS_TaskPriSet**. diff --git a/en/contribute/template/figures/how-distributedobject-works.png b/en/contribute/template/figures/how-distributedobject-works.png new file mode 100644 index 0000000000000000000000000000000000000000..33785a3fd4c66624b298b1aa36959dbf635d2343 Binary files /dev/null and b/en/contribute/template/figures/how-distributedobject-works.png differ diff --git a/en/contribute/template/guide-template.md b/en/contribute/template/guide-template.md index 90b5133d0817050586903c8514ddb5e2b838a324..c497b984ff363a56376a5e1d470a177d9e540003 100644 --- a/en/contribute/template/guide-template.md +++ b/en/contribute/template/guide-template.md @@ -1,158 +1,405 @@ -# Development Guidelines +# Development Guide Writing Template -***[Writing Requirements]*** +> **NOTE** +> +> *1. This template provides the recommended development guide document framework and writing instructions for typical knowledge points. In your writing, complete the development task scenario analysis and development guide outline design based on the specific **solution/feature/function/module**, and then write the content based on this template.* +> +> *2. Do not add any content between level-1 title (marked with #) and level-2 title (marked with ##).* +> +> *3. Delete all the writing instructions in italics from your formal documents.* + + +## *Example* Overview + +*Mandatory. Based on the scenario division of the solution/feature/function/module, you need to provide either "Example Overview" or "Example Task Scenario Overview", or both of them.* + +*1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it.* + +*2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it.* + +***[General Instructions for Writing the Development Guide]*** + +***1. Target audience**: internal and external developers (including product managers). Guidelines for UX designers are usually carried by UX design specifications and are not covered in the development guide. If UX design specifications need to be mentioned in the development guide, use hyperlinks.* + +***2. Content positioning**: Introduce what the solution/feature/function/module is, why it is required, and how to design, develop, and release related applications/devices. The development guide aims to help developers learn necessary knowledge and achieve specified task objectives in actual development activities.* -*Mandatory. Describe how a developer completes tasks in a specific scenario. Include one scenario in each section. The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* +***3. User-oriented****: Always provide developer-concerned, perceptible, and useful content from the perspective of developers.* +***4. Task-oriented****: Focus on actual tasks of developers, and provide complete, correct guidance that is easy to follow.* -| Requirement| Satisfied or Not| -| -------- | -------- | -| Each section covers only one scenario. If there are multiple scenarios, provide development guidelines for each scenario in separate sections. For example, you can use the following sections in **Audio**: **Development Guidelines on Audio Playback**, **Development Guidelines on Volume Management**, and **Development Guidelines on Sound Playback**.| | -| Use verbs + nouns to describe task operations in titles.| | +*5. This template only provides the basic document framework. You can adjust the content based on the actual requirements.* -## When to Use +### Introduction + +*Mandatory.* + +***[Developers' Concerns]*** + +*What is the solution/feature/function/module (definition)? What problems can it solve or what benefits can it bring (purpose/customer benefits - why)? * + +***[Key Writing Points]*** + +- *Provide easy-to-understand and scenario-specific descriptions. Refer to the SCQA method below to introduce the scenarios and characteristics of the solution/feature/function/module.* + - *S: situation. Introduce a familiar scenario.* + - *C: complication. Describe the conflict between the situation and requirement.* + - *Q: question. Ask a question. What can I do in such a case?* + - *A: answer. Describe the solution.* + +- *Visualize abstract concepts. You can provide content from the perspective of consumers for better understanding, for example, scenario effect in UX.* ***[Writing Requirements]*** -*Mandatory. Describe in which scenario, what problem is solved, and what the final effect is. Use the SCQA method.* +- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* + +- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* + +- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* + -- *S: situation. Introduce a familiar scenario.* +### Basic Concepts -- *C: complication. Describe the conflict between the situation and requirement.* +*Optional. Describe the basic concepts that are common to all task scenarios.* -- *Q: question. Ask a question. What can I do in such a case?* +***[Developers' Concerns]*** -- *A: answer. Describe the solution.* +*What are the unique concepts that I need to know when using the solution/feature/function/module?* -*The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* +***[Key Writing Points]*** -| Requirement| Satisfied or Not| -| -------- | -------- | -| Clearly describe the background, what operations are done when and where, what problems are solved, and what benefits are delivered.| | +- *Provide only the concepts that are mandatory in development tasks.* + +- *Describe here concepts used in multiple chapters such as the operation mechanism, restrictions, and development process. If a concept is used only in a chapter, describe the concept in that chapter only.* + +- *Do not describe common concepts in the industry. Use common terms in the industry instead of jargon.* + +- *If there are logical relationships between concepts, you are advised to use figures to describe the relationships.* + +***[Writing Requirements]*** + +- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* + +- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* + +- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* ***[Example]*** -You can use APIs described in this section to convert audio data into audible analog signals, play the audio signals using output devices, and manage playback tasks. +Before developing relational databases, you must understand the following basic concepts: + +- **RDB** + +A type of database based on the relational model of data. The RDB stores data in rows and columns. An RDB is also called RDB store. + +- **Predicate** + + Property or feature of a data entity, or the relationship between data entities. It is mainly used to define operation conditions. + +- **Result set** + + A set of query results used to access the data. You can access the required data in a result set in flexible modes. + + +### Working Principles + +*Optional. Describe the working principles that are common to all task scenarios.* + +***[Developers' Concerns]*** + +*How does the solution/feature/function/module work? What are the API calling and triggering time of key steps? I want to understand its principles for better use and debugging.* +***[Key Writing Points]*** -## Available APIs +- *If the principle is simple and can be understood from the content under "Basic Concepts", do not provide this section.* + +- *Describe only the mechanisms and principles that are visible in the development tasks (use or access). Do not provide internal implementation that is invisible to developers.* + +- *If necessary, use sequence diagrams and flowcharts. Ensure that the text description matches the figure description.* + +- *Be careful not to disclose internal information.* ***[Writing Requirements]*** -*Mandatory. Describe APIs involved in the development guideline to help developers have a general understanding of the APIs, thereby improving development efficiency. The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* +- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* + +- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* + +- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* + +***[Example]*** + +The distributed data objects are encapsulated into JS objects in distributed in-memory databases, which allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization. + +**Figure 1** Working mechanism -| Requirement| Satisfied or Not| -| -------- | -------- | -| Include only APIs relevant to the development task.| | -| If there are more than 10 APIs, you can provide only main APIs.| | + + + +### Constraints + +*Optional. Describe constraints that are common to all task scenarios.* + +***[Developers' Concerns]*** + +*What are the constraints for using the solution/feature/function/module? How well is the solution/feature/function/module implemented? Can it meet my requirements?* + +***[Key Writing Points]*** + +- *Describe perceptible constraints that affect development activities, including but not limited to the following:* + - ***Function constraints*** + - *Application scope of the solution/feature/function/module (Specify scenarios that are not supported.)* + - *Specification constraints* + - ***Operation constraints*** + - *Operations on known issues* + - *Potentially risky operations (such as performance deterioration)* + +- *Describe operations that are prone to errors in the procedure, but not in this section.* ***[Example]*** -The **AudioRenderer** class provides open audio playback capabilities. For details about the APIs, see the API reference. +- Data synchronization can be implemented across devices only for the applications with the same bundleName. + +- Each distributed data object occupies 100 KB to 150 KB of memory. Therefore, you are advised not to create too many distributed data objects. -**Table 1** Audio playback APIs +- The maximum size of a distributed data object is 500 KB. -| API| Description| -| -------- | -------- | -| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, the specified playback mode, and the default playback device.| -| AudioRenderer(AudioRendererInfo audioRendererInfo, PlayMode pm, AudioDeviceDescriptor outputDevice) throws IllegalArgumentException | A constructor used to create an **AudioRenderer** instance based on the specified playback parameters, playback mode, and playback device.| -| boolean play() | Plays audio streams.| -| boolean write(byte[] data, int offset, int size) | Writes audio data in the specified byte array into an audio receiver for playback.| +### Samples -## How to Develop +*Optional. Provide samples that are common to all task scenarios.* + +***[Developers' Concerns]*** + +*What sample code, codelabs, and demo projects are available?* + +***[Key Writing Points]*** + +*Provide links (generally Gitee links) to the released sample code, codelabs, and demo projects. Do not include project packages into the document as an attachment.* + +***[Example]*** + +The following sample is provided to help you better understand how to develop abilities: + +- [Intra- and Inter-page Navigation](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) + + +## Setting Up the Environment + +*Optional.* + +*Based on the analysis and breakdown of a specific task scenario, you can place the environment setup content under "Prerequisites" or "Preparations" and close to the "How to Develop" of the specific scenario.* + +*Specify how to prepare the development environment, including software and hardware configuration requirements, tool requirements, and device requirements.* + +*Delete this section if no special requirements are involved.* + + +### Environment Requirements ***[Writing Requirements]*** - *Mandatory. Describe the overall process to help developers quickly complete the task. The table below describes the writing requirements. After finishing the writing, check your content against these requirements one by one.* - -| Requirement| Satisfied or Not| -| -------- | -------- | -| **Writing a Development Procedure**| | -| Complete: All mandatory steps are provided.| | -| Clear: The logic of the writing is clear and reasonable. The overview, preparations, and operations in the document are described by following certain logic, and the chapters are not broken or contradictory.| | -| Sentence pattern for tasks: Use verbs + nouns to describe actions in titles or sentences.| | -| Prevention in advance: Describe the restrictions, error-prone operations, and potential risks in advance. Use general icons and styles.| | -| Clear steps-1: Describe the purpose of each step, no matter whether it is simple or not.| | -| Clear steps-2: Specify the environment, tools, operations, and how-to.| | -| If an operation is optional, specify the optional conditions.| | -| After the development procedure is complete, specify the expected results.| | -| **Writing a Code Segment**| | -| If a code segment involves commands to be copied by developers, display the commands in editable mode, instead of using screenshots. Use code snippets to wrap the commands.| | -| Highlight key code segments in blue (RGB: 0.0.255), and comment out key steps.| | -| The code display meets the code indentation requirements.| | -| If an API call is involved in a step, provide the API and its usage description or sample code. The code comes from specific instances.| | +*Describe the software and hardware configurations required by the development environment so that developers can prepare the environment in advance. You can use subtitles if there is a large amount of content.* ***[Example]*** -1. Use **AudioStreamInfo.Builder** to create an **AudioStreamInfo** instance for audio stream parameters. The following example uses the default values of the input parameters for **AudioStreamInfo.Builder**. You need to set the parameters based on the audio stream specification. - ``` - AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder() - .sampleRate(AudioStreamInfo.SAMPLE_RATE_UNSPECIFIED) - .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_NONE) - .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_INVALID) - .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_INVALID) - .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_UNKNOWN) - .build(); - ``` +The following table describes the environment configuration requirements specific to the Hi3861 development board. + + **Table 1** Hi3861 development environment-specific requirements + +| Platform Type| Development Tool| Function| How to Obtain| +| -------- | -------- | -------- | -------- | +| Linux server| SCons3.0.4+ | Executes script compilation.| Internet| +| Linux server| build-essential | Provides a basic software package for compilation and building.| Internet| + + +### Setting Up the Environment + +***[Writing Requirements]*** + +*Describe the procedure for setting up the development environment. If there is a large amount of content, use subtitles, for example, "Setting Up the Basic Build Environment" and "Setting Up the Compilation Tool Environment".* + +***[Example]*** + +1. Start a Linux server. - Example code for playing a PCM stream: +2. Run the following command to install the tool installation package: + ``` - AudioStreamInfo audioStreamInfo = new AudioStreamInfo.Builder().sampleRate(44100)// 44.1 kHz - .audioStreamFlag(AudioStreamInfo.AudioStreamFlag.AUDIO_STREAM_FLAG_MAY_DUCK)// Set audio ducking. - .encodingFormat(AudioStreamInfo.EncodingFormat.ENCODING_PCM_16BIT)//16-bit PCM - .channelMask(AudioStreamInfo.ChannelMask.CHANNEL_OUT_STEREO)// Set the dual output channel. - .streamUsage(AudioStreamInfo.StreamUsage.STREAM_USAGE_MEDIA)// Set the stream to be used for media. - .build(); + xxxxx ``` -2. Build the playback parameter structure via **AudioRendererInfo** for the audio stream created in Step 1, and use **AudioRendererInfo.Builder** to create an instance. The following example uses the default parameter values of the **AudioRendererInfo.Builder** instance. You need to set the playback parameters based on the audio playback specification. + +3. Run the following command to check whether the tool is successfully installed. + ``` - AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder() - .audioStreamInfo(audioStreamInfo) - .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_NONE) - .bufferSizeInBytes(0) - .distributedDeviceId("") - .isOffload(false) - .sessionID(AudioRendererInfo.SESSION_ID_UNSPECIFIED) - .build(); + xxxxx ``` - Example code for playing a PCM stream: - ``` - AudioRendererInfo audioRendererInfo = new AudioRendererInfo.Builder() - .audioStreamInfo(audioStreamInfo) - .audioStreamOutputFlag(AudioRendererInfo.AudioStreamOutputFlag.AUDIO_STREAM_OUTPUT_FLAG_DIRECT_PCM)// Set direct PCM output. - .bufferSizeInBytes(100) - .distributedDeviceId("E54***5E8")// Use distributed device E54***5E8 for playback. - .isOffload(false)// Value false indicates that the audio stream is transmitted to the buffer on a segment-by-segment basis for several times and then played. Value true indicates that the audio stream is transmitted to the HAL layer at a time. - .build(); - ``` - -3. Specify the playback mode based on the audio stream to be played. The playback modes differ only in the data writing process. Create an **AudioRenderer** instance using a constructor that fits your need. -4. After the playback task is complete, call the **release()** method on the **AudioRenderer** instance to release resources. +### Verifying the Environment + +***[Writing Requirements]*** + +*Optional. Provide the criteria for checking whether the environment is set up successfully. You can also provide the criteria along with the environment setup procedure, as provided in the preceding example.* + + +## *Example Task Scenario* Development (Use a specific scenario name. If there is only one scenario, use the solution/feature/function/module name.) + +*Mandatory.* + +***[Developers' Concerns]*** + +*How do I use or access the solution/feature/function/module?* + +***[Key Writing Points]*** + +*Provide scenarios that are close to actual development scenarios.* + +- *Task scenarios are what developers need to use to achieve development objectives.* + +- *There can be one or more task scenarios. You can use multiple "Development Guidelines" sections. Follow the hierarchical logic when writing the guidelines, that is, a task scenario -> a subtask scenario -> task logic ("Development Process") -> operation procedure ("How to Develop").* + +### *Example Task Scenario* Overview + +*Based on the scenario division of the solution/feature/function/module, you can provide either "Example Task Scenario Overview" or "Example Overview", or both of them.* + +*1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it.* + +*2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it.* + +### Development Process + +***[Key Writing Points]*** + +- *Optional. If there are many development steps (five or more core operations) or complex logical relationships between steps, provide the development process so that developers can have a panoramic view of the operations to be performed.* + +- *Provide flowcharts and tables if necessary.* -## (Optional) Commissioning and Verification +### Available APIs ***[Writing Requirements]*** -*Optional. After the development is complete, perform commissioning and verification to ensure that the operation is successful. The operation procedure requirements are the same as those in **Development Guidelines**. Other specific writing requirements are as follows. After finishing the writing, check your content against these requirements one by one.* +- *Optional. Describe the key APIs in the development steps and provide the API introduction, so that developers can have a general understanding of development.* -| Requirement| Satisfied or Not| -| -------- | -------- | -| Describe the final service commissioning process. The operation result of each step should be verified after the corresponding development task is complete.| | -| Specify the criteria for development success.| | +- *If there are more than 10 APIs, provide the main APIs only.* + +- *Ensure that the APIs and their functions of the corresponding version are supported when the document is released.* + +***[Example]*** + +Certain APIs can be called only by system applications that have been granted the **SystemCapability.Notification.Notification** permission. The APIs use either a callback or promise to return the result. The tables below list the APIs that use a callback, which provide the same functions as their counterparts that use a promise. For details about the APIs, see the [API document](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-notification.md). + +**Table 1** APIs for notification enabling + +| API | Description | +| ------------------------------------------------------------ | ---------------- | +| isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean>): void | Checks whether notification is enabled.| +| enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void | Sets whether to enable notification. | + + +### How to Develop + +***[Writing Requirements]*** + +*Mandatory.* + +- *Completeness and Correctness* + - *Describe the complete development process (for example, steps related to the code, resources, third-party libraries, and application configuration files in the HAP) so that developers can correctly complete the development. Do not omit key configuration operations.* + - *Ensure that the code snippet provided in the document can be built with the context in DevEco Studio.* + - *Ensure that the complete sample code provided in the document can be run in DevEco Studio, and the execution result is the same as that described in the document.* + +- *Clarity* + - *Provide a clear execution owner (who), operation purpose (why), operation content (what/how), and scenario (when/where) for each step. Use imperative sentence to describe steps.* + - *Clearly provide the APIs (if involved) in steps, as well as their usage description and sample code.* + - *Provide development suggestions or precautions for key steps and sample code (comments for sample code).* + *Think about what questions may be raised when developers are performing the operations.* *These problems are obstacles to developers.* *Provide support information in the document to help them handle these obstacles.* *Examples of support information:* + - *Branch selection principle. Provide principles or suggestions for selecting branches and parameters.* + + - *Necessary supplementary description. Describe possible special operations, required operation permissions, high efficiency skills, and concise and clear background knowledge.* + + - *Precautions. Describe operations that may adversely affect other functions or system performance and reliability, and operations that may cause data loss or security problems.* *Provide this type of information in a style different from that of the body prior to the operation procedure.* + + - *Error prevention/correction information. Provide guidance for preventing, locating, or rectifying typical problems that may occur in the development process.* *This type of information can be provided in "How to Develop" or "FAQs", depending on the content amount.* + +- *Standardization* + - *Provide both logically and syntactically correct sample code and write it in a standard manner. Anonymize sensitive information, such as mobile numbers, ID cards, and account names, for example, 186\*\*\*\*\*\*\*\*. Use private IP addresses or a corresponding format, for example, xx.xx.xx.xx and www.example.com, rather than real IP addresses and domain names.* + - *Provide code that complies with the code indentation requirements. Do not use the **Tab** key to indent code. Instead, use four spaces, to avoid incorrect display.* + +**[Example (Excerpt)]** + +1. Import the required modules. + + ```javascript + import formBindingData from '@ohos.application.formBindingData' + import formInfo from '@ohos.application.formInfo' + import formProvider from '@ohos.application.formProvider' + ``` + +2. Implement the lifecycle callbacks of **LifecycleForm**. + + ```javascript + export default { + onCreate(want) { + console.log('FormAbility onCreate'); + // Persistently store widget information for subsequent use, such as widget instance retrieval or update. + let obj = { + "title": "titleOnCreate", + "detail": "detailOnCreate" + }; + let formData = formBindingData.createFormBindingData(obj); + return formData; + }, + onCastToNormal(formId) { + // Called when the widget host converts the temporary widget into a normal one. The widget provider should do something to respond to the conversion. + console.log('FormAbility onCastToNormal'); + }, + } + ``` + + +### Verification -## Development Example ***[Writing Requirements]*** -*Provide a complete sample, briefly describe the principle and implementation of the sample, and provide a link to the source code repository.* +- *Optional. After the development is complete, provide a guide to check whether the operation is successful if there is an independent commissioning and verification operation. The operation procedure is the same as that described in "How to Develop."* + +- *Provide only the final service commissioning. You are advised to verify the operation result of each subtask after the development is complete.* + + +## FAQs + +*Optional.* + +***[Developers' Concerns]*** + +*What are the typical problems that may occur in the development process of the solution/feature/function/module? How do I locate and solve these problems?* + +***[Key Writing Points]*** + +*Describe the problems that may occur during the development and the solutions to them.* + +- *Delete this section if there are no common problems.* + +- *It is recommended that common problems in each task scenario be described in a separate chapter. Common problems related to a single task scenario be described in the corresponding chapter.* + + + +### 1. XX problem (simple problem) + +XXX + + +### 2. XX problem (complex problem) + +**Symptom** + +XXX + +**Possible Causes** -The following sample is provided to help you better understand how to xx: +XXX -- xxx (A link to the source code repository) +**Solution** - This sample xxx. +XXX diff --git a/en/contribute/template/js-template.md b/en/contribute/template/js-template.md index fddf204b85f3fc9a981476e2a00b3c3556ed4d43..a77adb292bbea3de8ba9ce39d91c781a083007fb 100644 --- a/en/contribute/template/js-template.md +++ b/en/contribute/template/js-template.md @@ -1,251 +1,277 @@ -# JS API Reference Template - -> *Writing Instructions* -> -> 0.1 - Delete all writing instructions after you finish the writing. -> -> 0.2 - Upload JS API reference documents to **docs/en/application-dev/reference/apis**. If these documents contain figures, upload the figures to the **figures** folder. -> -> 0.3 - Use a .d.ts file for a JS API reference document. **The file name must be in the following format: js-apis-<moduleName>.md**. Examples: -> For @ohos.multimedia.audio in the Media subsystem, the file name is **js-apis-audio.md**. -> For @ohos.telephony.sms in the Telephony subsystem, the file name is **js-apis-sms.md**. -> -> 0.4 - After uploading a JS API reference document, update the **Readme-EN.md** file in **docs/en/application-dev/reference/apis**. -> -> 0.5 - **Document Title**: Use phrases that summarize the module functionalities. -> -> 0.6 - Use the document title as the level-1 heading. Use the attributes, functions, classes, interfaces, enums, and types under the namespace as level-2 headings. Use the attributes and functions under classes as level-3 headings. -> -> **Version Description** -> -> 0.7 - **When introducing an API to an existing module, use the \<sup> tag to mark its earliest version.** -> Example: For an existing module of API 6, if an attribute is added in API 7, suffix the \<sup> tag to the name of the new attribute, for example, **newAttribute<sup>7+</sup>**. -> If a method is added, suffix the \<sup> tag to the method name, for example, **sim.getSimIccId<sup>7+</sup>**. The processing of new interfaces, classes, and enums is similar. -> -> 0.8 - **Deprecated content**: Do not delete the deprecated content directly from the document. Instead, suffix **deprecated** as a superscript to the content, and use the greater-than symbol (>) to introduce the substitute method plus the corresponding link. -> Example: abandonmentMethod<sup>(deprecated) </sup> -> -> > This APIs is no longer maintained since API version 7. You are advised to use [newMethod](#newMethod) instead. -> -> 0.9 - For **empty APIs that will be implemented only in the MR version**, add the following information to the interface description: -> This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR. -> -> **Required Permissions, System Capabilities, and System APIs** -> -> 0.10 - **Required permissions**: Maintain consistency with the code implementation. State the required permissions at the level of methods, enumerations, and attributes. Format: -> (Permissions that can be requested by all applications) **Required permissions**: ohos.permission.xxxx -> (Permissions that can be requested only by system applications) **Required permissions**: ohos.permission.xxxx (available only to system applications) -> -> 0.11 - **System capabilities**: -> Add the following information for each function: **System capability**: SystemCapability.xxx.xxx -> There are two cases for the information about system capabilities added to each table (attributes, enums, constants, and variables). -> Add the following description if all the items in a table require the same system capabilities: -> SystemCapability.xxx.xxx -> Add the following description if the items in a table require different system capabilities: -> The items in the table below require different system capabilities. For details, see the table. -> -> 0.12 - **System APIs**: Add the following description for system APIs: This is a system API and cannot be called by third-party applications. -> The following describes the instructions for writing a specific API. +# API Reference Template + +## General Writing Instructions + +| | Item | Writing Instruction | +| ---- | --------------------------------- | ------------------------------------------------------------ | +| 1 | Customer-oriented writing | **Stand in the shoes of developers and clearly describe the use cases, parameter selection principles, recommendations/tips, and sample code.**| +| 2 | | **Delete all writing instructions from your document after you finish the writing.** | +| 3 | Upload path | Upload markdown files to `docs/en/application-dev/reference/apis`.<br>Upload images to `docs/en/application-dev/reference/apis/figures`. In addition, reference the image path in the markdown file as follows: ``, ``, or ``.| +| 4 | File name | Provide one JS API reference document for each d.ts file. Name the file in the format of `js-apis-exampleModule.md`, where `exampleModule` is a variable and must be the same as the actual module name.<br>Examples:<br>For @ohos.multimedia.audio in the Multimedia subsystem, the JS API file name is `js-apis-audio.md`.<br>For @ohos.telephony.sms in the Telephony subsystem, the JS API file name is `js-apis-sms.md`.| +| 5 | Directory update | After uploading an API reference document, update the `Readme-EN.md` file in `docs/en/application-dev/reference/apis`.| +| 6 | Document structure | - Module description<br>- Initial version description<br>- Modules to Import/Usage description<br>- API description (attributes, methods, enums, and custom types)<br> The order in which APIs are described in the document must be consistent with that in which they appear in the code. If some APIs have a logical sequence, pay attention to their sequence in the API reference document.| +| 7 | API version description | 1. Use the greater-than sign (`>`) followed by a space to indent the description about the initial version of the module. Unless otherwise marked, all APIs in the module have the same initial version.<br>2. When introducing an API to an existing module, use the `<sup>` tag to mark its earliest version. The format is `<sup>versionNumber+</sup>`, for example, `<sup>7+</sup>`.<br> If an attribute of API version 7 is added to an existing module, suffix the `<sup>7+</sup>` tag to the name of the new attribute, for example, `newAttribute<sup>7+</sup>`.<br> If a method is added to an existing module, suffix the `<sup>` tag to the method name, for example, `sim.getSimIccId<sup>7+</sup>`. The same rule applies to new interfaces, classes, and enums. | +| 8 | Deprecated API description | Do not delete the deprecated content from the document. Instead, suffix `deprecated` as a superscript to the content, and use the greater-than sign (`>`) to introduce the substitute API plus a link to the API description.<br>Example: abandonmentMethod<sup>(deprecated)</sup><br>> This API is no longer maintained since API version 7. You are advised to use [newMethod]\(#newmethod) instead.| +| 9 | Permission description | Provide the same permission description as that defined in the code for each method, enum, and attribute.<br>1. If a specific permission required for using an API can be requested only by system applications, provide the description in the following format:<br> **Required permissions**: ohos.permission.examplePermission (available only to system applications)<br>2. If a specific permission required for using an API can be requested by all applications, provide the description in the following format:<br> **Required permissions**: ohos.permission.examplePermission<br>3. If multiple permissions are required for using an API, provide the permissions with `and` or `or` in the following format:<br> **Required permissions**: ohos.permission.examplePermissionA and ohos.permission.examplePermissionB<br> **Required permissions**: ohos.permission.examplePermissionA or ohos.permission.examplePermissionB| +| 10 | @syscap | 1. Provide a description for every API in the following format, wherein *A.B* indicates a specific system capability.<br> **System capability**: SystemCapability.*A.B*<br>2. There are two cases for adding system capability information to a table (of attributes, enums, constants, or variables).<br> 1) If all the items in a table require the same system capability, add the following information to the front of the table:<br> **System capability**: SystemCapability.*A.B*<br> 2) If the items in a table require different system capabilities,<br> list the system capability for each item in the table. | +| 11 | @system api | 1. If all APIs of a module are system APIs, add the following sentence to the next line of the initial version description:<br> The APIs provided by this module are system APIs.<br>2. If an API is a system API that can be used only by original equipment manufacturers (OEMs), add the following sentence to the API description:<br> This is a system API. | +| 12 | @FAModelOnly<br>@StageModelOnly | 1. If a module is implemented only for a specific ability model, add the following sentence to the next line of the initial version description:<br> - The APIs of this module can be used only in the FA model.<br>Or<br> - The APIs of this module can be used only in the stage model.<br>2. If an API is implemented only for a specific ability model, add the following sentence to the API description:<br> - This API can be used only in the FA model.<br>Or<br> - This API can be used only in the stage model.| +| 13 | Asynchronous methods (callback and promise)| Use the following sentences for callback methods.<br>Method introduction: *Describe the method.* This API uses an asynchronous callback to return the result.<br>Parameter description:<br>**callback\<boolean>**: Callback used to return the result. The value `true` indicates *something*, and `false` indicates the opposite.<br>**callback\<Object>**: Callback used to return *something*. Example: Callback used to return the `AudioCapturer` object. <br>**AsyncCallback\<void>**: Callback used to return the result. If the operation (or a specific operation description) is successful, `err` is `undefined`; otherwise, `err` is an `Error` object.<br>**AsyncCallback\<Object x>**: Callback used to return the result. If the operation (or a specific operation description) is successful, `err` is `undefined`, and `data` is the *x* object obtained; otherwise, `err` is an `Error` object.<br>Use the following sentences for promise methods.<br>Method introduction: *Describe the method.* This API uses a promise to return the result.<br>Parameter description:<br>**Promise\<boolean>**: Promise used to return the result. The value `true` indicates *something*, and `false` indicates the opposite.<br>**Promise\<Object>**: Promise used to return *something*. Example: Promise used to return the `AudioCapturer` object. <br>**Promise\<void>**: Promise that returns no value. | +| 14 | Sample code programming language | Use code blocks to provide sample code and mark the programming language.<br>Use `js` as the mark if both JS and eTS can be used, and use `ts` if only eTS can be used.| +| 15 | Link | Link format: [Link text]\(Link content)<br>Cross-folder link format: [markdown file name]\(\.\./../xxx/xxx.md). One `./` indicates one upper-level folder.<br>Intra-topic link: [Interface A<sup>7+</sup>]\(#xxxa7). The text in the intra-topic link must be the same as the title to be linked. In the link, all letters must be in lowercase, and no special character or label is included.| + +The following describes the instructions for writing a specific API reference document. *** + +# Document Title + > *Writing Instructions* > -> 1.1 - Use the greater-than symbol (>) to describe the initial version of an API. -> -> 1.2 - A module has only one initial version. -> -> 1.3 - Use the following sentence: "The initial APIs of this module are supported since API version ***x***. Newly added APIs will be marked with a superscript to indicate their earliest API version." Change ***x*** to the actual version. +> 1. **Document title**: Use phrases that summarize the module functionalities. Examples: `Ability` and `SIM Card Management` +> 2. **Heading levels**: Use the document title as the level-1 heading, which is prefixed with `#` followed by a space. Use the attributes, functions, classes, interfaces, enums, and types under the namespace as level-2 headings, which are prefixed with `##` followed by a space. Use the attributes and functions under classes as level-3 headings, which are prefixed with `###` followed by a space. +> 3. **Initial version description**: Use the greater-than symbol (`>`) to indent the description about the initial version of the module. Use a line break after **NOTE**. <br>Place the version description after the module description. A module has only one initial version. <br>Use the following sentence: "The initial APIs of this module are supported since API version *x*. Newly added APIs will be marked with a superscript to indicate their earliest API version." Change ***x*** to the actual version number. +Describe the module from its functionalities, use cases, and recommendations in this section. +**Example 1**: description of the background task management module -> **Note** -> -> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +This module provides background task management. +If a service needs to be continued when the application or service module is running in the background (not visible to users), the application or service module can request a transient task or continuous task for delayed suspension based on the service type. + +**Example 2**: description of the call module -Describe the module from its functionalities, use cases, and use suggestions in this section. +The call module provides call management functions, including making calls, redirecting to the dial screen, obtaining the call status, and formatting phone numbers. +To subscribe to the call state, use observer.on('callStateChange'). +**Example 3**: description of the distributed data management module +The distributed data management module provides collaboration between databases of different devices for applications. +The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, querying, and synchronizing data in the distributed database. + +**Example 4**: description of the linear container ArrayList module + +`ArrayList` is a linear data structure that is implemented based on arrays. `ArrayList` can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time. +Similar to `ArrayList`, `Vector` is also implemented based on arrays and can dynamically adjust the capacity. It increases the capability by 100% each time. +When compared with `LinkedList`, `ArrayList` is more efficient in random access but less efficient in the addition or removal operation, because its addition or removal operation affects the position of other elements in the container. +You are advised to use `ArrayList` when elements in a container need to be frequently read. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import > *Writing Instructions* > -> 2.1 - Write the modules to import based on the actual conditions. Provide the **import** statement in the form of a code segment. +> 1. Write the modules to import based on the actual conditions. Provide the **import** statement in the form of a code block. > -> 2.2 - If no module needs to be imported, change "Modules to Import" to "How to Use" and provide a usage description. -> Example of **How to Use**: -> Before using the **AbilityContext**, obtain the **Context** object through **[getContext()]**(***API-reference***.md). +> 2. If no module needs to be imported, change "Modules to Import" to "Usage" and provide a usage description. <br>Example of **Usage**:<br> +> Before using the `AbilityContext`, obtain the `Context` object through [getContext()]\(*API-reference*.md). > > ```js -> import ability_featureAbility from '@ohos.ability.featureAbility'; -> var context = ability_featureAbility.getContext(); +> import ability_featureAbility from '@ohos.ability.featureAbility'; +> var context = ability_featureAbility.getContext(); > ``` ```js import call from '@ohos.telephony.call'; ``` - ## Attributes > *Writing Instructions* > -> 4.1 - Optional. Delete this heading if there is no attribute. +> 1. Optional. Delete this heading if there is no attribute. > -> 4.2 - If an attribute is of a custom type, create a link to the corresponding interface or enum. +> 2. If an attribute is of a custom type, create a link to the corresponding interface or enum. > -> 4.3 - For a readable attribute, if it has a limited number of values with special meanings, enumerate the values. +> 3. For a readable attribute, if it has a limited number of values with special meanings, enumerate the values. > -> 4.4 - For a writable attribute, if only fixed fields are supported, describe them. -> -> 4.5 - If the items in the table require different system capabilities, add the following description: The items in the table below require different system capabilities. For details, see the table. Then, describe the system capabilities for each item. See [Enums](#enums). +> 4. For a writable attribute, if only fixed fields are supported, describe them. -**System capability**: SystemCapability.xxx.xxx (Mandatory) +**System capability**: SystemCapability.*A.B* (Mandatory) | Name | Type | Readable| Writable| Description | | ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------ | -| pluggedType | [BatteryPluggedType](#BatteryPluggedType) | Yes | No | Charger type of the current device. | +| pluggedType | [BatteryPluggedType](#batterypluggedtype) | Yes | No | Charger type of the current device. | | isBatteryPresent | boolean | Yes | No | Whether the battery is supported or present.| -## Enums - -> *Writing Instructions* -> -> 5.1 - Optional. Delete this heading if there is no enum. If there are multiple enums, describe them in separate level-2 headings. To create a level-2 heading, use two number signs (#). -> -> 5.2 - Use the actual enum name as the level-2 heading, for example, **BatteryHealthState**. - -Provide a brief description of the enum type. Example: Enumerates charger types. - -**System capability**: The items in the table below require different system capabilities. For details, see the table. (Mandatory) - -| Name| Value | Description | -| ---- | ---- | ------------------------------------------------------------ | -| NONE | 1 | Unknown type.<br>**System capability**: SystemCapability.xxx.xxx (mandatory)| - ## Methods > *Writing Instructions* > -> 6.1 - Optional. Delete this heading if there is no method. If there are multiple methods, describe them in separate level-2 headings. To create a level-2 heading, use two number signs (#). +> 1. Optional. Delete this heading if there is no method. If there are multiple methods, describe them in separate level-2 headings, prefixed with `##` followed by a space. +> +> 2. Use the actual method name, in the format of ClassName.methodName, as the level-2 heading. For a subscription method, add the subscription event to the method name. > -> 6.2 - Use the actual method name, in the format of ClassName.methodName, as the level-2 heading. For a subscription method, add the subscription event to the method name. -> Example of a common method: sim.getSimIccId -> Example of a subscription method: sim.on('exampleEvent') +> Example of a common method: sim.getSimIccId +> +> Example of a subscription method: sim.on('exampleEvent') > -> 6.3 - **Method calling mode**: The description must be the same as that in the .d.ts file. The description must include the parameter type, parameter name, and return value type. -> Example: getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void -> Note: The angle bracket (<>) may be identified as a label and not displayed. To ensure normal display, you can either add a backslash (\\) (in the format of "\\<>") or use escape characters \< and \>. +> 3. **Method calling mode**: The description must be the same as that in the .d.ts file and include the parameter type, parameter name, and return value type. +> Example: getNetworkState(slotId: number, callback: AsyncCallback\<NetworkState>): void +> Note: The angle bracket (<>) may be identified as a label and not displayed. To ensure normal display, you can either add a backslash (\\) (in the format of "\\<>") or use escape characters \< and \>. > -> 6.4.1 - **Method description**: Describe the features implemented by the method and include the prerequisites for using the method, the impact of the method, and the permissions and system capabilities required to use the method. (*Example of prerequisites: This method can be called only after the xx method is called; you must ensure that the connection to the Internet is normal. Example of impact: xx does not take effect after this method is called.*) +> 4. **Method description**: Describe the features implemented by the method and include the prerequisites for using the method, the impact of the method, and the permissions and system capabilities required to use the method. (*Example of prerequisites: This method can be called only after the xx method is called; you must ensure that the connection to the Internet is normal. Example of impact: xx does not take effect after this method is called.*) > -> 6.4.2 - **Asynchronous method**: If there are asynchronous methods, describe their return type in the method description. The return type can be a callback function or a **Promise** instance. +> 5. **Asynchronous methods**: If there are asynchronous methods, describe their return type in the method description. For details, see item 14 in "General Writing Instructions." > -> 6.4.3 - **Line feed in a table**: Use \<br> for line feed. +> 6. **Line feed in a table**: Use \<br> for line feed. -Provide the method name in the following format: (**static** if it is a static method) methodName (parameterName1: parameterType1, parameterName2: parameterType2, ...): returnValueType +Provide the method name in the following format: (`static` if it is a static method) methodName (parameterName1: parameterType1, parameterName2: parameterType2, ...): returnValueType -Describe the method. For details, see 6.4.1 and 6.4.2. +Describe the method. For details, see the fourth and fifth points in "Writing Instructions" above. -**Required permissions**: ohos.permission.xxx (Delete this part if no permission is involved. If a system permission is required, specify it.) +This API can be used only in the stage model. (optional) -**System capability**: SystemCapability.xxx.xxx (mandatory) +This is a system API. (optional) -**Parameters** (Optional. Delete this heading if there is no parameter.) +**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved. If a system permission is required, specify it.) + +**System capability**: SystemCapability.*A.B* (mandatory) + +**Parameters** (Optional. Delete this part if there is no parameter.) | Name | Type | Mandatory| Description | | ------------ | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| parameterOne | number \| string \| [CustomType](#CustomType) | Yes | Describe the parameter. Provide the value range and recommended value. If there is a fixed format, provide a format example, especially for the URI.<br>Provide a link for each custom parameter type.| -| callback | Callback\<Array<[CustomType](#CustomType)>> | No | Describe the parameter. For an optional parameter, describe the consequences if it is not specified.<br>Example: If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| parameterOne | number \| string \| [CustomType](#customtype) | Yes | Describe the parameter. Provide the value range and recommended value. If there is a fixed format, provide a format example, especially for the URI.<br>Provide a link for each custom parameter type.| +| callback | Callback\<Array<[CustomType](#customtype)>> | No | Describe the parameter. For an optional parameter, describe the consequences if it is not specified.<br>Example: If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.<br>For details about how to write callback methods, see item 14 in "General Writing Instructions."| -**Return value** (Optional. Delete this heading if there is no return value.) +**Return value** (Optional. Delete this part if there is no return value.) -| Type | Description | -| ------------------------------------------ | -------------------------------------------- | -| string | Describe the return value, for example, what can be done after the return value is obtained.| -| Promise\<Array<[CustomType](#CustomType)>> | Describe the return value, for example, what is obtained through the **Promise** instance. | +| Type | Description | +| ------------------------------------------ | ----------------------------------------------- | +| string | Describe the return value, for example, what can be done after the return value is obtained. | +| Promise\<Array<[CustomType](#CustomType)>> | Describe the return value. For details about how to write promise methods, see item 14 in "General Writing Instructions."| **Example** ```js // This part is mandatory. + // Check all sample code provided in the example. // Minor errors such as missing symbols and variable inconsistency are unacceptable. // Declare all variables that are used. -// Write an actual case that can be easily used, rather than the parameter names themselves. -// Use comments to describe the content that are not user-defined. + +// Write an actual case that can be easily used, rather than the parameter names themselves. Use comments to describe the content that are not user-defined. // Example: var result = xxx.createExample(parameterOne); // parameterOne is automatically obtained by scanning. + +// Provide clear and concise comments in the following typical scenarios: +// 1. The meaning of a variable name or the code logic is not self-explanatory. +// 2. A complex algorithm or special syntax is involved. ``` -## Classes/Interfaces +## On and Off Subscription Methods > *Writing Instructions* > -> 7.1 - Optional. Delete this heading if there is no class or interface. If there are multiple classes or interfaces, describe them in multiple level-2 headings. To create a level-2 heading, use two number signs (#). +> 1. The basic requirements are the same as those provided in [Methods](#methods). The following describes only the differences. > -> 7.2 - Use the actual class or interface name as the level-2 heading. -> -> 7.3 - If the class or interface contains both attributes and methods, write the attributes above the methods. Write their actual names in separate level-3 headings. -> If the class of interface contains only attributes, you do not need to create a level-3 heading. Instead, use a table to display the attributes. For details, see [CustomType](#CustomType). - -Describe the class or interface. If there are usage restrictions, describe them as well, for example, whether there is a prerequisite and whether an instance needs to be created by using any method. - -### Attributes - -> *Writing Instructions* +> 2. Use the actual method name, in the format of ClassName.methodName plus the subscription event, as the level-2 heading. +> Examples: `sim.on(?exampleEvent?)` and `on('play' | 'pause' | 'stop' | 'reset')` > -> Except that a level-3 heading is used, other instructions are the same as those listed under [Attributes](#Attributes). +> 3. **Method calling mode**: The description must be the same as that in the .d.ts file and include the parameter type, event name, parameter name, and return value type. +> Example: `on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void` +> Note: The angle bracket (<>) may be identified as a label and not displayed. To ensure normal display, you can either add a backslash (\\) (in the format of "\\<>") or use escape characters \< and \>. -### Methods in Classes/Interfaces +Provide the method name in the following format: (`static` if it is a static method) methodName (parameterName1: parameterType1, parameterName2: parameterType2, ...): returnValueType -> *Writing Instructions* -> -> 7.4 - Use the actual method name as the level-3 heading. **Do not add a prefix**. For a subscription method, add the corresponding subscription event to the method name. -> Example of a common method: getSimIccId -> Example of a subscription method: on('exampleEvent') -> The other instructions are the same as those stipulated in [Methods](#Methods). +Describe the method. For details, see the fourth and fifth points in "Writing Instructions" under [Methods](#methods). -Describe the method calling mode. For details, see 6.3. +This API can be used only in the stage model. (optional) -Describe the method. For details, see 6.4.1 and 6.4.2. +This is a system API. (optional) -**Required permissions**: ohos.permission.xxx (Delete this part if no permission is involved. If a system permission is required, specify it.) +**Required permissions**: ohos.permission.examplePermission (Delete this part if no permission is involved. If a system permission is required, specify it.) -**System capability**: SystemCapability.xxx.xxx (mandatory) +**System capability**: SystemCapability.*A.B* (mandatory) **Parameters** (Optional. Delete this heading if there is no parameter.) -| Name | Type | Mandatory| Description | -| ------------ | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| parameterOne | number \| string \| [CustomType](#CustomType) | Yes | Describe the parameter. Provide the value range and recommended value. If there is a fixed format, provide a format example, especially for the URI.<br>Provide a link for each custom parameter type.| -| callback | Callback\<Array<[CustomType](#CustomType)>> | No | Describe the parameter. For an optional parameter, describe the consequences if it is not specified.<br>Example: If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes | Describe the event and when or how it will be triggered. If a method involves multiple events, describe them separately.<br>**Example 1 (single event):**<br>Type of the event. The `'play'` event is triggered when the `play()` API is called and audio playback starts.<br>**Example 2 (multiple events)**:<br>Type of the event. The following events are supported:<br/>- 'play': triggered when the play() API is called and audio playback starts.<br/>- 'dataLoad': triggered when the audio data is loaded, that is, when the `src` attribute is configured.<br/>- 'finish': triggered when the audio playback is finished. | +| callback | Callback\<[CustomType](#CustomType)> | No | Describe the parameter. The instructions are the same as those provided under [Methods](#methods). | **Return value** (Optional. Delete this heading if there is no return value.) -| Type | Description | -| ------------------------------------------ | -------------------------------------------- | -| string | Describe the return value, for example, what can be done after the return value is obtained.| -| Promise\<Array<[CustomType](#CustomType)>> | Describe the return value, for example, what is obtained through the **Promise** instance. | +| Type | Description | +| ------ | ------------------------------------- | +| string | Describe the return value. The instructions are the same as those provided under [Methods](#methods).| **Example** ```js -// This part is mandatory. +// Mandatory. The instructions are the same as those provided under [Methods](#methods). + // Check all sample code provided in the example. // Minor errors such as missing symbols and variable inconsistency are unacceptable. // Declare all variables that are used. -// Write an actual case that can be easily used, rather than the parameter names themselves. -// Use comments to describe the content that are not user-defined. + +// Write an actual case that can be easily used, rather than the parameter names themselves. Use comments to describe the content that are not user-defined. // Example: var result = xxx.createExample(parameterOne); // parameterOne is automatically obtained by scanning. + +// Provide clear and concise comments in the following typical scenarios: +// 1. The meaning of a variable name or the code logic is not clearly stated in the code. +// 2. A complex algorithm or special syntax is involved. ``` +## Classes/Interfaces + +> *Writing Instructions* +> +> 1. Optional. Delete this heading if there is no class or interface. If there are multiple classes or interfaces, describe them in multiple level-2 headings, prefixed with `##` followed by a space. +> +> 2. Use the actual class or interface name as the level-2 heading. +> +> 3. If the class or interface contains both attributes and methods, write the attributes above the methods. Write their actual names in separate level-3 headings. +> If the class or interface contains only attributes, you do not need to create a level-3 heading. Instead, use a table to display the attributes. For details, see [CustomType](#customtype). + +Describe the class or interface. If there are usage restrictions, describe them as well, for example, whether there is a prerequisite and whether an instance needs to be created by using any method. + +### Attributes in Classes/Interfaces + +> *Writing Instructions* +> +> Except that a level-3 heading is used for attributes in classes/interfaces, other instructions are the same as those provided under [Attributes](#attributes). + +### Methods in Classes/Interfaces + +> *Writing Instructions* +> +> 1. Use the actual method name as the **level-3 heading**. **Do not add a prefix.** For a subscription method, add the corresponding subscription event to the method name. +> Example of a common method: getSimIccId +> Example of a subscription method: on('exampleEvent') +> 2. Other instructions are the same as those provided under [Methods](#methods). + +## Enums + +> *Writing Instructions* +> +> 1. Optional. Delete this heading if there is no enum. If there are multiple enums, describe them in separate level-2 headings, prefixed with `##` followed by a space. +> +> 2. Use the actual enum name as the level-2 heading, for example, `BatteryHealthState`. + +Provide a brief description of the enum type. Example: Enumerates the charger types. + +**System capability**: SystemCapability.xxx.xxx (mandatory) + +| Name| Value | Description | +| ---- | ---- | -------------------------- | +| NONE | 1 | Unknown type.| + ## CustomType The following is an example of the custom type of a key-value pair. -**System capability**: SystemCapability.xxx.xxx (Mandatory) +**System capability**: SystemCapability.*A.B* (mandatory) | Name | Type | Readable| Writable| Description | | ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | -| parameterUrl | string | Yes | Yes | Media output URI. The following types of URIs are supported:<br>1. Relative path whose protocol type is internal. Examples:<br>Temporary directory: internal://cache/test.mp4<br><br>2. Absolute path. Examples:<br>file:///data/data/ohos.xxx.xxx/files/test.mp4<br> | -| parameterOne | [CustomEnum](#enums) | Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. | +| parameterUrl | string | Yes | Yes | Media output URI. Supported: 1. Relative path whose protocol type is `internal`. Example: <br/>Temporary directory: internal://cache/test.mp4<br/> 2. Absolute path. Example:<br/> file:///data/data/ohos.xxx.xxx/files/test.mp4| +| parameterOne | [CustomEnum](#Enumeration)| Yes | Yes | Describe the attributes. The requirements are similar to those for the parameter description. | +## Change History +| Change Description| Date| +| -------- | ---- | +| 1. Provided the general writing instructions in a table.<br>2. Added the description about how to reference an image in "Upload path".<br>3. Added the "Document structure" item to describe the sequence of nodes in the API reference document.<br>4. Added the description for multiple permissions in "Permission description".<br>5. Added the description of @FAModelOnly and @StageModelOnly in the API reference document.<br>6. Added the description of asynchronous methods (callback and promise).<br>7. Added the standards and specifications for the sample code programming language.<br>8. Added the standard format for links used in the API reference document.<br>9. Added examples for "Module description".<br>10. Added the description of on and off subscription methods.<br>11. Updated the description of @syscap.<br>12. Updated the description of @systemapi. Now only the sentence "This is a system API." is used. <br>13. Deleted the MR version description.|2022-06-24| diff --git a/en/design/OpenHarmony-API-governance.md b/en/design/OpenHarmony-API-governance.md index a5784cb05d2b876d1713b4785573804cf4e3e895..ede0bcff97b48f692d5c08da76c81f491d9f71ac 100644 --- a/en/design/OpenHarmony-API-governance.md +++ b/en/design/OpenHarmony-API-governance.md @@ -2,7 +2,7 @@ ## Introduction -To help the OpenHarmony ecosystem develop and evolve in a healthy and orderly way, this Charter defines the governance process and lifecycle (create, change, deprecate, and delete) of OpenHarmony APIs. It also specifies basic design requirements of OpenHarmony APIs. +To help the OpenHarmony ecosystem develop and evolve in a healthy and orderly way, this Charter defines the governance process and lifecycle (creation, change, deprecation, and deletion) of OpenHarmony APIs. It also specifies basic design requirements of OpenHarmony APIs. This Charter is formulated by the API SIG and approved by the PMC for release. Any revision to this Charter will be released only after being reviewed by the API SIG and approved by the PMC. @@ -16,14 +16,14 @@ The OpenHarmony software stack contains multiple roles. Naturally, OpenHarmony A Different types of APIs have different compatibility requirements, as described in the table below. -| Type| Prepared By| Used By| Compatibility Requirement| Guarding Method| -|---|---|---|---|---| -| Public API | System and framework| All application developers| 5 API versions| X test suite (XTS)| -| Test API | Test framework| All application developers| 3 API versions| To be built| -| System API | System and framework|System application developers|Not guaranteed| To be built| -| HDI | HDF| System services| 4 API versions| XTS | -| Driver API | HDF | Driver developers| Not guaranteed| None| -| Inner API | System parts| System parts| Not guaranteed| None| + | Type | Prepared By | Used By | Compatibility Requirement | Guarding Method | + |--- |--- |--- |--- |--- | + | Public API | System and framework | All application developers | Five API versions | X test suite (XTS) | + | Test API | Test framework | All application developers | Three API versions | To be built | + | System API | System and framework |System application developers |Not guaranteed | To be built | + | HDI | HDF | System services | Four API versions | XTS | + | Driver API | HDF | Driver developers | Not guaranteed | None | + | Inner API | System parts | System parts | Not guaranteed | None | The APIs are described as follows: @@ -48,13 +48,13 @@ The content described in this Charter is irrelevant to the programming language ### Roles and Responsibilities -|**Role**|**Responsibilities in API Governance**| -| - | - | -|Contributor|Commit API code and design documents.| -|Committer|Review the code and submit a pre-review comment on an API commit.| -|Domain SIG|Comment on the commits of new API code, so the passed commits can be merged. <br/>Submit a pre-review comment on updated API code.| -|API SIG|Comment on updated API code.| -|PMC|Release API version plans. Review amendments of this Charter, revise the terms, and publish this Charter.| + | Role | Responsibilities in API Governance | + | --- | --- | + | Contributor | Commit API code and design documents. | + | Committer | Review the code and submit a pre-review comment on an API commit. | + | Domain SIG | Comment on the commits of new API code, so the passed commits can be merged. <br/>Submit a pre-review comment on updated API code. | + | API SIG | Comment on updated API code. | + | PMC | Release API version plans. Review amendments of this Charter, revise the terms, and publish this Charter. | ### API Review Process The API review process is as follows: @@ -66,7 +66,7 @@ The main process is as follows: 1. Initiate API review and commit code (contributor). If any APIs are added or modified, the contributor must additionally submit an API review application to specify the API requirement source, usage scenario, permission design, and privacy protection design. For details, see "API Review Application Composites" below. To avoid rework, the contributor can send an email to submit the API design document to the committer, domain SIG, and API SIG for pre-review before the formal API review application and code commit. 1. Review code (committer). After the code review is approved, the committer should submit the APIs to the domain SIG. If the API code involves multiple domains, they should be submitted to the committers of the corresponding domains. The next review step can be performed only after all committers review and approve the code. 1. Review APIs (domain SIG). The code of new APIs can be merged only after being reviewed and approved by the domain SIG. If there are changes to existing APIs, the domain SIG should submit them to the API SIG. If the new APIs involve multiple domains, they should be submitted to the SIGs of the corresponding domains. The code can be merged after being reviewed and approved by one of the domain SIGs. If the changed APIs involve multiple domains, they should be submitted to the SIGs of the corresponding domains. The next review step can be performed only after all domain SIGs approve the APIs. -1. Review API changes (owner: API SIG): The code of changed APIs can be merged only after being reviewed and approved by the API SIG. +1. Review API changes (API SIG). The code of changed APIs can be merged only after being reviewed and approved by the API SIG. 1. The review is complete. ### API Review Application Composites @@ -175,18 +175,18 @@ Design APIs from the perspective of their users rather than providers. ### Performance 1. Respond in a timely manner to avoid callers waiting. If an API call takes a long time, use an asynchronous API. -2. Pay attention to the impact of the API call timing and frequency on the RAM usage. -3. Pay attention to the impact of the API call timing and frequency on power consumption. +2. Make sure that the impact of API call timing and frequency on the RAM usage is under control. +3. Make sure that the impact of API call timing and frequency on the power consumption is under control. 4. Resources must be released in a timely manner when APIs that use resources are called. A fault tolerance mechanism must be provided for abnormal scenarios to ensure timely resource release. ### Power Consumption -1. Evaluate the impact of the API call timing and frequency on power consumption, and perform related design if there is any impact. -2. The power consumption should not deteriorate during version evolution. +1. Evaluate the impact of the API call timing and frequency on power consumption, and optimize the design if there is any impact. +2. Make sure that the power consumption does not deteriorate during version evolution. ### Reliability -1. APIs cannot crash due to external input (such as input parameters, system status, and external data), internal status, or data exceptions. It must return a specific error code or throw a predefined exception. +1. APIs shall not crash due to external input (such as input parameters, system status, and external data), internal status, or data exceptions. It must return a specific error code or throw a predefined exception. 2. It must be specified whether an API is called synchronously or asynchronously. If an API is called synchronously, specify the timeout duration or allow the caller to set the timeout duration to prevent service response failure caused by call suspension. 3. APIs must support multi-thread reentrant. 4. APIs must meet the idempotence requirement, which means that the same effect should be obtained for one or multiple API call requests with the same service meaning (except that API call depends on external resource changes). For reentrant API call, avoid introducing time-varying factors, such as system ticks, static variables, and global variables without mutual exclusion protection. For repeated call of the same client, **contextID**, **clientToken**, and **sequenceNo** can be used as input parameters. diff --git a/en/design/OpenHarmony-part-design.md b/en/design/OpenHarmony-part-design.md index 75487ee8848e878bc66e531b177880153245f5da..e5d73b5ea6d61e7863ad53b1cc582814e5cb3811 100644 --- a/en/design/OpenHarmony-part-design.md +++ b/en/design/OpenHarmony-part-design.md @@ -4,7 +4,7 @@ For easy software design and management, OpenHarmony decouples software from physical components, parts, and modules. A **component** can be independently deployed and reused at the binary level. A **part** can be independently developed, built, and tested. A **module** can be reused at the code level. -OpenHarmony abstracts system capabilities as parts, so you can customize OSs for different devices by assembling and configuring these parts. +OpenHarmony abstracts system capabilities as parts, so you can assemble and configure these parts to customize an OS for different devices. ## Part Definition @@ -12,7 +12,7 @@ A part is the basic unit of system capabilities. Divided based on source code, e ## Part Division -Follow the following rules for part classification: +Observe the following rules for part classification: - A part must have an independent code directory for compiling libraries or executable files. @@ -50,7 +50,7 @@ Comply with the following rules and recommendations during parts design and deve #### **Part Name** -The name must reflect the key function of a part and must be globally unique in the system. The name can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used. +The name must reflect the key function of a part and must be globally unique in the system. It can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used. #### **Repository Name** @@ -96,21 +96,23 @@ The addition, deletion, and modification of parts must be reviewed by the archit Table 1 Part attribute review form -| Part Attribute| Description| +| Part Attribute | Description | | ------------ | ------------------------------------------------------------ | -| Part name| The name must reflect the key function of a part and must be globally unique in the system. The name can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used.| -| Subsystem| Subsystem to which the part belongs.| -| Function description| Brief description of the functions of the part in one or two sentences.| -| Configurable features| Features that can be configured externally.| -| Applicable systems| Mini system, small system, standard system, or their combinations.| -| Source code directory| Root directory of the source code of the part.| -| ROM | ROM baseline value of the part.| -| RAM | RAM baseline value of the part.| -| Dependencies| Parts and open source software on which the part depends.| +| Part name | The name must reflect the key function of a part and must be globally unique in the system. The name can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used. | +| Subsystem | Subsystem to which the part belongs. | +| Function description | Brief description of the functions of the part in one or two sentences. | +| Configurable features | Features that can be configured externally. | +| Applicable systems | Mini system, small system, standard system, or their combinations. | +| Source code directory | Root directory of the source code of the part. | +| ROM | ROM baseline value of the part. | +| RAM | RAM baseline value of the part. | +| Dependencies | Parts and open source software on which the part depends. | 2. Send an email to the architecture SIG (dev@openharmony.io) and the [related domain SIG leaders](https://gitee.com/openharmony/community/blob/master/sig/sigs_subsystem_list.md) for review. Use "Application for Adding/Deleting/Modifying OpenHarmony Parts" as the email subject, and include the filled-in **Table 1 Part Attribute Review Form** in the email body. -> Note: For modified parts, provide a before and after comparison of the part attributes. For deleted parts, provide the plan for stopping part maintenance. Exercise caution when deleting or modifying parts and evaluate the impact on existing versions. +> Note: +> +> For modified parts, provide a before and after comparison of the part attributes. For deleted parts, provide the plan for stopping part maintenance. Exercise caution when deleting or modifying parts and evaluate the impact on existing versions. 3. After the review is passed, create a part repository and modify the manifest according to [SIG Management Regulations](https://gitee.com/openharmony/community/blob/master/sig/README-EN.md). After the SIG is incubated, incorporate it into the main code library of OpenHarmony. diff --git a/en/design/figures/HDI-Review-Process.png b/en/design/figures/HDI-Review-Process.png new file mode 100644 index 0000000000000000000000000000000000000000..7ba581237d86b0de4b6f6ec68bc066b3714adbbd Binary files /dev/null and b/en/design/figures/HDI-Review-Process.png differ diff --git a/en/design/hdi-design-specifications.md b/en/design/hdi-design-specifications.md new file mode 100644 index 0000000000000000000000000000000000000000..dcaf228795c5ffb81a5ddfc90a24aaaf9c7a8237 --- /dev/null +++ b/en/design/hdi-design-specifications.md @@ -0,0 +1,483 @@ +# OpenHarmony HDI Design Specifications + +## Overview + +Hardware device interface (HDI) provides a set of interfaces that function as a bridge between drivers and system services for data transmission. They have a direct impact on system efficiency, stability, compatibility, and reliability, as well as data accuracy and integrity. This document aims to standardize the design and development of OpenHarmony HDI interfaces, thereby ensuring consistent styles and complete functionalities for the interfaces. +This document is developed by the [driver SIG](https://gitee.com/openharmony/community/blob/master/sig/sig-driver/sig_driver.md) and approved by the [PMC](https://gitee.com/link?target=https%3A%2F%2Fwww.openharmony.cn%2Fcommunity%2Fpmc%2F). Any revision to this document must be reviewed by the driver SIG and approved by the PMC. + +**Acronyms** + +| Acronym | Full Spelling | +| --- | ------------------------------ | +| HDI | Hardware Device Interface | +| IDL | Interface Description Language | + +**Conventions** + +**Rule**: a convention that must be complied with + +**Rec**: a convention that should be considered + +**Note**: an explanation to a rule or rec + +**Change History** +| Version | Change Description | +| --- | --------------------- | +| v1.0 Beta | This issue is the initial version. | +| v1.0 | This issue is the official version. | + + +## Scope and Definition + + + +Located between the system service layer and the device driver layer, HDI provides unified device function abstract interfaces for device developers. It shields the differences of devices from system services. + +## General Rules + +### Version Control + +The HDI version number must be in the format of `major.minor`, where `major` must be an integer increased in ascending order and `minor` is a one-digit integer. + +- A change in `major` indicates architecture adjustment or interface definition that is not backward compatible. + +- A change in `minor` indicates enhanced or extended interface definitions that are backward compatible. + +When `major` changes, `minor` is reset to `0`. + +[Example] + +For released vibrator interfaces: + +```cpp +package ohos.hdi.vibrator.v1_0; +interface IVibrator { + ... + SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int frequency); + ... +} +``` + +If the update to the existing interfaces does not affect version compatibility, for example, adding a function, adding an enum definition, or changing a variable name, change only `minor`, for example, to `ohos.hdi.vibrator.v1_1`, as follows: + +```cpp +package ohos.hdi.vibrator.v1_1; +interface IVibrator { + ... + SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int freq); + ... +} +``` + +If the original interface is renamed or the variable list is modified, change `major`, for example, to `ohos.hdi.vibrator.v2_0`, as follows: + +```cpp +package ohos.hdi.vibrator.v2_0; +interface IVibrator { + ... + SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int frequency, [int] time); + ... +} +``` + +### Review and Control + +HDI interfaces are provided to implement upper-layer system service requirements and perform hardware operations (such as initialization). New and updated interfaces must be fully reviewed and strictly controlled. Only interfaces that meet universal requirements can be added. + +Table 1 Interface review and control roles + +| **Role** | **Responsibility** | +| ----------- | ------------------------------------------------ | +| Contributor | Write HDI code and submit the code and design documents for review. | +| Committer | Review the HDI code, and submit the code to the domain SIG for further review. | +| Domain SIG | Review the new or updated HDI code.| +| Driver SIG | Review the new or updated HDI code. | +| PMC | Revise and publish this design specifications. | + +### Release + +- HDI review process + +  + + The main process is as follows: + + 1. The contributor commits code and initiates a review. In addition to the code of new or updated HDI interfaces, the contributor must provide information about the HDI requirement source, usage scenario, permission design, and privacy protection design. For details, see "Review application composites" below. To increase the review efficiency, the contributor can email the design documents to the committer, domain SIG, and driver SIG before submitting the review application. + 2. The committer reviews the code and HDI interfaces. + 3. The domain SIG reviews the new or updated HDI interfaces. + 4. The driver SIG reviews and approves the new or updated HDI interfaces. + 5. The review is complete, and the code is merged. + +- Review application composites + + After the HDI design is complete, the domain SIG must organize an effective review and provide the following documents before HDI release: + + - Complete and reasonable test cases + + - **HDI version differences, with a clear addition or change scope** + + - Complete interface context, which must be provided in the design document to specify when and how to use each interface + + - Resource status transition diagram in the design document for resource-oriented interfaces + + - Compliance with the HDI design constraints proposed in this document + +- Requirements + + 1. Change `major` for any release that is incompatible with earlier versions. + + 2. Change `minor` for any interface released for function extension. + + 3. To deprecate any released interface: + + - The `deprecated` flag must be provided. + + - The deprecated interfaces must be retained in at least four OpenHarmony HDI versions. + +## HDI Design Constraints + +### Consistency + +#### [Rule] Use consistent nouns for terms. + +Multiple nouns with similar semantic meanings are not allowed to represent the same service object. Similarly, to avoid confusion, it is not allowed to use the same noun or linguistically close nouns for different service objects. + +#### [Rule] Keep the parameter sequence consistent. + +The sequence of a parameter or parameter group in multiple interfaces must be the same. + +For object-oriented C programming, place the interface object as the first parameter by convention. + +#### [Rule] Keep the memory ownership consistent. + +If the memory (storage data) passed through the input parameter (in) or output parameter (out) is allocated by the caller, the memory must be released by the caller. If the memory is allocated by the callee, it must be released by the callee. Regardless of whether data is passed from a service to a driver or received from a driver, the ownership of the data should not be changed, which must always be the memory allocator. + +[Example] + +```cpp +int (*OpenLayer)(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId); +``` + +When **OpenLayer** is called, the graphics layer data memory is allocated based on the input parameter **layerInfo**, and a layer ID is returned. + +```cpp +int (*CloseLayer)(uint32_t devId, uint32_t layerId); +``` + +A **CloseLayer** interface must be provided to release the graphics layer data memory when the caller finishes the operation. + +#### [Rule] Provide a specific return value for every synchronous interface. + +When defining a synchronous interface, you must define the return value and provide necessary invocation status information to specify whether the invocation is successful. If the invocation fails, specify the cause of the failure. You can define a return value based on the actual error cause. + +[Exceptions] + +If an interface is unidirectional, which means that a value can be returned without waiting for the interface to be executed, use the keyword `one way` in the comment. Example: + +```cpp +/* one way */ +void WriteReady(); +``` + +### Naming + +#### [Rule] Name an interface in the format of "I" + "*interface name*". +Interface names must be concise, easy to understand, and accurate. Avoid redundant and misleading words, or rare abbreviations. + +[Example] +``` + /* Good */ + interface IBattery { + ... + } + + /* Bad: The Interface suffix is redundant. */ + interface IBatteryInterface { + ... + } +``` +#### [Rule] Name the HDI package in the format of "package ohos.hdi.[interface_name].v[major_version]_[minor_version]". +[Example] +``` + /* Good */ + package ohos.hdi.battery.v1_0; + interface IBattery { + ... + } + + /* Bad: The hdi namespace and version information are missing. */ + package ohos.battery; + interface IBattery { + ... + } +``` +#### [Rule] Name classes, structs, functions, and parameters in camel case. +**Camel case style** +Camel case is the practice of writing words without spaces. It indicates the separation of words with a single capitalized letter, and the first word starts with either case, bringing about **UpperCamelCase** and **lowerCamelCase**. + + +| Type | Style | +| ---------------------------------------- | --------- | +| Interface types, functions, struct types, enum types, and union types | UpperCamelCase | +| Parameters, and member variables in a struct or union| lowerCamelCase | +| Constants and enums | All uppercase letters, separated by underscores (_)| + +#### [Rule] Use the interface class name as the interface file name and `.idl` as the file name extension. +- An independent interface file must be provided for every interface class, and the file name must be the same as that of the interface class (UpperCamelCase) and end with `.idl`. +- The description file of the type definition must be named `Types.idl` or `ExampleTypes.idl`. + +[Example] + +``` + package ohos.hdi.battery.v1_0; + interface IBattery { + ... + } +``` + The interface description file must be named `IBattery.idl`. + +### Ease to Use + +#### [Rule] Follow the single responsibility principle. + +The functionalities of each interface must be stable and clear, and the trigger source of interface changes must be unique. + +[Example] + +When the device status consists of the power status and port status, use two interfaces rather than one. + +**Correct Example** + +```cpp +int UpdatePowerState(int_t deviceId, int status); // This interface is used to update the power status of the device. + +int UpdatePortStatus(int deviceId, int status); // This interface is used to update the port status of the device. +``` + +**Incorrect Example** + +```cpp +int UpdateDeviceStatus(int deviceId, int powerStatus, int portStatus); +``` + +#### [Rule] Consider cohesion during interface parameter design. + +When defining an interface parameter, consider whether to pass the parameter separately or encapsulate the parameter in a struct based on the following factors: + +1. Is there a meaningful encapsulation boundary? + + If there is obvious cohesion or association between parameters, you can encapsulate these parameters in a struct. + +2. Is there any other use of this struct if structured parameters are used? + + If no, pass the parameter separately. + +3. Does a parameter group occur in multiple interfaces? + + If yes, you can pass these parameters as a struct. In this case, you also need to consider whether these parameter groups are cohesive. + +4. Is there a large number of optional parameters, or do they usually be assigned a default value? + + If yes, you can use a struct to simplify the invocation. + +[Example] + +Audio sampling attributes include the sampling format, sampling frequency, and number of channels. These attributes are also sampling related and can be passed as a struct. + +```cpp +struct AudioSampleAttributes +{ + enum AudioFormat format; + uint32_t sampleRate; + uint32_t channelCount; +}; +``` + +#### [Rule] Make interfaces of different device types independent from each other. + +Interfaces are managed by driver type, such as `Camera`, `Input`, `Display`, `Audio`, `Sensor`, and `Storage`. Interfaces of different device types should not depend on each other. It is recommended that common capabilities that may be used by more than two types of driver modules be abstracted as common interfaces and archived to the common interface capability library for management. + +[Exceptions] + +There is no restriction on the interfaces that provide common capabilities. For example, the definition of primitive types and the declaration of interfaces can be referenced by all interfaces. + +### Privacy Protection + +### [Rule] Consider privacy security. + +System services can access data such as device information and identifiers through drivers. Certain information, such as device names, serial numbers, and device addresses, is sensitive data defined in privacy protection specifications. During HDI design, pay attention to the use of these fields and review them carefully and thoroughly to ensure that the interfaces will never expose sensitive information. + +[Example] + +`Bluetooth` addresses are mainly used in device discovery and connection scenarios. When a device is discoverable, the `Bluetooth` address could be used for personal tracking. + +The major purpose of obtaining a `Bluetooth` address is to uniquely identify a device. Therefore, you can convert the `Bluetooth` address into a unique identifier for invocation or restrict the application scope of this interface. + +### Permission Control + +#### [Rule] Minimize the interface permissions. + +All behaviors across application sandboxes must be controlled by permissions. A specific permission can be granted only to applications that have legitimate service requirements. + +### Performance + +#### [Rule] Consider data transmission efficiency. + +Drivers have a large number of data transmission interfaces. Data transmission may involve inter-process communication (IPC), which increases system overheads or even trigger system scheduling. Therefore, you need to consider all situations when defining interfaces. For the data that must be transmitted between processes with low overhead and low latency, you can use the shared memory or message queue. + +[Example] + +Define a data transmission interface for a driver module as follows: + +```cpp +// IPC is not involved (direct interface calling). +int WriteData (...); // Define the data address pointer and data length as input parameters. + +/* + * IPC is involved. + * + * Define a shared memory or message queue object as the input parameter. + * In this way, data can be efficiently transmitted (since repetitive operations can be minimized). + */ +int PrepareWriteData(…); +``` + +#### [Rec] Consider the interface execution time. + +To improve IPC performance, you are advised to use asynchronous processing for time-consuming services on the server. If the client needs to wait for the result synchronously, you are advised to add a block on the client and use the asynchronous callback mode so that the IPC channel can be released in time. + +[Example] + +The `Camera` driver provides a device initialization interface, the execution of which takes more than 150 ms due to software and hardware reasons. If this interface uses synchronous mode, the camera HDI service IPC thread may be occupied for a long time, and other requests fail to be responded in time. It is more reasonable to design this interface as an asynchronous one. A callback can be used to return the initialization result to the client. If the client needs to wait for the return value before continuing other operations, it can block the process and wait for the callback result. + +#### [Rec] Minimize the number of new process entities. + +To reduce the system overhead, interfaces of the same type in the same subsystem must be deployed in the same process. Add processes only when they are necessary. + +### Power Consumption + +#### [Rule] Consider system power consumption. + +When the caller releases hardware resources, the corresponding driver module should release the wake lock so the system will not be prevented from sleeping. + +### Reliability + +#### [Rule] Mutual dependency is forbidden for the lifecycle of interface parameters. + +The lifecycle of interface parameters must be independent. Mutual dependency is prohibited. Pointer parameters should not point to the memory of other objects, for example, the serialized memory. This is because when the serialized memory is passed to the peer function, the memory block lifecycle disappears after the parameter is parsed, but the pointer may be passed between different functions, resulting in vulnerabilities such as Used After Free (UAF). + +[Example] + +Both `ReadUnpadBuffer` and `ReadCString` return a pointer variable that points to the internal memory of the serialized object. When the server callback is triggered, the serialized object used to pass the parameters is destroyed and the memory is free. If other processes on the server still use the pointers returned by the two interfaces, crash may occur due to the UAF. + +The correct practice is to copy the data to the memory managed by the service before using the data after the service response interface returns the data. + +#### [Rule] Consider reentrancy. + +Interfaces often need to support multiple clients, and a single client may have concurrent requests. Therefore, you must consider reentrancy during HDI design. To ensure correct processing of reentrant interfaces, use locks or semaphores to protect critical resources. + +[Example] + +A driver service provides resource request and release interfaces. When two clients request resources at the same time, if reentrancy is not considered for critical resources on the server, resources may be released in advance or cannot be released due to management data read/write competition. The correct practice is to lock critical resources. + +#### [Rec] Consider the transmission buffer capability. + +No flow control is posed on the amount of data sent in an interface or callback. However, if the data volume of an interface exceeds the maximum transmission buffer size, consider using a block until the resource is available. + +[Example] + +When memory application fails, you can use a semaphore to block the current thread until the memory is available. + +#### [Rule] Do not pass function pointers across address spaces. + +Virtual address space isolation is used between processes. Passing function pointers through IPC will cause access exceptions. Therefore, do not pass function pointers. To implement a callback function, use a callback object instead. + +[Example] + +The Wi-Fi module provides an interface to receive a callback triggered when the client accepts the server request. An incorrect practice is to write the function pointer implemented by the client to the serialized object, which causes a crash when the function pointer is called on the server. + +The correct practice is to design and implement the callback interface using a callback object, and pass the callback object to the server through the serialization interface, so the server can trigger the callback when needed. + +### Compatibility + +#### [Rule] Verify the version number before the client calls an interface. + +Due to the independent component update policy, the version number of an interface on the client may be different from that on the server. This requires the client to verify the version number on the server and use the matching version to call the interface on the server. + +[Example] + +Assume that the TP module provides interfaces of versions 1.0 and 1.1. The later version has new interfaces. The components on the client have updated to 1.1, and the server still uses 1.0. If the client directly calls an interface of 1.1 on the server, an error may occur. Instead, the client must use the service version query interface to check the server version. If the server version is 1.0, the client must use the interface of 1.0 to call the server. + +#### [Rule] Release HDI interfaces in .idl format. + +Currently, Unix-like drivers use virtual file system (VFS) interfaces to expose internal interfaces. The user mode and kernel mode communicate with each other using system calls. They are packed in different images, and two sets of interfaces are maintained separately. To ensure the consistency of the interface definition and parameter format between the two and consider the design objective of cross-kernel hardware driver foundation (HDF) deployment, release interfaces in .idl format and use a tool to generate interfaces of the target form. In addition, the user-mode caller is not allowed to operate the driver VFS interfaces through the file interface. This causes the framework to strongly depend on the kernel and violates the principle of depending on the interface instead of the implementation. + +Recommended practice: The driver provides interfaces in .idl format and encapsulates the access to the kernel device in the interface implementation. + +[Example] + +An input device provides query interfaces for attributes such as the device type and data precision. The input service should not directly access the VFS interface created by the kernel in open-ioctl mode. Instead, the input driver should provide an interface to abstract the input device as an object. Then the input service calls this interface to implement the required functionalities. + +### Documentation + +#### [Rule] Release HDI interfaces in .idl format. +To ensure interface compatibility and consistency, release interfaces in .idl format. It is prohibited to directly release interfaces in C/C++ header files. + + +#### [Rule] Provide an interface description during interface release. +The interface description must contain the interface functionality, parameter value range, return values, and precautions. The description text must be placed above the interface description in the .idl file and released with the interface. + +[Example] + +``` +/** + * @brief Obtains the executor information. + * + * @param executorInfo Indicates the executor information. For details, see {@link ExecutorInfo}. + * + * @return Returns <b>0</b> if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ +GetExecutorInfo([out] struct ExecutorInfo executorInfo); +``` + +### Programming Languages + +To ensure data interworking between interfaces implemented in different programming languages, follow the restrictions below when using data types in the interface description. + +#### Constraints on using basic data types + +| IDL Data Type | C++ Data Type | C Data Type | Data Length (Bytes)| +| -------------- | ----------- | --------------- | ----------- | +| void | void | void | NA | +| boolean | bool | bool | 1 | +| byte | int8_t | int8_t | 1 | +| short | int16_t | int16_t | 2 | +| int | int32_t | int32_t | 4 | +| long | int64_t | int64_t | 8 | +| float | float | float | 4 | +| double | double | double | 8 | +| String | std::string | char*, int size | NA | +| unsigned char | uint8_t | uint8_t | 1 | +| unsigned short | uint16_t | uint16_t | 2 | +| unsigned int | uint32_t | uint32_t | 4 | +| unsigned long | uint64_t | uint64_t | 8 | + +#### Constraints on Using Container Types + +| IDL Container Data Type| C++ Data Type | C Data Type | +| ----------- | ------------ | ----------- | +| List<T> | std::list<T> | T*,int size | + +#### Constraints on Using Array Types + +| IDL Array Data Type | C++ Data Type | C Data Type | +| --------- | -------------- | ----------- | +| T[] | std::vector<T> | T*,int size | + +#### Constraints on Using Custom Types + +| IDL Custom Data Type| C++ Data Type| C Data Type | +| ------- | ------- | ------ | +| struct | struct | struct | +| enum | enum | enum | diff --git a/en/device-dev/device-dev-guide.md b/en/device-dev/device-dev-guide.md index 01a4430c3b51bbf5589007615b5f69c9ced0a469..65f1bdf8e5afcdaa4c8d092f68d87eb6ad406693 100644 --- a/en/device-dev/device-dev-guide.md +++ b/en/device-dev/device-dev-guide.md @@ -36,7 +36,7 @@ In addition, OpenHarmony provides a wide array of system components that can be | Getting started | Getting started with setup, build, burning, debugging, and running of OpenHarmony | - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md)| | Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Mini System](kernel/kernel-mini-overview.md)<br>- [Kernel for Small System](kernel/kernel-small-overview.md)<br>- [HDF](driver/driver-hdf-overview.md)<br>- [Subsystems](subsystems/subsys-build-mini-lite.md)<br>- [Security Guidelines](security/security-guidelines-overall.md)<br>- [Privacy Protection](security/security-privacy-protection.md)| | Advanced development | Developing smart devices based on system capabilities | - [WLAN-connected Products](guide/device-wlan-led-control.md)<br>- [Cameras Without a Screen](guide/device-iotcamera-control-overview.md)<br>- [Cameras with a Screen](guide/device-camera-control-overview.md) | -| Porting and adaptation | - Porting and adapting OpenHarmony to an SoC<br>- Porting and adapting OpenHarmony to a third-party library<br>- Third-party vendor porting cases<br>| - [Mini System SoC Porting Guide](porting/porting-minichip.md)<br>- [Small System SoC Porting Guide](porting/porting-smallchip-prepare-needs.md)<br>- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty-overview.md) <br> - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md)<br> - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)<br> | +| Porting and adaptation | - Porting and adapting OpenHarmony to an SoC<br>- Porting and adapting OpenHarmony to a third-party library<br>- Third-party vendor porting cases<br>| - [Mini System SoC Porting Guide](porting/porting-minichip.md)<br>- [Small System SoC Porting Guide](porting/porting-smallchip-prepare-needs.md)<br>- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty-overview.md) <br> - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md)<br> - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)<br> | | Contributing components | Contributing components to OpenHarmony | - [HPM Part Overview](hpm-part/hpm-part-about.md)<br>- [HPM Part Development](hpm-part/hpm-part-development.md)<br>- [HPM Part Reference](hpm-part/hpm-part-reference.md) | | Reference | Referring to development specifications | [FAQs](faqs/faqs-overview.md) | diff --git a/en/device-dev/driver/driver-peripherals-lcd-des.md b/en/device-dev/driver/driver-peripherals-lcd-des.md index 06941d7c81bcd714357cb6a9e5e22997aa91a2ad..d5ba25a559c9c255a829ac083e869c0b28db9b00 100644 --- a/en/device-dev/driver/driver-peripherals-lcd-des.md +++ b/en/device-dev/driver/driver-peripherals-lcd-des.md @@ -319,7 +319,7 @@ static struct PanelInfo g_panelInfo = { .vsw = VERTICAL_SYNC_WIDTH, /* vertical sync width */ .frameRate = FRAME_RATE, /* frame rate */ .intfType = MIPI_DSI, /* panel interface type */ - .intfSync = OUTPUT_USER, /* output timming type */ + .intfSync = OUTPUT_USER, /* output timing type */ /* MIPI configuration */ .mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT }, /* backlight config info */ diff --git a/en/device-dev/driver/driver-platform-adc-des.md b/en/device-dev/driver/driver-platform-adc-des.md index f7075aa1d07a13320c429b23de01b41e5e18f25a..76c73fb3e947e45190831c6f060ae1c1ac1d97db 100644 --- a/en/device-dev/driver/driver-platform-adc-des.md +++ b/en/device-dev/driver/driver-platform-adc-des.md @@ -1,64 +1,79 @@ -# ADC<a name="1"></a> +# ADC -## Overview<a name="section1"></a> +## Overview + +### Function An analog-to-digital converter (ADC) is a device that converts analog signals into digital signals. The ADC APIs provide a set of common functions for ADC data transfer, including: -- Opening or closing an ADC device +- Opening or closing an ADC device +- Obtaining the analog-to-digital (AD) conversion result + +### Basic Concepts + +The ADC converts analog parameters into digital parameters for easy storage and computing. The technical specifications of the ADC include the following: + +- Resolution + + The number of binary bits that can be converted by an ADC. A greater number of bits indicates a higher resolution. +- Conversion error + + Difference between the actual and theoretical digital values output by an ADC. It is expressed by a multiple of the least significant bit. Generally, the maximum output error is used. +- Transition time + + Time required by an ADC to perform a complete conversion. + +### Working Principles + +In the Hardware Driver Foundation (HDF), the ADC module uses the unified service mode for API adaptation. In this mode, a service is used as the ADC manager to handle external access requests in a unified manner. The unified service mode applies when the system has multiple device objects of the same type. If the independent service mode is used in this case, more device nodes need to be configured and more memory resources will be consumed. + +The ADC module is divided into the following layers: + +- Interface layer: provides APIs for opening or closing a device and writing data. +- Core layer: provides the capabilities of binding, initializing, and releasing devices. +- Adaptation layer: implements driver-specific functions. + +In addition to the power and ground cables, the ADC requires only one cable to connect to the target device. The figure below shows the physical connection. -- Obtaining the analog-to-digital (AD) conversion result +**Figure 1** ADC physical connection - **Figure 1** ADC physical connection - -  -## Available APIs<a name="section2"></a> + + +### Constraints + +Currently, the ADC module supports only the kernels (LiteOS) of mini and small systems. + +## Usage Guidelines + +### When to Use + +An ADC is usually used to convert an analog voltage into a digital parameter, for example, it is used with a microphone to collect sound, used with an NTC resistor to measure temperature, or converts the output of analog sensors into digital parameters. + +### Available APIs + +The table below describes the APIs of the ADC module. For more details, see API Reference. **Table 1** APIs of the ADC driver -<a name="table1"></a> - -<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="18.63%"><p>Category</p> -</th> -<th class="cellrowborder" valign="top" width="28.03%"><p>API</p> -</th> -<th class="cellrowborder" valign="top" width="53.339999999999996%"><p>Description</p> -</th> -</tr> -</thead> -<tbody><tr><td class="cellrowborder" bgcolor="#ffffff" rowspan="2" valign="top" width="18.63%"><p>Managing ADC devices</p> -</td> -<td class="cellrowborder" valign="top" width="28.03%"><p>AdcOpen</p> -</td> -<td class="cellrowborder" valign="top" width="53.339999999999996%">Opens an ADC device.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top"><p>AdcClose</p> -</td> -<td valign="top"><p>Closes an ADC device.</p> -</td> -</tr> -<tr><td class="cellrowborder" bgcolor="#ffffff" valign="top" width="18.63%"><p>Obtaining the conversion result</p> -</td> -<td class="cellrowborder" valign="top" width="28.03%"><p>AdcRead</p> -</td> -<td class="cellrowborder" valign="top" width="53.339999999999996%"><p>Reads the AD conversion result.</p> -</td> -</tr> -</table> - -## Usage Guidelines<a name="section3"></a> - -### How to Use<a name="section4"></a> - -The figure below illustrates how to use the APIs. - - **Figure 2** Using ADC driver APIs - - - -### Opening an ADC Device<a name="section5"></a> + +| API | Description | +| -------- | ---------------- | +| AdcOpen | Opens an ADC device. | +| AdcClose | Closes an ADC device. | +| AdcRead | Obtains the AD conversion result.| + +### How to Develop + +The figure below shows the general development process. + + **Figure 2** Process of using ADC APIs + + + + +#### Opening an ADC Device. Call **AdcOpen** to open an ADC device. @@ -68,43 +83,20 @@ DevHandle AdcOpen(int16_t number); **Table 2** Description of AdcOpen -<a name="table2"></a> - -<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="20.66%"><p> Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="79.34%"><p><strong>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr><td class="cellrowborder" valign="top" width="20.66%"><p>number</p> -</td> -<td class="cellrowborder" valign="top" width="79.34%"><p>ADC device number.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="20.66%"><p><strong>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="79.34%"><p><strong>Description</strong></p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="20.66%"><p>NULL</p> -</td> -<td class="cellrowborder" valign="top" width="79.34%"><p>Failed to open the ADC device.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="20.66%"><p>Device handle</p> -</td> -<td class="cellrowborder" valign="top" width="79.34%"><p>Handle of the ADC device opened.</p> -</td> -</tr> -</tbody> -</table> - -For example, open device 1 of the two ADCs (numbered 0 and 1) in the system. + +| Parameter | Description | +| ---------- | ----------------- | +| number | ADC device number. | +| **Return Value**| **Description** | +| NULL | The operation failed. | +| Device handle | The operation is successful. The handle of the ADC device opened is returned.| + +Example: Open device 1 of the two ADCs (numbered 0 and 1) in the system. ```c DevHandle adcHandle = NULL; /* ADC device handle / -/* Open the ADC device. */ +/* Open ADC device 1. */ adcHandle = AdcOpen(1); if (adcHandle == NULL) { HDF_LOGE("AdcOpen: failed\n"); @@ -112,7 +104,7 @@ if (adcHandle == NULL) { } ``` -### Obtaining the AD Conversion Result<a name="section6"></a> +#### Obtaining the AD Conversion Result ```c int32_t AdcRead(DevHandle handle, uint32_t channel, uint32_t *val); @@ -120,48 +112,30 @@ int32_t AdcRead(DevHandle handle, uint32_t channel, uint32_t *val); **Table 3** Description of AdcRead -<a name="table3"></a> - -<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="50%"><p><strong> Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="50%"><p><strong>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr><td class="cellrowborder" valign="top" width="50%"><p>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>ADC device handle.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p>channel</p> -</td> -<td class="cellrowborder"valign="top" width="50%"><p>ADC device channel number.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p>val</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>AD conversion result.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p><strong>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p><strong>Description</strong></p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>The operation is successful.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p>Negative number</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>Failed to obtain the AC conversion result.</p> -</td> -</tr> -</tbody> -</table> - -### Closing an ADC Device<a name="section7"></a> + +| Parameter | Description | +| ---------- | -------------- | +| handle | ADC device handle. | +| channel | ADC device channel number. | +| val | Pointer to the AD conversion result. | +| **Return Value**| **Description**| +| 0 | The operation is successful. | +| Negative value | The operation failed. | + +Example: Obtain the AD conversion result of channel 1. + +```c +uint32_t value; +int32_t ret; + +ret = AdcRead(adcHandle, 1, &value); +if (ret != 0) { + HDF_LOGE("ADC read fail!\n"); + return; +} +``` + +#### Closing an ADC Device Call **AdcClose** to close the ADC device after the ADC communication is complete. ```c @@ -169,31 +143,12 @@ void AdcClose(DevHandle handle); ``` **Table 4** Description of AdcClose -<a name="table4"></a> - -<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="50%"><p> Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="50%"><p>Description</p> -</th> -</tr> -</thead> -<tbody><tr><td class="cellrowborder" valign="top" width="50%"><p>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>ADC device handle.</p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p><strong>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p><strong>Description</strong></p> -</td> -</tr> -<tr><td class="cellrowborder" valign="top" width="50%"><p>None</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p>No value is returned if the ADC device is closed.</p> -</td> -</tr> -</tbody> -</table> + +| Parameter | Description | +| ------ | ----------- | +| handle | ADC device handle.| +| **Return Value**| **Description** | +| N/A | N/A | Example: @@ -201,9 +156,9 @@ Example: AdcClose(adcHandle); /* Close the ADC device. */ ``` -## Example<a name="section8"></a> +### Example -This following example shows how to use ADC APIs to manage an ADC device on a Hi3516D V300 development board. +This following example shows how to use ADC APIs to manage an ADC device on a Hi3516D V300 board. The basic hardware information is as follows: @@ -242,7 +197,7 @@ static int32_t TestCaseAdc(void) for (i = 0; i < 30; i++) { ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &readBuf[i]); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: tp ADC write reg fail!:%d", __func__, ret); + HDF_LOGE("%s: Failed to read ADC!:%d", __func__, ret); AdcClose(adcHandle); return -1; } diff --git a/en/device-dev/driver/driver-platform-dac-des.md b/en/device-dev/driver/driver-platform-dac-des.md index 45cd858317a5affefb3bb285322f73c92b0b380c..4cffd91b8618ab4f466ce32f1ff0ca3e959f1e6b 100644 --- a/en/device-dev/driver/driver-platform-dac-des.md +++ b/en/device-dev/driver/driver-platform-dac-des.md @@ -1,6 +1,5 @@ # DAC - ## Overview ### DAC @@ -8,11 +7,9 @@ A digit-to-analog converter (DAC) is a device that converts a digital signal into an analog signal in electronics. The DAC APIs provide a set of methods for DAC data transfer, including: - - Opening or closing a DAC device - Setting the target digital-to-analog (DA) value - ### Basic Concepts The DAC module provides the output channel for the process control computer system. It connects to the executor to implement automatic control of the production process. It is also an important module in the analog-to-digital converter using feedback technologies. @@ -35,29 +32,31 @@ The DAC module provides the output channel for the process control computer syst ### Working Principles -In the Hardware Driver Foundation (HDF), the DAC module uses the unified service mode for API adaptation. In this mode, a device service is used as the DAC manager to handle access requests from the devices of the same type in a unified manner. The unified service mode applies to the scenario where there are many device objects of the same type. If the independent service mode is used, more device nodes need to be configured and memory resources will be consumed by services. The figure below shows the unified service mode. +In the Hardware Driver Foundation (HDF), the DAC module uses the unified service mode for API adaptation. In this mode, a service is used as the DAC manager to handle external access requests in a unified manner. The unified service mode applies when the system has multiple device objects of the same type. If the independent service mode is used in this case, more device nodes need to be configured and more memory resources will be consumed. The figure below shows the unified service mode. The DAC module is divided into the following layers: -- The interface layer provides APIs for opening or closing a device and writing data. -- The core layer provides the capabilities of binding, initializing, and releasing devices. -- The adaptation layer implements other functions. -> **NOTE**<br> ->The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. +- Interface layer: provides APIs for opening or closing a device and writing data. +- Core layer: provides the capabilities of binding, initializing, and releasing devices. +- Adaptation layer: implements driver-specific functions. + +> **NOTE** +> +> The core layer can call the functions of the interface layer and uses a hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. **Figure 1** Unified service mode - + ### Constraints - Currently, the DAC module supports only the kernels (LiteOS) of mini and small systems. +Currently, the DAC module supports only the kernels (LiteOS) of mini and small systems. -## Development Guidelines +## Usage Guidelines ### When to Use - The DAC module converts digital signals into analog signals in the form of current, voltage, or charge. It is mainly used in audio devices. Audio players and headsets use the DAC module as the digital-to-analog conversion channels. +The DAC module converts digital signals into analog signals in the form of current, voltage, or charge. It is mainly used in audio devices. Audio players and headsets use the DAC module as the digital-to-analog conversion channels. ### Available APIs @@ -65,45 +64,44 @@ The table below describes the APIs of the DAC module. For more details, see API **Table 1** DAC driver APIs -| API | Description | -| :------------------------------------------------------------| :------------ | -| DevHandle DacOpen(uint32_t number) | Opens a DAC device. | -| void DacClose(DevHandle handle) | Closes a DAC device. | -| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets a target DA value. | +| API | Description | +| ------------------------------------------------------------------ | ------------ | +| DevHandle DacOpen(uint32_t number) | Opens a DAC device. | +| void DacClose(DevHandle handle) | Closes a DAC device. | +| int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val) | Sets a target DA value.| ### How to Develop -The figure below illustrates how to use the APIs. +The figure below shows the general development process. + +**Figure 2** Process of using DAC APIs -**Figure 2** Using DAC driver APIs - + #### Opening a DAC Device Call **DacOpen()** to open a DAC device before performing the DA conversion. -``` +```c++ DevHandle DacOpen(uint32_t number); ``` **Table 2** Description of DacOpen -| **Parameter** | Description | -| ---------- | ----------------- | -| number | DAC device number. | -| **Return Value**| **Description** | -| NULL | Failed to open the DAC device. | -| Device handle | Handle of the DAC device opened.| - - +| Parameter | Description | +| --------- | ---------------- | +| number | DAC device number. | +| **Return Value**| **Description** | +| NULL | The operation failed. | +| Device handle | The operation is successful. The handle of the DAC device opened is returned.| -Open device 1 of the two ADC devices (numbered 0 and 1) in the system. +Example: Open device 1 of the two DAC devices (numbered 0 and 1) in the system. -``` +```c++ DevHandle dacHandle = NULL; /* DAC device handle / -/* Open the DAC device. */ +/* Open DAC device 1. */ dacHandle = DacOpen(1); if (dacHandle == NULL) { HDF_LOGE("DacOpen: failed\n"); @@ -113,23 +111,22 @@ if (dacHandle == NULL) { #### Setting a Target DA Value -``` +```c++ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); ``` **Table 3** Description of DacWrite - -| **Parameter** | Description | -| ---------- | -------------- | -| handle | DAC device handle. | -| channel | DAC channel number. | -| val | DA value to set. | +| Parameter | Description | +| --------- | ------------ | +| handle | DAC device handle. | +| channel | DAC channel number.| +| val | DA value to set. | | **Return Value**| **Description**| -| 0 | The operation is successful. | -| Negative value | The operation failed. | +| 0 | The operation is successful. | +| Negative value | The operation failed. | -``` +```c++ /* Write the target DA value through the DAC_CHANNEL_NUM channel. */ ret = DacWrite(dacHandle, DAC_CHANNEL_NUM, val); if (ret != HDF_SUCCESS) { @@ -142,28 +139,25 @@ int32_t DacWrite(DevHandle handle, uint32_t channel, uint32_t val); #### Closing a DAC Device After the DAC communication is complete, call **DacClose()** to close the DAC device. -``` +```c++ void DacClose(DevHandle handle); ``` **Table 4** Description of DacClose - -| **Parameter** | Description | -| ---------- | -------------- | -| handle | DAC device handle. | +| Parameter | Description | +| --------- | ------------ | +| handle | DAC device handle. | | **Return Value**| **Description**| -| void | - | - - +| void | - | Example: -``` +```c++ DacClose(dacHandle); /* Close the DAC device. */ ``` -## Development Example +## Example The procedure is as follows: @@ -173,8 +167,8 @@ The procedure is as follows: You can obtain the operation result by printing the log information based on the **val**. -``` -#include "hdmi_if.h" /* Header file for DAC APIs */ +```c++ +#include "dac_if.h" /* Header file for DAC APIs */ #include "hdf_log.h" /* Header file for log APIs */ /* Define device 0, channel 1. */ @@ -209,4 +203,4 @@ static int32_t TestCaseDac(void) return 0; } -``` \ No newline at end of file +``` diff --git a/en/device-dev/driver/driver-platform-i2c-des.md b/en/device-dev/driver/driver-platform-i2c-des.md index 0cd8cc6526887c83dd25f67bddb0b82e6bce26d2..9ba71d09003c5598ca4636eed7fe718406a1f960 100644 --- a/en/device-dev/driver/driver-platform-i2c-des.md +++ b/en/device-dev/driver/driver-platform-i2c-des.md @@ -64,7 +64,7 @@ The figure below illustrates how to use the APIs. **Figure 2** Using I2C driver APIs - + ### Opening an I2C Controller<a name="section13751110132914"></a> diff --git a/en/device-dev/driver/driver-platform-mmc-develop.md b/en/device-dev/driver/driver-platform-mmc-develop.md index 10445936ef0e8f53cc95968c40f1c9dd2aae29c7..b222b2081ea95ca1c17fe48e4d1e9413ff44f139 100644 --- a/en/device-dev/driver/driver-platform-mmc-develop.md +++ b/en/device-dev/driver/driver-platform-mmc-develop.md @@ -3,7 +3,7 @@ ## Overview -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, which increases memory usage. +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, which increases memory usage. **Figure 1** Independent service mode @@ -14,7 +14,7 @@ In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the inde **MmcCntlrOps**: - + ``` struct MmcCntlrOps { int32_t (*request)(struct MmcCntlr *cntlr, struct MmcCmd *cmd); @@ -37,23 +37,23 @@ struct MmcCntlrOps { **Table 1** Description of callback functions in MmcCntlrOps -| Function| Input Parameter| Return Value| Description| +| 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.| +| 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 @@ -75,7 +75,6 @@ The MMC module adaptation involves the following steps: > For details about the functions in **MmcCntlrOps**, see [Available APIs](#available-apis). 4. Debug the driver. - (Optional) For new drivers, verify the basic functions, for example, check the information returned after the **MmcCntlrOps** instance is attached and whether the device starts successfully. @@ -88,7 +87,7 @@ The following uses **himci.c** as an example to present the information required 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 example: - + ``` struct HdfDriverEntry g_mmcDriverEntry = { .moduleVersion = 1, @@ -106,7 +105,7 @@ The following uses **himci.c** as an example to present the information required - **device_info.hcs** configuration example - + ``` root { device_info { @@ -147,7 +146,7 @@ The following uses **himci.c** as an example to present the information required - **mmc_config.hcs** configuration example - + ``` root { platform { @@ -196,15 +195,15 @@ The following uses **himci.c** as an example to present the information required } } } - } - ``` - + } + ``` + 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 passes important parameters to the **MmcCntlr** object at the core layer. - + ``` struct HimciHost { struct MmcCntlr *mmc;// (Mandatory) Core layer structure @@ -257,7 +256,7 @@ The following uses **himci.c** as an example to present the information required - Instantiating **MmcCntlrOps** in **MmcCntlr** (other members are initialized by **Bind**) - + ``` static struct MmcCntlrOps g_himciHostOps = { .request = HimciDoRequest, @@ -300,7 +299,7 @@ The following uses **himci.c** as an example to present the information required 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) { @@ -347,7 +346,7 @@ The following uses **himci.c** as an example to present the information required Implements **ProcMciInit**. - + ``` static int32_t HimciMmcInit(struct HdfDeviceObject *obj) { @@ -377,7 +376,7 @@ The following uses **himci.c** as an example to present the information required 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. - + ``` static void HimciMmcRelease(struct HdfDeviceObject *obj) { diff --git a/en/device-dev/driver/driver-platform-regulator-develop.md b/en/device-dev/driver/driver-platform-regulator-develop.md index 960c3b88bfaf225ec1f911a22be8ffad0b25037b..022df8b238b518c4560789843391f751b1fabb5a 100644 --- a/en/device-dev/driver/driver-platform-regulator-develop.md +++ b/en/device-dev/driver/driver-platform-regulator-develop.md @@ -5,23 +5,18 @@ ### Regulator -The regulator module controls the voltage and current supplies of some devices in the system. - -### Basic Concepts - The regulator module controls the voltage and current supplies of some devices in the system. In an embedded system (especially a mobile phone), it is important to control the power consumption, which directly affects the battery endurance. You can use a regulator to shut down the power supply to an idle module in the system or reduce the voltage and current for the module. ### Working Principles -In the Hardware Driver Foundation (HDF), the regulator module uses the unified service mode for API adaptation. In this mode, a device service is used as the regulator manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies to the scenario where there are many device objects of the same type, for example, when the regulator has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and more memory resources will be consumed by services. +In the Hardware Driver Foundation (HDF), the regulator module uses the unified service mode for API adaptation. In this mode, a device service is used as the regulator manager to handle external access requests in a unified manner, which is reflected in the configuration file. The unified service mode applies when there are many device objects of the same type, for example, when the regulator has more than 10 controllers. If the independent service mode is used, more device nodes need to be configured and more memory resources will be consumed by services. The regulator module is divided into the following layers: +- Interface layer: provides APIs for opening or closing a device and writing data. +- Core layer: provides the capabilities of binding, initializing, and releasing devices. +- Adaptation layer: implements other functions. -- The interface layer provides APIs for opening or closing a device and writing data. -- The core layer provides the capabilities of binding, initializing, and releasing devices. -- The adaptation layer implements other functions. - -NOTE<br/>The core layer can call the functions of the interface layer and uses the hook to call functions of the adaptation layer. In this way, the adaptation layer can indirectly call the functions of the interface layer, but the interface layer cannot call the functions of the adaptation layer. +NOTE<br/>The core layer can call the APIs of the interface layer and uses hooks to call APIs of the adaptation layer. In this way, the adaptation layer can indirectly call the APIs of the interface layer, but the interface layer cannot call the APIs of the adaptation layer. **Figure 1** Unified service mode @@ -33,13 +28,12 @@ The regulator module is divided into the following layers: Currently, the regulator module supports only the kernels (LiteOS) of mini and small systems. -## Development Guidelines ### When to Use The regulator module controls the voltage and current supplies of some devices in the system. -### Available APIs +## Available APIs The functions in **RegulatorMethod** are used to call the corresponding regulator driver functions: @@ -65,31 +59,34 @@ struct RegulatorMethod { | Method | Input Parameter | Return Value | Description | -| ------------ | ------------------------------------------------------------ | ------------------ | ---------------- | +| ------------ | ----------------------------------------------------------- | ----------------- | ---------------- | | open | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Opens a device. | | close | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Closes a device. | | release | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Releases a device handle. | -| enable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Enabling a Regulator | -| disable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Disabling a Regulator | -| forceDisable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Forcibly Disabling a Regulator | +| enable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Enables a regulator. | +| disable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Disables a regulator. | +| forceDisable | **node**: structure pointer to the regulator node at the core layer. | HDF_STATUS| Forcibly disables a regulator. | | setVoltage | **node**: structure pointer to the regulator node at the core layer.<br>**minUv**: minimum voltage to set. It is a uint32_t variable.<br>**maxUv**: maximum voltage to set. It is a uint32_t variable.| HDF_STATUS| Sets the output voltage range.| -| getVoltage | **node**: structure pointer to the regulator node at the core layer.<br>**voltage**: pointer to the output voltage value.| HDF_STATUS| Obtains the voltage. | +| getVoltage | **node**: structure pointer to the regulator node at the core layer.<br>**voltage**: pointer to the output voltage.| HDF_STATUS| Obtains the voltage. | | setCurrent | **node**: structure pointer to the regulator node at the core layer.<br>**minUa**: minimum current to set. It is a uint32_t variable.<br>**maxUa**: maximum current to set. It is a uint32_t variable.| HDF_STATUS| Sets the output current range.| | getCurrent | **node**: structure pointer to the regulator node at the core layer.<br>**regCurrent**: pointer to the output current, which is of the uint32_t type.| HDF_STATUS| Obtains the current. | | getStatus | **node**: structure pointer to the regulator node at the core layer.<br>**status**: pointer to the output status, which is of the uint32_t type.| HDF_STATUS| Obtains the device status. | -### How to Develop + +## How to Develop The regulator module adaptation procedure is as follows: -- Instantiate the driver entry. -- Configure attribute files. -- Instantiate the core layer APIs. -- Debug the driver. +1. Instantiate the driver entry. +2. Configure attribute files. +3. Instantiate the core layer APIs. +4. Debug the driver. + +## Development Example 1. Instantiate the driver entry. - 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 are collected to form a segment address space similar to an array for the upper layer to invoke. + 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, the HDF calls the **Init()** function to load the driver. If **Init()** fails to be called, the HDF calls **Release** to release driver resources and exit. @@ -100,7 +97,7 @@ The regulator module adaptation procedure is as follows: .Init = VirtualRegulatorInit, .Release = VirtualRegulatorRelease, }; - // Call HDF_INIT to register the driver entry with the HDF framework. + // Call HDF_INIT to register the driver entry with the HDF. HDF_INIT(g_regulatorDriverEntry); ``` @@ -115,15 +112,15 @@ The regulator module adaptation procedure is as follows: | Member | Value | | --------------- | ------------------------------------------------------------ | | policy | **0**, which indicates that no service is published. | - | priority | Driver startup priority. The value range is 0 to 200. A larger value indicates a lower priority. If the priorities are the same, the device loading sequence is not ensured.| + | priority | Driver startup priority, which ranges form 0 to 200. A larger value indicates a lower priority. If the priorities are the same, the device loading sequence is not ensured.| | permission | Driver permission. | - | moduleName | The value is **HDF_PLATFORM_REGULATOR_MANAGER**. | - | serviceName | The value is **HDF_PLATFORM_REGULATOR_MANAGER**. | - | deviceMatchAttr | Reserved. | + | moduleName | **HDF_PLATFORM_REGULATOR_MANAGER** | + | serviceName | **HDF_PLATFORM_REGULATOR_MANAGER** | + | deviceMatchAttr | This parameter is reserved. | Configure regulator controller information from the second node. This node specifies a type of regulator controllers rather than a specific regulator controller. In this example, there is only one regulator device. If there are multiple regulator devices, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **regulator\_config** file. - - **device_info.hcs** configuration reference + - **device_info.hcs** configuration example ``` root { @@ -132,14 +129,14 @@ The regulator module adaptation procedure is as follows: hostName = "platform_host"; priority = 50; device_regulator :: device { - device0 :: deviceNode { // Configure an HDF device node for each regulator controller. - policy = 1; // 2: visible in user mode; 1: visible in kernel mode; 0: no service required. - priority = 50; // Driver startup priority. - permission = 0644; // Permission to create device nodes of the driver. + device0:: deviceNode { // Set an HDF device node for each regulator controller. + policy = 1; // Policy for the driver to publish services. + priority = 50; // Driver startup priority. + permission = 0644; // Permission to create device nodes for the driver. /* (Mandatory) Driver name, which must be the same as the moduleName in the driver entry. */ moduleName = "HDF_PLATFORM_REGULATOR_MANAGER"; serviceName = "HDF_PLATFORM_REGULATOR_MANAGER"; // (Mandatory) Unique name of the service published by the driver. - /* (Mandatory) Set the controller private data, which must be same as that in regulator_config.hcs. */ + /* (Mandatory) Set the controller private data, which must be same as that in regulator_config.hcs. */ deviceMatchAttr = "hdf_platform_regulator_manager"; } device1 :: deviceNode { @@ -155,7 +152,7 @@ The regulator module adaptation procedure is as follows: } ``` - - **regulator\_config.hcs** reference: + - **regulator\_config.hcs** configuration example: ``` root { @@ -184,7 +181,7 @@ The regulator module adaptation procedure is as follows: minUa = 0; maxUa = 0; } - /* Each regulator controller corresponds to a controller node. If there are multiple regulator controllers, add the corresponding controller nodes one by one.*/ + /* Each regulator controller corresponds to a controller node. If there are multiple regulator controllers, add the corresponding controller nodes one by one. */ controller_0x130d0001 :: regulator_controller { device_num = 1; name = "regulator_adapter_2"; @@ -201,146 +198,152 @@ The regulator module adaptation procedure is as follows: } ``` -3. Instantiate the APIs of the core layer. - - - Initialize the **RegulatorNode** object at the core layer, including initializing the vendor custom structure (passing parameters and data), instantiating **RegulatorMethod** (used to call underlying functions of the driver) in **PinCntlr**, and implementing the **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**). - - - Initializing the vendor custom structure +3. Instantiate the APIs of the core layer. - The **RegulatorNode** structure holds parameters and data for the driver. The HDF obtains the values in **regulator\_config.hcs** using **DeviceResourceIface**. - - ``` - // RegulatorNode is the controller structure at the core layer. Its members are assigned with values by using the Init function. - struct RegulatorNode { - struct RegulatorDesc regulatorInfo; - struct DListHead node; - struct RegulatorMethod *ops; - void *priv; - struct OsalMutex lock; - }; - - struct RegulatorDesc { - const char *name; /* Regulator name. */ - const char *parentName; /* Regulator parent node name. */ - struct RegulatorConstraints constraints; /* Regulator constraint information. */ - uint32_t minUv; /* Minimum output voltage. */ - uint32_t maxUv; /* Maximum output voltage. */ - uint32_t minUa; /* Minimum output current. */ - uint32_t maxUa; /* Maximum output current. */ - uint32_t status; /* Regulator status, which can be on or off. */ - int useCount; - int consumerRegNums; /* Number of regulator consumers. */ - RegulatorStatusChangecb cb; /* Variable used to notify the regulator status changes. */ - }; - - struct RegulatorConstraints { - uint8_t alwaysOn; /* Whether the regulator is always on. */ - uint8_t mode; /* Voltage or current. */ - uint32_t minUv; /* Minimum output voltage allowed. */ - uint32_t maxUv; /* Maximum output voltage allowed. */ - uint32_t minUa; /* Minimum output current allowed. */ - uint32_t maxUa; /* Maximum output current allowed. */ - }; - ``` - + Initialize the **RegulatorNode** 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 **RegulatorMethod** in **RegulatorNode** (so that the underlying driver functions can be called). + + - Defining a custom structure + + The **RegulatorNode** structure holds parameters and data for the driver. The HDF obtains the values in **regulator_config.hcs** using **DeviceResourceIface**. + + + + ``` + // RegulatorNode is the core layer controller structure. The Init function assigns values to the members of RegulatorNode. + struct RegulatorNode { + struct RegulatorDesc regulatorInfo; + struct DListHead node; + struct RegulatorMethod *ops; + void *priv; + struct OsalMutex lock; + }; + + struct RegulatorDesc { + const char *name; /* Regulator name. */ + const char *parentName; /* Regulator parent node name. */ + struct RegulatorConstraints constraints; /* Regulator constraint information. */ + uint32_t minUv; /* Minimum output voltage. */ + uint32_t maxUv; /* Maximum output voltage. */ + uint32_t minUa; /* Minimum output current. */ + uint32_t maxUa; /* Maximum output current. */ + uint32_t status; /* Regulator status, which can be on or off. */ + int useCount; + int consumerRegNums; /* Number of regulator consumers. */ + RegulatorStatusChangecb cb; /* Variable used to notify the regulator status changes. */ + }; + + struct RegulatorConstraints { + uint8_t alwaysOn; /* Whether the regulator is always on. */ + uint8_t mode; /* Voltage or current. */ + uint32_t minUv; /* Minimum output voltage allowed. */ + uint32_t maxUv; /* Maximum output voltage allowed. */ + uint32_t minUa; /* Minimum output current allowed. */ + uint32_t maxUa; /* Maximum output current allowed. */ + }; + ``` + + + + - Instantiating **RegulatorMethod** (other members are initialized by **Init**) + + ```c + // Example of regulator_virtual.c: Instantiate the hooks. + static struct RegulatorMethod g_method = { + .enable = VirtualRegulatorEnable, + .disable = VirtualRegulatorDisable, + .setVoltage = VirtualRegulatorSetVoltage, + .getVoltage = VirtualRegulatorGetVoltage, + .setCurrent = VirtualRegulatorSetCurrent, + .getCurrent = VirtualRegulatorGetCurrent, + .getStatus = VirtualRegulatorGetStatus, + }; + ``` + + + + - **Init** function + + Input parameter: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information. - - - Instantiating **RegulatorMethod** (other members are initialized by **Init**) - + Return value: + + **HDF\_STATUS** + + The table below lists some states. For more details, see **HDF\_STATUS** in **/drivers/framework/include/utils/hdf\_base.h**. + + **Table 2** HDF_STATUS + + | State | 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 and **RegulatorNode** members, and adds the regulator controller by calling the **RegulatorNodeAdd** function at the core layer. + + ```c - // Example of regulator_virtual.c: Instantiate the hook. - static struct RegulatorMethod g_method = { - .enable = VirtualRegulatorEnable, - .disable = VirtualRegulatorDisable, - .setVoltage = VirtualRegulatorSetVoltage, - .getVoltage = VirtualRegulatorGetVoltage, - .setCurrent = VirtualRegulatorSetCurrent, - .getCurrent = VirtualRegulatorGetCurrent, - .getStatus = VirtualRegulatorGetStatus, - }; + static int32_t VirtualRegulatorInit(struct HdfDeviceObject *device) + { + int32_t ret; + const struct DeviceResourceNode *childNode = NULL; + ... + DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { + ret = VirtualRegulatorParseAndInit(device, childNode);// (Mandatory) The implementation is as follows: + ... + } + ... + } + + static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node) + { + int32_t ret; + struct RegulatorNode *regNode = NULL; + (void)device; + + regNode = (struct RegulatorNode *)OsalMemCalloc(sizeof(*regNode));// Load the .hcs file. + ... + ret = VirtualRegulatorReadHcs(regNode, node);// Read .hcs information. + ... + regNode->priv = (void *)node; // Instantiate the node. + regNode->ops = &g_method; // Instantiate OPS. + + ret = RegulatorNodeAdd(regNode); // Add the node. + ... + } ``` - - - - - **Init** function - - Input parameters: - - **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. + + - **Release** function - Return value: + Input parameter: - **HDF\_STATUS** (The following table lists some states. For more details, see **HDF\_STATUS** in **/drivers/framework/include/utils/hdf\_base.h**.) + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information. - **Table 2** HDF\_STATUS - - | State | 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 and **RegulatorNode** members, and adds the regulator controller by calling the **RegulatorNodeAdd** function at the core layer. - - + Return value: + + No value is return. + + 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. + ```c - static int32_t VirtualRegulatorInit(struct HdfDeviceObject *device) + static void VirtualRegulatorRelease(struct HdfDeviceObject *device) { - int32_t ret; - const struct DeviceResourceNode *childNode = NULL; - ... - DEV_RES_NODE_FOR_EACH_CHILD_NODE(device->property, childNode) { - ret = VirtualRegulatorParseAndInit(device, childNode);// (Mandatory) The implementation is as follows: - ... - } - ... - } - - static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, const struct DeviceResourceNode *node) - { - int32_t ret; - struct RegulatorNode *regNode = NULL; - (void)device; - - regNode = (struct RegulatorNode *)OsalMemCalloc(sizeof(*regNode));// Load the .hcs file. - ... - ret = VirtualRegulatorReadHcs(regNode, node);// Read .hcs information. - ... - regNode->priv = (void *)node; // Instantiate the node. - regNode->ops = &g_method; // Instantiate OPS. - - ret = RegulatorNodeAdd(regNode); // Add the node. ... + RegulatorNodeRemoveAll();// (Mandatory) Call the function at the core layer to release regulator controller devices and services. } ``` - - - **Release** function - - Input parameters: - - **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration. - - Return value: - - – - - Function description: - - Releases memory and deletes the controller. This function assigns a value to the **Release** API 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. - - ```c - static void VirtualRegulatorRelease(struct HdfDeviceObject *device) - { - ... - RegulatorNodeRemoveAll();// (Mandatory) Call the function at the core layer to release regulator controller devices and services. - } - ``` - -4. (Optional) Debug the driver. - Verify the basic functions of the new driver, for example, whether the test cases are successful after the driver is loaded. \ No newline at end of file +4. Debug the driver. + + (Optional) Verify the basic functions of the new driver, for example, check whether the test cases are successful after the driver is loaded. + + diff --git a/en/device-dev/driver/driver-platform-spi-des.md b/en/device-dev/driver/driver-platform-spi-des.md index 066b92ea231bf86f8a0b2688b1119ef3bd832f84..696087ee948f1d8ac9747942551c1a166fd7cabd 100644 --- a/en/device-dev/driver/driver-platform-spi-des.md +++ b/en/device-dev/driver/driver-platform-spi-des.md @@ -1,160 +1,101 @@ -# SPI<a name="EN-US_TOPIC_0000001206171293"></a> +# SPI -## Overview<a name="section193356154511"></a> -Serial Peripheral Interface \(SPI\) is a serial bus specification used for high-speed, full-duplex, and synchronous communication. -SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital \(A/D\) converters. +## **Overview** + +Serial Peripheral Interface (SPI) is a serial bus specification used for high-speed, full-duplex, and synchronous communication. SPI is developed by Motorola. It is commonly used for communication with flash memory, real-time clocks, sensors, and analog-to-digital (A/D) converters. + SPI works in controller/device mode. Generally, there is one SPI controller that controls one or more SPI devices. They are connected via four wires: -- SCLK: clock signals output from the SPI controller -- MOSI: data output from the SPI controller and input into an SPI device -- MISO: data output from an SPI device and input into the SPI controller -- CS: signals enabled by an SPI device and controlled by the SPI controller - - -[Figure 1](#fig89085710359) shows the connection between one SPI controller and two SPI devices \(device A and device B\). In this figure, device A and device B share three pins \(SCLK, MISO, and MOSI\) of the controller. CS0 of device A and CS1 of device B are connected to CS0 and CS1 of the controller, respectively. - -**Figure 1** SPI controller/device connection<a name="fig89085710359"></a> - - -SPI communication is usually initiated by the SPI controller and is operated as follows: - -1. A single SPI device is selected at a time via the CS to communicate with the SPI controller. -2. Clock signals are provided for the selected SPI device via the SCLK. -3. The SPI controller sends data to SPI devices via the MOSI, and receives data from SPI devices via the MISO. - -- SPI can work in one of the following four modes, equivalent to one of the four possible states for Clock Polarity \(CPOL\) and Clock Phase \(CPHA\): - - If both CPOL and CPHA are **0**, the clock signal level is low in the idle state and data is sampled on the first clock edge. - - If CPOL is **0** and CPHA is **1**, the clock signal level is low in the idle state and data is sampled on the second clock edge. - - If CPOL is **1** and CPHA is **0**, the clock signal level is high in the idle state and data is sampled on the first clock edge. - - If both CPOL and CPHA are **1**, the clock signal level is high in the idle state and data is sampled on the second clock edge. - - -- SPI defines a set of common functions for operating an SPI device, including those for: - - Obtaining and releasing the handle of an SPI device. - - Reading or writing data of a specified length from or into an SPI device. - - Customizing data reading or writing via **SpiMsg**. - - Obtaining and setting SPI device configuration parameters. - - -> **NOTE**<br> ->Currently, these functions are only applicable in the communication initiated by the SPI controller. - -## Available APIs<a name="section1325964832615"></a> - -**Table 1** APIs for the SPI driver - -<a name="table1731550155318"></a> -<table><thead align="left"><tr id="row4419501537"><th class="cellrowborder" align="left" valign="top" width="20.857914208579142%" id="mcps1.2.4.1.1"><p id="p641050105320"><a name="p641050105320"></a><a name="p641050105320"></a><strong id="b17365506414"><a name="b17365506414"></a><a name="b17365506414"></a>Capability</strong></p> -</th> -<th class="cellrowborder" align="left" valign="top" width="23.36766323367663%" id="mcps1.2.4.1.2"><p id="p54150165315"><a name="p54150165315"></a><a name="p54150165315"></a><strong id="b191701618154210"><a name="b191701618154210"></a><a name="b191701618154210"></a>Function</strong></p> -</th> -<th class="cellrowborder" align="left" valign="top" width="55.77442255774422%" id="mcps1.2.4.1.3"><p id="p941150145313"><a name="p941150145313"></a><a name="p941150145313"></a><strong id="b64281840104214"><a name="b64281840104214"></a><a name="b64281840104214"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row1651292212306"><td class="cellrowborder" rowspan="2" valign="top" width="20.857914208579142%" headers="mcps1.2.4.1.1 "><p id="p1387414255305"><a name="p1387414255305"></a><a name="p1387414255305"></a>SPI device handle obtaining/releasing</p> -</td> -<td class="cellrowborder" valign="top" width="23.36766323367663%" headers="mcps1.2.4.1.2 "><p id="p8874825143014"><a name="p8874825143014"></a><a name="p8874825143014"></a>SpiOpen</p> -</td> -<td class="cellrowborder" valign="top" width="55.77442255774422%" headers="mcps1.2.4.1.3 "><p id="p1087432513307"><a name="p1087432513307"></a><a name="p1087432513307"></a>Obtains an SPI device handle.</p> -</td> -</tr> -<tr id="row1429083612305"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1956614106311"><a name="p1956614106311"></a><a name="p1956614106311"></a>SpiClose</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p829111362306"><a name="p829111362306"></a><a name="p829111362306"></a>Releases an SPI device handle.</p> -</td> -</tr> -<tr id="row34145016535"><td class="cellrowborder" rowspan="3" valign="top" width="20.857914208579142%" headers="mcps1.2.4.1.1 "><p id="p229610227124"><a name="p229610227124"></a><a name="p229610227124"></a>SPI reading/writing</p> -</td> -<td class="cellrowborder" valign="top" width="23.36766323367663%" headers="mcps1.2.4.1.2 "><p id="p19389143041518"><a name="p19389143041518"></a><a name="p19389143041518"></a>SpiRead</p> -</td> -<td class="cellrowborder" valign="top" width="55.77442255774422%" headers="mcps1.2.4.1.3 "><p id="p8738101941716"><a name="p8738101941716"></a><a name="p8738101941716"></a>Reads data of a specified length from an SPI device.</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>SpiWrite</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 data of a specified length into an SPI device.</p> -</td> -</tr> -<tr id="row1766145611414"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p183904373018"><a name="p183904373018"></a><a name="p183904373018"></a>SpiTransfer</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1639011313303"><a name="p1639011313303"></a><a name="p1639011313303"></a>Transfers SPI data.</p> -</td> -</tr> -<tr id="row1020919129159"><td class="cellrowborder" rowspan="2" valign="top" width="20.857914208579142%" headers="mcps1.2.4.1.1 "><p id="p82092126154"><a name="p82092126154"></a><a name="p82092126154"></a>SPI device configuration</p> -<p id="p6794153701111"><a name="p6794153701111"></a><a name="p6794153701111"></a></p> -</td> -<td class="cellrowborder" valign="top" width="23.36766323367663%" headers="mcps1.2.4.1.2 "><p id="p1739013012154"><a name="p1739013012154"></a><a name="p1739013012154"></a>SpiSetCfg</p> -</td> -<td class="cellrowborder" valign="top" width="55.77442255774422%" headers="mcps1.2.4.1.3 "><p id="p073910197173"><a name="p073910197173"></a><a name="p073910197173"></a>Sets configuration parameters for an SPI device.</p> -</td> -</tr> -<tr id="row379443710118"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4333154919111"><a name="p4333154919111"></a><a name="p4333154919111"></a>SpiGetCfg</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11333649171117"><a name="p11333649171117"></a><a name="p11333649171117"></a>Obtains configuration parameters of an SPI device.</p> -</td> -</tr> -</tbody> -</table> - -> **NOTE:** ->All functions provided in this document can be called only in kernel space. - -## Usage Guidelines<a name="section71363452477"></a> - -### How to Use<a name="section32846814820"></a> - -The figure below illustrates how to use the APIs. - -**Figure 2** Using SPI driver APIs<a name="fig1586912310348"></a> - - -### Obtaining an SPI Device Handle<a name="section1927265711481"></a> - -Before performing SPI communication, obtain an SPI device handle by calling **SpiOpen**. This function returns an SPI device handle with a specified bus number and CS number. - -DevHandle SpiOpen\(const struct SpiDevInfo \*info\); - -**Table 2** Description of SpiOpen - -<a name="table7603619123820"></a> -<table><tbody><tr id="row1060351914386"><td class="cellrowborder" valign="top" width="50%"><p id="p14603181917382"><a name="p14603181917382"></a><a name="p14603181917382"></a><strong id="b139290298482"><a name="b139290298482"></a><a name="b139290298482"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p36031519183819"><a name="p36031519183819"></a><a name="p36031519183819"></a><strong id="b17557183010484"><a name="b17557183010484"></a><a name="b17557183010484"></a>Description</strong></p> -</td> -</tr> -<tr id="row1960431983813"><td class="cellrowborder" valign="top" width="50%"><p id="p3604719123817"><a name="p3604719123817"></a><a name="p3604719123817"></a>info</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1560441923818"><a name="p1560441923818"></a><a name="p1560441923818"></a>Pointer to the SPI device descriptor.</p> -</td> -</tr> -<tr id="row380484160"><td class="cellrowborder" valign="top" width="50%"><p id="p460381915385"><a name="p460381915385"></a><a name="p460381915385"></a><strong id="b1431414320486"><a name="b1431414320486"></a><a name="b1431414320486"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p96031619153812"><a name="p96031619153812"></a><a name="p96031619153812"></a><strong id="b164533311485"><a name="b164533311485"></a><a name="b164533311485"></a>Description</strong></p> -</td> -</tr> -<tr id="row5793818161"><td class="cellrowborder" valign="top" width="50%"><p id="p1060418195389"><a name="p1060418195389"></a><a name="p1060418195389"></a>NULL</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p760471912388"><a name="p760471912388"></a><a name="p760471912388"></a>Failed to obtain an SPI device handle.</p> -</td> -</tr> -<tr id="row187914871618"><td class="cellrowborder" valign="top" width="50%"><p id="p5604719133811"><a name="p5604719133811"></a><a name="p5604719133811"></a>Device handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p3604181933818"><a name="p3604181933818"></a><a name="p3604181933818"></a>Returns the pointer to the SPI device handle.</p> -</td> -</tr> -</tbody> -</table> - -The following example shows how to obtain an SPI device handle based on the assumption that both the bus number and CS number of the SPI device are **0**. + - SCLK: clock signal output from the SPI controller + - MOSI: data output from the SPI controller to a device + - MISO: data output from an SPI device to the controller + - Chip select (CS): output from the SPI controller to indicate that data is being sent. It is controlled by the SPI controller. + +The figure below shows the connection between one controller and two devices (device A and device B). Device A and device B share three pins (SCLK, MISO, and MOSI) of the controller. CS 0 of device A and CS 1 of device B are connected to CS 0 and CS 1 of the controller, respectively. + + **Figure 1** Connection between the SPI controller and devices + +  + +- SPI communication is usually initiated by the controller and is performed as follows: + 1. The SPI controller selects a device to communicate on the select line. Only one device can be selected at a time. + 2. SCLK provides clock signals to the selected device. + 3. The SPI controller sends data to the device via MOSI, and receives data from the devices via MISO. + +- SPI can work in one of the following modes according to the combination of Clock Polarity (CPOL) and Clock Phase (CPHA) of the clock signal: + - If both CPOL and CPHA are **0**, the clock signal level is low in the idle state and data is sampled on the first clock edge. + - If CPOL is **0** and CPHA is **1**, the clock signal level is low in the idle state and data is sampled on the second clock edge. + - If CPOL is **1** and CPHA is **0**, the clock signal level is high in the idle state and data is sampled on the first clock edge. + - If both CPOL and CPHA are **1**, the clock signal level is high in the idle state and data is sampled on the second clock edge. + +- SPI defines a set of common functions for operating an SPI device, including those for: + - Obtaining and releasing an SPI device handle. + - Reading or writing data of the specified length from or into an SPI device. + - Customizing data reading or writing via **SpiMsg**. + - Obtaining and setting SPI device attributes. + +>  **NOTE**<br> +> Currently, these functions are only applicable in the communication initiated by the SPI controller. + + +## **Available APIs** + + **Table 1** SPI driver APIs + +| API| Description| +| -------- | -------- | +| SpiOpen | Opens an SPI device handle.| +| SpiClose | Closes an SPI device handle.| +| SpiRead | Reads data of the specified length from a device.| +| SpiWrite | Writes data of the specified length to a device.| +| SpiTransfer | Transfers SPI data.| +| SpiSetCfg | Sets SPI device attributes.| +| SpiGetCfg | Obtains SPI device attributes.| + +>  **NOTE**<br> +> All APIs described in this document can be called only in kernel mode. + + +## Usage Guidelines + + +### How to Use + +The figure below shows the general process of using SPI. + + **Figure 2** Process of using SPI APIs + +  + + +### Opening an SPI Device Handle +Before performing SPI communication, call **SpiOpen** to open the SPI device handle. This function returns the device handle of the SPI based on the specified bus number and CS number. + + +``` +DevHandle SpiOpen(const struct SpiDevInfo *info); ``` -struct SpiDevInfo spiDevinfo; /* SPI device descriptor */ -DevHandle spiHandle = NULL; /* SPI device handle */ -spiDevinfo.busNum = 0; /* SPI device bus number */ -spiDevinfo.csNum = 0; /* SPI device CS number */ -/* Obtain an SPI device handle. */ + **Table 2** Description of SpiOpen + +| **Parameter**| **Description**| +| -------- | -------- | +| info | Pointer to the SPI device descriptor.| +| **Return Value**| **Description**| +| NULL | The operation failed.| +| Device handle| The operation is successful. The SPI device handle obtained is returned.| + +For example, open the handle of the SPI device, whose bus number and the CS number are both **0**. + + +``` +struct SpiDevInfo spiDevinfo; /* SPI device descriptor. */ +DevHandle spiHandle = NULL; /* SPI device handle */ +spiDevinfo.busNum = 0; /* SPI device bus number. */ +spiDevinfo.csNum = 0; /* SPI device CS number. */ + +/* Obtain the SPI device handle. */ spiHandle = SpiOpen(&spiDevinfo); if (spiHandle == NULL) { HDF_LOGE("SpiOpen: failed\n"); @@ -162,324 +103,201 @@ if (spiHandle == NULL) { } ``` -### Obtaining SPI Device Configuration Parameters<a name="section541133418493"></a> - -After obtaining the SPI device handle, obtain the SPI device configuration parameters by calling the following function: - -int32\_t SpiGetCfg\(DevHandle handle, struct SpiCfg \*cfg\); - -**Table 3** Description of SpiGetCfg - -<a name="table14209152141313"></a> -<table><tbody><tr id="row1420918529133"><td class="cellrowborder" valign="top" width="50%"><p id="p42091852141314"><a name="p42091852141314"></a><a name="p42091852141314"></a><strong id="b6279123012486"><a name="b6279123012486"></a><a name="b6279123012486"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p202099523137"><a name="p202099523137"></a><a name="p202099523137"></a><strong id="b18243194818"><a name="b18243194818"></a><a name="b18243194818"></a>Description</strong></p> -</td> -</tr> -<tr id="row142091352171310"><td class="cellrowborder" valign="top" width="50%"><p id="p1520915529131"><a name="p1520915529131"></a><a name="p1520915529131"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p720995291310"><a name="p720995291310"></a><a name="p720995291310"></a>SPI device handle.</p> -</td> -</tr> -<tr id="row6209152161314"><td class="cellrowborder" valign="top" width="50%"><p id="p720916522139"><a name="p720916522139"></a><a name="p720916522139"></a>cfg</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p172091452131319"><a name="p172091452131319"></a><a name="p172091452131319"></a>Pointer to SPI device configuration parameters.</p> -</td> -</tr> -<tr id="row12092522139"><td class="cellrowborder" valign="top" width="50%"><p id="p18209125211134"><a name="p18209125211134"></a><a name="p18209125211134"></a><strong id="b16646173219483"><a name="b16646173219483"></a><a name="b16646173219483"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p420975231318"><a name="p420975231318"></a><a name="p420975231318"></a><strong id="b184316334486"><a name="b184316334486"></a><a name="b184316334486"></a>Description</strong></p> -</td> -</tr> -<tr id="row8209155251310"><td class="cellrowborder" valign="top" width="50%"><p id="p13210145291312"><a name="p13210145291312"></a><a name="p13210145291312"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p152101952141315"><a name="p152101952141315"></a><a name="p152101952141315"></a>Succeeded in obtaining SPI device configuration parameters.</p> -</td> -</tr> -<tr id="row102101452121320"><td class="cellrowborder" valign="top" width="50%"><p id="p10210175219134"><a name="p10210175219134"></a><a name="p10210175219134"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p72101252101312"><a name="p72101252101312"></a><a name="p72101252101312"></a>Failed to obtain SPI device configuration parameters.</p> -</td> -</tr> -</tbody> -</table> -``` -int32_t ret; -struct SpiCfg cfg = {0}; /* SPI configuration information */ -ret = SpiGetCfg(spiHandle, &cfg); /* Obtain SPI device configuration parameters. */ -if (ret != 0) { - HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret); -} -``` +### Obtaining SPI Device Attributes + +After obtaining the SPI device handle, you need to configure the device attributes. Before configuring the device attributes, you can call **SpiGetCfg** to obtain the device attributes. -### Setting SPI Device Configuration Parameters<a name="section7870106145010"></a> - -After obtaining the SPI device handle, set SPI device configuration parameters by calling the following function: - -int32\_t SpiSetCfg\(DevHandle handle, struct SpiCfg \*cfg\); - -**Table 4** Description of SpiSetCfg - -<a name="table219052945210"></a> -<table><tbody><tr id="row14191192918522"><td class="cellrowborder" valign="top" width="50%"><p id="p17424155016529"><a name="p17424155016529"></a><a name="p17424155016529"></a><strong id="b11281163011480"><a name="b11281163011480"></a><a name="b11281163011480"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p942512508520"><a name="p942512508520"></a><a name="p942512508520"></a><strong id="b1330312487"><a name="b1330312487"></a><a name="b1330312487"></a>Description</strong></p> -</td> -</tr> -<tr id="row219152915524"><td class="cellrowborder" valign="top" width="50%"><p id="p2191122985218"><a name="p2191122985218"></a><a name="p2191122985218"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1519162913524"><a name="p1519162913524"></a><a name="p1519162913524"></a>SPI device handle.</p> -</td> -</tr> -<tr id="row1719110297526"><td class="cellrowborder" valign="top" width="50%"><p id="p181911292523"><a name="p181911292523"></a><a name="p181911292523"></a>cfg</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p91911729155216"><a name="p91911729155216"></a><a name="p91911729155216"></a>Pointer to SPI device configuration parameters.</p> -</td> -</tr> -<tr id="row036524131716"><td class="cellrowborder" valign="top" width="50%"><p id="p6425165035214"><a name="p6425165035214"></a><a name="p6425165035214"></a><strong id="b96476326489"><a name="b96476326489"></a><a name="b96476326489"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p18425650165215"><a name="p18425650165215"></a><a name="p18425650165215"></a><strong id="b17432193311481"><a name="b17432193311481"></a><a name="b17432193311481"></a>Description</strong></p> -</td> -</tr> -<tr id="row43653411178"><td class="cellrowborder" valign="top" width="50%"><p id="p1319132918520"><a name="p1319132918520"></a><a name="p1319132918520"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1719117292522"><a name="p1719117292522"></a><a name="p1719117292522"></a>Succeeded in setting SPI device configuration parameters.</p> -</td> -</tr> -<tr id="row536594171715"><td class="cellrowborder" valign="top" width="50%"><p id="p719119296522"><a name="p719119296522"></a><a name="p719119296522"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p20191192925212"><a name="p20191192925212"></a><a name="p20191192925212"></a>Failed to set SPI device configuration parameters.</p> -</td> -</tr> -</tbody> -</table> ``` -int32_t ret; -struct SpiCfg cfg = {0}; /* SPI configuration information */ -cfg.mode = SPI_MODE_LOOP; /* Communication in loopback mode */ -cfg.transferMode = PAL_SPI_POLLING_TRANSFER; /* Communication in polling mode */ -cfg.maxSpeedHz = 115200; /* Maximum transmission frequency */ -cfg.bitsPerWord = 8; /* The width of per word to be read or written is 8 bits. */ -ret = SpiSetCfg(spiHandle, &cfg); /* Set SPI device configuration parameters. */ -if (ret != 0) { - HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret); -} +int32_t SpiGetCfg(DevHandle handle, struct SpiCfg *cfg); ``` -### Performing SPI Communication<a name="section13324155195013"></a> - -- Writing data of a specific length into an SPI device - -To write data into an SPI device only once, call the following function: - -int32\_t SpiWrite\(DevHandle handle, uint8\_t \*buf, uint32\_t len\); - -**Table 5** Description of SpiWrite - -<a name="table1018490043"></a> -<table><tbody><tr id="row31848013417"><td class="cellrowborder" valign="top" width="50%"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b42810303484"><a name="b42810303484"></a><a name="b42810303484"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p11158111316410"><a name="p11158111316410"></a><a name="p11158111316410"></a><strong id="b03103112484"><a name="b03103112484"></a><a name="b03103112484"></a>Description</strong></p> -</td> -</tr> -<tr id="row10184701945"><td class="cellrowborder" valign="top" width="50%"><p id="p104891871157"><a name="p104891871157"></a><a name="p104891871157"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p204891671156"><a name="p204891671156"></a><a name="p204891671156"></a>SPI device handle.</p> -</td> -</tr> -<tr id="row928111518418"><td class="cellrowborder" valign="top" width="50%"><p id="p4282955412"><a name="p4282955412"></a><a name="p4282955412"></a>buf</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p7282752412"><a name="p7282752412"></a><a name="p7282752412"></a>Pointer to the data to write.</p> -</td> -</tr> -<tr id="row149041113651"><td class="cellrowborder" valign="top" width="50%"><p id="p139051213357"><a name="p139051213357"></a><a name="p139051213357"></a>len</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p16905313854"><a name="p16905313854"></a><a name="p16905313854"></a>Length of the data to write.</p> -</td> -</tr> -<tr id="row1148818622017"><td class="cellrowborder" valign="top" width="50%"><p id="p8158313248"><a name="p8158313248"></a><a name="p8158313248"></a><strong id="b9649732154818"><a name="b9649732154818"></a><a name="b9649732154818"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p161591413741"><a name="p161591413741"></a><a name="p161591413741"></a><strong id="b12433113344813"><a name="b12433113344813"></a><a name="b12433113344813"></a>Description</strong></p> -</td> -</tr> -<tr id="row14488762202"><td class="cellrowborder" valign="top" width="50%"><p id="p103191916578"><a name="p103191916578"></a><a name="p103191916578"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1231981611712"><a name="p1231981611712"></a><a name="p1231981611712"></a>Succeeded in writing data into an SPI device.</p> -</td> -</tr> -<tr id="row164881464201"><td class="cellrowborder" valign="top" width="50%"><p id="p531916166716"><a name="p531916166716"></a><a name="p531916166716"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p93191161174"><a name="p93191161174"></a><a name="p93191161174"></a>Failed to write data into an SPI device.</p> -</td> -</tr> -</tbody> -</table> + **Table 3** Description of SpiGetCfg + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| +| cfg | Pointer to the SPI device attributes.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value | The operation failed.| + ``` int32_t ret; -uint8_t wbuff[4] = {0x12, 0x34, 0x56, 0x78}; -/* Write data of a specific length into an SPI device. */ -ret = SpiWrite(spiHandle, wbuff, 4); +struct SpiCfg cfg = {0}; /* SPI configuration. */ +ret = SpiGetCfg(spiHandle, &cfg); /* Obtain SPI device attributes. */ if (ret != 0) { - HDF_LOGE("SpiWrite: failed, ret %d\n", ret); + HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret); } ``` -- Reading data of a specific length from an SPI device - -To read data from an SPI device only once, call the following function: - -int32\_t SpiRead\(DevHandle handle, uint8\_t \*buf, uint32\_t len\); - -**Table 6** Description of SpiRead - -<a name="table0265191412124"></a> -<table><tbody><tr id="row42651914141213"><td class="cellrowborder" valign="top" width="50%"><p id="p1483184123"><a name="p1483184123"></a><a name="p1483184123"></a><strong id="b528223019480"><a name="b528223019480"></a><a name="b528223019480"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p9831871216"><a name="p9831871216"></a><a name="p9831871216"></a><strong id="b3416318489"><a name="b3416318489"></a><a name="b3416318489"></a>Description</strong></p> -</td> -</tr> -<tr id="row1926651415123"><td class="cellrowborder" valign="top" width="50%"><p id="p389183129"><a name="p389183129"></a><a name="p389183129"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p168151817124"><a name="p168151817124"></a><a name="p168151817124"></a>SPI device handle.</p> -</td> -</tr> -<tr id="row202661414201220"><td class="cellrowborder" valign="top" width="50%"><p id="p158161821210"><a name="p158161821210"></a><a name="p158161821210"></a>buf</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p98131811126"><a name="p98131811126"></a><a name="p98131811126"></a>Pointer to the data to read.</p> -</td> -</tr> -<tr id="row1926621451212"><td class="cellrowborder" valign="top" width="50%"><p id="p2918182124"><a name="p2918182124"></a><a name="p2918182124"></a>len</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p169718191220"><a name="p169718191220"></a><a name="p169718191220"></a>Length of the data to read.</p> -</td> -</tr> -<tr id="row05841310206"><td class="cellrowborder" valign="top" width="50%"><p id="p38171818128"><a name="p38171818128"></a><a name="p38171818128"></a><strong id="b1364973254814"><a name="b1364973254814"></a><a name="b1364973254814"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p881918161220"><a name="p881918161220"></a><a name="p881918161220"></a><strong id="b04341333484"><a name="b04341333484"></a><a name="b04341333484"></a>Description</strong></p> -</td> -</tr> -<tr id="row15584173192016"><td class="cellrowborder" valign="top" width="50%"><p id="p14871820128"><a name="p14871820128"></a><a name="p14871820128"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p88118101211"><a name="p88118101211"></a><a name="p88118101211"></a>Succeeded in reading data from an SPI device.</p> -</td> -</tr> -<tr id="row1058418317204"><td class="cellrowborder" valign="top" width="50%"><p id="p10841817125"><a name="p10841817125"></a><a name="p10841817125"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p986183127"><a name="p986183127"></a><a name="p986183127"></a>Failed to read data from an SPI device.</p> -</td> -</tr> -</tbody> -</table> + +### Setting SPI Device Attributes + +After obtaining the SPI device handle, call **SpiSetCfg** to set SPI device attributes. + ``` -int32_t ret; -uint8_t rbuff[4] = {0}; -/* Read data of a specific length from an SPI device. */ -ret = SpiRead(spiHandle, rbuff, 4); -if (ret != 0) { - HDF_LOGE("SpiRead: failed, ret %d\n", ret); -} +int32_t SpiSetCfg(DevHandle handle, struct SpiCfg *cfg); ``` -- Launching a custom transfer - -To launch a custom transfer, call the following function: - -int32\_t SpiTransfer\(DevHandle handle, struct SpiMsg \*msgs, uint32\_t count\); - -**Table 7** Description of SpiTransfer - -<a name="table1934414174212"></a> -<table><tbody><tr id="row1134415176216"><td class="cellrowborder" valign="top" width="50%"><p id="p13295152320217"><a name="p13295152320217"></a><a name="p13295152320217"></a><strong id="b1628393012482"><a name="b1628393012482"></a><a name="b1628393012482"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1295112352115"><a name="p1295112352115"></a><a name="p1295112352115"></a><strong id="b175931204814"><a name="b175931204814"></a><a name="b175931204814"></a>Description</strong></p> -</td> -</tr> -<tr id="row5344101702113"><td class="cellrowborder" valign="top" width="50%"><p id="p19295132382111"><a name="p19295132382111"></a><a name="p19295132382111"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p829510232213"><a name="p829510232213"></a><a name="p829510232213"></a>SPI device handle.</p> -</td> -</tr> -<tr id="row17344171722117"><td class="cellrowborder" valign="top" width="50%"><p id="p9295122332113"><a name="p9295122332113"></a><a name="p9295122332113"></a>msgs</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p202951238218"><a name="p202951238218"></a><a name="p202951238218"></a>Pointer to the message array to be transferred.</p> -</td> -</tr> -<tr id="row45812466213"><td class="cellrowborder" valign="top" width="50%"><p id="p1659246112117"><a name="p1659246112117"></a><a name="p1659246112117"></a>count</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p259124622119"><a name="p259124622119"></a><a name="p259124622119"></a>Number of messages in the message array.</p> -</td> -</tr> -<tr id="row45187318214"><td class="cellrowborder" valign="top" width="50%"><p id="p17295142322113"><a name="p17295142322113"></a><a name="p17295142322113"></a><strong id="b5650532164818"><a name="b5650532164818"></a><a name="b5650532164818"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p142959232211"><a name="p142959232211"></a><a name="p142959232211"></a><strong id="b84349335480"><a name="b84349335480"></a><a name="b84349335480"></a>Description</strong></p> -</td> -</tr> -<tr id="row175186313217"><td class="cellrowborder" valign="top" width="50%"><p id="p929532313211"><a name="p929532313211"></a><a name="p929532313211"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p829512237217"><a name="p829512237217"></a><a name="p829512237217"></a>Succeeded in launching the custom transfer.</p> -</td> -</tr> -<tr id="row1451803152114"><td class="cellrowborder" valign="top" width="50%"><p id="p12958234217"><a name="p12958234217"></a><a name="p12958234217"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p1295192312112"><a name="p1295192312112"></a><a name="p1295192312112"></a>Failed to launch the custom transfer.</p> -</td> -</tr> -</tbody> -</table> + **Table 4** Description of SpiSetCfg + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| +| cfg | Pointer to the SPI device attributes.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value | The operation failed.| + ``` int32_t ret; -uint8_t wbuff[1] = {0x12}; -uint8_t rbuff[1] = {0}; -struct SpiMsg msg; /* Custom message to be transferred */ -msg.wbuf = wbuff; /* Pointer to the data to write */ -msg.rbuf = rbuff; /* Pointer to the data to read */ -msg.len = 1; /* The length of the data to read or write is 1 bit. */ -msg.csChange = 1; /* Disable the CS before the next transfer. */ -msg.delayUs = 0; /* No delay before the next transfer */ -msg.speed = 115200; /* Speed of this transfer */ -/* Launch a custom transfer. The number of messages to be transferred is 1. */ -ret = SpiTransfer(spiHandle, &msg, 1); +struct SpiCfg cfg = {0}; /* SPI configuration. */ +cfg.mode = SPI_MODE_LOOP; /* Communicate in loop mode. */ +cfg.transferMode = PAL_SPI_POLLING_TRANSFER; /* Communicate in polling mode. */ +cfg.maxSpeedHz = 115200; /* Maximum transfer frequency. */ +cfg.bitsPerWord = 8; /* The width of per word to be read or written is 8 bits. */ +ret = SpiSetCfg(spiHandle, &cfg); /* Set SPI device attributes. */ if (ret != 0) { - HDF_LOGE("SpiTransfer: failed, ret %d\n", ret); + HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret); } ``` -### Destroying the SPI Device Handle<a name="section19661632135117"></a> -After the SPI communication, destroy the SPI device handle by calling the following function: +### Performing SPI Communication + +- Write data to an SPI device + + Call **SpiWrite()** to write data to an SPI device only once. + + + ``` + int32_t SpiWrite(DevHandle handle, uint8_t *buf, uint32_t len); + ``` + + **Table 5** Description of SpiWrite + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| +| buf | Pointer to the data to write.| +| len | Length of the data to write.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value | The operation failed.| + + + ``` + int32_t ret; + uint8_t wbuff[4] = {0x12, 0x34, 0x56, 0x78}; + /* Write data of the specified length to an SPI device. */ + ret = SpiWrite(spiHandle, wbuff, 4); + if (ret != 0) { + HDF_LOGE("SpiWrite: failed, ret %d\n", ret); + } + ``` + +- Read data from an SPI device + + Call **SpiRead()** to read data from an SPI device only once. + -void SpiClose\(DevHandle handle\); + ``` + int32_t SpiRead(DevHandle handle, uint8_t *buf, uint32_t len); + ``` -This function will release the resources previously obtained. + **Table 6** Description of SpiRead -**Table 8** Description of SpiClose +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| +| buf | Pointer to the data to read.| +| len | Length of the data to read.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + + + ``` + int32_t ret; + uint8_t rbuff[4] = {0}; + /* Read data of the specified length from an SPI device. */ + ret = SpiRead(spiHandle, rbuff, 4); + if (ret != 0) { + HDF_LOGE("SpiRead: failed, ret %d\n", ret); + } + ``` + +- Perform a custom transfer + + Call **SpiTransfer()** to perform a custom transfer. + + + ``` + int32_t SpiTransfer(DevHandle handle, struct SpiMsg *msgs, uint32_t count); + ``` + + **Table 7** Description of SpiTransfer + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| +| msgs | Pointer to the message array to be transferred.| +| count | Number of messages in the message array.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + + + ``` + int32_t ret; + uint8_t wbuff[1] = {0x12}; + uint8_t rbuff[1] = {0}; + struct SpiMsg msg; /* Custom message to be transferred. */ + msg.wbuf = wbuff; /* Data to write. */ + msg.rbuf = rbuff; /* Data to read. */ + msg.len = 1; /* The length of the data to read or write is 1 bit. */ + msg.csChange = 1; /* Close the CS before the next transfer. */ + msg.delayUs = 0; /* No delay before the next transfer. */ + msg.speed = 115200; /* Transfer speed. */ + /* Perform a custom transfer. The number of messages to be transferred is 1. */ + ret = SpiTransfer(spiHandle, &msg, 1); + if (ret != 0) { + HDF_LOGE("SpiTransfer: failed, ret %d\n", ret); + } + ``` + + +### Closing an SPI Device Handle + +After the SPI communication, call **SpiClose()** to close the SPI device handle. -<a name="table72517953115"></a> -<table><tbody><tr id="row1525793312"><td class="cellrowborder" valign="top" width="50%"><p id="p115402031153111"><a name="p115402031153111"></a><a name="p115402031153111"></a><strong id="b1728493044820"><a name="b1728493044820"></a><a name="b1728493044820"></a>Parameter</strong></p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p65406313319"><a name="p65406313319"></a><a name="p65406313319"></a><strong id="b176133134814"><a name="b176133134814"></a><a name="b176133134814"></a>Description</strong></p> -</td> -</tr> -<tr id="row1926109193116"><td class="cellrowborder" valign="top" width="50%"><p id="p105419317318"><a name="p105419317318"></a><a name="p105419317318"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="50%"><p id="p16541153110317"><a name="p16541153110317"></a><a name="p16541153110317"></a>SPI device handle.</p> -</td> -</tr> -</tbody> -</table> ``` -SpiClose(spiHandle); /* Destroy the SPI device handle. */ +void SpiClose(DevHandle handle); ``` -## Usage Example<a name="section06541058155120"></a> +This function releases the resources requested by **MipiDsiOpen**. + + **Table 8** Description of SpiClose -The following example shows how to obtain an SPI device handle, set the configuration parameters, and then read or write data from or into the SPI device, and finally destroy the SPI device handle. +| **Parameter**| **Description**| +| -------- | -------- | +| handle | SPI device handle.| + + +``` +SpiClose(spiHandle); /* Close the SPI device handle. */ +``` + + +## Example + +The following example shows how to obtain an SPI device handle, set device attributes, and then read or write data from or into the SPI device, and finally close the SPI device handle. ``` #include "hdf_log.h" @@ -488,61 +306,61 @@ The following example shows how to obtain an SPI device handle, set the configur void SpiTestSample(void) { int32_t ret; - struct SpiCfg cfg; /* SPI device configuration information */ - struct SpiDevInfo spiDevinfo; /* SPI device descriptor */ - DevHandle spiHandle = NULL; /* SPI device handle */ - struct SpiMsg msg; /* Custom message to be transferred */ + struct SpiCfg cfg; /* SPI device configuration. */ + struct SpiDevInfo spiDevinfo; /* SPI device descriptor. */ + DevHandle spiHandle = NULL; /* SPI device handle. */ + struct SpiMsg msg; /* Custom message to be transferred. */ uint8_t rbuff[4] = { 0 }; uint8_t wbuff[4] = { 0x12, 0x34, 0x56, 0x78 }; uint8_t wbuff2[4] = { 0xa1, 0xb2, 0xc3, 0xd4 }; - spiDevinfo.busNum = 0; /* SPI device bus number */ - spiDevinfo.csNum = 0; /* SPI device CS number */ - spiHandle = SpiOpen(&spiDevinfo); /* Obtain an SPI device handle based on spiDevinfo. */ + spiDevinfo.busNum = 0; /* SPI device bus number. */ + spiDevinfo.csNum = 0; /* SPI device CS number. */ + spiHandle = SpiOpen(&spiDevinfo); /* Open the SPI device handle based on spiDevinfo. */ if (spiHandle == NULL) { HDF_LOGE("SpiOpen: failed\n"); return; } - /* Obtain configuration parameters of an SPI device. */ + /* Obtain SPI attributes. */ ret = SpiGetCfg(spiHandle, &cfg); if (ret != 0) { HDF_LOGE("SpiGetCfg: failed, ret %d\n", ret); goto err; } - cfg.maxSpeedHz = 115200; /* Change the maximum clock frequency to 115200. */ - cfg.bitsPerWord = 8; /* Change the word width to 8 bits. */ - /* Set configuration parameters for an SPI device. */ + cfg.maxSpeedHz = 115200; /* Set the maximum clock frequency to 115200. */ + cfg.bitsPerWord = 8; /* Set the word width to 8 bits. */ + /* Set SPI attributes. */ ret = SpiSetCfg(spiHandle, &cfg); if (ret != 0) { HDF_LOGE("SpiSetCfg: failed, ret %d\n", ret); goto err; } - /* Write specified length of data into an SPI device. */ + /* Write data of the specified length to an SPI device. */ ret = SpiWrite(spiHandle, wbuff, 4); if (ret != 0) { HDF_LOGE("SpiWrite: failed, ret %d\n", ret); goto err; } - /* Read data of a specific length from an SPI device. */ + /* Read data of the specified length from an SPI device. */ ret = SpiRead(spiHandle, rbuff, 4); if (ret != 0) { HDF_LOGE("SpiRead: failed, ret %d\n", ret); goto err; } - msg.wbuf = wbuff2; /* Pointer to the data to write */ - msg.rbuf = rbuff; /* Pointer to the data to read */ - msg.len = 4; /* The length of the data to read or write is 4 bits. */ - msg.csChange = 1; /* Disable the CS before the next transfer. */ - msg.delayUs = 0; /* No delay before the next transfer */ - msg.speed = 115200; /* Speed of this transfer */ - /* Launch a custom transfer. The number of messages to be transferred is 1. */ + msg.wbuf = wbuff2; /* Data to write. */ + msg.rbuf = rbuff; /* Data to read. */ + msg.len = 4; /* Set the length of the data to read or write to 4 bits. */ + msg.csChange = 1; /* Close the CS before the next transfer. */ + msg.delayUs = 0; /* No delay before the next transfer. */ + msg.speed = 115200; /* Transfer speed. */ + /* Perform a custom transfer. The number of messages to be transferred is 1. */ ret = SpiTransfer(spiHandle, &msg, 1); if (ret != 0) { HDF_LOGE("SpiTransfer: failed, ret %d\n", ret); goto err; } err: - /* Destroy the SPI device handle. */ + /* Close the SPI device handle. */ SpiClose(spiHandle); } -``` \ No newline at end of file +``` diff --git a/en/device-dev/driver/driver-platform-spi-develop.md b/en/device-dev/driver/driver-platform-spi-develop.md index 40ed76d02446262f32d8d6e55eba044eca88fd89..992424e32ed99b6cbc5dba998871a9d46f3660e6 100644 --- a/en/device-dev/driver/driver-platform-spi-develop.md +++ b/en/device-dev/driver/driver-platform-spi-develop.md @@ -1,16 +1,18 @@ -# SPI<a name="EN-US_TOPIC_0000001199690327"></a> +# SPI -## Overview<a name="section84922229152909"></a> +## Overview -In the Hardware Driver Foundation \(HDF\), the Serial Peripheral Interface \(SPI\) 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. +Serial Peripheral Interface (SPI) is a serial bus specification used for high-speed, full-duplex, and synchronous communication. In the Hardware Driver Foundation (HDF), the SPI module 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, which increases memory usage. -**Figure 1** Independent service mode<a name="fig666465313303"></a> - + **Figure 1** Independent service mode -## Available APIs<a name="section752964871810"></a> +  + +## **Available APIs** + +**SpiCntlrMethod**: -SpiCntlrMethod: ``` struct SpiCntlrMethod { @@ -21,422 +23,348 @@ struct SpiCntlrMethod { int32_t (*Close)(struct SpiCntlr *cntlr); }; ``` -**Table 1** Callbacks for the members in the SpiCntlrMethod structure - -<a name="table7167123615321"></a> -<table><thead align="left"><tr id="row816783615326"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p8167193643218"><a name="p8167193643218"></a><a name="p8167193643218"></a>Callback</p> -</th> -<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.2"><p id="p31672362325"><a name="p31672362325"></a><a name="p31672362325"></a>Input Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="24.98%" id="mcps1.2.5.1.3"><p id="p51673367328"><a name="p51673367328"></a><a name="p51673367328"></a>Return Value</p> -</th> -<th class="cellrowborder" valign="top" width="25.019999999999996%" id="mcps1.2.5.1.4"><p id="p1116883619322"><a name="p1116883619322"></a><a name="p1116883619322"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row816883693214"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p11683369329"><a name="p11683369329"></a><a name="p11683369329"></a>Transfer</p> -</td> -<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p0671913132514"><a name="p0671913132514"></a><a name="p0671913132514"></a><strong id="b19675134258"><a name="b19675134258"></a><a name="b19675134258"></a>cntlr</strong>: structure pointer to the SPI controller at the core layer.</p> -<p id="p192109186258"><a name="p192109186258"></a><a name="p192109186258"></a><strong id="b1921051810258"><a name="b1921051810258"></a><a name="b1921051810258"></a>msg</strong>: structure pointer to the SPI message.</p> -<p id="p6168736173213"><a name="p6168736173213"></a><a name="p6168736173213"></a><strong id="b92627310191"><a name="b92627310191"></a><a name="b92627310191"></a>count</strong>: number of messages. The value is of the uint32_t type.</p> -</td> -<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.2.5.1.3 "><p id="p19168736113216"><a name="p19168736113216"></a><a name="p19168736113216"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.2.5.1.4 "><p id="p18168236143218"><a name="p18168236143218"></a><a name="p18168236143218"></a>Transfers messages.</p> -</td> -</tr> -<tr id="row3168113633211"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p4168636193212"><a name="p4168636193212"></a><a name="p4168636193212"></a>SetCfg</p> -</td> -<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p242632402513"><a name="p242632402513"></a><a name="p242632402513"></a><strong id="b742642452513"><a name="b742642452513"></a><a name="b742642452513"></a>cntlr</strong>: structure pointer to the SPI controller at the core layer.</p> -<p id="p11168163643217"><a name="p11168163643217"></a><a name="p11168163643217"></a><strong id="b1283910558207"><a name="b1283910558207"></a><a name="b1283910558207"></a>cfg</strong>: structure pointer to the SPI attributes.</p> -</td> -<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.2.5.1.3 "><p id="p101683367325"><a name="p101683367325"></a><a name="p101683367325"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.2.5.1.4 "><p id="p1216815368329"><a name="p1216815368329"></a><a name="p1216815368329"></a>Sets SPI controller attributes.</p> -</td> -</tr> -<tr id="row13168183683215"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p11168436123220"><a name="p11168436123220"></a><a name="p11168436123220"></a>GetCfg</p> -</td> -<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p9698153182520"><a name="p9698153182520"></a><a name="p9698153182520"></a><strong id="b19698131162510"><a name="b19698131162510"></a><a name="b19698131162510"></a>cntlr</strong>: structure pointer to the SPI controller at the core layer.</p> -<p id="p3168936133218"><a name="p3168936133218"></a><a name="p3168936133218"></a><strong id="b11555148182113"><a name="b11555148182113"></a><a name="b11555148182113"></a>cfg</strong>: structure pointer to the SPI attributes.</p> -</td> -<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.2.5.1.3 "><p id="p18169036193219"><a name="p18169036193219"></a><a name="p18169036193219"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.2.5.1.4 "><p id="p3169136173219"><a name="p3169136173219"></a><a name="p3169136173219"></a>Obtains SPI controller attributes.</p> -</td> -</tr> -<tr id="row9169133643218"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p13169163615320"><a name="p13169163615320"></a><a name="p13169163615320"></a>Open</p> -</td> -<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p181697365327"><a name="p181697365327"></a><a name="p181697365327"></a><strong id="b1876822162218"><a name="b1876822162218"></a><a name="b1876822162218"></a>cntlr</strong>: structure pointer to the SPI controller at the core layer. </p> -</td> -<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.2.5.1.3 "><p id="p1169163693216"><a name="p1169163693216"></a><a name="p1169163693216"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.2.5.1.4 "><p id="p1116963693218"><a name="p1116963693218"></a><a name="p1116963693218"></a>Enables the SPI.</p> -</td> -</tr> -<tr id="row11169436153214"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.1 "><p id="p0169736153219"><a name="p0169736153219"></a><a name="p0169736153219"></a>Close</p> -</td> -<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.5.1.2 "><p id="p31691936193210"><a name="p31691936193210"></a><a name="p31691936193210"></a><strong id="b16798152112239"><a name="b16798152112239"></a><a name="b16798152112239"></a>cntlr</strong>: structure pointer to the SPI controller at the core layer. </p> -</td> -<td class="cellrowborder" valign="top" width="24.98%" headers="mcps1.2.5.1.3 "><p id="p2169123617322"><a name="p2169123617322"></a><a name="p2169123617322"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="25.019999999999996%" headers="mcps1.2.5.1.4 "><p id="p1169636103220"><a name="p1169636103220"></a><a name="p1169636103220"></a>Disables the SPI.</p> -</td> -</tr> -</tbody> -</table> - -## How to Develop<a name="section799667984152909"></a> + + **Table 1** Description of the callback functions in SpiCntlrMethod + +| Function| Input Parameter| Return Value| Description| +| -------- | -------- | -------- | -------- | +| Transfer | **cntlr**: structure pointer to the SPI controller at the core layer.<br>**msg**: structure pointer to the SPI message.<br>**count**: number of messages. The value is of the uint32_t type.| HDF_STATUS| Transfers messages.| +| SetCfg | **cntlr**: structure pointer to the SPI controller at the core layer.<br>**cfg**: structure pointer to the SPI attributes.| HDF_STATUS| Sets SPI controller attributes.| +| GetCfg | **cntlr**: structure pointer to the SPI controller at the core layer.<br>**cfg**: structure pointer to the SPI attributes.| HDF_STATUS| Obtains SPI controller attributes.| +| Open | **cntlr**: structure pointer to the SPI controller at the core layer.| HDF_STATUS| Opens an SPI device.| +| Close | **cntlr**: structure pointer to the SPI controller at the core layer.| HDF_STATUS| Closes an SPI device.| + + +## How to Develop The SPI 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. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **spi\_config.hcs** file. - -3. Instantiate the SPI controller object. - - Initialize **SpiCntlr**. - - Instantiate **SpiCntlrMethod** in the **SpiCntlr** object. - - For details, see [Available APIs](#section752964871810). - - 4. \(Optional\) Debug the driver. - For new drivers, verify the basic functions, such as the SPI control status and response to interrupts. - - -## Development Example<a name="section956157227152909"></a> - -The following uses **spi\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement 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. - - 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. - - - SPI driver entry reference - - ``` - struct HdfDriverEntry g_hdfSpiDevice = { - .moduleVersion = 1, - .moduleName = "HDF_PLATFORM_SPI",// (Mandatory) The value must be the same as that of moduleName in the .hcs file. - .Bind = HdfSpiDeviceBind, // See the Bind function. - .Init = HdfSpiDeviceInit, // See the Init function. - .Release = HdfSpiDeviceRelease, //See the Release function. - }; - // Call HDF_INIT to register the driver entry with the HDF. - HDF_INIT(g_hdfSpiDevice); - ``` - -2. Add the **deviceNode** information to the **device\_info.hcs** file and configure the device attributes in the **spi\_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 **SpiCntlr** members at the core layer. - - In this example, there is only one SPI controller. If there are multiple SPI controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **spi\_config** file. - - - **device\_info.hcs** configuration reference - - ``` - root { - device_info { - match_attr = "hdf_manager"; - platform :: host { - hostName = "platform_host"; - priority = 50; - device_spi :: device {// Configure an HDF device node for each SPI controller. - device0 :: deviceNode { - policy = 1; - priority = 60; - permission = 0644; - moduleName = "HDF_PLATFORM_SPI"; - serviceName = "HDF_PLATFORM_SPI_0"; - deviceMatchAttr = "hisilicon_hi35xx_spi_0"; - } - device1 :: deviceNode { - policy = 1; - priority = 60; - permission = 0644; - moduleName = "HDF_PLATFORM_SPI"; // (Mandatory) Driver name, which must be the same as that of moduleName in the driver entry structure. - serviceName = "HDF_PLATFORM_SPI_1"; // (Mandatory) Unique name of the service published by the driver - deviceMatchAttr = "hisilicon_hi35xx_spi_1";// The value must be the same as that of match_attr in the .hcs file. - } - ... - } - } - } - } - ``` - - - **spi\_config.hcs** configuration reference - - ``` - root { - platform { - spi_config {// Configure private data for each SPI controller. - template spi_controller {// Template configuration. In the template, you can configure the common parameters shared by service nodes. - serviceName = ""; - match_attr = ""; - transferMode = 0; // Data transfer mode, which can be interrupt transfer (0), flow control transfer (1), or DMA transfer (2). - busNum = 0; // Bus number - clkRate = 100000000; - bitsPerWord = 8; // Bit width of the data transferred - mode = 19; // SPI data input/output mode - maxSpeedHz = 0; // Maximum clock frequency - minSpeedHz = 0; // Minimum clock frequency - speed = 2000000; // Current message transfer speed - fifoSize = 256; // FIFO size - numCs = 1; // Chip select (CS) number - regBase = 0x120c0000; // Used for address mapping. - irqNum = 100; // Interruption number - REG_CRG_SPI = 0x120100e4; // CRG_REG_BASE(0x12010000) + 0x0e4 - CRG_SPI_CKEN = 0; - CRG_SPI_RST = 0; - REG_MISC_CTRL_SPI = 0x12030024; // MISC_REG_BASE(0x12030000) + 0x24 - MISC_CTRL_SPI_CS = 0; - MISC_CTRL_SPI_CS_SHIFT = 0; - } - controller_0x120c0000 :: spi_controller { - busNum = 0; // (Mandatory) Bus number - CRG_SPI_CKEN = 0x10000; // (0x1 << 16) 0:close clk, 1:open clk - CRG_SPI_RST = 0x1; // (0x1 << 0) 0:cancel reset, 1:reset - match_attr = "hisilicon_hi35xx_spi_0";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. - } - controller_0x120c1000 :: spi_controller { - busNum = 1; - CRG_SPI_CKEN = 0x20000; // (0x1 << 17) 0:close clk, 1:open clk - CRG_SPI_RST = 0x2; // (0x1 << 1) 0:cancel reset, 1:reset - match_attr = "hisilicon_hi35xx_spi_1"; - regBase = 0x120c1000; // (Mandatory) Used for address mapping. - irqNum = 101; // (Mandatory) Interrupt number - } - ... - //(Optional) Add nodes to the device_info.hcs file as required. - } - } - } - ``` - -3. Initialize the **SpiCntlr** object at the core layer, including initializing the vendor custom structure \(transferring parameters and data\), instantiating **SpiCntlrMethod** \(used to call underlying functions of the driver\) in **SpiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). - - Custom structure reference - - To the driver, the custom structure carries parameters and data. The values in the **spi\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the device number and bus number, are also passed to the object at the core layer. - - ``` - struct Pl022 {// Corresponds to parameters in .hcs. - struct SpiCntlr *cntlr; - struct DListHead deviceList; - struct OsalSem sem; - volatile unsigned char *phyBase; - volatile unsigned char *regBase; - uint32_t irqNum; - uint32_t busNum; - uint32_t numCs; - uint32_t curCs; - uint32_t speed; - uint32_t fifoSize; - uint32_t clkRate; - uint32_t maxSpeedHz; - uint32_t minSpeedHz; - uint32_t regCrg; - uint32_t clkEnBit; - uint32_t clkRstBit; - uint32_t regMiscCtrl; - uint32_t miscCtrlCsShift; - uint32_t miscCtrlCs; - uint16_t mode; - uint8_t bitsPerWord; - uint8_t transferMode; - }; - - // SpiCntlr is the core layer controller structure. Its members are assigned with values by using the Init function. - struct SpiCntlr { - struct IDeviceIoService service; - struct HdfDeviceObject *device; - uint32_t busNum; - uint32_t numCs; - uint32_t curCs; - struct OsalMutex lock; - struct SpiCntlrMethod *method; - struct DListHead list; - void *priv; - }; - ``` - - - Instantiate the callback function structure **SpiCntlrMethod** in **SpiCntlr**. Other members are initialized by using the **Init** function. - - ``` - // Example in spi_hi35xx.c: instantiate the hook. - struct SpiCntlrMethod g_method = { - .Transfer = Pl022Transfer, - .SetCfg = Pl022SetCfg, - .GetCfg = Pl022GetCfg, - .Open = Pl022Open, - .Close = Pl022Close, - }; - ``` - - - Bind function - - Input parameters: - - **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. - - Return values: - - HDF\_STATUS - - Function description: - - Associates the **SpiCntlr** object with **HdfDeviceObject**. - - ``` - static int32_t HdfSpiDeviceBind(struct HdfDeviceObject *device) - { - ... - return (SpiCntlrCreate(device) == NULL) ? HDF_FAILURE : HDF_SUCCESS; - } - - struct SpiCntlr *SpiCntlrCreate(struct HdfDeviceObject *device) - { - struct SpiCntlr *cntlr = NULL; // Create the SpiCntlr object of the core layer. - ... - cntlr = (struct SpiCntlr *)OsalMemCalloc(sizeof(*cntlr));// Allocate memory. - ... - cntlr->device = device; // Enable conversion between HdfDeviceObject and SpiCntlr. - device->service = &(cntlr->service); // Enable conversion between HdfDeviceObject and SpiCntlr. - (void)OsalMutexInit(&cntlr->lock); // Initialize the lock. - DListHeadInit(&cntlr->list); // Add the corresponding node. - cntlr->priv = NULL; - return cntlr; - } - ``` - - - 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.\) - - **Table 2** Input parameters and return values of the init function - - <a name="table4311552173914"></a> - <table><thead align="left"><tr id="row8314152103916"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p331413523392"><a name="p331413523392"></a><a name="p331413523392"></a>Status (Value)</p> - </th> - <th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p7314145220390"><a name="p7314145220390"></a><a name="p7314145220390"></a>Description</p> - </th> - </tr> - </thead> - <tbody><tr id="row93142052183918"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p93141252123914"><a name="p93141252123914"></a><a name="p93141252123914"></a>HDF_ERR_INVALID_OBJECT</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p331485215390"><a name="p331485215390"></a><a name="p331485215390"></a>Invalid controller object</p> - </td> - </tr> - <tr id="row331445211399"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p83141352183917"><a name="p83141352183917"></a><a name="p83141352183917"></a>HDF_ERR_MALLOC_FAIL</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p15314175220397"><a name="p15314175220397"></a><a name="p15314175220397"></a>Failed to allocate memory</p> - </td> - </tr> - <tr id="row20314175213918"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p9314352113917"><a name="p9314352113917"></a><a name="p9314352113917"></a>HDF_ERR_INVALID_PARAM</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p131535273910"><a name="p131535273910"></a><a name="p131535273910"></a>Invalid parameter</p> - </td> - </tr> - <tr id="row1431565233911"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p0315052103915"><a name="p0315052103915"></a><a name="p0315052103915"></a>HDF_ERR_IO</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1831585215398"><a name="p1831585215398"></a><a name="p1831585215398"></a>I/O error</p> - </td> - </tr> - <tr id="row2315152193914"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p7315185263919"><a name="p7315185263919"></a><a name="p7315185263919"></a>HDF_SUCCESS</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1731585213910"><a name="p1731585213910"></a><a name="p1731585213910"></a>Initialization successful</p> - </td> - </tr> - <tr id="row5315752163916"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p6315105211392"><a name="p6315105211392"></a><a name="p6315105211392"></a>HDF_FAILURE</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p83157528399"><a name="p83157528399"></a><a name="p83157528399"></a>Initialization failed</p> - </td> - </tr> - </tbody> - </table> - - Function description: - - Initializes the custom structure object and **SpiCntlr**. - - ``` - static int32_t HdfSpiDeviceInit(struct HdfDeviceObject *device) - { - int32_t ret; - struct SpiCntlr *cntlr = NULL; - ... - cntlr = SpiCntlrFromDevice(device);// Forcibly convert HdfDeviceObject to SpiCntlr by using service. For details about the value assignment, see the Bind function. - //return (device == NULL) ? NULL : (struct SpiCntlr *)device->service; - ... - ret = Pl022Init(cntlr, device);// (Mandatory) Instantiate the operation object customized by the vendor. The following is an example: - ... - ret = Pl022Probe(cntlr->priv); - ... - return ret; - } - - static int32_t Pl022Init(struct SpiCntlr *cntlr, const struct HdfDeviceObject *device) - { - int32_t ret; - struct Pl022 *pl022 = NULL; - ... - pl022 = (struct Pl022 *)OsalMemCalloc(sizeof(*pl022));// Apply for memory. - ... - ret = SpiGetBaseCfgFromHcs(pl022, device->property); // Initialize busNum, numCs, speed, fifoSize, clkRate, mode, bitsPerWord, and transferMode. - ... - ret = SpiGetRegCfgFromHcs(pl022, device->property); // Initialize regBase, phyBase, irqNum, regCrg, clkEnBit ,clkRstBit, regMiscCtrl, miscCtrlCs, and miscCtrlCsShift. - ... - // Calculate the frequencies corresponding to the maximum and minimum speeds. - pl022->maxSpeedHz = (pl022->clkRate) / ((SCR_MIN + 1) * CPSDVSR_MIN); - pl022->minSpeedHz = (pl022->clkRate) / ((SCR_MAX + 1) * CPSDVSR_MAX); - DListHeadInit(&pl022->deviceList);// Initialize the DList linked list. - pl022->cntlr = cntlr; // Enable conversion between Pl022 and SpiCntlr. - cntlr->priv = pl022; // Enable conversion between Pl022 and SpiCntlr. - cntlr->busNum = pl022->busNum; // Assign a value to busNum in SpiCntlr. - cntlr->method = &g_method; // Connect to the SpiCntlrMethod instance. - ... - ret = Pl022CreatAndInitDevice(pl022); - if (ret != 0) { - Pl022Release(pl022); // Release the Pl022 object if the initialization fails. - return ret; - } - return 0; - } - ``` - - - Release function - - Input parameters: - - **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. - - Return values: - - – - - 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. - - ``` - static void HdfSpiDeviceRelease(struct HdfDeviceObject *device) - { - struct SpiCntlr *cntlr = NULL; - ... - cntlr = SpiCntlrFromDevice(device);// Forcibly convert HdfDeviceObject to SpiCntlr by using service. For details about the value assignment, see the Bind function. - // return (device==NULL) ?NULL:(struct SpiCntlr *)device->service; - ... - if (cntlr->priv != NULL) { - Pl022Remove((struct Pl022 *)cntlr->priv);// A forced conversion from SpiCntlr to Pl022 is involved. - } - SpiCntlrDestroy(cntlr); // Release the Pl022 object. - } - ``` \ No newline at end of file +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - 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 **spi_config.hcs** file. + +3. Instantiate the SPI controller object. + - Initialize **SpiCntlr**. + - Instantiate **SpiCntlrMethod** in the **SpiCntlr** object. + >  **NOTE**<br> + > For details about the functions in **SpiCntlrMethod**, see [Available APIs](#available-apis). + +4. Debug the driver.<br> + (Optional) For new drivers, verify the basic functions, such as the SPI status control and response to interrupts. + + +## Development Example + +The following uses **spi_hi35xx.c** as an example to present the information required for implementing device functions. + +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. + + SPI driver entry example: + + ``` + struct HdfDriverEntry g_hdfSpiDevice = { + .moduleVersion = 1, + .moduleName = "HDF_PLATFORM_SPI",// (Mandatory) The value must be the same as that of moduleName in the .hcs file. + .Bind = HdfSpiDeviceBind, // See the Bind function. + .Init = HdfSpiDeviceInit, // See the Init function. + .Release = HdfSpiDeviceRelease, //See the Release function. + }; + // Call HDF_INIT to register the driver entry with the HDF. + HDF_INIT(g_hdfSpiDevice); + ``` + +2. Add the **deviceNode** information to the **device_info.hcs** file and configure the device attributes in the **spi_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 **SpiCntlr** members at the core layer. + + In this example, there is only one SPI controller. If there are multiple SPI controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **spi_config** file for each controller. + + - **device_info.hcs** configuration example + + + ``` + root { + device_info { + match_attr = "hdf_manager"; + platform :: host { + hostName = "platform_host"; + priority = 50; + device_spi :: device { // Configure an HDF device node for each SPI controller. + device0 :: deviceNode { + policy = 1; + priority = 60; + permission = 0644; + moduleName = "HDF_PLATFORM_SPI"; + serviceName = "HDF_PLATFORM_SPI_0"; + deviceMatchAttr = "hisilicon_hi35xx_spi_0"; + } + device1 :: deviceNode { + policy = 1; + priority = 60; + permission = 0644; + moduleName = "HDF_PLATFORM_SPI"; // (Mandatory) Driver name, which must be the same as that of moduleName in the driver entry structure. + serviceName = "HDF_PLATFORM_SPI_1"; // (Mandatory) Unique name of the service published by the driver. + deviceMatchAttr = "hisilicon_hi35xx_spi_1";// The value must be the same as that of match_attr in the .hcs file. + } + ... + } + } + } + } + ``` + + - **spi_config.hcs** configuration example + + + ``` + root { + platform { + spi_config {// Configure private data for each SPI controller. + template spi_controller { // Template configuration. In the template, you can configure the common parameters shared by device nodes. + serviceName = ""; + match_attr = ""; + transferMode = 0; // Data transfer mode. The value **0** indicates interrupt transfer, **1** indicates flow control transfer, and **2** indicates DMA transfer. + busNum = 0; // Bus number. + clkRate = 100000000; + bitsPerWord = 8 // Number of bits per word. + mode = 19; // SPI data input/output mode. + maxSpeedHz = 0; // Maximum clock frequency. + minSpeedHz = 0; // Minimum clock frequency. + speed = 2000000; // Current message transfer speed. + fifoSize = 256; // FIFO size. + numCs = 1; // Chip select (CS) number. + regBase = 0x120c0000; // Used for address mapping. + irqNum = 100; // Interrupt request (IRQ) number. + REG_CRG_SPI = 0x120100e4; // CRG_REG_BASE(0x12010000) + 0x0e4 + CRG_SPI_CKEN = 0; + CRG_SPI_RST = 0; + REG_MISC_CTRL_SPI = 0x12030024; // MISC_REG_BASE(0x12030000) + 0x24 + MISC_CTRL_SPI_CS = 0; + MISC_CTRL_SPI_CS_SHIFT = 0; + } + controller_0x120c0000 :: spi_controller { + busNum = 0; // (Mandatory) Bus number. + CRG_SPI_CKEN = 0x10000; // (0x1 << 16) 0:close clk, 1:open clk + CRG_SPI_RST = 0x1; // (0x1 << 0) 0:cancel reset, 1:reset + match_attr = "hisilicon_hi35xx_spi_0";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. + } + controller_0x120c1000 :: spi_controller { + busNum = 1; + CRG_SPI_CKEN = 0x20000; // (0x1 << 17) 0:close clk, 1:open clk + CRG_SPI_RST = 0x2; // (0x1 << 1) 0:cancel reset, 1:reset + match_attr = "hisilicon_hi35xx_spi_1"; + regBase = 0x120c1000; // (Mandatory) Used for address mapping. + irqNum = 101; // (Mandatory) IRQ number. + } + ... + //(Optional) Add nodes to the device_info.hcs file as required. + } + } + } + ``` + +3. Initialize the **SpiCntlr** 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 **SpiCntlrMethod** in **SpiCntlr** (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 **spi_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 **SpiCntlr** object at the core layer. + + + ``` + struct Pl022 {// Corresponds to parameters in .hcs. + struct SpiCntlr *cntlr; + struct DListHead deviceList; + struct OsalSem sem; + volatile unsigned char *phyBase; + volatile unsigned char *regBase; + uint32_t irqNum; + uint32_t busNum; + uint32_t numCs; + uint32_t curCs; + uint32_t speed; + uint32_t fifoSize; + uint32_t clkRate; + uint32_t maxSpeedHz; + uint32_t minSpeedHz; + uint32_t regCrg; + uint32_t clkEnBit; + uint32_t clkRstBit; + uint32_t regMiscCtrl; + uint32_t miscCtrlCsShift; + uint32_t miscCtrlCs; + uint16_t mode; + uint8_t bitsPerWord; + uint8_t transferMode; + }; + + // SpiCntlr is the core layer controller structure. The Init function assigns values to the members of SpiCntlr. + struct SpiCntlr { + struct IDeviceIoService service; + struct HdfDeviceObject *device; + uint32_t busNum; + uint32_t numCs; + uint32_t curCs; + struct OsalMutex lock; + struct SpiCntlrMethod *method; + struct DListHead list; + void *priv; + }; + ``` + + - Instantiating **SpiCntlrMethod** in **SpiCntlr** (other members are initialized by **Init**) + + + ``` + // Example in spi_hi35xx.c: instantiate the hooks. + struct SpiCntlrMethod g_method = { + .Transfer = Pl022Transfer, + .SetCfg = Pl022SetCfg, + .GetCfg = Pl022GetCfg, + .Open = Pl022Open, + .Close = Pl022Close, + }; + ``` + + - **Bind** function + + Input parameter: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information. + + Return value: + + HDF_STATUS + + Function description: + + Associates the **SpiCntlr** object with **HdfDeviceObject**. + + + ``` + static int32_t HdfSpiDeviceBind(struct HdfDeviceObject *device) + { + ... + return (SpiCntlrCreate(device) == NULL) ? HDF_FAILURE : HDF_SUCCESS; + } + + struct SpiCntlr *SpiCntlrCreate(struct HdfDeviceObject *device) + { + struct SpiCntlr *cntlr = NULL; // Create the SpiCntlr object at the core layer. + ... + cntlr = (struct SpiCntlr *)OsalMemCalloc(sizeof(*cntlr));// Allocate memory. + ... + cntlr->device = device; // Prerequisites for conversion between HdfDeviceObject and SpiCntlr. + device->service = &(cntlr->service); // Prerequisites for conversion between HdfDeviceObject and SpiCntlr. + (void)OsalMutexInit(&cntlr->lock); // Initialize the lock. + DListHeadInit(&cntlr->list); // Add the corresponding nodes. + cntlr->priv = NULL; + return cntlr; + } + ``` + + - **Init** function + + Input parameter: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information. + + Return value: + + HDF_STATUS + + The table below lists 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: + + Initializes the custom structure object and **SpiCntlr**. + + + ``` + static int32_t HdfSpiDeviceInit(struct HdfDeviceObject *device) + { + int32_t ret; + struct SpiCntlr *cntlr = NULL; + ... + cntlr = SpiCntlrFromDevice(device); // Use service to forcibly convert HdfDeviceObject to SpiCntlr. For details about the value assignment, see the Bind function. + // return (device == NULL) ? NULL : (struct SpiCntlr *)device->service; + ... + ret = Pl022Init(cntlr, device); // (Mandatory) Instantiate the operation object customized by the vendor. The following is an example: + ... + ret = Pl022Probe(cntlr->priv); + ... + return ret; + } + + static int32_t Pl022Init(struct SpiCntlr *cntlr, const struct HdfDeviceObject *device) + { + int32_t ret; + struct Pl022 *pl022 = NULL; + ... + pl022 = (struct Pl022 *)OsalMemCalloc(sizeof(*pl022));// Request memory. + ... + ret = SpiGetBaseCfgFromHcs(pl022, device->property); // Initialize busNum, numCs, speed, fifoSize, clkRate, mode, bitsPerWord, and transferMode. + ... + ret = SpiGetRegCfgFromHcs(pl022, device->property); // Initialize regBase, phyBase, irqNum, regCrg, clkEnBit, clkRstBit, regMiscCtrl, miscCtrlCs, and miscCtrlCsShift. + ... + // Calculate the frequencies corresponding to the maximum and minimum speeds. + pl022->maxSpeedHz = (pl022->clkRate) / ((SCR_MIN + 1) * CPSDVSR_MIN); + pl022->minSpeedHz = (pl022->clkRate) / ((SCR_MAX + 1) * CPSDVSR_MAX); + DListHeadInit(&pl022->deviceList);// Initialize the DList linked list. + pl022->cntlr = cntlr; // Prerequisite for conversion between Pl022 and SpiCntlr. + cntlr->priv = pl022; // Prerequisite for conversion between Pl022 and SpiCntlr. + cntlr->busNum = pl022->busNum; // Assign a value to busNum in SpiCntlr. + cntlr->method = &g_method; // Attach the SpiCntlrMethod instance. + ... + ret = Pl022CreatAndInitDevice(pl022); + if (ret != 0) { + Pl022Release(pl022); // Release the Pl022 object if the initialization fails. + return ret; + } + return 0; + } + ``` + + - **Release** function + + Input parameter: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs information. + + Return value: + + No value is returned. + + 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. + + + ``` + static void HdfSpiDeviceRelease(struct HdfDeviceObject *device) + { + struct SpiCntlr *cntlr = NULL; + ... + cntlr = SpiCntlrFromDevice(device); // Use service to forcibly convert HdfDeviceObject to SpiCntlr. For details about the value assignment, see the Bind function. + // return (device==NULL) ?NULL:(struct SpiCntlr *)device->service; + ... + if (cntlr->priv != NULL) { + Pl022Remove((struct Pl022 *)cntlr->priv);// A forced conversion from SpiCntlr to Pl022 is involved. + } + SpiCntlrDestroy(cntlr); // Release the Pl022 object. + } + ``` diff --git a/en/device-dev/driver/driver-platform-uart-des.md b/en/device-dev/driver/driver-platform-uart-des.md index 20340bfd49d68136a9ca711cca35ca5c2cdb0834..5c52adac895044791d673de7e48ef4c4ead18943 100644 --- a/en/device-dev/driver/driver-platform-uart-des.md +++ b/en/device-dev/driver/driver-platform-uart-des.md @@ -106,7 +106,7 @@ The UART interface defines a set of common functions for operating a UART port, The figure below illustrates how to use the APIs. **Figure 3** Using UART driver APIs<a name="fig99673244388"></a> - + ### Obtaining a UART Device Handle<a name="section124512065617"></a> diff --git a/en/device-dev/driver/driver-platform-watchdog-des.md b/en/device-dev/driver/driver-platform-watchdog-des.md index deb85133a3dde4f11cfb03762f4f4fd9d656d51b..aa00d54869576d625e05eead5cbe237a81d560e8 100644 --- a/en/device-dev/driver/driver-platform-watchdog-des.md +++ b/en/device-dev/driver/driver-platform-watchdog-des.md @@ -1,124 +1,60 @@ -# Watchdog<a name="EN-US_TOPIC_0000001206372825"></a> - -## Overview<a name="section14918241977"></a> - -A watchdog, also called a watchdog timer, is a hardware timing device. If an error occurs in the main program of the system and fails to reset the watchdog timer, the watchdog timer sends a reset signal to restore the system to a normal state. - -## Available APIs<a name="section1180575010271"></a> - -**Table 1** Watchdog APIs - -<a name="table1731550155318"></a> -<table><thead align="left"><tr id="row4419501537"><th class="cellrowborder" valign="top" width="26.619999999999997%" id="mcps1.2.4.1.1"><p id="p641050105320"><a name="p641050105320"></a><a name="p641050105320"></a>Capability</p> -</th> -<th class="cellrowborder" valign="top" width="32.800000000000004%" id="mcps1.2.4.1.2"><p id="p54150165315"><a name="p54150165315"></a><a name="p54150165315"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="40.58%" id="mcps1.2.4.1.3"><p id="p941150145313"><a name="p941150145313"></a><a name="p941150145313"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row837081981712"><td class="cellrowborder" rowspan="2" valign="top" width="26.619999999999997%" headers="mcps1.2.4.1.1 "><p id="p681292481718"><a name="p681292481718"></a><a name="p681292481718"></a>Open/Close</p> -</td> -<td class="cellrowborder" valign="top" width="32.800000000000004%" headers="mcps1.2.4.1.2 "><p id="p183701419141710"><a name="p183701419141710"></a><a name="p183701419141710"></a>WatchdogOpen</p> -</td> -<td class="cellrowborder" valign="top" width="40.58%" headers="mcps1.2.4.1.3 "><p id="p17370161911710"><a name="p17370161911710"></a><a name="p17370161911710"></a>Opens a watchdog.</p> -</td> -</tr> -<tr id="row5610415171719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p661171510173"><a name="p661171510173"></a><a name="p661171510173"></a>WatchdogClose</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11611715161713"><a name="p11611715161713"></a><a name="p11611715161713"></a>Closes a watchdog.</p> -</td> -</tr> -<tr id="row337105133315"><td class="cellrowborder" rowspan="2" valign="top" width="26.619999999999997%" headers="mcps1.2.4.1.1 "><p id="p07631557153319"><a name="p07631557153319"></a><a name="p07631557153319"></a>Start/Stop</p> -</td> -<td class="cellrowborder" valign="top" width="32.800000000000004%" headers="mcps1.2.4.1.2 "><p id="p163765113337"><a name="p163765113337"></a><a name="p163765113337"></a>WatchdogStart</p> -</td> -<td class="cellrowborder" valign="top" width="40.58%" headers="mcps1.2.4.1.3 "><p id="p18376517332"><a name="p18376517332"></a><a name="p18376517332"></a>Starts a watchdog.</p> -</td> -</tr> -<tr id="row18399184610337"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1740010461335"><a name="p1740010461335"></a><a name="p1740010461335"></a>WatchdogStop</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19400194633318"><a name="p19400194633318"></a><a name="p19400194633318"></a>Stops a watchdog.</p> -</td> -</tr> -<tr id="row34145016535"><td class="cellrowborder" rowspan="2" valign="top" width="26.619999999999997%" headers="mcps1.2.4.1.1 "><p id="p229610227124"><a name="p229610227124"></a><a name="p229610227124"></a>Timeout duration</p> -</td> -<td class="cellrowborder" valign="top" width="32.800000000000004%" headers="mcps1.2.4.1.2 "><p id="p8296182221219"><a name="p8296182221219"></a><a name="p8296182221219"></a>WatchdogSetTimeout</p> -</td> -<td class="cellrowborder" valign="top" width="40.58%" headers="mcps1.2.4.1.3 "><p id="p16297172213125"><a name="p16297172213125"></a><a name="p16297172213125"></a>Sets the watchdog timeout duration.</p> -</td> -</tr> -<tr id="row11585016539"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1095722493616"><a name="p1095722493616"></a><a name="p1095722493616"></a>WatchdogGetTimeout</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15297162215122"><a name="p15297162215122"></a><a name="p15297162215122"></a>Obtains the watchdog timeout duration.</p> -</td> -</tr> -<tr id="row105701653185811"><td class="cellrowborder" valign="top" width="26.619999999999997%" headers="mcps1.2.4.1.1 "><p id="p2571145325819"><a name="p2571145325819"></a><a name="p2571145325819"></a>Status</p> -</td> -<td class="cellrowborder" valign="top" width="32.800000000000004%" headers="mcps1.2.4.1.2 "><p id="p175711953195814"><a name="p175711953195814"></a><a name="p175711953195814"></a>WatchdogGetStatus</p> -</td> -<td class="cellrowborder" valign="top" width="40.58%" headers="mcps1.2.4.1.3 "><p id="p331961319210"><a name="p331961319210"></a><a name="p331961319210"></a>Obtains the watchdog status.</p> -</td> -</tr> -<tr id="row1028182217215"><td class="cellrowborder" valign="top" width="26.619999999999997%" headers="mcps1.2.4.1.1 "><p id="p182818227214"><a name="p182818227214"></a><a name="p182818227214"></a>Feeding</p> -</td> -<td class="cellrowborder" valign="top" width="32.800000000000004%" headers="mcps1.2.4.1.2 "><p id="p17281223219"><a name="p17281223219"></a><a name="p17281223219"></a>WatchdogFeed</p> -</td> -<td class="cellrowborder" valign="top" width="40.58%" headers="mcps1.2.4.1.3 "><p id="p62815221125"><a name="p62815221125"></a><a name="p62815221125"></a>Feeds a watchdog, or resets a watchdog timer.</p> -</td> -</tr> -</tbody> -</table> - -> **NOTE**<br> ->All watchdog functions provided in this document can be called only in kernel mode. - -## Usage Guidelines<a name="section10103184312813"></a> - -### How to Use<a name="section10181195910815"></a> - -The figure below illustrates how to use the APIs. - -**Figure 1** Using watchdog driver APIs - - -### Opening a Watchdog<a name="section66089201107"></a> - -Use **WatchdogOpen** to open a watchdog. A system may have multiple watchdogs. You can open the specified watchdog by using the ID. - -int32\_t WatchdogOpen\(int16\_t wdtId\); - -**Table 2** Description of WatchdogOpen - -<a name="table1413702552814"></a> -<table><thead align="left"><tr id="row131371325142819"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p191372254283"><a name="p191372254283"></a><a name="p191372254283"></a><strong id="b9239182472212"><a name="b9239182472212"></a><a name="b9239182472212"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p113819255284"><a name="p113819255284"></a><a name="p113819255284"></a><strong id="b2595142572219"><a name="b2595142572219"></a><a name="b2595142572219"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row813812259282"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p101381625162813"><a name="p101381625162813"></a><a name="p101381625162813"></a>wdtId</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p191381425142813"><a name="p191381425142813"></a><a name="p191381425142813"></a>Watchdog ID.</p> -</td> -</tr> -<tr id="row2138202515281"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p141387252287"><a name="p141387252287"></a><a name="p141387252287"></a><strong id="b185321027172216"><a name="b185321027172216"></a><a name="b185321027172216"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p12138192512281"><a name="p12138192512281"></a><a name="p12138192512281"></a><strong id="b29359286226"><a name="b29359286226"></a><a name="b29359286226"></a>Description</strong></p> -</td> -</tr> -<tr id="row9138182519287"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p5138102532814"><a name="p5138102532814"></a><a name="p5138102532814"></a>NULL</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p3138192512815"><a name="p3138192512815"></a><a name="p3138192512815"></a>Failed to open the watchdog.</p> -</td> -</tr> -<tr id="row15138192518283"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p1850115512916"><a name="p1850115512916"></a><a name="p1850115512916"></a><strong id="b17275323221"><a name="b17275323221"></a><a name="b17275323221"></a>DevHandle</strong> pointer</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p16138122512817"><a name="p16138122512817"></a><a name="p16138122512817"></a>Pointer to the watchdog handle.</p> -</td> -</tr> -</tbody> -</table> +# Watchdog + + +## **Overview** + +A watchdog, also called a watchdog timer, is a hardware timing device used to facilitate automatic correction of temporary hardware faults or recover from system malfunctions. If an error occurs in the main program of the system and the watchdog timer is not cleared in time, the watchdog timer sends a reset signal to restore the system to the normal state. + + +## Available APIs + +**Table 1** Watchdog APIs + +| API| Description| +| -------- | -------- | +| WatchdogOpen | Opens a watchdog.| +| WatchdogClose | Closes a watchdog.| +| WatchdogStart | Starts a watchdog.| +| WatchdogStop | Stops a watchdog.| +| WatchdogSetTimeout | Sets the watchdog timeout duration.| +| WatchdogGetTimeout | Obtains the watchdog timeout duration.| +| WatchdogGetStatus | Obtains the watchdog status.| +| WatchdogFeed | Feeds a watchdog or resets a watchdog timer.| + +>  **NOTE** +> +> All watchdog APIs provided in this document can be called only in kernel mode. + + +## Usage Guidelines + + +### How to Use + +The figure below shows how to use the watchdog APIs. + +Figure 1 Using watchdog APIs + + + + +### Opening a Watchdog + +Use **WatchdogOpen()** to open a watchdog. A system may have multiple watchdogs. You need to specify the ID of the watchdog to open. + +``` +DevHandle WatchdogOpen(int16_t wdtId); +``` + +**Table 2** Description of WatchdogOpen + +| **Parameter**| **Description**| +| -------- | -------- | +| wdtId | Watchdog ID.| +| **Return Value**| **Description**| +| NULL | The operation failed.| +| **DevHandle** pointer| The operation is successful. The pointer to the watchdog device handle is returned.| + ``` DevHandle handle = NULL; @@ -129,46 +65,23 @@ if (handle == NULL) { } ``` -### Obtaining the Watchdog Status<a name="section786624341011"></a> - -int32\_t WatchdogGetStatus\(DevHandle handle, int32\_t \*status\); - -**Table 3** Description of WatchdogGetStatus - -<a name="table1018490043"></a> -<table><thead align="left"><tr id="row31848013417"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p1415816132411"><a name="p1415816132411"></a><a name="p1415816132411"></a><strong id="b8395121072312"><a name="b8395121072312"></a><a name="b8395121072312"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p11158111316410"><a name="p11158111316410"></a><a name="p11158111316410"></a><strong id="b20193201115238"><a name="b20193201115238"></a><a name="b20193201115238"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row3264122711222"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p15264727182211"><a name="p15264727182211"></a><a name="p15264727182211"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p2026452772210"><a name="p2026452772210"></a><a name="p2026452772210"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row928111518418"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p4282955412"><a name="p4282955412"></a><a name="p4282955412"></a>status</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p7282752412"><a name="p7282752412"></a><a name="p7282752412"></a>Pointer to the watchdog status.</p> -</td> -</tr> -<tr id="row17393154515328"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p8158313248"><a name="p8158313248"></a><a name="p8158313248"></a><strong id="b12817162152319"><a name="b12817162152319"></a><a name="b12817162152319"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p161591413741"><a name="p161591413741"></a><a name="p161591413741"></a><strong id="b112451923142314"><a name="b112451923142314"></a><a name="b112451923142314"></a>Description</strong></p> -</td> -</tr> -<tr id="row339324593215"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p103191916578"><a name="p103191916578"></a><a name="p103191916578"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p1231981611712"><a name="p1231981611712"></a><a name="p1231981611712"></a>The watchdog status is obtained.</p> -</td> -</tr> -<tr id="row15393184519323"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p531916166716"><a name="p531916166716"></a><a name="p531916166716"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p93191161174"><a name="p93191161174"></a><a name="p93191161174"></a>Failed to obtain the watchdog status.</p> -</td> -</tr> -</tbody> -</table> + +### Obtaining the Watchdog Status + +``` +int32_t WatchdogGetStatus(DevHandle handle, int32_t *status); +``` + +**Table 3** Description of WatchdogGetStatus + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Watchdog device handle.| +| status | Pointer to the watchdog status obtained.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; @@ -181,51 +94,28 @@ if (ret != 0) { } ``` -### Setting the Timeout Duration<a name="section182386137111"></a> - -int32\_t WatchdogSetTimeout\(PalHandle \*handle, uint32\_t seconds\); - -**Table 4** Description of WatchdogSetTimeout - -<a name="table9159112182210"></a> -<table><thead align="left"><tr id="row1216012212212"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p1416017262215"><a name="p1416017262215"></a><a name="p1416017262215"></a><strong id="b16573184672318"><a name="b16573184672318"></a><a name="b16573184672318"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p16160182192213"><a name="p16160182192213"></a><a name="p16160182192213"></a><strong id="b8612347182320"><a name="b8612347182320"></a><a name="b8612347182320"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row199536232314"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p17685481236"><a name="p17685481236"></a><a name="p17685481236"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p196852811232"><a name="p196852811232"></a><a name="p196852811232"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row141601729228"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p191601126226"><a name="p191601126226"></a><a name="p191601126226"></a>seconds</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p5160172182214"><a name="p5160172182214"></a><a name="p5160172182214"></a>Timeout duration, in seconds.</p> -</td> -</tr> -<tr id="row18160192172212"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p101601123222"><a name="p101601123222"></a><a name="p101601123222"></a><strong id="b12598352112317"><a name="b12598352112317"></a><a name="b12598352112317"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p17160192182212"><a name="p17160192182212"></a><a name="p17160192182212"></a><strong id="b145511753122319"><a name="b145511753122319"></a><a name="b145511753122319"></a>Description</strong></p> -</td> -</tr> -<tr id="row171600202220"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p121601226224"><a name="p121601226224"></a><a name="p121601226224"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p151607218222"><a name="p151607218222"></a><a name="p151607218222"></a>The setting is successful.</p> -</td> -</tr> -<tr id="row916012252211"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p19160026224"><a name="p19160026224"></a><a name="p19160026224"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p816092142210"><a name="p816092142210"></a><a name="p816092142210"></a>Setting failed.</p> -</td> -</tr> -</tbody> -</table> + +### Setting the Timeout Duration + +``` +int32_t WatchdogSetTimeout(DevHandle *handle, uint32_t seconds); +``` + +**Table 4** Description of WatchdogSetTimeout + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Pointer to the watchdog device handle.| +| seconds | Timeout duration to set, in seconds.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; uint32_t timeOut = 60; -/* Set the timeout duration, in seconds. */ +/* Set the timeout duration to 60 seconds. */ ret = WatchdogSetTimeout(handle, timeOut); if (ret != 0) { HDF_LOGE("WatchdogSetTimeout: failed, ret %d\n", ret); @@ -233,46 +123,23 @@ if (ret != 0) { } ``` -### Obtaining the Timeout Duration<a name="section1883310371114"></a> - -int32\_t WatchdogGetTimeout\(PalHandle \*handle, uint32\_t \*seconds\); - -**Table 5** Description of WatchdogGetTimeout - -<a name="table10147164819233"></a> -<table><thead align="left"><tr id="row14147848142313"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p4147124892316"><a name="p4147124892316"></a><a name="p4147124892316"></a><strong id="b1387481413247"><a name="b1387481413247"></a><a name="b1387481413247"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p12147144817232"><a name="p12147144817232"></a><a name="p12147144817232"></a><strong id="b7800151515242"><a name="b7800151515242"></a><a name="b7800151515242"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row8147124819230"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p21471248142313"><a name="p21471248142313"></a><a name="p21471248142313"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p12147134815233"><a name="p12147134815233"></a><a name="p12147134815233"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row514754818232"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p1614713484235"><a name="p1614713484235"></a><a name="p1614713484235"></a>seconds</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p71478484238"><a name="p71478484238"></a><a name="p71478484238"></a>Pointer to the timeout duration, in seconds.</p> -</td> -</tr> -<tr id="row214784814239"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p5147848152314"><a name="p5147848152314"></a><a name="p5147848152314"></a><strong id="b2468182016249"><a name="b2468182016249"></a><a name="b2468182016249"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p914724811236"><a name="p914724811236"></a><a name="p914724811236"></a><strong id="b18272182132419"><a name="b18272182132419"></a><a name="b18272182132419"></a>Description</strong></p> -</td> -</tr> -<tr id="row714744892312"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p1014764832315"><a name="p1014764832315"></a><a name="p1014764832315"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p1314824872310"><a name="p1314824872310"></a><a name="p1314824872310"></a>The watchdog status is obtained.</p> -</td> -</tr> -<tr id="row1514884815230"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p10148114822319"><a name="p10148114822319"></a><a name="p10148114822319"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p1314864822311"><a name="p1314864822311"></a><a name="p1314864822311"></a>Failed to obtain the watchdog status.</p> -</td> -</tr> -</tbody> -</table> + +### Obtaining the Timeout Duration + +``` +int32_t WatchdogGetTimeout(DevHandle *handle, uint32_t *seconds); +``` + +**Table 5** Description of WatchdogGetTimeout + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Pointer to the watchdog device handle.| +| seconds | Pointer to the timeout duration, in seconds.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; @@ -285,41 +152,22 @@ if (ret != 0) { } ``` -### Starting a Watchdog<a name="section82501405123"></a> - -int32\_t WatchdogStart\(DevHandle handle\); - -**Table 6** Description of WatchdogStart - -<a name="table529165182515"></a> -<table><thead align="left"><tr id="row92915122513"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p5292582517"><a name="p5292582517"></a><a name="p5292582517"></a><strong id="b99151951162417"><a name="b99151951162417"></a><a name="b99151951162417"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p929554258"><a name="p929554258"></a><a name="p929554258"></a><strong id="b121171651142418"><a name="b121171651142418"></a><a name="b121171651142418"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row629852250"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p22975122515"><a name="p22975122515"></a><a name="p22975122515"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p7290515256"><a name="p7290515256"></a><a name="p7290515256"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row183035162514"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p8302511255"><a name="p8302511255"></a><a name="p8302511255"></a><strong id="b1190315442414"><a name="b1190315442414"></a><a name="b1190315442414"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p16307522515"><a name="p16307522515"></a><a name="p16307522515"></a><strong id="b333525652414"><a name="b333525652414"></a><a name="b333525652414"></a>Description</strong></p> -</td> -</tr> -<tr id="row12305552510"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p1730175132513"><a name="p1730175132513"></a><a name="p1730175132513"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p630754259"><a name="p630754259"></a><a name="p630754259"></a>The watchdog is started.</p> -</td> -</tr> -<tr id="row4306516252"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p15304502515"><a name="p15304502515"></a><a name="p15304502515"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p0301559254"><a name="p0301559254"></a><a name="p0301559254"></a>Failed to start the watchdog.</p> -</td> -</tr> -</tbody> -</table> + +### Starting a Watchdog + +``` +int32_t WatchdogStart(DevHandle handle); +``` + +**Table 6** Description of WatchdogStart + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Watchdog device handle.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; @@ -331,41 +179,22 @@ if (ret != 0) { } ``` -### Feeding a Watchdog<a name="section3547530101211"></a> - -int32\_t WatchdogFeed\(DevHandle handle\); - -**Table 7** Description of WatchdogFeed - -<a name="table091163515394"></a> -<table><thead align="left"><tr id="row891133515393"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p1911143513918"><a name="p1911143513918"></a><a name="p1911143513918"></a><strong id="b16850010142518"><a name="b16850010142518"></a><a name="b16850010142518"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p1191173553917"><a name="p1191173553917"></a><a name="p1191173553917"></a><strong id="b8711511102516"><a name="b8711511102516"></a><a name="b8711511102516"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row189111635143918"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p189111435173917"><a name="p189111435173917"></a><a name="p189111435173917"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p11911143511397"><a name="p11911143511397"></a><a name="p11911143511397"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row15911835173916"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p7911123516396"><a name="p7911123516396"></a><a name="p7911123516396"></a><strong id="b11359914162517"><a name="b11359914162517"></a><a name="b11359914162517"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p169118356399"><a name="p169118356399"></a><a name="p169118356399"></a><strong id="b7180915162512"><a name="b7180915162512"></a><a name="b7180915162512"></a>Description</strong></p> -</td> -</tr> -<tr id="row189119352393"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p1391113513917"><a name="p1391113513917"></a><a name="p1391113513917"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p149111435143911"><a name="p149111435143911"></a><a name="p149111435143911"></a>The watchdog is fed.</p> -</td> -</tr> -<tr id="row5911123520392"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p49111335143920"><a name="p49111335143920"></a><a name="p49111335143920"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p1891216356391"><a name="p1891216356391"></a><a name="p1891216356391"></a>Failed to feed the watchdog.</p> -</td> -</tr> -</tbody> -</table> + +### Feeding a Watchdog + +``` +int32_t WatchdogFeed(DevHandle handle); +``` + +**Table 7** Description of WatchdogFeed + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Watchdog device handle.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; @@ -377,41 +206,22 @@ if (ret != 0) { } ``` -### Stopping a Watchdog<a name="section944595841217"></a> - -int32\_t WatchdogStop\(DevHandle handle\); - -**Table 8** Description of WatchdogStop - -<a name="table1286810515254"></a> -<table><thead align="left"><tr id="row28687517259"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p6868185120254"><a name="p6868185120254"></a><a name="p6868185120254"></a><strong id="b204221347152519"><a name="b204221347152519"></a><a name="b204221347152519"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p15868185114252"><a name="p15868185114252"></a><a name="p15868185114252"></a><strong id="b8153154862516"><a name="b8153154862516"></a><a name="b8153154862516"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row1868165114256"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p6869105115256"><a name="p6869105115256"></a><a name="p6869105115256"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p19869951202513"><a name="p19869951202513"></a><a name="p19869951202513"></a>Watchdog handle.</p> -</td> -</tr> -<tr id="row68696510259"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p2869165114256"><a name="p2869165114256"></a><a name="p2869165114256"></a><strong id="b2116105210253"><a name="b2116105210253"></a><a name="b2116105210253"></a>Return Value</strong></p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p158691551142517"><a name="p158691551142517"></a><a name="p158691551142517"></a><strong id="b8888115292518"><a name="b8888115292518"></a><a name="b8888115292518"></a>Description</strong></p> -</td> -</tr> -<tr id="row9869851192516"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p686916516252"><a name="p686916516252"></a><a name="p686916516252"></a>0</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p7869115192510"><a name="p7869115192510"></a><a name="p7869115192510"></a>The watchdog is stopped.</p> -</td> -</tr> -<tr id="row15869951122519"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p486925112518"><a name="p486925112518"></a><a name="p486925112518"></a>Negative value</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p086945172518"><a name="p086945172518"></a><a name="p086945172518"></a>Stopping the watchdog failed.</p> -</td> -</tr> -</tbody> -</table> + +### Stopping a Watchdog + +``` +int32_t WatchdogStop(DevHandle handle); +``` + +**Table 8** Description of WatchdogStop + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Watchdog device handle.| +| **Return Value**| **Description**| +| 0 | The operation is successful.| +| Negative value| The operation failed.| + ``` int32_t ret; @@ -423,44 +233,38 @@ if (ret != 0) { } ``` -### Closing a Watchdog<a name="section96561824121311"></a> -If the watchdog is no longer required, call **WatchdogClose** to close the watchdog handle. +### Closing a Watchdog -void WatchdogClose\(DevHandle handle\); +If a watchdog is no longer required, call **WatchdogClose()** to close it. -**Table 9** Description of WatchdogClose +``` +void WatchdogClose(DevHandle handle); +``` + +**Table 9** Description of WatchdogClose + +| **Parameter**| **Description**| +| -------- | -------- | +| handle | Watchdog device handle.| -<a name="table1017315185320"></a> -<table><thead align="left"><tr id="row417314182327"><th class="cellrowborder" valign="top" width="44.99%" id="mcps1.2.3.1.1"><p id="p117310184320"><a name="p117310184320"></a><a name="p117310184320"></a><strong id="b97421847122514"><a name="b97421847122514"></a><a name="b97421847122514"></a>Parameter</strong></p> -</th> -<th class="cellrowborder" valign="top" width="55.010000000000005%" id="mcps1.2.3.1.2"><p id="p7173191812324"><a name="p7173191812324"></a><a name="p7173191812324"></a><strong id="b14503748122514"><a name="b14503748122514"></a><a name="b14503748122514"></a>Description</strong></p> -</th> -</tr> -</thead> -<tbody><tr id="row1617331823211"><td class="cellrowborder" valign="top" width="44.99%" headers="mcps1.2.3.1.1 "><p id="p17173191811326"><a name="p17173191811326"></a><a name="p17173191811326"></a>handle</p> -</td> -<td class="cellrowborder" valign="top" width="55.010000000000005%" headers="mcps1.2.3.1.2 "><p id="p538814308323"><a name="p538814308323"></a><a name="p538814308323"></a>Watchdog handle.</p> -</td> -</tr> -</tbody> -</table> ``` /* Close the watchdog. */ ret = WatchdogClose(handle); ``` -## Usage Example<a name="section1724514523135"></a> -This example provides a complete process for using a watchdog. +## Example -In this example, open a watchdog, set the timeout duration, and start the watchdog. +The following example provides the complete development process. -- Feed the watchdog periodically to ensure that the system is not reset due to timer expiry. -- Stop feeding the watchdog and check whether the system is reset after the timer expires. +1. Open a watchdog, set the timeout duration, and start the watchdog. -Example: +2. Feed the watchdog periodically to ensure that the system is not reset due to timer expiry. +3. Stop feeding the watchdog and check whether the system is reset after the timer expires. + +Sample code: ``` #include "watchdog_if.h" @@ -481,7 +285,7 @@ static int32_t TestCaseWatchdog(void) /* Open watchdog 0. */ handle = WatchdogOpen(0); if (handle == NULL) { - HDF_LOGE("Open watchdog fail!"); + HDF_LOGE("Open watchdog failed!"); return -1; } @@ -493,7 +297,7 @@ static int32_t TestCaseWatchdog(void) return ret; } - /* Obtain the configured timeout duration. */ + /* Obtain the timeout duration. */ ret = WatchdogGetTimeout(handle, &timeout); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: get timeout fail! ret:%d\n", __func__, ret); @@ -505,14 +309,14 @@ static int32_t TestCaseWatchdog(void) /* Start the watchdog. The timer starts. */ ret = WatchdogStart(handle); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: satrt fail! ret:%d\n", __func__, ret); + HDF_LOGE("%s: start fail! ret:%d\n", __func__, ret); WatchdogClose(handle); return ret; } - /* Feed the watchdog every 1s. */ + /* Feed the watchdog every other second. */ for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) { - HDF_LOGE("%s: feeding watchdog %d times... \n", __func__, i); + HDF_LOGI("%s: feeding watchdog %d times... \n", __func__, i); ret = WatchdogFeed(handle); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: feed dog fail! ret:%d\n", __func__, ret); @@ -522,17 +326,17 @@ static int32_t TestCaseWatchdog(void) OsalSleep(1); } /* Because the interval for feeding the watchdog is shorter than the timeout duration, the system does not reset, and logs can be printed normally. */ - HDF_LOGE("%s: no reset ... feeding test OK!!!\n", __func__); + HDF_LOGI("%s: no reset ... feeding test OK!!!\n", __func__); - /* Enable the timer to expire by stopping feeding the watchdog. */ + /* Stop feeding the watchdog to make the timer expire. */ for (i = 0; i < WATCHDOG_TEST_FEED_TIME; i++) { - HDF_LOGE("%s: watiting dog buck %d times... \n", __func__, i); + HDF_LOGI("%s: waiting dog buck %d times... \n", __func__, i); OsalSleep(1); } - /* The system resets when the timer expires. If the code is correct, the log below is not displayed. */ - HDF_LOGE("%s: dog has't buck!!! \n", __func__, i); + /* The system resets when the timer expires. Theoretically, this log is not displayed. */ + HDF_LOGI("%s: dog hasn't back!!! \n", __func__, i); WatchdogClose(handle); return -1; } -``` \ No newline at end of file +``` diff --git a/en/device-dev/driver/driver-platform-watchdog-develop.md b/en/device-dev/driver/driver-platform-watchdog-develop.md index 13898cfeaafd8803834c5b62f819e56ecfde96e7..d153a4ae1788127dd08a0cf8c084c3cecc1b73fd 100644 --- a/en/device-dev/driver/driver-platform-watchdog-develop.md +++ b/en/device-dev/driver/driver-platform-watchdog-develop.md @@ -1,16 +1,21 @@ -# Watchdog<a name="EN-US_TOPIC_0000001199821009"></a> +# Watchdog -## Overview<a name="section1315827527160117"></a> +## **Overview** -In the Hardware Driver Foundation \(HDF\), the Watchdog \(also called Watchdog timer\) module 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 HDF Device Manager can be directly used. However, you need to configure a device node for each device, which increases the memory usage. +A watchdog, also called a watchdog timer, is a hardware timing device used to facilitate automatic correction of temporary hardware faults or recover from system malfunctions. -**Figure 1** Independent service mode<a name="fig61584136211"></a> - +In the Hardware Driver Foundation (HDF), the watchdog 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, which increases memory usage. -## Available APIs<a name="section1180575010271"></a> + **Figure 1** Independent service mode + +  + + +## **Available APIs** + +**WatchdogMethod**: -WatchdogMethod ``` struct WatchdogMethod { @@ -25,334 +30,250 @@ struct WatchdogMethod { }; ``` -**Table 1** Callbacks for the members in the WatchdogMethod structure - -<a name="table1370451732"></a> -<table><thead align="left"><tr id="row370511435"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.1"><p id="p170681939"><a name="p170681939"></a><a name="p170681939"></a>Callback</p> -</th> -<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.2"><p id="p870641434"><a name="p870641434"></a><a name="p870641434"></a>Input Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.3"><p id="p27061011739"><a name="p27061011739"></a><a name="p27061011739"></a>Output Parameter</p> -</th> -<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.4"><p id="p10707618315"><a name="p10707618315"></a><a name="p10707618315"></a>Return Value</p> -</th> -<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.6.1.5"><p id="p37071516316"><a name="p37071516316"></a><a name="p37071516316"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row18707191835"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p970720118311"><a name="p970720118311"></a><a name="p970720118311"></a>getStatus</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p124968261413"><a name="p124968261413"></a><a name="p124968261413"></a><strong id="b13481135102819"><a name="b13481135102819"></a><a name="b13481135102819"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p17071515316"><a name="p17071515316"></a><a name="p17071515316"></a><strong id="b142021397417"><a name="b142021397417"></a><a name="b142021397417"></a>status</strong>: int32_t pointer indicating the watchdog status (started or stopped).</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p5707319312"><a name="p5707319312"></a><a name="p5707319312"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p2707511312"><a name="p2707511312"></a><a name="p2707511312"></a>Obtains the watchdog status.</p> -</td> -</tr> -<tr id="row27071911538"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p370701533"><a name="p370701533"></a><a name="p370701533"></a>start</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p117071316317"><a name="p117071316317"></a><a name="p117071316317"></a><strong id="b136901310133110"><a name="b136901310133110"></a><a name="b136901310133110"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p127071411735"><a name="p127071411735"></a><a name="p127071411735"></a>–</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p19707111331"><a name="p19707111331"></a><a name="p19707111331"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p170811111319"><a name="p170811111319"></a><a name="p170811111319"></a>Starts a watchdog.</p> -</td> -</tr> -<tr id="row17708191130"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p11708113315"><a name="p11708113315"></a><a name="p11708113315"></a>stop</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p870841138"><a name="p870841138"></a><a name="p870841138"></a><strong id="b14846151912249"><a name="b14846151912249"></a><a name="b14846151912249"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p770841533"><a name="p770841533"></a><a name="p770841533"></a>–</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p18708115313"><a name="p18708115313"></a><a name="p18708115313"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p3708121738"><a name="p3708121738"></a><a name="p3708121738"></a>Stops a watchdog.</p> -</td> -</tr> -<tr id="row107081818310"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p10708181136"><a name="p10708181136"></a><a name="p10708181136"></a>setTimeout</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p2021212409407"><a name="p2021212409407"></a><a name="p2021212409407"></a><strong id="b1521224016409"><a name="b1521224016409"></a><a name="b1521224016409"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -<p id="p1870801834"><a name="p1870801834"></a><a name="p1870801834"></a><strong id="b721091763217"><a name="b721091763217"></a><a name="b721091763217"></a>seconds</strong>: input time value, which is of the uint32_t type.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p77081011731"><a name="p77081011731"></a><a name="p77081011731"></a>–</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p470871436"><a name="p470871436"></a><a name="p470871436"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p57091717315"><a name="p57091717315"></a><a name="p57091717315"></a>Sets the timeout period (in seconds) for a watchdog. Ensure that the actual watchdog running time complies with this setting.</p> -</td> -</tr> -<tr id="row3709911938"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p2070911932"><a name="p2070911932"></a><a name="p2070911932"></a>getTimeout</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p47091711732"><a name="p47091711732"></a><a name="p47091711732"></a><strong id="b88511419192416"><a name="b88511419192416"></a><a name="b88511419192416"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p57091411632"><a name="p57091411632"></a><a name="p57091411632"></a><strong id="b3906135871316"><a name="b3906135871316"></a><a name="b3906135871316"></a>seconds</strong>: output time value, which is of the uint32_t type.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p1470941838"><a name="p1470941838"></a><a name="p1470941838"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p17091511139"><a name="p17091511139"></a><a name="p17091511139"></a>Obtains the timeout period of a watchdog.</p> -</td> -</tr> -<tr id="row1770919112319"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.1 "><p id="p1270913116313"><a name="p1270913116313"></a><a name="p1270913116313"></a>feed</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.2 "><p id="p570971736"><a name="p570971736"></a><a name="p570971736"></a><strong id="b1854319172417"><a name="b1854319172417"></a><a name="b1854319172417"></a>wdt</strong>: structure pointer to the Watchdog controller at the core layer.</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.3 "><p id="p67091517315"><a name="p67091517315"></a><a name="p67091517315"></a>–</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.4 "><p id="p1670915111312"><a name="p1670915111312"></a><a name="p1670915111312"></a>HDF_STATUS</p> -</td> -<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.6.1.5 "><p id="p10709818316"><a name="p10709818316"></a><a name="p10709818316"></a>Feeds a watchdog. </p> -</td> -</tr> -</tbody> -</table> - - -## How to Develop<a name="section477974542160117"></a> - -The Watchdog 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. - -2. Configure attribute files. - - Add the **deviceNode** information to the **device\_info.hcs** file. - - \(Optional\) Add the **watchdog\_config.hcs** file. - -3. Instantiate the Watchdog controller object. - - Initialize **WatchdogCntlr**. - - Instantiate **WatchdogMethod** in the **WatchdogCntlr** object. - - For details, see [Available APIs](#available-apis). - -4. \(Optional\) Debug the driver. - - For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether the watchdog timer is successfully set. - - -## Development Example<a name="section1832270347160117"></a> - -The following uses **watchdog\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement 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. - - 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. - - - Watchdog driver entry reference - - ``` - struct HdfDriverEntry g_watchdogDriverEntry = { - .moduleVersion = 1, - .Bind = Hi35xxWatchdogBind, // See the Bind function. - .Init = Hi35xxWatchdogInit, // See the Init function. - .Release = Hi35xxWatchdogRelease, //See the Release function. - .moduleName = "HDF_PLATFORM_WATCHDOG",// (Mandatory) The value must be the same as that of moduleName in the .hcs file. - }; - HDF_INIT(g_watchdogDriverEntry);// 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 component attributes in the **watchdog\_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 **WatchdogCntlr** members at the core layer. - - In this example, there is only one Watchdog controller. If there are multiple Watchdog controllers, you need to add the **deviceNode** information to the **device\_info** file and add the corresponding device attributes to the **watchdog\_config** file. - - - **device\_info.hcs** configuration reference - - ``` - root { - device_info { - match_attr = "hdf_manager"; - device_watchdog :: device {// Device node - device0:: deviceNode {// DeviceNode of the driver - The policy = 1; // The value 1 indicates that the driver publishes kernel-mode services. The value 2 indicates that the driver publishes user-mode services. - priority = 20; // Driver startup priority - permission = 0644; // Permission to create device nodes for the driver - moduleName = "HDF_PLATFORM_WATCHDOG"; - // (Mandatory) Driver name. The value must be the same as that of moduleName in the driver entry structure. - serviceName = "HDF_PLATFORM_WATCHDOG_0"; - // (Mandatory) Unique name of the service published by the driver. - deviceMatchAttr = "hisilicon_hi35xx_watchdog_0"; - // (Mandatory) Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. - } - } - } - } - ``` - - - **watchdog\_config.hcs** configuration reference - - ``` - root { - platform { - template watchdog_controller {// Template configuration. In the template, you can configure the common parameters shared by service nodes. - id = 0; - match_attr = ""; - regBase = 0x12050000; // (Mandatory) Used for address mapping. - regStep = 0x1000; // (Mandatory) Used for address mapping. - } - controller_0x12050000 :: watchdog_controller {// (Mandatory) Keyword for matching the private data of the device driver. - match_attr = "hisilicon_hi35xx_watchdog_0"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. - } - // Configure this parameter when there are multiple watchdogs. - ... - } - } - ``` - -3. Initialize the **WatchdogCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **WatchdogMethod** \(used to call underlying functions of the driver\) in **WatchdogCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). - - Custom structure reference - - To the driver, the custom structure carries parameters and data. The values in the **watchdog\_config.hcs** file are read by HDF, and the structure members are initialized through **DeviceResourceIface**. Some important values, such as the index and the number of pins, are also passed to the **WatchdogCntlr** object at the core layer. - - ``` - struct Hi35xxWatchdog { - struct WatchdogCntlr wdt; // (Mandatory) Carrier that connects the upper and underlying layers. For details, see the following description. - OsalSpinlock lock; - volatile unsigned char *regBase;// [Mandatory] Used for address mapping. - uint32_t phyBase; // (Mandatory) Used for address mapping. - uint32_t regStep; // (Mandatory) Used for address mapping. - }; - // WatchdogCntlr is the core layer controller structure. Its members are assigned with values by using the Init function. - struct WatchdogCntlr { - struct IDeviceIoService service;// Driver service - struct HdfDeviceObject *device; // Drive device - OsalSpinlock lock; // This variable implements the spinlock function. - struct WatchdogMethod *ops; // Interface callback - int16_t wdtId; // ID of the watchdog device - void *priv; // Save the pointer. - }; - ``` - - - Instantiate the callback function structure **WatchdogMethod** in **WatchdogCntlr**. Other members are initialized by using the **Init** and **Bind** functions. - - ``` - static struct WatchdogMethod g_method = { - .getStatus = Hi35xxWatchdogGetStatus, - .start = Hi35xxWatchdogStart, - .stop = Hi35xxWatchdogStop, - .setTimeout = Hi35xxWatchdogSetTimeout, - .getTimeout = Hi35xxWatchdogGetTimeout, - .feed = Hi35xxWatchdogFeed, - }; - ``` - - - Init and Bind functions - - Input parameters: - - **HdfDeviceObject**: device object created by the HDF for each driver. It stores device-related private data and service APIs. - - 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 Init and Bind functions - - <a name="table86931033998"></a> - <table><thead align="left"><tr id="row10694203319911"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1669433319918"><a name="p1669433319918"></a><a name="p1669433319918"></a>Status (Value)</p> - </th> - <th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p06945331911"><a name="p06945331911"></a><a name="p06945331911"></a>Description</p> - </th> - </tr> - </thead> - <tbody><tr id="row869417338918"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p96941433391"><a name="p96941433391"></a><a name="p96941433391"></a>HDF_ERR_INVALID_OBJECT</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p4694333395"><a name="p4694333395"></a><a name="p4694333395"></a>Failed to locate the watchdog device</p> - </td> - </tr> - <tr id="row136941833091"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p66941336920"><a name="p66941336920"></a><a name="p66941336920"></a>HDF_ERR_MALLOC_FAIL</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1694133395"><a name="p1694133395"></a><a name="p1694133395"></a>Failed to allocate memory</p> - </td> - </tr> - <tr id="row469443317913"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p116951933293"><a name="p116951933293"></a><a name="p116951933293"></a>HDF_ERR_IO</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p969511331918"><a name="p969511331918"></a><a name="p969511331918"></a>I/O error</p> - </td> - </tr> - <tr id="row369533318911"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p669511331891"><a name="p669511331891"></a><a name="p669511331891"></a>HDF_SUCCESS</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p136951233699"><a name="p136951233699"></a><a name="p136951233699"></a>Initialization successful</p> - </td> - </tr> - <tr id="row17695633596"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1469583314910"><a name="p1469583314910"></a><a name="p1469583314910"></a>HDF_FAILURE</p> - </td> - <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10695193311919"><a name="p10695193311919"></a><a name="p10695193311919"></a>Initialization failed</p> - </td> - </tr> - </tbody> - </table> - - Function description: - - Initializes the custom structure object and **WatchdogCntlr**, and calls the **WatchdogCntlrAdd** function at the core layer. - - ``` - // Generally, the Init function initializes the members of the Hi35xxWatchdog structure based on the attribute values of the input parameter (HdfDeviceObject). - // In this example, the Bind function initializes the Hi35xxWatchdog structure. - static int32_t Hi35xxWatchdogInit(struct HdfDeviceObject *device) - { - (void)device; - return HDF_SUCCESS; - } - - static int32_t Hi35xxWatchdogBind(struct HdfDeviceObject *device) - { - int32_t ret; - struct Hi35xxWatchdog *hwdt = NULL; - ... - hwdt = (struct Hi35xxWatchdog *)OsalMemCalloc(sizeof(*hwdt));// Apply for memory for the Hi35xxWatchdog structure. - ... - hwdt->regBase = OsalIoRemap(hwdt->phyBase, hwdt->regStep); // Address mapping - ... - hwdt->wdt.priv = (void *)device->property;// (Optional) Assign the device attribute values to priv. However, priv is not called subsequently. - //If priv needs to be called, instantiate the getPriv and releasePriv member functions in WatchdogMethod. - hwdt->wdt.ops = &g_method; // (Mandatory) Assign the instantiated objects to the ops member so that the top layer can invoke the WatchdogMethod member functions. - hwdt->wdt.device = device; // (Mandatory) Enable conversion between HdfDeviceObject and WatchdogcCntlr. - ret = WatchdogCntlrAdd(&hwdt->wdt); // (Mandatory) Call this function to initialize the structure of the core layer. The driver accesses the platform core layer only after a success signal is returned. - if (ret != HDF_SUCCESS) {// If the operation fails, release the resources used by the Init function. - OsalIoUnmap((void *)hwdt->regBase); - OsalMemFree(hwdt); - return ret; - } - return HDF_SUCCESS; - } - ``` - - - Release function - - Input parameters: - - **HdfDeviceObject**: device object created by the HDF for each driver. It stores device-related private data and service APIs. - - Return values: - - – - - 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. - - ``` - static void Hi35xxWatchdogRelease(struct HdfDeviceObject *device) - { - struct WatchdogCntlr *wdt = NULL; - struct Hi35xxWatchdog *hwdt = NULL; - ... - wdt = WatchdogCntlrFromDevice(device);// Convert HdfDeviceObject to WatchdogCntlr by the service member. - //return (device == NULL) ? NULL : (struct WatchdogCntlr *)device->service; - if (wdt == NULL) { - return; - } - WatchdogCntlrRemove(wdt); // Core layer function used to execute wdt->device->service = NULL and release cntlr->lock. - hwdt = (struct Hi35xxWatchdog *)wdt; // Convert WatchdogCntlr to HimciHost. - if (hwdt->regBase != NULL) {// Remove address mapping. - OsalIoUnmap((void *)hwdt->regBase); - hwdt->regBase = NULL; - } - OsalMemFree(hwdt); // Release the memory occupied by the vendor-defined objects. - } - ``` \ No newline at end of file + **Table 1** Description of the callback functions in WatchdogMethod + +| Function| Input Parameter| Output Parameter| Return Value| Description| +| -------- | -------- | -------- | -------- | -------- | +| getStatus | **wdt**: structure pointer to the watchdog controller at the core layer.| **status**: int32_t pointer to the watchdog status (started or stopped).| HDF_STATUS| Obtains the watchdog status.| +| start | **wdt**: structure pointer to the watchdog controller at the core layer.| –| HDF_STATUS| Starts a watchdog.| +| stop | **wdt**: structure pointer to the watchdog controller at the core layer.| –| HDF_STATUS | Stops a watchdog.| +| setTimeout | **wdt**: structure pointer to the watchdog controller at the core layer.<br/>**seconds**: Timeout duration to set, in seconds. The value is of the uint32_t type. | – | HDF_STATUS | Sets the timeout duration for a watchdog. | +| getTimeout | **wdt**: structure pointer to the watchdog controller at the core layer.| **seconds**: Pointer to the watchdog timeout duration obtained. The value is of the uint32_t type. | HDF_STATUS| Obtains the timeout duration of a watchdog.| +| feed | **wdt**: structure pointer to the watchdog controller at the core layer.| –| HDF_STATUS| Feeds a watchdog. | + + +## How to Develop + +The watchdog 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. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device_info.hcs** file. + - (Optional) Add the **watchdog_config.hcs** file. + +3. Instantiate the watchdog controller object. + - Initialize **WatchdogCntlr**. + - Instantiate **WatchdogMethod** in the **WatchdogCntlr** object. + + + >  **NOTE** + > + > For details about the functions in **WatchdogMethod**, see [Available APIs](#available-apis). + +4. Debug the driver. + + (Optional) For new drivers, verify basic functions, for example, check the information returned after the driver is attached and whether the watchdog timer is successfully set. + + +## Development Example + +The following uses **watchdog_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. + + 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. + + Watchdog driver entry example: + + ``` + struct HdfDriverEntry g_watchdogDriverEntry = { + .moduleVersion = 1, + .Bind = Hi35xxWatchdogBind, // See the Bind function. + .Init = Hi35xxWatchdogInit, // See the Init function. + .Release = Hi35xxWatchdogRelease, // See the Release function. + .moduleName = "HDF_PLATFORM_WATCHDOG",// (Mandatory) The value must be the same as that of moduleName in the .hcs file. + }; + HDF_INIT(g_watchdogDriverEntry);// 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 component attributes in the **watchdog_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 **WatchdogCntlr** members at the core layer. + + In this example, there is only one watchdog controller. If there are multiple watchdog controllers, you need to add the **deviceNode** information to the **device_info** file and add the corresponding device attributes to the **watchdog_config** file for each controller. + + - **device_info.hcs** configuration example: + + + ``` + root { + device_info { + match_attr = "hdf_manager"; + device_watchdog :: device {// Device node. + device0:: deviceNode { // Device node of the driver. + policy = 1; // Policy for the driver to provide services. + priority = 20; // Driver startup priority. + permission = 0644; // Permission to create device nodes for the driver. + moduleName = "HDF_PLATFORM_WATCHDOG"; + // (Mandatory) Driver name. The value must be the same as that of moduleName in the driver entry structure. + serviceName = "HDF_PLATFORM_WATCHDOG_0"; + // (Mandatory) Unique name of the service published by the driver. + deviceMatchAttr = "hisilicon_hi35xx_watchdog_0"; + // (Mandatory) Keyword matching the private data of the driver. The value must be the same as that of match_attr in the private data configuration table of the driver. + } + } + } + } + ``` + + - **watchdog_config.hcs** configuration example: + + + ``` + root { + platform { + template watchdog_controller {// (Mandatory) Template configuration. In the template, you can configure the common parameters shared by device nodes. + id = 0; + match_attr = ""; + regBase = 0x12050000; // (Mandatory) Used for address mapping. + regStep = 0x1000; // (Mandatory) Used for address mapping. + } + controller_0x12050000 :: watchdog_controller {// (Mandatory) Keyword for matching the private data of the device driver. + match_attr = "hisilicon_hi35xx_watchdog_0"; // (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. + } + // Configure this parameter when there are multiple watchdogs. + ... + } + } + ``` + +3. Initialize the **WatchdogCntlr** 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 **WatchdogMethod** in **WatchdogCntlr** (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 **watchdog_config.hcs** file to initialize the members in the custom structure and passes important parameters, such as the index and the number of pins, to the **WatchdogCntlr** object at the core layer. + + + ``` + struct Hi35xxWatchdog { + struct WatchdogCntlr wdt; // (Mandatory) Carrier that connects the upper and underlying layers. For details, see the following description. + OsalSpinlock lock; + volatile unsigned char *regBase;// [Mandatory] Used for address mapping. + uint32_t phyBase; // (Mandatory) Used for address mapping. + uint32_t regStep; // (Mandatory) Used for address mapping. + }; + // WatchdogCntlr is the core layer controller structure. The Init function assigns values to the members of WatchdogCntlr. + struct WatchdogCntlr { + struct IDeviceIoService service;// Driver service. + struct HdfDeviceObject *device; // Driver device. + OsalSpinlock lock; // This variable is called by the HDF core layer to implement the spinlock function. + struct WatchdogMethod *ops; // Callbacks. + int16_t wdtId // ID of the watchdog device. + void *priv; // Pointer to the driver's private data. + }; + ``` + + - Instantiating **WatchdogMethod** in **WatchdogCntlr** (other members are initialized by **Init** and **Bind**) + + + ``` + static struct WatchdogMethod g_method = { + .getStatus = Hi35xxWatchdogGetStatus, + .start = Hi35xxWatchdogStart, + .stop = Hi35xxWatchdogStop, + .setTimeout = Hi35xxWatchdogSetTimeout, + .getTimeout = Hi35xxWatchdogGetTimeout, + .feed = Hi35xxWatchdogFeed, + }; + ``` + + - **Init** and **Bind** functions + + Input parameter: + + **HdfDeviceObject**, a device object created by the HDF for each driver, holds device-related private data and service APIs. + + Return value: + + HDF_STATUS + + The table below lists 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 | Failed to locate the watchdog device.| + | HDF_ERR_MALLOC_FAIL | Failed to allocate memory.| + | HDF_ERR_IO | I/O error.| + | HDF_SUCCESS | Initialization successful.| + | HDF_FAILURE | Initialization failed.| + + Function description: + + Initializes the custom structure object and **WatchdogCntlr**, and calls the **WatchdogCntlrAdd** function at the core layer. + + + ``` + // Generally, the Init function initializes the members of the Hi35xxWatchdog structure based on the attribute values in **HdfDeviceObject**. + // In this example, the Bind function initializes the Hi35xxWatchdog structure. + static int32_t Hi35xxWatchdogInit(struct HdfDeviceObject *device) + { + (void)device; + return HDF_SUCCESS; + } + + static int32_t Hi35xxWatchdogBind(struct HdfDeviceObject *device) + { + int32_t ret; + struct Hi35xxWatchdog *hwdt = NULL; + ... + hwdt = (struct Hi35xxWatchdog *)OsalMemCalloc(sizeof(*hwdt));// Apply for memory for the Hi35xxWatchdog structure. + ... + hwdt->regBase = OsalIoRemap(hwdt->phyBase, hwdt->regStep); // Address mapping + ... + hwdt->wdt.priv = (void *)device->property;// (Optional) Assign the device attribute values to priv. However, priv is not called subsequently. + //If the priv member is required, instantiate getPriv() and releasePriv() of WatchdogMethod. + hwdt->wdt.ops = &g_method; // (Mandatory) Assign the instantiated objects to the ops members so that the top layer can invoke the WatchdogMethod functions. + hwdt->wdt.device = device; // (Mandatory) Enable conversion between HdfDeviceObject and WatchdogcCntlr. + ret = WatchdogCntlrAdd(&hwdt->wdt); // (Mandatory) Call this function to initialize the structure of the core layer. The driver accesses the platform core layer only after a success signal is returned. + if (ret != HDF_SUCCESS) { // If the operation fails, release the resources used by Init(). + OsalIoUnmap((void *)hwdt->regBase); + OsalMemFree(hwdt); + return ret; + } + return HDF_SUCCESS; + } + ``` + + - **Release** function + + Input parameter: + + **HdfDeviceObject**, a device object created by the HDF for each driver, holds device-related private data and service APIs. + + Return value: + + No value is returned. + + Function description: + + Releases driver resources. This function assigns values to **Release()** in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, **Release()** can be called to release driver resources. The **Release()** function must contain the operations for releasing the memory and deleting the controller. + + All forced conversion operations for obtaining the corresponding object can be successful only when **Init()** has the corresponding value assignment operations. + + + ``` + static void Hi35xxWatchdogRelease(struct HdfDeviceObject *device) + { + struct WatchdogCntlr *wdt = NULL; + struct Hi35xxWatchdog *hwdt = NULL; + ... + wdt = WatchdogCntlrFromDevice(device);// Use service to convert HdfDeviceObject to WatchdogCntlr. + // return (device == NULL) ? NULL : (struct WatchdogCntlr *)device->service; + if (wdt == NULL) { + return; + } + WatchdogCntlrRemove(wdt); // Core layer function used to execute wdt->device->service = NULL and release cntlr->lock. + hwdt = (struct Hi35xxWatchdog *)wdt; // Convert WatchdogCntlr to HimciHost. + if (hwdt->regBase != NULL) { // Unmap addresses. + OsalIoUnmap((void *)hwdt->regBase); + hwdt->regBase = NULL; + } + OsalMemFree(hwdt); // Release the memory occupied by the vendor-defined objects. + } + ``` diff --git a/en/device-dev/driver/figures/ADC_physical_connection.png b/en/device-dev/driver/figures/ADC_physical_connection.png index da94f3b486edb6b269ef341b12b1816f23036c32..d3cddfb92b63afc8ae1b3f8d02e4ac9c7aeb9edd 100644 Binary files a/en/device-dev/driver/figures/ADC_physical_connection.png and b/en/device-dev/driver/figures/ADC_physical_connection.png differ diff --git a/en/device-dev/driver/figures/spi-controller-device-connection.png b/en/device-dev/driver/figures/spi-controller-device-connection.png index 96f68d24918dacf9244e0ad020f2e99d77f589c4..7a467a4d7278415cbd1174706b12cb9f598369b8 100644 Binary files a/en/device-dev/driver/figures/spi-controller-device-connection.png and b/en/device-dev/driver/figures/spi-controller-device-connection.png differ diff --git a/en/device-dev/driver/figures/using-ADC-process.png b/en/device-dev/driver/figures/using-ADC-process.png index 6aebca249fa9d7948eca5f0047cea6ac4074c731..691adc1e3454170d4c0f16f60739560ef2e3ea9f 100644 Binary files a/en/device-dev/driver/figures/using-ADC-process.png and b/en/device-dev/driver/figures/using-ADC-process.png differ diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index de4acc2188103623732bcd5bf241344352f18425..444283316c4eafd12cc98e5b0af20b999482c243 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -138,7 +138,7 @@ hb set 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: diff --git a/en/device-dev/guide/device-camera-visual-run.md b/en/device-dev/guide/device-camera-visual-run.md index d48ed33058c15611ecfc6d9fe0b10da038f2107f..fd583adfc26355621fae774b2f2745827f481abd 100644 --- a/en/device-dev/guide/device-camera-visual-run.md +++ b/en/device-dev/guide/device-camera-visual-run.md @@ -1,6 +1,6 @@ # Running on the Device<a name="EN-US_TOPIC_0000001054809161"></a> -Before you install the application and run it on the development board, install the DevEco Device Tool by following operations provided in [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905). Burn OpenHarmony into the development board, and run it on the board. For details about how to compile, burn, and run an image, see the [Hi3516 Development Board](../quick-start/quickstart-lite-introduction-hi3516.md#section26131214194212). After the image is running normally and the system is started properly, perform the following steps to install or uninstall the application: +Before you install the application and run it on the development board, install the DevEco Device Tool by following operations provided in [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905). Burn OpenHarmony into the development board, and run it on the board. For details about how to compile, burn, and run an image, see the [Hi3516 Development Board](../quick-start/Readme-EN.md). After the image is running normally and the system is started properly, perform the following steps to install or uninstall the application: 1. Store the compiled unsigned application installation package and installation tool in an SD card and insert the SD card into the development board slot. The installation tool is in **dev\_tools** of the directory where the image file is generated. 2. Run the following command to disable signature verification, which is enabled by default for application installation: diff --git a/en/device-dev/guide/device-iotcamera-control-example.md b/en/device-dev/guide/device-iotcamera-control-example.md index 0d2fbf23bf92862441b826088fbc42b55ba3beea..e13ad94f9036eba83d7d9bf157d72dbe127a3d6a 100644 --- a/en/device-dev/guide/device-iotcamera-control-example.md +++ b/en/device-dev/guide/device-iotcamera-control-example.md @@ -1,6 +1,6 @@ # Use Case<a name="EN-US_TOPIC_0000001055686082"></a> -- For details about the development board, compilation, burning, and image running, see [Hi3518 Development Board](../quick-start/quickstart-lite-introduction-hi3518.md#section14815247616). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**. +- For details about the development board, compilation, burning, and image running, see [Quick Start](../quick-start/Readme-EN.md). A compilation result file of sample code is stored in **out/ipcamera\_hi3518ev300/dev\_tools/bin/camera\_sample**. You can copy the file to a TF card, or modify the compilation script of **camera\_sample** to copy the result to **rootfs.img**. Modify **output\_dir** in **applications/sample/camera/media/BUILD.gn**. diff --git a/en/device-dev/kernel/kernel-basic-mini-time.md b/en/device-dev/kernel/kernel-basic-mini-time.md index 586349d0c4683c5b782b61ea2cd0b714e7b1b4b1..375e481f4c04354b83d1e043cac3d3f7f0a83c0c 100644 --- a/en/device-dev/kernel/kernel-basic-mini-time.md +++ b/en/device-dev/kernel/kernel-basic-mini-time.md @@ -1,8 +1,7 @@ -# Time Management<a name="EN-US_TOPIC_0000001078876462"></a> +# Time Management - -## Basic Concepts<a name="section36251149131120"></a> +## Basic Concepts Time management provides all time-related services for applications based on the system clock. @@ -12,67 +11,79 @@ People use second or millisecond as the time unit, while the operating system us The time management module of the OpenHarmony LiteOS-M kernel provides time conversion and statistics functions. -## Time Unit<a name="section97172532397"></a> -- Cycle +## Time Unit + +- Cycle + + Cycle is the minimum time unit in the system. The cycle duration is determined by the system clock frequency, that is, the number of cycles per second. +- Tick + + Tick is the basic time unit of the operating system and is determined by the number of ticks per second configured by the user. - Cycle is the minimum time unit in the system. The cycle duration is determined by the system clock frequency, that is, the number of cycles per second. -- Tick +## Available APIs - Tick is the basic time unit of the operating system and is determined by the number of ticks per second configured by the user. +The following table describes APIs available for OpenHarmony LiteOS-M time management. For more details about the APIs, see the API reference. +**Table 1** APIs of the time management module -## Available APIs<a name="section158501652121514"></a> +| API| Description| +| -------- | -------- | +| LOS_MS2Tick | Converts milliseconds into ticks.| +| LOS_Tick2MS | Converts ticks into milliseconds.| +| OsCpuTick2MS | Converts cycles into milliseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.| +| OsCpuTick2US | Converts cycles into microseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.| -The following table describes APIs available for the OpenHarmony LiteOS-M time management. For more details about the APIs, see the API reference. +**Table 2** APIs for time statistics -**Table 1** APIs of the time management module +| API| Description| +| -------- | -------- | +| LOS_SysClockGet | Obtains the system clock.| +| LOS_TickCountGet | Obtains the number of ticks since the system starts.| +| LOS_CyclePerTickGet | Obtains the number of cycles for each tick.| -| Category| API| Description| -| -------- | -------- | -------- | -| Time conversion| LOS_MS2Tick | Converts milliseconds into ticks.| -| | LOS_Tick2MS | Converts ticks into milliseconds.| -| | OsCpuTick2MS | Converts cycles into milliseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.| -| | OsCpuTick2US | Converts cycles into microseconds. Two UINT32 values indicate the high-order and low-order 32 bits of the result value, respectively.| -| Time statistics| LOS_SysClockGet | Obtains the system clock.| -| | LOS_TickCountGet | Obtains the number of ticks since the system starts.| -| | LOS_CyclePerTickGet | Obtains the number of cycles for each tick.| -| | LOS_CurrNanosec |Obtains the number of nanoseconds since the system starts.| -| Delay management| LOS_UDelay |Performs busy waiting in μs, which can be preempted by a task with a higher priority.| -| | LOS_MDelay |Performs busy waiting in ms, which can be preempted by a task with a higher priority.| -## How to Develop<a name="section783435801510"></a> +## How to Develop The typical development process of time management is as follows: -1. Complete board configuration and adaptation as required, and configure the system clock frequency \(**OS\_SYS\_CLOCK** in Hz and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**\). The default value of **OS\_SYS\_CLOCK** varies with the hardware platform. -2. Call the clock conversion and statistics APIs. +1. Complete board configuration and adaptation as required, and configure the system clock frequency (**OS_SYS_CLOCK** in Hz and **LOSCFG_BASE_CORE_TICK_PER_SECOND**). The default value of **OS_SYS_CLOCK** varies with the hardware platform. -> **NOTE** +2. Call the clock conversion and statistics APIs. + +> **NOTE** > ->- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**. ->- The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time. ->- The configuration options are maintained in the **target\_config.h** file of the development board project. +> - The time management module depends on **OS_SYS_CLOCK** and **LOSCFG_BASE_CORE_TICK_PER_SECOND**. +> +> - The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time. +> +> - The configuration options are maintained in the **target_config.h** file of the development board project. + -## Development Example<a name="section460018317164"></a> +## Development Example -### Example Description<a name="section127752801718"></a> + +### Example Description The following example describes basic time management methods, including: - Time conversion: convert milliseconds to ticks or convert ticks to milliseconds. + - Time statistics: obtain the number of cycles per tick, number of ticks since system startup, and number of delayed ticks. -### Sample Code<a name="section321653551711"></a> + +### Sample Code Prerequisites -- The default value of **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND** is **100**. -- The system clock frequency **OS\_SYS\_CLOCK** is configured. +- The default value of **LOSCFG_BASE_CORE_TICK_PER_SECOND** is **100**. + +- The system clock frequency **OS_SYS_CLOCK** is configured. Time conversion: + ``` VOID Example_TransformTime(VOID) { @@ -88,6 +99,7 @@ VOID Example_TransformTime(VOID) Time statistics and delay: + ``` VOID Example_GetTime(VOID) { @@ -112,12 +124,14 @@ VOID Example_GetTime(VOID) } ``` -### Verification<a name="section4366193318167"></a> + +### Verification The development is successful if the return result is as follows: Time conversion: + ``` tick = 1000 ms = 1000 @@ -125,6 +139,7 @@ ms = 1000 Time statistics and delay: + ``` LOS_CyclePerTickGet = 495000 LOS_TickCountGet = 1 diff --git a/en/device-dev/kernel/kernel-mini-basic-soft.md b/en/device-dev/kernel/kernel-mini-basic-soft.md index ec8e10ec130d2feb0d5c931b1ffbcccca56a7818..e6bb601669fcc6fd7403c25ccea520323eeea70d 100644 --- a/en/device-dev/kernel/kernel-mini-basic-soft.md +++ b/en/device-dev/kernel/kernel-mini-basic-soft.md @@ -1,5 +1,6 @@ # Software Timer + ## Basic Concepts The software timer is a software-simulated timer based on system tick interrupts. When the preset tick counter value has elapsed, the user-defined callback will be invoked. The timing precision is related to the cycle of the system tick clock. @@ -8,144 +9,132 @@ Due to the limitation in hardware, the number of hardware timers cannot meet use The software timer supports the following functions: -- Disabling the software timer using a macro -- Creating a software timer -- Starting a software timer -- Stopping a software timer -- Deleting a software timer -- Obtaining the number of remaining ticks of a software timer +- Disabling the software timer using a macro -## Working Principles +- Creating a software timer -The software timer is a system resource. When modules are initialized, a contiguous section of memory is allocated for software timers. The maximum number of timers supported by the system is configured by the **LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT** macro in **los\_config.h**. +- Starting a software timer -Software timers use a queue and a task resource of the system. The software timers are triggered based on the First In First Out \(FIFO\) rule. A timer with a shorter value is always closer to the queue head than a timer with a longer value, and is preferentially triggered. +- Stopping a software timer -The software timer counts time in ticks. When a software timer is created and started, the OpenHarmony LiteOS-M kernel determines the timer expiry time based on the current system time \(in ticks\) and the timing interval set by the user, and adds the timer control structure to the global timing list. +- Deleting a software timer -When a tick interrupt occurs, the tick interrupt handler scans the global timing list for expired timers. If such timers are found, the timers are recorded. +- Obtaining the number of remaining ticks of a software timer -When the tick interrupt handling function is complete, the software timer task \(with the highest priority\) is woken up. In this task, the timeout callback function for the recorded timer is called. -### Timer States +## Working Principles -- OS\_SWTMR\_STATUS\_UNUSED +The software timer is a system resource. When modules are initialized, a contiguous section of memory is allocated for software timers. The maximum number of timers supported by the system is configured by the **LOSCFG_BASE_CORE_SWTMR_LIMIT** macro in **los_config.h**. - The timer is not in use. When the timer module is initialized, all timer resources in the system are set to this state. +Software timers use a queue and a task resource of the system. The software timers are triggered based on the First In First Out (FIFO) rule. A timer with a shorter value is always closer to the queue head than a timer with a longer value, and is preferentially triggered. +The software timer counts time in ticks. When a software timer is created and started, the OpenHarmony LiteOS-M kernel determines the timer expiry time based on the current system time (in ticks) and the timing interval set by the user, and adds the timer control structure to the global timing list. -- OS\_SWTMR\_STATUS\_CREATED +When a tick interrupt occurs, the tick interrupt handler scans the global timing list for expired timers. If such timers are found, the timers are recorded. - The timer is created but not started or the timer is stopped. When **LOS\_SwtmrCreate** is called for a timer that is not in use or **LOS\_SwtmrStop** is called for a newly started timer, the timer changes to this state. +When the tick interrupt handling function is complete, the software timer task (with the highest priority) is woken up. In this task, the timeout callback function for the recorded timer is called. -- OS\_SWTMR\_STATUS\_TICKING +### Timer States - The timer is running \(counting\). When **LOS\_SwtmrStart** is called for a newly created timer, the timer enters this state. +- OS_SWTMR_STATUS_UNUSED + + The timer is not in use. When the timer module is initialized, all timer resources in the system are set to this state. +- OS_SWTMR_STATUS_CREATED + + The timer is created but not started or the timer is stopped. When **LOS_SwtmrCreate** is called for a timer that is not in use or **LOS_SwtmrStop** is called for a newly started timer, the timer changes to this state. + +- OS_SWTMR_STATUS_TICKING + + The timer is running (counting). When **LOS_SwtmrStart** is called for a newly created timer, the timer enters this state. -### Timer Modes<a name="section137521353175010"></a> +### Timer Modes -The OpenHarmony LiteOS-M kernel provides three types of software timers: +The OpenHarmony LiteOS-M kernel provides the following types of software timers: + +- One-shot timer: Once started, the timer is automatically deleted after triggering only one timer event. + +- Periodic timer: This type of timer periodically triggers timer events until it is manually stopped. + +- One-shot timer deleted by calling an API -- One-shot timer: Once started, the timer is automatically deleted after triggering only one timer event. -- Periodic timer: This type of timer periodically triggers timer events until it is manually stopped. -- One-shot timer deleted by calling an API ## Available APIs The following table describes APIs available for the OpenHarmony LiteOS-M software timer module. For more details about the APIs, see the API reference. -**Table 1** Software timer APIs - -<a name="table14277123518139"></a> -<table><thead align="left"><tr id="row152771935131315"><th class="cellrowborder" valign="top" width="17.77177717771777%" id="mcps1.2.4.1.1"><p id="p1127733591316"><a name="p1127733591316"></a><a name="p1127733591316"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="23.782378237823785%" id="mcps1.2.4.1.2"><p id="p22771357138"><a name="p22771357138"></a><a name="p22771357138"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="58.44584458445845%" id="mcps1.2.4.1.3"><p id="p327714358130"><a name="p327714358130"></a><a name="p327714358130"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row159539510586"><td class="cellrowborder" rowspan="2" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p1194410585810"><a name="p1194410585810"></a><a name="p1194410585810"></a>Creating or deleting timers</p> -</td> -<td class="cellrowborder" valign="top" width="23.782378237823785%" headers="mcps1.2.4.1.2 "><p id="p10944105115814"><a name="p10944105115814"></a><a name="p10944105115814"></a>LOS_SwtmrCreate</p> -</td> -<td class="cellrowborder" valign="top" width="58.44584458445845%" headers="mcps1.2.4.1.3 "><p id="p9944105175818"><a name="p9944105175818"></a><a name="p9944105175818"></a>Creates a software timer.</p> -</td> -</tr> -<tr id="row17953454580"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p094419505814"><a name="p094419505814"></a><a name="p094419505814"></a>LOS_SwtmrDelete</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p39445585817"><a name="p39445585817"></a><a name="p39445585817"></a>Deletes a software timer.</p> -</td> -</tr> -<tr id="row79531357589"><td class="cellrowborder" rowspan="2" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p139443595820"><a name="p139443595820"></a><a name="p139443595820"></a>Starting or stopping timers</p> -</td> -<td class="cellrowborder" valign="top" width="23.782378237823785%" headers="mcps1.2.4.1.2 "><p id="p1894435175815"><a name="p1894435175815"></a><a name="p1894435175815"></a>LOS_SwtmrStart</p> -</td> -<td class="cellrowborder" valign="top" width="58.44584458445845%" headers="mcps1.2.4.1.3 "><p id="p1194415518581"><a name="p1194415518581"></a><a name="p1194415518581"></a>Starts a software timer.</p> -</td> -</tr> -<tr id="row1095320545814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p20944355589"><a name="p20944355589"></a><a name="p20944355589"></a>LOS_SwtmrStop</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p169441515816"><a name="p169441515816"></a><a name="p169441515816"></a>Stop a software timer.</p> -</td> -</tr> -<tr id="row119525513581"><td class="cellrowborder" valign="top" width="17.77177717771777%" headers="mcps1.2.4.1.1 "><p id="p109442053586"><a name="p109442053586"></a><a name="p109442053586"></a>Obtaining remaining ticks of a software timer</p> -</td> -<td class="cellrowborder" valign="top" width="23.782378237823785%" headers="mcps1.2.4.1.2 "><p id="p9944354585"><a name="p9944354585"></a><a name="p9944354585"></a>LOS_SwtmrTimeGet</p> -</td> -<td class="cellrowborder" valign="top" width="58.44584458445845%" headers="mcps1.2.4.1.3 "><p id="p39441257586"><a name="p39441257586"></a><a name="p39441257586"></a>Obtaining remaining ticks of a software timer</p> -</td> -</tr> -</tbody> -</table> + **Table 1** Software timer APIs + +| API| Description| +| -------- | -------- | +| LOS_SwtmrCreate| Creates a timer.| +| LOS_SwtmrDelete| Deletes a timer.| +| LOS_SwtmrStart| Starts a timer.| +| LOS_SwtmrStop| Stops a timer.| +| LOS_SwtmrTimeGet| Obtains the remaining ticks of a software timer.| + ## How to Develop The typical development process of software timers is as follows: -1. Configure the software timer. - - Check that **LOSCFG\_BASE\_CORE\_SWTMR** and **LOSCFG\_BASE\_IPC\_QUEUE** are set to **1**. - - Configure **LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT** \(maximum number of software timers supported by the system\). - - Configure **OS\_SWTMR\_HANDLE\_QUEUE\_SIZE** \(maximum length of the software timer queue\). +1. Configure the software timer. + - Check that **LOSCFG_BASE_CORE_SWTMR** and **LOSCFG_BASE_IPC_QUEUE** are set to **1**. + - Configure **LOSCFG_BASE_CORE_SWTMR_LIMIT** (maximum number of software timers supported by the system). + - Configure **OS_SWTMR_HANDLE_QUEUE_SIZE** (maximum length of the software timer queue). + +2. Call **LOS_SwtmrCreate** to create a software timer. + - Create a software timer with the specified timing duration, timeout handling function, and triggering mode. + - Return the function execution result (success or failure). -2. Call **LOS\_SwtmrCreate** to create a software timer. - - Create a software timer with the specified timing duration, timeout handling function, and triggering mode. - - Return the function execution result \(success or failure\). +3. Call **LOS_SwtmrStart** to start the software timer. -3. Call **LOS\_SwtmrStart** to start the software timer. -4. Call **LOS\_SwtmrTimeGet** to obtain the remaining number of ticks of the software timer. -5. Call **LOS\_SwtmrStop** to stop the software timer. -6. Call **LOS\_SwtmrDelete** to delete the software timer. +4. Call **LOS_SwtmrTimeGet** to obtain the remaining number of ticks of the software timer. + +5. Call **LOS_SwtmrStop** to stop the software timer. + +6. Call **LOS_SwtmrDelete** to delete the software timer. + +> **NOTE** +> - Avoid too many operations in the callback function of the software timer. Do not use APIs or perform operations that may cause task suspension or blocking. +> +> - The software timers use a queue and a task resource of the system. The priority of the software timer tasks is set to **0** and cannot be changed. +> +> - The number of software timer resources that can be configured in the system is the total number of software timer resources available to the entire system, not the number of software timer resources available to users. For example, if the system software timer occupies one more resource, the number of software timer resources available to users decreases by one. +> +> - If a one-shot software timer is created, the system automatically deletes the timer and reclaims resources after the timer times out and the callback function is executed. +> +> - For a one-shot software timer that will not be automatically deleted after expiration, you need to call **LOS_SwtmrDelete** to delete it and reclaim the timer resource to prevent resource leakage. -> **NOTE**<br/> ->- Avoid too many operations in the callback function of the software timer. Do not use APIs or perform operations that may cause task suspension or blocking. ->- The software timers use a queue and a task resource of the system. The priority of the software timer tasks is set to **0** and cannot be changed. ->- The number of software timer resources that can be configured in the system is the total number of software timer resources available to the entire system, not the number of software timer resources available to users. For example, if the system software timer occupies one more resource, the number of software timer resources available to users decreases by one. ->- If a one-shot software timer is created, the system automatically deletes the timer and reclaims resources after the timer times out and the callback function is executed. ->- For a one-shot software timer that will not be automatically deleted after expiration, you need to call **LOS\_SwtmrDelete** to delete it and reclaim the timer resource to prevent resource leakage. ## Development Example + ### Example Description The following programming example demonstrates how to: -1. Create, start, delete, pause, and restart a software timer. -2. Use a one-shot software timer and a periodic software timer +1. Create, start, delete, pause, and restart a software timer. + +2. Use a one-shot software timer and a periodic software timer + ### Sample Code Prerequisites -- In **los\_config.h**, **LOSCFG\_BASE\_CORE\_SWTMR** is enabled. -- In **los\_config.h**, **LOSCFG\_BASE\_CORE\_SWTMR\_ALIGN** is disabled. The sample code does not involve timer alignment. -- The maximum number of software timers supported by the system \(**LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT**\) is configured. -- The maximum length of the software timer queue \(OS\_SWTMR\_HANDLE\_QUEUE\_SIZE\) is configured. +- In **los_config.h**, **LOSCFG_BASE_CORE_SWTMR** is enabled. + +- In **los_config.h**, **LOSCFG_BASE_CORE_SWTMR_ALIGN** is disabled. The sample code does not involve timer alignment. + +- The maximum number of software timers supported by the system (**LOSCFG_BASE_CORE_SWTMR_LIMIT**) is configured. + +- The maximum length of the software timer queue (OS_SWTMR_HANDLE_QUEUE_SIZE) is configured. The sample code is as follows: + ``` #include "los_swtmr.h" @@ -156,7 +145,7 @@ UINT32 g_timerCount2 = 0; /* Task ID*/ UINT32 g_testTaskId01; -void Timer1_Callback(UINT32 arg) //Callback function 1 +void Timer1_Callback(UINT32 arg) //Callback 1 { UINT32 tick_last1; g_timerCount1++; @@ -164,7 +153,7 @@ void Timer1_Callback(UINT32 arg) //Callback function 1 printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1); } -void Timer2_Callback(UINT32 arg) //Callback function 2 +void Timer2_Callback(UINT32 arg) //Callback 2 { UINT32 tick_last2; tick_last2 = (UINT32)LOS_TickCountGet(); @@ -237,10 +226,12 @@ UINT32 Example_TaskEntry(VOID) } ``` + ### Verification The output is as follows: + ``` create Timer1 success start Timer1 success @@ -261,4 +252,3 @@ g_timerCount2=9 tick_last2=2113 g_timerCount2=10 tick_last2=2213 delete Timer2 success ``` - diff --git a/en/device-dev/kernel/kernel-mini-basic-task.md b/en/device-dev/kernel/kernel-mini-basic-task.md index b431d06f674446fe4d0ac7c990eea128d641f7af..e2b71e961f6335ce9da5485e8b025b0df88e7308 100644 --- a/en/device-dev/kernel/kernel-mini-basic-task.md +++ b/en/device-dev/kernel/kernel-mini-basic-task.md @@ -1,65 +1,68 @@ # Task Management + ## Basic Concepts From the perspective of the operating system, tasks are the minimum running units that compete for system resources. They can use or wait for CPUs, use system resources such as memory, and run independently. The task module of the OpenHarmony LiteOS-M provides multiple tasks and supports switching between tasks, helping users manage business process procedures. The task module has the following features: -- Multiple tasks are supported. -- A task represents a thread. -- The preemptive scheduling mechanism is used for tasks. High-priority tasks can interrupt low-priority tasks. Low-priority tasks can be scheduled only after high-priority tasks are blocked or complete. -- Time slice round-robin is used to schedule tasks with the same priority. -- A total of 32 \(**0** to **31**\) priorities are defined. **0** is the highest priority, and **31** is the lowest. - -### Task-related Concepts - -**Task States** - -A task has multiple states. After the system initialization is complete, the created tasks can compete for certain resources in the system according to the scheduling procedure regulated by the kernel. - -A task can be in any of the following states: - -- Ready: The task is in the ready queue, waiting for execution by a CPU. -- Running: The task is being executed. -- Blocked: The task is not in the ready queue. The task may be suspended, delayed, waiting for a semaphore, waiting to read from or write into a queue, or reading from or writing into an event. -- Dead: The task execution is complete and waiting for the system to reclaim resources. - -**Task State Transitions** - -**Figure 1** Task state transitions<a name="fig186971918162613"></a> - - -The task transition process is as follows: +- Multiple tasks are supported. -- Ready → Running +- A task represents a thread. - A task enters Ready state once created. When task switching occurs, the task with the highest priority in the Ready queue will be executed. The task being executed enters the Running state and is removed from the Ready queue. +- The preemptive scheduling mechanism is used for tasks. High-priority tasks can interrupt low-priority tasks. Low-priority tasks can be scheduled only after high-priority tasks are blocked or complete. -- Running → Blocked +- Time slice round-robin is used to schedule tasks with the same priority. - When a running task is blocked \(suspended, delayed, or reading semaphores\), it will be inserted to the blocked task queue and changes from the Running state to the Blocked state. Then, task switching is triggered to run the task with the highest priority in the Ready queue. +- A total of 32 (**0** to **31**) priorities are defined. **0** is the highest priority, and **31** is the lowest. -- Blocked → Ready \(Blocked → Running\) - When a blocked task is recovered \(for example, the task is resumed, the delay period or semaphore read period times out, or the task successfully reads a semaphore\), the task will be added to the Ready queue and change from the Blocked state to the Ready state. If the priority of the recovered task is higher than that of the running task, task switching will be triggered to run the recovered task. Then, the task changes from the Ready state to the Running state. +### Task-related Concepts -- Ready → Blocked +**Task States** - When a task in the Ready state is blocked \(suspended\), the task changes to the Blocked state and is deleted from the Ready queue. The blocked task will not be scheduled until it is recovered. +A task has multiple states. After the system initialization is complete, the created tasks can compete for certain resources in the system according to the scheduling procedure regulated by the kernel. -- Running → Ready +A task can be in any of the following states: - When a task with a higher priority is created or recovered, tasks will be scheduled. The task with the highest priority in the Ready queue changes to the Running state. The originally running task changes to the Ready state and remains in the Ready queue. +- Ready: The task is in the ready queue, waiting for execution by a CPU. -- Running → Dead +- Running: The task is being executed. - When a running task is complete, it changes to the Dead state. The Dead state includes normal exit state as the task is complete and the Invalid state. For example, if a task is complete but is not automatically deleted, the task is in the Invalid state. +- Blocked: The task is not in the ready queue. The task may be suspended, delayed, waiting for a semaphore, waiting to read from or write into a queue, or reading from or writing into an event. -- Blocked → Dead +- Dead: The task execution is complete and waiting for the system to reclaim resources. - If an API is called to delete a blocked task, the task state change from Blocked to Dead. +**Task State Transitions** +**Figure 1** Task state transition<br> + +  + +The task state transition process is as follows: + +- Ready → Running + + A task enters Ready state once created. When task switching occurs, the task with the highest priority in the Ready queue will be executed. The task being executed enters the Running state and is removed from the Ready queue. +- Running → Blocked + + When a running task is blocked (suspended, delayed, or reading semaphores), it will be inserted to the blocked task queue and changes from the Running state to the Blocked state. Then, task switching is triggered to run the task with the highest priority in the Ready queue. +- Blocked → Ready (Blocked → Running) + + When a blocked task is recovered (for example, the task is resumed, the delay period or semaphore read period times out, or the task successfully reads a semaphore), the task will be added to the Ready queue and change from the Blocked state to the Ready state. If the priority of the recovered task is higher than that of the running task, task switching will be triggered to run the recovered task. Then, the task changes from the Ready state to the Running state. +- Ready → Blocked + + When a task in the Ready state is blocked (suspended), the task changes to the Blocked state and is deleted from the Ready queue. The blocked task will not be scheduled until it is recovered. +- Running → Ready + + When a task with a higher priority is created or recovered, tasks will be scheduled. The task with the highest priority in the Ready queue changes to the Running state. The originally running task changes to the Ready state and remains in the Ready queue. +- Running → Dead + + When a running task is complete, it changes to the Dead state. The Dead state includes normal exit state as the task is complete and the Invalid state. For example, if a task is complete but is not automatically deleted, the task is in the Invalid state. +- Blocked → Dead + + If an API is called to delete a blocked task, the task state change from Blocked to Dead. **Task ID** @@ -83,81 +86,84 @@ Resources, such as registers, used during the running of a task. When a task is **Task Control Block** -Each task has a task control block \(TCB\). A TCB contains task information, such as context stack pointer, state, priority, ID, name, and stack size. The TCB reflects the running status of a task. +Each task has a task control block (TCB). A TCB contains task information, such as context stack pointer, state, priority, ID, name, and stack size. The TCB reflects the running status of a task. **Task Switching** Task switching involves actions, such as obtaining the task with the highest priority in the Ready queue, saving the context of the switched-out task, and restoring the context of the switched-in task. -### Task Running Mechanism<a name="section123321315152219"></a> + +### Task Running Mechanism When a task is created, the system initializes the task stack and presets the context. The system places the task entry function in the corresponding position so that the function is executed when the task enters the running state for the first time. + ## Available APIs The following table describes APIs available for the OpenHarmony LiteOS-M task module. For more details about the APIs, see the API reference. -**Table 1** APIs of the task management module - -| Category| API| Description| -| -------- | -------- | -------- | -| Creating or deleting a task| LOS_TaskCreateOnly | Creates a task and suspends the task to disable scheduling of the task. To enable scheduling of the task, call **LOS_TaskResume** to make the task enter the Ready state.| -| | LOS_TaskCreate | Creates a task and places the task in the Ready state. If there is no task with a higher priority in the Ready queue, the task will be executed.| -| | LOS_TaskDelete | Deletes a task.| -| Controlling task status| LOS_TaskResume | Resumes a suspended task to place it in the Ready state.| -| | LOS_TaskSuspend | Suspends the specified task and performs task switching.| -| | LOS_TaskJoin | Suspends this task till the specified task is complete and the task control block resources are reclaimed.| -| | LOS_TaskDetach | Changes the task attribute from **joinable** to **detach**. After the task of the **detach** attribute is complete, the task control block resources will be automatically reclaimed.| -| | LOS_TaskDelay | Makes a task wait for a period of time (in ticks) and releases CPU resources. When the delay time expires, the task enters the Ready state again. The input parameter is the number of ticks.| -| | LOS_Msleep | Converts the input number of milliseconds into number of ticks, and use the result to call **LOS_TaskDelay**.| -| | LOS_TaskYield | Sets the time slice of the current task to **0** to release CPU resources and schedule the task with the highest priority in the Ready queue to run.| -| Controlling task scheduling| LOS_TaskLock | Locks task scheduling. However, tasks can still be interrupted.| -| | LOS_TaskUnlock | Unlocks task scheduling.| -| | LOS_Schedule | Triggers task scheduling| -| Controlling task priority| LOS_CurTaskPriSet | Sets the priority for the current task.| -| | LOS_TaskPriSet | Sets the priority for a specified task.| -| | LOS_TaskPriGet | Obtains the priority of a specified task.| -| Obtaining Job information| LOS_CurTaskIDGet | Obtains the ID of the current task.| -| | LOS_NextTaskIDGet | Obtains the ID of the task with the highest priority in the Ready queue.| -| | LOS_NewTaskIDGet | Same as **LOS_NextTaskIDGet**.| -| | LOS_CurTaskNameGet | Obtains the name of the current task.| -| | LOS_TaskNameGet | Obtains the name of a specified task.| -| | LOS_TaskStatusGet | Obtains the state of a specified task.| -| | LOS_TaskInfoGet | Obtains information about a specified task, including the task state, priority, stack size, stack pointer (SP), task entry function, and used stack space.| -| | LOS_TaskIsRunning | Checks whether the task module has started scheduling.| -| Updating task information| LOS_TaskSwitchInfoGet | Obtains task switching information. The macro **LOSCFG_BASE_CORE_EXC_TSK_SWITCH** must be enabled.| -| Reclaiming task stack resources| LOS_TaskResRecycle | Reclaims all task stack resources.| + **Table 1** APIs of the task management module + +| Category| Description| +| -------- | -------- | +| Creating or deleting a task| **LOS_TaskCreateOnly**: creates a task and places the task in the Ready state. If there is no task with a higher priority in the Ready queue, the task will be executed.<br>**LOS_TaskCreate**: creates a task and places the task in the Ready state. If there is no task with a higher priority in the Ready queue, the task will be executed.<br>**LOS_TaskDelete**: deletes a task.| +| Controlling task status| **LOS_TaskResume**: resumes a suspended task to place the task in the Ready state.<br>**LOS_TaskSuspend**: suspends the specified task and performs task switching.<br>**LOS_TaskJoin**: suspends this task till the specified task is complete and the task control block resources are reclaimed.<br>**LOS_TaskDelay**: makes a task wait for a period of time (in ticks) and releases CPU resources. When the delay timer expires, the task enters the Ready state again. The input parameter is the number of ticks.<br>**LOS_Msleep**: converts the input parameter number of milliseconds into number of ticks, and use the result to call **LOS_TaskDelay**.<br>**LOS_TaskYield**: sets the time slice of the current task to **0** to release CPU resources and schedule the task with the highest priority in the Ready queue to run.| +| Controlling task scheduling| **LOS_TaskLock**: locks task scheduling. However, tasks can still be interrupted.<br>**LOS_TaskUnlock**: unlocks task scheduling.<br>**LOS_Schedule**: triggers task scheduling.| +| Controlling task priority| **LOS_CurTaskPriSet**: sets the priority for the current task.<br>**LOS_TaskPriSet**: sets the priority for a specified task.<br>**LOS_TaskPriGet**: obtains the priority of a specified task.| +| Obtaining Job information| **LOS_CurTaskIDGet**: obtains the ID of the current task.<br>**LOS_NextTaskIDGet**: obtains the ID of the task with the highest priority in the Ready queue.<br>**LOS_NewTaskIDGet**: equivalent to **LOS_NextTaskIDGet**.<br>**LOS_CurTaskNameGet**: obtains the name of the current task.<br>**LOS_TaskNameGet**: obtains the name of a task.<br>**LOS_TaskStatusGet**: obtains the state of a task.<br>**LOS_TaskInfoGet**: obtains information about a specified task, including the task state, priority, stack size, stack pointer (SP), task entry function, and used stack space.<br>**LOS_TaskIsRunning**: checks whether the task module has started scheduling.| +| Updating task information| **LOS_TaskSwitchInfoGet**: obtains task switching information. The macro **LOSCFG_BASE_CORE_EXC_TSK_SWITCH** must be enabled.| ## How to Develop The typical development process of the task module is as follows: -1. Use **LOS\_TaskLock** to lock task scheduling and prevent high-priority tasks from being scheduled. -2. Use **LOS\_TaskCreate** to create a task. -3. Use **LOS\_TaskUnlock** to unlock task scheduling so that tasks can be scheduled by priority. -4. Use **LOS\_TaskDelay** to delay a task. -5. Use **LOS\_TaskSuspend** to suspend a task. -6. Use **LOS\_TaskResume** to resume the suspended task. - -> **NOTE**<br/> ->- Running idle tasks reclaims the TCBs and stacks in the to-be-recycled linked list. ->- The task name is a pointer without memory space allocated. When setting the task name, do not assign the local variable address to the task name pointer. ->- The task stack size is 8-byte aligned. Follow the "nothing more and nothing less" principle while determining the task stack size. ->- A running task cannot be suspended if task scheduling is locked. ->- Idle tasks and software timer tasks cannot be suspended or deleted. ->- In an interrupt handler or when a task is locked, the operation of calling **LOS\_TaskDelay** fails. ->- Locking task scheduling does not disable interrupts. Tasks can still be interrupted while task scheduling is locked. ->- Locking task scheduling must be used together with unlocking task scheduling. ->- Task scheduling may occur while a task priority is being set. ->- The maximum number of tasks that can be set for the operating system is the total number of tasks of the operating system, not the number of tasks available to users. For example, if the system software timer occupies one more task resource, the number of task resources available to users decreases by one. ->- **LOS\_CurTaskPriSet** and **LOS\_TaskPriSet** cannot be used in interrupts or used to modify the priorities of software timer tasks. ->- If the task corresponding to the task ID sent to **LOS\_TaskPriGet** has not been created or the task ID exceeds the maximum number of tasks, **-1** will be returned. ->- Resources such as a mutex or a semaphore allocated to a task must have been released before the task is deleted. +1. Use **LOS_TaskLock** to lock task scheduling and prevent high-priority tasks from being scheduled. + +2. Use **LOS_TaskCreate** to create a task. + +3. Use **LOS_TaskUnlock** to unlock task scheduling so that tasks can be scheduled by priority. + +4. Use **LOS_TaskDelay** to delay a task. + +5. Use **LOS_TaskSuspend** to suspend a task. + +6. Use **LOS_TaskResume** to resume the suspended task. + +> **NOTE**<br/> +> - Running idle tasks reclaims the TCBs and stacks in the to-be-recycled linked list. +> +> - The task name is a pointer without memory space allocated. When setting the task name, do not assign the local variable address to the task name pointer. +> +> - The task stack size is 8-byte aligned. Follow the "nothing more and nothing less" principle while determining the task stack size. +> +> - A running task cannot be suspended if task scheduling is locked. +> +> - Idle tasks and software timer tasks cannot be suspended or deleted. +> +> - In an interrupt handler or when a task is locked, the operation of calling **LOS_TaskDelay** fails. +> +> - Locking task scheduling does not disable interrupts. Tasks can still be interrupted while task scheduling is locked. +> +> - Locking task scheduling must be used together with unlocking task scheduling. +> +> - Task scheduling may occur while a task priority is being set. +> +> - The maximum number of tasks that can be set for the operating system is the total number of tasks of the operating system, not the number of tasks available to users. For example, if the system software timer occupies one more task resource, the number of task resources available to users decreases by one. +> +> - **LOS_CurTaskPriSet** and **LOS_TaskPriSet** cannot be used in interrupts or used to modify the priorities of software timer tasks. +> +> - If the task corresponding to the task ID sent to **LOS_TaskPriGet** has not been created or the task ID exceeds the maximum number of tasks, **-1** will be returned. +> +> - Resources such as a mutex or a semaphore allocated to a task must have been released before the task is deleted. + ## Development Example -This example describes the priority-based task scheduling and use of task-related APIs, including creating, delaying, suspending, and resuming two tasks with different priorities, and locking/unlocking task scheduling. The sample code is as follows: +This example describes the priority-based task scheduling and use of task-related APIs, including creating, delaying, suspending, and resuming two tasks with different priorities, and locking/unlocking task scheduling. + +The sample code is as follows: + ``` UINT32 g_taskHiId; @@ -249,7 +255,7 @@ UINT32 Example_TskCaseEntry(VOID) initParam.pcName = "TaskLo"; initParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; - /*Create a low-priority task. The task will not be executed immediately after being created, because task scheduling is locked. */ + /* Create a low-priority task. The task will not be executed immediately after being created, because task scheduling is locked. */ ret = LOS_TaskCreate(&g_taskLoId, &initParam); if (ret != LOS_OK) { LOS_TaskUnlock(); @@ -271,10 +277,12 @@ UINT32 Example_TskCaseEntry(VOID) } ``` + ### Verification The development is successful if the return result is as follows: + ``` LOS_TaskLock() Success! Example_TaskHi create Success! diff --git a/en/device-dev/kernel/kernel-mini-extend-dynamic-loading.md b/en/device-dev/kernel/kernel-mini-extend-dynamic-loading.md index 1bf198e1fa337518d06a4062c74a2cf290630b4c..3e6ab8c31e41128a1f15f10a2d396cb74dd7bc7f 100644 --- a/en/device-dev/kernel/kernel-mini-extend-dynamic-loading.md +++ b/en/device-dev/kernel/kernel-mini-extend-dynamic-loading.md @@ -1,17 +1,26 @@ # Dynamic Loading + ## Basic Concepts -In small devices with limited hardware resources, dynamic algorithm deployment capability is required to solve the problem that multiple algorithms cannot be deployed at the same time. The LiteOS-M kernel uses the Executable and Linkable Format \(ELF\) loading because it is easy to use and compatible with a wide variety of platforms. The LiteOS-M provides APIs similar to **dlopen** and **dlsym**. Apps can load and unload required algorithm libraries by using the APIs provided by the dynamic loading module. As shown in the following figure, the app obtains the corresponding information output through the API required by the third-party algorithm library. The third-party algorithm library depends on the basic APIs provided by the kernel, such as **malloc**. After the app loads the API and relocates undefined symbols, it can call the API to complete the function. The dynamic loading component supports only the Arm architecture. In addition, the signature and source of the shared library to be loaded must be verified to ensure system security. +In small devices with limited hardware resources, dynamic algorithm deployment capability is required to allow multiple algorithms to be deployed at the same time. The LiteOS-M kernel uses the Executable and Linkable Format (ELF) loading because it is easy to use and compatible with a wide variety of platforms. + +The LiteOS-M provides APIs similar to **dlopen** and **dlsym**. Apps can load and unload required algorithm libraries by using the APIs provided by the dynamic loading module. As shown in the following figure, the app obtains the corresponding information output through the API required by the third-party algorithm library. The third-party algorithm library depends on the basic APIs provided by the kernel, such as **malloc**. After the app loads the API and relocates undefined symbols, it can call the API to complete the function. + +The dynamic loading component supports only the Arm architecture. In addition, the signature and source of the shared library to be loaded must be verified to ensure system security. + + **Figure 1** LiteOS-M kernel dynamic loading architecture + +  -**Figure 1** LiteOS-M kernel dynamic loading architecture - ## Working Principles + ### Exporting the Symbol Table -The kernel needs to proactively expose the API required by the dynamic library when the shared library calls a kernel API, as shown in the following figure. This mechanism compiles the symbol information to the specified section and calls the **SYM\_EXPORT** macro to export information of the specified symbol. The symbol information is described in the structure **SymInfo**. Its members include the symbol name and symbol address information. The macro **SYM\_EXPORT** imports the symbol information to the **.sym.\*** section by using the **\_\_attribute\_\_** compilation attribute. +The kernel needs to proactively expose the API required by the dynamic library when the shared library calls a kernel API, as shown in the following figure. This mechanism compiles the symbol information to the specified section and calls the **SYM_EXPORT** macro to export information of the specified symbol. The symbol information is described in the structure **SymInfo**, which includes the symbol name and address information. The macro **SYM_EXPORT** imports the symbol information to the **.sym.*** section by using **__attribute__**. + ``` typedef struct { @@ -26,12 +35,15 @@ const SymInfo sym_##func __attribute__((section(".sym."#func))) = { \ }; ``` -**Figure 2** Exported symbol table information - + **Figure 2** Exported symbol table + +  + ### Loading an ELF File -During the loading process, the LOAD section to be loaded to the memory is obtained based on the ELF file handle and the section offset of the program header table. Generally, there are two sections: read-only section and read-write section. You can run the **readelf -l** command to view the LOAD section information of the ELF file. The physical memory is requested according to the related alignment attributes. Then, a code section or a data segment is written into the memory based on the loading base address and an offset of each section. +The **LOAD** section to be loaded to the memory can be obtained based on the ELF file handle and the section offset of the program header table. Generally, there are two sections: read-only and read-write. You can run the **readelf -l** command to view the LOAD section information of the ELF file. The physical memory is requested according to the related alignment attributes. Then, a code section or a data segment is written into the memory based on the loading base address and an offset of each section. + ``` $ readelf -l lib.so @@ -43,8 +55,7 @@ There are 4 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align EXIDX 0x000760 0x00000760 0x00000760 0x00008 0x00008 R 0x4 - LOAD 0x000000 0x00000000 0x00000000 0x0076c 0x0076c R E 0x10000 - LOAD 0x00076c 0x0001076c 0x0001076c 0x0010c 0x00128 RW 0x10000 + LOAD 0x000000 0x00000000 0x00000000 0x0076c 0x0076c R E 0x10000LOAD 0x00076c 0x0001076c 0x0001076c 0x0010c 0x00128 RW 0x10000 DYNAMIC 0x000774 0x00010774 0x00010774 0x000c8 0x000c8 RW 0x4 Section to Segment mapping: @@ -55,29 +66,45 @@ Program Headers: 03 .dynamic ``` -**Figure 3** Process of loading an ELF file - + **Figure 3** Process of loading an ELF file<br> +  + -### ELF File Link +### ELF File Linking A relocation table is obtained by using a **.dynamic** section of the ELF file. Each entry that needs to be relocated in the table is traversed. Then, the symbol is searched, based on the symbol name that needs to be relocated, in the shared library and the exported symbol table provided by the kernel. The relocation information is updated based on the symbol found. -**Figure 4** ELF file linking process - + **Figure 4** ELF file linking process + +  + ## ELF Specifications + ### ELF Type -When compiling a shared library, you can add **-fPIC** \(a compilation option\) to compile location-independent code. The shared library file type is **ET\_DYN**, which can be loaded to any valid address range. +When compiling a shared library, you can add **-fPIC** (a compilation option) to compile location-independent code. The shared library file type is **ET_DYN**, which can be loaded to any valid address range. Example: **arm-none-eabi-gcc -fPIC –shared –o lib.so lib.c** + ### Options for Linking -1. **-nostdlib**: Do not use the lib library in the compiler when linking. -2. **-nostartfiles**: Do not use the startup files in the compiler when linking. -3. **-fPIC**: compiles location-independent shared libraries. -4. **-z max-page-size=4**: sets the number of alignment bytes of the loadable sections in the binary file to **4**. This setting saves memory and can be used for a dynamic library. -5. **-mcpu=** specifies the CPU architecture. +- **-nostdlib**: Do not use the lib library in the compiler when linking. + +- **-nostartfiles**: Do not use the startup files in the compiler when linking. + +- **-fPIC**: compiles location-independent shared libraries. + +- **-z max-page-size=4**: sets the number of alignment bytes of the loadable sections in the binary file to **4**. This setting saves memory and can be used for a dynamic library. + +- **-mcpu=** specifies the CPU architecture. + + +## Constraints + +- Applications cannot be loaded. Only shared libraries can be loaded. +- The shared library to be loaded cannot depend on the libc library or other shared libraries in the compiler. It can depend only on the external APIs provided by the kernel (provided by the exported symbol table). +- This feature depends on the cross compiler and file system. diff --git a/en/device-dev/kernel/kernel-mini-extend-file-fat.md b/en/device-dev/kernel/kernel-mini-extend-file-fat.md index 5f191076a6e75743b254e0b8611698de701bb8e0..b7a9bffdd5e106d1afedff3f960b4f29d9b8dca2 100644 --- a/en/device-dev/kernel/kernel-mini-extend-file-fat.md +++ b/en/device-dev/kernel/kernel-mini-extend-file-fat.md @@ -1,20 +1,27 @@ # FAT + ## Basic Concepts -File Allocation Table \(FAT\) is a file system developed for personal computers. It consists of the DOS Boot Record \(DBR\) region, FAT region, and Data region. Each entry in the FAT region records information about the corresponding cluster in the storage device. The cluster information includes whether the cluster is used, number of the next cluster of the file, whether the file ends with the cluster. The FAT file system supports multiple formats, such as FAT12, FAT16, and FAT32. The numbers 12, 16, and 32 indicate the number of bits per cluster within the FAT, respectively. The FAT file system supports multiple media, especially removable media \(such as USB flash drives, SD cards, and removable hard drives\). The FAT file system ensures good compatibility between embedded devices and desktop systems \(such as Windows and Linux\) and facilitates file management. +File Allocation Table (FAT) is a file system developed for personal computers. It consists of the DOS Boot Record (DBR) region, FAT region, and Data region. Each entry in the FAT region records information about the corresponding cluster in the storage device. The cluster information includes whether the cluster is used, number of the next cluster of the file, whether the file ends with the cluster. + +The FAT file system supports multiple formats, such as FAT12, FAT16, and FAT32. The numbers 12, 16, and 32 indicate the number of bits per cluster within the FAT, respectively. The FAT file system supports multiple media, especially removable media (such as USB flash drives, SD cards, and removable hard drives). The FAT file system ensures good compatibility between embedded devices and desktop systems (such as Windows and Linux) and facilitates file management. The OpenHarmony kernel supports FAT12, FAT16, and FAT32 file systems. These file systems require a tiny amount of code to implement, use less resources, support a variety of physical media, and are tailorable and compatible with Windows and Linux systems. They also support identification of multiple devices and partitions. The kernel supports multiple partitions on hard drives and allows creation of the FAT file system on the primary partition and logical partition. + ## Development Guidelines -### Adaptation of Drivers -The use of the FAT file system requires support from the underlying MultiMediaCard \(MMC\) drivers. To run FatFS on a board with an MMC storage device, you must: +### Driver Adaptation + +The use of the FAT file system requires support from the underlying MultiMedia Card (MMC) drivers. To run FatFS on a board with an MMC storage device, you must: -1. Implement the **disk\_status**, **disk\_initialize**, **disk\_read**, **disk\_write**, and **disk\_ioctl** APIs to adapt to the embedded MMC \(eMMC\) drivers on the board. +1. Implement the **disk_status**, **disk_initialize**, **disk_read**, **disk_write**, and **disk_ioctl** APIs to adapt to the embedded MMC (eMMC) drivers on the board. +2. Add the **fs_config.h** file with information such as **FS_MAX_SS** (maximum sector size of the storage device) and **FF_VOLUME_STRS** (partition names) configured. + +The following is an example: -2. Add the **fs\_config.h** file with information such as **FS\_MAX\_SS** \(maximum sector size of the storage device\) and **FF\_VOLUME\_STRS** \(partition names\) configured. The following is an example: ``` #define FF_VOLUME_STRS "system", "inner", "update", "user" @@ -22,63 +29,70 @@ The use of the FAT file system requires support from the underlying MultiMediaCa #define FAT_MAX_OPEN_FILES 50 ``` + ### How to Develop -> **NOTE**<br/> ->- Note the following when managing FatFS files and directories: -> - A file cannot exceed 4 GB. -> - **FAT\_MAX\_OPEN\_FILES** specifies the maximum number files you can open at a time, and **FAT\_MAX\_OPEN\_DIRS** specifies the maximum number of folders you can open at a time. -> - Root directory management is not supported. File and directory names start with the partition name. For example, **user/testfile** indicates the file or directory **testfile** in the **user** partition. -> - To open a file multiple times, use **O\_RDONLY** \(read-only mode\). **O\_RDWR** or **O\_WRONLY** \(writable mode\) can open a file only once. -> - The read and write pointers are not separated. If a file is open in **O\_APPEND** mode, the read pointer is also at the end of the file. If you want to read the file from the beginning, you must manually set the position of the read pointer. -> - File and directory permission management is not supported. -> - The **stat** and **fstat** APIs do not support query of the modification time, creation time, and last access time. The Microsoft FAT protocol does not support time before A.D. 1980. ->- Note the following when mounting and unmounting FatFS partitions: -> - Partitions can be mounted with the read-only attribute. When the input parameter of the **mount** function is **MS\_RDONLY**, all APIs with the write attribute, such as **write**, **mkdir**, **unlink**, and **open** with **non-O\_RDONLY** attributes, will be rejected. -> - You can use the **MS\_REMOUNT** flag with **mount** to modify the permission for a mounted partition. -> - Before unmounting a partition, ensure that all directories and files in the partition are closed. -> - You can use **umount2** with the **MNT\_FORCE** parameter to forcibly close all files and folders and unmount the partition. However, this may cause data loss. Therefore, exercise caution when running **umount2**. ->- The FAT file system supports re-partitioning and formatting of storage devices using **fatfs\_fdisk** and **fatfs\_format**. -> - If a partition is mounted before being formatted using **fatfs\_format**, you must close all directories and files in the partition and unmount the partition first. -> - Before calling **fatfs\_fdisk**, ensure that all partitions in the device are unmounted. -> - Using **fatfs\_fdisk** and **fatfs\_format** may cause data loss. Exercise caution when using them. +>  **NOTE**<br> +> +> Note the following when managing FatFS files and directories: +> - A file cannot exceed 4 GB. +> - **FAT\_MAX\_OPEN\_FILES** specifies the maximum number files you can open at a time, and **FAT\_MAX\_OPEN\_DIRS** specifies the maximum number of folders you can open at a time. +> - Root directory management is not supported. File and directory names start with the partition name. For example, **user/testfile** indicates the file or directory **testfile** in the **user** partition. +> - To open a file multiple times, use **O_RDONLY** (read-only mode). **O_RDWR** or **O_WRONLY** (writable mode) can open a file only once. +> - The read and write pointers are not separated. If a file is open in **O_APPEND** mode, the read pointer is also at the end of the file. If you want to read the file from the beginning, you must manually set the position of the read pointer. +> - File and directory permission management is not supported. +> - The **stat** and **fstat** APIs do not support query of the modification time, creation time, and last access time. The Microsoft FAT protocol does not support time before A.D. 1980. +> +> Note the following when mounting and unmounting FatFS partitions: +> - Partitions can be mounted with the read-only attribute. When the input parameter of the **mount** function is **MS_RDONLY**, all APIs with the write attribute, such as **write**, **mkdir**, **unlink**, and **open** with **non-O_RDONLY** attributes, will be rejected. +> - You can use the **MS_REMOUNT** flag with **mount** to modify the permission for a mounted partition. +> - Before unmounting a partition, ensure that all directories and files in the partition are closed. +> - You can use **umount2** with the **MNT_FORCE** parameter to forcibly close all files and folders and unmount the partition. However, this may cause data loss. Therefore, exercise caution when running **umount2**. +> +> The FAT file system supports re-partitioning and formatting of storage devices using **fatfs_fdisk** and **fatfs_format**. +> - If a partition is mounted before being formatted using **fatfs_format**, you must close all directories and files in the partition and unmount the partition first. +> - Before calling **fatfs_fdisk**, ensure that all partitions in the device are unmounted. +> - Using **fatfs_fdisk** and **fatfs_format** may cause data loss. Exercise caution when using them. + ## Development Example + ### Example Description This example implements the following: -1. Create the **user/test** directory. -2. Create the **file.txt** file in the **user/test** directory. -3. Write "Hello OpenHarmony!" at the beginning of the file. -4. Save the update of the file to the device. -5. Set the offset to the beginning of the file. -6. Read the file. -7. Close the file. -8. Delete the file. -9. Delete the directory. +1. Create the **user/test** directory. +2. Create the **file.txt** file in the **user/test** directory. +3. Write **Hello OpenHarmony!** at the beginning of the file. +4. Save the file to a device. +5. Set the offset to the start position of the file. +6. Read the file. +7. Close the file. +8. Delete the file. +9. Delete the directory. + ### Sample Code -Prerequisites +**Prerequisites** -- The MMC device partition is mounted to the **user** directory. +The MMC device partition is mounted to the **user** directory. -The sample code is as follows: + The sample code is as follows: -``` -#include <stdio.h> -#include <string.h> -#include "sys/stat.h" -#include "fcntl.h" -#include "unistd.h" + ``` + #include <stdio.h> + #include <string.h> + #include "sys/stat.h" + #include "fcntl.h" + #include "unistd.h" -#define LOS_OK 0 -#define LOS_NOK -1 + #define LOS_OK 0 + #define LOS_NOK -1 -int FatfsTest(void) -{ + int FatfsTest(void) + { int ret; int fd = -1; ssize_t len; @@ -88,14 +102,14 @@ int FatfsTest(void) char writeBuf[20] = "Hello OpenHarmony!"; char readBuf[20] = {0}; - /* Create the user/test directory.*/ + /* Create the user/test directory. */ ret = mkdir(dirName, 0777); if (ret != LOS_OK) { printf("mkdir failed.\n"); return LOS_NOK; } - /* Create the file user/test/file.txt and make it readable and writable.*/ + /* Create a readable and writable file named file.txt in the user/test/ directory. */ fd = open(fileName, O_RDWR | O_CREAT, 0777); if (fd < 0) { printf("open file failed.\n"); @@ -109,21 +123,21 @@ int FatfsTest(void) return LOS_NOK; } - /* Save the update of the file to the device.*/ + /* Save the file to a storage device. */ ret = fsync(fd); if (ret != LOS_OK) { printf("fsync failed.\n"); return LOS_NOK; } - /* Move the read/write pointer to the file header. */ + /* Move the read/write pointer to the beginning of the file. */ off = lseek(fd, 0, SEEK_SET); if (off != 0) { printf("lseek failed.\n"); return LOS_NOK; } - /* Read the file content, with the same size as readBuf, to readBuf.*/ + /* Read the file content with the length of readBuf to readBuf. */ len = read(fd, readBuf, sizeof(readBuf)); if (len != strlen(writeBuf)) { printf("read file failed.\n"); @@ -138,14 +152,14 @@ int FatfsTest(void) return LOS_NOK; } - /*Delete the file user/test/file.txt.*/ + /* Delete the file file.txt from the user/test directory. */ ret = unlink(fileName); if (ret != LOS_OK) { printf("unlink failed.\n"); return LOS_NOK; } - /*Delete the user/test directory.*/ + /* Delete the user/test directory. */ ret = rmdir(dirName); if (ret != LOS_OK) { printf("rmdir failed.\n"); @@ -153,14 +167,15 @@ int FatfsTest(void) } return LOS_OK; -} -``` + } + ``` + ### Verification The development is successful if the return result is as follows: + ``` Hello OpenHarmony! ``` - diff --git a/en/device-dev/kernel/kernel-mini-extend-file-lit.md b/en/device-dev/kernel/kernel-mini-extend-file-lit.md index 7d51b76ab3167951eeaa72d839481a4630ec2390..599c94b5a12ea632374a03fcf0ca3e03afea7d8b 100644 --- a/en/device-dev/kernel/kernel-mini-extend-file-lit.md +++ b/en/device-dev/kernel/kernel-mini-extend-file-lit.md @@ -1,15 +1,17 @@ # LittleFS + ## Basic Concepts -LittleFS is a small file system designed for flash. By combining the log-structured file system and the copy-on-write \(COW\) file system, LittleFS stores metadata in log structure and data in the COW structure. This special storage empowers LittleFS high power-loss resilience. LittleFS uses the statistical wear leveling algorithm when allocating COW data blocks, effectively prolonging the service life of flash devices. LittleFS is designed for small-sized devices with limited resources, such as ROM and RAM. All RAM resources are allocated through a buffer with the fixed size \(configurable\). That is, the RAM usage does not grow with the file system. +LittleFS is a small file system designed for flash. By combining the log-structured file system and the copy-on-write (COW) file system, LittleFS stores metadata in log structure and data in the COW structure. This special storage empowers LittleFS high power-loss resilience. LittleFS uses the statistical wear leveling algorithm when allocating COW data blocks, effectively prolonging the service life of flash devices. LittleFS is designed for small-sized devices with limited resources, such as ROM and RAM. All RAM resources are allocated through a buffer with the fixed size (configurable). That is, the RAM usage does not grow with the file system. LittleFS is a good choice when you look for a flash file system that is power-cut resilient and has wear leveling support on a small device with limited resources. ## Development Guidelines -When porting LittleFS to a new hardware device, you need to declare **lfs\_config**: +When porting LittleFS to a new hardware device, you need to declare **lfs_config**: + ``` const struct lfs_config cfg = { // block device operations @@ -29,20 +31,21 @@ const struct lfs_config cfg = { }; ``` -**.read**, **.prog**, **.erase**, and **.sync** correspond to the read, write, erase, and synchronization APIs at the bottom layer of the hardware platform, respectively. +**.read**, **.prog**, **.erase**, and **.sync** correspond to the read, write, erase, and synchronization APIs at the bottom layer of the hardware platform, respectively. -**read\_size** indicates the number of bytes read each time. You can set it to a value greater than the physical read unit to improve performance. This value determines the size of the read cache. However, if the value is too large, more memory is consumed. +**read_size** indicates the number of bytes read each time. You can set it to a value greater than the physical read unit to improve performance. This value determines the size of the read cache. However, if the value is too large, more memory is consumed. -**prog\_size** indicates the number of bytes written each time. You can set it to a value greater than the physical write unit to improve performance. This value determines the size of the write cache and must be an integral multiple of **read\_size**. However, if the value is too large, more memory is consumed. +**prog_size** indicates the number of bytes written each time. You can set it to a value greater than the physical write unit to improve performance. This value determines the size of the write cache and must be an integral multiple of **read_size**. However, if the value is too large, more memory is consumed. -**block\_size**: indicates the number of bytes in each erase block. The value can be greater than that of the physical erase unit. However, a smaller value is recommended because each file occupies at least one block. The value must be an integral multiple of **prog\_size**. +**block_size**: indicates the number of bytes in each erase block. The value can be greater than that of the physical erase unit. However, a smaller value is recommended because each file occupies at least one block. The value must be an integral multiple of **prog_size**. -**block\_count** indicates the number of blocks that can be erased, which depends on the capacity of the block device and the size of the block to be erased \(**block\_size**\). +**block_count** indicates the number of blocks that can be erased, which depends on the capacity of the block device and the size of the block to be erased (**block_size**). -## Sample Code -The sample code is as follows: +## Sample Code + The sample code is as follows: + ``` #include "lfs.h" #include "stdio.h" @@ -89,11 +92,12 @@ int main(void) { } ``` -### Verification + + **Verification** The development is successful if the return result is as follows: + ``` Say hello 1 times. ``` - diff --git a/en/device-dev/kernel/kernel-mini-memory-perf.md b/en/device-dev/kernel/kernel-mini-memory-perf.md index 3da1dd5dc276a844ed393af9b7d73bed23a4b767..95d097792307376342a55eefcfde96f7f921952b 100644 --- a/en/device-dev/kernel/kernel-mini-memory-perf.md +++ b/en/device-dev/kernel/kernel-mini-memory-perf.md @@ -3,7 +3,8 @@ ## Basic Concepts -perf is a performance analysis tool. It uses the performance monitoring unit \(PMU\) to count sampling events and collect context information and provides hot spot distribution and hot paths. +perf is a performance analysis tool. It uses the performance monitoring unit (PMU) to count sampling events and collect context information and provides hot spot distribution and hot paths. + ## Working Principles @@ -13,227 +14,142 @@ perf provides two working modes: counting mode and sampling mode. In counting mode, perf collects only the number of event occurrences and duration. In sampling mode, perf also collects context data and stores the data in a circular buffer. The IDE then analyzes the data and provides information about hotspot functions and paths. + ## Available APIs + ### Kernel Mode -The perf module of the OpenHarmony LiteOS-A kernel provides the following APIs. For more details about the APIs, see the [API](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_perf.h) reference. - -**Table 1** perf module APIs - -<a name="table209384411409"></a> -<table><thead align="left"><tr id="row49387411909"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p142345517111"><a name="p142345517111"></a><a name="p142345517111"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p16234751114"><a name="p16234751114"></a><a name="p16234751114"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p1823555614"><a name="p1823555614"></a><a name="p1823555614"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row17146213111"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p3136111817"><a name="p3136111817"></a><a name="p3136111817"></a>Starting or stopping perf sampling</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p7136415111"><a name="p7136415111"></a><a name="p7136415111"></a>LOS_PerfStart</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p16136111512"><a name="p16136111512"></a><a name="p16136111512"></a>Starts sampling.</p> -</td> -</tr> -<tr id="row5146111214"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p201361616119"><a name="p201361616119"></a><a name="p201361616119"></a>LOS_PerfStop</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1313611114117"><a name="p1313611114117"></a><a name="p1313611114117"></a>Stops sampling.</p> -</td> -</tr> -<tr id="row61461611314"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7136171816"><a name="p7136171816"></a><a name="p7136171816"></a>Configuring perf sampling events</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p161364119113"><a name="p161364119113"></a><a name="p161364119113"></a>LOS_PerfConfig</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p41361218111"><a name="p41361218111"></a><a name="p41361218111"></a>Sets the type and period of a sampling event.</p> -</td> -</tr> -<tr id="row19146619113"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p21362119112"><a name="p21362119112"></a><a name="p21362119112"></a>Reading sampling data</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p113618119118"><a name="p113618119118"></a><a name="p113618119118"></a>LOS_PerfDataRead</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1113711612"><a name="p1113711612"></a><a name="p1113711612"></a>Reads the sampling data to a specified address.</p> -</td> -</tr> -<tr id="row201465110113"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p121376114114"><a name="p121376114114"></a><a name="p121376114114"></a>Registering a hook for the sampling data buffer</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p71371011513"><a name="p71371011513"></a><a name="p71371011513"></a>LOS_PerfNotifyHookReg</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p16137618118"><a name="p16137618118"></a><a name="p16137618118"></a>Registers the hook to be called when the buffer waterline is reached.</p> -</td> -</tr> -<tr id="row13145911019"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6137317113"><a name="p6137317113"></a><a name="p6137317113"></a>LOS_PerfFlushHookReg</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p613715120114"><a name="p613715120114"></a><a name="p613715120114"></a>Registers the hook for flushing the cache in the buffer.</p> -</td> -</tr> -</tbody> -</table> - -1. The structure of the perf sampling event is **PerfConfigAttr**. For details, see **kernel\\include\\los\_perf.h**. -2. The sampling data buffer is a circular buffer, and only the region that has been read in the buffer can be overwritten. -3. The buffer has limited space. You can register a hook to provide a buffer overflow notification or perform buffer read operation when the buffer waterline is reached. The default buffer waterline is 1/2 of the buffer size. The sample code is as follows: - - ``` - VOID Example_PerfNotifyHook(VOID) - { - CHAR buf[LOSCFG_PERF_BUFFER_SIZE] = {0}; - UINT32 len; - PRINT_DEBUG("perf buffer reach the waterline!\n"); - len = LOS_PerfDataRead(buf, LOSCFG_PERF_BUFFER_SIZE); - OsPrintBuff(buf, len); /* print data */ - } - LOS_PerfNotifyHookReg(Example_PerfNotifyHook); - ``` +The Perf module of the OpenHarmony LiteOS-A kernel provides the following functions. For details about the interfaces, see the [API reference](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_perf.h). -4. If the buffer sampled by perf involves caches across CPUs, you can register a hook for flushing the cache to ensure cache consistency. The sample code is as follows: + **Table 1** APIs of the perf module - ``` - VOID Example_PerfFlushHook(VOID *addr, UINT32 size) - { - OsCacheFlush(addr, size); /* platform interface */ - } - LOS_PerfNotifyHookReg(Example_PerfFlushHook); - ``` +| API| Description| +| -------- | -------- | +| LOS_PerfStart| Starts sampling.| +| LOS_PerfStop| Stops sampling.| +| LOS_PerfConfig| Sets the event type and sampling interval.| +| LOS_PerfDataRead| Reads the sampling data.| +| LOS_PerfNotifyHookReg| Registers the hook to be called when the buffer waterline is reached.| +| LOS_PerfFlushHookReg| Registers the hook for flushing the cache in the buffer.| + +- The structure of the perf sampling event is **PerfConfigAttr**. For details, see **kernel\include\los_perf.h**. + +- The sampling data buffer is a circular buffer, and only the region that has been read in the buffer can be overwritten. - The API for flushing the cache is configured based on the platform. +- The buffer has limited space. You can register a hook to provide a buffer overflow notification or perform buffer read operation when the buffer waterline is reached. The default buffer waterline is 1/2 of the buffer size. + + Example: + + ``` + VOID Example_PerfNotifyHook(VOID) + { + CHAR buf[LOSCFG_PERF_BUFFER_SIZE] = {0}; + UINT32 len; + PRINT_DEBUG("perf buffer reach the waterline!\n"); + len = LOS_PerfDataRead(buf, LOSCFG_PERF_BUFFER_SIZE); + OsPrintBuff(buf, len); /* print data */ + } + LOS_PerfNotifyHookReg(Example_PerfNotifyHook); + ``` + +- If the buffer sampled by perf involves caches across CPUs, you can register a hook for flushing the cache to ensure cache consistency. + + Example: + + ``` + VOID Example_PerfFlushHook(VOID *addr, UINT32 size) + { + OsCacheFlush(addr, size); /* platform interface */ + } + LOS_PerfNotifyHookReg(Example_PerfFlushHook); + ``` + + The API for flushing the cache is configured based on the platform. ### User Mode -The perf character device is located in **/dev/perf**. You can read, write, and control the user-mode perf by running the following commands on the device node: -- **read**: reads perf data in user mode. -- **write**: writes user-mode sampling events. -- **ioctl**: controls the user-mode perf, which includes the following: +The perf character device is located in **/dev/perf**. You can read, write, and control the user-mode perf by running the following commands on the device node: + - ``` - #define PERF_IOC_MAGIC 'T' - #define PERF_START _IO(PERF_IOC_MAGIC, 1) - #define PERF_STOP _IO(PERF_IOC_MAGIC, 2) - ``` +- **read**: reads perf data in user mode. - The operations correspond to **LOS\_PerfStart** and **LOS\_PerfStop**. +- **write**: writes user-mode sampling events. +- **ioctl**: controls the user-mode perf, which includes the following: + + ``` + #define PERF_IOC_MAGIC 'T' + #define PERF_START _IO(PERF_IOC_MAGIC, 1) + #define PERF_STOP _IO(PERF_IOC_MAGIC, 2) + ``` -For more details, see [User-mode Development Example](#user-mode-development-example). + The operations correspond to **LOS_PerfStart** and **LOS_PerfStop**. -## Development Guidelines -### Kernel-mode Development Process +For details, see [User-Mode Development Example](#user-mode-development-example). + + +## How to Develop + + +### Kernel-Mode Development Process The typical process of enabling perf is as follows: -1. Configure the macros related to the perf module. - - Configure the perf control macro **LOSCFG\_KERNEL\_PERF**, which is disabled by default. In the **kernel/liteos\_a** directory, run the **make update\_config** command, choose **Kernel**, and select **Enable Perf Feature**. - - <a name="table06964569614"></a> - <table><thead align="left"><tr id="row1697105618610"><th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.1"><p id="p669715610619"><a name="p669715610619"></a><a name="p669715610619"></a>Macro</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.2"><p id="p0697105612614"><a name="p0697105612614"></a><a name="p0697105612614"></a>menuconfig Option</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.3"><p id="p5697175610610"><a name="p5697175610610"></a><a name="p5697175610610"></a>Description</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.4"><p id="p1269712561866"><a name="p1269712561866"></a><a name="p1269712561866"></a>Value</p> - </th> - </tr> - </thead> - <tbody><tr id="row48579520718"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p138411959715"><a name="p138411959715"></a><a name="p138411959715"></a>LOSCFG_KERNEL_PERF</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p6841151471"><a name="p6841151471"></a><a name="p6841151471"></a>Enable Perf Feature</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p128411551271"><a name="p128411551271"></a><a name="p128411551271"></a>Whether to enable perf.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p1584116513713"><a name="p1584116513713"></a><a name="p1584116513713"></a>YES/NO</p> - </td> - </tr> - <tr id="row14856135172"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p10841145172"><a name="p10841145172"></a><a name="p10841145172"></a>LOSCFG_PERF_CALC_TIME_BY_TICK</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p6841751173"><a name="p6841751173"></a><a name="p6841751173"></a>Time-consuming Calc Methods->By Tick</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p188417515713"><a name="p188417515713"></a><a name="p188417515713"></a>Whether to use tick as the perf timing unit.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p28421251079"><a name="p28421251079"></a><a name="p28421251079"></a>YES/NO</p> - </td> - </tr> - <tr id="row08561858720"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p2842195177"><a name="p2842195177"></a><a name="p2842195177"></a>LOSCFG_PERF_CALC_TIME_BY_CYCLE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p148421551373"><a name="p148421551373"></a><a name="p148421551373"></a>Time-consuming Calc Methods->By Cpu Cycle</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p148421751575"><a name="p148421751575"></a><a name="p148421751575"></a>Whether to use cycle as the perf timing unit.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p7842551970"><a name="p7842551970"></a><a name="p7842551970"></a>YES/NO</p> - </td> - </tr> - <tr id="row168562511717"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p18842205871"><a name="p18842205871"></a><a name="p18842205871"></a>LOSCFG_PERF_BUFFER_SIZE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p128421655716"><a name="p128421655716"></a><a name="p128421655716"></a>Perf Sampling Buffer Size</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p88424511719"><a name="p88424511719"></a><a name="p88424511719"></a>Size of the buffer used for perf sampling.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p28421455716"><a name="p28421455716"></a><a name="p28421455716"></a>INT</p> - </td> - </tr> - <tr id="row685645671"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p1084245472"><a name="p1084245472"></a><a name="p1084245472"></a>LOSCFG_PERF_HW_PMU</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p11842651976"><a name="p11842651976"></a><a name="p11842651976"></a>Enable Hardware Pmu Events for Sampling</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p5842651971"><a name="p5842651971"></a><a name="p5842651971"></a>Whether to enable hardware PMU events. The target platform must support the hardware PMU.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p17842350713"><a name="p17842350713"></a><a name="p17842350713"></a>YES/NO</p> - </td> - </tr> - <tr id="row2085695779"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p148421951574"><a name="p148421951574"></a><a name="p148421951574"></a>LOSCFG_PERF_TIMED_PMU</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p16842115373"><a name="p16842115373"></a><a name="p16842115373"></a>Enable Hrtimer Period Events for Sampling</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p11842135973"><a name="p11842135973"></a><a name="p11842135973"></a>Whether to enable high-precision periodical events. The target platform must support the high precision event timer (HPET).</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p1784205875"><a name="p1784205875"></a><a name="p1784205875"></a>YES/NO</p> - </td> - </tr> - <tr id="row108562511719"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p684218515717"><a name="p684218515717"></a><a name="p684218515717"></a>LOSCFG_PERF_SW_PMU</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p284275473"><a name="p284275473"></a><a name="p284275473"></a>Enable Software Events for Sampling</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p184214514715"><a name="p184214514715"></a><a name="p184214514715"></a>Whether to enable software events. <strong id="b947154317012"><a name="b947154317012"></a><a name="b947154317012"></a>LOSCFG_KERNEL_HOOK</strong> must also be enabled.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p16896951459"><a name="p16896951459"></a><a name="p16896951459"></a>YES/NO</p> - </td> - </tr> - </tbody> - </table> - -2. Call **LOS\_PerfConfig** to configure the events to be sampled. - - perf provides two working modes and three types of events. - - Two modes: counting mode \(counts only the number of event occurrences\) and sampling mode \(collects context information such as task IDs, PC, and backtrace\) - - Three types of events: CPU hardware events \(such as cycle, branch, icache, and dcache\), high-precision periodical events \(such as CPU clock\), and OS software events \(such as task switch, mux pend, and IRQ\) - -3. Call **LOS\_PerfStart\(UINT32 sectionId\)** at the start of the code to be sampled. The input parameter **sectionId** specifies different sampling session IDs. -4. Call **LOS\_PerfStop** at the end of the code to be sampled. -5. Call **LOS\_PerfDataRead** to read the sampling data and use IDE to analyze the collected data. - -## Kernel-mode Development Example +1. Configure the macros related to the perf module. + + Configure the perf control macro **LOSCFG_KERNEL_PERF**, which is disabled by default. In the **kernel/liteos_a** directory, run the **make update_config** command, choose **Kernel**, and select **Enable Perf Feature**. + + | Item| menuconfig Option| Description| Value| + | -------- | -------- | -------- | -------- | + | LOSCFG_KERNEL_PERF | Enable Perf Feature | Whether to enable perf.| YES/NO | + | LOSCFG_PERF_CALC_TIME_BY_TICK | Time-consuming Calc Methods->By Tick | Whether to use tick as the perf timing unit.| YES/NO | + | LOSCFG_PERF_CALC_TIME_BY_CYCLE | Time-consuming Calc Methods->By Cpu Cycle | Whether to use cycle as the perf timing unit.| YES/NO | + | LOSCFG_PERF_BUFFER_SIZE | Perf Sampling Buffer Size | Size of the buffer used for perf sampling.| INT | + | LOSCFG_PERF_HW_PMU | Enable Hardware Pmu Events for Sampling | Whether to enable hardware PMU events. The target platform must support the hardware PMU.| YES/NO | + | LOSCFG_PERF_TIMED_PMU | Enable Hrtimer Period Events for Sampling | Whether to enable high-precision periodical events. The target platform must support the high precision event timer (HPET).| YES/NO | + | LOSCFG_PERF_SW_PMU | Enable Software Events for Sampling | Whether to enable software events. **LOSCFG_KERNEL_HOOK** must also be enabled.| YES/NO | + +2. Call **LOS_PerfConfig** to configure the events to be sampled. + + perf provides two working modes and three types of events. + + Working modes: counting mode (counts only the number of event occurrences) and sampling mode (collects context information such as task IDs, PC, and backtrace) + + Events: CPU hardware events (such as cycle, branch, icache, and dcache), high-precision periodical events (such as CPU clock), and OS software events (such as task switch, mux pend, and IRQ) + +3. Call **LOS_PerfStart(UINT32 sectionId)** at the start of the code to be sampled. The input parameter **sectionId** specifies different sampling session IDs. + +4. Call **LOS_PerfStop** at the end of the code to be sampled. + +5. Call **LOS_PerfDataRead** to read the sampling data and use IDE to analyze the collected data. + + +#### Kernel-Mode Development Example This example implements the following: -1. Create a perf task. -2. Configure sampling events. -3. Start perf. -4. Execute algorithms for statistics. -5. Stop perf. -6. Export the result. +1. Create a perf task. -## Kernel-mode Sample Code +2. Configure sampling events. -Prerequisites: The perf module configuration is complete in **menuconfig**. +3. Start perf. -The code is as follows: +4. Execute algorithms for statistics. + +5. Stop perf. + +6. Export the result. + + +#### Kernel-Mode Sample Code + +Prerequisites: The perf module configuration is complete in **menuconfig**. + +The sample code is as follows: ``` #include "los_perf.h" @@ -299,10 +215,10 @@ STATIC VOID perfTestHwEvent(VOID) UINT32 Example_Perf_test(VOID){ UINT32 ret; TSK_INIT_PARAM_S perfTestTask; - /* Create a perf task.*/ + /* Create a perf task. */ memset(&perfTestTask, 0, sizeof(TSK_INIT_PARAM_S)); perfTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)perfTestHwEvent; - perfTestTask.pcName = "TestPerfTsk"; /* Task name.*/ + perfTestTask.pcName = "TestPerfTsk"; /* Test task name. */ perfTestTask.uwStackSize = 0x800; perfTestTask.usTaskPrio = 5; perfTestTask.uwResved = LOS_TASK_STATUS_DETACHED; @@ -316,9 +232,10 @@ UINT32 Example_Perf_test(VOID){ LOS_MODULE_INIT(perfTestHwEvent, LOS_INIT_LEVEL_KMOD_EXTENDED); ``` -### Kernel-mode Verification -The output is as follows: +#### Kernel-Mode Verification + + The output is as follows: ``` --------count mode---------- @@ -330,48 +247,50 @@ num: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 hex: 00 ef ef ef 00 00 00 00 14 00 00 00 60 00 00 00 00 00 00 00 70 88 36 40 08 00 00 00 6b 65 72 6e 65 6c 00 00 01 00 00 00 cc 55 30 40 08 00 00 00 6b 65 72 6e 65 6c 00 00 ``` -- For the counting mode, the following information is displayed after perf is stopped: - - Event name \(cycles\), event type \(0xff\), and number of event occurrences \(5466989440\) +- For the counting mode, the following information is displayed after perf is stopped: + Event name (cycles), event type (0xff), and number of event occurrences (5466989440) - For hardware PMU events, the displayed event type is the hardware event ID, not the abstract type defined in **enum PmuHWId**. + For hardware PMU events, the displayed event type is the hardware event ID, not the abstract type defined in **enum PmuHWId**. -- For the sampling mode, the address and length of the sampled data will be displayed after perf is stopped: +- For the sampling mode, the address and length of the sampled data will be displayed after perf is stopped: + dump section data, addr: (0x8000000) length: (0x5000) - dump section data, addr: \(0x8000000\) length: \(0x5000\) + You can export the data using the JTAG interface and then use the IDE offline tool to analyze the data. - You can export the data using the JTAG interface and then use the IDE offline tool to analyze the data. + You can also call **LOS_PerfDataRead** to read data to a specified address for further analysis. In the example, **OsPrintBuff** is a test API, which prints the sampled data by byte. **num** indicates the sequence number of the byte, and **hex** indicates the value in the byte. - You can also call **LOS\_PerfDataRead** to read data to a specified address for further analysis. In the example, **OsPrintBuff** is a test API, which prints the sampled data by byte. **num** indicates the sequence number of the byte, and **hex** indicates the value in the byte. +### User-Mode Development Process -### User-mode Development Process +Choose **Driver** > **Enable PERF DRIVER** in **menuconfig** to enable the perf driver. This option is available in **Driver** only after **Enable Perf Feature** is selected in the kernel. -Choose **Driver** \> **Enable PERF DRIVER** in **menuconfig** to enable the perf driver. This option is available in **Driver** only after **Enable Perf Feature** is selected in the kernel. +1. Open the **/dev/perf** file and perform read, write, and ioctl operations. -1. Open the **/dev/perf** file and perform read, write, and ioctl operations. -2. Run the **perf** commands in user mode in the **/bin** directory. After running **cd bin**, you can use the following commands: - - **./perf start \[_id_\]**: starts perf sampling. _id_ is optional and is **0** by default. - - **./perf stop**: stops perf sampling. - - **./perf read <_nBytes_\>**: reads n-byte data from the sampling buffer and displays the data. - - **./perf list**: lists the events supported by **-e**. - - **./perf stat/record \[_option_\] <_command_\>**: sets counting or sampling parameters. - - The \[_option_\] can be any of the following: - - **-e**: sets sampling events. Events of the same type listed in **./perf list** can be used. - - **-p**: sets the event sampling interval. - - **-o**: specifies the path of the file for saving the perf sampling data. - - **-t**: specifies the task IDs for data collection. Only the contexts of the specified tasks are collected. If this parameter is not specified, all tasks are collected by default. - - **-s**: specifies the context type for sampling. For details, see **PerfSampleType** defined in **los\_perf.h**. - - **-P**: specifies the process IDs for data collection. Only the contexts of the specified processes are collected. If this parameter is not specified, all processes are collected by default. - - **-d**: specifies whether to divide the frequency \(the value is incremented by 1 each time an event occurs 64 times\). This option is valid only for hardware cycle events. - - - _command_ specifies the program to be checked by perf. +2. Run the **perf** commands in user mode in the **/bin** directory. + + After running **cd bin**, you can use the following commands: + + - **./perf start [*id*]**: starts perf sampling. *id* is optional and is **0** by default. + - **./perf stop**: stops perf sampling. + - **./perf read <*nBytes*>**: reads n-byte data from the sampling buffer and displays the data. + - **./perf list**: lists the events supported by **-e**. + - **./perf stat/record [*option*] <*command*>**: sets counting or sampling parameters. + - The [*option*] can be any of the following: + - -**-e**: sets sampling events. Events of the same type listed in **./perf list** can be used. + - -**-p**: sets the event sampling interval. + - -**-o**: specifies the path of the file for saving the perf sampling data. + - -**-t**: specifies the task IDs for data collection. Only the contexts of the specified tasks are collected. If this parameter is not specified, all tasks are collected by default. + - -**-s**: specifies the context type for sampling. For details, see **PerfSampleType** defined in **los_perf.h**. + - -**-P**: specifies the process IDs for data collection. Only the contexts of the specified processes are collected. If this parameter is not specified, all processes are collected by default. + - -**-d**: specifies whether to divide the frequency (the value is incremented by 1 each time an event occurs 64 times). This option is valid only for hardware cycle events. + - *command* specifies the program to be checked by perf. +Examples: +Run the **./perf list** command to display available events. -Examples: +The output is as follows: -Run the **./perf list** command to display available events. The output is as follows: ``` cycles [Hardware event] @@ -389,7 +308,10 @@ mem-alloc [Software event] mux-pend [Software event] ``` -Run **./perf stat -e cycles os\_dump**. The output is as follows: +Run **./perf stat -e cycles os_dump**. + +The output is as follows: + ``` type: 0 @@ -406,7 +328,10 @@ time used: 0.058000(s) [cycles] eventType: 0xff [core 1]: 13583830 ``` -Run **./perf record -e cycles os\_dump**. The output is as follows: +Run **./perf record -e cycles os_dump**. + +The output is as follows: + ``` type: 0 @@ -423,22 +348,28 @@ time used: 0.059000(s) save perf data success at /storage/data/perf.data ``` -> **NOTE**<br/> ->After running the **./perf stat/record** command, you can run the **./perf start** and **./perf stop** commands multiple times. The sampling event configuration is as per the parameters set in the latest **./perfstat/record** command. +>  **NOTE**<br> +> After running the **./perf stat/record** command, you can run the **./perf start** and **./perf stop** commands multiple times. The sampling event configuration is as per the parameters set in the latest **./perfstat/record** command. + -### User-mode Development Example +#### User-Mode Development Example This example implements the following: -1. Open the perf character device. -2. Write the perf events. -3. Start perf. -4. Stop perf. -5. Read the perf sampling data. +1. Open the perf character device. + +2. Write the perf events. -### User-Mode Sample Code +3. Start perf. -The code is as follows: +4. Stop perf. + +5. Read the perf sampling data. + + +#### User-Mode Sample Code + + The code is as follows: ``` #include "fcntl.h" @@ -506,13 +437,13 @@ int main(int argc, char **argv) } ``` -### User-mode Verification -The output is as follows: +#### User-Mode Verification + + The output is as follows: ``` [EMG] dump section data, addr: 0x8000000 length: 0x800000 num: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 ... hex: 00 ef ef ef 00 00 00 00 14 00 00 00 60 00 00 00 00 00 00 00 70 88 36 40 08 00 00 00 6b 65 72 6e 65 6c 00 00 01 00 00 00 cc 55 30 40 08 00 00 00 6b 65 72 6e 65 6c 00 00 ``` - diff --git a/en/device-dev/kernel/kernel-mini-overview.md b/en/device-dev/kernel/kernel-mini-overview.md index 7b86f1a82028e03366eb3441d6257eb7791764c3..a1b7902c802ad44bac6477e73757955d4611aecf 100644 --- a/en/device-dev/kernel/kernel-mini-overview.md +++ b/en/device-dev/kernel/kernel-mini-overview.md @@ -1,59 +1,35 @@ # Kernel Overview + ## Overview -The OpenHarmony LiteOS-M kernel is a lightweight operating system \(OS\) kernel designed for the IoT field. It features small size, low power consumption, and high performance. The LiteOS-M kernel has simple code structure, including the minimum function set, kernel abstraction layer \(KAL\), optional components, and project directory. It supports the Hardware Driver Foundation \(HDF\), which provides unified driver standards and access mode for device vendors to simplify porting of drivers and allow one-time development for multi-device deployment. +The OpenHarmony LiteOS-M kernel is a lightweight operating system (OS) kernel designed for the IoT field. It features small size, low power consumption, and high performance. The LiteOS-M kernel has simple code structure, including the minimum function set, kernel abstraction layer (KAL), optional components, and project directory. It supports the Hardware Driver Foundation (HDF), which provides unified driver standards and access mode for device vendors to simplify porting of drivers and allow one-time development for multi-device deployment. + +The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in the figure below. The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer (HAL) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs. -The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and hardware-irrelevant layers, as shown in the figure below. The hardware layer is classified based on the compiler toolchain and chip architecture, and provides a unified Hardware Abstraction Layer \(HAL\) interface to improve hardware adaptation and facilitate the expansion of various types of AIoT hardware and compilation toolchains. The other modules are irrelevant to the hardware. The basic kernel module provides basic kernel capabilities. The extended modules provide capabilities of components, such as the network and file systems, as well as exception handling and debug tools. The KAL provides unified standard APIs. + **Figure 1** Kernel architecture -**Figure 1** Kernel architecture - +  -### CPU Architecture Support + +## CPU Architecture Support The CPU architecture includes two layers: general architecture definition layer and specific architecture definition layer. The former provides interfaces supported and implemented by all architectures. The latter is specific to an architecture. For a new architecture to be added, the general architecture definition layer must be implemented first and the architecture-specific functions can be implemented at the specific architecture definition layer. -**Table 1** CPU architecture rules - -<a name="table577192233214"></a> -<table><thead align="left"><tr id="row977192213323"><th class="cellrowborder" valign="top" width="21.592159215921594%" id="mcps1.2.4.1.1"><p id="p15771422123213"><a name="p15771422123213"></a><a name="p15771422123213"></a>Rule</p> -</th> -<th class="cellrowborder" valign="top" width="34.713471347134714%" id="mcps1.2.4.1.2"><p id="p57782211323"><a name="p57782211323"></a><a name="p57782211323"></a>General Architecture Definition Layer</p> -</th> -<th class="cellrowborder" valign="top" width="43.694369436943695%" id="mcps1.2.4.1.3"><p id="p977132223217"><a name="p977132223217"></a><a name="p977132223217"></a>Specific Architecture Definition Layer</p> -</th> -</tr> -</thead> -<tbody><tr id="row1577522103217"><td class="cellrowborder" valign="top" width="21.592159215921594%" headers="mcps1.2.4.1.1 "><p id="p378152243213"><a name="p378152243213"></a><a name="p378152243213"></a>Header file location</p> -</td> -<td class="cellrowborder" valign="top" width="34.713471347134714%" headers="mcps1.2.4.1.2 "><p id="p37819227320"><a name="p37819227320"></a><a name="p37819227320"></a>arch/include</p> -</td> -<td class="cellrowborder" valign="top" width="43.694369436943695%" headers="mcps1.2.4.1.3 "><p id="p9783225321"><a name="p9783225321"></a><a name="p9783225321"></a>arch/<arch>/<arch>/<toolchain>/</p> -</td> -</tr> -<tr id="row16781422193218"><td class="cellrowborder" valign="top" width="21.592159215921594%" headers="mcps1.2.4.1.1 "><p id="p978112283215"><a name="p978112283215"></a><a name="p978112283215"></a>Header file name</p> -</td> -<td class="cellrowborder" valign="top" width="34.713471347134714%" headers="mcps1.2.4.1.2 "><p id="p2781322193210"><a name="p2781322193210"></a><a name="p2781322193210"></a>los_<function>.h</p> -</td> -<td class="cellrowborder" valign="top" width="43.694369436943695%" headers="mcps1.2.4.1.3 "><p id="p912752623513"><a name="p912752623513"></a><a name="p912752623513"></a>los_arch_<function>.h</p> -</td> -</tr> -<tr id="row207882213215"><td class="cellrowborder" valign="top" width="21.592159215921594%" headers="mcps1.2.4.1.1 "><p id="p10789229321"><a name="p10789229321"></a><a name="p10789229321"></a>Function name</p> -</td> -<td class="cellrowborder" valign="top" width="34.713471347134714%" headers="mcps1.2.4.1.2 "><p id="p1778202218329"><a name="p1778202218329"></a><a name="p1778202218329"></a>Halxxxx</p> -</td> -<td class="cellrowborder" valign="top" width="43.694369436943695%" headers="mcps1.2.4.1.3 "><p id="p207817224327"><a name="p207817224327"></a><a name="p207817224327"></a>Halxxxx</p> -</td> -</tr> -</tbody> -</table> - -LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see [Chip Architecture Adaptation](../porting/porting-chip-kernel-overview.md#section137431650339). - -### Working Principles - -Configure the system clock and number of ticks per second in the **target\_config.h** file of the development board. Configure the task, memory, inter-process communication \(IPC\), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below. - -**Figure 2** Kernel startup process - + **Table 1** CPU architecture rules + +| Rule| General Architecture Layer| Specific Architecture Layer| +| -------- | -------- | -------- | +| Header file location| arch/include | arch/<arch>/<arch>/<toolchain>/ | +| Header file name| los_<function>.h | los_arch_<function>.h | +| Function name| Halxxxx | Halxxxx | + +LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see [Chip Architecture Adaptation](../porting/porting-chip-kernel-overview.md). + + +## Working Principles + +In the **target\_config.h** file of the development board, configure the system clock and number of ticks per second, and configure the task, memory, inter-process communication (IPC), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot, as shown in the figure below. + **Figure 2** Kernel startup process<br> +  diff --git a/en/device-dev/kernel/kernel-small-apx-dll.md b/en/device-dev/kernel/kernel-small-apx-dll.md index 2e7bb0d0fadcf92e14ea957b89728e240542c18a..e33e8e55d65e6a5e39fbb33e154557e2751148e9 100644 --- a/en/device-dev/kernel/kernel-small-apx-dll.md +++ b/en/device-dev/kernel/kernel-small-apx-dll.md @@ -1,178 +1,69 @@ # Doubly Linked List - ## Basic Concepts -A doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains a pointer to the previous node and a pointer to the next node in the sequence of nodes. The pointer head is unique. A doubly linked list allows access from a list node to its next node and also the previous node on the list. This data structure facilitates data search, especially traversal of a large amount of data. The symmetry of the doubly linked list also makes operations, such as insertion and deletion, easy. However, pay attention to the pointer direction when performing operations. +A doubly linked list (DLL) is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains a pointer to the previous node and a pointer to the next node in the sequence of nodes. The pointer head is unique. A DLL allows access from a list node to its next node and also the previous node on the list. This data structure facilitates data search, especially traversal of a large amount of data. The symmetry of the DLL also makes operations, such as insertion and deletion, easy. However, pay attention to the pointer direction when performing operations. + ## Available APIs -The following table describes APIs available for the doubly linked list. For more details about the APIs, see the API reference. - -<a name="table9827162254713"></a> -<table><tbody><tr id="row2089515228470"><td class="cellrowborder" valign="top" width="8.14%"><p id="p4895182214473"><a name="p4895182214473"></a><a name="p4895182214473"></a>Function</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p58951922124713"><a name="p58951922124713"></a><a name="p58951922124713"></a>API</p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p5895122134719"><a name="p5895122134719"></a><a name="p5895122134719"></a>Description</p> -</td> -</tr> -<tr id="row20895152284710"><td class="cellrowborder" rowspan="2" valign="top" width="8.14%"><p id="p18951922144714"><a name="p18951922144714"></a><a name="p18951922144714"></a>Initializing a linked list</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p789516220474"><a name="p789516220474"></a><a name="p789516220474"></a><span>LOS_ListInit</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p38951422144710"><a name="p38951422144710"></a><a name="p38951422144710"></a>Initializes a specified node as a doubly linked list node.</p> -</td> -</tr> -<tr id="row289552216475"><td class="cellrowborder" valign="top"><p id="p11895222194718"><a name="p11895222194718"></a><a name="p11895222194718"></a><span>LOS_DL_LIST_HEAD</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p3895222184710"><a name="p3895222184710"></a><a name="p3895222184710"></a>Defines a node and initializes it as a doubly linked list node.</p> -</td> -</tr> -<tr id="row1689522210476"><td class="cellrowborder" rowspan="3" valign="top" width="8.14%"><p id="p12896132294720"><a name="p12896132294720"></a><a name="p12896132294720"></a>Adding a node</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p789611221477"><a name="p789611221477"></a><a name="p789611221477"></a><span>LOS_ListAdd</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p9896122134715"><a name="p9896122134715"></a><a name="p9896122134715"></a>Inserts the specified node to the head of a doubly linked list.</p> -</td> -</tr> -<tr id="row191212010315"><td class="cellrowborder" valign="top"><p id="p14135012318"><a name="p14135012318"></a><a name="p14135012318"></a>LOS_ListHeadInsert</p> -</td> -<td class="cellrowborder" valign="top"><p id="p4138202417318"><a name="p4138202417318"></a><a name="p4138202417318"></a>Inserts the specified node to the head of a doubly linked list. It is the same as <strong id="b1391981116212"><a name="b1391981116212"></a><a name="b1391981116212"></a>LOS_ListAdd</strong>.</p> -</td> -</tr> -<tr id="row188961225475"><td class="cellrowborder" valign="top"><p id="p18961122154718"><a name="p18961122154718"></a><a name="p18961122154718"></a><span>LOS_ListTailInsert</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p188961322144712"><a name="p188961322144712"></a><a name="p188961322144712"></a>Inserts the specified node to the end of a doubly linked list.</p> -</td> -</tr> -<tr id="row15357444193310"><td class="cellrowborder" rowspan="3" valign="top" width="8.14%"><p id="p1692010363413"><a name="p1692010363413"></a><a name="p1692010363413"></a>Adding a linked list</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p1735715449336"><a name="p1735715449336"></a><a name="p1735715449336"></a>LOS_ListAddList</p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p6622934203610"><a name="p6622934203610"></a><a name="p6622934203610"></a>Inserts the head of a specified linked list into the head of a doubly linked list.</p> -</td> -</tr> -<tr id="row15195047123311"><td class="cellrowborder" valign="top"><p id="p17195124711336"><a name="p17195124711336"></a><a name="p17195124711336"></a>LOS_ListHeadInsertList</p> -</td> -<td class="cellrowborder" valign="top"><p id="p185641532153916"><a name="p185641532153916"></a><a name="p185641532153916"></a>Inserts the head of a specified linked list into the head of a doubly linked list. It is the same as <strong id="b14274399311"><a name="b14274399311"></a><a name="b14274399311"></a>LOS_ListAddList</strong>.</p> -</td> -</tr> -<tr id="row144801751153310"><td class="cellrowborder" valign="top"><p id="p1048055153313"><a name="p1048055153313"></a><a name="p1048055153313"></a>LOS_ListTailInsertList</p> -</td> -<td class="cellrowborder" valign="top"><p id="p13855544153914"><a name="p13855544153914"></a><a name="p13855544153914"></a>Inserts the end of a specified linked list into the head of a doubly linked list.</p> -</td> -</tr> -<tr id="row5896112264710"><td class="cellrowborder" rowspan="2" valign="top" width="8.14%"><p id="p28961122174717"><a name="p28961122174717"></a><a name="p28961122174717"></a>Deleting a node</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p28961422154710"><a name="p28961422154710"></a><a name="p28961422154710"></a><span>LOS_ListDelete</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p289610224473"><a name="p289610224473"></a><a name="p289610224473"></a>Deletes the specified node from a doubly linked list.</p> -</td> -</tr> -<tr id="row3896522124711"><td class="cellrowborder" valign="top"><p id="p0896152213471"><a name="p0896152213471"></a><a name="p0896152213471"></a><span>LOS_ListDelInit</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p48965226475"><a name="p48965226475"></a><a name="p48965226475"></a>Deletes the specified node from the linked list and uses the node to initialize the linked list.</p> -</td> -</tr> -<tr id="row1689602294714"><td class="cellrowborder" rowspan="3" valign="top" width="8.14%"><p id="p18961222164716"><a name="p18961222164716"></a><a name="p18961222164716"></a>Determining a doubly linked list</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p78961522184715"><a name="p78961522184715"></a><a name="p78961522184715"></a><span>LOS_ListEmpty</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p16896172254720"><a name="p16896172254720"></a><a name="p16896172254720"></a>Checks whether a linked list is empty.</p> -</td> -</tr> -<tr id="row18516729174116"><td class="cellrowborder" valign="top"><p id="p17517829184112"><a name="p17517829184112"></a><a name="p17517829184112"></a>LOS_DL_LIST_IS_END</p> -</td> -<td class="cellrowborder" valign="top"><p id="p6517142944113"><a name="p6517142944113"></a><a name="p6517142944113"></a>Checks whether the specified linked list node is at the end of the linked list.</p> -</td> -</tr> -<tr id="row893214104211"><td class="cellrowborder" valign="top"><p id="p149321243429"><a name="p149321243429"></a><a name="p149321243429"></a>LOS_DL_LIST_IS_ON_QUEUE</p> -</td> -<td class="cellrowborder" valign="top"><p id="p393211444212"><a name="p393211444212"></a><a name="p393211444212"></a>Checks whether the linked list node is in a doubly linked list.</p> -</td> -</tr> -<tr id="row128977221474"><td class="cellrowborder" rowspan="5" valign="top" width="8.14%"><p id="p138971322174717"><a name="p138971322174717"></a><a name="p138971322174717"></a>Obtaining structure information</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p138971922194712"><a name="p138971922194712"></a><a name="p138971922194712"></a><span>LOS_OFF_SET_OF</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p08971022144720"><a name="p08971022144720"></a><a name="p08971022144720"></a>Obtains the offset of a member in a specified structure relative to the start address of the structure.</p> -</td> -</tr> -<tr id="row17897102264718"><td class="cellrowborder" valign="top"><p id="p222185817011"><a name="p222185817011"></a><a name="p222185817011"></a><span>LOS_DL_LIST_ENTRY</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p165524542002"><a name="p165524542002"></a><a name="p165524542002"></a>Obtains the address of the structure that contains the first node in the linked list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure.</p> -</td> -</tr> -<tr id="row15461471406"><td class="cellrowborder" valign="top"><p id="p1889792218473"><a name="p1889792218473"></a><a name="p1889792218473"></a>LOS_ListPeekHeadType</p> -</td> -<td class="cellrowborder" valign="top"><p id="p111876351019"><a name="p111876351019"></a><a name="p111876351019"></a>Obtains the address of the structure that contains the first node in the linked list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure. Return Null if the linked list is empty.</p> -</td> -</tr> -<tr id="row203104014114"><td class="cellrowborder" valign="top"><p id="p18321540016"><a name="p18321540016"></a><a name="p18321540016"></a>LOS_ListRemoveHeadType</p> -</td> -<td class="cellrowborder" valign="top"><p id="p913828651"><a name="p913828651"></a><a name="p913828651"></a>Obtains the address of the structure that contains the first node in the linked list, and deletes the first node from the list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure. Return Null if the linked list is empty.</p> -</td> -</tr> -<tr id="row745116416618"><td class="cellrowborder" valign="top"><p id="p1645217411963"><a name="p1645217411963"></a><a name="p1645217411963"></a>LOS_ListNextType</p> -</td> -<td class="cellrowborder" valign="top"><p id="p972412565619"><a name="p972412565619"></a><a name="p972412565619"></a>Obtains the address of the structure that contains the next node of the specified node in the linked list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the specified node, the third parameter indicates the name of the structure to be obtained, and the fourth input parameter indicates the name of the linked list in the structure. If the next node of the linked list node is the head node and is empty, NULL is returned.</p> -</td> -</tr> -<tr id="row4897192254715"><td class="cellrowborder" rowspan="2" valign="top" width="8.14%"><p id="p3897922164714"><a name="p3897922164714"></a><a name="p3897922164714"></a>Traversing a doubly linked list</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p58971222194713"><a name="p58971222194713"></a><a name="p58971222194713"></a><span>LOS_DL_LIST_FOR_EACH</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p28971222194714"><a name="p28971222194714"></a><a name="p28971222194714"></a>Traverses a doubly linked list.</p> -</td> -</tr> -<tr id="row589792254710"><td class="cellrowborder" valign="top"><p id="p689792264718"><a name="p689792264718"></a><a name="p689792264718"></a><span>LOS_DL_LIST_FOR_EACH_SAFE</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p148975222479"><a name="p148975222479"></a><a name="p148975222479"></a>Traverses a doubly linked list, and stores the next node of the current node for security verification.</p> -</td> -</tr> -<tr id="row208971622174718"><td class="cellrowborder" rowspan="2" valign="top" width="8.14%"><p id="p168977224474"><a name="p168977224474"></a><a name="p168977224474"></a>Traversing the structure that contains the doubly linked list</p> -</td> -<td class="cellrowborder" valign="top" width="32.09%"><p id="p1489752216479"><a name="p1489752216479"></a><a name="p1489752216479"></a><span>LOS_DL_LIST_FOR_EACH_ENTRY</span></p> -</td> -<td class="cellrowborder" valign="top" width="59.77%"><p id="p10897522194717"><a name="p10897522194717"></a><a name="p10897522194717"></a>Traverses the specified doubly linked list and obtains the address of the structure that contains the linked list node.</p> -</td> -</tr> -<tr id="row10897622104713"><td class="cellrowborder" valign="top"><p id="p2897112215478"><a name="p2897112215478"></a><a name="p2897112215478"></a><span>LOS_DL_LIST_FOR_EACH_ENTRY_SAFE</span></p> -</td> -<td class="cellrowborder" valign="top"><p id="p13898102220475"><a name="p13898102220475"></a><a name="p13898102220475"></a>Traverses the specified doubly linked list, obtains the structure address of the node that contains the linked list, and stores the structure address that contains the next node of the current node.</p> -</td> -</tr> -</tbody> -</table> - -## How to Develop<a name="section01781261552"></a> - -The typical development process of the doubly linked list is as follows: - -1. Call **LOS\_ListInit/LOS\_DL\_LIST\_HEAD** to initialize a doubly linked list. -2. Call **LOS\_ListAdd** to insert a node to the list. -3. Call **LOS\_ListTailInsert** to insert a node to the end of the list. -4. Call **LOS\_ListDelete** to delete the specified node. -5. Call **LOS\_ListEmpty** to check whether a linked list is empty. -6. Call **LOS\_ListDelInit** to delete a specified node, and initialize the linked list based on this node. - -> **NOTE:** ->- Pay attention to the operations of the front and back pointer of the node. ->- The linked list operation APIs are underlying APIs and do not check whether the input parameters are empty. You must ensure that the input parameters are valid. ->- If the memory of a linked list node is dynamically requested, release the memory after deleting the node. - -### Development Example<a name="section8354175218128"></a> +The table below describes the DLL APIs. For more details about the APIs, see the API reference. + +| **Category**| **API**| +| -------- | -------- | +| Initializing a DLL| - **LOS_ListInit**: initializes a node as a DLL node.<br>- **LOS_DL_LIST_HEAD**: defines a node and initializes it as a DLL node.| +| Adding a node| - **LOS_ListAdd**: adds a node to the head of a DLL.<br>- **LOS_ListHeadInsert**: same as **LOS_ListAdd**.<br>- **LOS_ListTailInsert**: inserts a node to the tail of a DLL.| +| Adding a DLL| - **LOS_ListAddList**: adds the head of a DLL to the head of this DLL.<br>- **LOS_ListHeadInsertList**: inserts the head of a DLL to the head of this DLL.<br>- **LOS_ListTailInsertList**: Inserts the end of a DLL to the head of this DLL.| +| Deleting a node| - **LOS_ListDelete**: deletes a node from this DLL.<br>- **LOS_ListDelInit**: deletes a node from this DLL and uses this node to initialize the DLL.| +| Checking a DLL| - **LOS_ListEmpty**: checks whether a DLL is empty.<br>- **LOS_DL_LIST_IS_END**: checks whether a node is the tail of the DLL.<br>- **LOS_DL_LIST_IS_ON_QUEUE**: checks whether a node is in the DLL.| +| Obtains structure information.| - **LOS_OFF_SET_OF**: obtains the offset of a member in the specified structure relative to the start address of the structure.<br>- **LOS_DL_LIST_ENTRY**: obtains the address of the structure that contains the first node in the DLL. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure.<br>- **LOS_ListPeekHeadType**: obtains the address of the structure that contains the first node in the linked list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure. Null will be returned if the DLL is empty.<br>- **LOS_ListRemoveHeadType**: obtains the address of the structure that contains the first node in the linked list, and deletes the first node from the list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the name of the structure to be obtained, and the third input parameter indicates the name of the linked list in the structure. Null will be returned if the DLL is empty.<br>- **LOS_ListNextType**: obtains the address of the structure that contains the next node of the specified node in the linked list. The first input parameter of the API indicates the head node in the list, the second input parameter indicates the specified node, the third parameter indicates the name of the structure to be obtained, and the fourth input parameter indicates the name of the linked list in the structure. If the next node of the linked list node is the head node and is empty, NULL will be returned.| +| Traversing a DLL| - **LOS_DL_LIST_FOR_EACH**: traverses a DLL.<br>- **LOS_DL_LIST_FOR_EACH_SAFE**: traverses the DLL and stores the subsequent nodes of the current node for security verification.| +| Traversing the structure that contains the DLL| - **LOS_DL_LIST_FOR_EACH_ENTRY**: traverses a DLL and obtains the address of the structure that contains the linked list node.<br>- **LOS_DL_LIST_FOR_EACH_ENTRY_SAFE**: traverses a DLL, obtains the address of the structure that contains the linked list node, and stores the address of the structure that contains the subsequent node of the current node.| + + +## How to Develop + +The typical development process of the DLL is as follows: + +1. Call **LOS_ListInit** or **LOS_DL_LIST_HEAD** to initialize a DLL. + +2. Call **LOS_ListAdd** to add a node into the DLL. + +3. Call **LOS_ListTailInsert** to insert a node to the tail of the DLL. + +4. Call **LOS_ListDelete** to delete the specified node. + +5. Call **LOS_ListEmpty** to check whether the DLL is empty. + +6. Call **LOS_ListDelInit** to delete the specified node and initialize the DLL based on the node. + + +>  **NOTE**<br> +> - Pay attention to the operations operations of the front and back pointer of the node. +> +> - The DLL APIs are underlying interfaces and do not check whether the input parameters are empty. You must ensure that the input parameters are valid. +> +> - If the memory of a linked list node is dynamically allocated, release the memory when deleting the node. + + + **Development Example** **Example Description** + This example implements the following: -1. Initialize a doubly linked list. -2. Add nodes. -3. Delete nodes. -4. Check the operation result. + +1. Initialize a DLL. + +2. Add nodes. + +3. Delete nodes. + +4. Check the operation result. + + ``` #include "stdio.h" @@ -184,7 +75,7 @@ static UINT32 ListSample(VOID) LOS_DL_LIST listNode1 = {NULL,NULL}; LOS_DL_LIST listNode2 = {NULL,NULL}; - // Initialize the linked list. + // Initialize the DLL. PRINTK("Initial head\n"); LOS_ListInit(&listHead); @@ -203,7 +94,7 @@ static UINT32 ListSample(VOID) LOS_ListDelete(&listNode1); LOS_ListDelete(&listNode2); - // Check that the linked list is empty. + // Check whether the DLL is empty. if (LOS_ListEmpty(&listHead)) { PRINTK("Delete success\n"); } @@ -212,8 +103,10 @@ static UINT32 ListSample(VOID) } ``` + **Verification** + The development is successful if the return result is as follows: ``` @@ -222,4 +115,3 @@ Add listNode1 success Tail insert listNode2 success Delete success ``` - diff --git a/en/device-dev/kernel/kernel-small-basic-memory-virtual.md b/en/device-dev/kernel/kernel-small-basic-memory-virtual.md index 1c3b440fd5ecc5741b2cad1a49ef59b90d9082aa..bcef2eb5c93bf3ba1b15552d055a5cfa7dc9405b 100644 --- a/en/device-dev/kernel/kernel-small-basic-memory-virtual.md +++ b/en/device-dev/kernel/kernel-small-basic-memory-virtual.md @@ -1,322 +1,129 @@ # Virtual Memory Management -## Basic Concepts<a name="section650193717411"></a> +## Basic Concepts Virtual memory management is a technology used by computer systems to manage memory. Each process has a continuous virtual address space. The size of the virtual address space is determined by the number of CPU bits. The maximum addressing space for a 32-bit hardware platform ranges from 0 GiB to 4 GiB. The 4 GiB space is divided into two parts: 3 GiB higher-address space for the LiteOS-A kernel and 1 GiB lower-address space for user-mode processes. The virtual address space of each process space is independent, and the code and data do not affect each other. -The system divides the virtual memory into memory blocks called virtual pages. The size of a virtual page is generally 4 KiB or 64 KiB. The virtual page of the LiteOS-A kernel is 4 KiB by default. You can configure memory management units \(MMUs\) as required. The minimum unit of the virtual memory management is a page. A virtual address region in the LiteOS-A kernel can contain one virtual page or multiple virtual pages with contiguous addresses. Similarly, the physical memory is also divided by page, and each memory block is called page frame. The virtual address space is divided as follows: 3 GiB \(**0x40000000** to **0xFFFFFFFF**\) for the kernel space and 1 GiB \(**0x01000000** to **0x3F000000**\) for the user space. The following tables describe the virtual address plan. You can view or configure virtual addresses in **los\_vm\_zone.h**. - -**Table 1** Kernel-mode addresses - -<a name="table9988174163613"></a> -<table><thead align="left"><tr id="row164675173616"><th class="cellrowborder" valign="top" width="19.99%" id="mcps1.2.4.1.1"><p id="p046752361"><a name="p046752361"></a><a name="p046752361"></a>Zone</p> -</th> -<th class="cellrowborder" valign="top" width="43.13%" id="mcps1.2.4.1.2"><p id="p0461651361"><a name="p0461651361"></a><a name="p0461651361"></a>Description</p> -</th> -<th class="cellrowborder" valign="top" width="36.88%" id="mcps1.2.4.1.3"><p id="p446195183611"><a name="p446195183611"></a><a name="p446195183611"></a>Property</p> -</th> -</tr> -</thead> -<tbody><tr id="row94619516367"><td class="cellrowborder" valign="top" width="19.99%" headers="mcps1.2.4.1.1 "><p id="p1846553363"><a name="p1846553363"></a><a name="p1846553363"></a>DMA zone</p> -</td> -<td class="cellrowborder" valign="top" width="43.13%" headers="mcps1.2.4.1.2 "><p id="p3461158364"><a name="p3461158364"></a><a name="p3461158364"></a>Addresses for direct memory access (DMA) of I/O devices.</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p10461152363"><a name="p10461152363"></a><a name="p10461152363"></a>Uncache</p> -</td> -</tr> -<tr id="row246551361"><td class="cellrowborder" valign="top" width="19.99%" headers="mcps1.2.4.1.1 "><p id="p3461259362"><a name="p3461259362"></a><a name="p3461259362"></a>Normal zone</p> -</td> -<td class="cellrowborder" valign="top" width="43.13%" headers="mcps1.2.4.1.2 "><p id="p1546056362"><a name="p1546056362"></a><a name="p1546056362"></a>Addresses for loading the kernel code segment, data segment, heap, and stack.</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p646125143613"><a name="p646125143613"></a><a name="p646125143613"></a>Cache</p> -</td> -</tr> -<tr id="row646165133613"><td class="cellrowborder" valign="top" width="19.99%" headers="mcps1.2.4.1.1 "><p id="p114675183615"><a name="p114675183615"></a><a name="p114675183615"></a>high mem zone</p> -</td> -<td class="cellrowborder" valign="top" width="43.13%" headers="mcps1.2.4.1.2 "><p id="p194611583613"><a name="p194611583613"></a><a name="p194611583613"></a>Addresses for allocating contiguous virtual memory. The mapped physical memory blocks may not be contiguous.</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p8461153369"><a name="p8461153369"></a><a name="p8461153369"></a>Cache</p> -</td> -</tr> -</tbody> -</table> - -**Table 2** User-mode virtual addresses - -<a name="table19965411366"></a> -<table><thead align="left"><tr id="row646185183618"><th class="cellrowborder" valign="top" width="20%" id="mcps1.2.4.1.1"><p id="p3466593612"><a name="p3466593612"></a><a name="p3466593612"></a>Zone</p> -</th> -<th class="cellrowborder" valign="top" width="43.120000000000005%" id="mcps1.2.4.1.2"><p id="p84645143613"><a name="p84645143613"></a><a name="p84645143613"></a>Description</p> -</th> -<th class="cellrowborder" valign="top" width="36.88%" id="mcps1.2.4.1.3"><p id="p1146115203615"><a name="p1146115203615"></a><a name="p1146115203615"></a>Property</p> -</th> -</tr> -</thead> -<tbody><tr id="row7462511363"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.4.1.1 "><p id="p2467516363"><a name="p2467516363"></a><a name="p2467516363"></a>Code segment</p> -</td> -<td class="cellrowborder" valign="top" width="43.120000000000005%" headers="mcps1.2.4.1.2 "><p id="p7472523618"><a name="p7472523618"></a><a name="p7472523618"></a>User-mode code segment address range</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p14476563611"><a name="p14476563611"></a><a name="p14476563611"></a>Cache</p> -</td> -</tr> -<tr id="row34755153614"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.4.1.1 "><p id="p194735173612"><a name="p194735173612"></a><a name="p194735173612"></a>Heap</p> -</td> -<td class="cellrowborder" valign="top" width="43.120000000000005%" headers="mcps1.2.4.1.2 "><p id="p114720518362"><a name="p114720518362"></a><a name="p114720518362"></a>User-mode heap address range</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p9474515364"><a name="p9474515364"></a><a name="p9474515364"></a>Cache</p> -</td> -</tr> -<tr id="row9476518368"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.4.1.1 "><p id="p34714516369"><a name="p34714516369"></a><a name="p34714516369"></a>Stack</p> -</td> -<td class="cellrowborder" valign="top" width="43.120000000000005%" headers="mcps1.2.4.1.2 "><p id="p74705163612"><a name="p74705163612"></a><a name="p74705163612"></a>User-mode stack address range</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p144775143613"><a name="p144775143613"></a><a name="p144775143613"></a>Cache</p> -</td> -</tr> -<tr id="row1047353364"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.4.1.1 "><p id="p1947145163615"><a name="p1947145163615"></a><a name="p1947145163615"></a>Shared library</p> -</td> -<td class="cellrowborder" valign="top" width="43.120000000000005%" headers="mcps1.2.4.1.2 "><p id="p24745193617"><a name="p24745193617"></a><a name="p24745193617"></a>Address range for loading the user-mode shared library, including the address range mapped by mmap.</p> -</td> -<td class="cellrowborder" valign="top" width="36.88%" headers="mcps1.2.4.1.3 "><p id="p11472510363"><a name="p11472510363"></a><a name="p11472510363"></a>Cache</p> -</td> -</tr> -</tbody> -</table> - -## Working Principles<a name="section072885512412"></a> +The system divides the virtual memory into memory blocks called virtual pages. The size of a virtual page is generally 4 KiB or 64 KiB. The virtual page of the LiteOS-A kernel is 4 KiB by default. You can configure memory management units (MMUs) as required. The minimum unit of the virtual memory management is a page. A virtual address region in the LiteOS-A kernel can contain one virtual page or multiple virtual pages with contiguous addresses. Similarly, the physical memory is also divided by page, and each memory block is called page frame. The virtual address space is divided as follows: 3 GiB (**0x40000000** to **0xFFFFFFFF**) for the kernel space and 1 GiB (**0x01000000** to **0x3F000000**) for the user space. The following tables describe the virtual address plan. You can view or configure virtual addresses in **los_vm_zone.h**. + +**Table 1** Kernel-mode addresses + +| Zone| Description| Property| +| -------- | -------- | -------- | +| DMA zone | Addresses for direct memory access (DMA) of I/O devices.| Uncache | +| Normal zone | Addresses for loading the kernel code segment, data segment, heap, and stack.| Cache | +| high mem zone | Addresses for allocating contiguous virtual memory. The mapped physical memory blocks may not be contiguous.| Cache | + +**Table 2** User-mode virtual addresses + +| Zone| Description| Property| +| -------- | -------- | -------- | +| Code snippet| User-mode code segment address range.| Cache | +| Heap| User-mode heap address range.| Cache | +| Stack| User-mode stack address range.| Cache | +| Shared databases| Address range for loading the user-mode shared library, including the address range mapped by mmap.| Cache | + + +## Working Principles In virtual memory management, the virtual address space is contiguous, but the mapped physical memory is not necessarily contiguous, as depicted in the following figure. When an executable program is loaded and runs, the CPU accesses the code or data in the virtual address space in the following two cases: -- If the page \(for example, V0\) containing the virtual address accessed by the CPU is mapped to a physical page \(for example, P0\), the CPU locates the page table entry corresponding to the process \(for details, see [Virtual-to-Physical Mapping](kernel-small-basic-inner-reflect.md)"\), accesses the physical memory based on the physical address information in the page table entry, and returns the content. -- If the page \(for example, V2\) containing the virtual address accessed by the CPU is not mapped to a physical page, the system triggers a page missing fault, requests a physical page, copies the corresponding information to the physical page, and updates the start address of the physical page to the page table entry. Then, the CPU can access specific code or data by executing the instruction for accessing the virtual memory again. - -**Figure 1** Mapping between the virtual and physical memory addresses<a name="fig144371159135620"></a> - - -## Development Guidelines<a name="section20956116050"></a> - -### Available APIs<a name="section166137221657"></a> - -**Table 3** APIs of the virtual memory management module - -<a name="table1415203765610"></a> -<table><thead align="left"><tr id="row134151837125611"><th class="cellrowborder" valign="top" width="12.811281128112812%" id="mcps1.2.4.1.1"><p id="p16415637105612"><a name="p16415637105612"></a><a name="p16415637105612"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="29.84298429842984%" id="mcps1.2.4.1.2"><p id="p11415163718562"><a name="p11415163718562"></a><a name="p11415163718562"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="57.34573457345735%" id="mcps1.2.4.1.3"><p id="p1641533755612"><a name="p1641533755612"></a><a name="p1641533755612"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row0415737175610"><td class="cellrowborder" rowspan="5" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p4917132105710"><a name="p4917132105710"></a><a name="p4917132105710"></a>Obtaining process memory space</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p341513372561"><a name="p341513372561"></a><a name="p341513372561"></a>LOS_CurrSpaceGet</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p74151037185617"><a name="p74151037185617"></a><a name="p74151037185617"></a>Obtains the pointer to the current process space structure.</p> -</td> -</tr> -<tr id="row1841519376561"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p64151837155618"><a name="p64151837155618"></a><a name="p64151837155618"></a>LOS_SpaceGet</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p441516379562"><a name="p441516379562"></a><a name="p441516379562"></a>Obtains the pointer to the process space structure corresponding to the virtual address.</p> -</td> -</tr> -<tr id="row536885134010"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p236819594010"><a name="p236819594010"></a><a name="p236819594010"></a>LOS_GetKVmSpace</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p736918564019"><a name="p736918564019"></a><a name="p736918564019"></a>Obtains the pointer to the kernel process space structure.</p> -</td> -</tr> -<tr id="row11567448194112"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p0568204814115"><a name="p0568204814115"></a><a name="p0568204814115"></a>LOS_GetVmallocSpace</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p05681348204114"><a name="p05681348204114"></a><a name="p05681348204114"></a>Obtains the pointer to the vmalloc space structure.</p> -</td> -</tr> -<tr id="row1141513373562"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p17765212416"><a name="p17765212416"></a><a name="p17765212416"></a>LOS_GetVmSpaceList</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1972971913115"><a name="p1972971913115"></a><a name="p1972971913115"></a>Obtains the pointer to the process space linked list.</p> -</td> -</tr> -<tr id="row137812054195014"><td class="cellrowborder" rowspan="15" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p15344719152113"><a name="p15344719152113"></a><a name="p15344719152113"></a>Operations related to the virtual address region</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p97821654195014"><a name="p97821654195014"></a><a name="p97821654195014"></a>LOS_RegionFind</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p137821854205011"><a name="p137821854205011"></a><a name="p137821854205011"></a>Searches for and returns the virtual address region corresponding to the specified address in the process space.</p> -</td> -</tr> -<tr id="row254713575505"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p954785720501"><a name="p954785720501"></a><a name="p954785720501"></a>LOS_RegionRangeFind</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p20547557175013"><a name="p20547557175013"></a><a name="p20547557175013"></a>Searches for and returns the virtual address region corresponding to the specified address range in the process space.</p> -</td> -</tr> -<tr id="row1692045119"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1510110115114"><a name="p1510110115114"></a><a name="p1510110115114"></a>LOS_IsRegionFileValid</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p61011045112"><a name="p61011045112"></a><a name="p61011045112"></a>Checks whether the virtual address region is mapped to a file.</p> -</td> -</tr> -<tr id="row186701424548"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1967018210546"><a name="p1967018210546"></a><a name="p1967018210546"></a>LOS_RegionAlloc</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p196701221548"><a name="p196701221548"></a><a name="p196701221548"></a>Requests a free virtual address region.</p> -</td> -</tr> -<tr id="row1955586175412"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p555626195420"><a name="p555626195420"></a><a name="p555626195420"></a>LOS_RegionFree</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p85568612547"><a name="p85568612547"></a><a name="p85568612547"></a>Releases a specific region in the process space.</p> -</td> -</tr> -<tr id="row259111510282"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p3591135110288"><a name="p3591135110288"></a><a name="p3591135110288"></a>LOS_RegionEndAddr</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p4675183817474"><a name="p4675183817474"></a><a name="p4675183817474"></a>Obtains the end address of the specified address region.</p> -</td> -</tr> -<tr id="row12894115716285"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p889418577280"><a name="p889418577280"></a><a name="p889418577280"></a>LOS_RegionSize</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p68941757112813"><a name="p68941757112813"></a><a name="p68941757112813"></a>Obtains the size of a region.</p> -</td> -</tr> -<tr id="row14931456182812"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1293135611287"><a name="p1293135611287"></a><a name="p1293135611287"></a>LOS_IsRegionTypeFile</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1393185613288"><a name="p1393185613288"></a><a name="p1393185613288"></a>Checks whether the address region is a file memory mapping.</p> -</td> -</tr> -<tr id="row12153854132814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p115335452819"><a name="p115335452819"></a><a name="p115335452819"></a>LOS_IsRegionPermUserReadOnly</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1415314545285"><a name="p1415314545285"></a><a name="p1415314545285"></a>Checks whether the address region is read-only in the user space.</p> -</td> -</tr> -<tr id="row29249497282"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1492415495284"><a name="p1492415495284"></a><a name="p1492415495284"></a>LOS_IsRegionFlagPrivateOnly</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1392434982817"><a name="p1392434982817"></a><a name="p1392434982817"></a>Checks whether the address region has private attributes.</p> -</td> -</tr> -<tr id="row1233194042814"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p3339401289"><a name="p3339401289"></a><a name="p3339401289"></a>LOS_SetRegionTypeFile</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p193317409285"><a name="p193317409285"></a><a name="p193317409285"></a>Sets the file memory mapping attribute.</p> -</td> -</tr> -<tr id="row178971473283"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4898184782815"><a name="p4898184782815"></a><a name="p4898184782815"></a>LOS_IsRegionTypeDev</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p11898144722818"><a name="p11898144722818"></a><a name="p11898144722818"></a>Checks whether the address region is device memory mapping.</p> -</td> -</tr> -<tr id="row11137546152811"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p20137194672812"><a name="p20137194672812"></a><a name="p20137194672812"></a>LOS_SetRegionTypeDev</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p81384462287"><a name="p81384462287"></a><a name="p81384462287"></a>Sets the device memory mapping attribute. </p> -</td> -</tr> -<tr id="row1023564216285"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p92351842162819"><a name="p92351842162819"></a><a name="p92351842162819"></a>LOS_IsRegionTypeAnon</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p6235842132818"><a name="p6235842132818"></a><a name="p6235842132818"></a>Checks whether the address region is an anonymous mapping.</p> -</td> -</tr> -<tr id="row1646364402813"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p44631644152814"><a name="p44631644152814"></a><a name="p44631644152814"></a>LOS_SetRegionTypeAnon</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p174631844182818"><a name="p174631844182818"></a><a name="p174631844182818"></a>Sets the anonymous mapping attribute. </p> -</td> -</tr> -<tr id="row038233717288"><td class="cellrowborder" rowspan="5" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p6820331185317"><a name="p6820331185317"></a><a name="p6820331185317"></a>Verifying address</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p838383720282"><a name="p838383720282"></a><a name="p838383720282"></a>LOS_IsUserAddress</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p12383837102818"><a name="p12383837102818"></a><a name="p12383837102818"></a>Checks whether the address is in the user space.</p> -</td> -</tr> -<tr id="row61506354284"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2151113517288"><a name="p2151113517288"></a><a name="p2151113517288"></a>LOS_IsUserAddressRange</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p615123552814"><a name="p615123552814"></a><a name="p615123552814"></a>Checks whether the address region is in the user space.</p> -</td> -</tr> -<tr id="row18301515194210"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19301141519421"><a name="p19301141519421"></a><a name="p19301141519421"></a>LOS_IsKernelAddress</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p730110154427"><a name="p730110154427"></a><a name="p730110154427"></a>Checks whether the address is in the kernel space.</p> -</td> -</tr> -<tr id="row191211718204213"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1112121812423"><a name="p1112121812423"></a><a name="p1112121812423"></a>LOS_IsKernelAddressRange</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p6122101814219"><a name="p6122101814219"></a><a name="p6122101814219"></a>Checks whether the address region is in the kernel space.</p> -</td> -</tr> -<tr id="row774964092115"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p17152102415416"><a name="p17152102415416"></a><a name="p17152102415416"></a>LOS_IsRangeInSpace</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p115218248547"><a name="p115218248547"></a><a name="p115218248547"></a>Checks whether the address region is in the process space.</p> -</td> -</tr> -<tr id="row179196525521"><td class="cellrowborder" rowspan="3" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p153501191535"><a name="p153501191535"></a><a name="p153501191535"></a>vmalloc operations</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p152945155531"><a name="p152945155531"></a><a name="p152945155531"></a>LOS_VMalloc</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p1229461512535"><a name="p1229461512535"></a><a name="p1229461512535"></a>Requests memory using <strong id="b2981120154115"><a name="b2981120154115"></a><a name="b2981120154115"></a>vmalloc</strong>.</p> -</td> -</tr> -<tr id="row1934135935211"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p162941115155315"><a name="p162941115155315"></a><a name="p162941115155315"></a>LOS_VFree</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p12294171516536"><a name="p12294171516536"></a><a name="p12294171516536"></a>Releases memory using <strong id="b1911793812416"><a name="b1911793812416"></a><a name="b1911793812416"></a>vmalloc</strong>.</p> -</td> -</tr> -<tr id="row944214919304"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p644229163016"><a name="p644229163016"></a><a name="p644229163016"></a>LOS_IsVmallocAddress</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1344220993011"><a name="p1344220993011"></a><a name="p1344220993011"></a>Checks whether the address is requested by using <strong id="b11623210425"><a name="b11623210425"></a><a name="b11623210425"></a>vmalloc</strong>.</p> -</td> -</tr> -<tr id="row72131845145315"><td class="cellrowborder" rowspan="4" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p84847816543"><a name="p84847816543"></a><a name="p84847816543"></a>Requesting memory</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p8787345546"><a name="p8787345546"></a><a name="p8787345546"></a>LOS_KernelMalloc</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p17787444543"><a name="p17787444543"></a><a name="p17787444543"></a>Allocates memory from the heap memory pool if the requested memory is less than 16 KiB; allocates multiple contiguous physical pages for memory allocation if the requested memory is greater than 16 KiB.</p> -</td> -</tr> -<tr id="row48491549145311"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p14787149541"><a name="p14787149541"></a><a name="p14787149541"></a>LOS_KernelMallocAlign</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p478719411543"><a name="p478719411543"></a><a name="p478719411543"></a>Allocates memory with alignment attributes. The allocation rule is the same as that of the <strong id="b13365164915813"><a name="b13365164915813"></a><a name="b13365164915813"></a>LOS_KernelMalloc</strong> API.</p> -</td> -</tr> -<tr id="row151093538536"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p15787134185412"><a name="p15787134185412"></a><a name="p15787134185412"></a>LOS_KernelFree</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p878712410546"><a name="p878712410546"></a><a name="p878712410546"></a>Releases the memory requested by <strong id="b426742412595"><a name="b426742412595"></a><a name="b426742412595"></a>LOS_KernelMalloc</strong> and <strong id="b20812228205916"><a name="b20812228205916"></a><a name="b20812228205916"></a>LOS_KernelMallocAlign</strong>.</p> -</td> -</tr> -<tr id="row5126856205319"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p197871646545"><a name="p197871646545"></a><a name="p197871646545"></a>LOS_KernelRealloc</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p378813416547"><a name="p378813416547"></a><a name="p378813416547"></a>Reallocates the memory requested by <strong id="b161871016807"><a name="b161871016807"></a><a name="b161871016807"></a>LOS_KernelMalloc</strong> and <strong id="b1368514211001"><a name="b1368514211001"></a><a name="b1368514211001"></a>LOS_KernelMallocAlign</strong>.</p> -</td> -</tr> -<tr id="row12397132718549"><td class="cellrowborder" rowspan="4" valign="top" width="12.811281128112812%" headers="mcps1.2.4.1.1 "><p id="p112971954115419"><a name="p112971954115419"></a><a name="p112971954115419"></a>Others</p> -</td> -<td class="cellrowborder" valign="top" width="29.84298429842984%" headers="mcps1.2.4.1.2 "><p id="p2777034145414"><a name="p2777034145414"></a><a name="p2777034145414"></a>LOS_PaddrQuery</p> -</td> -<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p13777834115413"><a name="p13777834115413"></a><a name="p13777834115413"></a>Obtains the physical address based on the virtual address.</p> -</td> -</tr> -<tr id="row5558122119542"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p9558421155418"><a name="p9558421155418"></a><a name="p9558421155418"></a>LOS_VmSpaceFree</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p755852119545"><a name="p755852119545"></a><a name="p755852119545"></a>Releases the process space, including the virtual memory region and page table.</p> -</td> -</tr> -<tr id="row15860142919544"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p168603298547"><a name="p168603298547"></a><a name="p168603298547"></a>LOS_VmSpaceReserve</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p12860429185410"><a name="p12860429185410"></a><a name="p12860429185410"></a>Reserves a memory space in the process space.</p> -</td> -</tr> -<tr id="row394217543569"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11943125419566"><a name="p11943125419566"></a><a name="p11943125419566"></a>LOS_VaddrToPaddrMmap</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p16943954105613"><a name="p16943954105613"></a><a name="p16943954105613"></a>Maps the physical address region with the specified length to a virtual address region. You need to request the physical address region before the operation.</p> -</td> -</tr> -</tbody> -</table> - -### How to Develop<a name="section8752103914513"></a> +- If the page (for example, V0) containing the virtual address accessed by the CPU is mapped to a physical page (for example, P0), the CPU locates the page table entry corresponding to the process (for details, see [Virtual-to-Physical Mapping](kernel-small-basic-inner-reflect.md)"), accesses the physical memory based on the physical address information in the page table entry, and returns the content. -To use APIs related to virtual memory: +- If the page (for example, V2) containing the virtual address accessed by the CPU is not mapped to a physical page, the system triggers a page missing fault, requests a physical page, copies the corresponding information to the physical page, and updates the start address of the physical page to the page table entry. Then, the CPU can access specific code or data by executing the instruction for accessing the virtual memory again. + + **Figure 1** Mapping between the virtual and physical memory addresses<br> + +  + + +## Development Guidelines + + +### Available APIs + +**Table 3** APIs of the virtual memory management module -1. Obtain the process space structure using the APIs for obtaining the process space, and access the structure information. -2. Perform the following operations on the virtual address region: - - Call **LOS\_RegionAlloc** to request a virtual address region. +| API| Description| +| -------- | -------- | +| LOS_CurrSpaceGet | Obtains the pointer to the current process space structure.| +| LOS_SpaceGet | Obtains the pointer to the process space structure corresponding to the virtual address.| +| LOS_GetKVmSpace | Obtains the pointer to the kernel process space structure.| +| LOS_GetVmallocSpace | Obtains the pointer to the vmalloc space structure.| +| LOS_GetVmSpaceList | Obtains the pointer to the process space linked list.| - - Call **LOS\_RegionFind** and **LOS\_RegionRangeFind** to check whether the corresponding address region exists. - - Call **LOS\_RegionFree** to release a virtual address region. +**Table 4** Operations related to the virtual address region + +| API| Description| +| -------- | -------- | +| LOS_RegionFind | Searches for and returns the virtual address region corresponding to the specified address in the process space.| +| LOS_RegionRangeFind | Searches for and returns the virtual address region corresponding to the specified address range in the process space.| +| LOS_IsRegionFileValid | Checks whether the virtual address region is mapped to a file.| +| LOS_RegionAlloc | Requests a free virtual address region.| +| LOS_RegionFree | Releases a specific region in the process space.| +| LOS_RegionEndAddr | Obtains the end address of the specified address region.| +| LOS_RegionSize | Obtains the size of a region.| +| LOS_IsRegionTypeFile | Checks whether the address region is a file memory mapping.| +| LOS_IsRegionPermUserReadOnly | Checks whether the address region is read-only in the user space.| +| LOS_IsRegionFlagPrivateOnly | Checks whether the address region has private attributes.| +| LOS_SetRegionTypeFile | Sets the file memory mapping attributes. | +| LOS_IsRegionTypeDev | Checks whether the address region is device memory mapping.| +| LOS_SetRegionTypeDev | Sets the device memory mapping attributes. | +| LOS_IsRegionTypeAnon | Checks whether the address region is an anonymous mapping.| +| LOS_SetRegionTypeAnon | Sets the anonymous mapping attributes. | + +**Table 5** APIs for address verification + +| API| Description| +| -------- | -------- | +| LOS_IsUserAddress | Checks whether the address is in the user space.| +| LOS_IsUserAddressRange | Checks whether the address region is in the user space.| +| LOS_IsKernelAddress | Checks whether the address is in the kernel space.| +| LOS_IsKernelAddressRange | Checks whether the address region is in the kernel space.| +| LOS_IsRangeInSpace | Checks whether the address region is in the process space.| + +**Table 6** APIs for vmalloc operations + +| API| Description| +| -------- | -------- | +| LOS_VMalloc | Requests memory using **vmalloc**.| +| LOS_VFree | Releases memory using **vmalloc**.| +| LOS_IsVmallocAddress | Checks whether the address is requested using **vmalloc**. | + +**Table 7** APIs for memory allocation + +| API| Description| +| -------- | -------- | +| LOS_KernelMalloc | Allocates memory from the heap memory pool if the requested memory is less than 16 KiB; allocates multiple contiguous physical pages if the requested memory is greater than 16 KiB. | +| LOS_KernelMallocAlign | Allocates memory with alignment attributes. The allocation rule is the same as that of the **LOS_KernelMalloc** API.| +| LOS_KernelFree | Releases the memory requested by **LOS_KernelMalloc** and **LOS_KernelMallocAlign**.| +| LOS_KernelRealloc | Reallocates the memory requested by **LOS_KernelMalloc** and **LOS_KernelMallocAlign**.| + +**Table 8** Other APIs + +| API | Description | +| -------- | -------- | +| LOS_PaddrQuery | Obtains the physical address based on the virtual address. | +| LOS_VmSpaceFree | Releases the process space, including the virtual memory region and page table. | +| LOS_VmSpaceReserve | Reserves a memory space in the process space. | +| LOS_VaddrToPaddrMmap | Maps the physical address region with the specified length to a virtual address region. You need to request the physical address region before the operation. | + + +### How to Develop + +To use APIs related to virtual memory: -3. Call **vmalloc** and memory requesting APIs to apply for memory in the kernel as demanded. +1. Obtain the process space structure using the APIs for obtaining the process space, and access the structure information. +2. Perform the following operations on the virtual address region: + - Call **LOS_RegionAlloc** to request a virtual address region. + - Call **LOS_RegionFind** and **LOS_RegionRangeFind** to check whether the corresponding address region exists. + - Call **LOS_RegionFree** to release a virtual address region. -> **NOTE:** ->The physical memory requested by using the memory requesting APIs must be contiguous. If the system cannot provide a large number of contiguous memory blocks, the request fails. Therefore, the memory requesting APIs are recommended for requesting small memory blocks. **vmalloc** is recommended for requesting non-contiguous physical memory. However, the memory is allocated in the unit of pages \(4096 bytes/page in the current system\). If you want memory that is an integer multiple of a page, you can use **vmalloc**. For example, you can use **vmalloc** to request memory for file reading in a file system, which demands a large cache. +3. Call **vmalloc** APIs (see table 6) and memory allocation APIs (see table 7) to apply for memory in the kernel as required. +>  **NOTE** +> +> The physical memory requested by using the memory allocation APIs must be contiguous. If the system cannot provide a large number of contiguous memory blocks, the request fails. Therefore, the memory allocation APIs are recommended for requesting small memory blocks. +> +> **vmalloc** APIs are recommended for requesting non-contiguous physical memory. However, the memory is allocated in the unit of pages (4096 bytes/page in the current system). If you want memory that is an integer multiple of a page, you can use **vmalloc** APIs. For example, you can use **vmalloc** to request memory for file reading in a file system, which demands a large cache. diff --git a/en/device-dev/kernel/kernel-small-basic-trans-rwlock.md b/en/device-dev/kernel/kernel-small-basic-trans-rwlock.md index 97f8b77622ee03c6701df1e0b426778c8a956ddd..18558986daf9a5cf45e72a771aa8dc6e98454876 100644 --- a/en/device-dev/kernel/kernel-small-basic-trans-rwlock.md +++ b/en/device-dev/kernel/kernel-small-basic-trans-rwlock.md @@ -1,128 +1,85 @@ # RW Lock -## Basic Concepts<a name="section4692105214260"></a> +## Basic Concepts -Similar to a mutex, a read-write lock \(RW lock\) can be used to synchronize tasks in the same process. Different from a mutex, an RW lock allows concurrent access for read operations and exclusive access for write operations. +Similar to a mutex, a read-write lock (RW lock) can be used to synchronize tasks in the same process. Different from a mutex, an RW lock allows concurrent access for read operations and exclusive access for write operations. An RW lock has three states: locked in read mode, locked in write mode, and unlocked. Observe the following rules when using RW locks: -- If there is no lock in write mode in the protected area, any task can add a lock in read mode. -- A lock in write mode can be added only when the protected area is in the unlocked state. +- If there is no lock in write mode in the protected area, any task can add a lock in read mode. + +- A lock in write mode can be added only when the protected area is in the unlocked state. In a multi-task environment, multiple tasks may access the same shared resource. A lock in read mode allows access to a protected area in shared mode, and a lock in a write mode allows exclusive access to the shared resource. This sharing-exclusive manner is suitable for a multi-task environment where the data read operations are far more than data write operations. It can improve multi-task concurrency of the application. -## Working Principles<a name="section1239111562720"></a> + +## Working Principles How does an RW lock implement lock in read mode and lock in write mode to control read/write access of multiple tasks? -- If task A acquires the lock in write mode for the first time, other tasks cannot acquire or attempt to acquire the lock in read mode. - -- If task A acquires the lock in read mode, the RW lock count increments by 1 when a task acquires or attempts to acquire the lock in read mode. - -## Development Guidelines<a name="section11643194275"></a> - -### Available APIs<a name="section15335332122717"></a> - -**Table 1** Read/write lock module APIs - -<a name="table37108292611"></a> -<table><thead align="left"><tr id="row8711112919610"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p3711102912617"><a name="p3711102912617"></a><a name="p3711102912617"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1671110293610"><a name="p1671110293610"></a><a name="p1671110293610"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p87114292617"><a name="p87114292617"></a><a name="p87114292617"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row37115291166"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1795312108911"><a name="p1795312108911"></a><a name="p1795312108911"></a>Creating and deleting an RW lock</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1671120293611"><a name="p1671120293611"></a><a name="p1671120293611"></a>LOS_RwlockInit</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p171112291967"><a name="p171112291967"></a><a name="p171112291967"></a>Creates an RW lock.</p> -</td> -</tr> -<tr id="row17711329268"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p071114291864"><a name="p071114291864"></a><a name="p071114291864"></a>LOS_RwlockDestroy</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p137111129965"><a name="p137111129965"></a><a name="p137111129965"></a>Deletes the specified RW lock.</p> -</td> -</tr> -<tr id="row5711192912616"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p86087143910"><a name="p86087143910"></a><a name="p86087143910"></a>Requesting a lock in read mode</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1171112295614"><a name="p1171112295614"></a><a name="p1171112295614"></a>LOS_RwlockRdLock</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1271110291969"><a name="p1271110291969"></a><a name="p1271110291969"></a>Requests the specified lock in read mode.</p> -</td> -</tr> -<tr id="row1571162918615"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1564192618292"><a name="p1564192618292"></a><a name="p1564192618292"></a>LOS_RwlockTryRdLock</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p107118291660"><a name="p107118291660"></a><a name="p107118291660"></a>Attempts to request the specified lock in read mode.</p> -</td> -</tr> -<tr id="row189551130172817"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7951153082815"><a name="p7951153082815"></a><a name="p7951153082815"></a>Requesting a lock in write mode</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p111591404308"><a name="p111591404308"></a><a name="p111591404308"></a>LOS_RwlockWrLock</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11951183013281"><a name="p11951183013281"></a><a name="p11951183013281"></a>Requests the specified lock in write mode.</p> -</td> -</tr> -<tr id="row199551530122820"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p32171573014"><a name="p32171573014"></a><a name="p32171573014"></a>LOS_RwlockTryWrLock</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p5951123092819"><a name="p5951123092819"></a><a name="p5951123092819"></a>Attempts to request the specified lock in write mode.</p> -</td> -</tr> -<tr id="row1642820328301"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1542823210305"><a name="p1542823210305"></a><a name="p1542823210305"></a>Releasing an RW lock</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p174281324308"><a name="p174281324308"></a><a name="p174281324308"></a>LOS_RwlockUnLock</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1342810327309"><a name="p1342810327309"></a><a name="p1342810327309"></a>Releases the specified RW lock.</p> -</td> -</tr> -<tr id="row11318134133111"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p73182345312"><a name="p73182345312"></a><a name="p73182345312"></a>Verifying RW lock validity</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1031813416318"><a name="p1031813416318"></a><a name="p1031813416318"></a>LOS_RwlockIsValid</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p43187342311"><a name="p43187342311"></a><a name="p43187342311"></a>Checks the validity of an RW lock.</p> -</td> -</tr> -</tbody> -</table> - -### How to Develop<a name="section14774114882714"></a> +- If task A acquires the lock in write mode for the first time, other tasks cannot acquire or attempt to acquire the lock in read mode. + +- If task A acquires the lock in read mode, the RW lock count increments by 1 when a task acquires or attempts to acquire the lock in read mode. + + +## Development Guidelines + + +### Available APIs + +**Table 1** APIs of the RW lock module + +| API| Description| +| -------- | -------- | +| LOS_RwlockInit| Creates an RW lock.| +| LOS_RwlockDestroy| Deletes an RW lock.| +| LOS_RwlockRdLock| Requests the specified lock in read mode.| +| LOS_RwlockTryRdLock| Attempts to request a lock in read mode.| +| LOS_RwlockWrLock| Requests the specified lock in write mode.| +| LOS_RwlockTryWrLock| Attempts to request a lock in write mode.| +| LOS_RwlockUnLock| Releases the specified RW lock.| +| LOS_RwlockIsValid| Checks the validity of an RW lock.| + + +### How to Develop The typical development process is as follows: -1. Call **LOS\_RwlockInit** to create an RW lock. +1. Call **LOS_RwlockInit** to create an RW lock. -2. Call **LOS\_RwlockRdLock** to request a lock in read mode or call **LOS\_RwlockWrLock** to request a lock in write mode. +2. Call **LOS_RwlockRdLock** to request a lock in read mode or call **LOS_RwlockWrLock** to request a lock in write mode. -If a lock in read mode is requested: + If a lock in read mode is requested: -- If the lock is not held, the read task can acquire the lock. -- If the lock is held, the read task acquires the lock and is executed based on the task priority. -- If the lock in write mode is held by another task, the task cannot acquire the lock until the lock in write mode is released. + - If the lock is not held, the read task can acquire the lock. -If a lock in write mode is requested: + - If the lock is held, the read task acquires the lock and is executed based on the task priority. -- If the lock is not held or if the task that holds the lock in read mode is the one that requests the lock in write mode, the task acquires the lock in write mode immediately. -- If the lock already has a lock in read mode and the read task has a higher priority, the current task is suspended until the lock in read mode is released. + - If the lock in write mode is held by another task, the task cannot acquire the lock until the lock in write mode is released. -3. There are three types of locks in read mode and write mode: non-block mode, permanent block mode, and scheduled block mode. The difference lies in the task suspension time. + If a lock in write mode is requested: + + - If the lock is not held or if the task that holds the lock in read mode is the one that requests the lock in write mode, the task acquires the lock in write mode immediately. -4. Call **LOS\_RwlockUnLock** to release an RW lock. + - If the lock already has a lock in read mode and the read task has a higher priority, the current task is suspended until the lock in read mode is released. -- If tasks are blocked by the specified RW lock, the task with the highest priority is woken up, enters the Ready state, and is scheduled. +3. There are three types of locks in read mode and write mode: non-block mode, permanent block mode, and scheduled block mode. The difference lies in the task suspension time. -- If no task is blocked by the specified RW lock, the RW lock is released. +4. Call **LOS_RwlockUnLock** to release an RW lock. -5. Call **LOS\_RwlockDestroy** to delete an RW lock. + - If tasks are blocked by the specified RW lock, the task with the highest priority is woken up, enters the Ready state, and is scheduled. + - If no task is blocked by the specified RW lock, the RW lock is released. -> **NOTE:** ->- The RW lock cannot be used in the interrupt service program. ->- When using the LiteOS-A kernel, the OpenHarmony must ensure real-time task scheduling and avoid long-time task blocking. Therefore, an RW lock must be released as soon as possible after use. ->- When an RW lock is held by a task, the task priority cannot be changed by using APIs such as **LOS\_TaskPriSet**. +5. Call **LOS_RwlockDestroy** to delete an RW lock. + >  **NOTE**<br> + > - The RW lock cannot be used in the interrupt service program. + > + > - The LiteOS-A kernel used in the RTOS must ensure real-time task scheduling and avoid long-time task blocking. Therefore, RW locks must be released as soon as possible after use. + > + > - When an RW lock is held by a task, the task priority cannot be changed by using APIs, such as **LOS_TaskPriSet**. diff --git a/en/device-dev/kernel/kernel-small-bundles-fs-support-fat.md b/en/device-dev/kernel/kernel-small-bundles-fs-support-fat.md index d82858014b528de1c82b4313cfc3a0e0312a9540..e2bf8109175e2498239134fd959f71326d263bf9 100644 --- a/en/device-dev/kernel/kernel-small-bundles-fs-support-fat.md +++ b/en/device-dev/kernel/kernel-small-bundles-fs-support-fat.md @@ -1,40 +1,49 @@ # FAT -## Basic Concepts<a name="section621393911385"></a> +## Basic Concepts -File Allocation Table \(FAT\) is a file system developed for personal computers. It consists of the DOS Boot Record \(DBR\) region, FAT region, and Data region. Each entry in the FAT region records information about the corresponding cluster in the storage device. The cluster information includes whether the cluster is used, the number of the next cluster of the file, and whether the file ends with the cluster. The FAT file system supports multiple formats, such as FAT12, FAT16, and FAT32. The numbers 12, 16, and 32 indicate the number of bits per cluster within the FAT, and also restrict the maximum file size in the system. The FAT file system supports multiple media, especially removable media \(such as USB flash drives, SD cards, and removable hard drives\). The FAT file system ensures good compatibility between embedded devices and desktop systems \(such as Windows and Linux\) and facilitates file management. +File Allocation Table (FAT) is a file system developed for personal computers. It consists of the DOS Boot Record (DBR) region, FAT region, and Data region. Each entry in the FAT region records information about the corresponding cluster in the storage device. The cluster information includes whether the cluster is used, number of the next cluster of the file, whether the file ends with the cluster. The FAT file system supports multiple formats, such as FAT12, FAT16, and FAT32. The numbers 12, 16, and 32 indicate the number of bits per cluster within the FAT, and also restrict the maximum file size in the system. The FAT file system supports multiple media, especially removable media (such as USB flash drives, SD cards, and removable hard drives). The FAT file system ensures good compatibility between embedded devices and desktop systems (such as Windows and Linux) and facilitates file management. The OpenHarmony kernel supports FAT12, FAT16, and FAT32 file systems. These file systems require a tiny amount of code to implement, use less resources, support a variety of physical media, and are tailorable and compatible with Windows and Linux systems. They also support identification of multiple devices and partitions. The kernel supports multiple partitions on hard drives and allows creation of the FAT file system on the primary partition and logical partition. -## Working Principles<a name="section10796155213381"></a> + +## Working Principles This document does not include the FAT design and physical layout. You can find a lot of reference on the Internet. -The OpenHarmony LiteOS-A kernel uses block cache \(Bcache\) to improve FAT performance. When read and write operations are performed, Bcache caches the sectors close to the read and write sectors to reduce the number of I/Os and improve performance. The basic cache unit of Bcache is block. The size of each block is the same. By default, there are 28 blocks, and each block caches data of 64 sectors. When the Bcache dirty block rate \(number of dirty sectors/total number of sectors\) reaches the threshold, writeback is triggered and cached data is written back to disks. You can manually call **sync** and **fsync** to write data to disks if you want. Some FAT APIs \(such as **close** and **umount**\) may also trigger writeback operations. However, you are advised not to use them to trigger writeback. +The OpenHarmony LiteOS-A kernel uses block cache (Bcache) to improve FAT performance. When read and write operations are performed, Bcache caches the sectors close to the read and write sectors to reduce the number of I/Os and improve performance. The basic cache unit of Bcache is block. The size of each block is the same. By default, there are 28 blocks, and each block caches data of 64 sectors. When the Bcache dirty block rate (number of dirty sectors/total number of sectors) reaches the threshold, writeback is triggered and cached data is written back to disks. You can manually call **sync** and **fsync** to write data to disks if you want. Some FAT APIs (such as **close** and **umount**) may also trigger writeback operations. However, you are advised not to use them to trigger writeback. + -## Development Guidelines<a name="section144094483919"></a> +## Development Guidelines -### How to Develop<a name="section139086116394"></a> + + **How to Develop** The development process involves mounting partitions, managing files and directories, and unmounting partitions. -The device name of the SD card or MMC is **mmcblk\[x\]p\[y\]**, and the file system type is **vfat**. +The device name of the SD card or MMC is **mmcblk[x]p[y]**, and the file system type is **vfat**. Example: + ``` mount("/dev/mmcblk0p0", "/mnt", "vfat", 0, NULL); ``` -> **NOTE**<br/> ->- The size of a single FAT file cannot be greater than 4 GiB. ->- When there are two SD card slots, the first card inserted is card 0, and that inserted later is card 1. ->- When multi-partition is enabled and there are multiple partitions, the device node **/dev/mmcblk0** \(primary device\) registered by card 0 and **/dev/mmcblk0p0** \(secondary device\) are the same device. In this case, you cannot perform operations on the primary device. ->- Before removing an SD card, close the open files and directories and unmount the related nodes. Otherwise, SD card exceptions or memory leaks may occur. ->- Before performing the **format** operation, unmount the mount point. ->- After the Bcache feature takes effect, note the following: -> - When **MS\_NOSYNC** is carried in the **mount** function, FAT does not proactively write the content in the cache back to the storage device. The FAT-related APIs **open**, **close**, **unlink**, **rename**, **mkdir**, **rmdir**, and **truncate** do not automatically perform the **sync** operation, which improves the operation speed. However, the upper layer must actively invoke the **sync** operation to synchronize data. Otherwise, data loss may occur. -> - Bcache provides scheduled writeback. After **LOSCFG\_FS\_FAT\_CACHE\_SYNC\_THREAD** is enabled in **menuconfig**, the OpenHarmony kernel creates a scheduled task to write the Bcache data back to disks. By default, the kernel checks the dirty block rate in the Bcache every 5 seconds. If the dirty block rate exceeds 80%, the **sync** operation will be performed to write all dirty data in the Bcache to disks. You can call **LOS\_SetSyncThreadPrio**, **LOS\_SetSyncThreadInterval**, and **LOS\_SetDirtyRatioThreshold** to set the task priority, flush interval, and dirty block rate threshold, respectively. -> - The cache has 28 blocks by default, and each block has 64 sectors. - +>  **NOTE**<br> +> - The size of a single FAT file cannot be greater than 4 GiB. +> +> - When there are two SD card slots, the first card inserted is card 0, and that inserted later is card 1. +> +> - When multi-partition is enabled and there are multiple partitions, the device node **/dev/mmcblk0** (primary device) registered by card 0 and **/dev/mmcblk0p0** (secondary device) are the same device. In this case, you cannot perform operations on the primary device. +> +> - Before removing an SD card, close the open files and directories and unmount the related nodes. Otherwise, SD card exceptions or memory leaks may occur. +> +> - Before performing the **format** operation, unmount the mount point. +> +> - After the Bcache feature takes effect, note the following: +> - When **MS_NOSYNC** is carried in the **mount** function, FAT does not proactively write the content in the cache back to the storage device. The FAT-related APIs **open**, **close**, **unlink**, **rename**, **mkdir**, **rmdir**, and **truncate** do not automatically perform the **sync** operation, which improves the operation speed. However, the upper layer must actively invoke the **sync** operation to synchronize data. Otherwise, data loss may occur. +> +> - Bcache provides scheduled writeback. After **LOSCFG_FS_FAT_CACHE_SYNC_THREAD** is enabled in **menuconfig**, the OpenHarmony kernel creates a scheduled task to write the Bcache data back to disks. By default, the kernel checks the dirty block rate in the Bcache every 5 seconds. If the dirty block rate exceeds 80%, the **sync** operation will be performed to write all dirty data in the Bcache to disks. You can call **LOS_SetSyncThreadPrio**, **LOS_SetSyncThreadInterval**, and **LOS_SetDirtyRatioThreshold** to set the task priority, flush interval, and dirty block rate threshold, respectively. +> - The cache has 28 blocks by default, and each block has 64 sectors. diff --git a/en/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md b/en/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md index d205531eb3d7ac83645ce872669a645d0d4d5aa5..57e01b4a58d9430f167b89c0cd03f6b4ded73dbf 100644 --- a/en/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md +++ b/en/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md @@ -1,135 +1,140 @@ # NFS -## Basic Concepts<a name="section195414101464"></a> +## Basic Concepts -NFS allows you to share files across hosts and OSs over a network. You can treat NFS as a file system service, which is equivalent to folder sharing in the Windows OS to some extent. +Network File System (NFS) allows you to share files across hosts and OSs over a network. You can treat NFS as a file system service, which is equivalent to folder sharing in the Windows OS to some extent. -## Working Principles<a name="section165621321194618"></a> -The NFS of the OpenHarmony LiteOS-A kernel acts as an NFS client. The NFS client can mount the directory shared by a remote NFS server to the local machine and run the programs and shared files without occupying the storage space of the current system. To the local machine, the directory on the remote server is like its disk. - -## Development Guidelines<a name="section7454935184611"></a> - -1. Create an NFS server. - -The following uses the Ubuntu OS as an example to describe how to configure an NFS server. - -- Install the NFS server software. - -Set the download source of the Ubuntu OS when the network connection is normal. - -``` -sudo apt-get install nfs-kernel-server -``` +## Working Principles -- Create a directory for mounting and assign full permissions for the directory. - -``` -mkdir -p /home/sqbin/nfs -sudo chmod 777 /home/sqbin/nfs -``` - -- Configure and start the NFS server. - -Append the following line in the **/etc/exports** file: - -``` -/home/sqbin/nfs *(rw,no_root_squash,async) -``` - -**/home/sqbin/nfs** is the root directory shared by the NFS server. - -Start the NFS server. +The NFS of the OpenHarmony LiteOS-A kernel acts as an NFS client. The NFS client can mount the directory shared by a remote NFS server to the local machine and run the programs and shared files without occupying the storage space of the current system. To the local machine, the directory on the remote server is like its disk. -``` -sudo /etc/init.d/nfs-kernel-server start -``` -Restart the NFS server. +## Development Guidelines -``` -sudo /etc/init.d/nfs-kernel-server restart -``` +1. Create an NFS server. -1. Configure the board as an NFS client. + The following uses the Ubuntu OS as an example to describe how to configure an NFS server. -In this section, the NFS client is a device running the OpenHarmony kernel. + - Install the NFS server software. -- Set the hardware connection. + Set the download source of the Ubuntu OS when the network connection is normal. -Connect the OpenHarmony kernel device to the NFS server. Set their IP addresses in the same network segment. For example, set the IP address of the NFS server to **10.67.212.178/24** and set the IP address of the OpenHarmony kernel device to **10.67.212.3/24**. Note that the preceding IP addresses are private IP addresses used as examples. You need to use your actual IP addresses. + ``` + sudo apt-get install nfs-kernel-server + ``` -You can run the **ifconfig** command to check the OpenHarmony kernel device's IP address. + - Create a directory for mounting and assign full permissions for the directory. -- Start the network and ensure that the network between the board and NFS server is normal. + ``` + mkdir -p /home/sqbin/nfs + sudo chmod 777 /home/sqbin/nfs + ``` -Start the Ethernet or another type of network, and then run **ping** to check whether the network connection to the server is normal. + - Configure and start the NFS server. -``` -OHOS # ping 10.67.212.178 -[0]Reply from 10.67.212.178: time=1ms TTL=63 -[1]Reply from 10.67.212.178: time=0ms TTL=63 -[2]Reply from 10.67.212.178: time=1ms TTL=63 -[3]Reply from 10.67.212.178: time=1ms TTL=63 ---- 10.67.212.178 ping statistics --- -4 packets transmitted, 4 received, 0 loss -``` + Append the following line in the **/etc/exports** file: -Initialize the NFS client. + ``` + /home/sqbin/nfs *(rw,no_root_squash,async) + ``` + + **/home/sqbin/nfs** is the root directory shared by the NFS server. + + Start the NFS server. -``` -OHOS # mkdir /nfs -OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 -``` + ``` + sudo /etc/init.d/nfs-kernel-server start + ``` + + Restart the NFS server. -If the following information is displayed, the NFS client is initialized. + ``` + sudo /etc/init.d/nfs-kernel-server restart + ``` -``` -OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 -Mount nfs on 10.67.212.178:/home/sqbin/nfs, uid:1011, gid:1000 -Mount nfs finished. -``` +2. Configure the board as an NFS client. -This command mounts the **/home/sqbin/nfs** directory on the NFS server whose IP address is 10.67.212.178 to the **/nfs** directory on the OpenHarmony kernel device. + In this section, the NFS client is a device running the OpenHarmony kernel. -> **NOTE:** ->This section assumes that the NFS server is available, that is, the **/home/sqbin/nfs** directory on the NFS server 10.67.212.178 is accessible. ->The **mount** command format is as follows: ->``` ->mount <SERVER_IP:SERVER_PATH> <CLIENT_PATH> nfs ->``` ->- **SERVER\_IP** indicates the IP address of the server. ->- **SERVER\_PATH** indicates the path of the shared directory on the NFS server. ->- **CLIENT\_PATH** indicates the NFS path on the local device. ->- **nfs** indicates the path to which the remote shared directory is mounted on the local device. ->Replace the parameters as required. ->If you do not want to restrict the NFS access permission, set the permission of the NFS root directory to **777** on the Linux CLI. ->``` ->chmod -R 777 /home/sqbin/nfs ->``` ->The NFS client setting is complete, and the NFS file system has been mounted. + - Set the hardware connection. -1. Share files using NFS. + Connect the OpenHarmony kernel device to the NFS server. Set their IP addresses in the same network segment. For example, set the IP address of the NFS server to **10.67.212.178/24** and the IP address of the OpenHarmony kernel device to + **10.67.212.3/24**. Note that this IP address is an intranet private IP address. Use the actual IP address. -Create the **dir** directory on the NFS server and save the directory. Run the **ls** command in the OpenHarmony kernel. + You can run the **ifconfig** command to check the OpenHarmony kernel device's IP address. -``` -OHOS # ls /nfs -``` + - Start the network and ensure that the network between the board and NFS server is normal. -The following information is returned from the serial port: + Start the Ethernet or another type of network, and then run **ping** to check whether the network connection to the server is normal. -``` -OHOS # ls /nfs -Directory /nfs: -drwxr-xr-x 0 u:0 g:0 dir -``` -The **dir** directory created on the NFS server has been synchronized to the **/nfs** directory on the client \(OpenHarmony kernel system\). + ``` + OHOS # ping 10.67.212.178 + [0]Reply from 10.67.212.178: time=1ms TTL=63 + [1]Reply from 10.67.212.178: time=0ms TTL=63 + [2]Reply from 10.67.212.178: time=1ms TTL=63 + [3]Reply from 10.67.212.178: time=1ms TTL=63 + --- 10.67.212.178 ping statistics --- + 4 packets transmitted, 4 received, 0 loss + ``` + + Initialize the NFS client. -Similarly, you can create files and directories on the client \(OpenHarmony kernel system\) and access them from the NFS server. + ``` + OHOS # mkdir /nfs + OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 + ``` + + If the following information is displayed, the NFS client is initialized. -> **NOTE:** ->Currently, the NFS client supports some NFS v3 specifications. Therefore, the NFS client is not fully compatible with all types of NFS servers. You are advised to use the Linux NFS server to perform the development. + ``` + OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 + Mount nfs on 10.67.212.178:/home/sqbin/nfs, uid:1011, gid:1000 + Mount nfs finished. + ``` + + This command mounts the **/home/sqbin/nfs** directory on the NFS server (IP address: 10.67.212.178) to the **/nfs** directory on the OpenHarmony kernel device. + >  **NOTE** + > + > This example assumes that the NFS server is available, that is, the **/home/sqbin/nfs** directory on the NFS server 10.67.212.178 is accessible. + > + > The **mount** command format is as follows: + > + > ``` + > mount <SERVER_IP:SERVER_PATH> <CLIENT_PATH> nfs + > ``` + > + > **SERVER_IP** indicates the IP address of the server; **SERVER_PATH** indicates the path of the shared directory on the NFS server; **CLIENT_PATH** indicates the NFS path on the local device; **nfs** indicates the path to which the remote shared directory is mounted on the local device. Replace the parameters as required. + > + > If you do not want to restrict the NFS access permission, set the permission of the NFS root directory to **777** on the Linux CLI. + > + > ``` + > chmod -R 777 /home/sqbin/nfs + > ``` + > + > The NFS client setting is complete, and the NFS file system is mounted. + +3. Share files using NFS. + + Create the **dir** directory on the NFS server. Run the **ls** command in the OpenHarmony kernel. + + ``` + OHOS # ls /nfs + ``` + + The following information is returned from the serial port: + + ``` + OHOS # ls /nfs + Directory /nfs: + drwxr-xr-x 0 u:0 g:0 dir + ``` + + The **dir** directory created on the NFS server has been synchronized to the **/nfs** directory on the client (OpenHarmony kernel system). Similarly, you can create files and directories on the client (OpenHarmony kernel system) and access them from the NFS server. + + >  **NOTE** + > + > Currently, the NFS client supports some NFS v3 specifications. Therefore, the NFS client is not fully compatible with all types of NFS servers. You are advised to use the Linux NFS server to perform the development. diff --git a/en/device-dev/kernel/kernel-small-bundles-fs-support-procfs.md b/en/device-dev/kernel/kernel-small-bundles-fs-support-procfs.md index a9b031e9f72b535f22f3083491c5b76c08459e3f..261eae927bd78029daead0a19c56aca175a8623e 100644 --- a/en/device-dev/kernel/kernel-small-bundles-fs-support-procfs.md +++ b/en/device-dev/kernel/kernel-small-bundles-fs-support-procfs.md @@ -1,28 +1,32 @@ # procfs -## Basic Concepts<a name="section146801917174017"></a> +## Basic Concepts -The proc filesystem \(procfs\) is a virtual file system that displays process or other system information in a file-like structure. It is more convenient to obtain system information in file operation mode than API calling mode. +The proc filesystem (procfs) is a virtual file system that displays process or other system information in a file-like structure. It is more convenient to obtain system information in file operation mode than API calling mode. -## Working Principles<a name="section479762916408"></a> -In the OpenHarmony kernel, procfs is automatically mounted to the **/proc** directory during startup. Only the kernel module can create file nodes to provide the query service. +## Working Principles -## Development Guidelines<a name="section1221174524014"></a> +In the OpenHarmony kernel, procfs is automatically mounted to the **/proc** directory during startup. Only the kernel module can create file nodes to provide the query service. -To create a procfs file, you need to use **ProcMkdir** to create a directory and use **CreateProcEntry** to create a file. The development of the file node function is to hook the read and write functions to the file created by **CreateProcEntry**. When the procfs file is read or written, the hooked functions will be called to implement custom functions. -### Development Example<a name="section52016575401"></a> +## Development Guidelines -The following describes how to create the **/proc/hello/world** file to implement the following functions: +To create a procfs file, you need to use **ProcMkdir** to create a directory and use **CreateProcEntry** to create a file. The development of the file node function is to hook the read and write functions to the file created by **CreateProcEntry**. When the procfs file is read or written, the hooked functions will be called to implement custom functions. -1. Create a file in **/proc/hello/world**. + +### Development Example + +The following describes how to create the **/proc/hello/world** file to implement the following functions: + +1. Create a file in **/proc/hello/world**. 2. Read the file. When the file is read, "HelloWorld!" is returned. 3. Write the file and print the data written in the file. + ``` #include "proc_fs.h" @@ -48,7 +52,7 @@ static const struct ProcFileOperations HELLO_WORLD_OPS = { void HelloWorldInit(void) { - /* Create the hello directory.*/ + /* Create the hello directory. */ struct ProcDirEntry *dir = ProcMkdir("hello", NULL); if (dir == NULL) { PRINT_ERR("create dir failed!\n"); @@ -69,7 +73,8 @@ void HelloWorldInit(void) **Verification** -After the OS startup, run the following command in the shell: +After the OS startup, run the following commands in the shell: + ``` OHOS # cat /proc/hello/world @@ -77,4 +82,3 @@ OHOS # Hello World! OHOS # echo "yo" > /proc/hello/world OHOS # your input is: yo ``` - diff --git a/en/device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md b/en/device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md index 975baff8c25166e4e9afa703c4208aa03af5d066..ee785aeffd5fa016fe4a605183d68324aaff73dc 100644 --- a/en/device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md +++ b/en/device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md @@ -1,60 +1,43 @@ # Ramfs -## Basic Concepts<a name="section9507151014420"></a> -Ramfs is a RAM-based file system whose size can be dynamically adjusted. Ramfs does not have a backing store. Directory entries and page caches are allocated when files are written into ramfs. However, data is not written back to any other storage medium. This means that data will be lost after a power outage. - -## Working Principles<a name="section1859711263447"></a> - -Ramfs stores all files in RAM, and read/write operations are performed in RAM. Ramfs is generally used to store temporary data or data that needs to be frequently modified, such as the **/tmp** and **/var** directories. Using ramfs reduces the read/write loss of the memory and improves the data read/write speed. - -## Development Guidelines<a name="section163554380448"></a> +## Basic Concepts +Ramfs is a RAM-based file system whose size can be dynamically adjusted. Ramfs does not have a backing store. Directory entries and page caches are allocated when files are written into ramfs. However, data is not written back to any other storage medium. This means that data will be lost after a power outage. +## Working Principles +Ramfs stores all files in RAM, and read/write operations are performed in RAM. Ramfs is generally used to store temporary data or data that needs to be frequently modified, such as the **/tmp** and **/var** directories. Using ramfs reduces the read/write loss of the memory and improves the data read/write speed. +## Development Guidelines Mount: - ``` mount(NULL, "/dev/shm", "ramfs", 0, NULL) ``` - -Create a directory: - +Create a directory: ``` mkdir(pathname, mode) ``` - Create a file: - ``` open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, mode) ``` - -Read a directory: - +Read a directory: ``` dir = opendir(pathname) ptr = readdir(dir) closedir(dir) ``` - -Delete a file: - +Delete a file: ``` unlink(pathname) ``` - Delete a directory: - ``` rmdir(pathname) ``` - -Unmount: - +Unmount: ``` umount("/dev/shm") ``` - -> **CAUTION:** ->- A ramfs file system can be mounted only once. Once mounted to a directory, it cannot be mounted to other directories. ->- Ramfs is under debugging and disabled by default. Do not use it in formal products. - +>  **CAUTION**<br/> +> - A ramfs file system can be mounted only once. Once mounted to a directory, it cannot be mounted to other directories. +> +> - Ramfs is under debugging and disabled by default. Do not use it in formal products. diff --git a/en/device-dev/kernel/kernel-small-debug-shell-guide.md b/en/device-dev/kernel/kernel-small-debug-shell-guide.md index d20dd2abf4420eb5f115171aafaa697108f38ed7..3bb07ddf59843ff76a2b7f4472ecc9a089f99421 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-guide.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-guide.md @@ -1,164 +1,87 @@ -# Shell Command Development Guidelines - - -## Development Guidelines<a name="section13408945163812"></a> +# Shell Command Development You can perform the following operations to add shell commands: -1. Include the following header files: - - ``` - #include "shell.h" - #include "shcmd.h" - ``` - -2. Register commands. You can register commands either statically or dynamically when the system is running. In most cases, static registration is widely used by common system commands, and dynamic registration is widely used by user commands. - - 1. Static registration: - - 1. Register a command using a macro. - - The prototype of the macro is as follows: - - ``` - SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook) - ``` - - **Table 1** Parameters of the SHELLCMD\_ENTRY macro - - <a name="table1198543584513"></a> - <table><thead align="left"><tr id="row209856358456"><th class="cellrowborder" valign="top" width="20.91%" id="mcps1.2.3.1.1"><p id="p998583517456"><a name="p998583517456"></a><a name="p998583517456"></a><strong id="b1195317394217"><a name="b1195317394217"></a><a name="b1195317394217"></a>Parameter</strong></p> - </th> - <th class="cellrowborder" valign="top" width="79.09%" id="mcps1.2.3.1.2"><p id="p169851735174511"><a name="p169851735174511"></a><a name="p169851735174511"></a><strong id="b1958216251314"><a name="b1958216251314"></a><a name="b1958216251314"></a>Description</strong></p> - </th> - </tr> - </thead> - <tbody><tr id="row13985153574517"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p6985113513452"><a name="p6985113513452"></a><a name="p6985113513452"></a>l</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p998573514457"><a name="p998573514457"></a><a name="p998573514457"></a>Specifies the global variable name passed in static registration. Note that the name cannot be the same as other symbol names in the system.</p> - </td> - </tr> - <tr id="row398513594518"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p59856356450"><a name="p59856356450"></a><a name="p59856356450"></a>cmdType</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p119859355458"><a name="p119859355458"></a><a name="p119859355458"></a>Specifies the command type, which can be any of the following:</p> - <a name="ul11135144114816"></a><a name="ul11135144114816"></a><ul id="ul11135144114816"><li><p id="p21351144488"><a name="p21351144488"></a><a name="p21351144488"></a><strong id="b189416548121"><a name="b189416548121"></a><a name="b189416548121"></a>CMD_TYPE_EX</strong>: does not support standard command parameters and will mask the command keywords you entered. For example, if you enter <strong id="b1940315357339"><a name="b1940315357339"></a><a name="b1940315357339"></a>ls /ramfs</strong>, only <strong id="b67371541123316"><a name="b67371541123316"></a><a name="b67371541123316"></a>/ramfs</strong> will be passed to the registration function, and <strong id="b1145320313411"><a name="b1145320313411"></a><a name="b1145320313411"></a>ls</strong> will be masked.</p> - </li><li><p id="p21353410482"><a name="p21353410482"></a><a name="p21353410482"></a><strong id="b15922145203418"><a name="b15922145203418"></a><a name="b15922145203418"></a>CMD_TYPE_STD</strong>: supports standard command parameters. All the characters you entered will be passed to the registration function after being parsed.</p> - </li></ul> - </td> - </tr> - <tr id="row20985153524519"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p1098693510451"><a name="p1098693510451"></a><a name="p1098693510451"></a>cmdKey</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p11986735144514"><a name="p11986735144514"></a><a name="p11986735144514"></a>Specifies the command keyword, which is the name used to access a shell function.</p> - </td> - </tr> - <tr id="row1398683511450"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p598613359451"><a name="p598613359451"></a><a name="p598613359451"></a>paraNum</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p11986535144516"><a name="p11986535144516"></a><a name="p11986535144516"></a>Specifies the maximum number of input parameters in the execution function to be called. This parameter is not supported currently.</p> - </td> - </tr> - <tr id="row39861935154516"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p5986735114518"><a name="p5986735114518"></a><a name="p5986735114518"></a>cmdHook</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p398683574515"><a name="p398683574515"></a><a name="p398683574515"></a>Specifies the address of the execution function, that is, the function executed by the command.</p> - </td> - </tr> - </tbody> - </table> - - Example: - - ``` - SHELLCMD_ENTRY(ls_shellcmd, CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs) - ``` - - 2. Add options to the **build/mk/liteos\_tables\_ldflags.mk** file. - - For example, when registering the **ls** command, add **-uls\_shellcmd** to the **build/mk/liteos\_tables\_ldflags.mk** file. **-u** is followed by the first parameter of **SHELLCMD\_ENTRY**. - - 2. Dynamic registration: - - The prototype of the function to register is as follows: - - ``` - UINT32 osCmdReg(CmdT ype cmdType, CHAR *cmdKey, UINT32 paraNum, CmdCallBackFunc cmdProc) - ``` - - **Table 2** Parameters of UINT32 osCmdReg - - <a name="table194461933114919"></a> - <table><thead align="left"><tr id="row1644693318490"><th class="cellrowborder" valign="top" width="20.91%" id="mcps1.2.3.1.1"><p id="p1644618337493"><a name="p1644618337493"></a><a name="p1644618337493"></a><strong id="b414914114815"><a name="b414914114815"></a><a name="b414914114815"></a>Parameter</strong></p> - </th> - <th class="cellrowborder" valign="top" width="79.09%" id="mcps1.2.3.1.2"><p id="p444603317491"><a name="p444603317491"></a><a name="p444603317491"></a><strong id="b19862274819"><a name="b19862274819"></a><a name="b19862274819"></a>Description</strong></p> - </th> - </tr> - </thead> - <tbody><tr id="row844643374912"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p14446133319498"><a name="p14446133319498"></a><a name="p14446133319498"></a>cmdType</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p174461339496"><a name="p174461339496"></a><a name="p174461339496"></a>Specifies the command type, which can be any of the following:</p> - <a name="ul1244773317496"></a><a name="ul1244773317496"></a><ul id="ul1244773317496"><li><p id="p1844719331495"><a name="p1844719331495"></a><a name="p1844719331495"></a><strong id="b1596594718"><a name="b1596594718"></a><a name="b1596594718"></a>CMD_TYPE_EX</strong>: does not support standard command parameters and will mask the command keywords you entered. For example, if you enter <strong id="b134411664"><a name="b134411664"></a><a name="b134411664"></a>ls /ramfs</strong>, only <strong id="b384234630"><a name="b384234630"></a><a name="b384234630"></a>/ramfs</strong> will be passed to the registration function, and <strong id="b1102747310"><a name="b1102747310"></a><a name="b1102747310"></a>ls</strong> will be masked.</p> - </li><li><p id="p20447143315498"><a name="p20447143315498"></a><a name="p20447143315498"></a><strong id="b97295345"><a name="b97295345"></a><a name="b97295345"></a>CMD_TYPE_STD</strong>: supports standard command parameters. All the characters you entered will be passed to the registration function after being parsed.</p> - </li></ul> - </td> - </tr> - <tr id="row14471733184915"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p744783319494"><a name="p744783319494"></a><a name="p744783319494"></a>cmdKey</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p18447833124914"><a name="p18447833124914"></a><a name="p18447833124914"></a>Specifies the command keyword, which is the name used to access a shell function.</p> - </td> - </tr> - <tr id="row17447143317495"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p174477331495"><a name="p174477331495"></a><a name="p174477331495"></a>paraNum</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p8447233184914"><a name="p8447233184914"></a><a name="p8447233184914"></a>Specifies the maximum number of input parameters in the execution function to be called. This parameter is not supported currently. The default value is <strong id="b1425195414484"><a name="b1425195414484"></a><a name="b1425195414484"></a>XARGS(0xFFFFFFFF)</strong>.</p> - </td> - </tr> - <tr id="row10447233174913"><td class="cellrowborder" valign="top" width="20.91%" headers="mcps1.2.3.1.1 "><p id="p18447183334920"><a name="p18447183334920"></a><a name="p18447183334920"></a>cmdHook</p> - </td> - <td class="cellrowborder" valign="top" width="79.09%" headers="mcps1.2.3.1.2 "><p id="p44471533184912"><a name="p44471533184912"></a><a name="p44471533184912"></a>Specifies the address of the execution function, that is, the function executed by the command.</p> - </td> - </tr> - </tbody> - </table> - - Example: - - ``` - osCmdReg(CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs) - ``` +1. Include header files. - > **NOTE:** - >The command keyword must be unique. That is, two different commands cannot share the same command keyword. Otherwise, only one command is executed. - >When executing user commands sharing the same keyword, the shell executes only the first command in the **help** commands. + + ``` + #include "shell.h" + #include "shcmd.h" + ``` -3. Use the following function prototype to add built-in commands: +2. Register commands. - ``` - UINT32 osShellCmdLs(UINT32 argc, CHAR **argv) - ``` + You can register commands either statically or dynamically (with the system running). Generally, common system commands are registered statically, and user commands are registered dynamically. - **Table 3** Parameters of osShellCmdLs + - Static registration - <a name="table174451958105116"></a> - <table><thead align="left"><tr id="row84451058105117"><th class="cellrowborder" valign="top" width="24.42%" id="mcps1.2.3.1.1"><p id="p1644515855111"><a name="p1644515855111"></a><a name="p1644515855111"></a><strong id="b710871813012"><a name="b710871813012"></a><a name="b710871813012"></a>Parameter</strong></p> - </th> - <th class="cellrowborder" valign="top" width="75.58%" id="mcps1.2.3.1.2"><p id="p18445145805113"><a name="p18445145805113"></a><a name="p18445145805113"></a><strong id="b12608195015"><a name="b12608195015"></a><a name="b12608195015"></a>Description</strong></p> - </th> - </tr> - </thead> - <tbody><tr id="row194461458185112"><td class="cellrowborder" valign="top" width="24.42%" headers="mcps1.2.3.1.1 "><p id="p64461158145120"><a name="p64461158145120"></a><a name="p64461158145120"></a>argc</p> - </td> - <td class="cellrowborder" valign="top" width="75.58%" headers="mcps1.2.3.1.2 "><p id="p1844625885112"><a name="p1844625885112"></a><a name="p1844625885112"></a>Specifies the number of parameters in the shell command.</p> - </td> - </tr> - <tr id="row144620587511"><td class="cellrowborder" valign="top" width="24.42%" headers="mcps1.2.3.1.1 "><p id="p244625811517"><a name="p244625811517"></a><a name="p244625811517"></a>argv</p> - </td> - <td class="cellrowborder" valign="top" width="75.58%" headers="mcps1.2.3.1.2 "><p id="p11446958105119"><a name="p11446958105119"></a><a name="p11446958105119"></a>Specifies a pointer array, where each element points to a string. You can determine whether to pass the command keyword to the registration function by specifying the command type.</p> - </td> - </tr> - </tbody> - </table> + 1. Register a command using a macro. -4. Enter the shell command in either of the following methods: - - Enter the shell command in a serial port tool. + The prototype of the macro is as follows: - - Enter the shell command in the Telnet tool. For details, see [telnet](kernel-small-debug-shell-net-telnet.md). + ``` + SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook) + ``` + **Table 1** SHELLCMD_ENTRY parameters + | Parameter| Description| + | -------- | -------- | + | l | Specifies the global variable name passed in static registration. Note that the name cannot be the same as other symbol names in the system.| + | cmdType | Specifies the command type, which can be any of the following:<br>**CMD_TYPE_EX**: does not support standard command parameters and will mask the command keywords you entered. For example, if you enter **ls /ramfs**, only **/ramfs** will be passed to the registration function and **ls** will be masked.<br>**CMD_TYPE_STD**: supports standard command parameters. All the characters you entered will be passed to the registration function after being parsed. | + | cmdKey | Specifies the command keyword, which is the name used to access a shell function.| + | paraNum | Specifies the maximum number of input parameters in the execution function to be called. This parameter is not supported currently.| + | cmdHook | Specifies the address of the execution function, that is, the function executed by the command.| + Example: + + ``` + SHELLCMD_ENTRY(ls_shellcmd, CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs) + ``` + + + 2. Add options to the **build/mk/liteos_tables_ldflags.mk** file. + + For example, when registering the **ls** command, add **-uls_shellcmd** to the **build/mk/liteos_tables_ldflags.mk** file. **-u** is followed by the first parameter of **SHELLCMD_ENTRY**. + + - Dynamic registration + + The prototype of the function to register is as follows: + + ``` + UINT32 osCmdReg(CmdT ype cmdType, CHAR *cmdKey, UINT32 paraNum, CmdCallBackFunc cmdProc) + ``` + **Table 2** UINT32 osCmdReg parameters + | Parameter| Description| + | -------- | -------- | + | cmdType | Specifies the command type, which can be any of the following:<br>**CMD_TYPE_EX**: does not support standard command parameters and will mask the command keywords you entered. For example, if you enter **ls /ramfs**, only **/ramfs** will be passed to the registration function, and **ls** will be masked.<br>**CMD_TYPE_STD**: supports standard command parameters. All the characters you entered will be passed to the registration function after being parsed.| + | cmdKey | Specifies the command keyword, which is the name used to access a shell function.| + | paraNum | Specifies the maximum number of input parameters in the execution function to be called. This parameter is not supported currently. The default value is **XARGS(0xFFFFFFFF)**.| + | cmdHook | Specifies the address of the execution function, that is, the function executed by the command.| + + Example: + ``` + osCmdReg(CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs) + ``` +  NOTE<br> + > The command keyword must be unique. That is, two different commands cannot share the same command keyword. Otherwise, only one command is executed. When executing user commands sharing the same keyword, the shell executes only the first command in the **help** commands. + + +3. Use the following function prototype to add built-in commands: + + ``` + UINT32 osShellCmdLs(UINT32 argc, CHAR **argv) + ``` + + **Table 3** osShellCmdLs parameters + + | Parameter| Description| + | -------- | -------- | + | argc | Specifies the number of parameters in the shell command.| + | argv | Specifies a pointer array, where each element points to a string. You can determine whether to pass the command keyword to the registration function by specifying the command type.| + +4. Enter the shell command in either of the following methods: + + - Enter the shell command using a serial port tool. + - Enter the shell command using the Telnet tool. For details about how to use Telnet, see [telnet](../kernel/kernel-small-debug-shell-net-telnet.md). diff --git a/en/device-dev/kernel/kernel-small-debug-shell-magickey.md b/en/device-dev/kernel/kernel-small-debug-shell-magickey.md index 95dd7f69f0160ae301c51a210ddb51c3c357728b..80248ba4e5fbc59fbef823ca8b34e8584709c243 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-magickey.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-magickey.md @@ -1,42 +1,36 @@ # Magic Key -## When to Use<a name="section2350114718546"></a> +## When to Use -When the system does not respond, you can use the magic key to check whether the system is locked and interrupted \(the magic key also does not respond\) or view the system task running status. +When the system does not respond, you can use the magic key function to check whether the system is suspended by an interrupt lock (the magic key also does not respond) or view the system task running status. -If an interrupt is responded, you can use the magic key to check the task CPU usage \(**cpup**\) and find out the task with the highest CPU usage. Generally, the task with a higher priority preempts the CPU resources. +If interrupts are responded, you can use the magic key to check the task CPU usage (**cpup**) and find out the task with the highest CPU usage. Generally, the task with a higher priority preempts the CPU resources. -## How to Use<a name="section3305151511559"></a> -1. Configure the macro **LOSCFG\_ENABLE\_MAGICKEY**. +## How to Use -The magic key depends on the **LOSCFG\_ENABLE\_MAGICKEY** macro. Before using the magic key, select **Enable MAGIC KEY** on **menuconfig**. +1. Configure the macro **LOSCFG_ENABLE_MAGICKEY**. -**Enable MAGIC KEY**: **Debug** ---\> **Enable MAGIC KEY** + The magic key depends on the **LOSCFG_ENABLE_MAGICKEY** macro. Before using the magic key, select **Enable MAGIC KEY** (**Debug** ---> **Enable MAGIC KEY**) on **menuconfig**. The magic key cannot be used if this option is disabled. -The magic key cannot be used if this macro is disabled. + >  **NOTE** + > + > On **menuconfig**, you can move the cursor to **LOSCFG_ENABLE_MAGICKEY** and enter a question mark (?) to view help Information. + +2. Press **Ctrl+R** to enable the magic key. -> **NOTE:** ->On **menuconfig**, you can move the cursor to **LOSCFG\_ENABLE\_MAGICKEY** and type a question mark \(?\) to view help information. + When the UART or USB-to-virtual serial port is connected, press **Ctrl+R**. If "Magic key on" is displayed, the magic key is enabled. To disable it, press **Ctrl+R** again. If "Magic key off" is displayed, the magic key is disabled. -2. Press **Ctrl+R** to enable the magic key. + The functions of the magic key are as follows: -When the UART or USB-to-virtual serial port is connected, press **Ctrl+R**. If "Magic key on" is displayed, the magic key is enabled. + - **Ctrl+Z**: displays help information about the related magic keys. -To disable the magic key, press **Ctrl+R** again. If "Magic key off" is displayed, the magic key is disabled. + - **Ctrl+T**: displays task information. -You can use the magic key combinations as follows: - -- **Ctrl+Z**: displays help information about the related magic keys. - -- **Ctrl+T**: displays task information. - -- **Ctrl+P**: allows the system to proactively enter the panic state. After the panic-related information is printed, the system is suspended. - -- **Ctrl+E**: Checks the integrity of the memory pool. If an error is detected, the system displays an error message. If no error is detected, the system displays "system memcheck over, all passed!". - - -> **NOTICE:** ->If magic key is enabled, when special characters need to be entered through the UART or USB-to-virtual serial port, avoid using characters the same as the magic keys. Otherwise, the magic key may be triggered by mistake, causing errors in the original design. + - **Ctrl+P**: allows the system to proactively enter the panic state. After the panic-related information is printed, the system is suspended. + - **Ctrl+E**: Checks the integrity of the memory pool. If an error is detected, the system displays an error message. If no error is detected, the system displays "system memcheck over, all passed!". + + >  **NOTICE**<br> + > If magic key is enabled, when special characters need to be entered through the UART or USB-to-virtual serial port, avoid using characters the same as the magic keys. Otherwise, the magic key may be triggered by mistake, causing errors in the original design. diff --git a/en/device-dev/kernel/kernel-small-debug-shell-overview.md b/en/device-dev/kernel/kernel-small-debug-shell-overview.md index 5ac89f7eb900197534dca3a3d73846a9bdde0b6f..7c1ce9d0e6e8d0caf21fc5bd38d7c4f976de65eb 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-overview.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-overview.md @@ -1,35 +1,34 @@ -# Introduction to the Shell +# Shell The shell provided by the OpenHarmony kernel supports commonly used debugging commands. You can also add and customize commands to the shell of the OpenHarmony kernel to address your service needs. The common debugging commands include the following: -- System commands: commands used to query information, such as system tasks, semaphores, system software timers, CPU usage, and interrupts. -- File commands: commands used to manage files and directories, such as **ls** and **cd**. +- System commands: commands used to query information, such as system tasks, semaphores, system software timers, CPU usage, and interrupts. -- Network commands: commands used to query the IP addresses of other devices connected to the development board, querying the IP address of the local device, testing network connectivity, and setting the access point \(AP\) and station \(STA\) modes of the development board. +- File commands: commands used to manage files and directories, such as **ls** and **cd**. - For details about how to add a command, see [Shell Command Development Guidelines](kernel-small-debug-shell-guide.md) and [Shell Command Programming Example](kernel-small-debug-shell-build.md). +- Network commands: commands used to query the IP addresses of other devices connected to the development board, querying the IP address of the local device, testing network connectivity, and setting the access point (AP) and station (STA) modes of the development board. + For details about the process of adding commands, see [Shell Command Development](../kernel/kernel-small-debug-shell-guide.md) and [Shell Command Programming Example](../kernel/kernel-small-debug-shell-build.md). -## Important Notes -Note the following when using the shell: + **Precautions** -- You can use the **exec** command to run executable files. -- The shell supports English input by default. To delete the Chinese characters entered in UTF-8 format, press the backspace key for three times. +Note the following when using shell: -- When entering shell commands, file names, and directory names, you can press **Tab** to enable automatic completion. If there are multiple completions, multiple items are printed based on the same characters they have. If more than 24 lines of completions are available, the system displays the message "Display all num possibilities?\(y/n\)", asking you to determine whether to print all items. You can enter **y** to print all items or enter **n** to exit the printing. If more than 24 lines are printed after your selection, the system displays "--More--". In this case, you can press **Enter** to continue the printing or press **q** \(or **Ctrl+c**\) to exit. +- You can use the **exec** command to run executable files. -- The shell working directory is separated from the system working directory. You can run commands such as **cd** and **pwd** on the shell to perform operations on the shell working directory, and run commands such as **chdir** and **getcwd** to perform operations on the system working directory. Pay special attention when an input parameter in a file system operation command is a relative path. +- The shell supports English input by default. To delete the Chinese characters entered in UTF-8 format, press the backspace key for three times. -- Before using network shell commands, you need to call the **tcpip\_init** function to initialize the network and set up the Telnet connection. By default, the kernel does not call **tcpip\_init**. +- When entering shell commands, file names, and directory names, you can press **Tab** to enable automatic completion. If there are multiple completions, multiple items are printed based on the same characters they have. If more than 24 lines of completions are available, the system displays the message "Display all num possibilities?(y/n)", asking you to determine whether to print all items. You can enter **y** to print all items or enter **n** to exit the printing. If more than 24 lines are printed after your selection, the system displays "--More--". In this case, you can press **Enter** to continue the printing or press **q** (or **Ctrl+c**) to exit. -- You are not advised to run shell commands to perform operations on device files in the **/dev** directory, which may cause unexpected results. +- The shell working directory is separated from the system working directory. You can run commands such as **cd** and **pwd** on the shell to perform operations on the shell working directory, and run commands such as **chdir** and **getcwd** to perform operations on the system working directory. Pay special attention when an input parameter in a file system operation command is a relative path. -- The shell functions do not comply with the POSIX standards and are used only for debugging. - - > **NOTICE**<br/> - >The shell functions are used for debugging only and can be enabled only in the Debug version \(by enabling the **LOSCFG\_DEBUG\_VERSION** configuration item using **menuconfig**\). +- Before using network shell commands, you need to call the **tcpip_init** function to initialize the network and set up the Telnet connection. By default, the kernel does not call **tcpip_init**. +- You are not advised to run shell commands to perform operations on device files in the **/dev** directory, which may cause unexpected results. +- The shell functions do not comply with the POSIX standards and are used only for debugging. + >  **NOTICE**<br> + > The shell functions are used for debugging only and can be enabled only in the Debug version (by enabling **LOSCFG_DEBUG_VERSION** using **menuconfig**). diff --git a/en/device-dev/kernel/kernel-small-debug-trace.md b/en/device-dev/kernel/kernel-small-debug-trace.md index b808e35d2515e9ede4def18ec35fd7a06a638d59..df41fd67f3d7d2ddc196e1ea4ddc3c10e701aa95 100644 --- a/en/device-dev/kernel/kernel-small-debug-trace.md +++ b/en/device-dev/kernel/kernel-small-debug-trace.md @@ -1,10 +1,12 @@ # Trace -## Basic Concepts<a name="section531482192018"></a> + +## Basic Concepts Trace helps you learn about the kernel running process and the execution sequence of modules and tasks. With the information, you can better understand the code running process of the kernel and locate time sequence problems. -## Working Principles<a name="section5125124532010"></a> + +## Working Principles The kernel provides a hook framework to embed hooks in the main process of each module. In the initial startup phase of the kernel, the trace function is initialized and the trace handlers are registered with the hooks. @@ -16,170 +18,117 @@ In offline mode, trace frames are stored in a circular buffer. If too many frame  -The online mode must be used with the integrated development environment \(IDE\). Trace frames are sent to the IDE in real time. The IDE parses the records and displays them in a visualized manner. - -## **Available APIs**<a name="section17747184017458"></a> - -### Kernel Mode<a name="section104473014465"></a> - -The trace module of the OpenHarmony LiteOS-A kernel provides the following functions. For details about the APIs, see the [API](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_trace.h) reference. - -**Table 1** Trace module APIs - -<a name="table1290750144615"></a> -<table><thead align="left"><tr id="row92916507464"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p1429185074615"><a name="p1429185074615"></a><a name="p1429185074615"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1729115010467"><a name="p1729115010467"></a><a name="p1729115010467"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p12911501463"><a name="p12911501463"></a><a name="p12911501463"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row9287279472"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p12191827104720"><a name="p12191827104720"></a><a name="p12191827104720"></a>Starting and stopping trace</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1519152774719"><a name="p1519152774719"></a><a name="p1519152774719"></a>LOS_TraceStart</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p619102714475"><a name="p619102714475"></a><a name="p619102714475"></a>Starts trace.</p> -</td> -</tr> -<tr id="row17281727204713"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p519162715477"><a name="p519162715477"></a><a name="p519162715477"></a>LOS_TraceStop</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p12191827164710"><a name="p12191827164710"></a><a name="p12191827164710"></a>Stops trace.</p> -</td> -</tr> -<tr id="row428102714719"><td class="cellrowborder" rowspan="3" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1019327194717"><a name="p1019327194717"></a><a name="p1019327194717"></a>Managing trace records</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1319142714474"><a name="p1319142714474"></a><a name="p1319142714474"></a>LOS_TraceRecordDump</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p0192275474"><a name="p0192275474"></a><a name="p0192275474"></a>Exports data in the trace buffer.</p> -</td> -</tr> -<tr id="row192852794713"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1419827104715"><a name="p1419827104715"></a><a name="p1419827104715"></a>LOS_TraceRecordGet</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1619162715479"><a name="p1619162715479"></a><a name="p1619162715479"></a>Obtains the start address of the trace buffer.</p> -</td> -</tr> -<tr id="row172882764719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1019527134714"><a name="p1019527134714"></a><a name="p1019527134714"></a>LOS_TraceReset</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1619192720473"><a name="p1619192720473"></a><a name="p1619192720473"></a>Clears events in the trace buffer.</p> -</td> -</tr> -<tr id="row82715275472"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1419122716473"><a name="p1419122716473"></a><a name="p1419122716473"></a>Filtering trace records</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p121917278472"><a name="p121917278472"></a><a name="p121917278472"></a>LOS_TraceEventMaskSet</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1419927154711"><a name="p1419927154711"></a><a name="p1419927154711"></a>Sets the event mask to trace only events of the specified modules.</p> -</td> -</tr> -<tr id="row827827174718"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p9201275471"><a name="p9201275471"></a><a name="p9201275471"></a>Masking events of specified interrupt IDs</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p720112717476"><a name="p720112717476"></a><a name="p720112717476"></a>LOS_TraceHwiFilterHookReg</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p192042713475"><a name="p192042713475"></a><a name="p192042713475"></a>Registers a hook to filter out events of specified interrupt IDs.</p> -</td> -</tr> -<tr id="row42714279476"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p172011270476"><a name="p172011270476"></a><a name="p172011270476"></a>Performing function instrumentation</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1120122754714"><a name="p1120122754714"></a><a name="p1120122754714"></a>LOS_TRACE_EASY</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p12032714717"><a name="p12032714717"></a><a name="p12032714717"></a>Performs simple instrumentation.</p> -</td> -</tr> -<tr id="row1927122734715"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p52062712478"><a name="p52062712478"></a><a name="p52062712478"></a>LOS_TRACE</p> -</td> -<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p182062734713"><a name="p182062734713"></a><a name="p182062734713"></a>Performs standard instrumentation.</p> -</td> -</tr> -</tbody> -</table> - -- You can perform function instrumentation in the source code to trace specific events. The system provides the following APIs for instrumentation: - - **LOS\_TRACE\_EASY\(TYPE, IDENTITY, params...\)** for simple instrumentation - - You only need to insert this API into the source code. - - **TYPE** specifies the event type. The value range is 0 to 0xF. The meaning of each value is user-defined. - - **IDENTITY** specifies the object of the event operation. The value is of the **UIntPtr** type. - - **Params** specifies the event parameters. The value is of the **UIntPtr** type. - - Example: - - ``` - Perform simple instrumentation for reading and writing files fd1 and fd2. - Set TYPE to 1 for read operations and 2 for write operations. - Insert the following to the position where the fd1 file is read: - LOS_TRACE_EASY(1, fd1, flag, size); - Insert the following to the position where the fd2 file is read: - LOS_TRACE_EASY(1, fd2, flag, size); - Insert the following to the position where the fd1 file is written: - LOS_TRACE_EASY(2, fd1, flag, size); - Insert the following in the position where the fd2 file is written: - LOS_TRACE_EASY(2, fd2, flag, size); - ``` - - - **LOS\_TRACE\(TYPE, IDENTITY, params...\)** for standard instrumentation. - - Compared with simple instrumentation, standard instrumentation supports dynamic event filtering and parameter tailoring. However, you need to extend the functions based on rules. - - **TYPE** specifies the event type. You can define the event type in **enum LOS\_TRACE\_TYPE** in the header file **los\_trace.h**. For details about methods and rules for defining events, see other event types. - - The **IDENTITY** and **Params** are the same as those of simple instrumentation. - - Example: - - ``` - 1. Set the event mask (module-level event type) in enum LOS_TRACE_MASK. - Format: TRACE_#MOD#_FLAG (MOD indicates the module name) - Example: - TRACE_FS_FLAG = 0x4000 - 2. Define the event type in enum LOS_TRACE_TYPE. - Format: #TYPE# = TRACE_#MOD#_FLAG | NUMBER - Example: - FS_READ = TRACE_FS_FLAG | 0; // Read files - FS_WRITE = TRACE_FS_FLAG | 1; // Write files - 3. Set event parameters in the #TYPE#_PARAMS(IDENTITY, parma1...) IDENTITY, ... format. - #TYPE# is the #TYPE# defined in step 2. - Example: - #define FS_READ_PARAMS(fp, fd, flag, size) fp, fd, flag, size - The parameters defined by the macro correspond to the event parameters recorded in the trace buffer. You can modify the parameters as required. - If no parameter is specified, events of this type are not traced. - #define FS_READ_PARAMS(fp, fd, flag, size) // File reading events are not traced. - 4. Insert a code stub in a proper position. - Format: LOS_TRACE(#TYPE#, #TYPE#_PARAMS(IDENTITY, parma1...)) - LOS_TRACE(FS_READ, fp, fd, flag, size); // Code stub for reading files - The parameters following #TYPE# are the input parameter of the FS_READ_PARAMS function in step 3. - ``` - - > **NOTE:** - >The trace event types and parameters can be modified as required. For details about the parameters, see **kernel\\include\\los\_trace.h**. - - - -- For **LOS\_TraceEventMaskSet\(UINT32 mask\)**, only the most significant 28 bits \(corresponding to the enable bit of the module in **LOS\_TRACE\_MASK**\) of the mask take effect and are used only for module-based tracing. Currently, fine-grained event-based tracing is not supported. For example, in **LOS\_TraceEventMaskSet\(0x202\)**, the effective mask is **0x200 \(TRACE\_QUE\_FLAG\)** and all events of the QUE module are collected. The recommended method is **LOS\_TraceEventMaskSet\(TRACE\_EVENT\_FLAG | TRACE\_MUX\_FLAG | TRACE\_SEM\_FLAG | TRACE\_QUE\_FLAG\);**. -- To enable trace of only simple instrumentation events, set **Trace Mask** to **TRACE\_MAX\_FLAG**. -- The trace buffer has limited capacity. When the trace buffer is full, events will be overwritten. You can use **LOS\_TraceRecordDump** to export data from the trace buffer and locate the latest records by **CurEvtIndex**. -- The typical trace operation process includes **LOS\_TraceStart**, **LOS\_TraceStop**, and **LOS\_TraceRecordDump**. -- You can filter out interrupt events by interrupt ID to prevent other events from being overwritten due to frequent triggering of a specific interrupt in some scenarios. You can customize interrupt filtering rules. - - The sample code is as follows: - - ``` - BOOL Example_HwiNumFilter(UINT32 hwiNum) - { - if ((hwiNum == TIMER_INT) || (hwiNum == DMA_INT)) { - return TRUE; - } - return FALSE; +The online mode must be used with the integrated development environment (IDE). Trace frames are sent to the IDE in real time. The IDE parses the records and displays them in a visualized manner. + + +## Available APIs + + +### Kernel Mode + +The trace module of the OpenHarmony LiteOS-A kernel provides the following APIs. For more details, see [API reference](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_trace.h). + + **Table 1** APIs of the trace module + +| Category| Description| +| -------- | -------- | +| Starting/Stopping trace| **LOS_TraceStart**: starts trace.<br>**LOS_TraceStop**: stops trace. | +| Managing trace records| **LOS_TraceRecordDump**: dumps data from the trace buffer.<br>**LOS_TraceRecordGet**: obtains the start address of the trace buffer.<br>**LOS_TraceReset**: clears events in the trace buffer. | +| Filtering trace records| **LOS_TraceEventMaskSet**: sets the event mask to trace only events of the specified modules.| +| Masking events of specified interrupt IDs| **LOS_TraceHwiFilterHookReg**: registers a hook to filter out events of specified interrupt IDs.| +| Performing function instrumentation| **LOS_TRACE_EASY**: performs simple instrumentation.<br>**LOS_TRACE**: performs standard instrumentation. | + +You can perform function instrumentation in the source code to trace specific events. The system provides the following APIs for instrumentation: + +- **LOS_TRACE_EASY(TYPE, IDENTITY, params...)** for simple instrumentation + + - You only need to insert this API into the source code. + - **TYPE** specifies the event type. The value range is 0 to 0xF. The meaning of each value is user-defined. + - **IDENTITY** specifies the object of the event operation. The value is of the **UIntPtr** type. + - **Params** specifies the event parameters. The value is of the **UIntPtr** type. + Example: + + ``` + Perform simple instrumentation for reading and writing files fd1 and fd2. + Set TYPE to 1 for read operations and 2 for write operations. + Insert the following to the position where the fd1 file is read: + LOS_TRACE_EASY(1, fd1, flag, size); + Insert the following to the position where the fd2 file is read: + LOS_TRACE_EASY(1, fd2, flag, size); + Insert the following to the position where the fd1 file is written: + LOS_TRACE_EASY(2, fd1, flag, size); + Insert the following in the position where the fd2 file is written: + LOS_TRACE_EASY(2, fd2, flag, size); + ``` +- **LOS_TRACE(TYPE, IDENTITY, params...)** for standard instrumentation. + - Compared with simple instrumentation, standard instrumentation supports dynamic event filtering and parameter tailoring. However, you need to extend the functions based on rules. + - **TYPE** specifies the event type. You can define the event type in **enum LOS_TRACE_TYPE** in the header file **los_trace.h**. For details about methods and rules for defining events, see other event types. + - The **IDENTITY** and **Params** are the same as those of simple instrumentation. + Example: + + ``` + 1. Set the event mask (module-level event type) in enum LOS_TRACE_MASK. + Format: TRACE_#MOD#_FLAG (MOD indicates the module name) + Example: + TRACE_FS_FLAG = 0x4000 + 2. Define the event type in **enum LOS_TRACE_TYPE**. + Format: #TYPE# = TRACE_#MOD#_FLAG | NUMBER + Example: + FS_READ = TRACE_FS_FLAG | 0; // Read files. + FS_WRITE = TRACE_FS_FLAG | 1; // Write files. + 3. Set event parameters in the #TYPE#_PARAMS(IDENTITY, parma1...) IDENTITY, ... format. + #TYPE# is the #TYPE# defined in step 2. + Example: + #define FS_READ_PARAMS(fp, fd, flag, size) fp, fd, flag, size + The parameters defined by the macro correspond to the event parameters recorded in the trace buffer. You can modify the parameters as required. + If no parameter is specified, events of this type are not traced. + #define FS_READ_PARAMS(fp, fd, flag, size) // File reading events are not traced. + 4. Insert a code stub in a proper position. + Format: LOS_TRACE(#TYPE#, #TYPE#_PARAMS(IDENTITY, parma1...)) + LOS_TRACE(FS_READ, fp, fd, flag, size); // Code stub for reading files. + The parameters following #TYPE# are the input parameter of the **FS_READ_PARAMS** function in step 3. + ``` + + >  **NOTE**<br> + > The trace event types and parameters can be modified as required. For details about the parameters, see **kernel\include\los_trace.h**. + +For **LOS_TraceEventMaskSet(UINT32 mask)**, only the most significant 28 bits (corresponding to the enable bit of the module in **LOS_TRACE_MASK**) of the mask take effect and are used only for module-based tracing. Currently, fine-grained event-based tracing is not supported. For example, in **LOS_TraceEventMaskSet(0x202)**, the effective mask is **0x200 (TRACE_QUE_FLAG)** and all events of the QUE module are collected. The recommended method is **LOS_TraceEventMaskSet(TRACE_EVENT_FLAG | TRACE_MUX_FLAG | TRACE_SEM_FLAG | TRACE_QUE_FLAG);**. + +To enable trace of only simple instrumentation events, set **Trace Mask** to **TRACE_MAX_FLAG**. + +The trace buffer has limited capacity. When the trace buffer is full, events will be overwritten. You can use **LOS_TraceRecordDump** to export data from the trace buffer and locate the latest records by **CurEvtIndex**. + +The typical trace operation process includes **LOS_TraceStart**, **LOS_TraceStop**, and **LOS_TraceRecordDump**. + +You can filter out interrupt events by interrupt ID to prevent other events from being overwritten due to frequent triggering of a specific interrupt in some scenarios. You can customize interrupt filtering rules. + +Example: + +``` +BOOL Example_HwiNumFilter(UINT32 hwiNum) +{ + if ((hwiNum == TIMER_INT) || (hwiNum == DMA_INT)) { + return TRUE; } - LOS_TraceHwiFilterHookReg(Example_HwiNumFilter); - ``` + return FALSE; +} +LOS_TraceHwiFilterHookReg(Example_HwiNumFilter); +``` + +The interrupt events with interrupt ID of **TIMER_INT** or **DMA_INT** are not traced. + +### User Mode -The interrupt events with interrupt ID of **TIMER\_INT** or **DMA\_INT** are not traced. +The trace character device is added in **/dev/trace**. You can use **read()**, **write()**, and **ioctl()** on the device node to read, write, and control trace in user mode. -### User Mode<a name="section1996920294531"></a> +- **read()**: reads the trace data in user mode. -The trace character device is added in **/dev/trace**. You can use **read\(\)**, **write\(\)**, and **ioctl\(\)** on the device node to read, write, and control trace in user mode. +- **write()**: writes an event in user mode. -- **read\(\)**: reads the trace data in user mode. -- **write\(\)**: writes an event in user mode. -- **ioctl\(\)**: performs user-mode trace operations, including: +- **ioctl()**: performs user-mode trace operations, including: + ``` #define TRACE_IOC_MAGIC 'T' #define TRACE_START _IO(TRACE_IOC_MAGIC, 1) @@ -189,134 +138,77 @@ The trace character device is added in **/dev/trace**. You can use **read\(\)* #define TRACE_SET_MASK _IO(TRACE_IOC_MAGIC, 5) ``` -The operations specified by the input parameter of **ioctl\(\)** correspond to **LOS\_TraceStart**, **LOS\_TraceStop**, **LOS\_TraceReset**, **LOS\_TraceRecordDump**, and **LOS\_TraceEventMaskSet**, respectively. +The operations specified by the input parameter of **ioctl()** correspond to **LOS_TraceStart**, **LOS_TraceStop**, **LOS_TraceReset**, **LOS_TraceRecordDump**, and **LOS_TraceEventMaskSet**, respectively. + +For details, see [User-Mode Development Example](kernel-small-debug-trace.md#user-mode). + -For more details, see [User-mode Programming Example](https://gitee.com/openharmony/docs/blob/70744e1e0e34d66e11108a00c8db494eea49dd02/en/device-dev/kernel/kernel-small-debug-trace.md#section4.2.2). +## Development Guidelines -## Development Guidelines<a name="section10302175017543"></a> -### Kernel-mode Development Process<a name="section04021008552"></a> +### Kernel-Mode Development Process The typical trace process is as follows: -1. Configure the macro related to the trace module. - - Configure the trace macro **LOSCFG\_KERNEL\_TRACE**, which is disabled by default. Run the **make update\_config** command in the **kernel/liteos\_a** directory, choose **Kernel** \> **Enable Hook Feature**, and set **Enable Trace Feature** to **YES**. - - <a name="table16145182665619"></a> - <table><thead align="left"><tr id="row16145192611566"><th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.1"><p id="p18145726175614"><a name="p18145726175614"></a><a name="p18145726175614"></a>Configuration</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.2"><p id="p15145162613562"><a name="p15145162613562"></a><a name="p15145162613562"></a>menuconfig Option</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.3"><p id="p111451263569"><a name="p111451263569"></a><a name="p111451263569"></a>Description</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.4"><p id="p12145112616562"><a name="p12145112616562"></a><a name="p12145112616562"></a>Value</p> - </th> - </tr> - </thead> - <tbody><tr id="row5318402576"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p330560125717"><a name="p330560125717"></a><a name="p330560125717"></a>LOSCFG_KERNEL_TRACE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p83051406576"><a name="p83051406576"></a><a name="p83051406576"></a>Enable Trace Feature</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p1530512018572"><a name="p1530512018572"></a><a name="p1530512018572"></a>Specifies whether to enable the trace feature.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p123051600573"><a name="p123051600573"></a><a name="p123051600573"></a>YES/NO</p> - </td> - </tr> - <tr id="row1731810085715"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p1930514019579"><a name="p1930514019579"></a><a name="p1930514019579"></a>LOSCFG_RECORDER_MODE_OFFLINE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p1830511011573"><a name="p1830511011573"></a><a name="p1830511011573"></a>Trace work mode ->Offline mode</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p23051509577"><a name="p23051509577"></a><a name="p23051509577"></a>Specifies whether to enable the online trace mode.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p630514085717"><a name="p630514085717"></a><a name="p630514085717"></a>YES/NO</p> - </td> - </tr> - <tr id="row13189005711"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p1305110165716"><a name="p1305110165716"></a><a name="p1305110165716"></a>LOSCFG_RECORDER_MODE_ONLINE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p9305709579"><a name="p9305709579"></a><a name="p9305709579"></a>Trace work mode ->Online mode</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p1330610175717"><a name="p1330610175717"></a><a name="p1330610175717"></a>Specifies whether to enable the offline trace mode.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p18306180185715"><a name="p18306180185715"></a><a name="p18306180185715"></a>YES/NO</p> - </td> - </tr> - <tr id="row3318603579"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p1830616035713"><a name="p1830616035713"></a><a name="p1830616035713"></a>LOSCFG_TRACE_CLIENT_INTERACT</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p230613005719"><a name="p230613005719"></a><a name="p230613005719"></a>Enable Trace Client Visualization and Control</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p19306200125711"><a name="p19306200125711"></a><a name="p19306200125711"></a>Specifies whether to enable interaction with Trace IDE (dev tools), including data visualization and process control.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p16306130155720"><a name="p16306130155720"></a><a name="p16306130155720"></a>YES/NO</p> - </td> - </tr> - <tr id="row23181607578"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p83064095720"><a name="p83064095720"></a><a name="p83064095720"></a>LOSCFG_TRACE_FRAME_CORE_MSG</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p730611075711"><a name="p730611075711"></a><a name="p730611075711"></a>Enable Record more extended content ->Record cpuid, hardware interrupt status, task lock status</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p83061018576"><a name="p83061018576"></a><a name="p83061018576"></a>Specifies whether to enable recording of the CPU ID, interruption state, and lock task state.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p19306805574"><a name="p19306805574"></a><a name="p19306805574"></a>YES/NO</p> - </td> - </tr> - <tr id="row8318904574"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p430617095718"><a name="p430617095718"></a><a name="p430617095718"></a>LOSCFG_TRACE_FRAME_EVENT_COUNT</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p13064013576"><a name="p13064013576"></a><a name="p13064013576"></a>Enable Record more extended content ->Record event count, which indicate the sequence of happend events</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p133061203576"><a name="p133061203576"></a><a name="p133061203576"></a>Specifies whether to enables recording of the event sequence number.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p13306190105710"><a name="p13306190105710"></a><a name="p13306190105710"></a>YES/NO</p> - </td> - </tr> - <tr id="row4318406577"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p183068010574"><a name="p183068010574"></a><a name="p183068010574"></a>LOSCFG_TRACE_FRAME_MAX_PARAMS</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p7306160125716"><a name="p7306160125716"></a><a name="p7306160125716"></a>Record max params</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p030610020572"><a name="p030610020572"></a><a name="p030610020572"></a>Specifies the maximum number of parameters for event recording.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p93065012570"><a name="p93065012570"></a><a name="p93065012570"></a>INT</p> - </td> - </tr> - <tr id="row17317102571"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p330616014570"><a name="p330616014570"></a><a name="p330616014570"></a>LOSCFG_TRACE_BUFFER_SIZE</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p03061903577"><a name="p03061903577"></a><a name="p03061903577"></a>Trace record buffer size</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p14306120115713"><a name="p14306120115713"></a><a name="p14306120115713"></a>Specifies the trace buffer size.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p230613012578"><a name="p230613012578"></a><a name="p230613012578"></a>INT</p> - </td> - </tr> - </tbody> - </table> - -2. \(Optional\) Preset event parameters and stubs \(or use the default event parameter settings and event stubs\). -3. \(Optional\) Call **LOS\_TraceStop** to stop trace and call **LOS\_TraceReset** to clear the trace buffer. \(Trace is started by default.\) -4. \(Optional\) Call **LOS\_TraceEventMaskSet** to set the event mask for trace \(only the interrupts and task events are enabled by default\). For details about the event mask, see **LOS\_TRACE\_MASK** in **los\_trace.h**. -5. Call **LOS\_TraceStart** at the start of the code where the event needs to be traced. -6. Call **LOS\_TraceStop** at the end of the code where the event needs to be traced. -7. Call **LOS\_TraceRecordDump** to output the data in the buffer. \(The input parameter of the function is of the Boolean type. The value **FALSE** means to output data in the specified format, and the value **TRUE** means to output data to Trace IDE.\) - -The methods in steps 3 to 7 are encapsulated with shell commands. After the shell is enabled, the corresponding commands can be executed. The mapping is as follows: - -- LOS\_TraceReset —— trace\_reset -- LOS\_TraceEventMaskSet —— trace\_mask -- LOS\_TraceStart —— trace\_start -- LOS\_TraceStop —— trace\_stop -- LOS\_TraceRecordDump —— trace\_dump - -## Kernel-mode Programming Example<a name="section112034213583"></a> +1. Configure the macro related to the trace module. + + Configure the macro **LOSCFG_KERNEL_TRACE**, which is disabled by default. Run the **make update_config** command in the **kernel/liteos_a** directory, choose **Kernel** > **Enable Hook Feature**, and set **Enable Trace Feature** to **YES**. + +| Configuration Item | menuconfig Option| Description| Value| +| -------- | -------- | -------- | -------- | +| LOSCFG_KERNEL_TRACE | Enable Trace Feature | Specifies whether to enable the trace feature.| YES/NO | +| LOSCFG_RECORDER_MODE_OFFLINE | Trace work mode ->Offline mode | Specifies whether to enable the online trace mode.| YES/NO | +| LOSCFG_RECORDER_MODE_ONLINE | Trace work mode ->Online mode | Specifies whether to enable the offline trace mode.| YES/NO | +| LOSCFG_TRACE_CLIENT_INTERACT | Enable Trace Client Visualization and Control | Enables interaction with Trace IDE (dev tools), including data visualization and process control.| YES/NO | +| LOSCFG_TRACE_FRAME_CORE_MSG | Enable Record more extended content -<br>>Record cpuid, hardware interrupt<br> status, task lock status | Specifies whether to enable recording of the CPU ID, interruption state, and lock task state.| YES/NO | +| LOSCFG_TRACE_FRAME_EVENT_COUNT | Enable Record more extended content<br> ->Record event count,<br> which indicate the sequence of happend events | Specifies whether to enables recording of the event sequence number.| YES/NO | +| LOSCFG_TRACE_FRAME_MAX_PARAMS | Record max params | Specifies the maximum number of parameters for event recording.| INT | +| LOSCFG_TRACE_BUFFER_SIZE | Trace record buffer size | Specifies the trace buffer size.| INT | + +2. (Optional) Preset event parameters and stubs (or use the default event parameter settings and event stubs). + +3. (Optional) Call **LOS_TraceStop** to stop trace and call **LOS_TraceReset** to clear the trace buffer. (Trace is started by default.) + +4. (Optional) Call **LOS_TraceEventMaskSet** to set the event mask for trace (only the interrupts and task events are enabled by default). For details about the event mask, see **LOS_TRACE_MASK** in **los_trace.h**. + +5. Call **LOS_TraceStart** at the start of the code where the event needs to be traced. + +6. Call **LOS_TraceStop** at the end of the code where the event needs to be traced. + +7. Call **LOS_TraceRecordDump** to output the data in the buffer. (The input parameter of the function is of the Boolean type. The value **FALSE** means to output data in the specified format, and the value **TRUE** means to output data to Trace IDE.) + +The methods in steps 3 to 7 are encapsulated with shell commands. You can run these commands on shell. The mappings between the functions and commands are as follows: + +- LOS_TraceReset —— trace_reset + +- LOS_TraceEventMaskSet —— trace_mask + +- LOS_TraceStart —— trace_start + +- LOS_TraceStop —— trace_stop + +- LOS_TraceRecordDump —— trace_dump + + +### Kernel-Mode Development Example This example implements the following: -1. Create a trace task. -2. Set the event mask. -3. Start trace. -4. Stop trace. -5. Output trace data in the specified format. +1. Create a trace task. + +2. Set the event mask. + +3. Start trace. + +4. Stop trace. + +5. Output trace data in the specified format. + + +### Kernel-Mode Sample Code -## Kernel-mode Sample Code<a name="section10348549155812"></a> +The sample code is as follows: -The code is as follows: ``` #include "los_trace.h" @@ -331,21 +223,21 @@ VOID Example_Trace(VOID) dprintf("trace start error\n"); return; } - /* Trigger a task switching event.*/ + /* Trigger a task switching event. */ LOS_TaskDelay(1); LOS_TaskDelay(1); LOS_TaskDelay(1); - /* Stop trace.*/ + /* Stop trace. */ LOS_TraceStop(); LOS_TraceRecordDump(FALSE); } UINT32 Example_Trace_test(VOID){ UINT32 ret; TSK_INIT_PARAM_S traceTestTask; - /* Create a trace task. */ + /* Create a trace task. */ memset(&traceTestTask, 0, sizeof(TSK_INIT_PARAM_S)); traceTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_Trace; - traceTestTask.pcName = "TestTraceTsk"; /* Trace task name*/ + traceTestTask.pcName = "TestTraceTsk"; /* Test task name. */ traceTestTask.uwStackSize = 0x800; traceTestTask.usTaskPrio = 5; traceTestTask.uwResved = LOS_TASK_STATUS_DETACHED; @@ -354,22 +246,24 @@ UINT32 Example_Trace_test(VOID){ dprintf("TraceTestTask create failed .\n"); return LOS_NOK; } - /* Trace is started by default. Therefore, you can stop trace, clear the buffer, and then restart trace. */ + /* Trace is started by default. Therefore, you can stop trace, clear the buffer, and then start trace. */ LOS_TraceStop(); LOS_TraceReset(); - /* Enable trace of the Task module events. */ + /* Enable trace of the Task module events. */ LOS_TraceEventMaskSet(TRACE_TASK_FLAG); return LOS_OK; } LOS_MODULE_INIT(Example_Trace_test, LOS_INIT_LEVEL_KMOD_EXTENDED); ``` -## Verification<a name="section8601444165916"></a> + +### Verification The output is as follows: + ``` -*******TraceInfo begin******* +***TraceInfo begin*** clockFreq = 50000000 CurEvtIndex = 7 Index Time(cycles) EventType CurTask Identity params @@ -381,36 +275,41 @@ Index Time(cycles) EventType CurTask Identity params 5 0x36eec810 0x45 0xc 0x1 0x9 0x8 0x1f 6 0x3706f804 0x45 0x1 0x0 0x1f 0x4 0x0 7 0x37070e59 0x45 0x0 0x1 0x0 0x8 0x1f -*******TraceInfo end******* +***TraceInfo end*** ``` The output event information includes the occurrence time, event type, task in which the event occurs, object of the event operation, and other parameters of the event. -- **EventType**: event type. For details, see **enum LOS\_TRACE\_TYPE** in the header file **los\_trace.h**. -- **CurrentTask**: ID of the running task. -- **Identity**: object of the event operation. For details, see **\#TYPE\#\_PARAMS** in the header file **los\_trace.h**. -- **params**: event parameters. For details, see **\#TYPE\#\_PARAMS** in the header file **los\_trace.h**. +- **EventType**: event type. For details, see **enum LOS_TRACE_TYPE** in the header file **los_trace.h**. + +- **CurrentTask**: ID of the running task. + +- **Identity**: object of the event operation. For details, see **#TYPE#_PARAMS** in the header file **los_trace.h**. + +- **params**: event parameters. For details, see **#TYPE#_PARAMS** in the header file **los_trace.h**. The following uses output No. 0 as an example. + ``` Index Time(cycles) EventType CurTask Identity params 0 0x366d5e88 0x45 0x1 0x0 0x1f 0x4 ``` -- **Time \(cycles\)** can be converted into time \(in seconds\) by dividing the cycles by clockFreq. -- **0x45** indicates the task switching event. **0x1** is the ID of the task in running. -- For details about the meanings of **Identity** and **params**, see the **TASK\_SWITCH\_PARAMS** macro. +- **Time (cycles)** can be converted into time (in seconds) by dividing the cycles by clockFreq. + +- **0x45** indicates the task switching event. **0x1** is the ID of the task in running. + +- For details about the meanings of **Identity** and **params**, see the **TASK_SWITCH_PARAMS** macro. ``` #define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \ taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus ``` -Because of **\#TYPE\#\_PARAMS\(IDENTITY, parma1...\) IDENTITY, ...**, **Identity** is **taskId \(0x0\)** and the first parameter is **oldPriority \(0x1f\)**. - -> **NOTE:** ->The number of **param**s is specified by the **LOSCFG\_TRACE\_FRAME\_MAX\_PARAMS** parameter. The default value is **3**. Excess parameters are not recorded. You need to set **LOSCFG\_TRACE\_FRAME\_MAX\_PARAMS** based on service requirements. +Because of **#TYPE#_PARAMS(IDENTITY, parma1...) IDENTITY, ...**, **Identity** is **taskId (0x0)** and the first parameter is **oldPriority (0x1f)**. -Task 0x1 is switched to Task 0x0. The priority of task 0x1 is **0x1f**, and the state is **0x4**. The priority of the task 0x0 is **0x0**. +>  **NOTE** +> The number of parameters in **params** is specified by **LOSCFG_TRACE_FRAME_MAX_PARAMS**. The default value is **3**. Excess parameters are not recorded. You need to set **LOSCFG_TRACE_FRAME_MAX_PARAMS** based on service requirements. +Task 0x1 is switched to Task 0x0. The priority of task 0x1 is **0x1f**, and the state is **0x4**. The priority of the task 0x0 is **0x0**. diff --git a/en/device-dev/kernel/kernel-small-memory-lms.md b/en/device-dev/kernel/kernel-small-memory-lms.md index 74595cb951918bad29df9240c52395866cc5e853..277cbea8a28268a9c4597be980a22bb69f8f85f8 100644 --- a/en/device-dev/kernel/kernel-small-memory-lms.md +++ b/en/device-dev/kernel/kernel-small-memory-lms.md @@ -1,186 +1,119 @@ # LMS -## Basic Concepts<a name="section531482192018"></a> +## Basic Concepts -Lite Memory Sanitizer \(LMS\) is a tool used to detect memory errors on a real-time basis. LMS can detect buffer overflow, Use-After-Free \(UAF\), and double free errors in real time, and notify the operating system immediately. Together with locating methods such as Backtrace, LMS can locate the code line that causes the memory error. It greatly improves the efficiency of locating memory errors. +Lite Memory Sanitizer (LMS) is a tool used to detect memory errors on a real-time basis. LMS can detect buffer overflow, Use-After-Free (UAF), and double free errors in real time, and notify the operating system immediately. Together with locating methods such as Backtrace, LMS can locate the code line that causes the memory error. It greatly improves the efficiency of locating memory errors. The LMS module of the OpenHarmony LiteOS-A kernel provides the following functions: -- Supports check of multiple memory pools. -- Checks the memory allocated by **LOS\_MemAlloc**, **LOS\_MemAllocAlign**, and **LOS\_MemRealloc**. -- Checks the memory when bounds-checking functions are called \(enabled by default\). -- Checks the memory when libc frequently accessed functions, including **memset**, **memcpy**, **memmove**, **strcat**, **strcpy**, **strncat** and **strncpy**, are called. - -## Working Principles<a name="section5125124532010"></a> - -LMS uses shadow memory mapping to mark the system memory state. There are three states: **Accessible**, **RedZone**, and **Freed**. The shadow memory is located in the tail of the memory pool. - -- After memory is allocated from the heap, the shadow memory in the data area is set to the **Accessible** state, and the shadow memory in the head node area is set to the **RedZone** state. -- When memory is released from the heap, the shadow memory of the released memory is set to the **Freed** state. -- During code compilation, a function is inserted before the read/write instructions in the code to check the address validity. The tool checks the state value of the shadow memory that accesses the memory. If the shadow memory is in the **RedZone** statue, an overflow error will be reported. If the shadow memory is in the **Freed** state, a UAF error will be reported. -- When memory is released, the tool checks the state value of the shadow memory at the released address. If the shadow memory is in the **RedZone** state, a double free error will be reported. - -## Available APIs<a name="section17747184017458"></a> - -### Kernel Mode<a name="section104473014465"></a> - -The LMS module of the OpenHarmony LiteOS-A kernel provides the following APIs. For more details about the APIs, see the [API](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_lms.h) reference. - -**Table 1** LMS module APIs - -<a name="table209384411409"></a> -<table><thead align="left"><tr id="row49387411909"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p142345517111"><a name="p142345517111"></a><a name="p142345517111"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p16234751114"><a name="p16234751114"></a><a name="p16234751114"></a>API</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p1823555614"><a name="p1823555614"></a><a name="p1823555614"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row8853204717245"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1363682115251"><a name="p1363682115251"></a><a name="p1363682115251"></a>Adding a memory pool to be checked</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p363617214253"><a name="p363617214253"></a><a name="p363617214253"></a>LOS_LmsCheckPoolAdd</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1163632113259"><a name="p1163632113259"></a><a name="p1163632113259"></a>Adds the address range of a memory pool to the LMS check linked list. LMS performs a validity check when the accessed address is within the linked list. In addition, <strong id="b126321851183511"><a name="b126321851183511"></a><a name="b126321851183511"></a>LOS_MemInit</strong> calls this API to add the initialized memory pool to the LMS check linked list by default.</p> -</td> -</tr> -<tr id="row1094914508245"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p13104133062514"><a name="p13104133062514"></a><a name="p13104133062514"></a>Deleting a memory pool from the LMS check linked list</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p161042030142516"><a name="p161042030142516"></a><a name="p161042030142516"></a>LOS_LmsCheckPoolDel</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p17104430102517"><a name="p17104430102517"></a><a name="p17104430102517"></a>Cancels the validity check on the specified memory pool.</p> -</td> -</tr> -<tr id="row749355410241"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p178831422252"><a name="p178831422252"></a><a name="p178831422252"></a>Protecting a specified memory chunk</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1688315421254"><a name="p1688315421254"></a><a name="p1688315421254"></a>LOS_LmsAddrProtect</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p128831842152520"><a name="p128831842152520"></a><a name="p128831842152520"></a>Locks a memory chunk to prevent it from being read or written. Once the locked memory chunk is accessed, an error will be reported.</p> -</td> -</tr> -<tr id="row1018195932414"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p11243144917257"><a name="p11243144917257"></a><a name="p11243144917257"></a>Disabling protection of a specified memory chunk</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1324354932516"><a name="p1324354932516"></a><a name="p1324354932516"></a>LOS_LmsAddrDisableProtect</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p12243184922515"><a name="p12243184922515"></a><a name="p12243184922515"></a>Unlocks a memory chunk to make it readable and writable.</p> -</td> -</tr> -</tbody> -</table> - -### User Mode<a name="section58151229172811"></a> +- Supports check of multiple memory pools. + +- Checks the memory allocated by **LOS_MemAlloc**, **LOS_MemAllocAlign**, and **LOS_MemRealloc**. + +- Checks the memory when bounds-checking functions are called (enabled by default). + +- Checks the memory when libc frequently accessed functions, including **memset**, **memcpy**, **memmove**, **strcat**, **strcpy**, **strncat** and **strncpy**, are called. + + +## Working Principles + +LMS uses shadow memory mapping to mark the system memory state. There are three states: **Accessible**, **RedZone**, and **Freed**. The shadow memory is located in the tail of the memory pool. + +- After memory is allocated from the heap, the shadow memory in the data area is set to the **Accessible** state, and the shadow memory in the head node area is set to the **RedZone** state. + +- When memory is released from the heap, the shadow memory of the released memory is set to the **Freed** state. + +- During code compilation, a function is inserted before the read/write instructions in the code to check the address validity. The tool checks the state value of the shadow memory that accesses the memory. If the shadow memory is in the **RedZone** statue, an overflow error will be reported. If the shadow memory is in the **Freed** state, a UAF error will be reported. + +- When memory is released, the tool checks the state value of the shadow memory at the released address. If the shadow memory is in the **RedZone** state, a double free error will be reported. + + +## Available APIs + + +### Kernel Mode + +The LMS module of the OpenHarmony LiteOS-A kernel provides the following APIs. For more details, see [API reference](https://gitee.com/openharmony/kernel_liteos_a/blob/master/kernel/include/los_lms.h). + + **Table 1** APIs of the LMS module + +| Category| API| Description| +| -------- | -------- | -------- | +| Adding a memory pool to be checked| LOS_LmsCheckPoolAdd | Adds the address range of a memory pool to the LMS check linked list. LMS performs a validity check when the accessed address is within the linked list. In addition, **LOS_MemInit** calls this API to add the initialized memory pool to the LMS check linked list by default.| +| Deleting a memory pool from the LMS check linked list| LOS_LmsCheckPoolDel | Cancels the validity check on the specified memory pool.| +| Protecting a specified memory chunk| LOS_LmsAddrProtect | Locks a memory chunk to prevent it from being read or written. Once the locked memory chunk is accessed, an error will be reported.| +| Disabling protection of a specified memory chunk| LOS_LmsAddrDisableProtect | Unlocks a memory chunk to make it readable and writable.| + + +### User Mode The user mode provides only the LMS check library. It does not provide external APIs. -## Development Guidelines<a name="section10302175017543"></a> -### Kernel-mode Development Process<a name="section04021008552"></a> +## Development Guidelines -The typical process for enabling LMS is as follows: -1. Configure the macros related to the LMS module. - - Configure the LMS macro **LOSCFG\_KERNEL\_LMS**, which is disabled by default. Run the **make update\_config** command in the **kernel/liteos\_a** directory, choose **Kernel**, and select **Enable Lite Memory Sanitizer**. - - <a name="table06964569614"></a> - <table><thead align="left"><tr id="row1697105618610"><th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.1"><p id="p669715610619"><a name="p669715610619"></a><a name="p669715610619"></a>Macro</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.2"><p id="p0697105612614"><a name="p0697105612614"></a><a name="p0697105612614"></a>menuconfig Option</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.3"><p id="p5697175610610"><a name="p5697175610610"></a><a name="p5697175610610"></a>Description</p> - </th> - <th class="cellrowborder" valign="top" width="25%" id="mcps1.1.5.1.4"><p id="p1269712561866"><a name="p1269712561866"></a><a name="p1269712561866"></a>Value</p> - </th> - </tr> - </thead> - <tbody><tr id="row92613334297"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p4252633102917"><a name="p4252633102917"></a><a name="p4252633102917"></a>LOSCFG_KERNEL_LMS</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p92528337293"><a name="p92528337293"></a><a name="p92528337293"></a>Enable Lms Feature</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p13252133362915"><a name="p13252133362915"></a><a name="p13252133362915"></a>Whether to enable LMS.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p42521833172917"><a name="p42521833172917"></a><a name="p42521833172917"></a>YES/NO</p> - </td> - </tr> - <tr id="row19261173310297"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p02529337299"><a name="p02529337299"></a><a name="p02529337299"></a>LOSCFG_LMS_MAX_RECORD_POOL_NUM</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p4252203372913"><a name="p4252203372913"></a><a name="p4252203372913"></a>Lms check pool max num</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p15253153322912"><a name="p15253153322912"></a><a name="p15253153322912"></a>Maximum number of memory pools that can be checked by LMS.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p11253123319293"><a name="p11253123319293"></a><a name="p11253123319293"></a>INT</p> - </td> - </tr> - <tr id="row22611332293"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p325363316297"><a name="p325363316297"></a><a name="p325363316297"></a>LOSCFG_LMS_LOAD_CHECK</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p162531334294"><a name="p162531334294"></a><a name="p162531334294"></a>Enable lms read check</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p7253633112915"><a name="p7253633112915"></a><a name="p7253633112915"></a>Whether to enable LMS read check.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p02531733132910"><a name="p02531733132910"></a><a name="p02531733132910"></a>YES/NO</p> - </td> - </tr> - <tr id="row1826153311290"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p1025383314293"><a name="p1025383314293"></a><a name="p1025383314293"></a>LOSCFG_LMS_STORE_CHECK</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p125383322920"><a name="p125383322920"></a><a name="p125383322920"></a>Enable lms write check</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p52531933192917"><a name="p52531933192917"></a><a name="p52531933192917"></a>Whether to enable LMS write check.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p225313335292"><a name="p225313335292"></a><a name="p225313335292"></a>YES/NO</p> - </td> - </tr> - <tr id="row15261333142915"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.1 "><p id="p825310333293"><a name="p825310333293"></a><a name="p825310333293"></a>LOSCFG_LMS_CHECK_STRICT</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.2 "><p id="p142538338292"><a name="p142538338292"></a><a name="p142538338292"></a>Enable lms strict check, byte-by-byte</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.3 "><p id="p1325333352920"><a name="p1325333352920"></a><a name="p1325333352920"></a>Whether to enable LMS byte-by-byte check.</p> - </td> - <td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="p32541333292"><a name="p32541333292"></a><a name="p32541333292"></a>YES/NO</p> - </td> - </tr> - </tbody> - </table> - -2. Modify the compile script of the target module. - - Add "-fsanitize=kernel-address" to insert memory access checks, and add the **-O0** option to disable optimization performed by the compiler. - - The modifications vary depending on the compiler \(GCC or Clang\) used. The following is an example: - - ``` - if ("$ohos_build_compiler_specified" == "gcc") { - cflags_c = [ - "-O0", - "-fsanitize=kernel-address", - ] - } else { - cflags_c = [ - "-O0", - "-fsanitize=kernel-address", - "-mllvm", - "-asan-instrumentation-with-call-threshold=0", - "-mllvm", - "-asan-stack=0", - "-mllvm", - "-asan-globals=0", - ] - } - ``` +### Kernel-Mode Development Process -3. Recompile the code and check the serial port output. The memory problem detected will be displayed. +The typical process for enabling LMS is as follows: -## Kernel-mode Development Example<a name="section112034213583"></a> +1. Configure the macros related to the LMS module. + + Configure the LMS macro **LOSCFG_KERNEL_LMS**, which is disabled by default. Run the **make update_config** command in the **kernel/liteos_a** directory, choose **Kernel**, and select **Enable Lite Memory Sanitizer**. + + | Macro| menuconfig Option| Description| Value:| + | -------- | -------- | -------- | -------- | + | LOSCFG_KERNEL_LMS | Enable Lms Feature | Whether to enable LMS.| YES/NO | + | LOSCFG_LMS_MAX_RECORD_POOL_NUM | Lms check pool max num | Maximum number of memory pools that can be checked by LMS.| INT | + | LOSCFG_LMS_LOAD_CHECK | Enable lms read check | Whether to enable LMS read check.| YES/NO | + | LOSCFG_LMS_STORE_CHECK | Enable lms write check | Whether to enable LMS write check.| YES/NO | + | LOSCFG_LMS_CHECK_STRICT | Enable lms strict check, byte-by-byte | Whether to enable LMS byte-by-byte check.| YES/NO | + + +2. Modify the build script of the target module. + + Add **-fsanitize=kernel-address** to insert memory access checks, and add the **-O0** option to disable optimization performed by the compiler. + + The modifications vary depending on the compiler (GCC or Clang) used. The following is an example: + + ``` + if ("$ohos_build_compiler_specified" == "gcc") { + cflags_c = [ + "-O0", + "-fsanitize=kernel-address", + ] + } else { + cflags_c = [ + "-O0", + "-fsanitize=kernel-address", + "-mllvm", + "-asan-instrumentation-with-call-threshold=0", + "-mllvm", + "-asan-stack=0", + "-mllvm", + "-asan-globals=0", + ] + } + ``` + +3. Recompile the code and check the serial port output. The memory problem detected will be displayed. + + +#### Kernel-Mode Development Example This example implements the following: -1. Create a task for LMS. -2. Construct a buffer overflow error and a UAF error. -3. Add "-fsanitize=kernel-address", execute the compilation, and check the output. +1. Create a task for LMS. -## Kernel-mode Sample Code<a name="section10348549155812"></a> +2. Construct a buffer overflow error and a UAF error. -The code is as follows: +3. Add "-fsanitize=kernel-address", execute the compilation, and check the output. + + +#### Kernel-Mode Sample Code + + The sample code is as follows: ``` #define PAGE_SIZE (0x1000U) @@ -221,10 +154,10 @@ VOID LmsTestCaseTask(VOID) UINT32 Example_Lms_test(VOID){ UINT32 ret; TSK_INIT_PARAM_S lmsTestTask; - /* Create a task for LMS. */ + /* Create a task for LMS. */ memset(&lmsTestTask, 0, sizeof(TSK_INIT_PARAM_S)); lmsTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)LmsTestCaseTask; - lmsTestTask.pcName = "TestLmsTsk"; /* Task name. */ + lmsTestTask.pcName = "TestLmsTsk"; /* Test task name. */ lmsTestTask.uwStackSize = 0x800; lmsTestTask.usTaskPrio = 5; lmsTestTask.uwResved = LOS_TASK_STATUS_DETACHED; @@ -238,20 +171,21 @@ UINT32 Example_Lms_test(VOID){ LOS_MODULE_INIT(Example_Lms_test, LOS_INIT_LEVEL_KMOD_EXTENDED); ``` -### Kernel-mode Verification<a name="section61719481795"></a> -The output is as follows: +#### Kernel-Mode Verification + + The output is as follows: ``` ######LmsTestOsmallocOverflow start ###### -[ERR][KProcess:LmsTestCaseTask]***** Kernel Address Sanitizer Error Detected Start ***** +[ERR][KProcess:LmsTestCaseTask]* Kernel Address Sanitizer Error Detected Start * [ERR][KProcess:LmsTestCaseTask]Heap buffer overflow error detected [ERR][KProcess:LmsTestCaseTask]Illegal READ address at: [0x4157a3c8] [ERR][KProcess:LmsTestCaseTask]Shadow memory address: [0x4157be3c : 4] Shadow memory value: [2] OsBackTrace fp = 0x402c0f88 runTask->taskName = LmsTestCaseTask runTask->taskID = 2 -*******backtrace begin******* +***backtrace begin*** traceback fp fixed, trace using fp = 0x402c0fd0 traceback 0 -- lr = 0x400655a4 fp = 0x402c0ff8 traceback 1 -- lr = 0x40065754 fp = 0x402c1010 @@ -269,18 +203,18 @@ traceback 3 -- lr = 0x40004e14 fp = 0xcacacaca [0x4157a3e0]: 00 00 00 00 00 00 00 00 | [0x4157be3e | 0]: 3 3 [0x4157a3e8]: 00 00 00 00 00 00 00 00 | [0x4157be3e | 4]: 3 3 [0x4157a3f0]: 00 00 00 00 00 00 00 00 | [0x4157be3f | 0]: 3 3 -[ERR][KProcess:LmsTestCaseTask]***** Kernel Address Sanitizer Error Detected End ***** +[ERR][KProcess:LmsTestCaseTask]* Kernel Address Sanitizer Error Detected End * str[20]=0xffffffba ######LmsTestOsmallocOverflow stop ###### ###### LmsTestUseAfterFree start ###### -[ERR][KProcess:LmsTestCaseTask]***** Kernel Address Sanitizer Error Detected Start ***** +[ERR][KProcess:LmsTestCaseTask]* Kernel Address Sanitizer Error Detected Start * [ERR][KProcess:LmsTestCaseTask]Use after free error detected [ERR][KProcess:LmsTestCaseTask]Illegal READ address at: [0x4157a3d4] [ERR][KProcess:LmsTestCaseTask]Shadow memory address: [0x4157be3d : 2] Shadow memory value: [3] OsBackTrace fp = 0x402c0f90 runTask->taskName = LmsTestCaseTask runTask->taskID = 2 -*******backtrace begin******* +***backtrace begin*** traceback fp fixed, trace using fp = 0x402c0fd8 traceback 0 -- lr = 0x40065680 fp = 0x402c0ff8 traceback 1 -- lr = 0x40065758 fp = 0x402c1010 @@ -298,35 +232,36 @@ traceback 3 -- lr = 0x40004e14 fp = 0xcacacaca [0x4157a3e8]: ba dc cd ab c8 a3 57 41 | [0x4157be3e | 4]: 2 2 [0x4157a3f0]: 0c 1a 00 00 00 00 00 00 | [0x4157be3f | 0]: 2 3 [0x4157a3f8]: 00 00 00 00 00 00 00 00 | [0x4157be3f | 4]: 3 3 -[ERR][KProcess:LmsTestCaseTask]***** Kernel Address Sanitizer Error Detected End ***** +[ERR][KProcess:LmsTestCaseTask]* Kernel Address Sanitizer Error Detected End * str[ 0]=0x 0 ######LmsTestUseAfterFree stop ###### ``` The key output information is as follows: -- Error type: - - Heap buffer overflow - - UAF +- Error type: + - Heap buffer overflow + - UAF + +- Incorrect operations: + - Illegal read + - Illegal write + - Illegal double free -- Incorrect operations: - - Illegal read - - Illegal write - - Illegal double free +- Context: + - Task information (**taskName** and **taskId**) + - Backtrace -- Context: - - Task information \(**taskName** and **taskId**\) - - Backtrace +- Memory information of the error addresses: + - Memory value and the value of the corresponding shadow memory + - Memory address: memory value|[shadow memory address|shadow memory byte offset]: shadow memory value + - Shadow memory value. **0** (Accessible), **3** (Freed), **2** (RedZone), and **1** (filled value) -- Memory information of the error addresses: - - Memory value and the value of the corresponding shadow memory - - Memory address: memory value|\[shadow memory address|shadow memory byte offset\]: shadow memory value - - Shadow memory value. **0** \(Accessible\), **3** \(Freed\), **2** \(RedZone\), and **1** \(filled value\) +### User-Mode Development Process -### User-mode Development Process<a name="section1425821711114"></a> +Add the following to the build script of the app to be checked. For details about the complete code, see **/kernel/liteos_a/apps/lms/BUILD.gn**. -Add the following to the build script of the app to be checked. For details about the complete code, see **/kernel/liteos\_a/apps/lms/BUILD.gn**. ``` if ("$ohos_build_compiler_specified" == "gcc") { @@ -369,16 +304,19 @@ if ("$ohos_build_compiler_specified" == "gcc") { deps = [ "//kernel/liteos_a/kernel/extended/lms/usr:usrlmslib" ] ``` -### User-mode Development Example<a name="section3470546163"></a> + +#### User-Mode Development Example This example implements the following: -1. Construct a buffer overflow error and a UAF error. -2. Modify the build script and perform the build again. +1. Construct a buffer overflow error and a UAF error. + +2. Modify the build script and perform the build again. + -### User-Mode Sample Code<a name="section183253286161"></a> +#### User-Mode Sample Code -The code is as follows: + The code is as follows: ``` static void BufWriteTest(void *buf, int start, int end) @@ -421,16 +359,17 @@ int main(int argc, char * const * argv) } ``` -### User-mode Verification<a name="section5665123516214"></a> -The output is as follows: +#### User-Mode Verification + + The output is as follows: ``` -***** Lite Memory Sanitizer Error Detected ***** +* Lite Memory Sanitizer Error Detected * Heap buffer overflow error detected! Illegal READ address at: [0x1f8b3edf] Shadow memory address: [0x3d34d3ed : 6] Shadow memory value: [2] -Accessable heap addr 0 +Accessible heap addr 0 Heap red zone 2 Heap freed buffer 3 Dump info around address [0x1f8b3edf]: @@ -443,7 +382,7 @@ Dump info around address [0x1f8b3edf]: [0x1f8b3ee8]: 09 00 00 00 00 00 00 00 | [0x3d34d3ee | 4]: 0 0 [0x1f8b3ef0]: 00 00 00 00 08 03 09 00 | [0x3d34d3ef | 0]: 2 2 [0x1f8b3ef8]: 00 00 00 00 00 00 00 00 | [0x3d34d3ef | 4]: 2 2 -***** Lite Memory Sanitizer Error Detected End ***** +* Lite Memory Sanitizer Error Detected End * Backtrace() returned 5 addresses #01: <LMS_ReportError+0x284>[0x4d6c] -> ./sample_usr_lms #02: <(null)+0x2004074>[0x4074] -> ./sample_usr_lms @@ -451,11 +390,11 @@ Backtrace() returned 5 addresses #04: <main+0x40>[0x363c] -> ./sample_usr_lms #05: <(null)+0x1f856f30>[0x56f30] -> /lib/libc.so -------- LMS_malloc_test End -------- -***** Lite Memory Sanitizer Error Detected ***** +* Lite Memory Sanitizer Error Detected * Use after free error detected! Illegal Double free address at: [0x1f8b3ee0] Shadow memory address: [0x3d34d3ee : 0] Shadow memory value: [3] -Accessable heap addr 0 +Accessible heap addr 0 Heap red zone 2 Heap freed buffer 3 Dump info around address [0x1f8b3ee0]: @@ -468,7 +407,7 @@ Dump info around address [0x1f8b3ee0]: [0x1f8b3ef0]: 20 40 8b 1f 20 20 8b 1f | [0x3d34d3ef | 0]: 3 3 [0x1f8b3ef8]: 00 00 00 00 00 00 00 00 | [0x3d34d3ef | 4]: 3 3 [0x1f8b3f00]: 00 00 00 00 00 00 00 00 | [0x3d34d3f0 | 0]: 3 3 -***** Lite Memory Sanitizer Error Detected End ***** +* Lite Memory Sanitizer Error Detected End * Backtrace() returned 5 addresses #01: <LMS_ReportError+0x284>[0x4d6c] -> ./sample_usr_lms #02: <LMS_free+0xcc>[0x5548] -> ./sample_usr_lms @@ -479,4 +418,3 @@ Backtrace() returned 5 addresses ``` The Backtrace output contains the names of the files where the addresses are located. You can locate the code line corresponding to the address in the related file. - diff --git a/en/device-dev/kernel/kernel-small-start-kernel.md b/en/device-dev/kernel/kernel-small-start-kernel.md index c92af04ba02216c05708e280bd427b7b8cb128d8..01c4373ac8b51dc17a9ea91985c98688f4965311 100644 --- a/en/device-dev/kernel/kernel-small-start-kernel.md +++ b/en/device-dev/kernel/kernel-small-start-kernel.md @@ -1,99 +1,46 @@ # Startup in Kernel Mode -## Kernel Startup Process<a name="section9882154318299"></a> - -The kernel startup process consists of the assembly startup and C language startup, as shown in the following figure. The assembly startup involves the following operations: initializing CPU settings, disabling dCache/iCache, enabling the FPU and NEON, setting the MMU to establish the virtual-physical address mapping, setting the system stack, clearing the BSS segment, and calling the main function of the C language. The C language startup involves the following operations: starting the OsMain function and starting scheduling. As shown in the following figure, the OsMain function is used for basic kernel initialization and architecture- and board-level initialization. The kernel startup framework leads the initialization process. The right part of the figure shows the phase in which external modules can register with the kernel startup framework and starts. [Table 1](#table38544719428) describes each phase. - -**Figure 1** Kernel startup process<a name="fig983731153511"></a> - - -**Table 1** Startup framework levels - -<a name="table38544719428"></a> -<table><thead align="left"><tr id="row286134714423"><th class="cellrowborder" valign="top" width="35.58%" id="mcps1.2.3.1.1"><p id="p886164717423"><a name="p886164717423"></a><a name="p886164717423"></a>Level</p> -</th> -<th class="cellrowborder" valign="top" width="64.42%" id="mcps1.2.3.1.2"><p id="p586194716421"><a name="p586194716421"></a><a name="p586194716421"></a>Description</p> -</th> -</tr> -</thead> -<tbody><tr id="row48664764218"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p7861447174211"><a name="p7861447174211"></a><a name="p7861447174211"></a>LOS_INIT_LEVEL_EARLIEST</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p1561350125815"><a name="p1561350125815"></a><a name="p1561350125815"></a>Earliest initialization.</p> -<p id="p13865183210552"><a name="p13865183210552"></a><a name="p13865183210552"></a>The initialization is architecture-independent. The board and subsequent modules initialize the pure software modules on which they depend.</p> -<p id="p1686104764216"><a name="p1686104764216"></a><a name="p1686104764216"></a>Example: trace module</p> -</td> -</tr> -<tr id="row4861478429"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p1986164710423"><a name="p1986164710423"></a><a name="p1986164710423"></a>LOS_INIT_LEVEL_ARCH_EARLY</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p6864470423"><a name="p6864470423"></a><a name="p6864470423"></a>Early initialization of the architecture.</p> -<p id="p118192355598"><a name="p118192355598"></a><a name="p118192355598"></a>The initialization is architecture-dependent. Subsequent modules initialize the modules on which they depend. It is recommended that functions not required for startup be placed at <strong id="b13751321192318"><a name="b13751321192318"></a><a name="b13751321192318"></a>LOS_INIT_LEVEL_ARCH</strong>.</p> -</td> -</tr> -<tr id="row98694774219"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p118624714210"><a name="p118624714210"></a><a name="p118624714210"></a>LOS_INIT_LEVEL_PLATFORM_EARLY</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p118531052143510"><a name="p118531052143510"></a><a name="p118531052143510"></a>Early initialization of the platform.</p> -<p id="p666132195816"><a name="p666132195816"></a><a name="p666132195816"></a>The initialization depends on the board platform and drivers. Subsequent modules initialize the modules on which they depend. It is recommended that functions required for startup be placed at <strong id="b44971429202712"><a name="b44971429202712"></a><a name="b44971429202712"></a>LOS_INIT_LEVEL_PLATFORM</strong>. -</td> -</tr> -<tr id="row8863470423"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p19861547114214"><a name="p19861547114214"></a><a name="p19861547114214"></a>LOS_INIT_LEVEL_KMOD_PREVM</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p2862471421"><a name="p2862471421"></a><a name="p2862471421"></a>Kernel module initialization before memory initialization.</p> -<p id="p989110481520"><a name="p989110481520"></a><a name="p989110481520"></a>Initialize the modules that need to be enabled before memory initialization.</p> -</td> -</tr> -<tr id="row4861147124218"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p16863472426"><a name="p16863472426"></a><a name="p16863472426"></a>LOS_INIT_LEVEL_VM_COMPLETE</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p1186114715427"><a name="p1186114715427"></a><a name="p1186114715427"></a>Initialization after the basic memory is ready.</p> -<p id="p26441930165910"><a name="p26441930165910"></a><a name="p26441930165910"></a>After memory initialization, initialize the modules that need to be enabled and do not depend on inter-process communication (IPC) and system processes.</p> -<p id="p76991543175013"><a name="p76991543175013"></a><a name="p76991543175013"></a>Example: shared memory function</p> -</td> -</tr> -<tr id="row12869472429"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p178694712429"><a name="p178694712429"></a><a name="p178694712429"></a>LOS_INIT_LEVEL_ARCH</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p1086104719427"><a name="p1086104719427"></a><a name="p1086104719427"></a>Late initialization of the architecture.</p> -<p id="p556511281688"><a name="p556511281688"></a><a name="p556511281688"></a>The initialization is related to the architecture extension functions. Subsequent modules initialize the modules on which they depend.</p> -</td> -</tr> -<tr id="row128624717424"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p198684711427"><a name="p198684711427"></a><a name="p198684711427"></a>LOS_INIT_LEVEL_PLATFORM</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p65519915524"><a name="p65519915524"></a><a name="p65519915524"></a>Late initialization of the platform.</p> -<p id="p187247164213"><a name="p187247164213"></a><a name="p187247164213"></a>The initialization depends on the board platform and drivers. Subsequent modules initialize the modules on which they depend.</p> -<p id="p138046651010"><a name="p138046651010"></a><a name="p138046651010"></a>Example: initialization of the driver kernel abstraction layer (MMC and MTD)</p> -</td> -</tr> -<tr id="row2149155220436"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p8150105215436"><a name="p8150105215436"></a><a name="p8150105215436"></a>LOS_INIT_LEVEL_KMOD_BASIC</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p81509525436"><a name="p81509525436"></a><a name="p81509525436"></a>Initialization of the kernel basic modules.</p> -<p id="p763134221115"><a name="p763134221115"></a><a name="p763134221115"></a>Initialize the basic modules that can be detached from the kernel.</p> -<p id="p7781186191213"><a name="p7781186191213"></a><a name="p7781186191213"></a>Example: VFS initialization</p> -</td> -</tr> -<tr id="row19671355174317"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p1596825564317"><a name="p1596825564317"></a><a name="p1596825564317"></a>LOS_INIT_LEVEL_KMOD_EXTENDED</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p6968155513438"><a name="p6968155513438"></a><a name="p6968155513438"></a>Initialization of the kernel extended modules.</p> -<p id="p669712304124"><a name="p669712304124"></a><a name="p669712304124"></a>Initialize the extended modules that can be detached from the kernel.</p> -<p id="p7600114618125"><a name="p7600114618125"></a><a name="p7600114618125"></a>Example: initialization of system call, ProcFS, Futex, HiLog, HiEvent, and LiteIPC</p> -</td> -</tr> -<tr id="row357517134414"><td class="cellrowborder" valign="top" width="35.58%" headers="mcps1.2.3.1.1 "><p id="p12575676449"><a name="p12575676449"></a><a name="p12575676449"></a>LOS_INIT_LEVEL_KMOD_TASK</p> -</td> -<td class="cellrowborder" valign="top" width="64.42%" headers="mcps1.2.3.1.2 "><p id="p7128122619143"><a name="p7128122619143"></a><a name="p7128122619143"></a>Kernel task creation</p> -<p id="p1657587184419"><a name="p1657587184419"></a><a name="p1657587184419"></a>Create kernel tasks (kernel tasks and software timer tasks).</p> -<p id="p55485297219"><a name="p55485297219"></a><a name="p55485297219"></a>Example: creation of the resident resource reclaiming task, SystemInit task, and CPU usage statistics task.</p> -</td> -</tr> -</tbody> -</table> - -## Programming Example<a name="section19145114703217"></a> - -### Example Description<a name="section1045483642518"></a> +## Kernel Startup Process + +The kernel startup process consists of the assembly startup and C language startup, as shown in the following figure. + +The assembly startup involves the following operations: initializing CPU settings, disabling dCache/iCache, enabling the FPU and NEON, setting the MMU to establish the virtual-physical address mapping, setting the system stack, clearing the BSS segment, and calling the main function of the C language. + +The C language startup involves the following operations: starting the **OsMain** function and starting scheduling. As shown in the following figure, the **OsMain** function is used for basic kernel initialization and architecture- and board-level initialization. The kernel startup framework leads the initialization process. The right part of the figure shows the phase in which external modules can register with the kernel startup framework and starts. The table below describes each phase. + + + **Figure 1** Kernel startup process<br> +  + + + **Table 1** Start framework + +| Level | Startup Description | +| -------- | -------- | +| LOS_INIT_LEVEL_EARLIEST | Earliest initialization.<br>The initialization is architecture-independent. The board and subsequent modules initialize the pure software modules on which they depend.<br>Example: trace module| +| LOS_INIT_LEVEL_ARCH_EARLY | Early initialization of the architecture.<br>The initialization is architecture-dependent. Subsequent modules initialize the modules on which they depend. It is recommended that functions not required for startup be placed at **LOS_INIT_LEVEL_ARCH**.| +| LOS_INIT_LEVEL_PLATFORM_EARLY | Early initialization of the platform.<br>The initialization depends on the board platform and drivers. Subsequent modules initialize the modules on which they depend. It is recommended that functions required for startup be placed at **LOS_INIT_LEVEL_PLATFORM**.<br>Example: UART module| +| LOS_INIT_LEVEL_KMOD_PREVM | Kernel module initialization before memory initialization.<br>Initialize the modules that need to be enabled before memory initialization.| +| LOS_INIT_LEVEL_VM_COMPLETE | Initialization after the basic memory is ready.<br>After memory initialization, initialize the modules that need to be enabled and do not depend on inter-process communication (IPC) and system processes.<br>Example: shared memory function| +| LOS_INIT_LEVEL_ARCH | Late initialization of the architecture.<br>The initialization is related to the architecture extension functions. Subsequent modules initialize the modules on which they depend.| +| LOS_INIT_LEVEL_PLATFORM | Late initialization of the platform.<br>The initialization depends on the board platform and drivers. Subsequent modules initialize the modules on which they depend.<br>Example: initialization of the driver kernel abstraction layer (MMC and MTD)| +| LOS_INIT_LEVEL_KMOD_BASIC | Initialization of the kernel basic modules.<br>Initialize the basic modules that can be detached from the kernel.<br>Example: VFS initialization| +| LOS_INIT_LEVEL_KMOD_EXTENDED | Initialization of the kernel extended modules.<br>Initialize the extended modules that can be detached from the kernel.<br>Example: initialization of system call, ProcFS, Futex, HiLog, HiEvent, and LiteIPC| +| LOS_INIT_LEVEL_KMOD_TASK | Kernel task creation.<br>Create kernel tasks (kernel tasks and software timer tasks).<br>Example: creation of the resident resource reclaiming task, SystemInit task, and CPU usage statistics task| + + +## Programming Example + +**Example Description** Add a kernel module and register the initialization function of the module to the kernel startup process through the kernel startup framework, so as to complete the module initialization during the kernel initialization process. + **Sample Code** + + ``` /* Header file of the kernel startup framework */ #include "los_init.h" @@ -110,8 +57,11 @@ unsigned int OsSampleModInit(void) LOS_MODULE_INIT(OsSampleModInit, LOS_INIT_LEVEL_KMOD_EXTENDED); ``` + **Verification** + + ``` main core booting up... OsSampleModInit SUCCESS! @@ -120,9 +70,12 @@ cpu 1 entering scheduler cpu 0 entering scheduler ``` + According to the information displayed during the system startup, the kernel has called the initialization function of the registered module during the startup to initialize the module. -> **NOTE:** ->Modules at the same level cannot depend on each other. It is recommended that a new module be split based on the preceding startup phase and be registered and started as required. ->You can view the symbol table in the **.rodata.init.kernel.\*** segment of the **OHOS\_Image.map** file generated after the build is complete, so as to learn about the initialization entry of each module that has been registered with the kernel startup framework and check whether the newly registered initialization entry has taken effect. +>  **NOTE** +> +> Modules at the same level cannot depend on each other. It is recommended that a new module be split based on the preceding startup phase and be registered and started as required. +> +> You can view the symbol table in the **.rodata.init.kernel.*** segment of the **OHOS_Image.map** file generated after the build is complete, so as to learn about the initialization entry of each module that has been registered with the kernel startup framework and check whether the newly registered initialization entry has taken effect. diff --git a/en/device-dev/kernel/kernel-small-start-user.md b/en/device-dev/kernel/kernel-small-start-user.md index f2526dda1e39f972865de8ae98f29fbffb24fd22..fb34ba4194831b84c2683fd4ab11e2ee2cc2098c 100644 --- a/en/device-dev/kernel/kernel-small-start-user.md +++ b/en/device-dev/kernel/kernel-small-start-user.md @@ -48,14 +48,14 @@ Common compilation modes of user-mode programs include: Example: ``` - clang --target=arm-liteos --sysroot=prebuilts/lite/sysroot -o helloworld helloworld.c + clang --target=arm-liteos --sysroot=sysroot -o helloworld helloworld.c ``` Before running the **clang** command, install the LLVM compiler. For details, see [Installing LLVM](../quick-start/quickstart-lite-steps-hi3861-setting.md). **--target=arm-liteos**: specifies the compilation platform, which is arm-liteos. - **--sysroot=$\{YOUR\_ROOT\_PATH\}/prebuilts/lite/sysroot**: specifies the directory in which you can search for the header file and the dependent standard libraries. + **--sysroot=$\{YOUR\_ROOT\_OUT\_PATH\}/sysroot**: specifies the directory in which you can search for the header file and the dependent standard libraries. A user-mode program can be started in either of the following ways: diff --git a/en/device-dev/kernel/kernel-standard-build.md b/en/device-dev/kernel/kernel-standard-build.md index 747c9133458aec67156d3a1200d705b1a45df4a5..3c950570cf2ae2638fd00a68756c3cefaaf3ddce 100644 --- a/en/device-dev/kernel/kernel-standard-build.md +++ b/en/device-dev/kernel/kernel-standard-build.md @@ -1,14 +1,16 @@ # Compiling and Building the Linux Kernel -## Example 1 + + **Example** The following uses the Hi3516D V300 board and Ubuntu x86 server as an example. -Perform a full build for the project to generate the **uImage** kernel image. + +Perform a full build for the project to generate the **uImage** kernel image. + ``` -./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. - --build-target build_kernel # Build the uImage kernel image of the hispark_taurus_standard. - --gn-args linux_kernel_version=\"linux-5.10\" # Build the specified kernel version. +./build.sh --product-name hispark_taurus_standard # Build the hispark_taurus_standard image. + --build-target build_kernel # Build the uImage kernel image of hispark_taurus_standard. + --gn-args linux_kernel_version=\"linux-5.10\" # Specify the kernel version. ``` - diff --git a/en/device-dev/kernel/kernel-standard-sched-rtg.md b/en/device-dev/kernel/kernel-standard-sched-rtg.md index 534cdcdab06c04c6f3abce5e29766411e4c819cc..61a36ab5bb7aad13789b0ce053e3dbcd73be6b25 100644 --- a/en/device-dev/kernel/kernel-standard-sched-rtg.md +++ b/en/device-dev/kernel/kernel-standard-sched-rtg.md @@ -51,11 +51,11 @@ STATE COMM PID PRIO CPU // Thread information, including th ## Available APIs -The RTG provides the device node and ioctl APIs for querying and configuring group information. The device node is in `/dev/sched_rtg_ctrl`. - -| Device Node | request | Description | -| ------------------- | ------------------- | ------------------- | -| /dev/sched_rtg_ctrl | CMD_ID_SET_RTG | Creates an RTG, and adds, updates, or deletes threads in the group. | -| | CMD_ID_SET_CONFIG | Configures global group attributes, for example, the maximum number of real-time RTGs.| -| | CMD_ID_SET_RTG_ATTR | Configures specified group attributes, for example, the thread priority. | -| | CMD_ID_SET_MIN_UTIL | Sets the minimum utilization of an RTG. | +The RTG provides the device node and ioctl APIs for querying and configuring group information. The device node is in **/dev/sched_rtg_ctrl**. + +| Request | Description | +| ------------------- | ------------------- | +| CMD_ID_SET_RTG | Creates an RTG, and adds, updates, or deletes threads in the group. | +| CMD_ID_SET_CONFIG | Sets global group attributes, for example, the maximum number of real-time RTGs. | +| CMD_ID_SET_RTG_ATTR | Sets specified group attributes, for example, the thread priority. | +| CMD_ID_SET_MIN_UTIL | Sets the minimum utilization of an RTG. | diff --git a/en/device-dev/porting/porting-chip-prepare-knows.md b/en/device-dev/porting/porting-chip-prepare-knows.md index 6422f0f6bddd007815c9122704f67713d5f78c7a..64a136cd4884c4d76a9ddf86c9160e410177cdc8 100644 --- a/en/device-dev/porting/porting-chip-prepare-knows.md +++ b/en/device-dev/porting/porting-chip-prepare-knows.md @@ -18,7 +18,7 @@ The implementation of the OpenHarmony project directories and functions relies o | /build/lite | OpenHarmony basic compilation and building framework.| | /kernel/liteos_m | Basic kernel. The implementation related to the chip architecture is in the **arch** directory.| | /device | Board-level implementation, which complies with the OpenHarmony specifications. For details about the directory structure and porting process, see [Overview](../porting/porting-chip-board-overview.md).| -| /vendor | Product-level implementation, which is contributed by Huawei or product vendors.| +| /vendor | Product-level implementation, which is contributed by product vendors. | The **device** directory is in the internal structure of **device/{Chip solution vendor}/{Development board}**. The following uses HiSilicon **hispark_taurus** as an example: @@ -37,7 +37,7 @@ device ``` -The **vendor** directory is in the internal structure of **vendor/{Product solution vendor}/{Product name}**. The following uses the Huawei Wi-Fi IoT product as an example: +The **vendor** directory is in the internal structure of **vendor/{Product solution vendor}/{Product name}**. The following uses the Wi-Fi IoT product as an example: diff --git a/en/device-dev/porting/porting-linux-kernel.md b/en/device-dev/porting/porting-linux-kernel.md index 81b5fd7812343e478e163f4d6e6d73ea816da342..cbe6bef55a6b9ad6ad69f33da16c6d51843a7256 100644 --- a/en/device-dev/porting/porting-linux-kernel.md +++ b/en/device-dev/porting/porting-linux-kernel.md @@ -1,12 +1,12 @@ -# A Method for Rapidly Porting the OpenHarmony Linux Kernel<a name="EN-US_TOPIC_0000001162545194"></a> +# A Method for Rapidly Porting the OpenHarmony Linux Kernel -## Overview<a name="section28051350151118"></a> +## Overview This document describes how to quickly port OpenHarmony to a third-party chip platform by using the existing capabilities of the Linux kernel of the third-party chip platform. -## Overall Porting Approach<a name="section994883124"></a> +## Overall Porting Approach -### Kernel Mode Layer and User Mode Layer<a name="section953481431217"></a> +### Kernel Mode Layer and User Mode Layer For easy description, we divide the OpenHarmony architecture into two parts: @@ -20,7 +20,7 @@ The user mode layer includes other parts except the OpenHarmony kernel layer. It The user mode layer of OpenHarmony is loosely coupled with the third-party chip platform and is easy to port. The kernel and HDF at the kernel mode layer are closely coupled with the third-party chip platform and are difficult to port. This document focus on the porting of the kernel mode layer. In addition, it describes only the quick porting of the Linux kernel. It does not include the porting of LiteOS. -### Composition of the Kernel Mode Layer<a name="section81437528121"></a> +### Composition of the Kernel Mode Layer The OpenHarmony kernel mode layer can be further divided as follows: @@ -51,7 +51,7 @@ The standard LTS Linux kernel and third-party SoC chip platform code constitute In the following, we elaborate how to port OpenHarmony that uses with the third-party Linux kernel. -### Overall Porting Process<a name="section86060191"></a> +### Overall Porting Process The porting process is as follows: @@ -59,11 +59,11 @@ The porting process is as follows: 2. Port the OpenHarmony basic kernel-mode code. 3. Port OpenHarmony mandatory kernel-mode features \(such as HDF\). -## Procedure<a name="section98871341171310"></a> +## Procedure The following uses Raspberry Pi 3b \(BCM2837\) as an example to describe how to port OpenHarmony to Raspberry Pi. -### Setting Up the Environment<a name="section16584650181314"></a> +### Setting Up the Environment 1. Copy the third-party kernel code to the OpenHarmony build environment. @@ -84,8 +84,8 @@ The following uses Raspberry Pi 3b \(BCM2837\) as an example to describe how to # Configure the build environment, and use clang provided by the project to build the Raspberry Pi kernel source code. export PATH=$PROJ_ROOT/prebuilts/clang/ohos/linux-x86_64/llvm/bin:$PROJ_ROOT/prebuilts/gcc/linux-x86/arm/gcc-linaro-7.5.0-arm-linux-gnueabi/bin/:$PATH export MAKE_OPTIONS="ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- CC=clang HOSTCC=clang" - export PRODUCT_PATH=vendor/hisilicon/hispark_taurus_standard - ``` + export PRODUCT_PATH=vendor/hisilicon/hispark_taurus_linux + ``` 3. Comment out the flags that cannot be recognized by **clang**. @@ -96,7 +96,7 @@ The following uses Raspberry Pi 3b \(BCM2837\) as an example to describe how to ``` -### Porting Basic Kernel-Mode Code<a name="section95112081716"></a> +### Porting Basic Kernel-Mode Code Currently, the basic kernel-mode code of OpenHarmony is related to the log service. The lightweight kernel log service code includes the following: @@ -125,7 +125,7 @@ Enable the CONFIG macros **CONFIG\_HILOG** and **CONFIG\_HIEVENT** in the kernel For details about how to use the logs, see [Hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README.md). -### Porting the HDF Feature<a name="section12971205681710"></a> +### Porting the HDF Feature 1. Install HDF patches. @@ -186,14 +186,14 @@ For details about how to use the logs, see [Hilog\_lite](https://gitee.com/openh  -### Building the Image<a name="section1681965561911"></a> +### Building the Image ``` # Run the following command: make ${MAKE_OPTIONS} -j33 zImage ``` -### \(Optional\) Building and Running HDF Test Cases<a name="section460792312204"></a> +### \(Optional\) Building and Running HDF Test Cases **Overview** diff --git a/en/device-dev/porting/porting-thirdparty-cmake.md b/en/device-dev/porting/porting-thirdparty-cmake.md index 7956e702ae20df460ab4026420557d8a625276da..3ae6e23ff8382ef93fd1583487c433e468233695 100755 --- a/en/device-dev/porting/porting-thirdparty-cmake.md +++ b/en/device-dev/porting/porting-thirdparty-cmake.md @@ -348,7 +348,7 @@ The following steps show how to configure and modify the toolchains for cross-co #toolchain: follow up-layer, depend on $ohos_build_compiler if (ohos_build_compiler == "clang") { - CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${root_out_dir}sysroot/" } else { CMAKE_TOOLCHAIN_FLAG = "" } diff --git a/en/device-dev/porting/porting-thirdparty-makefile.md b/en/device-dev/porting/porting-thirdparty-makefile.md index 68136beef3a57f2068e8340974d4ada331ccc6c7..6c64a5ce974c525069df4e710753a0f2c54df594 100644 --- a/en/device-dev/porting/porting-thirdparty-makefile.md +++ b/en/device-dev/porting/porting-thirdparty-makefile.md @@ -262,9 +262,9 @@ if (ohos_build_thirdparty_migrated_from_fuchisa == true) { TEST_ENABLE = "YES" if (TEST_ENABLE == "YES") { - MAKE_COMMAND = "make test OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + MAKE_COMMAND = "make test OHOS_SYSROOT_PATH=${root_out_dir}sysroot/" } else { - MAKE_COMMAND = "make OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + MAKE_COMMAND = "make OHOS_SYSROOT_PATH=${root_out_dir}sysroot/" } ``` diff --git a/en/device-dev/quick-start/Readme-EN.md b/en/device-dev/quick-start/Readme-EN.md index faa682a677c3ad1523a3705b312f371755523fb0..294cd1ec35ccdb16369b610eed0d38ae06bc93d0 100644 --- a/en/device-dev/quick-start/Readme-EN.md +++ b/en/device-dev/quick-start/Readme-EN.md @@ -19,9 +19,9 @@ - [Burning](quickstart-ide-lite-steps-hi3516-burn.md) - [Running](quickstart-ide-lite-steps-hi3516-running.md) - Appendix - - Introduction to Development Boards - - [Introduction to the Hi3861 Development Board](quickstart-ide-lite-introduction-hi3861.md) - - [Introduction to the Hi3516 Development Board](quickstart-ide-lite-introduction-hi3516.md) + - [Introduction to the Hi3861 Development Board](quickstart-ide-lite-introduction-hi3861.md) + - [Introduction to the Hi3516 Development Board](quickstart-ide-lite-introduction-hi3516.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) - Getting Started with Mini and Small Systems (Installation Package Mode) - [Mini and Small System Overview](quickstart-lite-overview.md) - [Environment Preparation](quickstart-lite-env-setup.md) @@ -49,6 +49,7 @@ - [Introduction to the Hi3861 Development Board](quickstart-lite-introduction-hi3861.md) - [Introduction to the Hi3516 Development Board](quickstart-lite-introduction-hi3516.md) - [Reference](quickstart-lite-reference.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) - Getting Started with Standard System (IDE Mode, Recommended) - [Standard System Overview](quickstart-ide-standard-overview.md) - Environment Preparation @@ -67,9 +68,9 @@ - [Burning](quickstart-ide-standard-running-rk3568-burning.md) - [Running](quickstart-ide-standard-running-rk3568-running.md) - Appendix - - Introduction to Development Boards - - [Introduction to the Hi3516 Development Board](quickstart-ide-standard-board-introduction-hi3516.md) - - [Introduction to the RK3568 Development Board](quickstart-ide-standard-board-introduction-rk3568.md) + - [Introduction to the Hi3516 Development Board](quickstart-ide-standard-board-introduction-hi3516.md) + - [Introduction to the RK3568 Development Board](quickstart-ide-standard-board-introduction-rk3568.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) - Getting Started with Standard System (Installation Package Mode) - [Standard System Overview](quickstart-standard-overview.md) - [Setting Up Environments for Standard System](quickstart-standard-env-setup.md) @@ -93,3 +94,4 @@ - [Introduction to the Hi3516 Development Board](quickstart-standard-board-introduction-hi3516.md) - [Introduction to the RK3568 Development Board](quickstart-standard-board-introduction-rk3568.md) - [Reference](quickstart-standard-reference.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001114129426.png b/en/device-dev/quick-start/figures/en-us_image_0000001114129426.png index c5548cb227bd024b49aa3adba0a20869581448e8..8cff39968a2d34bdd93daa5de808a07558b56077 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001114129426.png and b/en/device-dev/quick-start/figures/en-us_image_0000001114129426.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001114129427.png b/en/device-dev/quick-start/figures/en-us_image_0000001114129427.png new file mode 100644 index 0000000000000000000000000000000000000000..b4d11ba64f1f23a789167eabfc36f482fbc09697 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001114129427.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001160649343.png b/en/device-dev/quick-start/figures/en-us_image_0000001160649343.png index 67d8044b72056d4ed6230ccc4ad99d5e954596b6..144950cb8cb1d260989d988242ca318ab584dfe6 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001160649343.png and b/en/device-dev/quick-start/figures/en-us_image_0000001160649343.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001160649344.png b/en/device-dev/quick-start/figures/en-us_image_0000001160649344.png new file mode 100644 index 0000000000000000000000000000000000000000..82edf61fc871cc83e073036ee2593b89dea5e5cb Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001160649344.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001177478136.png b/en/device-dev/quick-start/figures/en-us_image_0000001177478136.png index fcaf25e47e2e47ecad8aebe463aeccdf1d8bf85e..e83dad0b26392f009564d2e4014e374187ac1d7f 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001177478136.png and b/en/device-dev/quick-start/figures/en-us_image_0000001177478136.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001194504874.png b/en/device-dev/quick-start/figures/en-us_image_0000001194504874.png index fdd12932d3777bd30a208e539a78ede6384cce19..0ba155fce3a06f53d085a1309cc00e9710e3c58d 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001194504874.png and b/en/device-dev/quick-start/figures/en-us_image_0000001194504874.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001194821710.png b/en/device-dev/quick-start/figures/en-us_image_0000001194821710.png index 17d64a31a527a2b7453cc8490655609bd338ad7c..560240a18a081d50201d6185d25da46cc1c7a0eb 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001194821710.png and b/en/device-dev/quick-start/figures/en-us_image_0000001194821710.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001198566364.png b/en/device-dev/quick-start/figures/en-us_image_0000001198566364.png index 1ba77b7feaca23043e71171824cdead7c4f8f108..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001198566364.png and b/en/device-dev/quick-start/figures/en-us_image_0000001198566364.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001198566365.png b/en/device-dev/quick-start/figures/en-us_image_0000001198566365.png new file mode 100644 index 0000000000000000000000000000000000000000..5702f209752edc74d687e5e8ce7e210428f4551e Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001198566365.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001198722374.png b/en/device-dev/quick-start/figures/en-us_image_0000001198722374.png index c6507f28b980b84c65102aa844e93f806cb490a9..6914f2d806dc8a2a8a26a8265f60832686dc2902 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001198722374.png and b/en/device-dev/quick-start/figures/en-us_image_0000001198722374.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001198943768.png b/en/device-dev/quick-start/figures/en-us_image_0000001198943768.png index 5a709092da504fbb090ad8d44938e435712bc0eb..5702f209752edc74d687e5e8ce7e210428f4551e 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001198943768.png and b/en/device-dev/quick-start/figures/en-us_image_0000001198943768.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001220852753.png b/en/device-dev/quick-start/figures/en-us_image_0000001220852753.png new file mode 100644 index 0000000000000000000000000000000000000000..58d4e1027aefb6650920d9d31fbb622bebc4f726 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001220852753.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001220852754.png b/en/device-dev/quick-start/figures/en-us_image_0000001220852754.png index c3013a3f9bd3951e53e1f0848c12700024c5f5e8..a316d0a2c4117a16143c79426523dbc75c8dd1a8 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001220852754.png and b/en/device-dev/quick-start/figures/en-us_image_0000001220852754.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001220852755.png b/en/device-dev/quick-start/figures/en-us_image_0000001220852755.png new file mode 100644 index 0000000000000000000000000000000000000000..884a8a0d8dfc1e14b3b2a256ede49bc88772c816 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001220852755.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221012767.png b/en/device-dev/quick-start/figures/en-us_image_0000001221012767.png new file mode 100644 index 0000000000000000000000000000000000000000..eead40cd3f889b23f73a6f02a9b7f44c822c2e37 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001221012767.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221012768.png b/en/device-dev/quick-start/figures/en-us_image_0000001221012768.png new file mode 100644 index 0000000000000000000000000000000000000000..d744afcd6c27ca674ae202bd4ca3511bb58bdbbc Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001221012768.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221025048.png b/en/device-dev/quick-start/figures/en-us_image_0000001221025048.png index f17d2dd5dbc86b98a659218ed4a5e3a69409ae54..f0d3cfc874effae73aad01dd26961ef4946c8f81 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001221025048.png and b/en/device-dev/quick-start/figures/en-us_image_0000001221025048.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221172710.png b/en/device-dev/quick-start/figures/en-us_image_0000001221172710.png index 29b22463c375704734e6925861551aa27ec7b295..cd6c3f1d8cea88d58a885446dad9cae3b74bce0b 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001221172710.png and b/en/device-dev/quick-start/figures/en-us_image_0000001221172710.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221172711.png b/en/device-dev/quick-start/figures/en-us_image_0000001221172711.png new file mode 100644 index 0000000000000000000000000000000000000000..d1992b49a9805cd0823c98c2d6f1500a10c5f249 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001221172711.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221344980.png b/en/device-dev/quick-start/figures/en-us_image_0000001221344980.png index 7bf0acc41746926462ab3c352f143f90f2e65358..86501f030f57eea30b724f8b7d32736a8ddc7f21 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001221344980.png and b/en/device-dev/quick-start/figures/en-us_image_0000001221344980.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001221356692.png b/en/device-dev/quick-start/figures/en-us_image_0000001221356692.png index 8f5ee977c68bce18bed83887191ddf870df7d8e9..6d567bf69106c8bb266c7f7f445a317b5405c6a5 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001221356692.png and b/en/device-dev/quick-start/figures/en-us_image_0000001221356692.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001223190441.png b/en/device-dev/quick-start/figures/en-us_image_0000001223190441.png index 63d053122f3c7beaa990f63431ccb16692562535..c3c0811c65d83f3a88f158f1c3336c1a950f4e69 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001223190441.png and b/en/device-dev/quick-start/figures/en-us_image_0000001223190441.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001225760456.png b/en/device-dev/quick-start/figures/en-us_image_0000001225760456.png index 9e249959cad7e68b535f8732b44e20db9f6db2fc..61536a53597991971c997481624f1aedbc232c6d 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001225760456.png and b/en/device-dev/quick-start/figures/en-us_image_0000001225760456.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001227277128.png b/en/device-dev/quick-start/figures/en-us_image_0000001227277128.png index fd2a5588e6576449bcb9ec1f92a12649dcd6c5d0..df66ac7a87d293ae8500eae978fbe5bcbc23e214 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001227277128.png and b/en/device-dev/quick-start/figures/en-us_image_0000001227277128.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001227757036.png b/en/device-dev/quick-start/figures/en-us_image_0000001227757036.png index c354bdb69c0293fd19cb71905f828fca1fe7d09c..dea8677bfd7c9ba3f7b82f00c8422d695f85b86b 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001227757036.png and b/en/device-dev/quick-start/figures/en-us_image_0000001227757036.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001239661509.png b/en/device-dev/quick-start/figures/en-us_image_0000001239661509.png index c3f10040538814eccbecf2ef37d472d59743e08f..541920af4791d36a3ad8eb3e8ccf154dc947944a 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001239661509.png and b/en/device-dev/quick-start/figures/en-us_image_0000001239661509.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001243704061.png b/en/device-dev/quick-start/figures/en-us_image_0000001243704061.png index c93b7b610138e91c0b6b171cb515f540163e731b..f81b300b68edcc0400dcf72dfeb827fcf6ccaeea 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001243704061.png and b/en/device-dev/quick-start/figures/en-us_image_0000001243704061.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265492885.png b/en/device-dev/quick-start/figures/en-us_image_0000001265492885.png index 7cc6ca102383151b5b67447332e73fc16c5ef85e..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265492885.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265492885.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265505181.png b/en/device-dev/quick-start/figures/en-us_image_0000001265505181.png index eff6401bb39152c2d02b7f17e557b1cd5dbb0e87..da90fa7c0cd0da44ab6aff877eb8e11550dc7871 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265505181.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265505181.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265652869.png b/en/device-dev/quick-start/figures/en-us_image_0000001265652869.png index 4c1ce174731a8e20b62d119cbe1728e9a8394176..fb6232380ebbc988a3b23dfec149daedd3f0c971 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265652869.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265652869.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265665157.png b/en/device-dev/quick-start/figures/en-us_image_0000001265665157.png index 0a574b8ee51edd1f4049e5ca6821a9347a45c2de..56dabefba81dd9391d3bb5f52931bdbdc5753b22 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265665157.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265665157.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265676877.png b/en/device-dev/quick-start/figures/en-us_image_0000001265676877.png index a87d8c651147e1b7cb1f3d60513a6b3139540399..f467c1b45f84730fd3fc45158004d9a03dec2551 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265676877.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265676877.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265772913.png b/en/device-dev/quick-start/figures/en-us_image_0000001265772913.png index 659d732a4d044cfa4dacb84c5ec96bfc6b29707e..e5596ca2eac9b5d2cd1c96ffa50b1e390c68c904 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265772913.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265772913.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265785209.png b/en/device-dev/quick-start/figures/en-us_image_0000001265785209.png index 0e5a65d7765d8bc936ca9a2d7db12f3adeffd831..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265785209.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265785209.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001265945173.png b/en/device-dev/quick-start/figures/en-us_image_0000001265945173.png index f2447dd8f49268594e781e1c68751b209e01894c..d6dbd5d63c55c135dd8121d4ca1b4d11d5438897 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001265945173.png and b/en/device-dev/quick-start/figures/en-us_image_0000001265945173.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001266887264.png b/en/device-dev/quick-start/figures/en-us_image_0000001266887264.png index f931e2cfba06791a3891248c5d8e6a9f0e86bf0e..e17047264d181b73e48e96a54c60517b57f42fb5 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001266887264.png and b/en/device-dev/quick-start/figures/en-us_image_0000001266887264.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001267532292.png b/en/device-dev/quick-start/figures/en-us_image_0000001267532292.png index 8ed1535a6bc23dc5bd02fbd5a3f1392f46ad8d83..db92b0181a48b56990633058e3a4efce7ca5be82 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001267532292.png and b/en/device-dev/quick-start/figures/en-us_image_0000001267532292.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271237241.png b/en/device-dev/quick-start/figures/en-us_image_0000001271237241.png index caa9309b7f069597073ffa593a7fbc6820b4b2e9..0a150015345ea48708c486f21b76796f6e3ee36d 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001271237241.png and b/en/device-dev/quick-start/figures/en-us_image_0000001271237241.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271237242.png b/en/device-dev/quick-start/figures/en-us_image_0000001271237242.png new file mode 100644 index 0000000000000000000000000000000000000000..9a300afbcd842f7c61877123236675efc422f039 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001271237242.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271442129.png b/en/device-dev/quick-start/figures/en-us_image_0000001271442129.png new file mode 100644 index 0000000000000000000000000000000000000000..8587b80f4fc5cb91cd18462b47053451947d4833 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001271442129.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271442261.png b/en/device-dev/quick-start/figures/en-us_image_0000001271442261.png index 4e14740a2906da609abea693b77a2680fa7054a2..8587b80f4fc5cb91cd18462b47053451947d4833 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001271442261.png and b/en/device-dev/quick-start/figures/en-us_image_0000001271442261.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271448821.png b/en/device-dev/quick-start/figures/en-us_image_0000001271448821.png index 53cbcb8b0d0c30cb289b746d20b6c73927019d1a..0a150015345ea48708c486f21b76796f6e3ee36d 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001271448821.png and b/en/device-dev/quick-start/figures/en-us_image_0000001271448821.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001271477045.png b/en/device-dev/quick-start/figures/en-us_image_0000001271477045.png index c55a6ddd1aa319adfa05987ff3f5c79231e7208d..8581b9663ab1f1597166d9e5b668c4d70c273e01 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001271477045.png and b/en/device-dev/quick-start/figures/en-us_image_0000001271477045.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001275592884.png b/en/device-dev/quick-start/figures/en-us_image_0000001275592884.png new file mode 100644 index 0000000000000000000000000000000000000000..2186d2a5328684c1a479d4fca6b9fa74884c6a7b Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001275592884.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001276354454.png b/en/device-dev/quick-start/figures/en-us_image_0000001276354454.png new file mode 100644 index 0000000000000000000000000000000000000000..2419d79327a7a13df83fe637916b9abeb180a2b0 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001276354454.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001278358765.png b/en/device-dev/quick-start/figures/en-us_image_0000001278358765.png index 96b251c58071d4203ff51f28317f378d6ec71ebb..3bb58a00550fb0a0e195eb7f4cdb9e80be1ac6ab 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001278358765.png and b/en/device-dev/quick-start/figures/en-us_image_0000001278358765.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001279425450.png b/en/device-dev/quick-start/figures/en-us_image_0000001279425450.png new file mode 100644 index 0000000000000000000000000000000000000000..fa3d1c40e18002a60a3c179b5e4e1396056a5b41 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001279425450.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001279426717.png b/en/device-dev/quick-start/figures/en-us_image_0000001279426717.png index 53cbcb8b0d0c30cb289b746d20b6c73927019d1a..0a150015345ea48708c486f21b76796f6e3ee36d 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001279426717.png and b/en/device-dev/quick-start/figures/en-us_image_0000001279426717.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001279586409.png b/en/device-dev/quick-start/figures/en-us_image_0000001279586409.png new file mode 100644 index 0000000000000000000000000000000000000000..e1cfe8323c13c750a03c4d5c86f2c383e554485d Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001279586409.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001279587085.png b/en/device-dev/quick-start/figures/en-us_image_0000001279587085.png new file mode 100644 index 0000000000000000000000000000000000000000..084af8cfb40d4c59aa428890df7a1aee622a79d4 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001279587085.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001280938208.png b/en/device-dev/quick-start/figures/en-us_image_0000001280938208.png new file mode 100644 index 0000000000000000000000000000000000000000..2e1c5ad3ffe3f4dcceeb78c33856c063aa506b43 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001280938208.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001312778829.png b/en/device-dev/quick-start/figures/en-us_image_0000001312778829.png index 15791ccc963502062bd54537567db8876d9d7b63..eb1df60899dd8c41a61369410603d8f0adb77486 100644 Binary files a/en/device-dev/quick-start/figures/en-us_image_0000001312778829.png and b/en/device-dev/quick-start/figures/en-us_image_0000001312778829.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001322167645.png b/en/device-dev/quick-start/figures/en-us_image_0000001322167645.png new file mode 100644 index 0000000000000000000000000000000000000000..b2d394f1debbbcf714a401630370639014d46160 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001322167645.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001326412233.png b/en/device-dev/quick-start/figures/en-us_image_0000001326412233.png new file mode 100644 index 0000000000000000000000000000000000000000..e31eef74e95c2ecbb8e62d4ad897a2188e66d186 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001326412233.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001327429541.png b/en/device-dev/quick-start/figures/en-us_image_0000001327429541.png new file mode 100644 index 0000000000000000000000000000000000000000..cc19b0a8e8f97ec07b29eab8b01f387c5c81903c Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001327429541.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001333642545.png b/en/device-dev/quick-start/figures/en-us_image_0000001333642545.png new file mode 100644 index 0000000000000000000000000000000000000000..2186d2a5328684c1a479d4fca6b9fa74884c6a7b Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001333642545.png differ diff --git a/en/device-dev/quick-start/figures/en-us_image_0000001333802045.png b/en/device-dev/quick-start/figures/en-us_image_0000001333802045.png new file mode 100644 index 0000000000000000000000000000000000000000..1fef79a0d9ab7d7862be1e108ae947cec5eb16d2 Binary files /dev/null and b/en/device-dev/quick-start/figures/en-us_image_0000001333802045.png differ diff --git a/en/device-dev/quick-start/quickstart-build.md b/en/device-dev/quick-start/quickstart-build.md new file mode 100644 index 0000000000000000000000000000000000000000..d37a8b85537962efed99a9a2b68e1566cf06f9a9 --- /dev/null +++ b/en/device-dev/quick-start/quickstart-build.md @@ -0,0 +1,40 @@ +# Overall Description of Compilation Form Factors +Products Supported for Compilation and Building (Click the links to learn about the specific product configurations and related differences.) + +| Compilation Form Factor | Development Board | Main Chip | Kernel | System Type | +| ----------------------------- | --------------- | ----------- | ----------- | ----------- | +| [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | WinnerMicro | LiteOS-M | Mini | +| [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | Rockchip | Linux | Standard | +| [rk3568_mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_mini_system/config.json) | rk3568 | Rockchip | Linux | Standard | +| [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | STM32MP1xx | LiteOS-A | small | +| [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | Hi3861 V100 | LiteOS-M | Mini | +| [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | Hi3861 V100 | LiteOS-M | Mini | +| [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | hi3518ev300 | LiteOS-A | Small | +| [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | Hi3516D V300 | LiteOS-A | Small | +| [ipcamera_hispark_taurus_linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_linux/config.json) | hispark_taurus | Hi3516D V300 | Linux | Small | +| [hispark_taurus_standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_standard/config.json) | hispark_taurus | Hi3516D V300 | Linux | Standard | +| [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | Hi3516D V300 | Linux | Standard | +| [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | hi3751v350 | Linux | Standard | +| [hispark_taurus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_mini_system/config.json) | hispark_taurus | Hi3516D V300 | LiteOS-A | Mini | +| [hispark_pegasus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_mini_system/config.json) | hispark_pegasus | Hi3861 V100 | LiteOS-M | Mini | +| [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini | +| [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | GR551x | LiteOS-M | Mini | +| [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | ASR582X | LiteOS-M | Mini | +| [xts_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/xts_demo/config.json) | dev_wifi_a | ASR582X | LiteOS-M | Mini | +| [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | +| [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | +| [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | BES2600 | LiteOS-M | Mini | +| [mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/mini_distributed_music_player/config.json) | v200zr | BES2600 | LiteOS-M | Mini | +| [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | stm32f4xx | LiteOS-M | Mini | +| [qemu_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json) | arm_mps2_an386 | QEMU | LiteOS-M | Mini | +| [qemu_cksy_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_csky_mini_system_demo/config.json) | SmartL_E802 | QEMU | LiteOS-M | Mini | +| [qemu_cm55_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_cm55_mini_system_demo/config.json) | arm_mps3_an547 | QEMU | LiteOS-M | Mini | +| [qemu_xtensa_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_xtensa_mini_system_demo/config.json) | esp32 | QEMU | LiteOS-M | Mini | +| [qemu_riscv_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_riscv32_mini_system_demo/config.json) | ricsv32_virt | QEMU | LiteOS-M | Mini | +| [qemu_ca7_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_ca7_mini_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small | +| [qemu_small_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | QEMU | LiteOS-A | Small | +| [qemu_arm_linux_min](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_min/config.json) | qemu-arm-linux | QEMU | Linux | Standard | +| [qemu_arm_linux_headless](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | QEMU | Linux | Standard | +| [iotlink_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | +| [dsoftbus_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | +| [xts_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/xts_demo/config.json) | cst85_wblink | Chipsea | LiteOS-M | Mini | diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md index 798e092f3b6f5d0476c0adb12147d2f215f16e1c..1733121204ab84855e33b90409ecb4aa5f5c8f95 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md @@ -58,7 +58,7 @@ Perform the steps below in the source code directory: 3. Add a component. - Modify the **build/lite/components/applications.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **applications.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) + Modify the **build/lite/components/communication.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **communication.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) ``` diff --git a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md index f3de1522e47257bf0b3f0a644b945c5cc629d87f..9c180451924b4fbccb3492f877bf5ed2946b301f 100644 --- a/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md +++ b/en/device-dev/quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md @@ -62,7 +62,7 @@ The following exemplifies how to create a program by modifying the source code. 4. Add a component. - Modify the **build/lite/components/applications.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **applications.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) + Modify the **build/lite/components/communication.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **communication.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) ``` diff --git a/en/device-dev/quick-start/quickstart-lite-env-setup.md b/en/device-dev/quick-start/quickstart-lite-env-setup.md index bdbc5b70d3f908618aa0800a34db564295ed3012..0ed30ce269de01663c69593b15a8d5eb8d70f141 100644 --- a/en/device-dev/quick-start/quickstart-lite-env-setup.md +++ b/en/device-dev/quick-start/quickstart-lite-env-setup.md @@ -379,18 +379,19 @@ Perform the following steps in Ubuntu: ### Installing LLVM (Only Required for OpenHarmony_v1.x) >  **NOTICE**<br> -> When downloading source code under the OpenHarmony_v1.x branches or tags, perform the operation procedure described in this section to install LLVM 9.0.0. +> When downloading source code under the OpenHarmony_v1.x branches or tags, perform the operation procedure described in this section to install LLVM 12.0.1. > > When downloading source code under the Master or non-OpenHarmony_v1.x branches or tags, skip this section. hb will automatically download the latest version of LLVM. 1. Start a Linux server. -2. [Download LLVM](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar) +2. [Download LLVM](https://repo.huaweicloud.com/openharmony/compiler/clang/12.0.1-530132/linux/clang-530132-linux-x86_64.tar.bz2) 3. Decompress the LLVM installation package to **~/llvm**. ``` - tar -zxvf llvm.tar -C ~/ + tar -jxvf clang.tar.bz2 -C ~/ + mv ~/clang-530132/ ~/llvm ``` 4. Set the environment variable. diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md index 798e092f3b6f5d0476c0adb12147d2f215f16e1c..1733121204ab84855e33b90409ecb4aa5f5c8f95 100644 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md +++ b/en/device-dev/quick-start/quickstart-lite-steps-hi3516-helloworld.md @@ -58,7 +58,7 @@ Perform the steps below in the source code directory: 3. Add a component. - Modify the **build/lite/components/applications.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **applications.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) + Modify the **build/lite/components/communication.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **communication.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) ``` diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md index f3de1522e47257bf0b3f0a644b945c5cc629d87f..9c180451924b4fbccb3492f877bf5ed2946b301f 100644 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md +++ b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-helloworld.md @@ -62,7 +62,7 @@ The following exemplifies how to create a program by modifying the source code. 4. Add a component. - Modify the **build/lite/components/applications.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **applications.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) + Modify the **build/lite/components/communication.json** file and add the configuration of **hello_world_app**. The following code snippet is a snippet of the **communication.json** file: The configuration between \#\#start\#\# and \#\#end\#\# is new. (\#\#start\#\# and \#\#end\#\# are only used to identify the location. After the configuration is complete, delete these lines.) ``` diff --git a/en/device-dev/quick-start/quickstart-standard-ide-directory.md b/en/device-dev/quick-start/quickstart-standard-ide-directory.md index 5285337d788ce1d7e97b286419f7beabfa59faef..51c4c3cb4951c817e86660138cba4348c103e70a 100644 --- a/en/device-dev/quick-start/quickstart-standard-ide-directory.md +++ b/en/device-dev/quick-start/quickstart-standard-ide-directory.md @@ -1,22 +1,22 @@ ## Getting Started with Standard System (IDE Mode) - [Standard System Overview](quickstart-ide-standard-overview.md) - - Environment Preparation - - [Setting Up the Windows+Ubuntu Hybrid Development Environment](quickstart-ide-standard-env-setup-win-ubuntu.md) - - [Obtaining Source Code](quickstart-ide-standard-sourcecode-acquire.md) - - [Creating a Source Code Project](quickstart-ide-standard-create-project.md) - - Running a Hello World Program - - Hi3516 Development Board - - [Writing a Hello World Program](quickstart-ide-standard-running-hi3516-create.md) - - [Building](quickstart-ide-standard-running-hi3516-build.md) - - [Burning](quickstart-ide-standard-running-hi3516-burning.md) - - [Running](quickstart-ide-standard-running-hi3516-running.md) - - RK3568 Development Board - - [Writing a Hello World Program](quickstart-ide-standard-running-rk3568-create.md) - - [Building](quickstart-ide-standard-running-rk3568-build.md) - - [Burning](quickstart-ide-standard-running-rk3568-burning.md) - - [Running](quickstart-ide-standard-running-rk3568-running.md) - - Appendix - - Introduction to Development Boards - - [Introduction to the Hi3516 Development Board](quickstart-ide-standard-board-introduction-hi3516.md) - - [Introduction to the RK3568 Development Board](quickstart-ide-standard-board-introduction-rk3568.md) - - [Getting Started with Mini and Small Systems (Installation Package Mode)](quickstart-lite-package-directory.md) +- Environment Preparation + - [Setting Up the Windows+Ubuntu Hybrid Development Environment](quickstart-ide-standard-env-setup-win-ubuntu.md) + - [Obtaining Source Code](quickstart-ide-standard-sourcecode-acquire.md) +- [Creating a Source Code Project](quickstart-ide-standard-create-project.md) +- Running a Hello World Program + - Hi3516 Development Board + - [Writing a Hello World Program](quickstart-ide-standard-running-hi3516-create.md) + - [Building](quickstart-ide-standard-running-hi3516-build.md) + - [Burning](quickstart-ide-standard-running-hi3516-burning.md) + - [Running](quickstart-ide-standard-running-hi3516-running.md) + - RK3568 Development Board + - [Writing a Hello World Program](quickstart-ide-standard-running-rk3568-create.md) + - [Building](quickstart-ide-standard-running-rk3568-build.md) + - [Burning](quickstart-ide-standard-running-rk3568-burning.md) + - [Running](quickstart-ide-standard-running-rk3568-running.md) +- Appendix + - [Introduction to the Hi3516 Development Board](quickstart-ide-standard-board-introduction-hi3516.md) + - [Introduction to the RK3568 Development Board](quickstart-ide-standard-board-introduction-rk3568.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) + diff --git a/en/device-dev/quick-start/quickstart-standard-package-directory.md b/en/device-dev/quick-start/quickstart-standard-package-directory.md index 8912028e042d94cf2fea39d1e0033ccfc456d611..c544aa1e268e21ecf00aeed733a303a72626fc32 100644 --- a/en/device-dev/quick-start/quickstart-standard-package-directory.md +++ b/en/device-dev/quick-start/quickstart-standard-package-directory.md @@ -3,7 +3,7 @@ - [Setting Up Environments for Standard System](quickstart-standard-env-setup.md) - Running a Hello World Program - Hi3516 Development Board - - [Writing a Hello World Program](quickstart-standard-running-hi3516-create.md) + - [Writing a Hello World Program](quickstart-std-3516-create.md) - [Building](quickstart-standard-running-hi3516-build.md) - [Burning](quickstart-standard-running-hi3516-burning.md) - [Running](quickstart-standard-running-hi3516-running.md) @@ -20,5 +20,5 @@ - Introduction to Development Boards - [Introduction to the Hi3516 Development Board](quickstart-standard-board-introduction-hi3516.md) - [Introduction to the RK3568 Development Board](quickstart-standard-board-introduction-rk3568.md) - - [Getting Started with Standard System (IDE Mode)](quickstart-standard-ide-directory.md) + - [Overall Description of Compilation Form Factors](quickstart-build.md) - [Reference](quickstart-standard-reference.md) diff --git a/en/device-dev/subsystems/figure/Hiview_module_data_interaction.png b/en/device-dev/subsystems/figure/Hiview_module_data_interaction.png new file mode 100644 index 0000000000000000000000000000000000000000..b2b734bc03a4a6556f3c4128b7a86244ffaa3d09 Binary files /dev/null and b/en/device-dev/subsystems/figure/Hiview_module_data_interaction.png differ diff --git a/en/device-dev/subsystems/figure/build-process.jpg b/en/device-dev/subsystems/figure/build-process.jpg index a48ea734509526b3ed0fe85b7c4a98b0a2a9c4f0..68fba0c4265dc6899eb6576dd243a7887d5cf615 100644 Binary files a/en/device-dev/subsystems/figure/build-process.jpg and b/en/device-dev/subsystems/figure/build-process.jpg differ diff --git a/en/device-dev/subsystems/subsys-boot.md b/en/device-dev/subsystems/subsys-boot.md index f4d2e36562e6766d51b5f4bcbef0843ac69488c7..a5b61f59149cd57c0df24fa4d656e92271808808 100644 --- a/en/device-dev/subsystems/subsys-boot.md +++ b/en/device-dev/subsystems/subsys-boot.md @@ -3,7 +3,6 @@ - **[Startup](subsys-boot-overview.md)** - **[init Module](subsys-boot-init.md)** - **[appspawn Module](subsys-boot-appspawn.md)** -- **[appspawn Module for the Standard System](subsys-boot-appspawn-standard.md)** - **[bootstrap Module](subsys-boot-bootstrap.md)** - **[syspara Module](subsys-boot-syspara.md)** - **[FAQs](subsys-boot-faqs.md)** diff --git a/en/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md b/en/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md index 61ee379301ce6efd16ba3fa3642599932719b085..66181d0660e07c52462a009aa360ca48f27cd3fa 100644 --- a/en/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md +++ b/en/device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md @@ -2,46 +2,46 @@ ## Overview -Generate Ninja (GN) a meta-build system that generates build files for Ninja, which allows you to build your OpenHarmony projects with Ninja. +Generate Ninja (GN) is a meta-build system that generates build files for Ninja. It is the front end of Ninja. GN and Ninja together complete OpenHarmony build tasks. -### Introduction to GN +### GN -- GN is currently used in several popular systems, including Chromium, Fuchsia, and OpenHarmony. -- The GN syntax has limitations rooted in its design philosophy. For example, there is no way to get the length of a list and wildcards are not supported. To learn about the GN design philosophy, see https://gn.googlesource.com/gn/+/main/docs/language.md#Design-philosophy. Therefore, if you find that it is complex to implement something using GN, look it over and think about whether it is really necessary. -- For details about GN, see the official GN document at https://gn.googlesource.com/gn/+/main/docs/. +- GN is used in large software systems such as Chromium, Fuchsia, and OpenHarmony. +- However, the GN syntax has limitations rooted in its [design philosophy](https://gn.googlesource.com/gn/+/main/docs/language.md#Design-philosophy). For example, it does not support wildcards and cannot get the length of a list. If you find it complex to implement something with GN, stop and consider whether it is necessary to do it. +- For more details about GN, visit https://gn.googlesource.com/gn/+/main/docs/. -### Intended Audience and Scope +### Intended Audience and Purpose -This document is intended for OpenHarmony developers. Its focus is on the GN coding style and issues that may occur during the use of GN. The GN syntax is not covered here. For details about the basics of GN, see the GN reference document at https://gn.googlesource.com/gn/+/main/docs/reference.md. +This document is intended for OpenHarmony developers. This document describes the GN coding style and practices. It does not cover the GN syntax. For details about the GN basics, see [GN Reference](https://gn.googlesource.com/gn/+/main/docs/reference.md). ### General Principles -On the premise that functions are available, scripts must be easy to read, easy to maintain, and exhibit good scalability and performance. +Scripts must be easy to read and maintain, and have good scalability and performance while functioning well. ## Coding Style ### Naming -In general cases, the naming follows the Linux kernel coding style, that is, **lowercase letters+underscore**. +Follow the Linux kernel naming style, that is, lowercase letters + underscores (_). #### Local Variables -For the purpose of this document, a local variable refers to a variable that is restricted to use in a certain scope and not passed down. +A local variable is a variable restricted to use in a certain scope and cannot be passed down. -To better distinguish local variables from global variables, local variables start with an underscore (**_**). +Different from global variables, local variables start with an underscore (_). ``` -# Example 1 +# Example 1: action("some_action") { ... - # _output is a local variable. Hence, it starts with an underscore (_). + # _output is a local variable. _output = "${target_out_dir}/${target_name}.out" outputs = [ _output ] args = [ ... - "--output", - rebase_path(_output, root_build_dir), - ... + "--output", + rebase_path(_output, root_build_dir), + ... ] ... } @@ -49,32 +49,32 @@ action("some_action") { #### Global Variables -A global variable starts with a **lowercase letter**. +A global variable starts with a lowercase letter. -If you want a variable value to be modified by **gn args**, use **declare\_args**. Otherwise, do not use **declare\_args**. +Use **declare_args** to declare the variable value only if the variable value can be modified by **gn args**. ``` # Example 2 declare_args() { - # You can use gn args to change the value of some_feature. + # The value of some_feature can be changed by gn args. some_feature = false } ``` #### Targets -The target is named in the format of **lowercase letters+underscore**. - -A subtarget in the template is named in the ${*target\_name*}\__*suffix* format. This naming convention has the following advantages: +Name the targets in the lowercase letters + underscores (_) format. -- The ${*target\_name*} part can prevent duplicate subtarget names. +Name the subtargets in templates in the ${target_name}+double underscores (__)+suffix format. This naming convention has the following advantages: -- The double underscores (\__) can help identify the module to which the subtarget belongs, thereby facilitating fault locating. +- ${target_name} prevents duplicate subtarget names. +- The double underscores (__) help locate the module to which a subtarget belongs. + ``` # Example 3 template("ohos_shared_library") { - # "{target_name}" (primary target name) + "__" (double underscores) + "notice" (suffix) + # "{target_name}" (Target name) + "__" (double underscores) + "notice" (suffix) _notice_target = "${target_name}__notice" collect_notice(_notice_target) { ... @@ -87,7 +87,7 @@ A subtarget in the template is named in the ${*target\_name*}\__*suffix* format. #### Custom Templates -Whenever possible, **use verbs** for template names. +Name templates in the verb+object format. ``` # Example 4 @@ -99,15 +99,15 @@ template("compile_resources") { ### Formatting -To maintain consistency in styles such as code alignment and line feed, a GN script needs to be formatted before being submitted. Use the format tool provided by GN to format your script. The command is as follows: +GN scripts must be formatted before being submitted. Formatting ensures consistency in style, such as code alignment and line feed. Use the format tool provided by GN to format your scripts. The command is as follows: ```shell $ gn format path-to-BUILD.gn ``` -**gn format** sorts imports in alphabetical order. To maintain the original sequence, you can add an empty comment line. +**gn format** sorts the imported files in alphabetical order. To maintain the original sequence, add an empty comment line. -Assume that the original import sequence is as follows: +For example, the original import sequence is as follows: ``` # Example 5 @@ -115,42 +115,42 @@ import("//b.gni") import("//a.gni") ``` -After the format command is executed, the import sequence is changed as follows: +**gn format** sorts the files as follows: ``` import("//a.gni") import("//b.gni") ``` -To maintain the original import sequence, add an empty comment line. +To maintain the original sequence, add an empty comment line. ``` import("//b.gni") -# Comment to maintain the original import sequence. +# Comment to keep the original sequence import("//a.gni") ``` -## Coding Practice - -### Principles of Practice +## Coding Practices -The build script completes the following two tasks: +### Guidelines -1. **Describe the dependency between modules (deps).** +The build script completes the following tasks: - In practice, the most frequent problem is **lack of dependency**. +1. Describes the dependency (deps) between modules. + + In practice, the most common problem is lack of dependency. -2. **Describe the module compilation rules (rule).** +2. Defines the module build rules (rule). + + In practice, unclear input and output are common problems. - In practice, common problems are **unclear input** and **unclear output**. - -Lack of dependency can result in the following: - -- **Possible compilation error** +Lack of dependency leads to the following problems: +- Unexpected compilation error + ``` # Example 6 - # The compilation is prone to errors as a result of lack of dependency. + # Lack of dependency poses a possibility of compilation errors. shared_library("a") { ... } @@ -164,35 +164,35 @@ Lack of dependency can result in the following: deps = [ ":b" ] } ``` + + In this example, **libb.so** is linked to **liba.so**, which means that **b** depends on **a**. However, the dependency of **b** on **a** is not declared in the dependency list (**deps**) of **b**. Compilation is performed concurrently. An error occurs if **liba.so** is not available when **libb.so** attempts to create a link to it. + + If **liba.so** is available, the compilation is successful. Therefore, lack of dependency poses a possibility of compilation errors. - In the preceding example, **liba.so** is linked to **libb.so** when being linked. This means that **b** depends on **a**. However, the dependency list (**deps**) of **b** does not declare its dependency on **a**. As compilation is performed concurrently, a compilation error will occur if compilation of **liba.so** is not yet complete when **libb.so** is being linked. - - From this example we can see that lack of dependency does not necessarily lead to a compilation error. It poses a possibility of errors. - -- **Missing involvement of dependent modules** - - In the preceding example, because **images** depends on **b** only, **a** does not participate in the compilation of **images** using Ninja. However, as **b** depends on **a**, an error occurs when **b** is linked. +- Missing compilation of modules + + In example 6, images are the target to build. Since images depend only on **b**, **a** will not be compiled. However, as **b** depends on **a**, an error occurs when **b** is linked. -One less common problem is **too many dependencies**. **Too many dependencies can reduce concurrency and slow down compilation**. +Another problem is unnecessary dependencies. Unnecessary dependencies reduce concurrency and slow down compilation. The following is an example: -In the example below, adding the unwanted **_compile\_resource\_target** dependency to **_compile\_js_target** means that **_compile\_js_target** can be compiled only after compilation of **_compile\_resource\_target** is complete. +**_compile_js_target** does not necessarily depend on **_compile_resource_target**. If this dependency is added, **_compile_js_target** can be compiled only after **_compile_resource_target** is compiled. ``` -# Example 7 -# Too many dependencies slow down compilation. +# Example 7: +# Unnecessary dependencies slow down compilation. template("too_much_deps") { ... _gen_resource_target = "${target_name}__res" action(_gen_resource_target) { ... } - + _compile_resource_target = "${target_name}__compile_res" action(_compile_resource_target) { deps = [":$_gen_resource_target"] ... } - + _compile_js_target = "${target_name}__js" action(_compile_js_target) { # This deps is not required. @@ -201,15 +201,15 @@ template("too_much_deps") { } ``` -Unclear input can result in the following: +Unclear input leads to the following problems: -- **Modified code is not compiled during the incremental compilation.** -- **After code changes, the cache being used is still hit.** +- Modified code is not compiled during incremental compilation. +- The cache being used is still hit after the code is changed. -In the following example, **foo.py** references functions in **bar.py**. This means that **bar.py** is the input of **foo.py** and must be added to the **input** or **depfile** of **implict_input_action**. Otherwise, if **bar.py** is modified, the **implict_input_action** module will not be recompiled. +In the following example, **foo.py** references the functions in **bar.py**. This means **bar.py** is the input of **foo.py**. You need to add **bar.py** to **input** or **depfile** of **implict_input_action**. Otherwise, if **bar.py** is modified, **implict_input_action** will not be recompiled. ``` -# Example 8 +# Example 8: action("implict_input_action") { script = "//path-to-foo.py" ... @@ -218,19 +218,19 @@ action("implict_input_action") { ``` #!/usr/bin/env -# Contents of foo.py +# Content of foo.py import bar ... bar.some_function() ... ``` -Unclear output can result in the following: +Unclear output leads to the following problems: -- **The output is implicit.** -- **When the cache is used, implicit output cannot be obtained from the cache.** +- Implicit output +- A failure to obtain the implicit output from the cache -In the following example, **foo.py** generates two files: **a.out** and **b.out**; the output of **implict_output_action** declares only **a.out**. In this case, **b.out** is an implicit output, and the cache stores **a.out** but not **b.out**. When the cache is hit, **b.out** cannot be compiled. +In the following example, **foo.py** generates two files: **a.out** and **b.out**. However, the output of **implict_output_action** declares only **a.out**. In this case, **b.out** is an implicit output, and the cache stores only **a.out**. When the cache is hit, **b.out** cannot be compiled. ``` # Example 9 @@ -252,43 +252,40 @@ write_file("a.out") ### Templates -**Do not use the GN native templates. Use the templates provided by the compilation system.** +**Do not use GN native templates. Use the templates provided by the build system.** -The GN native templates are **source_set**, **shared_library**, **static_library**, **action**, **executable**, and **group**. +The GN native templates include **source_set**, **shared_library**, **static_library**, **action**, **executable** and **group**. -These native templates are discouraged due to the following reasons: +The native templates are not recommended due to the following reasons: -- **The native templates only provide minimum functions**. They do not provide extra functions such as external_deps parsing, notice collection, and installation information generation. These extra functions are generated during module compilation. Therefore, the native templates must be extended. +- The native templates provide only the minimal build configuration. They cannot provide functions, such as parsing **external_deps**, collecting notice, and generating installation information. -- When the file on which the input file depends changes, the native template **action** cannot automatically detect the change and cannot be recompiled. See Example 8. - - - - Mapping between native templates and templates provided by the compilation system: - - | Template Provided by the Compilation System | Native Template | - | :------------------------------------------ | --------------- | - | ohos_shared_library | shared_library | - | ohos_source_set | source_set | - | ohos_executable | executable | - | ohos_static_library | static_library | - | action_with_pydeps | action | - | ohos_group | group | - +- The native **action** template cannot automatically detect the changes in the dependencies of the input file, and cannot start recompilation. See Example 8. + + The table below lists the mapping between the GN native templates and templates provided by the compilation system. + +| Template Provided by the Compilation System | GN Native Template | +|:------------------- | -------------- | +| ohos_shared_library | shared_library | +| ohos_source_set | source_set | +| ohos_executable | executable | +| ohos_static_library | static_library | +| action_with_pydeps | action | +| ohos_group | group | ### Using Python Scripts -Prioritize the Python script over the shell script in **action**. The Python script has the following advantages over the shell script: +You are advised to use Python scripts instead of shell scripts in **action**. Compared with shell scripts, Python scripts feature: -- More user-friendly syntax: It will not generate strange errors just because a space is missing. -- More readable. -- Higher maintainability and debugability. -- Faster compilation: thanks to Python task caching by OpenHarmony. +- More user-friendly syntax, which eliminates errors caused by lack of a space +- Easier to read +- Easier to maintain and debug +- Faster compilation due to caching of Python tasks ### rebase_path -- Call **rebase_path** only in the **args** list of **action**. - +- Call **rebase_path** only in **args** of **action**. + ``` # Example 10 template("foo") { @@ -309,15 +306,15 @@ Prioritize the Python script over the shell script in **action**. The Python scr } ``` -- If **rebase_path** is executed twice for the same variable, unexpected results may occur. - +- If rebase_path is called twice for the same variable, unexpected results occur. + ``` # Example 11 template("foo") { action(target_name) { ... args = [ - # rebase_path is executed twice for bar, and the passed bar value is incorrect. + # After rebase_path is called twice for bar, the bar value passed is incorrect. "--bar=" + rebase_path(invoker.bar, root_build_dir), ... ] @@ -334,14 +331,14 @@ Prioritize the Python script over the shell script in **action**. The Python scr ### Sharing Data Between Modules -Data sharing between modules is common. For example, a module may want to know the **outputs** and **deps** of another module. - -- Data sharing within the same **BUILD.gn** file - - Data in the same **BUILD.gn** file can be shared by defining global variables. - - In the following example, the output of module **a** is the input of module **b**. Module **a** shares data with module **b** by defining global variables. +It is common to share data between modules. For example, module A wants to know the output and **deps** of module B. +- Data sharing within the same **BUILD.gn** + + Data in the same **BUILD.gn** can be shared by defining global variables. + + In the following example, the output of module **a** is the input of module **b**, and can be shared with module **b** via global variables. + ``` # Example 12 _output_a = get_label_info(":a", "out_dir") + "/a.out" @@ -355,25 +352,25 @@ Data sharing between modules is common. For example, a module may want to know t } ``` -- Data sharing between different **BUILD.gn** files - - The best way to share data between different **BUILD.gn** files is to save the data as files and then transfer the files between modules. This scenario is complex. For details, see **write_meta_data** in the OpenHarmony HAP compilation process. +- Data sharing between different **BUILD.gn**s + + The best way to share data between different **BUILD.gn** is to save the data as files and transfer the files between modules. You can refer to **write_meta_data** in the OpenHarmony HAP build process. ### forward_variable_from -- To customize a template, you need to forward **testonly** first, since the target of the template may be depended on by that of **testonly**. - +- To customize a template, pass (**forward**) **testonly** first because the **testonly** target may depend on the template target. + ``` # Example 13 - # Forward testonly for a custom template. + # For a customized template, pass testonly first. template("foo") { forward_variable_from(invoker, ["testonly"]) ... } ``` -- Do not use asterisks (*) to forward variables. Required variables should be explicitly forwarded one by one. - +- Do not use asterisks (*) to **forward** variables. Required variables must be explicitly forwarded one by one. + ``` # Example 14 # Bad. The asterisk (*) is used to forward the variable. @@ -382,25 +379,25 @@ Data sharing between modules is common. For example, a module may want to know t ... } - # Good. Variables are explicitly forward one by one. + # Good. Variables are explicitly forwarded one by one. template("bar") { # forward_variable_from(invoker, [ - "testonly", - "deps", - ... - ]) + "testonly", + "deps", + ... + ]) ... } ``` ### target_name -The value of **target_name** varies according to the scope. +The value of **target_name** varies with the scope. ``` # Example 15 -# The value of target_name varies according to the scope. +# The value of target_name varies with the scope. template("foo") { # The displayed target_name is "${target_name}". print(target_name) @@ -426,7 +423,7 @@ To export header files from a module, use **public_configs**. ``` # Example 16 -# b depends on a and inherits the headers of a. +# b depends on a and inherits from the headers of a. config("headers") { include_dirs = ["//path-to-headers"] ... @@ -443,11 +440,11 @@ executable("b") { ### template -A custom template must contain a subtarget named *target_name*. This subtarget is used as the main target of the template. It should depend on other subtargets so that the subtargets can be compiled. +A custom template must contain a subtarget named **target_name**. This subtarget is used as the target of the template and depends on other subtargets. Otherwise, the subtargets will not be compiled. ``` # Example 17 -# A custom template must contain a subtarget named target_name. +# A custom template must have a subtarget named target_name. template("foo") { _code_gen_target = "${target_name}__gen" code_gen(_code_gen_target) { @@ -462,7 +459,7 @@ template("foo") { ... group(target_name) { deps = [ - # Since _compile_gen_target depends on _code_gen_target, the main target only needs to depend on _compile_gen_target. + # _compile_gen_target depends on _code_gen_target. Therefore, target_name only needs to depend on _compile_gen_target. ":$_compile_gen_target" ] } @@ -471,11 +468,11 @@ template("foo") { ### set_source_assignment_filter -In addition to filtering **sources**, **set_source_assignment_filter** can also be used to filter other variables. After the filtering is complete, clear the filter and **sources** list. +In addition to **sources**, **set_source_assignment_filter** can be used to filter other variables. After the filtering is complete, clear the filter and **sources**. ``` # Example 18 -# Use set_source_assignment_filter to filter dependencies and add the dependencies whose label matches *:*_res to the dependency list. +# Use set_source_assignment_filter to filter dependencies and add the dependencies with labels matching *:*_res to the dependency list. _deps = [] foreach(_possible_dep, invoker.deps) { set_source_assignment_filter(["*:*_res"]) @@ -492,18 +489,20 @@ set_source_assignment_filter([]) In the latest version, **set_source_assignment_filter** is replaced by **filter_include** and **filter_exclude**. -### Using **deps** for Intra-part Dependencies and **external_deps** for Cross-part Dependencies +### Using deps and external_deps + +- An OpenHarmony component is a group of modules that can provide a capability. -- In OpenHarmony, a part is a group of modules that can provide a certain capability. -- When defining a module, you can declare the **part_name** to signify the part to which the module belongs. +- When defining a module, you must specify **part_name** to indicate the component to which the module belongs. -- Each part declares its inner-kit for other parts to invoke. For details about the declaration of inner-kit, see **ohos.build** in the source code. -- Inter-part dependencies can only be inner-kit modules. +- You must also declare **inner-kit** of a component for other components to call. For details about the declaration of component **innerkit**, see **bundle.json** in the source code. -- If the values of **part_name** of modules **a** and **b** are the same, the two modules belong to the same part. In this case, the dependency between the modules can be declared using **deps**. +- **inner-kit** applies only to dependent modules in different components. -- If the values of **part_name** of modules **a** and **b** are different, the two modules belong to different parts. In this case, the dependency between the modules must be declared using **external_deps** in the format of *componentName:moduleName*. See Example 19. +- If modules **a** and **b** has the same **part_name**, modules **a** and **b** belong to the same component. In this case, declare the dependency between them using **deps**. +- If modules **a** and **b** have different **part_name**, modules **a** and **b** belong to different components. In this case, declare the dependency between them using **external_deps** in the Component name:Module name format. See Example 19. + ``` # Example 19 shared_library("a") { @@ -512,11 +511,3 @@ In the latest version, **set_source_assignment_filter** is replaced by **filter_ ... } ``` - - - - - - - - diff --git a/en/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md b/en/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md index 929b6e4d050e0ed0428c0a423e2beca86936f8de..f6f28d7352ad2bdc1226cf3b0228395d4d4e3c7d 100644 --- a/en/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md +++ b/en/device-dev/subsystems/subsys-build-gn-kconfig-visual-config-guide.md @@ -5,12 +5,12 @@ ### Kconfig Visual Configuration Kconfig visual configuration is implemented on [Kconfiglib](https://github.com/ulfalizer/Kconfiglib) and [Kconfig](https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html#introduction). It allows customized configuration of OpenHarmony subsystem components. -This function has the following advantages: +Kconfig visual configuration has the following advantages: - Intuitive display of software component options - High reliability (Linux kernel and Buildroot use Kconfig for visualized configuration) -### Key Concepts +### Basic Concepts - [Kconfig](https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html#introduction): a visual configuration file format for Linux. @@ -22,20 +22,20 @@ This function has the following advantages: - [Config format conversion](https://gitee.com/openharmony/build/blob/master/tools/component_tools/parse_kconf.py): converts the **config** file generated on the GUI to the standard format for compilation and build. -## Procedure +## Operation Guide 1. Obtain the source code. - For details, see [Obtaining Source Code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md). + For details, see [Obtaining Source Code](../get-code/sourcecode-acquire.md). 2. Set up the environment. - The Kconfiglib required for environment configuration has been embedded in the OpenHarmony hb tool. For details about how to install the hb tool, see [Install hb](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md#install-hb). + The Kconfiglib required for environment configuration has been embedded in the OpenHarmony hb tool. For details about how to install the hb tool, see [Installing hb](../quick-start/quickstart-lite-env-setup.md). 3. Open the Kconfig configuration interface. ```shell - #Go to the build repository directory. + # Go to the build repository directory. cd build/tools/component_tools menuconfig kconfig ``` @@ -68,7 +68,7 @@ This function has the following advantages: Example: - 1. Perform a global build. + 1. Perform a full build. ```shell cp productdefine/common/base/base_product.json productdefine/common/products/ohos-arm64.json @@ -91,23 +91,23 @@ This function has the following advantages: By default, the file **product.json** is generated in the current directory. You can also use `python3 parse_kconf.py --out="example/out.json"` to specify the file path. - For more operations, see `python3 parse_kconf.py -h`. + For more operations, run `python3 parse_kconf.py -h`. ​ ## FAQs -### The latest component information is missing from the menu. +### Latest Components Not Displayed in the Menu List -The component list [productdefine/common/base/base_product.json](https://gitee.com/openharmony/productdefine_common/blob/master/base/base_product.json) is updated with product updates and iterations. As a result, the Kconfig menu does not contain the latest components. +The component list [productdefine/common/base/base_product.json](https://gitee.com/openharmony/productdefine_common/blob/master/base/base_product.json) is updated with product updates and iterations. The Kconfig menu does not contain the latest components. -Solution: +**Solution** -- Update the [Kconfig file](https://gitee.com/openharmony/build/blob/master/tools/component_tools/kconfig). +Update the [Kconfig file](https://gitee.com/openharmony/build/blob/master/tools/component_tools/kconfig). - ```shell - cd build/tools/component_tools - python3 generate_kconfig.py - ``` +```shell +cd build/tools/component_tools +python3 generate_kconfig.py +``` - For more details, see `python3 generate_kconfig.py -h`. +You can run `python3 generate_kconfig.py -h` to view more options. diff --git a/en/device-dev/subsystems/subsys-build-mini-lite.md b/en/device-dev/subsystems/subsys-build-mini-lite.md index d8b4c946818710f2d669a26d91b940c08cd6a44e..fa47c3a94b36fdc69c207ae602c218574c9074c7 100644 --- a/en/device-dev/subsystems/subsys-build-mini-lite.md +++ b/en/device-dev/subsystems/subsys-build-mini-lite.md @@ -2,38 +2,33 @@ ## Overview -The Compilation and Building subsystem is a build framework that supports component-based OpenHarmony development using Generate Ninja \(GN\) and Ninja. You can use this subsystem to: +The Compilation and Building subsystem provides a build framework based on Generate Ninja (GN) and Ninja. This subsystem allows you to: -- Assemble components for a product and build the product. +- Assemble components into a product and build the product. -- Build chipset source code independently. -- Build a single component independently. +- Build chipset source code independently. -### Basic Concepts - -Learn the following concepts before you start compilation and building: - -- Subsystem - - A subsystem is a logical concept. It consists of one or more components. OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from bottom to top. System functions are developed by the level of system, subsystem, and component. In a multi-device deployment scenario, you can customize subsystems and components as required. - - -- Component - - A component is a reusable, configurable, and tailorable function unit. Each component has an independent directory, and multiple components can be developed concurrently and built and tested independently. - -- GN +- Build a single component independently. - Generate Ninja \(GN\) is used to generate Ninja files. - -- Ninja - - Ninja is a small high-speed build system. - -- hb - - hb is a command line tool for OpenHarmony to execute build commands. +### Basic Concepts +Learn the following basic concepts before you start: + +- Subsystem + + A subsystem, as a logical concept, consists of one or more components. OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from the bottom up. System functions are developed by levels, from system to subsystem and then to component. In a multi-device deployment scenario, you can customize subsystems and components as required. +- Component + + A component is a reusable, configurable, and tailorable function unit. Each component has an independent directory, and can be built and tested independently and developed concurrently. +- GN + + GN is short for Generate Ninja. It is used to build Ninja files. +- Ninja + + Ninja is a small high-speed building system. +- hb + + hb is an OpenHarmony command line tool used to execute build commands. ### Directory Structure @@ -42,8 +37,8 @@ build/lite ├── components # Component description file ├── figures # Figures in the readme file ├── hb # hb pip installation package -├── make_rootfs # Script used to create the file system image -├── config # Build configuration +├── make_rootfs # Script used to create a file system image +├── config # Build configurations │ ├── component # Component-related template definition │ ├── kernel # Kernel-related build configuration │ └── subsystem # Subsystem build configuration @@ -52,174 +47,197 @@ build/lite └── toolchain # Build toolchain configuration, which contains the compiler directories, build options, and linking options ``` -### Build Process +### **Build Process** The figure below shows the build process. -**Figure 1** Build process - + **Figure 1** Build process + +  + +1. Use **hb set** to set the OpenHarmony source code directory and the product to build. -1. Use **hb set** to set the OpenHarmony source code directory and the product to build. -2. Use **hb build** to build the product, development board, or component. The procedure is as follows: - - Read the **config.gni** file of the development board selected. The file contains the build toolchain, linking commands, and build options. - - Run the **gn gen** command to read the product configuration and generate the **out** directory and **ninja** files for the solution. - - Run **ninja -C out/board/product** to start the build. - - Package the build result, set the file attributes and permissions, and create a file system image. +2. Use **hb build** to build the product, development board, or component. + The procedure is as follows: + + (1) Read the **config.gni** file of the development board selected. The file contains the build toolchain, linking commands, and build options. + + (2) Run the **gn gen** command to read the product configuration and generate the **out** directory and **ninja** files for the solution. + + (3) Run **ninja -C out/board/product** to start the build. + + (4) Package the files built, set file attributes and permissions, and create a file system image. ## Configuration Rules -To ensure that the chipset and product solutions are pluggable and decoupled from OpenHarmony, the paths, directory trees, and configuration of components, chipset solutions, and product solutions must comply with the following rules: +You can build a component, a chipset solution, and a product solution. To ensure that the chipset and product solutions are decoupled from OpenHarmony, follow the rules below: ### Component -The source code directory for a component is named in the _\{Domain\}/\{Subsystem\}/\{Component\}_ format. The component directory tree is as follows: +The component source code directory is named in the *{Domain}/{Subsystem}/{Component}* format. The component directory structure is as follows: -> **CAUTION**<br/> ->Define component attributes, such as the name, source code directory, function description, mandatory or not, build targets, RAM, ROM, build outputs, adapted kernels, configurable features, and dependencies, in the JSON file of the subsystem in the **build/lite/components** directory. When adding a component, add its definition to the JSON file of the corresponding subsystem. The component configured for a product must have been defined in a subsystem. Otherwise, the verification will fail. +>  **CAUTION**<br/> +> The .json file of the subsystem in the **build/lite/components** directory contains component attributes, including the name, source code directory, function description, mandatory or not, build targets, RAM, ROM, build outputs, adapted kernels, configurable features, and dependencies of the component. When adding a component, add the component information in the .json file of the corresponding subsystem. The component configured for a product must have been defined in a subsystem. Otherwise, the verification will fail. ``` component ├── interfaces │ ├── innerkits # APIs exposed internally among components -│ └── kits # App APIs provided for app developers +│ └── kits # APIs provided for application developers ├── frameworks # Framework implementation ├── services # Service implementation -└── BUILD.gn # Build script +├── BUILD.gn # Build script ``` -The following example shows how to define attributes of the sensor component of the pan-sensor subsystem: + The following example shows how to configure attributes of the sensor service component of the pan-sensor subsystem: + + ``` + { + "name": "@ohos/sensor_lite", # OpenHarmony Package Manager (HPM) component name, in the "@Organization/Component name" format. + "description": "Sensor services", # Description of the component functions. + "version": "3.1", # Version, which must be the same as the version of OpenHarmony. + "license": "MIT", # Component license. + "publishAs": "code-segment", # Mode for publishing the HPM package. The default value is code-segment. + "segment": { + "destPath": "" + }, # Code restoration path (source code path) set when "publishAs" is code-segment. + "dirs": {"base/sensors/sensor_lite"}, # Directory structure of the HPM package. This field is mandatory and can be left empty. + "scripts": {}, # Scripts to be executed. This field is mandatory and can be left empty. + "licensePath": "COPYING", + "readmePath": { + "en": "README.rst" + }, + "component": { # Component attributes. + "name": "sensor_lite", # Component name. + "subsystem": "", # Subsystem to which the component belongs. + "syscap": [], # System capabilities provided by the component for applications. + "features": [], # List of external configurable features of a component. Generally, this parameter corresponds to sub_component in build and can be configured by the product. + "adapted_system_type": [], # Types of adapted systems. The value can be mini, small, and standard. + "rom": "92KB", # Component ROM size. + "ram": "~200KB",, # Component RAM size. + "deps": { + "components": [ # Other components on which this component depends. + "samgr_lite" + ], + "third_party": [ # Third-party open-source software on which this component depends. + "bounds_checking_function" + ] + } + "build": { # Build-related configuration. + "sub_component": [ + ""//base/sensors/sensor_lite/services:sensor_service"", # Component build entry + ], # Component build entry. Configure modules here. + "inner_kits": [], # APIs between components. + "test": [] # Entry for building the component's test cases. + } + } + } + ``` + + Observe the following rules when writing the component's **BUILD.gn**: + +- The build target name must be the same as the component name. + +- Define the configurable features in the **BUILD.gn** file of the component. Name the configurable features in the ohos_{subsystem}*{component}*{feature} format. Define the features in component description and configure them in the **config.json** file. + +- Define macros in the OHOS_{SUBSYSTEM}*{COMPONENT}*{FEATURE} format. + + >  **NOTE**<br> + > The component build script is written in GN. For details about how to use GN, see [GN Quick Start Guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md). The component is the build target, which can be a static library, a dynamic library, an executable file, or a group. + + The following example shows the **foundation/graphic/ui/BUILD.gn** file for a graphics UI component: + + ``` + # Declare the configurable features of the component. + declare_args() { + enable_ohos_graphic_ui_animator = false # Whether to enable animation. + ohos_ohos_graphic_ui_font = "vector" # Configurable font type, which can be vector or bitmap. + } -``` -{ - "components": [ - { - "component": "sensor_lite", # Component name - "description": "Sensor services", # Brief description of the component - "optional": "true", # Whether the component is mandatory for the system - "dirs": [ # Source code directory of the component - "base/sensors/sensor_lite" - ], - "targets": [ # Build entry of the component - "//base/sensors/sensor_lite/services:sensor_service" - ], - "rom": "92KB", # Component ROM - "ram": "~200KB", # Component RAM (estimated) - "output": [ "libsensor_frameworks.so" ], # Component build outputs - "adapted_kernel": [ "liteos_a" ], # Adapted kernel for the component - "features": [], # Configurable features of the component - "deps": { - "components": [ # Other components on which the component depends - "samgr_lite" - ], - "third_party": [ # Open-source third-party software on which the component depends - "bounds_checking_function" + # Basic component functions. + shared_library("base") { + sources = [ + ... + ] + include_dirs = [ + ... + ] + } + + # Build only when the animator is enabled. + if(enable_ohos_graphic_ui_animator ) { + shared_library("animator") { + sources = [ + ... ] + include_dirs = [ + ... + ] + deps = [ :base ] } } - ] -} -``` + ... + # It is recommended that the target name be the same as the name of the component, which can be an executable file (.bin), shared_library (.so file), static_library (.a file), or a group. + executable("ui") { + deps = [ + ":base" + ] -Observe the following rules when configuring **BUILD.gn**: + # The animator feature is configured by the product. + if(enable_ohos_graphic_ui_animator ) { + deps += [ + "animator" + ] + } + } + ``` -- The build target name must be the same as the component name. -- Define the configurable features in the **BUILD.gn** file of the component. Name the configurable features in the **ohos\_**\{_subsystem_\}**\_**\{_component_\}**\_**\{_feature_\} format. Define the features in component description and configure them in the **config.json** file. -- Define macros in the **OHOS\_**\{_SUBSYSTEM_\}**\_**\{_COMPONENT_\}**\_**\{_FEATURE_\} format. +### Chipset Solution - > **NOTE**<br/> GN is used as the build script language for components. For details about how to use GN, see [GN Quick Start Guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md). In GN, a component is a target to build, which can be a static library, a dynamic library, an executable file, or a group. +- The chipset solution is a special component. It is built based on a development board, including the drivers, device API adaptation, and SDK. +- The source code path is named in the **device/{Development board}/{Chipset solution vendor}** format. -The following example shows how to build the **foundation/graphic/ui/BUILD.gn** file for a graphics UI component: +- The chipset solution component is built by default based on the development board selected. + +- The chipset solution directory structure is as follows: -``` - # Declare the configurable features of the component - declare_args() { - enable_ohos_graphic_ui_animator = false # Animation switch - ohos_ohos_graphic_ui_font = "vector" # Configurable font type, which can be vector or bitmap - } - - # Basic component functions - shared_library("base") { - sources = [ - ...... - ] - include_dirs = [ - ...... - ] - } - - # Build only when the animator is enabled - if(enable_ohos_graphic_ui_animator ) { - shared_library("animator") { - sources = [ - ...... - ] - include_dirs = [ - ...... - ] - deps = [ :base ] - } - } - ...... - # It is recommended that the target name be the same as the component name, which can be an executable .bin file, shared_library (.so file), static_library (.a file), or a group. - executable("ui") { - deps = [ - ":base" - ] - - # The animator feature is configured by the product. - if(enable_ohos_graphic_ui_animator ) { - deps += [ - "animator" - ] - } - } -``` + ``` + device + └── board # Chipset solution vendor + └── company # Development board name + ├── BUILD.gn # Build script + ├── hals # OS device API adaptation + ├── linux # (Optional) Linux kernel version + │ └── config.gni # Linux build configuration + └── liteos_a # (Optional) LiteOS kernel version + └── config.gni # LiteOS_A build configuration + ``` -### Chipset + >  **NOTE**<br> + > The **config.gni** file contains build-related configuration of the development board. The parameters in the file are used to build all OS components, and are globally visible to the system during the build process. -- The chipset solution is a complete solution based on a development board. The solution includes the drivers, API adaptation, and SDK. -- The chipset solution is a special component, whose source code directory is named in the _**device**/\{Chipset solution vendor\}/\{Development board\}_ format. -- The chipset component is built by default based on the development board selected by the product. +- The **config.gni** file contains the following key parameters: -The chipset solution directory tree is as follows: + ``` + kernel_type: Kernel used by the development board, for example, LiteOS_A, LiteOS_M, or Linux. + kernel_version: Kernel version of the development board, for example, 4.19. + board_cpu: CPU of the development board, for example, Cortex-A7 or RISCV32. + board_arch: Chipset architecture of the development board, for example, ARMv7-A or RV32IMAC. + board_toolchain: Name of the customized build toolchain used by the development board, for example, gcc-arm-none-eabi. If this field is not specified, ohos-clang will be used by default. + board_toolchain_prefix: Prefix of the toolchain, for example, gcc-arm-none-eabi. + board_toolchain_type: Toolchain type. Currently, only GCC and clang are supported. + board_cflags: Build options of the .c file configured for the development board. + board_cxx_flags: Build options of the .cpp file configured for the development board. + board_ld_flags: Linking options configured for the development board. + ``` -``` -device -└── company # Chipset solution vendor - └── board # Name of the development board - ├── BUILD.gn # Build script - ├── hals # Southbound APIs for OS adaptation - ├── linux # Linux kernel version (optional) - │ └── config.gni # Build options for the Linux version - └── liteos_a # LiteOS kernel version (optional) - └── config.gni # Build options for the LiteOS Cortex-A version -``` +### Product Solution -> **NOTE** <br/> ->The **config.gni** file contains build-related configurations of the development board. The parameters in the file are globally visible to the system and can be used to build all OS components during the build process. +The product solution is a special component. It is a product built based on a development board. It includes the OS adaptation, component assembly and configuration, startup configuration, and file system configuration. The source code directory is named in the **vendor**/{*Product solution vendor*}/{*Product name*} format. -The **config.gni** file contains the following key parameters: - -``` -kernel_type: kernel used by the development board, for example, liteos_a, liteos_m, or linux. -kernel_version: kernel version used by the development board, for example, 4.19. -board_cpu: CPU of the development board, for example, cortex-a7 or riscv32. -board_arch: chipset architecture of the development board, for example, armv7-a or rv32imac. -board_toolchain: name of the customized build toolchain used by the development board, for example, gcc-arm-none-eabi. If this field is not specified, ohos-clang will be used by default. -board_toolchain_prefix: prefix of the build toolchain, for example, gcc-arm-none-eabi. -board_toolchain_type: build toolchain type, for example, gcc or clang. Currently, only GCC and clang are supported. -board_cflags: build options of the .c file configured for the development board. -board_cxx_flags: build options of the .cpp file configured for the development board. -board_ld_flags: link options configured for the development board. -``` - -### Product - -The product solution is a complete product based on a development board. It includes the OS adaptation, component assembly configuration, startup configuration, and file system configuration. The source code directory of a product solution is named in the **vendor**/\{_Product solution vendor_\}/\{_Product name_\} format. A product solution is also a special component. - -The product solution directory tree is as follows: +The product solution directory structure is as follows: ``` vendor @@ -232,170 +250,164 @@ vendor │ ├── BUILD.gn # Product build script │ └── config.json # Product configuration file │ └── fs.yml # File system packaging configuration - └── ...... + └── ... ``` -> **CAUTION**<br/> ->Create directories and files based on the preceding rules for new products. The Compilation and Building subsystem scans the configured products based on the rules. +>  **CAUTION**<br/> +> Follow the preceding rules to create directories and files for new products. The Compilation and Building subsystem scans the configured products based on the rules. The key directories and files are described as follows: -- **vendor/company/product/init\_configs/etc** +1. **vendor/company/product/init_configs/etc** + + This folder contains the rcS, Sxxx, and fstab scripts. The init process runs the rcS, fstab, and S00-xxx scripts in sequence before starting system services. The **S***xxx* script is used to create device nodes and directories, scan device nodes, and change file permissions for the development board and product. These scripts are copied from the **BUILD.gn** file to the **out** directory of the product as required and packaged into the **rootfs** image. + +2. **vendor/company/product/init_configs/init.cfg** + + This file is the configuration file for the **init** process to start services. Currently, the following commands are supported: + + - **start**: starts a service. + + - **mkdir**: creates a folder. + + - **chmod**: changes the permission on a specified directory or file. + + - **chown**: changes the owner group of a specified directory or file. + + - **mount**: mounts a device. + + The fields in the file are described as follows: + + ``` + { + "jobs" : [{ # Job array. A job corresponds to a command set. Jobs are executed in the following sequence: pre-init > init > post-init. + "name" : "pre-init", + "cmds" : [ + "mkdir /storage/data", # Create a directory. + "chmod 0755 /storage/data", #Modify the permissions. The format of the permission value is 0xxx, for example, 0755. + "mkdir /storage/data/log", + "chmod 0755 /storage/data/log", + "chown 4 4 /storage/data/log", # Change the owner group. The first number is the user ID (UID), and the second number is the group ID (GID). + ... + "mount vfat /dev/mmcblock0 /sdcard rw,umask=000" # The command format is mount [File system type] [source] [target] [flags] [data]. + # The value of flags can be nodev, noexec, nosuid, or rdonly only. + ] + }, { + "name" : "init", + "cmds" : [ # Start services based on the sequence of the cmds array. + "start shell", # There is only one space between start and the service name. + ... + "start service1" + ] + }, { + "name" : "post-init", # Job that is finally executed. Operations performed after the init process is started, for example, mounting a device after the driver initialization). + "cmds" : [] + } + ], + "services" : [{ # Service array. A service corresponds to a process. + "name" : "shell", # Service name. + "path" : ["/sbin/getty", "-n", "-l", "/bin/sh", "-L", "115200", "ttyS000", "vt100"], # Full path of the executable file. It must start with "path". + "uid" : 0, # Process UID, which must be the same as that in the binary file. + "gid" : 0, # Process GID, which must be the same as that in the binary file. + "once" : 0, # Whether the process is a one-off process. The value 1 indicates that process is a one-off process, and the value 0 indicates the opposite. The init process does not restart the one-off process after the process exits. + "importance" : 0, # Whether the process is a key process. The value 1 indicates a key process, and the value 0 indicates the opposite. If a key process exits, the init process will restart the board. + "caps" : [4294967295] + }, + ... + ] + } + ``` - This folder contains the **rcS**, **S**_xxx_, and **fstab** scripts. The **init** process runs the **rcS**, **fstab**, and **S**_00_-_xxx_ scripts in sequence before starting system services. The **S**_xxx_ script contains content related to the development board and product. It is used to create device nodes and directories, scan device nodes, and change file permissions. These scripts are copied from the **BUILD.gn** file to the **out** directory of the product as required and packaged into the **rootfs** image. +3. **vendor/company/product/init_configs/hals** -- **vendor/company/product/init\_configs/init.cfg** + This file contains the OS adaptation of the product. For details about APIs for implementing OS adaptation, see the readme file of each component. - This file is the configuration file for the **init** process to start services. Currently, the following commands are supported: +4. **vendor/company/product/config.json** - - **start**: starts a service. - - **mkdir**: creates a folder. - - **chmod**: changes the permission on a specified directory or file. - - **chown**: changes the owner group of a specified directory or file. - - **mount**: mounts a device. + The **config.json** file is the main entry for the build and contains configurations of the development board, OS, and kernel. - The fields in the file are described as follows: + The following example shows the **config.json** file of the IP camera developed based on the hispark_taurus board: -``` -{ - "jobs" : [{ # Job array. A job corresponds to a command set. Jobs are executed in the following sequence: pre-init > init > post-init. - "name" : "pre-init", - "cmds" : [ - "mkdir /storage/data", # Create a directory. - "chmod 0755 /storage/data", # Change the permission, which is in 0xxx format, for example, 0755. - "mkdir /storage/data/log", - "chmod 0755 /storage/data/log", - "chown 4 4 /storage/data/log", # Change the owner group. The first number indicates the UID, and the second indicates the GID. - ...... - "mount vfat /dev/mmcblock0 /sdcard rw, umask=000" # The command is in the mount [File system type][source] [target] [flags] [data] format. - # Currently, flags can only be nodev, noexec, nosuid, or rdonly. - ] - }, { - "name" : "init", - "cmds" : [ # Start services based on the sequence of the cmds array. - "start shell", # Note that there is only one space between start and the service name. - ...... - "start service1" + ``` + { + "product_name": "ipcamera", # Product name + "version": "3.0", # Version of config.json. The value is 3.0. + "type": "small", # System type. The value can be mini, small, or standard. + "ohos_version": "OpenHarmony 1.0", # OS version + "device_company": "hisilicon", # Chipset vendor + "board": "hispark_taurus", # Name of the development board + "kernel_type": "liteos_a", # Kernel type + "kernel_version": "3.0.0", # Kernel version + "subsystems": [ + { + "subsystem": "aafwk", # Subsystem + "components": [ + { "component": "ability", "features":[ "enable_ohos_appexecfwk_feature_ability = true" ] } # Selected component and feature configuration ] - }, { - "name" : "post-init", # Job that is finally executed. Operations performed after the init process is started, for example, mounting a device after the driver initialization. - "cmds" : [] + }, + { + ... + } + ... + More subsystems and components } - ], - "services" : [{ # Service array. A service corresponds to a process. - "name" : "shell", # Service name - "path" : ["/sbin/getty", "-n", "-l", "/bin/sh", "-L", "115200", "ttyS000", "vt100"], # Full path of the executable file. It must start with "path". - "uid" : 0, # Process UID, which must be the same as that in the binary file. - "gid" : 0, # Process GID, which must be the same as that in the binary file. - "once" : 0, # Whether the process is a one-off process. 1: The proces is a one-off process. The init process does not restart it after the process exits. 0: The process is not a one-off process. The init process restarts it if the process exits. - "importance" : 0, # Whether the process is a key process. 1: The process is a key process. If it exits, the init process restarts the board. 0: The process is not a key process. If it exits, the init process does not restart the board. - "caps" : [4294967295] - }, - ...... - ] -} -``` - -- **vendor/company/product/init\_configs/hals** - - This file stores the content related to OS adaptation of the product. For details about APIs for implementing OS adaptation, see the readme file of each component. - -- **vendor/company/product/config.json** - - The **config.json** file is the main entry for the build and contains configurations of the development board, OS components, and kernel. - - The following example shows the **config.json** file of the IP camera developed based on the hispark\_taurus development board: - -``` -{ - "product_name": "ipcamera", # Product name - "version": "3.0", # config.json version, which is 3.0 - "type": "small", # System type, which can be mini, small, or standard - "ohos_version": "OpenHarmony 1.0", # OS version - "device_company": "hisilicon", # Chipset vendor - "board": "hispark_taurus", # Name of the development board - "kernel_type": "liteos_a", # Kernel type - "kernel_version": "3.0.0", # Kernel version - "subsystems": [ - { - "subsystem": "aafwk", # Subsystem - "components": [ - { "component": "ability", "features":[ "enable_ohos_appexecfwk_feature_ability = true" ] } # Component and its features - ] - }, - { - ...... - } - ...... - More subsystems and components - } -} -``` - -- **vendor/company/product/fs.yml** - - This file packages the build result to create a configuration file system image, for example, **rootfs.img** \(user-space root file system\) and **userfs.img** \(readable and writable file\). It consists of multiple lists, and each list corresponds to a file system. The fields are described as follows: - -``` -fs_dir_name: (Mandatory) declares the name of the file system, for example, rootfs or userfs. -fs_dirs: (Optional) configures the mapping between the file directory in the out directory and the system file directory. Each file directory corresponds to a list. -source_dir: (Optional) specifies the target file directory in the out directory. If this field is missing, an empty directory will be created in the file system based on target_dir. -target_dir: (Mandatory) specifies the corresponding file directory in the file system. -ignore_files: (Optional) declares ignored files during the copy operation. -dir_mode: (Optional) specifies the file directory permission, which is set to 755 by default. -file_mode: (Optional) declares permissions of all files in the directory, which is set to 555 by default. -fs_filemode: (Optional) configures files that require special permissions. Each file corresponds to a list. -file_dir: (Mandatory) specifies the detailed file path in the file system. -file_mode: (Mandatory) declares file permissions. -fs_symlink: (Optional) configures the soft link of the file system. -fs_make_cmd: (Mandatory) creates the file system script. The script provided by the OS is stored in the build/lite/make_rootfs directory. Linux, LiteOS, ext4, jffs2, and vfat are supported. Chipset vendors can also customize the script as required. -fs_attr: (Optional) dynamically adjusts the file system based on configuration items. -``` - -The **fs\_symlink** and **fs\_make\_cmd** fields support the following variables: - -- $\{root\_path\} - - Code root directory, which corresponds to **$\{ohos\_root\_path\}** of GN - -- $\{out\_path\} - - **out** directory of the product, which corresponds to **$\{root\_out\_dir\}** of GN - -- $\{fs\_dir\} - - File system directory, which consists of the following variables - - - $\{root\_path\} - - $\{fs\_dir\_name\} - -> **NOTE**<br/> ->**fs.yml** is optional and does not need to be configured for devices without a file system. - -- **vendor/company/product/BUILD.gn** - - This file is the entry for building the source code of the solution vendor and copying the startup configuration file. The **BUILD.gn** file in the corresponding product directory will be built by default if a product is selected. The following example shows how to build the **BUILD.gn** file of a product: - -``` -group("product") { # The target name must be the same as the product name (level-3 directory name under the product directory). - deps = [] - # Copy the init configuration. - deps += [ "init_configs" ] - # Others - ...... -} -``` - - -## Usage Guidelines + } + ``` + +5. **vendor/company/product/fs.yml** + + This file defines the process for creating a file system image, for example, **rootfs.img** (user-space root file system) and **userfs.img** (readable and writable file). It consists of multiple lists, and each list corresponds to a file system. The fields are described as follows: + + ``` + fs_dir_name: (Mandatory) specifies name of the file system, for example, rootfs or userfs. + fs_dirs: (Optional) specifies the mapping between the file directory in the out directory and the system file directory. Each file directory corresponds to a list. + source_dir: (Optional) specifies target file directory in the out directory. If this field is not specified, an empty directory will be created in the file system based on target_dir. + target_dir: (Mandatory) specifies the file directory in the file system. + ignore_files: (Optional) declares ignored files during the copy operation. + dir_mode: (Optional) specifies the file directory permissions. The default value is 755. + file_mode: (Optional) specifies the permissions of all files in the directory. The default value is 555. + fs_filemode: (Optional) specifies the files that require special permissions. Each file corresponds to a list. + file_dir: (Mandatory) specifies the detailed file path in the file system. + file_mode: (Mandatory) declares file permissions. + fs_symlink: (Optional) specifies the soft link of the file system. + fs_make_cmd: (Mandatory) creates the file system script. The script provided by the OS is located in the build/lite/make_rootfs directory. Linux, LiteOS, ext4, jffs2, and vfat are supported. Chipset vendors can also customize the script as required. + fs_attr: (Optional) dynamically adjusts the file system based on configuration items. + ``` + + The **fs_symlink** and **fs_make_cmd** fields support the following variables: + + - **${root_path}**: Code root directory, which corresponds to **${ohos_root_path}** of GN. + - **${out_path}**: The **out** directory of the product, which corresponds to **${root_out_dir}** of GN. + - **${fs_dir}**: File system directory, which consists of variables **${root_path}** and **${fs_dir_name}**. + + >  **NOTE**<br> + > **fs.yml** is optional and not required for devices without a file system. + +6. **vendor/company/product/BUILD.gn** + + This file provides the product built entry. It is used to build the source code of the solution vendor and copy the startup configuration file. The **BUILD.gn** file in the corresponding product directory will be built by default if a product is selected. + + The following is an example of the **BUILD.gn** file of a product: + + ``` + group("product") { # The name must be the same as the product name (level-3 directory name under the product directory). + deps = [] + # Copy the init configuration. + deps += [ "init_configs" ] + # Others + ... + } + ``` + +## Guidelines ### Prerequisites -The development environment has GN, Ninja, Python 3.7.4 or later, and hb available. For details about installation methods, see [Environment Setup](../quick-start/quickstart-lite-env-setup.md). +The development environment has GN, Ninja, Python 3.9.2 or later, and hb available. For details about the installation method, see [Setting Up Environments for the Mini and Small Systems](../quick-start/quickstart-lite-env-setup.md). ### Using hb -**hb** is a command line tool for OpenHarmony to execute build commands. Common hb commands are described as follows: +**hb** is an OpenHarmony command line tool for executing build commands. Common hb commands are described as follows: **hb set** @@ -410,13 +422,15 @@ optional arguments: -p, --product Set OHOS board and kernel ``` -- **hb set** \(without argument\): starts the default setting process. -- **hb set -root** _dir_: sets the root directory of the code. -- **hb set -p**: sets the product to build. +- If you run **hb set** with no argument, the default setting process starts. + +- You can run **hb set -root** *dir* to set the root directory of the source code. + +- You can run **hb set -p** to set the product to build. **hb env** -Displays the current configuration. +Displays the current settings. ``` hb env @@ -432,53 +446,62 @@ hb env ``` hb build -h -usage: hb build [-h] [-b BUILD_TYPE] [-c COMPILER] [-t [TEST [TEST ...]]] - [--dmverity] [--tee] [-p PRODUCT] [-f] [-n] - [-T [TARGET [TARGET ...]]] [-v] [-shs] [--patch] +usage: hb build [-h] [-b BUILD_TYPE] [-c COMPILER] [-t [TEST [TEST ...]]] [-cpu TARGET_CPU] [--dmverity] [--tee] + [-p PRODUCT] [-f] [-n] [-T [TARGET [TARGET ...]]] [-v] [-shs] [--patch] [--compact-mode] + [--gn-args GN_ARGS] [--keep-ninja-going] [--build-only-gn] [--log-level LOG_LEVEL] [--fast-rebuild] + [--device-type DEVICE_TYPE] [--build-variant BUILD_VARIANT] [component [component ...]] positional arguments: - component name of the component + component name of the component, mini/small only optional arguments: -h, --help show this help message and exit -b BUILD_TYPE, --build_type BUILD_TYPE - release or debug version + release or debug version, mini/small only -c COMPILER, --compiler COMPILER - specify compiler + specify compiler, mini/small only -t [TEST [TEST ...]], --test [TEST [TEST ...]] compile test suit - --dmverity Enable dmverity + -cpu TARGET_CPU, --target-cpu TARGET_CPU + select cpu + --dmverity enable dmverity --tee Enable tee -p PRODUCT, --product PRODUCT - build a specified product with - {product_name}@{company}, eg: camera@huawei + build a specified product with {product_name}@{company} -f, --full full code compilation -n, --ndk compile ndk -T [TARGET [TARGET ...]], --target [TARGET [TARGET ...]] - Compile single target + compile single target -v, --verbose show all command lines while building -shs, --sign_haps_by_server sign haps by server --patch apply product patch before compiling - - --dmverity Enable dmverity - -p PRODUCT, --product PRODUCT - build a specified product with - {product_name}@{company}, eg: ipcamera@hisilcon - -f, --full full code compilation - -T [TARGET [TARGET ...]], --target [TARGET [TARGET ...]] - Compile single target + --compact-mode compatible with standard build system set to false if we use build.sh as build entrance + --gn-args GN_ARGS specifies gn build arguments, eg: --gn-args="foo="bar" enable=true blah=7" + --keep-ninja-going keeps ninja going until 1000000 jobs fail + --build-only-gn only do gn parse, donot run ninja + --log-level LOG_LEVEL + specifies the log level during compilationyou can select three levels: debug, info and error + --fast-rebuild it will skip prepare, preloader, gn_gen steps so we can enable it only when there is no change + for gn related script + --device-type DEVICE_TYPE + specifies device type + --build-variant BUILD_VARIANT + specifies device operating mode ``` -- **hb build** \(without argument\): builds the code based on the configured code directory, product, and options. The **-f** option deletes all products to be built, which is equivalent to running **hb clean** and **hb build**. -- **hb build** _\{component\_name\}_: builds a product component separately based on the development board and kernel set for the product, for example, **hb build kv\_store**. -- **hb build -p ipcamera@hisilicon**: skips the **set** step and builds the product directly. -- You can run **hb build** in **device/device\_company/board** to select the kernel and start the build based on the current development board and the selected kernel to generate an image that contains the kernel and driver only. +- If you run **hb build** with no argument, the previously configured code directory, product, and options are used for the build. The **-f** option deletes all products to be built. It is equivalent to running **hb clean** and **hb build**. + +- You can run **hb build** *{component_name}* to build product components separately based on the development board and kernel set for the product, for example, **hb build kv_store**. + +- You can run **hb build -p ipcamera@hisilicon** to skip the setting step and build the product directly. + +- You can run **hb build** in **device/board/device_company** to select the kernel and build an image that contains the kernel and drivers only based on the current development board and the selected kernel. **hb clean** -You can run **hb clean** to clear the build result of the product in the **out** directory and retain the **args.gn** and **build.log** files only. To clear files in a specified directory, add the directory parameter to the command, for example, **hb clean out/xxx/xxx**. +You can run **hb clean** to delete all the files except **args.gn** and **build.log** in the **out** directory. To clear files in a specified directory, add the directory parameter to the command, for example, **hb clean out/board/product**. By default, the files in the **out** directory are cleared. ``` hb clean @@ -495,477 +518,462 @@ optional arguments: To add a component, determine the subsystem to which the component belongs and the component name, and then perform the following steps: -1. Add the component build script after the source code development is complete. - - The following example adds the **BUILD.gn** script \(stored in the **applications/sample/hello\_world** directory\) to build the **hello\_world** component \(as an executable file\). +1. Add the component build script after the source code development is complete. + + The following example shows the **BUILD.gn** script (in the **applications/sample/hello_world** directory) for the **hello_world** executable file. - ``` - executable("hello_world") { - include_dirs = [ - "include", - ] - sources = [ - "src/hello_world.c" + ``` + executable("hello_world") { + include_dirs = [ + "include", ] - } - ``` - - The above script is used to build **hello\_world** that can run on OpenHarmony. - - To build the preceding component separately, select a product via the **hb set** command and run the **-T** command. - - ``` - hb build -f -T //applications/sample/hello_world - ``` - - After the component functions are verified on the development board, perform steps 2 to 4 to configure the component to the product. - -2. Add component description. - - The component description is stored in the **build/lite/components** directory. New components must be added to the JSON file of the corresponding subsystem. The component description must contain the following fields: - - - **component**: name of the component - - **description**: brief description of the component - - **optional**: whether the component is optional - - **dirs**: source code directory of the component - - **targets**: component build entry - - For example, to add the **hello\_world** component to the application subsystem, add the **hello\_world** object to the **applications.json** file. - - ``` - { - "components": [ - { - "component": "hello_world", - "description": "Hello world.", - "optional": "true", - "dirs": [ - "applications/sample/hello_world" - ], - "targets": [ - "//applications/sample/hello_world" - ] - }, - ... + sources = [ + "src/hello_world.c" + ] + } + ``` + + This script can be used to build a file named **hello_world** that can run on OpenHarmony. + + To build the preceding component separately, run **hb set** to select a product and run the following command to build **hello_world** separately. + + ``` + hb build -f -T //applications/sample/hello_world + ``` + + After the component functions are verified on the development board, perform steps 2 to 4 to add the component to the product. + +2. Add the component description. + + The component description is stored in the **build/lite/components** directory. Add the new component to the .json file of the corresponding subsystem. The component description must contain the following fields: + + - **component**: component name. + - **description**: description of the component functions. + - **optional**: whether the component is optional. + - **dirs**: source code directory of the component. + - **targets**: component build entry. + + The following is an example of adding the **hello_world** component to the **applications.json** file. + + ``` + { + "components": [ + { + "component": "hello_world", + "description": "Hello world.", + "optional": "true", + "dirs": [ + "applications/sample/hello_world" + ], + "targets": [ + "//applications/sample/hello_world" + ] + }, + ... + ] + } + ``` + +3. Add the component to the product. + + The product configuration file **config.json** is located in the **vendor/company/product/** directory. This file contains the product name, OpenHarmony version, device vendor, development board, kernel type, kernel version, subsystems, and components. The following example adds **hello_world** to the **my_product.json** file: + + ``` + { + "product_name": "hello_world_test", + "ohos_version": "OpenHarmony 1.0", + "device_company": "hisilicon", + "board": "hispark_taurus", + "kernel_type": "liteos_a", + "kernel_version": "1.0.0", + "subsystems": [ + { + "subsystem": "applications", + "components": [ + { "component": "hello_world", "features":[] } + ] + }, + ... ] - } - ``` - -3. Configure the component for the product. - - The **config.json** file is stored in the **vendor/company/product/** directory. The file must contain the product name, OpenHarmony version, device vendor, development board, kernel type, kernel version, and the subsystem and component to configure. The following example adds the **hello\_world** component to the **my\_product.json** configuration file: - - ``` - { - "product_name": "hello_world_test", - "ohos_version": "OpenHarmony 1.0", - "device_company": "hisilicon", - "board": "hispark_taurus", - "kernel_type": "liteos_a", - "kernel_version": "1.0.0", - "subsystems": [ - { - "subsystem": "applications", - "components": [ - { "component": "hello_world", "features":[] } - ] - }, - ... - ] - } - ``` - -4. Build the product. - - 1. Run the **hb set** command in the root code directory and select the product. - - 2. Run the **hb build** command. + } + ``` +4. Build the product. + + 1. Run the **hb set** command in the root code directory and select the product. + + 2. Run the **hb build** command. ### Adding a Chipset Solution The following uses the RTL8720 development board provided by Realtek as an example. To a chipset solution, perform the following steps: -1. Create a directory for the chipset solution. - - To create a directory based on [Configuration Rules](#configuration-rules), run the following command in the root code directory: - - ``` - mkdir -p device/realtek/rtl8720 - ``` - -2. Create a directory for kernel adaptation and build the **config.gni** file of the development board. - - For example, to adapt the LiteOS-A kernel to the RTL8720 development board, configure the **device/realtek/rtl8720/liteos\_a/config.gni** file as follows: - - ``` - # Kernel type, e.g. "linux", "liteos_a", "liteos_m". - kernel_type = "liteos_a" - - # Kernel version. - kernel_version = "3.0.0" - - # Board CPU type, e.g. "cortex-a7", "riscv32". - board_cpu = "real-m300" - - # Board arch, e.g. "armv7-a", "rv32imac". - board_arch = "" - - # Toolchain name used for system compiling. - # E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf. - # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. - board_toolchain = "gcc-arm-none-eabi" - - # The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc. - board_toolchain_path = - rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin", - root_build_dir) - - # Compiler prefix. - board_toolchain_prefix = "gcc-arm-none-eabi-" - - # Compiler type, "gcc" or "clang". - board_toolchain_type = "gcc" - - # Board related common compile flags. - board_cflags = [] - board_cxx_flags = [] - board_ld_flags = [] - ``` - -3. Build the script. - - Create the **BUILD.gn** file in the development board directory. The target name must be the same as that of the development board. The content in the **device/realtek/rtl8720/BUILD.gn** file is configured as follows: - - ``` - group("rtl8720") { # The target can be shared_library, static_library, or an executable file. - # Content - ...... - } - ``` - -4. Build the chipset solution. - - Run the **hb build** command in the development board directory to start the build. - +1. Create a directory for the chipset solution based on the [configuration rules](#chipset-solution). + Run the following command in the root directory of the code: + + ``` + mkdir -p device/board/realtek/rtl8720 + ``` + +2. Create a directory for kernel adaptation and write the **config.gni** file of the development board. + For example, to adapt the LiteOS-A kernel to the RTL8720 development board, write the **device/realtek/rtl8720/liteo_a/config.gni** file as follows: + + ``` + # Kernel type, e.g. "linux", "liteos_a", "liteos_m". + kernel_type = "liteos_a" + + # Kernel version. + kernel_version = "3.0.0" + + # Board CPU type, e.g. "cortex-a7", "riscv32". + board_cpu = "real-m300" + + # Board arch, e.g. "armv7-a", "rv32imac". + board_arch = "" + + # Toolchain name used for system compiling. + # E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf. + # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. + board_toolchain = "gcc-arm-none-eabi" + + # The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc. + board_toolchain_path = + rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin", + root_build_dir) + + # Compiler prefix. + board_toolchain_prefix = "gcc-arm-none-eabi-" + + # Compiler type, "gcc" or "clang". + board_toolchain_type = "gcc" + + # Board related common compile flags. + board_cflags = [] + board_cxx_flags = [] + board_ld_flags = [] + ``` + +3. Write the build script. + Create the **BUILD.gn** file in the development board directory. The target name must be the same as that of the development board. The following is an example of the **device/realtek/rtl8720/BUILD.gn** file for the RTL8720 development board: + + ``` + group("rtl8720") { # The build target can be shared_library, static_library, or an executable file. + # Content + ... + } + ``` + +4. Build the chipset solution. + Run the **hb build** command in the development board directory to start the build. ### Adding a Product Solution -You can use the Compilation and Building subsystem to customize product solutions by assembling chipset solutions and components. The procedure is as follows: - -1. Create a product directory. - - The following uses the Wi-Fi IoT component on the RTL8720 development board as an example. Run the following command in the root code directory to create a product directory based on [Configuration Rules](#configuration-rules): - - ``` - mkdir -p vendor/my_company/wifiiot - ``` - -2. Assemble the product. - - Create the **config.json** file in the product directory. The **vendor/my\_company/wifiiot/config.json** file is as follows: - - ``` - { - "product_name": "wifiiot", # Product name - "version": "3.0", # config.json version, which is 3.0 - "type": "small", # System type, which can be mini, small, or standard - "ohos_version": "OpenHarmony 1.0", # OS version - "device_company": "realtek", # Name of the chipset solution vendor - "board": "rtl8720", # Name of the development board - "kernel_type": "liteos_m", # Kernel type - "kernel_version": "3.0.0", # Kernel version - "subsystems": [ - { - "subsystem": "kernel", # Subsystem - "components": [ - { "component": "liteos_m", "features":[] } # Component and its features - ] - }, - ... - { - More subsystems and components - } - ] - } - ``` - - Before the build, the Compilation and Building subsystem checks the validity of fields, including **device\_company**, **board**, **kernel\_type**, **kernel\_version**, **subsystem**, and **component**. The **device\_company**, **board**, **kernel\_type**, and **kernel\_version** fields must match the current chipset solution, and **subsystem** and **component** must match the component description in the **build/lite/components** file. - -3. Implement adaptation to OS APIs. - - Create the **hals** directory in the product directory and store the source code as well as the build script for OS adaptation in this directory. - -4. Configure the system service. - - Create the **init\_configs** directory in the product directory and then the **init.cfg** file in the newly created directory. Configure the system service to be started. - -5. \(Optional\) Configure the init process only for the Linux kernel. - - Create the **etc** directory in the **init\_configs** directory, and then the **init.d** folder and the **fstab** file in the newly created directory. Then, create the **rcS** and **S**_xxx_ files in the **init.d** file and edit them based on product requirements. - -6. \(Optional\) Configure the file system image only for the development board that supports the file system. - - Create the **fs.yml** file in the product directory and configure it as required. A typical **fs.yml** file is as follows: - - ``` - - - fs_dir_name: rootfs # Image name - fs_dirs: - - - # Copy the files in the out/my_board/my_product/bin directory to the rootfs/bin directory and ignore the .bin files related to testing. - source_dir: bin - target_dir: bin - ignore_files: - - Test.bin - - TestSuite.bin - - - # Copy the files in the out/my_board/my_product/libs directory to the rootfs/lib directory, ignore all .a files, and set the file permissions to 644 and folder permissions 755. - source_dir: libs - target_dir: lib - ignore_files: - - .a - dir_mode: 755 - file_mode: 644 - - - source_dir: usr/lib - target_dir: usr/lib - ignore_files: - - .a - dir_mode: 755 - file_mode: 644 - - - source_dir: config - target_dir: etc - - - source_dir: system - target_dir: system - - - source_dir: sbin - target_dir: sbin - - - source_dir: usr/bin - target_dir: usr/bin - - - source_dir: usr/sbin - target_dir: usr/sbin - - - # Create an empty proc directory. - target_dir: proc - - - target_dir: mnt - - - target_dir: opt - - - target_dir: tmp - - - target_dir: var - - - target_dir: sys - - - source_dir: etc - target_dir: etc - - - source_dir: vendor - target_dir: vendor - - - target_dir: storage - - fs_filemode: - - - file_dir: lib/ld-uClibc-0.9.33.2.so - file_mode: 555 - - - file_dir: lib/ld-2.24.so - file_mode: 555 - - - file_dir: etc/init.cfg - file_mode: 400 - fs_symlink: - - - # Create the soft link ld-musl-arm.so.1 -> libc.so in the rootfs/lib directory. - source: libc.so - link_name: ${fs_dir}/lib/ld-musl-arm.so.1 - - - source: mksh - link_name: ${fs_dir}/bin/sh - - - source: mksh - link_name: ${fs_dir}/bin/shell - fs_make_cmd: - # Create an ext4 image for the rootfs directory using the script. - - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 - - - fs_dir_name: userfs - fs_dirs: - - - source_dir: storage/etc - target_dir: etc - - - source_dir: data - target_dir: data - fs_make_cmd: - - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 - - ``` - -7. \(Optional\) Configure patches if the product and components need to be patched. - - Create the **patch.yml** file in the product directory and configure it as required. A typical **patch.yml** file is as follows: - - ``` - # Directory in which the patch is to be installed - foundation/communication/dsoftbus: - # Directory in which the patch is stored - - foundation/communication/dsoftbus/1.patch - - foundation/communication/dsoftbus/2.patch - third_party/wpa_supplicant: - - third_party/wpa_supplicant/1.patch - - third_party/wpa_supplicant/2.patch - - third_party/wpa_supplicant/3.patch - ... - ``` - - If you add **--patch** when running the **hb build** command, the patch file can be added to the specified directory before the build. +You can customize a product solution by flexibly assembling a chipset solution and components. The procedure is as follows: + +1. Create a product directory based on the [configuration rules](#product-solution). + The following uses the Wi-Fi IoT module on the RTL8720 development board as an example. Run the following command in the root directory to create a product directory: + + ``` + mkdir -p vendor/my_company/wifiiot + ``` + +2. Assemble the product. + Create a **config.json** file, for example for wifiiot, in the product directory. The **vendor/my_company/wifiiot/config.json** file is as follows: + + ``` + { + "product_name": "wifiiot", # Product name + "version": "3.0", # Version of config.json. The value is 3.0. + "type": "small", # System type. The value can be mini, small, or standard. + "ohos_version": "OpenHarmony 1.0", # OS version + "device_company": "realtek", # Name of the chipset solution vendor + "board": "rtl8720", # Name of the development board + "kernel_type": "liteos_m", # Kernel type + "kernel_version": "3.0.0", # Kernel version + "subsystems": [ + { + "subsystem": "kernel", # Subsystem + "components": [ + { "component": "liteos_m", "features":[] } # Component and its features + ] + }, + ... + { + More subsystems and components + } + ] + } + ``` + + >  **CAUTION**<br/> + > Before the build, the Compilation and Building subsystem checks the validity of fields in **config.json**. The **device_company**, **board**, **kernel_type**, and **kernel_version** fields must match the fields of the chipset solution, and **subsystem** and **component** must match the component description in the **build/lite/components** file. + +3. Implement adaptation to OS APIs. + Create the **hals** directory in the product directory and save the source code as well as the build script for OS adaptation in this directory. + +4. Configure system services. + Create the **init_configs** directory in the product directory and then the **init.cfg** file in the **init_configs** directory, and configure the system services to be started. + +5. (Optional) Configure the init process for the Linux kernel. + Create the **etc** directory in the **init_configs** directory, and then the **init.d** folder and the **fstab** file in the **etc** directory. Then, create the **rcS** and **S***xxx* files in the **init.d** file and edit them based on product requirements. + +6. (Optional) Configure the file system image for the development board that supports the file system. + + Create a **fs.yml** file in the product directory and configure it as required. A typical **fs.yml** file is as follows: + + ``` + - + fs_dir_name: rootfs # Image name + fs_dirs: + - + # Copy the files in the out/my_board/my_product/bin directory to the rootfs/bin directory and ignore the .bin files related to testing. + source_dir: bin + target_dir: bin + ignore_files: + - Test.bin + - TestSuite.bin + - + # Copy the files in the out/my_board/my_product/libs directory to the rootfs/lib directory, ignore all .a files, and set the file permissions to 644 and folder permissions 755. + source_dir: libs + target_dir: lib + ignore_files: + - .a + dir_mode: 755 + file_mode: 644 + - + source_dir: usr/lib + target_dir: usr/lib + ignore_files: + - .a + dir_mode: 755 + file_mode: 644 + - + source_dir: config + target_dir: etc + - + source_dir: system + target_dir: system + - + source_dir: sbin + target_dir: sbin + - + source_dir: usr/bin + target_dir: usr/bin + - + source_dir: usr/sbin + target_dir: usr/sbin + - + # Create an empty proc directory. + target_dir: proc + - + target_dir: mnt + - + target_dir: opt + - + target_dir: tmp + - + target_dir: var + - + target_dir: sys + - + source_dir: etc + target_dir: etc + - + source_dir: vendor + target_dir: vendor + - + target_dir: storage + + fs_filemode: + - + file_dir: lib/ld-uClibc-0.9.33.2.so + file_mode: 555 + - + file_dir: lib/ld-2.24.so + file_mode: 555 + - + file_dir: etc/init.cfg + file_mode: 400 + fs_symlink: + - + # Create the soft link ld-musl-arm.so.1 -> libc.so in the rootfs/lib directory. + source: libc.so + link_name: ${fs_dir}/lib/ld-musl-arm.so.1 + - + source: mksh + link_name: ${fs_dir}/bin/sh + - + source: mksh + link_name: ${fs_dir}/bin/shell + fs_make_cmd: + # Run the script to create an ext4 image from rootfs. + - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 + - + fs_dir_name: userfs + fs_dirs: + - + source_dir: storage/etc + target_dir: etc + - + source_dir: data + target_dir: data + fs_make_cmd: + - ${root_path}/build/lite/make_rootfs/rootfsimg_linux.sh ${fs_dir} ext4 + + ``` + +7. (Optional) Configure patches if the product and components need to be patched. + + Create a **patch.yml** file in the product directory and configure it as required. A typical **patch.yml** file is as follows: + + ``` + # Directory in which the patch is to be installed + foundation/communication/dsoftbus: + # Directory in which the patch is stored. + - foundation/communication/dsoftbus/1.patch + - foundation/communication/dsoftbus/2.patch + third_party/wpa_supplicant: + - third_party/wpa_supplicant/1.patch + - third_party/wpa_supplicant/2.patch + - third_party/wpa_supplicant/3.patch + ... + ``` + + + Add **--patch** when running the **hb build** command. Then, the patch files can be added to the specified directory before the build. ``` hb build -f --patch ``` -8. Build the script. - - Create the **BUILD.gn** file in the product directory and write the script. The following **BUILD.gn** file uses the Wi-Fi IoT component in [1](#li1970321162111) as an example: - - ``` - group("wifiiot") { # The target name must be the same as the product name. - deps = [] - # Copy the init configuration. - deps += [ "init_configs" ] - # Build the hals directory. - deps += [ "hals" ] - # Others - ...... - } - ``` +8. Write the build script. + Create a **BUILD.gn** file in the product directory and write the script. The following **BUILD.gn** file uses the Wi-Fi IoT module in step 1 as an example: -9. Build the product. + ``` + group("wifiiot") { # The target name must be the same as the product name. + deps = [] + # Copy the init configuration. + deps += [ "init_configs" ] + # Add **hals**. + deps += [ "hals" ] + # Others + ... + } + ``` - Run the **hb set** command in the code root directory, select the new product as prompted, and run the **hb build** command. +9. Build the product. + Run the **hb set** command in the code root directory, select the new product as prompted, and run the **hb build** command. ## Troubleshooting -### Invalid -- w Option - -- **Symptom** - - The build fails, and "usr/sbin/ninja: invalid option -- w" is displayed. - -- **Cause** - - The Ninja version in the build environment is outdated and does not support the **--w** option. +### "usr/sbin/ninja: invalid option -- w" Displayed During the Build Process -- **Solution** +- **Symptom** + + The build fails, and **usr/sbin/ninja: invalid option -- w** is displayed. - Uninstall Ninja and GN and follow the instructions provided in [IDE](../get-code/gettools-ide.md) to install Ninja and GN of the required version. +- **Possible Causes** + + The Ninja version in use does not support the **--w** option. +- **Solution** + + Uninstall Ninja and GN, and [install Ninja and GN of the required version](../get-code/gettools-ide.md). -### Library ncurses Not Found +### "/usr/bin/ld: cannot find -lncurses" Displayed During the Build Process -- **Symptom** +- **Symptom** + + The build fails, and **/usr/bin/ld: cannot find -lncurses** is displayed. - The build fails, and "/usr/bin/ld: cannot find -lncurses" is displayed. +- **Possible Causes** + + The ncurses library is not installed. -- **Cause** +- **Solution** + + ``` + sudo apt-get install lib32ncurses5-dev + ``` - The ncurses library is not installed. +### "line 77: mcopy: command not found" Displayed During the Build Process -- **Solution** +- **Symptom** + + The build fails, and **line 77: mcopy: command not found** is displayed. - ``` - sudo apt-get install lib32ncurses5-dev - ``` - - -### mcopy not Found +- **Possible Causes** + + mcopy is not installed. -- **Symptom** +- **Solution** + + ``` + sudo apt-get install dosfstools mtools + ``` - The build fails, and "line 77: mcopy: command not found" is displayed. +### "riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory" Displayed During the Build Process -- **Cause** +- **Symptom** + + The build fails, and the following information is displayed: <br>**riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory** - mcopy is not installed. - -- **Solution** - - ``` - sudo apt-get install dosfstools mtools - ``` +- **Possible Causes** + + Permission is required to access files in the RISC-V compiler directory. +- **Solution** -### No riscv File or Directory + 1. Run the following command to locate **gcc_riscv32**: -- **Symptom** + ``` + which riscv32-unknown-elf-gcc + ``` - The build fails, and the following information is displayed: + 2. Run the **chmod** command to change the directory permission to **755**. - riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory. - -- **Cause** - - Permission is required to access files in the **riscv** compiler directory. - -- **Solution** - - Run the following command to query the directory where **gcc\_riscv32** is located: - - ``` - which riscv32-unknown-elf-gcc - ``` + - Run the **chmod** command to change the directory permission to **755**. + +### "No module named 'Crypto'" Displayed During the Build Process -### No Crypto +- **Symptom** + + The build fails, and **No module named 'Crypto'** is displayed. -- **Symptom** +- **Possible Causes** + + Crypto is not installed in Python 3. - The build fails, and "No component named 'Crypto'" is displayed. +- **Solution** + + 1. Run the following command to query the Python version: + + ``` + python3 --version + ``` + + 2. Ensure that Python 3.9.2 or later is installed, and then run the following command to install PyCryptodome: + + ``` + sudo pip3 install pycryptodome + ``` -- **Cause** +### "xx.sh : xx unexpected operator" Displayed During the Build Process - Crypto is not installed in Python 3. +- **Symptom** + + The build fails, and **xx.sh [: xx unexpected operator** is displayed. -- **Solution** - 1. Run the following command to query the Python version: - - ``` - python3 --version - ``` - - 2. Ensure that Python 3.7 or later is installed, and then run the following command to install pycryptodome: - - ``` - sudo pip3 install pycryptodome - ``` - - - -### Unexpected Operator - -- **Symptom** - - The build fails, and "xx.sh \[: xx unexpected operator" is displayed. - -- **Cause** - - The build environment is shell, not bash. - -- **Solution** - - ``` - sudo rm -rf /bin/sh - sudo ln -s /bin/bash /bin/sh - ``` +- **Possible Causes** + + The build environment shell is not bash. +- **Solution** + + ``` + sudo rm -rf /bin/sh + sudo ln -s /bin/bash /bin/sh + ``` diff --git a/en/device-dev/subsystems/subsys-build-standard-large.md b/en/device-dev/subsystems/subsys-build-standard-large.md index 588d41c97447e31a06b67f21e226f27e00183efe..d1f3eb9fd89a82aee966221853706f0d7562e776 100644 --- a/en/device-dev/subsystems/subsys-build-standard-large.md +++ b/en/device-dev/subsystems/subsys-build-standard-large.md @@ -1,226 +1,813 @@ -# Building the Standard System<a name="EN-US_TOPIC_0000001076490572"></a> +# Building the Standard System -## Overview<a name="section17466112012244"></a> +## Overview -The compilation and building subsystem provides a framework based on Generate Ninja \(GN\) and Ninja. This subsystem allows you to: +The Compilation and Building subsystem provides a build framework based on Generate Ninja (GN) and Ninja. This subsystem allows you to: -- Build products based on different chipset platforms, for example, Hi3516D V300. +- Build products based on different chipset platforms, for example, hispark_taurus_standard. -- Package capabilities required by a product by assembling modules based on the product configuration. +- Package capabilities required by a product by assembling components based on the product configuration. -### Basic Concepts<a name="section445513507246"></a> +### Basic Concepts -It is considered best practice to learn the following basic concepts before you start building: +Learn the following basic concepts before you start: -- **Platform** +- Platform + + A platform consists of the development board and kernel. The supported subsystems and components vary with the platform. - A platform is a combination of development boards and kernels. +- Subsystem + + OpenHarmony is designed with a layered architecture, which consists of the kernel layer, system service layer, framework layer, and application layer from the bottom up. System functions are developed by levels, from system to subsystem and then to component. In a multi-device deployment scenario, you can customize subsystems and components as required. A subsystem, as a logical concept, consists of the least required components. - Supported subsystems and modules vary according to the platform. +- Component + + A component is a reusable software unit that contains source code, configuration files, resource files, and build scripts. Integrated in binary mode, a component can be built and tested independently. -- **Subsystems** +- GN + + GN is short for Generate Ninja. It is used to build Ninja files. - OpenHarmony is designed with a layered architecture, which from bottom to top consists of the kernel layer, system service layer, framework layer, and application layer. System functions are expanded by levels, from system to subsystem, and further to module. In a multi-device deployment scenario, unnecessary subsystems and modules can be excluded from the system as required. A subsystem is a logical concept and is a flexible combination of functions. +- Ninja + + Ninja is a small high-speed building system. -- **Module** +### Working Principles - A module is a reusable software binary unit that contains source code, configuration files, resource files, and build scripts. A module can be built independently, integrated in binary mode, and then tested independently. +The process for building an OpenHarmony system is as follows: -- **GN** +- Parsing commands: Parse the name of the product to build and load related configurations. - GN is short for Generate Ninja, which is used to generate Ninja files. +- Running GN: Configure the toolchain and global options based on the product name and compilation type. -- **Ninja** +- Running Ninja: Start building and generate a product distribution. - Ninja is a small high-speed build system. +### Constraints +- You need to obtain the source code using method 3 described in [Obtaining Source Code](../get-code/sourcecode-acquire.md). -### Working Principles<a name="section12541217142510"></a> +- Ubuntu 18.04 or later must be used. -The process to build OpenHarmony is as follows: +- You must install the software packages required for build. + The command is as follows: + + ``` + # Run the script in the home directory. + # ./build/build_scripts/env_setup.sh + # Do not run the command as the **root** user. Otherwise, the environment variables will be added to the **root** user. If your **shell** is not **bash** or **Zsh**, you need to manually configure the following content to your environment variables after the execution. To view your environment variables, run the **cd** command to go to your home directory and view the hidden files. + # export PATH=/home/tools/llvm/bin:$PATH + # export PATH=/home/tools/hc-gen:$PATH + # export PATH=/home/tools/gcc_riscv32/bin:$PATH + # export PATH=/home/tools/ninja:$PATH + # export PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH + # export PATH=/home/tools/gn:$PATH + # export PATH=/root/.local/bin:$PATH + + # If you do not need to run the script, you need to install the following: + apt-get update -y + apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.9.2 python3-pip git zip unzip curl wget gcc g++ ruby dosfstools mtools default-jre default-jdk scons python3-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev + apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 python2.7 gcc-arm-none-eabi vim ssh locales doxygen + # Install the following modules for Python: + chmod +x /usr/bin/repo + pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple requests setuptools pymongo kconfiglib pycryptodome ecdsa ohos-build pyyaml prompt_toolkit==1.0.14 redis json2html yagmail python-jenkins + pip3 install esdk-obs-python --trusted-host pypi.org + pip3 install six --upgrade --ignore-installed six + #You also need to install LLVM, hc-gen, gcc_riscv32, Ninja, node-v14.15.4-linux-x64, and GN, and import the non-bash or non-Zsh configuration in the shell to your environment variables. + ``` -- Parsing commands: Parse the name of the product to build and load related configurations. -- Running GN: Configure toolchains and global options based on the parsed product name and compilation type. -- Running Ninja: Start building and generate a product distribution. -### Limitations and Constraints<a name="section886933762513"></a> -- You must download the source code using method 3 described in [Source Code Acquisition](../get-code/sourcecode-acquire.md). -- The build environment must be Ubuntu 18.04 or later. -- You must install the software package required for build. +## Building Guidelines - The installation command is as follows: +### Directory Structure - ``` - sudo apt-get install binutils git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 - ``` +``` +/build # Directory for build -## Compilation and Building Guidelines<a name="section16901215262"></a> +├── __pycache__ +├── build_scripts/ # Python scripts for build +├── common/ +├── config/ # Build-related configurations +├── core +│ └── gn/ # BUILD.gn configuration + └── build_scripts/ +├── docs +gn_helpers.py* +lite/ # hb and preloader entry +misc/ +├── ohos # Process for building and packaging OpenHarmony +│ ├── kits # Kits build and packaging templates and processing +│ ├── ndk # NDK templates and processing +│ ├── notice # Notice templates and processing +│ ├── packages # Distribution packaging templates and processing +│ ├── sa_profile # SA profiles and processing +│ ├── sdk # SDK templates and processing, which contains the module configuration in the SDK +│ └── testfwk # Testing-related processing +├── ohos.gni* # Common .gni files for importing a module at a time. +├── ohos_system.prop +├── ohos_var.gni* +├── prebuilts_download.sh* +├── print_python_deps.py* +├── scripts/ +├── subsystem_config.json +├── subsystem_config_example.json +├── templates/ # C/C++ build templates +├── test.gni* +├── toolchain # Build toolchain configuration +├── tools # Common tools +├── version.gni +├── zip.py* -### Directory Structure<a name="section109065332264"></a> -``` -/build # Primary directory -├── config # Build configuration items -├── core -│ └── gn # Build entry BUILD.gn configuration -├── loader # Loader of module configuration, which also generates a template for the module -├── ohos # Configuration of the process for building and packaging OpenHarmony -│ ├── kits # Build and packaging templates and processing flow for kits -│ ├── ndk # NDK template and processing flow -│ ├── notice # Notice template and processing flow -│ ├── packages # Distribution packaging template and processing flow -│ ├── sa_profile # SA template and processing flow -│ ├── sdk # SDK template and processing flow, which contains the module configuration in the SDK -│ └── testfwk # Processing flow related to the test -├── scripts # Build-related Python script -├── templates # C/C++ build templates -└── toolchain # Toolchain configuration ``` -### Build Command<a name="section123265539266"></a> +### Build Command -- Run the following command in the root directory of the source code to build the full distribution: +- Run the following command in the root directory of the source code to build a full distribution: - ``` - ./build.sh --product-name {product_name} - ``` + ``` - **product\_name** indicates the product supported by the current distribution, for example, hispark_taurus_standard. + ./build.sh --product-name {product_name} + + ``` - The image generated after build is stored in the **out/{device_name}/packages/phone/images/** directory. + **{product_name}** specifies the product platform supported by the current distribution, for example, **hispark_taurus_standard**. -- The build command supports the following options: + The image generated is stored in the **out/{device_name}/packages/phone/images/** directory. - ``` - --product-name # (Mandatory) Name of the product to build, for example, Hi3516D V300 - --build-target # (Optional) One or more build targets - --gn-args # (Optional) One or more gn parameters - --ccache # (Optional) Use of Ccache for build. This option takes effect only when Ccache is installed on the local PC. - ``` +- The **./build.sh** command supports the following options: + ``` + -h, --help # Display help information and exit. + --source-root-dir=SOURCE_ROOT_DIR # Specify the path. + --product-name=PRODUCT_NAME # Specify the product name. + --device-name=DEVICE_NAME # Specify the device name. + --target-cpu=TARGET_CPU # Specify the CPU. + --target-os=TARGET_OS # Specify the operating system. + -T BUILD_TARGET, --build-target=BUILD_TARGET # specifies one or more targets to build. + --gn-args=GN_ARGS # Specify GN parameters. + --ninja-args=NINJA_ARGS # Specify Ninja parameters. + -v, --verbose # Display all commands used. + --keep-ninja-going # Keep Ninja going until 1,000,000 jobs fail. + --sparse-image + --jobs=JOBS + --export-para=EXPORT_PARA + --build-only-gn # Perform GN parsing and does not run Ninja. + --ccache # (Optional) Use ccache for build. You need to install ccache locally. + --fast-rebuild # Whether to use fast rebuild. The default value is False. + --log-level=LOG_LEVEL # Specify the log level during the build. The options are debug, info, and error. The default value is info. + --device-type=DEVICE_TYPE # Specify the device type. The default value is default. + --build-variant=BUILD_VARIANT # Specify the device operation mode. The default value is user. -### How to Develop<a name="section591084422719"></a> + ``` -1. Add a module. +### How to Develop - The following steps use a custom module as an example to describe how to build the module, including build a library, an executable file, and a configuration file. +1. Add a component. + + The following use a custom component as an example to describe how to write .gn scripts for a library, an executable file, and a configuration file. + + In this example, **partA** consists of **feature1**, **feature2**, and **feature3**, which represent a dynamic library, an executable file, and an etc configuration file, respectively. + + Add **partA** to a subsystem, for example, **subsystem_examples** (defined in the **test/examples/** directory). + - The example module **partA** consists of **feature1**, **feature2**, and **feature3**. The target is a dynamic library for **feature1**, an executable file for **feature2**, and an etc configuration file for **feature3**. +The directory structure of **partA** is as follows: - Add **partA** to a subsystem, for example, **subsystem\_examples** \(defined in the **test/examples/** directory\). +``` + + test/examples/partA + ├── feature1 + │ ├── BUILD.gn + │ ├── include + │ │ └── helloworld1.h + │ └── src + │ └── helloworld1.cpp + ├── feature2 + │ ├── BUILD.gn + │ ├── include + │ │ └── helloworld2.h + │ └── src + │ └── helloworld2.cpp + └── feature3 + ├── BUILD.gn + └── src + └── config.conf + +``` - The complete directory structure of **partA** is as follows: +(a) Write **test/examples/partA/feature1/BUILD.gn** for the dynamic library. - ``` - test/examples/partA - ├── feature1 - │ ├── BUILD.gn - │ ├── include - │ │ └── helloworld1.h - │ └── src - │ └── helloworld1.cpp - ├── feature2 - │ ├── BUILD.gn - │ ├── include - │ │ └── helloworld2.h - │ └── src - │ └── helloworld2.cpp - └── feature3 - ├── BUILD.gn - └── src - └── config.conf - ``` +``` + + config("helloworld_lib_config") { + include_dirs = [ "include" ] +} + + ohos_shared_library("helloworld_lib") { + sources = [ + "include/helloworld1.h", + "src/helloworld1.cpp", + ] + public_configs = [ ":helloworld_lib_config" ] + part_name = "partA" +} + +``` - Example 1: GN script \(**test/examples/partA/feature1/BUILD.gn**\) for building a dynamic library +(b) Write **test/examples/partA/feature2/BUILD.gn** for the executable file. - ``` - config("helloworld_lib_config") { +``` + + ohos_executable("helloworld_bin") { + sources = [ + "src/helloworld2.cpp" + ] include_dirs = [ "include" ] - } - - ohos_shared_library("helloworld_lib") { - sources = [ - "include/helloworld1.h", - "src/helloworld1.cpp", + deps = [ # Dependent modules in the component + "../feature1:helloworld_lib" + ] + external_deps = [ "partB:module1" ] # (Optional) Dependent modules of another component are named in Component name:Module name format. + install_enable = true # By default, the executable file is not installed. You need to set this parameter to true for installation. + part_name = "partA" +} + +``` + +(c) Write **test/examples/partA/feature3/BUILD.gn** for the etc module. + +``` + + ohos_prebuilt_etc("feature3_etc") { + source = "src/config.conf" + relative_install_dir = "init" # (Optional) Relative directory for installing the module. The default installation directory is **/system/etc**. + part_name = "partA" +} + +``` + + (d) Add the module configuration **test/examples/bundle.json** to the **bundle.json** file of the component. Each component has a **bundle.json** file in the root directory of the component. The sample code is as follows: + + ``` + { + "name": "@ohos/<component_name>, # OpenHarmony Package Manager (HPM) component name, in the "@Organization/Component name" format. + "description": "xxxxxxxxxxxxxxxxxxx", # Description of the component functions. + "version": "3.1", # Version, which must be the same as the version of OpenHarmony. + "license": "MIT", # Component license. + "publishAs": "code-segment", # Mode for publishing the HPM package. The default value is code-segment. + "segment": { + "destPath": "" + }, # Set the code restoration path (source code path) when publishAs is code-segment. + "dirs": {}, # Directory structure of the HPM package. This field is mandatory and can be left empty. + "scripts": {}, # Scripts to be executed. This field is mandatory and can be left empty. + "licensePath": "COPYING", # Path of the module's license. + "readmePath": { + "en": "README.rst" + }, # Path of module's reademe.opensource. + "component": { # Component attributes. + "name": "<component_name>", # Component name. + "subsystem": "", # Subsystem to which the component belongs. + "syscap": [], # System capabilities provided by the component for applications. + "features": [], # List of the component's configurable features. Generally, this parameter corresponds to sub_component in build and can be configured. + "adapted_system_type": [], # Adapted system types, which can be mini, small, and standard. Multiple values are allowed. + "rom": "xxxKB" # ROM baseline. If there is no baseline, enter the current value. + "ram": "xxxKB", # RAM baseline. If there is no baseline, enter the current value. + "deps": { + "components": [], # Other components on which this component depends. + "third_party": [] # Third-party open-source software on which this component depends. + }, + "build": { # Build-related configurations. + "sub_component": [], # Component build entry. Configure the module here. + "inner_kits": [], # APIs between components. + "test": [] # Entry for building the component's test cases. + } + } + } + ``` + +2. Add the component to the product configuration file. + Add the component to **//vendor/{*product_company*}/{*product-name*}/config.json**. + + For example, add "subsystem_examples:partA" to the product **config.json** file. **partA** will be built and packaged into the distribution. + +3. Start the build. + For example, run the following command to build **hispark_taurus_standard**: + + ``` + + ./build.sh --product-name hispark_taurus_standard --ccache + + ``` + +4. Obtain the build result. + You can obtain the generated files from the **out/hispark_taurus/** directory and the image in the **out/hispark_taurus/packages/phone/images/** directory. + +## FAQs + +### How Do I Build a Module and Package It into a Distribution? + +- Set **part_name** for the module. A module can belong to only one part. + +- Add the module to **component.build.sub_component** of the component, or define the dependency between the module and the modules in **component.build.sub_component**. + +- Add the component to the component list of the product. + +### How Do I Set deps and external_deps? + +When adding a module, you need to declare its dependencies in **BUILD.gn**. **deps** specifies dependent modules in the same component, and **external_deps** specifies dependent modules between components. + +The dependency between modules can be classified into: + +**deps**: The dependent module to be added belongs to the same component with the current module. For example, module 2 depends on module 1, and modules 1 and 2 belong to the same component. + +**external_deps**: The dependent module to be added belongs to another component. For example, module 2 depends on module 1, and modules 1 and 2 belong to different components. + +- Example of **deps**: + + ``` + import("//build/ohos.gni") + ohos_shared_library("module1") { + ... + part_name = "part1" # (Mandatory) Name of the component to which the module belongs. + ... + } + ``` + + ``` + import("//build/ohos.gni") + ohos_shared_library("module2") { + ... + deps = [ + "GN target of module 1", + ... + ] # Intra-component dependency + part_name = "part1" # (Mandatory) Name of the part to which the module belongs. + } + ``` + +- Example of **external_deps**: + + ``` + import("//build/ohos.gni") + ohos_shared_library("module1") { + ... + part_name = "part1" # (Mandatory) Name of the component to which the module belongs. + ... + } + ``` + +- **bundle.json** file of the component to which module 1 belongs + + ``` + { + "name": "@ohos/<component_name>", # HPM component name, in the "@Organization/Component name" format. + "description": "xxxxxxxxxxxxxxxx", # Description of the component functions. + "version": "3.1", # Version, which must be the same as the version of OpenHarmony. + "license": "MIT", # Component license. + "publishAs": "code-segment", # Mode for publishing the HPM package. The default value is code-segment. + "segment": { + "destPath": "" + }, # Code restoration path (source code path) when publishAs is code-segment. + "dirs": {}, # Directory structure of the HPM package. This field is mandatory and can be left empty. + "scripts": {}, # Scripts to be executed. This field is mandatory and can be left empty. + "licensePath "licensePath": "COPYING", + ": "COPYING", + "readmePath": { + "en": "README.rst" + }, + "component": { # Component attributes. + "name": "<component_name>", # Component name. + "subsystem": "", # Subsystem to which the component belongs. + "syscap": [], # System capabilities provided by the component for applications. + "features": [], # List of the component's configurable features. Generally, this parameter corresponds to sub_component in build and can be configured. + "adapted_system_type": [], # Adapted system types, which can be mini, small, and standard. Multiple values are allowed. + "rom": "xxxKB" # ROM baseline. If there is no baseline, enter the current value. + "ram": "xxxKB", # RAM baseline. If there is no baseline, enter the current value. + "deps": { + "components": [], # Other components on which this component depends. + "third_party": [] # Third-party open-source software on which this component depends. + }, + "build": { # Build-related configurations. + "sub_component": ["part1"], # Component build entry. All modules of the component are listed here. + "inner_kits": [], # APIs between components. + { + "header": { + "header_base": "Header file directory", # Directory of the header files. + "header_files": [ + "Header file name" + ] # List of header file names. + }, + "name": "GN target of module 1" + }, + ], + "test": [] # Entry for building the component's test cases. + } + } + } + ``` + + ``` + import("//build/ohos.gni") + ohos_shared_library("module2") { + ... + external_deps = [ + "part1:module1", + ... + ] # Inter-component dependency. The dependent module must be declared in **inner_kits** by the dependent component. + part_name = "part2" # (Mandatory) Name of the component to which the module belongs. + } + + ``` + +>  **CAUTION**<br/> +> The values of **external_deps** are in the *Component name*:*Module name* format. The module name must exist in **inner_kits** of the dependent component. + + + + + +### How Do I Add a Module to a Standard System? + +You may need to: + +- Add a module to an existing component. + +- Add a module to a new component. + +- Add a module to a new subsystem. + +#### Adding a Module to an Existing Component + +1. Configure the **BUILD.gn** file in the module directory and select the corresponding template. + + Follow the procedure for adding a module to an existing component. Note that **part_name** in the **BUILD.gn** file is the name of the existing component. +2. Modify the **bundle.json** file. "GN target of the module in the component" + + ``` + { + "name": "@ohos/<component_name>, # HPM component name, in the "@Organization/Component name" format. + "description": "xxxxxxxxxxxxxxxxxxx", # Description of the component functions. + "version": "3.1", # Version, which must be the same as the version of OpenHarmony. + "license": "MIT", # Component license. + "publishAs": "code-segment", # Mode for publishing the HPM package. The default value is code-segment. + "segment": { + "destPath": "third_party/nghttp2" + }, # Code restoration path (source code path) when publishAs is code-segment. + "dirs": {}, # Directory structure of the HPM package. This field is mandatory and can be left empty. + "scripts": {}, # Scripts to be executed. This field is mandatory and can be left empty. + "licensePath": "COPYING", + "readmePath": { + "en": "README.rst" + }, + "component": { # Component attributes. + "name": "<component_name>", # Component name. + "subsystem": "", # Subsystem to which the component belongs. + "syscap": [], # System capabilities provided by the component for applications. + "features": [], # List of the component's configurable features. Generally, this parameter corresponds to sub_component in build and can be configured. + "adapted_system_type": [], # Adapted system types, which can be mini, small, and standard. Multiple values are allowed. + "rom": "xxxKB" # ROM baseline. If there is no baseline, enter the current value. + "ram": "xxxKB", # RAM baseline. If there is no baseline, enter the current value. + "deps": { + "components": [], # Other components on which this component depends. + "third_party": [] # Third-party open-source software on which this component depends. + }, + + "build": { # Build-related configurations + "sub_component": [ + "//foundation/arkui/napi:napi_packages", # Existing module 1 + "//foundation/arkui/napi:napi_packages_ndk" # Existing module 2 + "//foundation/arkui/napi:new" # Module to add + ], # Component build entry. Configure the module here. + "inner_kits": [], # APIs between components + "test": [] # Entry for building the component's test cases. + } + } + } + ``` + + Note that the **bundle.json** file must be in the folder of the corresponding subsystem. + +#### Creating a Component and Adding a Module + +1. Configure the **BUILD.gn** file in the module directory and select the corresponding template. Note that **part_name** in the **BUILD.gn** file is the name of the newly added component. + +2. Create a **bundle.json** file in the folder of the corresponding subsystem. + + The **bundle.json** file consists of two parts: **subsystem** and **parts**. Add the component information to **parts**. When adding a component, you need to specify the **sub_component** of the component. If there are APIs provided for other components, add them in **inner_kits**. If there are test cases, add them in **test**. + +3. Add the new component to the end of existing components in **//vendor/{product_company}/{product-name}/config.json**. + + ``` + "subsystems": [ + { + "subsystem": "Name of the subsystem to which the component belongs", + "components": [ + {"component": "Component 1 name", "features":[]}, # Existing component 1 in the subsystem + { "component": "Component 2 name", "features":[] }, # Existing component 2 in the subsystem + {"component": "New component name", "features":[]} # New component in the subsystem + ] + }, + ... + ] + ``` + +#### Creating a Subsystem and Adding a Module + +1. Configure the **BUILD.gn** file in the module directory and select the corresponding template. + + Note that **part_name** in the **BUILD.gn** file is the name of the newly added component. + +2. Create a **bundle.json** file in the folder of the component of the subsystem. + + This step is the same as the step in "Creating a Component and Adding a Module." + +3. Modify the **subsystem_config.json** file in the **build** directory. + + ``` + { + "Subsystem 1 name": { # Existing subsystem 1 + "path": "Subsystem 1 directory", + "name": "Subsystem 1 name" + }, + "Subsystem 2 name": { # Existing subsystem 2 + "path": "Subsystem 2 directory", + "name": "Subsystem 2 name" + }, + "Subsystem name new": { # Subsystem to add + "path": "New subsystem directory", + "name": "New subsystem name" + }, + ... + } + ``` + + This file defines the subsystems and their paths. To add a subsystem, specify **path** and **name** for the subsystem. + +4. If **product-name** in the **//vendor/{product_company}/{product-name}** directory is **hispark_taurus_standard**, add the new component information to the end of existing components in the **config.json** file. + + ``` + "subsystems": [ + { + "subsystem": "arkui", # Name of the existing subsystem + "components": [ # All components of the subsystem + { + "component": "ace_engine_standard", # Name of the existing component + "features": [] + }, + { + "component": "napi", # Name of the existing component + "features": [] + } + { + "component": "component_new1", # Name of the new component added to the existing subsystem + "features": [] + } + ] + }, + { + "subsystem": "subsystem_new", # Name of the new subsystem to add + "components": [ + { + "component": "component_new2", # Name of the component added to the new subsystem + "features": [] + } + ] + }, + ... + ] + ``` + Verification: + - Check that **module_list** in the **BUILD.gn** file in the component directory under the corresponding subsystem directory contains the target defined in the **BUILD.gn** file of the new module. + - Check the .so file or binary file generated in the image created. + +#### Configuration Files + +There are four OpenHarmony configuration files. + +1. **vendor\Product vendor\Product name\config.json** + + ``` + { + "product_name": "MyProduct", + "version": "3.0", + "type": "standard", + "target_cpu": "arm", + "ohos_version": "OpenHarmony 1.0", + "device_company": "MyProductVendor", + "board": "MySOC", + "enable_ramdisk": true, + "subsystems": [ + { + "subsystem": "ace", + "components": [ + { "component": "ace_engine_lite", "features":[""] } + ] + }, + ... ] - public_configs = [ ":helloworld_lib_config" ] - part_name = "partA" + } + + ``` + This file specifies the name, manufacturer, device, version, type of system to be built, and subsystems of the product. + +2. **subsystem_config.json** in the **build** directory + + ``` + { + "arkui": { + "path": "foundation/arkui", + "name": "arkui" + }, + "ai": { + "path": "foundation/ai", + "name": "ai" + }, + ...... } - ``` + ``` + This file contains subsystem information. You need to configure **name** and **path** for each subsystem. + +3. **bundle.json** of a subsystem + + ``` + { + "name": "@ohos/<component_name>, # HPM component name, in the "@Organization/Component name" format. + "description": "xxxxxxxxxxxxxxxxxxx", # Description of the component functions. + "version": "3.1", # Version, which must be the same as the version of OpenHarmony. + "license": "MIT", # Component license. + "publishAs": "code-segment", # Mode for publishing the HPM package. The default value is code-segment. + "segment": { + "destPath": "" + }, # Code restoration path (source code path) when publishAs is code-segment. + "dirs": {}, # Directory structure of the HPM package. This field is mandatory and can be left empty. + "scripts": {}, # Scripts to be executed. This field is mandatory and can be left empty. + "licensePath": "COPYING", + "readmePath": { + "en": "README.rst" + }, + "component": { # Component attributes. + "name": "<component_name>", # Component name. + "subsystem": "", # Subsystem to which the component belongs. + "syscap": [], # System capabilities provided by the component for applications. + "features": [], # List of the component's configurable features. Generally, this parameter corresponds to sub_component in build and can be configured. + "adapted_system_type": [], # Adapted system types, which can be mini, small, and standard. Multiple values are allowed. + "rom": "xxxKB" # ROM baseline. If there is no baseline, enter the current value. + "ram": "xxxKB", # RAM baseline. If there is no baseline, enter the current value. + "deps": { + "components": [], # Other components on which this component depends. + "third_party": [] # Third-party open-source software on which this component depends. + }, + "build": { # Build-related configurations. + "sub_component": ["gn target of the module"], # Component build entry + "inner_kits": [], # APIs between components. + "test": [] # Entry for building the component's test cases. + } + } + } + ``` + The **bundle.json** file defines the components of a subsystem. + + Each component contains the module's target **component.build.sub_component**, **component.build.inner_kits** for interaction between components, and test cases **component.build.test_list**. The **component.build.sub_component** is mandatory. + +4. **BUILD.gn** of each module + + You can create **BUILD.gn** from a template or using the GN syntax. + +### How Do I Build a HAP? + +#### **HAP Description** + +An OpenHarmony Ability Package (HAP) includes resources, raw assets, JS assets, native libraries, and **config.json**. + +#### **Templates** - Example 2: GN script \(**test/examples/partA/feature2/BUILD.gn**\) for building an executable file +The compilation and build subsystem provides four templates for building HAPs. The templates are integrated in **ohos.gni**. Before using the templates, import **build/ohos.gni**. + +1. **ohos_resources** + + This template declares resource targets. After a target is built by restool, an index file is generated. The resource source file and index file are both packaged into the HAP. + + A **ResourceTable.h** file is also generated after resource building. This header file can be referenced if the resource target is relied on. + + The resource target name must end with **resources**, **resource**, or **res**. Otherwise, a build error may occur. + + The following variables are supported: + + - **sources**: a list of resource paths. + - **hap_profile**: **config.json** of the HAP required for resource building. + - **deps**: (optional) dependency of the current target. + +2. **ohos_assets** + + This template declares asset targets. + + Beware that the spelling is "assets" as opposed to "assert". + + The asset target name must end with **assets** or **asset**. + + The following variables are supported: + + - **sources**: a list for raw asset paths. + - **deps**: (optional) dependency of the current target. + +3. **ohos_js_assets** + + This template declares a JS resource target. The JS resource is the executable part of an L2 HAP. + + The JS asset target name must end with **assets** or **asset**. + + The following variables are supported: + + - **source_dir**: JS resource path, which is of the string type. + - **deps**: (optional) dependency of the current target. + +4. **ohos_hap** + + This template declares a HAP target. A HAP that will be generated and packaged into the system image. + + The following variables are supported: + + - **hap_profile**: **config.json** of the HAP. + - **deps**: dependency of the current target. + - **shared_libraries**: native libraries on which the current target depends. + - **hap_name**: (optional) name of the HAP. The default value is the target name. + - **final_hap_path**: (optional) destination path of the HAP. It takes precedence over **hap_name**. + - **subsystem_name**: name of the subsystem to which the HAP belongs. The value must be the same as that in **bundle.json**. Otherwise, the HAP will fail to be installed in the system image. + - **part_name**: name of the component to which the HAP belongs. The value must be the same as that in **bundle.json**. + - **js2abc**: whether to convert the HAP into ARK bytecode. + - **certificate_profile**: certificate profile of the HAP, which is used for signature. For details about signatures, see [Configuring Signature Information](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section17660437768). + - **certificate_file**: Certificate file. You must apply for the certificate and its profile from the official OpenHarmony website. + - **keystore_path**: keystore file, which is used for signature. + - **keystore_password**: keystore password, which is used for signature. + - **key_alias**: key alias. + - **module_install_name**: name of the HAP used during installation. + - **module_install_dir**: installation path. The default path is **system/app**. + +**HAP Example** ``` - ohos_executable("helloworld_bin") { - sources = [ - "src/helloworld2.cpp" + import("//build/ohos.gni") # Import **ohos.gni**. + ohos_hap("clock") { + hap_profile = "./src/main/config.json" # config.json + deps = [ + ":clock_js_assets", # JS assets + ":clock_resources", # Resources ] - include_dirs = [ "include" ] - deps = [ # Dependent submodule - "../feature1:helloworld_lib" + shared_libraries = [ + "//third_party/libpng:libpng", # Native library ] - external_deps = [ "partB:module1" ] # (Optional) If there is a cross-module dependency, the format is "module name: submodule name" - install_enable = true # By default, the executable file is not installed. You need to set this parameter to true for installation. - part_name = "partA" + certificate_profile = "../signature/systemui.p7b" # Certificate profile + hap_name = "SystemUI-NavigationBar" # HAP name + part_name = "prebuilt_hap" + subsystem_name = "applications" + } + ohos_js_assets("clock_js_assets") { + source_dir = "./src/main/js/default" + } + ohos_resources("clock_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" } ``` - Example 3: GN script \(**test/examples/partA/feature3/BUILD.gn**\) for building the etc configuration file \(submodule\). +### What Does an Open-Source Software Notice Collect? - ``` - ohos_prebuilt_etc("feature3_etc") { - source = "src/config.conf" - relative_install_dir = "init" # (Optional) Directory for installing the submodule, which is relative to the default installation directory (/system/etc) - part_name = "partA" - } - ``` +#### Information to Collect - Example 4: Adding the module configuration file **test/examples/ohos.build** to the **ohos.build** file of this subsystem. Each subsystem has an **ohos.build** file in its root directory. Example: +The notice collects only the licenses of the modules packaged in the image. For example, the licenses of the tools (such as Clang, Python, and Ninja) used during the build process are not collected. - ``` - "partA": { - "module_list": [ - "//test/examples/partA/feature1:helloworld_lib", - "//test/examples/partA/feature2:helloworld_bin", - "//test/examples/partA/feature3:feature3_etc", - ], - "inner_kits": [ - - ], - "system_kits": [ - - ], - "test_list": [ - - ] - } - ``` +A static library itself is not packaged. However, if it is packaged into the system as part of a dynamic library or executable file, the license of the static library will be collected for completeness. - The declaration of a module contains the following parts: +The final **Notice.txt** file must include all licenses used by the files in the image and the mapping between modules and licenses. - - **module\_list**: submodule list of the module - - **inner\_kits**: APIs for other modules that depend on this module through **external\_deps** - - **system\_kits**: APIs for developers - - **test\_list**: test cases for the submodules of the module +The **Notice.txt** file is located in the **/system/etc/** directory. -2. Add the module to the product configuration file. +#### Rules for Collecting Information - Add the module to the product configuration file **//vendor/{product_company}/{product-name}/config.json**. +Licenses are collected by priority. - Add "subsystem\_examples:partA" to the product configuration file. **partA** will be built and packaged into the distribution. +1. Licenses that are directly declared in a module's **BUILD.gn** are given the top priority. The following is an example: -3. Build the module. + ``` + ohos_shared_library("example") { + ... + license_file = "path-to-license-file" + ... + } + ``` - For example, run the following command to build hispark_taurus_standard: +2. If there is no explicitly declared license, the build script searches for the **Readme.OpenSource** file in the directory of **BUILD.gn**, parses the file, and collects the obtained licenses. + If the **Readme.OpenSource** file does not contain license information, an error will be reported. - ``` - ./build.sh --product-name hispark_taurus_standard --ccache - ``` +3. If the **Readme.OpenSource** file does not exist, the build script searches for the **License**, **Copyright**, and **Notice** files from the current directory to the root directory of the source code by default. If obtained license information will be used as the licenses of the module. + +4. If no license is found, the default license (Apache License 2.0) will be used. -4. Obtain the build result. +Check items: - Files generated during the build process are stored in the **out/hispark_taurus/** directory, and the generated image is stored in the **out/hispark_taurus/packages/phone/images/** directory. +1. For third-party open-source software, such as OpenSSL and ICU, **Readme.OpenSource** must be configured in the source code directory. Check whether **Readme.OpenSource** is in the same directory as **BUILD.gn** and whether the license configured in **Readme.OpenSource** is valid. +2. If the source code is not licensed under the Apache License 2.0, the corresponding license file must be provided in the source code directory or declared by **license_file** for the module. +3. If the source code file added to **BUILD.gn** is not from the current directory, check whether the license in the repository where the source code file is located is the same as that in the repository of **BUILD.gn**. License inconsistency entails follow-up operations. diff --git a/en/device-dev/subsystems/subsys-data-storage-guide.md b/en/device-dev/subsystems/subsys-data-storage-guide.md index b04c82592a0266a05103a60be2752fa4c4530930..2d577a2ffff46d6ba6b4b40da81fb6f4ae606d58 100644 --- a/en/device-dev/subsystems/subsys-data-storage-guide.md +++ b/en/device-dev/subsystems/subsys-data-storage-guide.md @@ -16,7 +16,7 @@ Create a **Preferences** instance for data operations. A **Preferences** instanc | Class| Method| Description| | --- | ----- | ----| -| PreferencesHelper | static std::shared_ptr<Preferences> GetPreferences(const std::string &path, int &errCode); | Creates a **Preferences** instance. <br/>**path**: storage path of the application data. <br/>**errCode**: error code. <br/>Return value: **Preferences** instance created.| +| PreferencesHelper | static std::shared_ptr<Preferences> GetPreferences(const std::string &path, int &errCode); | Creates a **Preferences** instance. <br>**path**: storage path of the application data.<br>**errCode**: error code.<br>Return value: **Preferences** instance created.| **Writing Data** @@ -26,13 +26,13 @@ Call the **put()** method to add or modify data in a **Preferences** instance. | Class| Method| Description| | --- | ----- | ----| -| Preferences | int PutInt(const std::string &key, int value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutString(const std::string &key, const std::string &value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutBool(const std::string &key, bool value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutLong(const std::string &key, int64_t value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutFloat(const std::string &key, float value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutDouble(const std::string &key, double value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| -| Preferences | int PutStringSet(const std::string &key, const std::set\<std::string\> &value); | **key**: key of the data to write. It cannot be empty. <br/>**value**: value of the data to write. <br/>Return value: error code.| +| Preferences | int PutInt(const std::string &key, int value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutString(const std::string &key, const std::string &value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutBool(const std::string &key, bool value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutLong(const std::string &key, int64_t value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutFloat(const std::string &key, float value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutDouble(const std::string &key, double value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| Preferences | int PutStringSet(const std::string &key, const std::set\<std::string\> &value); | **key**: key of the data to write. It cannot be empty.<br>**value**: value of the data to write.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| **Reading Data** @@ -42,17 +42,17 @@ Call the **get()** method to read data from a **Preferences** instance. | Class| Method| Description| | --- | ----- | ----| -| Preferences | bool GetBool(const std::string &key, bool defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | std::string GetString(const std::string &key, const std::string &defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | bool GetBool(const std::string &key, bool defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | float GetFloat(const std::string &key, float defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | double GetDouble(const std::string &key, double defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | int64_t GetLong(const std::string &key, int64_t defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| -| Preferences | std::set\<std::string\> GetStringSet(const std::string &key, std::set\<std::string\> &defValue); | **key**: key of the data to read. It cannot be empty. <br/>**defValue**: default value to return if the operation fails or the value does not exist. <br/>Return value: Returns the value read if the operation is successful; returns **defValue** otherwise.| +| Preferences | int GetInt(const std::string &key, const int defValue = 0); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | std::string GetString(const std::string &key, const std::string &defValue = {}); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | bool GetBool(const std::string &key, const bool defValue = false); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | float GetFloat(const std::string &key, const float defValue = 0); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | double GetDouble(const std::string &key, const double defValue = 0); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | int64_t GetLong(const std::string &key, const int64_t defValue = 0); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| +| Preferences | std::set\<std::string\> GetStringSet(const std::string &key, const std::set\<std::string\> &defValue = {}); | **key**: key of the data to read. It cannot be empty.<br>**defValue**: default value to return if the operation fails or the value does not exist.<br>Return value: value obtained.| **Storing Data Persistently** -Call the **flush()** or **flushSync** method to write the cached data back to its text file for persistent storage. +Call the **Flush()** or **FlushSync()** method to write the cached data back to its text file for persistent storage. **Table 4** APIs for data persistence @@ -65,12 +65,12 @@ Call the **flush()** or **flushSync** method to write the cached data back to it Specify **PreferencesObserver** as the callback to subscribe to data changes. When the value of the subscribed key is changed and the **flush()** method is executed, **PreferencesObserver** will be invoked. -**Table 5** APIs for subscribing to data changes +**Table 5** APIs for observing data changes | Class| Method| Description| | --- | ----- | ----| -| Preferences | void RegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver); | Subscribes to data changes. <br/>**preferencesObserver**: callback invoked to return the data changes.| -| Preferences | void UnRegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver); | Unsubscribes from data changes. <br/>**preferencesObserver**: callback used to report data changes.| +| Preferences | void RegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver); | Subscribes to data changes. <br>**preferencesObserver**: callback invoked to return the data changes.| +| Preferences | void UnRegisterObserver(std::shared_ptr<PreferencesObserver> preferencesObserver); | Unsubscribes from data changes. <br>**preferencesObserver**: callback used to report data changes.| **Deleting Data** @@ -80,8 +80,8 @@ Use the following APIs to delete a **Preferences** instance or data file. | Class| Method| Description| | --- | ----- | ----| -| PreferencesHelper | int DeletePreferences(const std::string &path); | Deletes a **Preferences** instance from the memory and deletes its file from the device. <br/>**path**: storage path of the application data. <br/>Return value: error code.| -| PreferencesHelper | int RemovePreferencesFromCache(const std::string &path); | Deletes a **Preferences** instance from the memory. <br/>**path**: storage path of the application data. <br/>Return value: error code.| +| PreferencesHelper | int DeletePreferences(const std::string &path); | Deletes a **Preferences** instance from the memory and deletes its file from the device. <br>**path**: storage path of the application data.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| +| PreferencesHelper | int RemovePreferencesFromCache(const std::string &path); | Deletes a **Preferences** instance from the memory. <br>**path**: storage path of the application data.<br>Return value: Returns **0** if the operation is successful; returns the error code otherwise.| ## How to Develop @@ -122,14 +122,13 @@ Use the following APIs to delete a **Preferences** instance or data file. 5. Store data persistently. - Use the **flush()** or **flushSync()** method to flush data in the **Preferences** instance to its file. + Use the **Flush()** or **FlushSync()** method to flush data in the **Preferences** instance to its file. ```C++ int err = pref->FlushSync(); EXPECT_EQ(ret, E_OK); ``` - 6. Subscribe to data changes. Specify **PreferencesObserver** as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and the **flush()** or **flushSync()** method is executed, **PreferencesObserver** will be invoked. Unregister the **PreferencesObserver** when it is no longer required. @@ -144,7 +143,7 @@ Use the following APIs to delete a **Preferences** instance or data file. std::atomic_int notifyTimes; static const std::vector<std::string> NOTIFY_KEYS_VECTOR; }; - + PreferencesObserverCounter::~PreferencesObserverCounter() {} void PreferencesObserverCounter::OnChange(Preferences &preferences, const std::string &key) @@ -156,7 +155,7 @@ Use the following APIs to delete a **Preferences** instance or data file. } } } - + const std::vector<std::string> PreferencesObserverCounter::NOTIFY_KEYS_VECTOR = { PreferencesTest::KEY_TEST_INT_ELEMENT, PreferencesTest::KEY_TEST_LONG_ELEMENT, PreferencesTest::KEY_TEST_FLOAT_ELEMENT, PreferencesTest::KEY_TEST_BOOL_ELEMENT, PreferencesTest::KEY_TEST_STRING_ELEMENT }; @@ -167,17 +166,17 @@ Use the following APIs to delete a **Preferences** instance or data file. std::shared_ptr<PreferencesObserver> counter = std::make_shared<PreferencesObserverCounter>(); pref->RegisterObserver(counter); // Register a callback to return data changes. - + pref->PutString(PreferencesTest::KEY_TEST_STRING_ELEMENT, "test"); pref->Flush(); // Trigger the onChanged callback of the counter. EXPECT_EQ(static_cast<PreferencesObserverCounter *>(counter.get())->notifyTimes, 1); - + /* same value */ pref->PutInt(PreferencesTest::KEY_TEST_INT_ELEMENT, 2); pref->PutString(PreferencesTest::KEY_TEST_STRING_ELEMENT, "test"); pref->Flush(); EXPECT_EQ(static_cast<PreferencesObserverCounter *>(counter.get())->notifyTimes, 2); - + pref->UnRegisterObserver(counter); // Unregister the callback for data changes. ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md index 06033bd48bdd941aa104a3997a323b9359576c62..aad574b94e51306a4130173f8ea8a4a7304b0b39 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @@ -1,99 +1,233 @@ -# HiSysEvent Logging<a name="EN-US_TOPIC_0000001231373947"></a> - -## Overview<a name="section77571101789"></a> - -### Introduction<a name="section123133332175224"></a> - -HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics. - -### Constraints<a name="section123181432175224"></a> - -Before logging system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). - -## Development Guidelines<a name="section314416685113"></a> - -### Available APIs<a name="section13480315886"></a> - -The following table lists the C++ APIs provided by the HiSysEvent class. - -For details about the HiSysEvent class, see the API reference. - -**Table 1** C++ APIs provided by HiSysEvent - -| API| Description| -| -------- | --------- | -| template<typename... Types> static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Logs system events. <br><br>Input arguments: <ul><li>**domain**: Indicates the domain related to the event. You can use a preconfigured domain or customize a domain as needed. The name of a custom domain can contain a maximum of 16 characters, including digits (0-9) and uppercase letters (A-Z). It must start with a letter. </li><li>**eventName**: Indicates the event name. The value contains a maximum of 32 characters, including digits (0 to 9), letters (A-Z), and underscores (_). It must start with a letter and cannot end with an underscore. </li><li>**type**: Indicates the event type. For details, see EventType. </li><li>**keyValues**: Indicates the key-value pairs of event parameters. It can be in the format of the basic data type, std::string, std::vector<basic data type>, or std:vector<std::string>. The value contains a maximum of 48 characters, including digits (0 to 9), letters (A-Z), and underscores (_). It must start with a letter and cannot end with an underscore. The number of parameter names cannot exceed 32. </li></ul>Return value: <ul><li>**0**: The logging is successful. </li><li>Negative value: The logging has failed.</li></ul> | - -**Table 2** Description of HiSysEvent::Domain APIs - -| API| Description| -| -------- | --------- | -| 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 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| -| static const std::string CCRUNTIME |C/C++ operating environment subsystem| -| static const std::string COMMUNICATION | Public communication subsystem| -| static const std::string DEVELOPTOOLS | Development toolchain subsystem| -| static const std::string DISTRIBUTED_DATAMGR | Distributed data management subsystem| -| static const std::string DISTRIBUTED_SCHEDULE | Distributed Scheduler subsystem| -| static const std::string GLOBAL | Globalization subsystem| -| static const std::string GRAPHIC | Graphics subsystem| -| static const std::string HIVIEWDFX | DFX subsystem| -| static const std::string IAWARE | Scheduling and resource management subsystem| -| static const std::string INTELLI_ACCESSORIES | Smart accessory subsystem| -| static const std::string INTELLI_TV | Smart TV subsystem| -| static const std::string IVI_HARDWARE | IVI-dedicated hardware subsystem| -| static const std::string LOCATION | LBS subsystem| -| static const std::string MSDP | MSDP subsystem| -| static const std::string MULTI_MEDIA | Media subsystem| -| static const std::string MULTI_MODAL_INPUT | Multimode input subsystem| -| static const std::string NOTIFICATION | Common event and notification subsystem| -| static const std::string POWERMGR | Power management subsystem| -| static const std::string ROUTER | Router subsystem| -| static const std::string SECURITY | Security subsystem| -| static const std::string SENSORS | Pan-sensor subsystem| -| static const std::string SOURCE_CODE_TRANSFORMER | Application porting subsystem| -| static const std::string STARTUP | Startup subsystem| -| static const std::string TELEPHONY | Telephony subsystem| -| static const std::string UPDATE | Update subsystem| -| static const std::string USB | USB subsystem| -| static const std::string WEARABLE_HARDWARE | Wearable-dedicated hardware subsystem| -| static const std::string WEARABLE_HARDWARE | Wearable-dedicated service subsystem| -| static const std::string OTHERS | Others| - -**Table 3** Description of HiSysEvent::EventType - -| Name| Description| -| -------- | --------- | -| FAULT | Fault event| +# HiSysEvent Logging + +## Overview + +### Introduction + +HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running. Besides, it supports shielding of event logging by event domain, helping you to evaluate the impact of event logging. + +### Working Principles + +Before logging system events, you need to complete HiSysEvent logging configuration. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). + +## Development Guidelines + +### When to Use + +Use HiSysEvent logging to flush logged event data to disks. + +### Available APIs + +#### C++ Event Logging APIs + +HiSysEvent logging is implemented using the API provided by the **HiSysEvent** class. For details, see the API Reference. + +>  **NOTE** +> In OpenHarmony-3.2-Beta3, HiSysEvent logging is open for restricted use to avoid event storms. The **HiSysEvent::Write** API in Table 1 is replaced by the **HiSysEventWrite** API in Table 2. The **HiSysEvent::Write** API has been deprecated. Use the **HiSysEventWrite** API instead for HiSysEvent logging. + +**Table 1** C++ event logging API (deprecated) + +| API | Description | +| ------------------------------------------------------------ | ---------------------- | +| template<typename... Types> <br>static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Flushes logged event data to disks.| + +**Table 2** C++ event logging API (in use) +| API | Description | +| ------------------------------------------------------------ | ---------------------- | +| HiSysEventWrite(domain, eventName, type, ...) | Flushes logged event data to disks.| + + **Table 3** Event types + +| Event | Description | +| --------- | ------------ | +| FAULT | Fault event| +| STATISTIC | Statistical event| +| SECURITY | Security event| +| BEHAVIOR | Behavior event| + +#### Kernel Event Logging APIs + +The following table describes the kernel event logging APIs. + +**Table 4** Description of kernel event logging APIs + +| API | Description | +| ------------------------------------------------------------ | ------------------------------------ | +| struct hiview_hisysevent *hisysevent_create(const char *domain, const char *name, enum hisysevent_type type); | Creates a **hisysevent** object. | +| void hisysevent_destroy(struct hiview_hisysevent *event); | Destroys a **hisysevent** object. | +| int hisysevent_put_integer(struct hiview_hisysevent *event, const char *key, long long value); | Adds event parameters of the integer type to a **hisysevent** object. | +| int hisysevent_put_string(struct hiview_hisysevent *event, const char *key, const char *value); | Adds event parameters of the string type to a **hisysevent** object.| +| int hisysevent_write(struct hiview_hisysevent *event); | Flushes **hisysevent** object data to disks. | + +Table 5 Kernel event types + +| Event | Description | +| --------- | ------------ | +| FAULT | Fault event| | STATISTIC | Statistical event| -| SECURITY | Security event| -| BEHAVIOR | System behavior event| +| SECURITY | Security event| +| BEHAVIOR | Behavior event| + +### How to Develop + +#### C++ Event Logging + +1. Call the event logging API wherever needed, with required event parameters passed to the API. + + ```c++ + HiSysEventWrite(HiSysEvent::Domain::AAFWK, "START_APP", HiSysEvent::EventType::BEHAVIOR, "APP_NAME", "com.ohos.demo"); + ``` + +#### Kernel Event Logging + +1. Create a **hisysevent** object based on the specified event domain, event name, and event type. + + ```c + struct hiview_hisysevent *event = hisysevent_create("KERNEL", "BOOT", BEHAVIOR); + ``` + +2. Pass the customized event parameters to the **hisysevent** object. -### Development Example<a name="section112771171317"></a> + ```c + // Add a parameter of the integer type. + hisysevent_put_integer(event, "BOOT_TIME", 100); -C++ + // Add a parameter of the string type. + hisysevent_put_string(event, "MSG", "This is a test message"); + ``` -1. Develop the source code. +3. Trigger reporting of the **hisysevent** event. - Include the HiSysEvent header file in the class definition header file or class implementation source file. For example: + ```c + hisysevent_write(event); + ``` +4. Manually destroy the **hisysevent** object. + + ```c + hisysevent_destroy(&event); + ``` + +#### Shielding of Event Logging by Event Domain + +1. In the corresponding file, define the **DOMAIN_MASKS** macro with content similar to DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_n. There are three scenarios: + +- Shielding only event logging for the event domains configured in the current source code file: Define the **DOMAIN_MASKS** macro before importing the **.cpp** file to the **hisysevent.h** file. + ```c++ + #define DOMAIN_MASKS "DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_n" + #include "hisysevent.h" + ``` + +- Shielding event logging for event domains of the entire module: Define the **DOMAIN_MASKS** macro in the **BUILD.gn** file of the module. + ```gn + config("module_a"){ + cflags_cc += ["-DDOMAIN_MASKS=\"DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_n\""] + } + ``` + +- Shielding event logging for event domains globally: Define the **DOMAIN_MASKS** macro in **/build/config/compiler/BUILD.gn**. + ```gn + cflags_cc += ["-DDOMAIN_MASKS=\"DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_n\""] + ``` + +2. Perform event logging by using the **HiSysEventWrite** API. + ```c++ + constexpr char DOMAIN[] = "DOMAIN_NAME_1"; + const std::string eventName = "EVENT_NAME1"; + OHOS:HiviewDFX::HiSysEvent::EventType eventType = OHOS:HiviewDFX::HiSysEvent::EventType::FAULT; + HiSysEventWrite(domain, eventName, eventType); // Event logging is shielded for DOMAIN_NAME_1 because it has been defined in the DOMAIN_MASKS macro. + ``` + +### Development Examples + +#### C++ Event Logging + +Assume that a service module needs to trigger event logging during application startup to record the application startup event and application bundle name. The following is the complete sample code: + +1. Add the HiSysEvent component dependency to the **BUILD.gn** file of the service module. + + ```c++ + external_deps = [ "hisysevent_native:libhisysevent" ] + ``` + +2. In the application startup function **StartAbility()** of the service module, call the event logging API with the event parameters passed in. + + ```c++ + #include "hisysevent.h" + + int StartAbility() + { + ... // Other service logic + int ret = HiSysEventWrite(HiSysEvent::Domain::AAFWK, "START_APP", HiSysEvent::EventType::BEHAVIOR, "APP_NAME", "com.ohos.demo"); + ... // Other service logic + } + ``` + +#### Kernel Event Logging + +Assume that the kernel service module needs to trigger event logging during device startup to record the device startup event. The following is the complete sample code: + +1. In the device startup function **device_boot()**, construct a **hisysevent** object. After that, trigger event reporting, and then destroy the **hisysevent** object. + + ```c + #include <dfx/hiview_hisysevent.h> + + #include <linux/errno.h> + #include <linux/printk.h> + + int device_boot() + { + ... // Other service logic + struct hiview_hisysevent *event = NULL; + int ret = 0; + + event = hisysevent_create("KERNEL", "BOOT", BEHAVIOR); + if (!event) { + pr_err("failed to create event"); + return -EINVAL; + } + ret = hisysevent_put_string(event, "MSG", "This is a test message"); + if (ret != 0) { + pr_err("failed to put sting to event, ret=%d", ret); + goto hisysevent_end; + } + ret = hisysevent_write(event); + + hisysevent_end: + hisysevent_destroy(&event); + ... // Other service logic + } ``` + +#### Shielding of Event Logging by Event Domain + +- If you want to shield event logging for the **AAFWK** and **POWER** domains in a **.cpp** file, define the **DOMAIN_MASKS** macro before including the **hisysevent.h** header file to the **.cpp** file. + ```c++ + + #define DOMAIN_MASKS "AAFWK|POWER" + #include "hisysevent.h" - ``` + ... // Other service logic + HiSysEventWrite(OHOS:HiviewDFX::HiSysEvent::Domain::AAFWK, "JS_ERROR", OHOS:HiviewDFX::HiSysEvent::EventType::FAULT, "MODULE", "com.ohos.module"); // HiSysEvent logging is not performed. + ... // Other service logic + HiSysEventWrite(OHOS:HiviewDFX::HiSysEvent::Domain::POWER, "POWER_RUNNINGLOCK", OHOS:HiviewDFX::HiSysEvent::EventType::FAULT, "NAME", "com.ohos.module"); // HiSysEvent logging is not performed. - Add the event logging code. For example, if you want to log events specific to the app start time (start\_app), then add the following code to the service implementation source file: + ``` +- If you want to shield event logging for the **AAFWK** and **POWER** domains of the entire service module, define the **DOMAIN_MASKS** macro as follows in the **BUILG.gn** file of the service module. + ```gn + config("module_a") { + ... // Other configuration items + cflags_cc += ["-DDOMAIN_MASKS=\"AAFWK|POWER\""] + } ``` - HiSysEvent::Write(HiSysEvent::Domain::AAFWK, "start_app", HiSysEvent::EventType::FAULT, "app_name", "com.demo"); + +- If you want to shield event logging for the **AAFWK** and **POWER** domains globally, define the **DOMAIN_MASKS** macro as follows in **/build/config/compiler/BUILD.gn**. + ```gn + ... // Other configuration items + cflags_cc += ["-DDOMAIN_MASKS=\"AAFWK|POWER\""] ``` -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. +# Reference - ``` - external_deps = [ "hisysevent_native:libhisysevent" ] - ``` +The HiSysEvent module writes the logged event data to the node file, and the Hiview module parses and processes the event data in a unified manner. For details, see the [Hiview Development Guide](subsys-dfx-hiview.md). diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..d5ea1ec4528401a14f04d84b4c79b927ff62b29d --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-overview.md @@ -0,0 +1,22 @@ +# HiSysEvent Overview + + +## Introduction + +HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics. + +The key modules of HiSysEvent are described as follows: + +- Event configuration: enables you to define HiSysEvent events in YAML files. + +- Trace point configuration: provides trace point APIs and supports flushing of HiSysEvent events to disks. + +- Event subscription: provides APIs for you to subscribe to HiSysEvent events by event domain and event name. + +- Event query: provides APIs for you to query HiSysEvent events by event domain and event name. + +- Event debugging tool: allows you to subscribe to real-time HiSysEvent events and query historical HiSysEvent events. + +## Reference + +For more information about the source code and usage of HiSysEvent, access the [HiSysEvent code repository](https://gitee.com/openharmony/hiviewdfx_hisysevent). diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md index 7e6b3a45e72d58f6f0b1847b38dc817ef82a8ae3..15fd6220152829b8e8ca6f62551caa25d8a9e088 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @@ -1,12 +1,13 @@ -# HiSysEvent Tool Usage<a name="EN-US_TOPIC_0000001231614021"></a> +# HiSysEvent Tool Usage -## Overview<a name="section1886702718521"></a> + +## Overview The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** directory of the system. You can use this tool to subscribe to real-time system events or query historical system vents. -## Subscribing to Real-Time System Events<a name="section1210623418527"></a> +## Subscribing to Real-Time System Events -- Command for subscribing to real-time system events: +- Command for subscribing to real-time system events: ``` hisysevent -r @@ -15,10 +16,10 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -r | Subscribes to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.| + | -------- | -------- | + | -r | Subscribes to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.| -- Command for enabling the debugging mode: +- Command for enabling the debugging mode: ``` hisysevent -r -d @@ -27,10 +28,10 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -d | Subscribes to real-time system events in debugging mode.| + | -------- | -------- | + | -d | Subscribes to real-time system events in debugging mode.| -- Command for subscribing to real-time system events by event tag: +- Command for subscribing to real-time system events by event tag: ``` hisysevent -r -t <tag> [-c [WHOLE_WORD|PREFIX|REGULAR]] @@ -39,24 +40,22 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -t | Event tag used to filter subscribed real-time system events.| - | -c | Matching rule for event tags. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| + | -------- | -------- | + | -t | Event tag used to filter subscribed real-time system events.| + | -c | Matching rule for event tags. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| Example: ``` - # hisysevent -r -t "TAG" -c PREFIX - {"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_":"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_":"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 "STA" -c PREFIX + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963670809,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805200750","HAPPEN_TIME":1501963670809,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"4973863135535405472","info_":""} + # hisysevent -r -t "STAw{0,6}" -c REGULAR + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963793206,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805200953","HAPPEN_TIME":1501963793206,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} + # hisysevent -r -t "STA\w+" -c REGULAR + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963863393,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201103","HAPPEN_TIME":1501963863393,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"5522352691813553392","info_":""} ``` -- Command for subscribing to real-time system events by event domain and event name: +- Command for subscribing to real-time system events by event domain and event name: ``` hisysevent -r -o <domain> -n <eventName> [-c [WHOLE_WORD|PREFIX|REGULAR]] @@ -65,31 +64,29 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -o | Event domain used to filter subscribed real-time system events.| - | -n | Event name used to filter subscribed real-time system events.| - | -c | Matching rule for event domains and event names. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| + | -------- | -------- | + | -o | Event domain used to filter subscribed real-time system events.| + | -n | Event name used to filter subscribed real-time system events.| + | -c | Matching rule for event domains and event names. The options can be **WHOLE_WORD**, PREFIX, or **REGULAR**.| Example: ``` - # hisysevent -r -o "DOMAINA" -n "EVENTNAMEA" - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - # hisysevent -r -o "DOMA\w{0,10}" -n "EVENT\w+" -c REULAR - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} - # hisysevent -r -o "DOMA\w{0,10}" -c REGULAR - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINABC","name_":"EVENTNAMEB","type_":1,"time_":1501940279938,"tz_":"+0000","pid_":1428,"tid_":1344,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -r -o "RELIABILITY" -n "APP_FREEZE" + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201309","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} + # hisysevent -r -o "RELIABI\w{0,8}" -n "APP_FREEZE" -c REGULAR + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964144383,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201544","HAPPEN_TIME":1501964144383,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"13456525196455104060","info_":""} + # hisysevent -r -o "RELIABI\w+" -c REGULAR + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964193466,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201633","HAPPEN_TIME":1501964193466,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"12675246910904037271","info_":""} ``` - > **NOTE:** - >If **-t**, **-o**, and **-n** are specified, the system checks whether the configured event tag is null. If the event tag is not null, the system filters system events based on the matching rules for the event tag. Otherwise, the system filters system events based on the matching rules for the event domain and event name. + > **NOTE** + > If **-t**, **-o**, and **-n** are specified, the system checks whether the configured event tag is null. If the event tag is not null, the system filters system events based on the matching rules for the event tag. Otherwise, the system filters system events based on the matching rules for the event domain and event name. + -## Querying Historical System Events<a name="section1210623418539"></a> +## Querying Historical System Events -- Command for querying historical system events: +- Command for querying historical system events: ``` hisysevent -l @@ -98,10 +95,10 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -l | Queries historical system events based on the default settings. A maximum of 1,000 latest system events will be returned.| + | -------- | -------- | + | -l | Queries historical system events based on the default settings. A maximum of 1,000 latest system events will be returned.| -- Command for querying historical system events within the specified period of time: +- Command for querying historical system events within the specified period of time: ``` hisysevent -l -s <begin time> -e <end time> @@ -110,21 +107,20 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -s | Start time for querying historical system events. Only system events generated after the start time are returned.| - | -e | End time for querying historical system events. Only system events generated before the end time are returned.| + | -------- | -------- | + | -s | Start time for querying historical system events. Only system events generated after the start time are returned.| + | -e | End time for querying historical system events. Only system events generated before the end time are returned.| Example: ``` - # hisysevent -l -s 20207388633 -e 20207389000 - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -l -s 1501964222980 -e 1501964222996 + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""} + {"domain_":"GRAPHIC","name_":"NO_DRAW","type_":1,"time_":1501964222980,"tz_":"+0000","pid_":1505,"tid_":1585,"uid_":10002,"PID":1505,"UID":10002,"ABILITY_NAME":"","MSG":"It took 1957104259905ns to draw, UI took 0ns to draw, RSRenderThread took 8962625ns to draw, RSRenderThread dropped 0 UI Frames","level_":"MINOR","id_":"1708287249901948387","info_":"isResolved,eventId:0"} + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222994,"tz_":"+0000","pid_":623,"tid_":1445,"uid_":1201,"SUB_EVENT_TYPE":"NO_DRAW","EVENT_TIME":"20170805201702","MODULE":"NO_DRAW","PNAME":"NO_DRAW","REASON":"NO_DRAW","DIAG_INFO":"","STACK":"SUMMARY:\n","HIVIEW_LOG_FILE_PATHS":["/data/log/faultlog/faultlogger/appfreeze-NO_DRAW-10002-20170805201702"],"DOMAIN":"GRAPHIC","STRING_ID":"NO_DRAW","PID":1505,"UID":10002,"PACKAGE_NAME":"NO_DRAW","PROCESS_NAME":"","MSG":"It took 1956945826265ns to draw, UI took 0ns to draw, RSRenderThread took 9863293ns to draw, RSRenderThread dropped 0 UI Frames\n","level_":"CRITICAL","tag_":"STABILITY","id_":"10448522101019619655","info_":""} ``` -- Command for setting the maximum number of historical events that can be queried: +- Command for setting the maximum number of historical events that can be queried: ``` hisysevent -l -m <max hisysevent count> @@ -133,18 +129,36 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Description of command options: | Option| Description| - | -------- | --------- | - | -m | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.| + | -------- | -------- | + | -m | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.| Example: ``` - # hisysevent -l -s 20207388633 -e 20207389000 -m 3 - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - # hisysevent -l -m 2 - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} - {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -l -s 1501964222980 -e 1501964222996 -m 1 + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""} + ``` + +## System Event Validity Check + +- Enabling system event validity check + + ``` + hisysevent -v ``` + + Description of command options: + + | Option| Description| + | -------- | -------- | + | -v | Used with the subscription command **-r** and query command **-l**. If system event validity check is enabled, invalid content contained in system events will be highlighted in red.| + Example: + + ``` + # hisysevent -v -l -s 1501964222980 -e 1501964222996 + # The **HAPPEN_TIME** and **VERSION** fields are not configured in the YAML file for the **APP_FREEZE** event that belongs to the **RELIABILITY** domain. Therefore, the two fields are highlighted in red. + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""} + # hisysevent -v -r -o "RELIABILITY" -n "APP_FREEZE" + {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964644584,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805202404","HAPPEN_TIME":1501964644584,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"11097868872446282676","info_":""} + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent.md b/en/device-dev/subsystems/subsys-dfx-hisysevent.md index aba11496ba72484a72f37b2c3f424156e52085c5..86ceb227152ca26ec2c50a9be11d7c15b9be6adf 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent.md @@ -1,5 +1,7 @@ # HiSysEvent Development<a name="EN-US_TOPIC_0000001195021448"></a> +- **[HiSysEvent Overview](subsys-dfx-hisysevent-overview.md)** + - **[HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md)** - **[HiSysEvent Logging](subsys-dfx-hisysevent-logging.md)** diff --git a/en/device-dev/subsystems/subsys-dfx-hiview.md b/en/device-dev/subsystems/subsys-dfx-hiview.md new file mode 100644 index 0000000000000000000000000000000000000000..34751c841a6857d8cacfc438a22abf4a7273f7ec --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hiview.md @@ -0,0 +1,197 @@ +# Hiview Development Guide + + +## Introduction + + +### Function Overview + +Hiview is a module that provides toolkits for device maintenance across different platforms. It consists of the plugin management platform and the service plugins running on the platform. Hiview works in event-driven mode. The core of Hiview is a collection of HiSysEvent stubs distributed in the system. Formatted events are reported to Hiview through the HiSysEvent API for processing. The following figure shows the data interaction process. + +**Figure 1** Data interaction between Hiview modules + + + +1. The service process calls the event logging API to report logged event information and writes the information to the node file. +2. SysEventSource of the Hiview process asynchronously reads event information from the node file and distributes the event to SysEventPipeline for processing. + - The SysEventService plugin verifies events and flushes them to disks. + - The Faultlogger plugin processes fault-related events. + - The EventLogger plugin collects event-related log information. +3. On completion of event processing, SysEventPipeline sends the events to the event subscription queue and then dispatches the events to the subscription plugin for processing. + - FreezeDetectorPlugin processes screen freezing events. + - HiCollieCollector processes suspension events. + +### Basic Concepts + +Before you get started, familiarize yourself with the following concepts: + +- Plug-in + + An independent module running in the Hiview process. A plugin is delivered with the Hiview binary file to implement maintenance and fault management functions independently. Plug-ins can be disassembled independently during compilation, and can be hosted on the platform during running and dynamically configured. + +- Pipeline + + An ordered set of event processing plugins. Events entering the pipeline are processed by plugins on the pipeline in sequence. + +- Event source + + A special plugin that can produce events. Different from common plugins, a special plugin can be bound to a pipeline, and can produce events and distribute them to the pipeline. + +- Pipeline group + + A group of pipelines configured on the same event source. + +### Working Principles + +Hiview supports plugin development on the plugin management platform and provides the required plugin development capabilities. You can add plugins to the Hiview platform to implement HiSysEvent event processing. Before you get started, you're expected to have a basic understanding of plugin working principles. + +#### Plug-in Registration + +A plugin can be registered in any of the following modes. + +| Mode | Description | +| ------------------ | ------------------------------------------------------------ | +| Static registration | Use the **REGISTER(xxx);** macro to register the plugin. Such a plugin cannot be unloaded.| +| Proxy registration | Use the **REGISTER_PROXY(xxx);** macro to register the plugin. Such a plugin is not loaded upon startup and can be loaded and unloaded dynamically during system running.| +| Proxy registration and loading upon startup| Use the **REGISTER_PROXY_WITH_LOADED(xxx);** macro to register the plugin. Such a plugin is loaded upon startup and can be unloaded and loaded dynamically during system running.| + +#### Plug-in Event-Driven Modes + +There are two event-driven modes available for plugins: pipeline-driven and subscription-driven. The differences are as follows: + +- Pipeline-driven plugins need to be configured on the pipeline. After an event is distributed from an event source to the pipeline, the event traverses the plugins configured on the pipeline in sequence for processing. +- Subscription-driven plugins do not need to be configured on the pipeline. However, a listener needs to be registered with the Hiview platform upon plugin startup, and the plugin needs to implement the event listener function. + +#### Plug-in Loading + +Depending on your service demand, you can compile all or some plugins into the Hiview binary file. + +Multiple plugins can be built into an independent plugin package and preset in the system as an independent **.so** file. One **.so** file corresponds to one **plugin_config** file. For example, **libxxx.z.so** corresponds to the** xxx_plugin_config** file. When the Hiview process starts, it scans for the plugin package (**.so** file) and the corresponding configuration file and loads the plugins in the plugin package. + +The plugin package is described as follows: + +1. The plugin package runs on the plugin management platform as an independent entity. The plugins, pipelines, or event sources in it provide the same functions as the plugins in the Hiview binary. + +2. Plug-ins in the plugin package can be inserted into the Hiview binary pipeline. + + +3. Subscribers, wherever they are located, can receive events sent by the platform based on the subscription rules. + + +## Plug-in Development Guide + + +### When to Use + +You can deploy a plugin on the Hiview platform if you want to perform specific service processing on the HiSysEvent events distributed from the event source. The following table describes the APIs used for plugin development. + +### Available APIs + +The following table lists the APIs related to plugin development. For details about the APIs, see the API Reference. + +Table 1 Description of Plugin APIs + +| API | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| virtual void OnLoad() | Loads plugins. After plugins are loaded, you can call this API to initialize data.| +| virtual void OnUnload() | Unloads plugins. Before plugins are unloaded, you can call this API to reclaim data. | +| virtual bool ReadyToLoad() | Checks whether the current plugin can be loaded when the Hiview starts plugin loading. | +| virtual bool OnEvent(std::shared_ptr\<Event\>& event) | Implements event processing. You can call this API to receive events distributed by the pipeline or platform perform service processing.| +| virtual bool CanProcessEvent(std::shared_ptr\<Event\> event) | Checks whether an event can traverse backward throughout the entire pipeline. This function takes effect only when the plugin is the first one in the pipeline.| +| HiviewContext* GetHiviewContext() | Obtains the context of the Hiview plugin management platform. | + +**Table 2** Description of Event APIs + +| API | Description | +| ---------------------- | ---------------------------- | +| domain_ | Event domain. | +| eventName_ | Event name. | +| happenTime_ | Time when an event occurs. | +| jsonExtraInfo_ | Event data in JSON format. | +| bool IsPipelineEvent() | Whether an event is a pipeline event. | +| bool HasFinish() | Whether an event can continue to traverse backward.| + +### How to Develop + +1. Define a service plugin class, namely, **PluginExample**, which inherits from the **Plugin** class. + + ```c++ + #include "event.h" + #include "plugin.h" + + class PluginExample : public Plugin { + public: + bool OnEvent(std::shared_ptr<Event>& event) override; + void OnLoad() override; + void OnUnload() override; + }; + ``` + +2. In the plugin class implementation code, register the plugin and overwrite the corresponding functions based on the service requirements. + + ```c++ + #include "plugin_factory.h" + + // Register the plugin in static registration mode. + REGISTER(PluginExample); + + void PluginExample::OnLoad() + { + ... // Initialize plugin resources while the plugin is loaded. + printf("PluginExample OnLoad \n"); + } + + void PluginExample::OnUnload() + { + ... // Release plugin resources while the plugin is unloaded. + printf("PluginExample OnUnload \n"); + } + + bool PluginExample::OnEvent(std::shared_ptr<Event>& event) + { + ... // Perform specific service processing on the event using the event processing function. + printf("PluginExample OnEvent \n"); + + // If the plugin focuses only on events of a certain domain, log only the events of this domain. + if (event->domain_ == "TEST_DOMAIN") { + printf("The event data received is %s \n", event->jsonExtraInfo_); + return true; + } + + return false; + } + ``` + +3. Configure the plugin in the **plugin_build.json** file and compile the plugin with the Hiview binary file. + + ```json + { + "plugins": { + "PluginExample": { + "path": "plugins/PluginExample", + "name": "PluginExample" + } + }, + "rules": [ + { + "info": { + "loadorder": { + "PluginExample": { + "loadtime": 0 + } + }, + "pipelines": { + "SysEventPipeline": [ + PluginExample + ] + } + } + } + ] + } + ``` + + +## Reference + +For more information about the source code and usage of HiSysEvent, access the Hiview code repository(https://gitee.com/openharmony/hiviewdfx_hiview). diff --git a/en/device-dev/subsystems/subsys-dfx-overview.md b/en/device-dev/subsystems/subsys-dfx-overview.md index 10d57285496c2534e1f78ea3eecac6bc40449fd9..17f65f4ffd4ef6a59f363fcf80419e6fc2cf9cbe 100644 --- a/en/device-dev/subsystems/subsys-dfx-overview.md +++ b/en/device-dev/subsystems/subsys-dfx-overview.md @@ -12,6 +12,7 @@ The DFX subsystem provides the following functions: - HiChecker: implements defect scanning. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - HiDumper: exports system information. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). - FaultLogger: implements crash detection. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). +- Hiview: implements device maintenance across different platforms. It is applicable to standard-system devices \(reference memory ≥ 128 MiB\). ## Basic Concepts<a name="section5635178134811"></a> diff --git a/en/device-dev/subsystems/subsys-dfx.md b/en/device-dev/subsystems/subsys-dfx.md index 6ede18fca604394d71e5663f631568a7a911561b..f01cb1eb3be14fb4a3519012fdbaf94599b82a0a 100644 --- a/en/device-dev/subsystems/subsys-dfx.md +++ b/en/device-dev/subsystems/subsys-dfx.md @@ -8,3 +8,4 @@ - **[HiSysEvent Development](subsys-dfx-hisysevent.md)** - **[HiDumper Development](subsys-dfx-hidumper.md)** - **[HiChecker Development](subsys-dfx-hichecker.md)** +- **[Hiview Development](subsys-dfx-hiview.md)** diff --git a/en/device-dev/subsystems/subsys-sensor-overview.md b/en/device-dev/subsystems/subsys-sensor-overview.md index baaa934fe1e2b498a5c3668ae2bc6b6b53601a9d..91a8187098ba32d0c7e841f06568947ffaa26b4f 100644 --- a/en/device-dev/subsystems/subsys-sensor-overview.md +++ b/en/device-dev/subsystems/subsys-sensor-overview.md @@ -1,96 +1,31 @@ -# Sensor Overview<a name="EN-US_TOPIC_0000001092893507"></a> +# Service Overview -## Introduction<a name="section667413271505"></a> + +## Introduction The pan-sensor service subsystem provides a lightweight sensor service framework. You can call APIs offered by this framework to query the sensor list, enable or disable a sensor, and subscribe to or unsubscribe from sensor data. The following figure shows the architecture of the lightweight sensor framework. -**Figure 1** Sensor service framework + **Figure 1** Sensor service framework + +  + +- Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler. - +- Sensor Framework: manages sensor data subscription, creates and destroys data channels, and implements communication with the Sensor Service module. -- Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler. -- Sensor Framework: manages sensor data subscription, creates and destroys data channels, and implements communication with the Sensor Service module. -- Sensor Service: interacts with the HDF module to receive, parse, and distribute data, manages sensors on hardware and sensor data reporting, and controls sensor permissions. +- Sensor Service: interacts with the HDF module to receive, parse, and distribute data, manages sensors on hardware and sensor data reporting, and controls sensor permissions. -## Available APIs<a name="section7255104114110"></a> -**Table 1** APIs of the sensor framework +## Available APIs -<a name="table203963834718"></a> -<table><thead align="left"><tr id="row173964834716"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p20921103144918"><a name="p20921103144918"></a><a name="p20921103144918"></a>Function</p> -</th> -<th class="cellrowborder" valign="top" width="25.722572257225725%" id="mcps1.2.4.1.2"><p id="p109216317495"><a name="p109216317495"></a><a name="p109216317495"></a>Description</p> -</th> -<th class="cellrowborder" valign="top" width="40.94409440944094%" id="mcps1.2.4.1.3"><p id="p1192112316497"><a name="p1192112316497"></a><a name="p1192112316497"></a>Parameter</p> -</th> -</tr> -</thead> -<tbody><tr id="row4397198154712"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p11001322173912"><a name="p11001322173912"></a><a name="p11001322173912"></a>int32_t <strong id="b792815314396"><a name="b792815314396"></a><a name="b792815314396"></a>GetAllSensors</strong>(SensorInfo **sensorInfo, int32_t *count)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p199227318499"><a name="p199227318499"></a><a name="p199227318499"></a>Obtains information about all sensors in the system.</p> -<p id="p9922153110492"><a name="p9922153110492"></a><a name="p9922153110492"></a><strong id="b2922183114917"><a name="b2922183114917"></a><a name="b2922183114917"></a>Return value</strong>: Returns <strong id="b15367115154516"><a name="b15367115154516"></a><a name="b15367115154516"></a>0</strong> if the information is obtained; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p4922173116498"><a name="p4922173116498"></a><a name="p4922173116498"></a><strong id="b633817407478"><a name="b633817407478"></a><a name="b633817407478"></a>sensorInfo</strong> (not NULL): information about all sensors in the system</p> -<p id="p18922931134919"><a name="p18922931134919"></a><a name="p18922931134919"></a><strong id="b8845650154711"><a name="b8845650154711"></a><a name="b8845650154711"></a>count</strong> (not NULL): total number of sensors in the system</p> -</td> -</tr> -<tr id="row1839716854716"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p38874252376"><a name="p38874252376"></a><a name="p38874252376"></a>int32_t <strong id="b17835184513919"><a name="b17835184513919"></a><a name="b17835184513919"></a>SubscribeSensor</strong>(int32_t sensorTypeId, SensorUser *user)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p14922113114914"><a name="p14922113114914"></a><a name="p14922113114914"></a>Subscribes to sensor data. The system will report the obtained sensor data to the subscriber.</p> -<p id="p5922331114916"><a name="p5922331114916"></a><a name="p5922331114916"></a><strong id="b7756437172"><a name="b7756437172"></a><a name="b7756437172"></a>Return value</strong>: Returns <strong id="b37618371173"><a name="b37618371173"></a><a name="b37618371173"></a>0</strong> if the subscription is successful; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p17922183120490"><a name="p17922183120490"></a><a name="p17922183120490"></a><strong id="b383183812561"><a name="b383183812561"></a><a name="b383183812561"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p8922193154917"><a name="p8922193154917"></a><a name="p8922193154917"></a><strong id="b15825101814564"><a name="b15825101814564"></a><a name="b15825101814564"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -</td> -</tr> -<tr id="row6397138134713"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p6923143184914"><a name="p6923143184914"></a><a name="p6923143184914"></a>int32_t <strong id="b338673044313"><a name="b338673044313"></a><a name="b338673044313"></a>UnsubscribeSensor</strong>(int32_t sensorTypeId, SensorUser *user)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p792383116495"><a name="p792383116495"></a><a name="p792383116495"></a>Unsubscribes from sensor data. The system will no longer report sensor data to the subscriber.</p> -<p id="p139231531184912"><a name="p139231531184912"></a><a name="p139231531184912"></a><strong id="b1698214914415"><a name="b1698214914415"></a><a name="b1698214914415"></a>Return value</strong>: Returns <strong id="b20983690447"><a name="b20983690447"></a><a name="b20983690447"></a>0</strong> if the unsubscription is successful; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p178981446572"><a name="p178981446572"></a><a name="p178981446572"></a><strong id="b5189141634413"><a name="b5189141634413"></a><a name="b5189141634413"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p178988410573"><a name="p178988410573"></a><a name="p178988410573"></a><strong id="b56761418164417"><a name="b56761418164417"></a><a name="b56761418164417"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -</td> -</tr> -<tr id="row43981283476"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p992473112496"><a name="p992473112496"></a><a name="p992473112496"></a>int32_t <strong id="b16691194511438"><a name="b16691194511438"></a><a name="b16691194511438"></a>SetBatch</strong>(int32_t sensorTypeId, SensorUser *user, int64_t samplingInterval, int64_t reportInterval)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p14924831124913"><a name="p14924831124913"></a><a name="p14924831124913"></a>Sets the data sampling interval and data reporting interval for the specified sensor.</p> -<p id="p14924203134910"><a name="p14924203134910"></a><a name="p14924203134910"></a><strong id="b181731732463"><a name="b181731732463"></a><a name="b181731732463"></a>Return value</strong>: Returns <strong id="b417363104616"><a name="b417363104616"></a><a name="b417363104616"></a>0</strong> if the setting is successful; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p189243318494"><a name="p189243318494"></a><a name="p189243318494"></a><strong id="b4102102264610"><a name="b4102102264610"></a><a name="b4102102264610"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p167364493594"><a name="p167364493594"></a><a name="p167364493594"></a><strong id="b930712416461"><a name="b930712416461"></a><a name="b930712416461"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -<p id="p1692403115493"><a name="p1692403115493"></a><a name="p1692403115493"></a><strong id="b1866310191589"><a name="b1866310191589"></a><a name="b1866310191589"></a>samplingInterval</strong>: sensor data sampling interval, in nanoseconds</p> -<p id="p392443174917"><a name="p392443174917"></a><a name="p392443174917"></a><strong id="b851892113817"><a name="b851892113817"></a><a name="b851892113817"></a>reportInterval</strong>: sensor data reporting interval, in nanoseconds</p> -</td> -</tr> -<tr id="row439813812472"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p17925631194911"><a name="p17925631194911"></a><a name="p17925631194911"></a>int32_t <strong id="b12311455154316"><a name="b12311455154316"></a><a name="b12311455154316"></a>ActivateSensor</strong>(int32_t sensorTypeId, SensorUser *user)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p1892583174920"><a name="p1892583174920"></a><a name="p1892583174920"></a>Enables the specified sensor that has been subscribed to.</p> -<p id="p16925113119497"><a name="p16925113119497"></a><a name="p16925113119497"></a><strong id="b1190011547620"><a name="b1190011547620"></a><a name="b1190011547620"></a>Return value</strong>: Returns <strong id="b1690019543620"><a name="b1690019543620"></a><a name="b1690019543620"></a>0</strong> if the sensor is successfully enabled; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p59255313493"><a name="p59255313493"></a><a name="p59255313493"></a><strong id="b269629475"><a name="b269629475"></a><a name="b269629475"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p1692517314499"><a name="p1692517314499"></a><a name="p1692517314499"></a><strong id="b1739417117716"><a name="b1739417117716"></a><a name="b1739417117716"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -</td> -</tr> -<tr id="row123998813470"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p492513120494"><a name="p492513120494"></a><a name="p492513120494"></a>int32_t <strong id="b1612146204413"><a name="b1612146204413"></a><a name="b1612146204413"></a>DeactivateSensor</strong>(int32_t sensorTypeId, SensorUser *user)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p12925143118492"><a name="p12925143118492"></a><a name="p12925143118492"></a>Disables an enabled sensor.</p> -<p id="p5926031124914"><a name="p5926031124914"></a><a name="p5926031124914"></a><strong id="b13736235877"><a name="b13736235877"></a><a name="b13736235877"></a>Return value</strong>: Returns <strong id="b273720356714"><a name="b273720356714"></a><a name="b273720356714"></a>0</strong> if the sensor is successfully disabled; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p1692683112499"><a name="p1692683112499"></a><a name="p1692683112499"></a><strong id="b1452911411574"><a name="b1452911411574"></a><a name="b1452911411574"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p1081949113"><a name="p1081949113"></a><a name="p1081949113"></a><strong id="b11188443178"><a name="b11188443178"></a><a name="b11188443178"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -</td> -</tr> -<tr id="row939914814478"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p11530101054411"><a name="p11530101054411"></a><a name="p11530101054411"></a>int32_t <strong id="b1999420216444"><a name="b1999420216444"></a><a name="b1999420216444"></a>SetMode</strong>(int32_t sensorTypeId, SensorUser *user, int32_t mode)</p> -</td> -<td class="cellrowborder" valign="top" width="25.722572257225725%" headers="mcps1.2.4.1.2 "><p id="p892633118493"><a name="p892633118493"></a><a name="p892633118493"></a>Sets the data reporting mode for the specified sensor.</p> -<p id="p1927031114910"><a name="p1927031114910"></a><a name="p1927031114910"></a><strong id="b456216221484"><a name="b456216221484"></a><a name="b456216221484"></a>Return value</strong>: Returns <strong id="b12562112214811"><a name="b12562112214811"></a><a name="b12562112214811"></a>0</strong> if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.</p> -</td> -<td class="cellrowborder" valign="top" width="40.94409440944094%" headers="mcps1.2.4.1.3 "><p id="p119277312492"><a name="p119277312492"></a><a name="p119277312492"></a><strong id="b19747144015816"><a name="b19747144015816"></a><a name="b19747144015816"></a>sensorTypeId</strong>: ID of a sensor type</p> -<p id="p159271031184915"><a name="p159271031184915"></a><a name="p159271031184915"></a><strong id="b1367209917"><a name="b1367209917"></a><a name="b1367209917"></a>user</strong> (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.</p> -<p id="p0927173154916"><a name="p0927173154916"></a><a name="p0927173154916"></a><strong id="b3914356101520"><a name="b3914356101520"></a><a name="b3914356101520"></a>mode</strong>: data reporting mode of the sensor</p> -</td> -</tr> -</tbody> -</table> + **Table 1** APIs of the sensor framework +| API| Description| Parameter| +| -------- | -------- | -------- | +| int32_t **GetAllSensors**( <br> SensorInfo \*\*sensorIn <br> fo, int32_t \*count) | Obtains information about all sensors in the system.<br>**Return value**: Returns **0** if the information is obtained; returns a non-zero value otherwise.| **sensorInfo** (not NULL): information about all sensors in the system<br>**count** (not NULL): total number of sensors in the system| +| int32_t **SubscribeSensor** <br> (int32_t sensorTypeId, <br> SensorUser \*user) | Subscribes to sensor data. The system will report the obtained sensor data to the subscriber.<br>**Return value**: Returns **0** if the subscription is successful; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| +| int32_t **UnsubscribeSensor** <br> (int32_t sensorTypeId, SensorUser \*user) | Unsubscribes from sensor data. The system will no longer report sensor data to the subscriber.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| +| int32_t **SetBatch**(int32_t sensorTypeId, SensorUser <br> \*user, int64_t samplingInterval, int64_t reportInterval) | Sets the data sampling interval and data reporting interval for the specified sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.<br>**samplingInterval**: sensor data sampling interval, in nanoseconds<br>**reportInterval**: sensor data reporting interval, in nanoseconds| +| int32_t **ActivateSensor**(int32_t sensorTypeId, <br> SensorUser \*user) | Enables the specified sensor that has been subscribed to.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| +| int32_t **DeactivateSensor**(int32_t sensor <br> TypeId, SensorUser \*user) | Disables an enabled sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.| +| int32_t **SetMode**(int32_t sensorTypeId, <br> SensorUser \*user, int32_t mode) | Sets the data reporting mode for the specified sensor.<br>**Return value**: Returns **0** if the sensor data reporting mode is successfully set; returns a non-zero value otherwise.| **sensorTypeId**: ID of a sensor type<br>**user** (not NULL): sensor subscriber that requests sensor data. A subscriber can obtain data from only one sensor.<br>**mode**: data reporting mode of the sensor| diff --git a/en/device-dev/subsystems/subsys-xts-guide.md b/en/device-dev/subsystems/subsys-xts-guide.md index d9ee3223e3aa282f5e7e847a07f7a20b00c628c5..90992e3e0449cd9a883ba5ddba171f5ae8fefb9d 100644 --- a/en/device-dev/subsystems/subsys-xts-guide.md +++ b/en/device-dev/subsystems/subsys-xts-guide.md @@ -2,7 +2,7 @@ ## Introduction -The X test suite \(XTS\) subsystem contains a set of OpenHarmony compatibility test suites, including the currently supported application compatibility test suite \(ACTS\) and the device compatibility test suite \(DCTS\) that will be supported in the future. +The X test suite (XTS) subsystem contains a set of OpenHarmony compatibility test suites, including the currently supported application compatibility test suite (ACTS) and the device compatibility test suite (DCTS) that will be supported in the future. This subsystem contains the ACTS and **tools** software package. @@ -19,7 +19,7 @@ OpenHarmony supports the following systems: - Small system - A small system runs on a device that comes with memory greater than or equal to 1 MiB and application processors such as ARM Cortex-A. It provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, and routers, and event data recorders \(EDRs\) for smart travel. + A small system runs on a device that comes with memory greater than or equal to 1 MiB and application processors such as ARM Cortex-A. It provides higher security capabilities, standard graphics frameworks, and video encoding and decoding capabilities. Typical products include smart home IP cameras, electronic cat eyes, and routers, and event data recorders (EDRs) for smart travel. - Standard system @@ -34,7 +34,7 @@ OpenHarmony supports the following systems: │ └── subsystem # Source code of subsystem test cases for the standard system │ └── subsystem_lite # Source code of subsystems test cases for mini and small systems │ └── BUILD.gn # Build configuration of test cases for the standard system -│ └── build_lite +│ └── build_lite # Build configuration of test cases for the mini and small systems. │ └── BUILD.gn # Build configuration of test cases for mini and small systems └── tools # Test tool code ``` @@ -72,9 +72,9 @@ Test cases for the mini system must be developed in C, and those for the small s | Performance | Tests the processing capability of the tested object under specific preset conditions and load models. The processing capability is measured by the service volume that can be processed in a unit time, for example, call per second, frame per second, or event processing volume per second. | | Power | Tests the power consumption of the tested object in a certain period of time under specific preset conditions and load models. | | Reliability | Tests the service performance of the tested object under common and uncommon input conditions, or specified service volume pressure and long-term continuous running pressure. The test covers stability, pressure handling, fault injection, and Monkey test times. | -| Security | <ul><li>Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.</li><li>Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.</li><li>Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT).</li></ul> | +| Security | Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.<br/>Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.<br/> Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT). | | Global | Tests the internationalized data and localization capabilities of the tested object, including multi-language display, various input/output habits, time formats, and regional features, such as currency, time, and culture taboos. | -| Compatibility | <ul><li>Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.</li><li>Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.</li><li>Tests software compatibility with related hardware.</li></ul> | +| Compatibility | Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.<br/>Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.<br/>Tests software compatibility with related hardware. | | User | Tests user experience of the object in real user scenarios. All conclusions and comments should come from the users, which are all subjective evaluation in this case. | | Standard | Tests the compliance with industry and company-specific standards, protocols, and specifications. The standards here do not include any security standards that should be classified into the security test. | | Safety | Tests the safety property of the tested object to avoid possible hazards to personal safety, health, and the object itself. | @@ -92,107 +92,109 @@ The test framework and programming language vary with the system type. | Small | HCPPTest | C++ | | Standard | HJSUnit and HCPPTest | JavaScript and C++ | -### Developing Test Cases in C (for the Mini System\) +### Developing Test Cases in C (for the Mini System) **Developing Test Cases for the Mini System** HCTest and the C language are used to develop test cases. HCTest is enhanced and adapted based on the open-source test framework Unity. -1. Define the test case directory. The test cases are stored to **test/xts/acts**. +1. Define the test case directory. The test cases are stored to **test/xts/acts**. + + ``` + ├── acts + │ └──subsystem_lite + │ │ └── module_hal + │ │ │ └── BUILD.gn + │ │ │ └── src + │ └──build_lite + │ │ └── BUILD.gn + ``` - ``` - ├── acts - │ └──subsystem_lite - │ │ └── module_hal - │ │ │ └── BUILD.gn - │ │ │ └── src - │ └──build_lite - │ │ └── BUILD.gn - ``` 2. Write the test case in the **src** directory. - a) Include the test framework header file. + (1) Include the test framework header file. - ``` - #include "hctest.h" - ``` + ``` + #include "hctest.h" + ``` - b) Use the **LITE\_TEST\_SUIT** macro to define names of the subsystem, module, and test suite. + (2) Use the **LITE_TEST_SUIT** macro to define names of the subsystem, module, and test suite. - ``` - /** - * @brief Registers a test suite named IntTestSuite. - * @param test Subsystem name - * @param example Module name - * @param IntTestSuite Test suite name - */ - LITE_TEST_SUIT(test, example, IntTestSuite); - ``` + ``` + /** + * @brief register a test suite named "IntTestSuite" + * @param test subsystem name + * @param example module name + * @param IntTestSuite test suite name + */ + LITE_TEST_SUIT(test, example, IntTestSuite); + ``` - c) Define Setup and TearDown. + (3) Define Setup and TearDown. - ​ Format: Test suite name+Setup, Test suite name+TearDown. + Format: Test suite name+Setup, Test suite name+TearDown. + The Setup and TearDown functions must exist, but function bodies can be empty. + + (4) Use the **LITE_TEST_CASE** macro to write the test case. - ​ The Setup and TearDown functions must exist, but function bodies can be empty. + Three parameters are involved: test suite name, test case name, and test case properties (including type, granularity, and level). + + ``` + LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1) + { + // Do something. + }; + ``` + + (5) Use the **RUN_TEST_SUITE** macro to register the test suite. - d) Use the **LITE\_TEST\_CASE** macro to write the test case. + ``` + RUN_TEST_SUITE(IntTestSuite); + ``` - ​ Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\). +3. Create the configuration file (**BUILD.gn**) of the test module. - ``` - LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1) - { - // Do something - }; - ``` + Create a **BUILD.gn** (example) file in each test module directory, and specify the name of the built static library and its dependent header files and libraries. - e) Use the **RUN\_TEST\_SUITE** macro to register the test suite. + The format is as follows: ``` - RUN_TEST_SUITE(IntTestSuite); + import("//test/xts/tools/lite/build/suite_lite.gni") + hctest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/test_demo.c", + ] + include_dirs = [ ] + cflags = [ "-Wno-error" ] + } ``` -3. Create the configuration file \(**BUILD.gn**\) of the test module. - - Create a **BUILD.gn** \(example\) file in each test module directory, and specify the name of the built static library and its dependent header files and libraries. The format is as follows: - - ``` - import("//test/xts/tools/lite/build/suite_lite.gni") - hctest_suite("ActsDemoTest") { - suite_name = "acts" - sources = [ - "src/test_demo.c", - ] - include_dirs = [ ] - cflags = [ "-Wno-error" ] - } - ``` +4. Add build options to the **BUILD.gn** file in the **acts** directory. -4. Add build options to the **BUILD.gn** file in the **acts** directory. + You need to add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. - You need to add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. - - ``` - lite_component("acts") { - ... - if(board_name == "liteos_m") { - features += [ - ... - "//xts/acts/subsystem_lite/module_hal:ActsDemoTest" - ] - } - } - ``` + ``` + lite_component("acts") { + ... + if(board_name == "liteos_m") { + features += [ + ... + "//xts/acts/subsystem_lite/module_hal:ActsDemoTest" + ] + } + } + ``` -5. Run build commands. +5. Run build commands. - Test suites are built along with the OS version. The ACTS is built together with the debug version. + Test suites are built along with the OS version. The ACTS is built together with the debug version. - > **NOTE**<br/> The ACTS build middleware is a static library, which will be linked to the image. + > **NOTE**<br/> The ACTS build middleware is a static library, which will be linked to the image. -### Executing Test Cases in C (for the Mini System\) +### Executing Test Cases in C (for the Mini System) **Executing Test Cases for the Mini System** @@ -211,120 +213,122 @@ The log for each test suite starts with "Start to run test suite:" and ends wit ### Developing Test Cases in C++ (for Standard and Small Systems) -**Developing Test Cases for Small-System Devices** \(for the standard system, see the **global/i18n\_standard directory**.\) +**Developing Test Cases for Small-System Devices** (for the standard system, see the **global/i18n_standard directory**.) The HCPPTest framework, an enhanced version based on the open-source framework Googletest, is used. -1. Define the test case directory. The test cases are stored to **test/xts/acts**. - - ``` - ├── acts - │ └──subsystem_lite - │ │ └── module_posix - │ │ │ └── BUILD.gn - │ │ │ └── src - │ └──build_lite - │ │ └── BUILD.gn - ``` - -2. Write the test case in the **src** directory. - - a) Include the test framework header file. - - ​ The following statement includes **gtest.h**. +1. Define the test case directory. The test cases are stored to **test/xts/acts**. ``` - #include "gtest/gtest.h" + ├── acts + │ └──subsystem_lite + │ │ └── module_posix + │ │ │ └── BUILD.gn + │ │ │ └── src + │ └──build_lite + │ │ └── BUILD.gn ``` - b) Define Setup and TearDown. - - ``` - using namespace std; - using namespace testing::ext; - class TestSuite: public testing::Test { - protected: - // Preset action of the test suite, which is executed before the first test case - static void SetUpTestCase(void){ - } - // Test suite cleanup action, which is executed after the last test case - static void TearDownTestCase(void){ - } - // Preset action of the test case - virtual void SetUp() - { - } - // Cleanup action of the test case - virtual void TearDown() - { - } - }; - ``` - - c) Use the **HWTEST** or **HWTEST\_F** macro to write the test case. - - ​ **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation. - - ​ **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation. - - ​ Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\). +2. Write the test case in the **src** directory. - ``` - HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) { - // Do something - } - ``` + (1) Include the test framework. + + Include **gtest.h**. + ``` + #include "gtest/gtest.h" + ``` + + + (2) Define Setup and TearDown. + + ``` + using namespace std; + using namespace testing::ext; + class TestSuite: public testing::Test { + protected: + // Preset action of the test suite, which is executed before the first test case + static void SetUpTestCase(void){ + } + // Test suite cleanup action, which is executed after the last test case + static void TearDownTestCase(void){ + } + // Preset action of the test case + virtual void SetUp() + { + } + // Cleanup action of the test case + virtual void TearDown() + { + } + }; + ``` + + + (3) Use the **HWTEST** or **HWTEST_F** macro to write the test case. + + **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation. + + **HWTEST_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation. + + Three parameters are involved: test suite name, test case name, and test case properties (including type, granularity, and level). + + ``` + HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) { + // Do something + ``` -3. Create a configuration file \(**BUILD.gn**\) of the test module. +3. Create a configuration file (**BUILD.gn**) of the test module. Create a **BUILD.gn** file in each test module directory, and specify the name of the built static library and its dependent header files and libraries. Each test module is independently built into a **.bin** executable file, which can be directly pushed to the development board for testing. Example: - - ``` - import("//test/xts/tools/lite/build/suite_lite.gni") - hcpptest_suite("ActsDemoTest") { - suite_name = "acts" - sources = [ - "src/TestDemo.cpp" - ] - - include_dirs = [ - "src", - ... - ] - deps = [ - ... - ] - cflags = [ "-Wno-error" ] - } + + ``` + import("//test/xts/tools/lite/build/suite_lite.gni") + hcpptest_suite("ActsDemoTest") { + suite_name = "acts" + sources = [ + "src/TestDemo.cpp" + ] + + include_dirs = [ + "src", + ... + ] + deps = [ + ... + ] + cflags = [ "-Wno-error" ] + } + ``` - ``` - 4. Add build options to the **BUILD.gn** file in the **acts** directory. - Add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. + Add the test module to the **test/xts/acts/build_lite/BUILD.gn** script in the **acts** directory. + + ``` + lite_component("acts") { + ... + else if(board_name == "liteos_a") { + features += [ + ... + "//xts/acts/subsystem_lite/module_posix:ActsDemoTest" + ] + } + } + ``` - ``` - lite_component("acts") { - ... - else if(board_name == "liteos_a") { - features += [ - ... - "//xts/acts/subsystem_lite/module_posix:ActsDemoTest" - ] - } - } - ``` 5. Run build commands. Test suites are built along with the OS version. The ACTS is built together with the debug version. - > **NOTE**<br/> The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the **suites\\acts** directory of the build result. + > **NOTE** + > + >The ACTS for the small system is independently built to an executable file (.bin) and archived in the **suites\acts** directory of the build result. -### Executing Test Cases in C++ (for Standard and Small Systems\) +### Executing Test Cases in C++ (for Standard and Small Systems) **Executing Test Cases for the Small System** @@ -332,24 +336,29 @@ Currently, test cases are shared by the NFS and mounted to the development board **Setting Up the Environment** -1. Use a network cable or wireless network to connect the development board to your PC. -2. Configure the IP address, subnet mask, and gateway for the development board. Ensure that the development board and the PC are in the same network segment. -3. Install and register the NFS server on the PC and start the NFS service. +1. Use a network cable or wireless network to connect the development board to your PC. + +2. Configure the IP address, subnet mask, and gateway for the development board. Ensure that the development board and the PC are in the same network segment. + +3. Install and register the NFS server on the PC and start the NFS service. + 4. Run the **mount** command for the development board to ensure that the development board can access NFS shared files on the PC. Format: **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_development board directory_ **nfs** - Example: + Example: ``` mount 192.168.1.10:/nfs /nfs nfs ``` + + **Executing Test Cases** Execute **ActsDemoTest.bin** to trigger test case execution, and analyze serial port logs generated after the execution is complete. -### Developing Test Cases in JavaScript (for the Standard System\) +### Developing Test Cases in JavaScript (for the Standard System) The HJSUnit framework is used to support automated test of OpenHarmony apps that are developed using the JavaScript language based on the JS application framework. @@ -366,73 +375,82 @@ The test cases are developed with the JavaScript language and must meet the prog | beforeEach | Presets a test-case-level action executed before each test case is executed. The number of execution times is the same as the number of test cases defined by it. You can pass the action function as the only parameter. | No | | afterEach | Presets a test-case-level clear action executed after each test case is executed. The number of execution times is the same as the number of test cases defined by it. You can pass the clear function as the only parameter. | No | | describe | Defines a test suite. You can pass two parameters: test suite name and test suite function. The describe statement supports nesting. You can use beforeall, beforeEach, afterEach, and afterAll in each describe statement. | Yes | -| it | Defines a test case. You can pass three parameters: test case name, filter parameter, and test case function. <br>**Usage of the filter parameter:** <br>The value of the filter parameter is a 32-bit integer. Setting different bits to 1 means different configurations: <br><ul><li>Bit 0: whether the filter parameter takes effect. 1 means that the test case is used for the function test and other settings of the parameter do not take effect.</li><li>Bits 0-10: test case categories</li><li>Bits 16-18: test case scales</li><li>Bits 24-28: test levels</li></ul>**Test case categories**: Bits 0-10 indicate FUNCTION (function test), PERFORMANCE (performance test), POWER (power consumption test), RELIABILITY (reliability test), SECURITY (security compliance test), GLOBAL (integrity test), COMPATIBILITY (compatibility test), USER (user test), STANDARD (standard test), SAFETY (security feature test), and RESILIENCE (resilience test), respectively. <br>**Test case scales**: Bits 16-18 indicate SMALL (small-scale test), MEDIUM (medium-scale test), and LARGE (large-scale test), respectively. <br>**Test levels**: Bits 24-28 indicate LEVEL0 (level-0 test), LEVEL1 (level-1 test), LEVEL2 (level-2 test), LEVEL3 (level-3 test), and LEVEL4 (level-4 test), respectively. | Yes | +| it | Defines a test case. You can pass three parameters: test case name, filter parameter, and test case function. <br>**Filter parameter:** <br/>The value is a 32-bit integer. Setting different bits to 1 means different configurations.<br/> - Setting bit 0 to **1** means bypassing the filter. <br>- Setting bits 0-10 to **1** specifies the test case type, which can be FUNCTION (function test), PERFORMANCE (performance test), POWER (power consumption test), RELIABILITY (reliability test), SECURITY (security compliance test), GLOBAL (integrity test), COMPATIBILITY (compatibility test), USER (user test), STANDARD (standard test), SAFETY (security feature test), and RESILIENCE (resilience test), respectively.<br>- Setting bits 16-18 to **1** specifies the test case scale, which can be SMALL (small-scale test), MEDIUM (medium-scale test), and LARGE (large-scale test), respectively.<br>- Seting bits 24-28 to **1** specifies the test level, which can be LEVEL0 (level-0 test), LEVEL1 (level-1 test), LEVEL2 (level-2 test), LEVEL3 (level-3 test), and LEVEL4 (level-4 test), respectively.<br> | Yes | Use the standard syntax of Jasmine to write test cases. The ES6 specification is supported. 1. Define the test case directory. The test cases are stored in the **entry/src/main/js/test** directory. ``` - ├── BUILD.gn - │ └──entry - │ │ └──src - │ │ │ └──main - │ │ │ │ └──js - │ │ │ │ │ └──default - │ │ │ │ │ │ └──pages - │ │ │ │ │ │ │ └──index - │ │ │ │ │ │ │ │ └──index.js # Entry file - │ │ │ │ │ └──test # Test code - │ │ │ └── resources # HAP resources - │ │ │ └── config.json # HAP configuration file - ``` + ├── BUILD.gn + │ └──entry + │ │ └──src + │ │ │ └──main + │ │ │ │ └──js + │ │ │ │ │ └──default + │ │ │ │ │ │ └──pages + │ │ │ │ │ │ │ └──index + │ │ │ │ │ │ │ │ └──index.js # Entry file + │ │ │ │ │ └──test # Test code directory + │ │ │ └── resources # HAP resources + │ │ │ └── config.json # HAP configuration file + ``` -2. Start the JS test framework and load test cases. The following is an example for **index.js**. - ``` - // Start the JS test framework and load test cases. +2. Start the JS test framework and load test cases. + + The following is an example for **index.js**. + + ``` + // Start the JS test framework and load test cases. import {Core, ExpectExtend} from 'deccjsunit/index' export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, - } - ``` + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, + } + ``` -3. Write a unit test case by referring to the following example: + - ``` - // Use HJSUnit to perform the unit test. - describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) - }) - ``` +3. Write a unit test case. + + The following is an example: + + ``` + // Example 1: Use HJSUnit to perform a unit test. + describe('appInfoTest', function () { + it('app_info_test_001', 0, function () { + var info = app.getInfo() + expect(info.versionName).assertEqual('1.0') + expect(info.versionCode).assertEqual('3') + }) + }) + ``` + -### Packaging Test Cases in JavaScript (for the Standard System\) + +### Packaging Test Cases in JavaScript (for the Standard System) For details about how to build a HAP, see the JS application development guide of the standard system [Building and Creating HAPs](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_overview-0000001055075201). @@ -444,12 +462,15 @@ Run the following command: ./build.sh suite=acts system_size=standard ``` + + + Test case directory: **out/release/suites/acts/testcases** Test framework and test case directory: **out/release/suites/acts** \(the test suite execution framework is compiled during the build process) -## Executing Test Cases in a Full Build (for Small and Standard Systems\) +## Executing Test Cases in a Full Build (for Small and Standard Systems) **Setting Up a Test Environment** @@ -468,29 +489,30 @@ Install Python 3.7 or a later version on a Windows environment and ensure that t **Executing Test Cases** -1. On the Windows environment, locate the directory in which the test cases are stored \(**out/release/suites/acts**, copied from the Linux server\), go to the directory in the Windows command window, and run **acts\\run.bat**. +1. On the Windows environment, locate the directory in which the test cases are stored \(**out/release/suites/acts**, copied from the Linux server), go to the directory in the Windows command window, and run **acts\\run.bat**. -1. Enter the command for executing the test case. +2. Enter the command for executing the test case. - Execute all test cases. - ``` - run acts - ``` - -  - - - Execute the test cases of a module \(view specific module information in **\\acts\\testcases\\**\). - - ``` - run –l ActsSamgrTest - ``` - -  - - Wait until the test cases are complete. - + ``` + run acts + ``` + +  + + - Execute the test cases of a module \(view specific module information in **\acts\testcases\**). + + ``` + run –l ActsSamgrTest + ``` + +  + + You can view specific module information in **\acts\testcases\**. + + Wait until the test cases are complete. 3. View the test report. - Go to **acts\\reports\\**, obtain the current execution record, and open **summary\_report.html** to view the test report. + Go to **acts\reports**, obtain the current execution record, and open **summary_report.html** to view the test report. diff --git a/en/device-dev/website.md b/en/device-dev/website.md index 7aa6c47b823301d3554a80d04b2c6f9a0c466270..058c142b50164cd3f0e38649a61024b6e8eac8c8 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -24,6 +24,7 @@ - Appendix - [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md) - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - Getting Started with Mini and Small Systems (Installation Package Mode) - [Mini and Small System Overview](quick-start/quickstart-lite-overview.md) - [Environment Preparation](quick-start/quickstart-lite-env-setup.md) @@ -51,6 +52,7 @@ - [Introduction to the Hi3861 Development Board](quick-start/quickstart-lite-introduction-hi3861.md) - [Introduction to the Hi3516 Development Board](quick-start/quickstart-lite-introduction-hi3516.md) - [Reference](quick-start/quickstart-lite-reference.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - Getting Started with Standard System (IDE Mode, Recommended) - [Standard System Overview](quick-start/quickstart-ide-standard-overview.md) - Environment Preparation @@ -71,6 +73,7 @@ - Appendix - [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) - [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - Getting Started with Standard System (Installation Package Mode) - [Standard System Overview](quick-start/quickstart-standard-overview.md) - [Setting Up Environments for Standard System](quick-start/quickstart-standard-env-setup.md) @@ -94,6 +97,7 @@ - [Introduction to the Hi3516 Development Board](quick-start/quickstart-standard-board-introduction-hi3516.md) - [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md) - [Reference](quick-start/quickstart-standard-reference.md) + - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - [Obtaining Source Code](get-code/sourcecode-acquire.md) - Compatibility and Security @@ -379,6 +383,7 @@ - [Audio](driver/driver-peripherals-audio-des.md) - [Camera](driver/driver-peripherals-camera-des.md) - [Facial Authentication](driver/driver-peripherals-face_auth-des.md) + - [Fingerprint Authentication](driver/driver-peripherals-fingerprint_auth-des.md) - [LCD](driver/driver-peripherals-lcd-des.md) - [Light](driver/driver-peripherals-light-des.md) - [PIN Authentication](driver/driver-peripherals-pinauth-des.md) @@ -463,7 +468,6 @@ - [Startup](subsystems/subsys-boot-overview.md) - [init Module](subsystems/subsys-boot-init.md) - [appspawn Module](subsystems/subsys-boot-appspawn.md) - - [appspawn Module for the Standard System](subsystems/subsys-boot-appspawn-standard.md) - [bootstrap Module](subsystems/subsys-boot-bootstrap.md) - [syspara Module](subsystems/subsys-boot-syspara.md) - [FAQs](subsystems/subsys-boot-faqs.md) diff --git a/en/glossary.md b/en/glossary.md index 40187dc8d5a70764b41a4f94e513ca1a6fa20a62..b5ce34fad0e1a72c8e4ba3520e336189175f7d64 100644 --- a/en/glossary.md +++ b/en/glossary.md @@ -29,9 +29,9 @@ ## D -- ### DevEco Studio for Embedded +- ### DevEco Device Tool - Integrated development environment (IDE) for developing embedded devices. + A one-stop development environment and all-in-one resource platform for smart device developers. Its comprehensive capabilities span the entire process of device development, from chip template project creation and custom development resource selection to code editing, build, debugging, and burning. - ### DMS diff --git a/en/readme/DeviceProfile.md b/en/readme/DeviceProfile.md index 29653fb13b515c0c88d00f1ca819745f1a1a4397..d1e4fdc0bfbc4ff5da9f219e52f2c60ac6dbd2d1 100644 --- a/en/readme/DeviceProfile.md +++ b/en/readme/DeviceProfile.md @@ -171,14 +171,13 @@ subscribeInfos.emplace_back(info2); std::list<ProfileEvent> failedEvents; // Call SubscribeProfileEvents. -DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(subscribeInfos, - callback, failedEvents); +DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(subscribeInfos, callback, failedEvents); sleep(SUBSCRIBE_SLEEP_TIME); std::list<ProfileEvent> profileEvents; profileEvents.emplace_back(ProfileEvent::EVENT_PROFILE_CHANGED); failedEvents.clear(); // Cancel the subscription. -DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEvents, +DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEvents, callback, failedEvents); callback, failedEvents); ``` @@ -186,4 +185,4 @@ DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEv **DeviceProfile subsystem** -[device\_profile\_core](https://gitee.com/openharmony/device_profile_core) +[device\_info\_manager](https://gitee.com/openharmony/deviceprofile_device_info_manager) diff --git a/en/readme/SAMGR.md b/en/readme/SAMGR.md index be89cb571dcacb5407fed7e8d0d6765121968acc..59273729b8d48784c9817b7adf16bcac60ff79cc 100644 --- a/en/readme/SAMGR.md +++ b/en/readme/SAMGR.md @@ -1,4 +1,4 @@ -# System Ability Manager(<a name="EN-US_TOPIC_0000001115719369"></a>) +# System Ability Manager<a name="EN-US_TOPIC_0000001115719369"></a> ## Introduction<a name="section11660541593"></a> diff --git a/en/readme/figures/User-IAM-subsystem-architecture.png b/en/readme/figures/User-IAM-subsystem-architecture.png index 13a861f97107524e38ed06f1e3d153cdc7d55fe2..64eaba85160ef22e68b0ebb53ab7e7862d881cec 100644 Binary files a/en/readme/figures/User-IAM-subsystem-architecture.png and b/en/readme/figures/User-IAM-subsystem-architecture.png differ diff --git a/en/readme/kernel.md b/en/readme/kernel.md index 470d4cf0be35257de3fc0c17184b509fdc783898..22956b8232cca83c8e1fcdf9e504b498eedcbad2 100644 --- a/en/readme/kernel.md +++ b/en/readme/kernel.md @@ -211,8 +211,6 @@ LiteOS: [device\_qemu](https://gitee.com/openharmony/device_qemu/blob/master/README.md) -[prebuilts\_lite\_sysroot](https://gitee.com/openharmony/prebuilts_lite_sysroot/blob/master/README.md) - Linux: [kernel\_linux\_patches](https://gitee.com/openharmony/kernel_linux_patches/blob/master/README.md) diff --git a/en/readme/update.md b/en/readme/update.md index 58abb6e73eeda879a98784c288b6cc7f230a31a7..52c384ff79961f75f2662430a0c88a8532cc9f46 100644 --- a/en/readme/update.md +++ b/en/readme/update.md @@ -1,25 +1,25 @@ -# Update<a name="EN-US_TOPIC_0000001149909821"></a> +# Update -## Introduction<a name="section184mcpsimp"></a> +## Introduction The Update subsystem helps you implement over the air \(OTA\) update of OpenHarmony devices. The update subsystem consists of the following: -1. Packaging tool +- Packaging tool The packaging tool is developed using Python and deployed on the PC to prepare update packages. It packages each update image, signs the update package, generates the update package execution script, and finally creates an update package. After the execution script is run on a OpenHarmony device, the device parses and executes the script to complete the update process. - The update package contains two files: **build\_tools.zip** and **update.bin**. + The update package contains two files: **build\_tools.zip** and **update.bin**. - **build\_tools.zip**: update assistance tools, including the executable files and scripts. - **update.bin**: TLV-encoded file, in which update contents are serialized and stored in the TLV format. The packaging tool signs the **update.bin** file and the generated update package \(**.zip** file\) independently. -2. Update service +- Update service The update service is used to search, download, and trigger updates. -3. Updater +- Updater The updater is the core module of the update subsystem. It provides the following functions: @@ -29,7 +29,7 @@ The Update subsystem helps you implement over the air \(OTA\) update of OpenHarm 4. Installs the related component packages based on the update script. 5. Performs post-processing after the update is complete, for example, deleting the update package and recording the update status. -4. Update app +- Update app The upgrade app is used to trigger search and download of update packages. @@ -53,14 +53,14 @@ Before you get started, familiarize yourself with the following concepts: ``` base/update # Update subsystem repository -├── app # Update app code +├── app # Update app code ├── packaging_tools # Packaging tool code -├── updater # Updater code +├── updater # Updater code │ ├── interfaces # External APIs -│ ├── resources # UI image resources of the update subsystem, such as animations and progress bar images -│ ├── services # Updater logic code -│ └── utils # Common code of the update subsystem, including the string processing functions and file processing functions -└── updateservice # Update service code +│ ├── resources # UI image resources of the update subsystem, such as animations and progress bar images +│ ├── services # Updater logic code +│ └── utils # Common code of the update subsystem, including the string processing functions and file processing functions +└── updateservice # Update service code ``` ## Repositories Involved<a name="section251mcpsimp"></a> diff --git a/en/readme/user-iam.md b/en/readme/user-iam.md index 52aba67d9048692ead51f3141090abaeb878ab43..32cceeaa64ee0962455a42296c005b8fc03d5e96 100644 --- a/en/readme/user-iam.md +++ b/en/readme/user-iam.md @@ -1,8 +1,10 @@ -# User IAM Subsystem +# User IAM ## Introduction -The user identity and access management (IAM) subsystem provides a unified framework for user credential management and user identity authentication in OpenHarmony. It allows multiple users to set their own authentication credential information and authenticates their identities based on the information set. This subsystem is widely used in security-sensitive scenarios such as screen lock. The subsystem also provides APIs for third-party developers to call the identity authentication capabilities to control user access. +The user identity and access management (IAM) subsystem provides a unified framework for user credential management and user identity authentication in OpenHarmony. It allows multiple users to set their own authentication credential information and authenticates their identities based on the information set. + +This subsystem is widely used in security-sensitive scenarios such as screen lock. It also provides APIs for developers to call the identity authentication capabilities to control user access. **Figure 1** Subsystem architecture @@ -16,14 +18,16 @@ The user IAM subsystem consists of the unified user authentication framework and Based on the unified user authentication framework, the system can be extended to support multiple authentication capabilities. Currently, the authentication executors supported by OpenHarmony are password and facial authentication. To implement a new authentication executor, you only need to implement authentication capabilities in a new part and connect the new part to the unified user authentication framework based on the interfaces defined by the authentication executor management part. -*Note: In the user IAM subsystem, an authentication executor is the minimum execution unit of a user identity authentication operation. For example, a password authentication module is responsible for password collection, password processing and comparison, and secure storage, and therefore it can be abstracted as a password authentication executor.* +> **NOTE** +> +>In the user IAM subsystem, an authentication executor is the minimum execution unit of a user identity authentication operation. For example, a password authentication module is responsible for password collection, password processing and comparison, and secure storage, and therefore it can be abstracted as a password authentication executor. ## Directory Structure ```undefined //base/user_iam -├── user_auth_framework # User authentication framework, including user authentication, credential management and executor management +├── user_auth_framework # User authentication framework, including user authentication, credential management, and executor management ├── face_auth # Facial authentication module, which connects to the authentication executor management part and supports facial information recording, deletion, and verification ├── pin_auth # Password authentication module, which connects to the authentication executor management part and supports password recording, deletion, and verification @@ -31,15 +35,15 @@ Based on the unified user authentication framework, the system can be extended t ## Constraints -1. User credential management is a key operation in the system, and interfaces used for user credential management can be invoked only by basic system applications. -2. The authentication executors process user authentication credentials and their capabilities can only be implemented by system services for interconnection with the authentication executor management part. +- User credential management is a key operation in the system, and the interfaces used for user credential management can be invoked only by basic system applications. +- The authentication executors process user authentication credentials, and their capabilities can only be implemented by system services for interconnection with the authentication executor management part. ## Usage ### How to Use 1. The unified user authentication framework must work with an authentication executor. -2. The first default authentication executor in the system must be password authentication. +2. The first default authentication executor in the system must be a password authentication executor. ## Repositories Involved diff --git a/en/readme/window-manager.md b/en/readme/window-manager.md index 41c07066713106fb4ba8e12e293383df88aeb66e..19f2f48dff0483d665172772256fe5236552a806 100644 --- a/en/readme/window-manager.md +++ b/en/readme/window-manager.md @@ -8,6 +8,8 @@ The Window Manager subsystem provides basic capabilities of window and display m  +Components of the Window Manager subsystem are described as follows: + - **Window Manager Client** Provides window object abstraction and window management interfaces, and connects to the ability and UI framework. @@ -28,23 +30,22 @@ The Window Manager subsystem provides basic capabilities of window and display m ```text foundation/window/window_manager/ -├── dm # Stores Display Manager Client implementation code -├── dmserver # Stores Display Manager Server implementation code -├── interfaces # Stores external APIs -│ ├── innerkits # Stores native APIs -│ └── kits # Stores JS APIs and native APIs -├── resources # Stores resource files used by the framework -├── sa_profile # Stores system service configuration files -├── snapshot # Stores implementation code of the screenshot command line tool -├── utils # Stores tools -├── wm # Stores Window Manager Client implementation code -├── wmserver # Stores Window Manager Server implementation code +├── dm # Implementation code of Display Manager Client +├── dmserver # Implementation code of Display Manager Server +├── interfaces # External APIs +│ ├── innerkits # Native APIs +│ └── kits # JS APIs and native APIs +├── resources # Resource files used by the framework +├── sa_profile # System service configuration files +├── snapshot # Implementation code of the screenshot command line tool +├── utils # Utilities +├── wm # Implementation code of Window Manager Client +├── wmserver # Implementation code of Window Manager Server ``` ## Constraints -- Programming language version - - C++ 11 or later +The Programming language version must be C++ 11 or later. ## Available APIs diff --git a/en/readme/xts.md b/en/readme/xts.md index c4558c9d947dda419b382382fa49421217f46fbe..9bd767f143168c7d3b3a478fabd99eb745fcd5c8 100644 --- a/en/readme/xts.md +++ b/en/readme/xts.md @@ -1,15 +1,15 @@ -# XTS<a name="EN-US_TOPIC_0000001126156429"></a> +# XTS -## Introduction<a name="section465982318513"></a> +## Introduction The X test suite \(XTS\) subsystem contains a set of OpenHarmony compatibility test suites, including the currently supported application compatibility test suite \(ACTS\) and the device compatibility test suite \(DCTS\) that will be supported in the future. -This subsystem contains the ACTS and **tools** software package. +This subsystem contains the ACTS and **tools** software package. -- The **acts** directory stores the source code and configuration files of ACTS test cases. The ACTS helps device vendors detect the software incompatibility as early as possible and ensures that the software is compatible to OpenHarmony during the entire development process. -- The **tools** software package stores the test case development framework related to **acts**. +- The **acts** directory stores the source code and configuration files of ACTS test cases. The ACTS helps device vendors detect the software incompatibility as early as possible and ensures that the software is compatible with OpenHarmony during the entire development process. +- The **tools** software package stores the test case development framework related to **acts**. -## System Types<a name="section125090457443"></a> +## System Types OpenHarmony supports the following system types: @@ -26,222 +26,79 @@ OpenHarmony supports the following system types: A standard system runs on the devices whose memory is greater than or equal to 128 MiB and that are equipped with application processors such as ARM Cortex-A. This system provides a complete application framework supporting the enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. This system applies to high-end refrigerator displays. -## Directory Structure<a name="section161941989596"></a> +## Directory Structure ``` /test/xts -├── acts # Test code +├── acts # Test code │ └── subsystem # Source code of subsystem test cases for the standard system │ └── subsystem_lite # Source code of subsystems test cases for mini and small systems │ └── BUILD.gn # Build configuration of test cases for the standard system │ └── build_lite │ └── BUILD.gn # Build configuration of test cases for mini and small systems -└── tools # Test tool code +└── tools # Test tool code ``` -## Constraints<a name="section119744591305"></a> +## Constraints Test cases for the mini system must be developed based on C, and those for the small system must be developed based on C++. -## Usage Guidelines<a name="section137768191623"></a> - -**Table 1** Test case levels - -<a name="table12856113719456"></a> -<table><thead align="left"><tr id="row88561737114517"><th class="cellrowborder" valign="top" width="33.333333333333336%" id="mcps1.2.4.1.1"><p id="p54711456452"><a name="p54711456452"></a><a name="p54711456452"></a>Level</p> -</th> -<th class="cellrowborder" valign="top" width="33.283328332833285%" id="mcps1.2.4.1.2"><p id="p114834544518"><a name="p114834544518"></a><a name="p114834544518"></a>Definition</p> -</th> -<th class="cellrowborder" valign="top" width="33.383338333833386%" id="mcps1.2.4.1.3"><p id="p348154574518"><a name="p348154574518"></a><a name="p348154574518"></a>Scope</p> -</th> -</tr> -</thead> -<tbody><tr id="row78561137134514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p17481345124512"><a name="p17481345124512"></a><a name="p17481345124512"></a>Level0</p> -</td> -<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1548945204514"><a name="p1548945204514"></a><a name="p1548945204514"></a>Smoke</p> -</td> -<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p174824517456"><a name="p174824517456"></a><a name="p174824517456"></a>Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable.</p> -</td> -</tr> -<tr id="row28563372451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p448445144512"><a name="p448445144512"></a><a name="p448445144512"></a>Level1</p> -</td> -<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p44813452452"><a name="p44813452452"></a><a name="p44813452452"></a>Basic</p> -</td> -<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p648184584514"><a name="p648184584514"></a><a name="p648184584514"></a>Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable.</p> -</td> -</tr> -<tr id="row12856137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p164834520453"><a name="p164834520453"></a><a name="p164834520453"></a>Level2</p> -</td> -<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p148245184511"><a name="p148245184511"></a><a name="p148245184511"></a>Major</p> -</td> -<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p348945124510"><a name="p348945124510"></a><a name="p348945124510"></a>Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing.</p> -</td> -</tr> -<tr id="row48571137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p7481545184513"><a name="p7481545184513"></a><a name="p7481545184513"></a>Level3</p> -</td> -<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1748184514455"><a name="p1748184514455"></a><a name="p1748184514455"></a>Regular</p> -</td> -<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p8481245104519"><a name="p8481245104519"></a><a name="p8481245104519"></a>Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions.</p> -</td> -</tr> -<tr id="row14857133712451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p1248144515456"><a name="p1248144515456"></a><a name="p1248144515456"></a>Level4</p> -</td> -<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p94804514519"><a name="p94804514519"></a><a name="p94804514519"></a>Rare</p> -</td> -<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p1248445164516"><a name="p1248445164516"></a><a name="p1248445164516"></a>Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations.</p> -</td> -</tr> -</tbody> -</table> - -**Table 2** Test case granularities - -<a name="table1690733521014"></a> -<table><thead align="left"><tr id="row9907143516105"><th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.2.4.1.1"><p id="p1141312416102"><a name="p1141312416102"></a><a name="p1141312416102"></a>Test Scale</p> -</th> -<th class="cellrowborder" valign="top" width="35.17351735173517%" id="mcps1.2.4.1.2"><p id="p34131416109"><a name="p34131416109"></a><a name="p34131416109"></a>Test Objects</p> -</th> -<th class="cellrowborder" valign="top" width="45.23452345234523%" id="mcps1.2.4.1.3"><p id="p12413141171010"><a name="p12413141171010"></a><a name="p12413141171010"></a>Test Environment</p> -</th> -</tr> -</thead> -<tbody><tr id="row2907335181017"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p6414134117109"><a name="p6414134117109"></a><a name="p6414134117109"></a>LargeTest</p> -</td> -<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p20414104113101"><a name="p20414104113101"></a><a name="p20414104113101"></a>Service functionalities, all-scenario features, and mechanical power environment (MPE) and scenario-level DFX</p> -</td> -<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p5414841121013"><a name="p5414841121013"></a><a name="p5414841121013"></a>Devices close to real devices</p> -</td> -</tr> -<tr id="row10907635131015"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p19414134117104"><a name="p19414134117104"></a><a name="p19414134117104"></a>MediumTest</p> -</td> -<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p114141241141018"><a name="p114141241141018"></a><a name="p114141241141018"></a>Modules, subsystem functionalities after module integration, and DFX</p> -</td> -<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p14414941111015"><a name="p14414941111015"></a><a name="p14414941111015"></a>Single device that is actually used. You can perform message simulation, but do not mock functions.</p> -</td> -</tr> -<tr id="row1990713353100"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p641414110109"><a name="p641414110109"></a><a name="p641414110109"></a>SmallTest</p> -</td> -<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p54141541181018"><a name="p54141541181018"></a><a name="p54141541181018"></a>Modules, classes, and functions</p> -</td> -<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p1841494131013"><a name="p1841494131013"></a><a name="p1841494131013"></a>Local PC. Use a large number of mocks to replace dependencies with other modules.</p> -</td> -</tr> -</tbody> -</table> - -**Table 3** Test types - -<a name="table18811230124619"></a> -<table><thead align="left"><tr id="row48163019466"><th class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.2.3.1.1"><p id="p1791784418465"><a name="p1791784418465"></a><a name="p1791784418465"></a>Type</p> -</th> -<th class="cellrowborder" valign="top" width="80.96%" id="mcps1.2.3.1.2"><p id="p2917164444614"><a name="p2917164444614"></a><a name="p2917164444614"></a>Definition</p> -</th> -</tr> -</thead> -<tbody><tr id="row682630104615"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1091784414469"><a name="p1091784414469"></a><a name="p1091784414469"></a>Function</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p16917344104618"><a name="p16917344104618"></a><a name="p16917344104618"></a>Tests the correctness of both service and platform functionalities provided by the tested object for end users or developers.</p> -</td> -</tr> -<tr id="row1821930154611"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p591714474612"><a name="p591714474612"></a><a name="p591714474612"></a>Performance</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p15917154410463"><a name="p15917154410463"></a><a name="p15917154410463"></a>Tests the processing capability of the tested object under specific preset conditions and load models. The processing capability is measured by the service volume that can be processed in a unit time, for example, call per second, frame per second, or event processing volume per second.</p> -</td> -</tr> -<tr id="row13821030104616"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p691711440467"><a name="p691711440467"></a><a name="p691711440467"></a>Power</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p159171544104616"><a name="p159171544104616"></a><a name="p159171544104616"></a>Tests the power consumption of the tested object in a certain period of time under specific preset conditions and load models.</p> -</td> -</tr> -<tr id="row6821330114618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13917164454612"><a name="p13917164454612"></a><a name="p13917164454612"></a>Reliability</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p11917194416465"><a name="p11917194416465"></a><a name="p11917194416465"></a>Tests the service performance of the tested object under common and uncommon input conditions, or specified service volume pressure and long-term continuous running pressure. The test covers stability, pressure handling, fault injection, and Monkey test times.</p> -</td> -</tr> -<tr id="row11821930184612"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1691774474618"><a name="p1691774474618"></a><a name="p1691774474618"></a>Security</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul112421652121513"></a><a name="ul112421652121513"></a><ul id="ul112421652121513"><li>Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.</li><li>Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.</li><li>Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT).</li></ul> -</td> -</tr> -<tr id="row16825307467"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p129188444462"><a name="p129188444462"></a><a name="p129188444462"></a>Global</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p179186444465"><a name="p179186444465"></a><a name="p179186444465"></a>Tests the internationalized data and localization capabilities of the tested object, including multi-language display, various input/output habits, time formats, and regional features, such as currency, time, and culture taboos.</p> -</td> -</tr> -<tr id="row08211308464"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p191814447465"><a name="p191814447465"></a><a name="p191814447465"></a>Compatibility</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul186961827111612"></a><a name="ul186961827111612"></a><ul id="ul186961827111612"><li>Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.</li><li>Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.</li><li>Tests software compatibility with related hardware.</li></ul> -</td> -</tr> -<tr id="row1782730124618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13918144134614"><a name="p13918144134614"></a><a name="p13918144134614"></a>User</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291844494611"><a name="p1291844494611"></a><a name="p1291844494611"></a>Tests user experience of the object in real user scenarios. All conclusions and comments should come from the users, which are all subjective evaluation in this case.</p> -</td> -</tr> -<tr id="row58243024617"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1291884474614"><a name="p1291884474614"></a><a name="p1291884474614"></a>Standard</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p0918124424614"><a name="p0918124424614"></a><a name="p0918124424614"></a>Tests the compliance with industry and company-specific standards, protocols, and specifications. The standards here do not include any security standards that should be classified into the security test.</p> -</td> -</tr> -<tr id="row382830124619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p119181044164619"><a name="p119181044164619"></a><a name="p119181044164619"></a>Safety</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291818443468"><a name="p1291818443468"></a><a name="p1291818443468"></a>Tests the safety property of the tested object to avoid possible hazards to personal safety, health, and the object itself.</p> -</td> -</tr> -<tr id="row1083153014465"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p39187441469"><a name="p39187441469"></a><a name="p39187441469"></a>Resilience</p> -</td> -<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p891815444462"><a name="p891815444462"></a><a name="p891815444462"></a>Tests the resilience property of the tested object to ensure that it can withstand and maintain the defined running status (including downgrading) when being attacked, and recover from and adapt defense to the attacks to approach mission assurance.</p> -</td> -</tr> -</tbody> -</table> - -## Test Case Development Guidelines<a name="section3695134065513"></a> +## Usage Guidelines + +**Table 1** Test case levels + +| Level | Definition | Scope | +| ----- | ---------- | ----- | +| Level0 | Smoke | Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable. | +| Level1 | Basic | Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable. | +| Level2 | Major | Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing. | +| Level3 | Regular | Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions. | +| Level4 | Rare | Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations. | + +**Table 2** Test case granularities + +| Test Scale | Test Objects | Test Environment | +| ---------- | ------------ | ---------------- | +| LargeTest | Service functionalities, all-scenario features, and mechanical power environment (MPE) and scenario-level DFX | Devices close to real devices. | +| MediumTest | Modules, subsystem functionalities after module integration, and DFX | Single device that is actually used. You can perform message simulation, but do not mock functions. | +| SmallTest | Modules, classes, and functions | Local PC. Use a large number of mocks to replace dependencies with other modules. | + +**Table 3** Test types + +| Type | Definition | +| ---------- | ------------ | +| Function | Tests the correctness of both service and platform functionalities provided by the tested object for end users or developers. | +| Performance | Tests the processing capability of the tested object under specific preset conditions and load models. The processing capability is measured by the service volume that can be processed in a unit time, for example, call per second, frame per second, or event processing volume per second. | +| Power | Tests the power consumption of the tested object in a certain period of time under specific preset conditions and load models. +| Reliability | Tests the service performance of the tested object under common and uncommon input conditions, or specified service volume pressure and long-term continuous running pressure. The test covers stability, pressure handling, fault injection, and Monkey test times. | +| Security | - Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.<br>- Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.<br>- Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT). | +| Global | Tests the internationalized data and localization capabilities of the tested object, including multi-language display, various input/output habits, time formats, and regional features, such as currency, time, and culture taboos. | +| Compatibility | - Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.<br>- Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.<br>- Tests software compatibility with related hardware. | +| User | Tests user experience of the object in real user scenarios. All conclusions and comments should come from the users, which are all subjective evaluation in this case. | +| Standard | Tests the compliance with industry and company-specific standards, protocols, and specifications. The standards here do not include any security standards that should be classified into the security test. | +| Safety | Tests the safety property of the tested object to avoid possible hazards to personal safety, health, and the object itself. | +| Resilience | Tests the resilience property of the tested object to ensure that it can withstand and maintain the defined running status (including downgrading) when being attacked, and recover from and adapt defense to the attacks to approach mission assurance. | + + +## Test Case Development Guidelines You should select the appropriate programming language and your target test framework to develop test cases. -**Table 4** Test frameworks and test case languages for different systems - -<a name="table4418343171415"></a> -<table><thead align="left"><tr id="row34183435145"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p941874311148"><a name="p941874311148"></a><a name="p941874311148"></a>System</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1841804341413"><a name="p1841804341413"></a><a name="p1841804341413"></a>Test Framework</p> -</th> -<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p2418104311148"><a name="p2418104311148"></a><a name="p2418104311148"></a>Language</p> -</th> -</tr> -</thead> -<tbody><tr id="row8419164319148"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7419194312143"><a name="p7419194312143"></a><a name="p7419194312143"></a>Mini</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419124312145"><a name="p10419124312145"></a><a name="p10419124312145"></a>HCTest</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11419643191410"><a name="p11419643191410"></a><a name="p11419643191410"></a>C</p> -</td> -</tr> -<tr id="row141915438147"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p441911436141"><a name="p441911436141"></a><a name="p441911436141"></a>Small</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p541916432142"><a name="p541916432142"></a><a name="p541916432142"></a>HCPPTest</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p54191643131416"><a name="p54191643131416"></a><a name="p54191643131416"></a>C++</p> -</td> -</tr> -<tr id="row4419134341417"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p341964313143"><a name="p341964313143"></a><a name="p341964313143"></a>Standard</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419443171416"><a name="p10419443171416"></a><a name="p10419443171416"></a>HJSUnit and HCPPTest</p> -</td> -<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9419143181414"><a name="p9419143181414"></a><a name="p9419143181414"></a>JavaScript and C++</p> -</td> -</tr> -</tbody> -</table> - -### C-based Test Case Development and Compilation \(for the Mini System\)<a name="section198193336544"></a> +**Table 4** Test frameworks and test case languages for different systems + +| System | Test Framework | Language | +| ---------- | ------------ | ---------------- | +| Mini | HCTest | C | +| Small | HCPPTest | C++ | +| Standard | HJSUnit and HCPPTest | JavaScript and C++ | + +### C-based Test Case Development and Compilation \(for the Mini System\) **Developing test cases for the mini system** The HCTest framework is used to support test cases developed with the C language. HCTest is enhanced and adapted based on the open-source test framework Unity. -1. Access the **test/xts/acts** repository where the test cases will be stored. +1. Access the **test/xts/acts** repository where the test cases will be stored. ``` ├── acts @@ -253,7 +110,7 @@ The HCTest framework is used to support test cases developed with the C language │ │ └── BUILD.gn ``` -2. Write the test case in the **src** directory. +2. Write the test case in the **src** directory. 1 Import the test framework header file. @@ -261,10 +118,10 @@ The HCTest framework is used to support test cases developed with the C language #include "hctest.h" ``` - 2. Use the **LITE\_TEST\_SUIT** macro to define names of the subsystem, module, and test suite. + 2. Use the **LITE\_TEST\_SUIT** macro to define names of the subsystem, module, and test suite. ``` - /** + /** * @brief Registers a test suite named IntTestSuite. * @param test Subsystem name * @param example Module name @@ -279,7 +136,7 @@ The HCTest framework is used to support test cases developed with the C language The Setup and TearDown functions must exist, but function bodies can be empty. - 4. Use the **LITE\_TEST\_CASE** macro to write the test case. + 4. Use the **LITE\_TEST\_CASE** macro to write the test case. Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\). @@ -290,7 +147,7 @@ The HCTest framework is used to support test cases developed with the C language }; ``` - 5. Use the **RUN\_TEST\_SUITE** macro to register the test suite. + 5. Use the **RUN\_TEST\_SUITE** macro to register the test suite. ``` RUN_TEST_SUITE(IntTestSuite); @@ -298,7 +155,7 @@ The HCTest framework is used to support test cases developed with the C language 3. Create the configuration file \(**BUILD.gn**\) of the test module. - Create a **BUILD.gn** \(example\) build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. The format is as follows: + Create a **BUILD.gn** \(example\) build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. The format is as follows: ``` import("//test/xts/tools/lite/build/suite_lite.gni") @@ -312,9 +169,9 @@ The HCTest framework is used to support test cases developed with the C language } ``` -4. Add build options to the **BUILD.gn** file in the **acts** directory. +4. Add build options to the **BUILD.gn** file in the **acts** directory. - You need to add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. + You need to add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. ``` lite_component("acts") { @@ -332,11 +189,12 @@ The HCTest framework is used to support test cases developed with the C language Test suites are built along with version build. The ACTS is built together with the debug version. - > **NOTE:** + > **NOTE** + > >The ACTS build middleware is a static library, which will be linked to the image. -### C-based Test Case Execution \(for the Mini System\)<a name="section13820233175418"></a> +### C-based Test Case Execution \(for the Mini System\) **Executing test cases for the mini system** @@ -351,15 +209,15 @@ Burn the image into the development board. View the serial port logs, whose format is as follows: -The log for each test suite starts with **Start to run test suite:** and ends with **xx Tests xx Failures xx Ignored**. +The log for each test suite starts with **Start to run test suite:** and ends with **xx Tests xx Failures xx Ignored**. -### C++-based Test Case Development and Compilation \(for Standard and Small Systems\)<a name="section3822123311540"></a> +### C++-based Test Case Development and Compilation \(for Standard and Small Systems\) -**Developing test cases for small-system devices** \(For examples of the standard system, go to the **global/i18n\_standard directory**.\) +**Developing test cases for small-system devices** \(For examples of the standard system, go to the **global/i18n\_standard directory**.\) The HCPPTest framework is enhanced and adapted based on the open-source framework Googletest. -1. Access the **test/xts/acts** repository where the test cases will be stored. +1. Access the **test/xts/acts** repository where the test cases will be stored. ``` ├── acts @@ -371,11 +229,11 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor │ │ └── BUILD.gn ``` -2. Write the test case in the **src** directory. +2. Write the test case in the **src** directory. 1. Import the test framework header file. - The following statement includes **gtest.h**. + The following statement includes **gtest.h**. ``` #include "gtest/gtest.h" @@ -405,11 +263,11 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor }; ``` - 3. Use the **HWTEST** or **HWTEST\_F** macro to write the test case. + 3. Use the **HWTEST** or **HWTEST\_F** macro to write the test case. - **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation. + **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation. - **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation. + **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation. Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\). @@ -421,7 +279,7 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor 3. Create a configuration file \(**BUILD.gn**\) of the test module. - Create a **BUILD.gn** build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. Each test module is independently built into a **.bin** executable file, which can be directly pushed to the development board for testing. + Create a **BUILD.gn** build file in each test module directory. Specify the name of the built static library and its dependent header file and library in the build file. Each test module is independently built into a **.bin** executable file, which can be directly pushed to the development board for testing. Example: @@ -444,9 +302,9 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor } ``` -4. Add build options to the **BUILD.gn** file in the **acts** directory. +4. Add build options to the **BUILD.gn** file in the **acts** directory. - Add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. + Add the test module to the **test/xts/acts/build\_lite/BUILD.gn** script in the **acts** directory. ``` lite_component("acts") { @@ -464,11 +322,12 @@ The HCPPTest framework is enhanced and adapted based on the open-source framewor Test suites are built along with the version build. The ACTS is built together with the debug version. - > **NOTE:** - >The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the **suites\\acts** directory of the build result. + > **NOTE** + > + >The ACTS for the small system is independently built to an executable file \(.bin\) and archived in the **suites\\acts** directory of the build result. -### C++-based Test Case Execution \(for Standard and Small Systems\)<a name="section128222336544"></a> +### C++-based Test Case Execution \(for Standard and Small Systems\) **Executing test cases for the small system** @@ -479,9 +338,9 @@ Currently, test cases are shared by the NFS and mounted to the development board 1. Use a network cable or wireless network to connect the development board to your PC. 2. Configure the IP address, subnet mask, and gateway for the development board. Ensure that the development board and the PC are in the same network segment. 3. Install and register the NFS server on the PC and start the NFS service. -4. Run the **mount** command for the development board to ensure that the development board can access NFS shared files on the PC. +4. Run the **mount** command for the development board to ensure that the development board can access NFS shared files on the PC. - Format: **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_development board directory_ **nfs** + Format: **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_development board directory_ **nfs** Example: @@ -492,9 +351,9 @@ Currently, test cases are shared by the NFS and mounted to the development board **Executing test cases** -Execute **ActsDemoTest.bin** to trigger test case execution, and analyze serial port logs generated after the execution is complete. +Execute **ActsDemoTest.bin** to trigger test case execution, and analyze serial port logs generated after the execution is complete. -### JavaScript-based Test Case Development \(for the Standard System\)<a name="section159801435165220"></a> +### JavaScript-based Test Case Development \(for the Standard System\) The HJSUnit framework is used to support automated test of OpenHarmony apps that are developed using the JavaScript language based on the JS application framework. @@ -502,71 +361,20 @@ The HJSUnit framework is used to support automated test of OpenHarmony apps that The test cases are developed with the JavaScript language and must meet the programming specifications of the language. -**Table 5** - -<a name="table13980103565212"></a> -<table><thead align="left"><tr id="row1098093545218"><th class="cellrowborder" valign="top" width="17.92179217921792%" id="mcps1.2.4.1.1"><p id="p49811235135214"><a name="p49811235135214"></a><a name="p49811235135214"></a>Syntax</p> -</th> -<th class="cellrowborder" valign="top" width="68.88688868886888%" id="mcps1.2.4.1.2"><p id="p898183565220"><a name="p898183565220"></a><a name="p898183565220"></a>Description</p> -</th> -<th class="cellrowborder" valign="top" width="13.19131913191319%" id="mcps1.2.4.1.3"><p id="p17981143512526"><a name="p17981143512526"></a><a name="p17981143512526"></a>Mandatory</p> -</th> -</tr> -</thead> -<tbody><tr id="row1598183515528"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p139810358527"><a name="p139810358527"></a><a name="p139810358527"></a>beforeAll</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p198111352526"><a name="p198111352526"></a><a name="p198111352526"></a>Presets a test-suite-level action executed only once before all test cases are executed. You can pass the action function as the only parameter.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p298114355529"><a name="p298114355529"></a><a name="p298114355529"></a>No</p> -</td> -</tr> -<tr id="row11981103512529"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p20981135135215"><a name="p20981135135215"></a><a name="p20981135135215"></a>afterAll</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p39811935115217"><a name="p39811935115217"></a><a name="p39811935115217"></a>Presets a test-suite-level clear action executed only once after all test cases are executed. You can pass the clear function as the only parameter.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p998110354527"><a name="p998110354527"></a><a name="p998110354527"></a>No</p> -</td> -</tr> -<tr id="row1298116359526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p898112359526"><a name="p898112359526"></a><a name="p898112359526"></a>beforeEach</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p149811335175215"><a name="p149811335175215"></a><a name="p149811335175215"></a>Presets a test-case-level action executed before each test case is executed. The number of execution times is the same as the number of test cases defined by <strong id="b32523248388"><a name="b32523248388"></a><a name="b32523248388"></a>it</strong>. You can pass the action function as the only parameter.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p13981133585212"><a name="p13981133585212"></a><a name="p13981133585212"></a>No</p> -</td> -</tr> -<tr id="row6982435115219"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p19982133517525"><a name="p19982133517525"></a><a name="p19982133517525"></a>afterEach</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p1398213575219"><a name="p1398213575219"></a><a name="p1398213575219"></a>Presets a test-case-level clear action executed after each test case is executed. The number of execution times is the same as the number of test cases defined by <strong id="b10590142313399"><a name="b10590142313399"></a><a name="b10590142313399"></a>it</strong>. You can pass the clear function as the only parameter.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p159821535195219"><a name="p159821535195219"></a><a name="p159821535195219"></a>No</p> -</td> -</tr> -<tr id="row16982143513521"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p598203510527"><a name="p598203510527"></a><a name="p598203510527"></a>describe</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p5982123595215"><a name="p5982123595215"></a><a name="p5982123595215"></a>Defines a test suite. You can pass two parameters: test suite name and test suite function. The <strong id="b7320205019400"><a name="b7320205019400"></a><a name="b7320205019400"></a>describe</strong> statement supports nesting. You can use <strong id="b138214222410"><a name="b138214222410"></a><a name="b138214222410"></a>beforeall</strong>, <strong id="b18677102314115"><a name="b18677102314115"></a><a name="b18677102314115"></a>beforeEach</strong>, <strong id="b1353142514113"><a name="b1353142514113"></a><a name="b1353142514113"></a>afterEach</strong>, and <strong id="b131041629204111"><a name="b131041629204111"></a><a name="b131041629204111"></a>afterAll</strong> in each <strong id="b590433484116"><a name="b590433484116"></a><a name="b590433484116"></a>describe</strong> statement.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p898217352527"><a name="p898217352527"></a><a name="p898217352527"></a>Yes</p> -</td> -</tr> -<tr id="row6982113518526"><td class="cellrowborder" valign="top" width="17.92179217921792%" headers="mcps1.2.4.1.1 "><p id="p17982123510526"><a name="p17982123510526"></a><a name="p17982123510526"></a>it</p> -</td> -<td class="cellrowborder" valign="top" width="68.88688868886888%" headers="mcps1.2.4.1.2 "><p id="p598211352522"><a name="p598211352522"></a><a name="p598211352522"></a>Defines a test case. You can pass three parameters: test case name, filter parameter, and test case function.</p> -<p id="p5205769588"><a name="p5205769588"></a><a name="p5205769588"></a>Usage of the filter parameter:</p> -<p id="p1545919528618"><a name="p1545919528618"></a><a name="p1545919528618"></a>The value of the filter parameter is a 32-bit integer. Setting different bits to <strong id="b045919521765"><a name="b045919521765"></a><a name="b045919521765"></a>1</strong> means different configurations:</p> -<a name="ul6932113319395"></a><a name="ul6932113319395"></a><ul id="ul6932113319395"><li>bit 0: whether the filter parameter takes effect. <strong id="b1193293318395"><a name="b1193293318395"></a><a name="b1193293318395"></a>1</strong> means that the test case is used for the function test and other settings of the parameter do not take effect.</li><li>Bits 0-10: test case categories</li><li>Bits 16-18: test case scales</li><li>Bits 24-28: test levels</li></ul> -<p id="p7965165151011"><a name="p7965165151011"></a><a name="p7965165151011"></a><strong id="b15148755145114"><a name="b15148755145114"></a><a name="b15148755145114"></a>Test case categories</strong>: Bits 0-10 indicate FUNCTION (function test), PERFORMANCE (performance test), POWER (power consumption test), RELIABILITY (reliability test), SECURITY (security compliance test), GLOBAL (integrity test), COMPATIBILITY (compatibility test), USER (user test), STANDARD (standard test), SAFETY (security feature test), and RESILIENCE (resilience test), respectively.</p> -<p id="p199651555102"><a name="p199651555102"></a><a name="p199651555102"></a><strong id="b135908568519"><a name="b135908568519"></a><a name="b135908568519"></a>Test case scales</strong>: Bits 16-18 indicate SMALL (small-scale test), MEDIUM (medium-scale test), and LARGE (large-scale test), respectively.</p> -<p id="p296545151020"><a name="p296545151020"></a><a name="p296545151020"></a><strong id="b12181058125111"><a name="b12181058125111"></a><a name="b12181058125111"></a>Test levels</strong>: Bits 24-28 indicate LEVEL0 (level-0 test), LEVEL1 (level-1 test), LEVEL2 (level-2 test), LEVEL3 (level-3 test), and LEVEL4 (level-4 test), respectively.</p> -</td> -<td class="cellrowborder" valign="top" width="13.19131913191319%" headers="mcps1.2.4.1.3 "><p id="p17601752115716"><a name="p17601752115716"></a><a name="p17601752115716"></a>Yes</p> -</td> -</tr> -</tbody> -</table> +**Table 5** Basic syntax + +| Syntax | Description | Mandatory | +| ------ | ----------- | --------- | +| beforeAll | Presets a test-suite-level action executed only once before all test cases are executed. You can pass the action function as the only parameter. | No | +| afterAll | Presets a test-suite-level clear action executed only once after all test cases are executed. You can pass the clear function as the only parameter. | No | +| beforeEach | Presets a test-case-level action executed before each test case is executed. The number of execution times is the same as the number of test cases defined by it. You can pass the action function as the only parameter. | No | +| afterEach | Presets a test-case-level clear action executed after each test case is executed. The number of execution times is the same as the number of test cases defined by it. You can pass the clear function as the only parameter. | No | +| describe | Defines a test suite. You can pass two parameters: test suite name and test suite function. The describe statement supports nesting. You can use beforeall, beforeEach, afterEach, and afterAll in each describe statement. | Yes | +| it | Defines a test case. You can pass three parameters: test case name, filter parameter, and test case function.<br>**Usage of the filter parameter**:<br>The value of the filter parameter is a 32-bit integer. Setting different bits to 1 means different configurations:<br><ul><li>bit 0: whether the filter parameter takes effect. **1** means that the test case is used for the function test and other settings of the parameter do not take effect.</li><li>Bits 0-10: test case categories</li><li>Bits 16-18: test case scales</li><li>Bits 24-28: test levels</li></ul>**Test case categories**: Bits 0-10 indicate FUNCTION (function test), PERFORMANCE (performance test), POWER (power consumption test), RELIABILITY (reliability test), SECURITY (security compliance test), GLOBAL (integrity test), COMPATIBILITY (compatibility test), USER (user test), STANDARD (standard test), SAFETY (security feature test), and RESILIENCE (resilience test), respectively.<br>**Test case scales**: Bits 16-18 indicate SMALL (small-scale test), MEDIUM (medium-scale test), and LARGE (large-scale test), respectively.<br>**Test levels**: Bits 24-28 indicate LEVEL0 (level-0 test), LEVEL1 (level-1 test), LEVEL2 (level-2 test), LEVEL3 (level-3 test), and LEVEL4 (level-4 test), respectively. | Yes | Use the standard syntax of Jasmine to write test cases. The ES6 specification is supported. -1. Store the test cases in the **entry/src/main/js/test** directory, whose structure is as follows: +1. Store the test cases in the **entry/src/main/js/test** directory, whose structure is as follows: ``` ├── BUILD.gn @@ -583,7 +391,7 @@ Use the standard syntax of Jasmine to write test cases. The ES6 specification is │ │ │ └── config.json # HAP configuration file ``` -2. Start the JS test framework and load test cases. The following is an example for **index.js**. +2. Start the JS test framework and load test cases. The following is an example for **index.js**. ``` // Start the JS test framework and load test cases. @@ -628,12 +436,12 @@ Use the standard syntax of Jasmine to write test cases. The ES6 specification is ``` -### JavaScript-based Test Case Packaging \(for the Standard System\)<a name="section445519106559"></a> +### JavaScript-based Test Case Packaging \(for the Standard System\) For details about how to build a HAP, see the JS application development guide of the standard system [Building and Creating HAPs](https://developer.harmonyos.com/en/docs/documentation/doc-guides/build_overview-0000001055075201). -## Repositories Involved<a name="section1371113476307"></a> +## Repositories Involved [xts\_acts](https://gitee.com/openharmony/xts_acts) diff --git a/en/release-notes/OpenHarmony-v3.1.1-release.md b/en/release-notes/OpenHarmony-v3.1.1-release.md index 81a705cb5ab619bb9bf1163077f96bfa96b6bcd7..bcff1ffc13392f7b2e563b7e97e679a6e048bee7 100644 --- a/en/release-notes/OpenHarmony-v3.1.1-release.md +++ b/en/release-notes/OpenHarmony-v3.1.1-release.md @@ -21,7 +21,7 @@ Distributed data management is now compatible with the **\@system.storage** APIs 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. +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 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** @@ -32,12 +32,13 @@ The Contacts application allows third-party applications to invoke the system ca **Table 1** Version mapping of software and tools -| Software/Tool| Version| Remarks| +| Software/Tool| Version| Remarks| | -------- | -------- | -------- | -| OpenHarmony | 3.1.1 Release | NA | -| SDK | Ohos_sdk_full 3.1.6.5 (API Version 8 Release) | NA | -| (Optional) HUAWEI DevEco Studio| 3.0 Beta3 for OpenHarmony | Recommended for developing OpenHarmony applications| -| (Optional) HUAWEI DevEco Device Tool| 3.0 Release | Recommended for developing OpenHarmony devices| +| OpenHarmony | 3.1.1 Release | NA | +| Public SDK | Ohos_sdk_public 3.1.6.6 (API Version 8 Release)| This toolkit is intended for application developers and does not contain system APIs that require system permissions.<br>It is provided as standard in DevEco Studio 3.0 Beta4 or later.<br>The public SDK of API version 8 was released on July 6, 2022.| +| Full SDK | Ohos_sdk_full 3.1.6.5 (API Version 8 Release) | This toolkit is intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions.<br>To use the full SDK, manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md).| +| (Optional) HUAWEI DevEco Studio| 3.0 Beta3 for OpenHarmony | This tool is recommended for developing OpenHarmony applications.| +| (Optional) HUAWEI DevEco Device Tool| 3.0 Release | This tool is recommended for developing OpenHarmony smart devices.| ## Source Code Acquisition @@ -101,8 +102,10 @@ repo forall -c 'git lfs pull' | Hi3861 mini system solution (binary) | 3.1.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.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.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.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.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)| +| Full SDK package for the standard system (macOS) | 3.1.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)| +| Full SDK package for the standard system (Windows/Linux) | 3.1.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)| +| Public SDK package for the standard system (macOS)| 3.1.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-public.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-mac-public.tar.gz.sha256)| +| Public SDK package for the standard system (Windows/Linux)| 3.1.1 Release | [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-public.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/ohos-sdk-public.tar.gz.sha256)| ## What's New @@ -114,21 +117,22 @@ This version has the following updates to OpenHarmony 3.1 Release. **Table 3** New and enhanced features - | Subsystem| Standard System| Mini and Small Systems| +| 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 | +| SDK | SDKs are classified into full SDKs and public SDKs.<br>Note: The public SDK of API version 8 was released on July 6, 2022.| NA | +| 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 Application Not Response 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 @@ -159,4 +163,4 @@ For details about the adaptation status, see [SIG-Devboard](https://gitee.com/op | ------------------------------------------------------------ | ---------------------------------------------------------- | ------------------------------------------------- | ------------ | | [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 | +| [I59P32](https://gitee.com/openharmony/distributedhardware_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 | diff --git a/en/release-notes/api-change/v3.2-beta/js-apidiff-distributedschedule.md b/en/release-notes/api-change/v3.2-beta/js-apidiff-distributedschedule.md new file mode 100644 index 0000000000000000000000000000000000000000..d07a990a8e198a5f02adff1e3ad68960713eedb3 --- /dev/null +++ b/en/release-notes/api-change/v3.2-beta/js-apidiff-distributedschedule.md @@ -0,0 +1,16 @@ +# JS API Changes of the Distributed Scheduler Subsystem + +The table below lists the APIs changes of the distributed scheduler subsystem in OpenHarmony 3.2 Beta1 over OpenHarmony 3.1 Release. + +## API Changes + +| Module| Class| Method/Attribute/Enumeration/Constant| Change Type| +|---|---|---|---| +| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void; | Added| +| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", token: number): void; | Added| +| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void; | Added| +| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", token: number): void; | Added| +| ohos.continuation.continuationManager | continuationManager | on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void; | Deprecated| +| ohos.continuation.continuationManager | continuationManager | off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void; | Deprecated| +| ohos.continuation.continuationManager | continuationManager | on(type: "deviceDisconnect", callback: Callback\<string>): void; | Deprecated| +| ohos.continuation.continuationManager | continuationManager | off(type: "deviceDisconnect", callback?: Callback\<string>): void; | Deprecated| diff --git a/en/third-party-components/npm-third-party-guide.md b/en/third-party-components/npm-third-party-guide.md index 6ba26adfac994335031346467ff4c86b05929843..cd042e86e394e050ae8e69fc1f402eb1717156b9 100644 --- a/en/third-party-components/npm-third-party-guide.md +++ b/en/third-party-components/npm-third-party-guide.md @@ -1,11 +1,11 @@ # Using OpenHarmony JS/TS Third-Party Components -## OpenHarmony JS/TS Third-Party Components +## Overview -OpenHarmony JS/TS third-party components are delivered in the form of OpenHarmony npm packages. Developed based on the traditional npm components, OpenHarmony npm shared packages come with specially designed project structures and configuration files, which allow code of OpenHarmony UI pages and resources to be shared across modules or projects. The OpenHarmony npm package enables multiple modules or projects to share code related to OpenHarmony UI and resources. You can go to the [official npm website](https://docs.npmjs.com/about-npm) to learn about basic functions and mechanisms of npm. +OpenHarmony JS/TS third-party components are delivered in the form of OpenHarmony npm packages. Developed based on the traditional npm components, OpenHarmony npm shared packages come with specially designed project structures and configuration files. Such a package enables multiple modules or projects to share code related to OpenHarmony UI and resources. You can go to the [official npm website](https://docs.npmjs.com/about-npm) to learn about the basic functions and mechanisms of npm. ## Searching for OpenHarmony JS/TS Third-Party Components -1. Watch the [OpenHarmony-TPC/tpc_resource](https://gitee.com/openharmony-tpc/tpc_resource) project on the Gitee website. You can find a component based on the directory index. +1. Find the [OpenHarmony-TPC/tpc_resource](https://gitee.com/openharmony-tpc/tpc_resource) project on the Gitee website. You can find a component based on the directory index. 2. Visit the [OpenHarmony website](https://www.openharmony.cn/mainPlay/tpc) and search for required third-party components by type, category, or keyword. @@ -17,17 +17,17 @@ During application development, you can import JS/TS third-party components in t 2. Under **Terminal** project, go to the **entry** directory and run the target component's command to install the component. For details about the command, see "Download and Installation" of the third-party component on the OpenHarmony website. - The following uses the installation of the [vCard third-party component](https://growing.openharmony.cn/mainPlay/libraryMaps/vcard_595) as an example. Find the installation command in "Download and Installation" and then run the command. + The following uses the installation of the [vCard component](https://growing.openharmony.cn/mainPlay/libraryMaps/vcard_595) as an example. Find the installation command in "Download and Installation" and then run the command.   -3. A **node_modules** file is automatically generated in the project folder. In this example, the downloaded third-party library is **@ohos\VCard** in the **node_modules** directory. +3. Check for the **node_modules** file, which is automatically generated in the project folder. In this example, the downloaded third-party library is **@ohos\VCard** in the **node_modules** directory.  -4. The following dependency is automatically added to the **package.json** file: +4. Check for the dependency configuration, which is automatically added to the **package.json** file: ``` "dependencies": { @@ -35,10 +35,10 @@ During application development, you can import JS/TS third-party components in t } ``` -5. Import the component to the file that wants to use the component. +5. Import the component to the file that plans to use the component.  -6. Now you can use the APIs. +6. Use the APIs as you want.  diff --git a/en/third-party-components/third-party-components-introduction.md b/en/third-party-components/third-party-components-introduction.md index 6ed307016e9ff37ffa21aa0c6ccbd05feee45318..4416dd625bff709480c1f121da4dbfa644f705d1 100644 --- a/en/third-party-components/third-party-components-introduction.md +++ b/en/third-party-components/third-party-components-introduction.md @@ -1,5 +1,5 @@ # OpenHarmony Third-Party Components -OpenHarmony third-party components are verified software that work with the OpenHarmony system to facilitate your development of OpenHarmony devices or applications. Depending on the programming language they use, these components are classified as JS/TS third-party components or C/C++ third-party components. JS/TS third-party components use JavaScript or TypeScript and are usually imported as source code or OpenHarmony npm packages. They are used in application development. C/C++ third-party components use the programming language C/C++ and are usually imported as source code or OpenHarmony hpm packages. They are used as native APIs during application development or directly compiled in the OpenHarmony OS image during device development. +OpenHarmony third-party components are verified software that work with the OpenHarmony system to facilitate your development of OpenHarmony devices or applications. Depending on the programming language they use, these components are classified as JS/TS third-party components or C/C++ third-party components. JS/TS third-party components use the JavaScript or TypeScript programming language and are usually imported as source code or OpenHarmony npm packages. They are used in application development. C/C++ third-party components use the C/C++ programming language and are usually imported as source code or OpenHarmony hpm packages. They are used as native APIs during application development or directly compiled in the OpenHarmony OS image during device development. Currently, OpenHarmony provides UI, animation, image, multimedia, file, network, security, tool, and other third-party components. diff --git a/zh-cn/OpenHarmony-Overview_zh.md b/zh-cn/OpenHarmony-Overview_zh.md index c9d0e1714a216509ebb58dc8e55f8e7f556c54aa..d1e7d2846472ee5b603c6b576560b8ba4afe2ac9 100644 --- a/zh-cn/OpenHarmony-Overview_zh.md +++ b/zh-cn/OpenHarmony-Overview_zh.md @@ -1,27 +1,10 @@ # OpenHarmonyå¼€æºé¡¹ç›® -- [项目介ç»](#section1270210396435) -- [技术架构](#section2502124574318) -- [技术特性](#section12212842173518) -- [系统类型](#section145241459142416) -- [详细特å¾](#section25831825174419) -- [支æŒçš„å¼€å‘æ¿](#section25831825174123) -- [快速入门](#section44681652104210) -- [代ç 仓地å€](#section107651249181914) -- [å¼€å‘者文档](#section21031470109) -- [æºç 下载](#section39011923144212) -- [示例教程](#sectionsamples) -- [如何å‚与](#section19611528174215) -- [许å¯åè®®](#section1245517472115) -- [è”系方å¼](#section61728335424) - -[View English](https://gitee.com/openharmony/docs/blob/master/en/OpenHarmony-Overview.md) - -## 项目介ç»<a name="section1270210396435"></a> +## é¡¹ç›®ä»‹ç» OpenHarmony是由开放原åå¼€æºåŸºé‡‘会(OpenAtom Foundation)åµåŒ–åŠè¿è¥çš„å¼€æºé¡¹ç›®ï¼Œç›®æ ‡æ˜¯é¢å‘全场景ã€å…¨è¿žæŽ¥ã€å…¨æ™ºèƒ½æ—¶ä»£ï¼ŒåŸºäºŽå¼€æºçš„æ–¹å¼ï¼Œæ建一个智能终端设备æ“作系统的框架和平å°ï¼Œä¿ƒè¿›ä¸‡ç‰©äº’è”产业的ç¹è£å‘展。 -## 技术架构<a name="section2502124574318"></a> +## 技术架构 OpenHarmony整体éµä»Žåˆ†å±‚设计,从下å‘上ä¾æ¬¡ä¸ºï¼šå†…æ ¸å±‚ã€ç³»ç»ŸæœåŠ¡å±‚ã€æ¡†æž¶å±‚和应用层。系统功能按照“系统 \> å系统 \> 组件â€é€çº§å±•å¼€ï¼Œåœ¨å¤šè®¾å¤‡éƒ¨ç½²åœºæ™¯ä¸‹ï¼Œæ”¯æŒæ ¹æ®å®žé™…需求è£å‰ªæŸäº›éžå¿…è¦çš„组件。OpenHarmony技术架构如下所示: @@ -57,47 +40,47 @@ OpenHarmony整体éµä»Žåˆ†å±‚设计,从下å‘上ä¾æ¬¡ä¸ºï¼šå†…æ ¸å±‚ã€ç³»ç»Ÿ 应用层包括系统应用和第三方éžç³»ç»Ÿåº”用。应用由一个或多个FA(Feature Ability)或PA(Particle Ability)组æˆã€‚å…¶ä¸ï¼ŒFA有UIç•Œé¢ï¼Œæ供与用户交互的能力;而PAæ— UIç•Œé¢ï¼Œæä¾›åŽå°è¿è¡Œä»»åŠ¡çš„能力以åŠç»Ÿä¸€çš„æ•°æ®è®¿é—®æŠ½è±¡ã€‚基于FA/PAå¼€å‘的应用,能够实现特定的业务功能,支æŒè·¨è®¾å¤‡è°ƒåº¦ä¸Žåˆ†å‘,为用户æ供一致ã€é«˜æ•ˆçš„应用体验。 -## 技术特性<a name="section12212842173518"></a> +## 技术特性 -1. **硬件互助,资æºå…±äº«** +**硬件互助,资æºå…±äº«** - 主è¦é€šè¿‡ä¸‹åˆ—模å—è¾¾æˆ +主è¦é€šè¿‡ä¸‹åˆ—模å—è¾¾æˆ - - 分布å¼è½¯æ€»çº¿ +- 分布å¼è½¯æ€»çº¿ - 分布å¼è½¯æ€»çº¿æ˜¯å¤šè®¾å¤‡ç»ˆç«¯çš„ç»Ÿä¸€åŸºåº§ï¼Œä¸ºè®¾å¤‡é—´çš„æ— ç¼äº’è”æ供了统一的分布å¼é€šä¿¡èƒ½åŠ›ï¼Œèƒ½å¤Ÿå¿«é€Ÿå‘çŽ°å¹¶è¿žæŽ¥è®¾å¤‡ï¼Œé«˜æ•ˆåœ°ä¼ è¾“ä»»åŠ¡å’Œæ•°æ®ã€‚ + 分布å¼è½¯æ€»çº¿æ˜¯å¤šè®¾å¤‡ç»ˆç«¯çš„ç»Ÿä¸€åŸºåº§ï¼Œä¸ºè®¾å¤‡é—´çš„æ— ç¼äº’è”æ供了统一的分布å¼é€šä¿¡èƒ½åŠ›ï¼Œèƒ½å¤Ÿå¿«é€Ÿå‘çŽ°å¹¶è¿žæŽ¥è®¾å¤‡ï¼Œé«˜æ•ˆåœ°ä¼ è¾“ä»»åŠ¡å’Œæ•°æ®ã€‚ - - 分布å¼æ•°æ®ç®¡ç† +- 分布å¼æ•°æ®ç®¡ç† - 分布å¼æ•°æ®ç®¡ç†ä½äºŽåŸºäºŽåˆ†å¸ƒå¼è½¯æ€»çº¿ä¹‹ä¸Šçš„能力,实现了应用程åºæ•°æ®å’Œç”¨æˆ·æ•°æ®çš„分布å¼ç®¡ç†ã€‚用户数æ®ä¸å†ä¸Žå•ä¸€ç‰©ç†è®¾å¤‡ç»‘定,业务逻辑与数æ®å˜å‚¨åˆ†ç¦»ï¼Œåº”用跨设备è¿è¡Œæ—¶æ•°æ®æ— ç¼è¡”æŽ¥ï¼Œä¸ºæ‰“é€ ä¸€è‡´ã€æµç•…çš„ç”¨æˆ·ä½“éªŒåˆ›é€ äº†åŸºç¡€æ¡ä»¶ + 分布å¼æ•°æ®ç®¡ç†ä½äºŽåŸºäºŽåˆ†å¸ƒå¼è½¯æ€»çº¿ä¹‹ä¸Šçš„能力,实现了应用程åºæ•°æ®å’Œç”¨æˆ·æ•°æ®çš„分布å¼ç®¡ç†ã€‚用户数æ®ä¸å†ä¸Žå•ä¸€ç‰©ç†è®¾å¤‡ç»‘定,业务逻辑与数æ®å˜å‚¨åˆ†ç¦»ï¼Œåº”用跨设备è¿è¡Œæ—¶æ•°æ®æ— ç¼è¡”æŽ¥ï¼Œä¸ºæ‰“é€ ä¸€è‡´ã€æµç•…çš„ç”¨æˆ·ä½“éªŒåˆ›é€ äº†åŸºç¡€æ¡ä»¶ - - 分布å¼ä»»åŠ¡è°ƒåº¦ +- 分布å¼ä»»åŠ¡è°ƒåº¦ - 分布å¼ä»»åŠ¡è°ƒåº¦åŸºäºŽåˆ†å¸ƒå¼è½¯æ€»çº¿ã€åˆ†å¸ƒå¼æ•°æ®ç®¡ç†ã€åˆ†å¸ƒå¼Profileç‰æŠ€æœ¯ç‰¹æ€§ï¼Œæž„建统一的分布å¼æœåŠ¡ç®¡ç†ï¼ˆå‘现ã€åŒæ¥ã€æ³¨å†Œã€è°ƒç”¨ï¼‰æœºåˆ¶ï¼Œæ”¯æŒå¯¹è·¨è®¾å¤‡çš„应用进行远程å¯åŠ¨ã€è¿œç¨‹è°ƒç”¨ã€ç»‘定/解绑ã€ä»¥åŠè¿ç§»ç‰æ“ä½œï¼Œèƒ½å¤Ÿæ ¹æ®ä¸åŒè®¾å¤‡çš„能力ã€ä½ç½®ã€ä¸šåŠ¡è¿è¡ŒçŠ¶æ€ã€èµ„æºä½¿ç”¨æƒ…况并结åˆç”¨æˆ·çš„ä¹ æƒ¯å’Œæ„图,选择最åˆé€‚的设备è¿è¡Œåˆ†å¸ƒå¼ä»»åŠ¡ + 分布å¼ä»»åŠ¡è°ƒåº¦åŸºäºŽåˆ†å¸ƒå¼è½¯æ€»çº¿ã€åˆ†å¸ƒå¼æ•°æ®ç®¡ç†ã€åˆ†å¸ƒå¼Profileç‰æŠ€æœ¯ç‰¹æ€§ï¼Œæž„建统一的分布å¼æœåŠ¡ç®¡ç†ï¼ˆå‘现ã€åŒæ¥ã€æ³¨å†Œã€è°ƒç”¨ï¼‰æœºåˆ¶ï¼Œæ”¯æŒå¯¹è·¨è®¾å¤‡çš„应用进行远程å¯åŠ¨ã€è¿œç¨‹è°ƒç”¨ã€ç»‘定/解绑ã€ä»¥åŠè¿ç§»ç‰æ“ä½œï¼Œèƒ½å¤Ÿæ ¹æ®ä¸åŒè®¾å¤‡çš„能力ã€ä½ç½®ã€ä¸šåŠ¡è¿è¡ŒçŠ¶æ€ã€èµ„æºä½¿ç”¨æƒ…况并结åˆç”¨æˆ·çš„ä¹ æƒ¯å’Œæ„图,选择最åˆé€‚的设备è¿è¡Œåˆ†å¸ƒå¼ä»»åŠ¡ - - 设备虚拟化 +- 设备虚拟化 - 分布å¼è®¾å¤‡è™šæ‹ŸåŒ–å¹³å°å¯ä»¥å®žçŽ°ä¸åŒè®¾å¤‡çš„资æºèžåˆã€è®¾å¤‡ç®¡ç†ã€æ•°æ®å¤„ç†ï¼Œå°†å‘¨è¾¹è®¾å¤‡ä½œä¸ºæ‰‹æœºèƒ½åŠ›çš„延伸,共åŒå½¢æˆä¸€ä¸ªè¶…级虚拟终端。 + 分布å¼è®¾å¤‡è™šæ‹ŸåŒ–å¹³å°å¯ä»¥å®žçŽ°ä¸åŒè®¾å¤‡çš„资æºèžåˆã€è®¾å¤‡ç®¡ç†ã€æ•°æ®å¤„ç†ï¼Œå°†å‘¨è¾¹è®¾å¤‡ä½œä¸ºæ‰‹æœºèƒ½åŠ›çš„延伸,共åŒå½¢æˆä¸€ä¸ªè¶…级虚拟终端。 -2. **一次开å‘,多端部署** +**一次开å‘,多端部署** - OpenHarmonyæ供用户程åºæ¡†æž¶ã€Ability框架以åŠUI框架,能够ä¿è¯å¼€å‘的应用在多终端è¿è¡Œæ—¶ä¿è¯ä¸€è‡´æ€§ã€‚一次开å‘ã€å¤šç«¯éƒ¨ç½²ã€‚ +OpenHarmonyæ供用户程åºæ¡†æž¶ã€Ability框架以åŠUI框架,能够ä¿è¯å¼€å‘的应用在多终端è¿è¡Œæ—¶ä¿è¯ä¸€è‡´æ€§ã€‚一次开å‘ã€å¤šç«¯éƒ¨ç½²ã€‚ - 多终端软件平å°API具备一致性,确ä¿ç”¨æˆ·ç¨‹åºçš„è¿è¡Œå…¼å®¹æ€§ã€‚ +多终端软件平å°API具备一致性,确ä¿ç”¨æˆ·ç¨‹åºçš„è¿è¡Œå…¼å®¹æ€§ã€‚ - - 支æŒåœ¨å¼€å‘过程ä¸é¢„览终端的能力适é…情况(CPU/内å˜/外设/软件资æºç‰ï¼‰ã€‚ - - 支æŒæ ¹æ®ç”¨æˆ·ç¨‹åºä¸Žè½¯ä»¶å¹³å°çš„兼容性æ¥è°ƒåº¦ç”¨æˆ·å‘ˆçŽ°ã€‚ +- 支æŒåœ¨å¼€å‘过程ä¸é¢„览终端的能力适é…情况(CPU/内å˜/外设/软件资æºç‰ï¼‰ã€‚ +- 支æŒæ ¹æ®ç”¨æˆ·ç¨‹åºä¸Žè½¯ä»¶å¹³å°çš„兼容性æ¥è°ƒåº¦ç”¨æˆ·å‘ˆçŽ°ã€‚ -3. **统一OS,弹性部署** +**统一OS,弹性部署** - OpenHarmony通过组件化和组件弹性化ç‰è®¾è®¡æ–¹æ³•ï¼Œåšåˆ°ç¡¬ä»¶èµ„æºçš„å¯å¤§å¯å°ï¼Œåœ¨å¤šç§ç»ˆç«¯è®¾å¤‡é—´ï¼ŒæŒ‰éœ€å¼¹æ€§éƒ¨ç½²ï¼Œå…¨é¢è¦†ç›–了ARMã€RISC-Vã€x86ç‰å„ç§CPU,从百KiB到GiB级别的RAM。 +OpenHarmony通过组件化和组件弹性化ç‰è®¾è®¡æ–¹æ³•ï¼Œåšåˆ°ç¡¬ä»¶èµ„æºçš„å¯å¤§å¯å°ï¼Œåœ¨å¤šç§ç»ˆç«¯è®¾å¤‡é—´ï¼ŒæŒ‰éœ€å¼¹æ€§éƒ¨ç½²ï¼Œå…¨é¢è¦†ç›–了ARMã€RISC-Vã€x86ç‰å„ç§CPU,从百KiB到GiB级别的RAM。 -## 系统类型<a name="section145241459142416"></a> +## 系统类型 OpenHarmony支æŒå¦‚ä¸‹å‡ ç§ç³»ç»Ÿç±»åž‹ï¼š @@ -114,7 +97,7 @@ OpenHarmony支æŒå¦‚ä¸‹å‡ ç§ç³»ç»Ÿç±»åž‹ï¼š é¢å‘应用处ç†å™¨ä¾‹å¦‚Arm Cortex-A的设备,支æŒçš„设备最å°å†…å˜ä¸º128MiB,å¯ä»¥æ供增强的交互能力ã€3D GPU以åŠç¡¬ä»¶åˆæˆèƒ½åŠ›ã€æ›´å¤šæŽ§ä»¶ä»¥åŠåŠ¨æ•ˆæ›´ä¸°å¯Œçš„图形能力ã€å®Œæ•´çš„应用框架。å¯æ”¯æ’‘的产å“如高端的冰箱显示å±ã€‚ -## 详细特å¾<a name="section25831825174419"></a> +## è¯¦ç»†ç‰¹å¾ åœ¨ä»‹ç»OpenHarmony特性å‰ï¼Œéœ€è¦å…ˆæ˜Žç¡®ä»¥ä¸‹ä¸¤ä¸ªåŸºæœ¬æ¦‚念: @@ -126,245 +109,59 @@ OpenHarmony支æŒå¦‚ä¸‹å‡ ç§ç³»ç»Ÿç±»åž‹ï¼š 对å系统的进一æ¥æ‹†åˆ†ï¼Œå¯å¤ç”¨çš„软件å•å…ƒï¼Œå®ƒåŒ…å«æºç ã€é…置文件ã€èµ„æºæ–‡ä»¶å’Œç¼–译脚本;能独立构建,以二进制方å¼é›†æˆï¼Œå…·å¤‡ç‹¬ç«‹éªŒè¯èƒ½åŠ›çš„二进制å•å…ƒã€‚ - 以下为OpenHarmonyä¸ç›¸å…³çš„å系统简介,详细介ç»è§å系统Readme文档,入å£ï¼š[https://gitee.com/openharmony/docs/tree/master/zh-cn/readme](https://gitee.com/openharmony/docs/tree/master/zh-cn/readme)。 -<a name="table18981149155318"></a> - -<table><thead align="left"><tr id="row69811925313"><th class="cellrowborder" valign="top" width="11.148885111488852%" id="mcps1.1.4.1.1"><p id="p9143172718537"><a name="p9143172718537"></a><a name="p9143172718537"></a>åç³» 统</p> -</th> -<th class="cellrowborder" valign="top" width="80.49195080491951%" id="mcps1.1.4.1.2"><p id="p6143122775319"><a name="p6143122775319"></a><a name="p6143122775319"></a>简 介</p> -</th> -<th class="cellrowborder" valign="top" width="8.35916408359164%" id="mcps1.1.4.1.3"><p id="p36827655311"><a name="p36827655311"></a><a name="p36827655311"></a>适用范围</p> -</th> -</tr> -</thead> -<tbody><tr id="row1746235812115"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p84622581117"><a name="p84622581117"></a><a name="p84622581117"></a>å†…æ ¸</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p34626584118"><a name="p34626584118"></a><a name="p34626584118"></a>支æŒé€‚用于嵌入å¼è®¾å¤‡åŠèµ„æºå—é™è®¾å¤‡ï¼Œå…·æœ‰å°ä½“积ã€é«˜æ€§èƒ½ã€ä½ŽåŠŸè€—ç‰ç‰¹å¾çš„LiteOSå†…æ ¸ï¼›æ”¯æŒåŸºäºŽlinux kernelæ¼”è¿›çš„é€‚ç”¨äºŽæ ‡å‡†ç³»ç»Ÿçš„linuxå†…æ ¸ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p31041221121"><a name="p31041221121"></a><a name="p31041221121"></a>å°åž‹ç³»ç»Ÿ</p> -<p id="p16450192619121"><a name="p16450192619121"></a><a name="p16450192619121"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row4465751131114"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p12465145131117"><a name="p12465145131117"></a><a name="p12465145131117"></a>分布å¼æ–‡ä»¶</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p1046615111118"><a name="p1046615111118"></a><a name="p1046615111118"></a>æ供本地åŒæ¥JS文件接å£ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p15466135171117"><a name="p15466135171117"></a><a name="p15466135171117"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row14286184818110"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1328654871112"><a name="p1328654871112"></a><a name="p1328654871112"></a>图形</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p15912684317"><a name="p15912684317"></a><a name="p15912684317"></a>主è¦åŒ…括UI组件ã€å¸ƒå±€ã€åŠ¨ç”»ã€å—体ã€è¾“入事件ã€çª—å£ç®¡ç†ã€æ¸²æŸ“绘制ç‰æ¨¡å—,构建基于轻é‡OS应用框架满足硬件资æºè¾ƒå°çš„物è”ç½‘è®¾å¤‡æˆ–è€…æž„å»ºåŸºäºŽæ ‡å‡†OS的应用框架满足富设备(如平æ¿å’Œè½»æ™ºèƒ½æœºç‰ï¼‰çš„OpenHarmony系统应用开å‘。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p228719483115"><a name="p228719483115"></a><a name="p228719483115"></a>所有系统</p> -</td> -</tr> -<tr id="row4981119185313"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p43071335181312"><a name="p43071335181312"></a><a name="p43071335181312"></a>驱动</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p849919919515"><a name="p849919919515"></a><a name="p849919919515"></a>OpenHarmony驱动å系统采用Cé¢å‘对象编程模型构建,通过平å°è§£è€¦ã€å†…æ ¸è§£è€¦ï¼Œå…¼å®¹ä¸åŒå†…æ ¸ï¼Œæ供了归一化的驱动平å°åº•åº§ï¼Œæ—¨åœ¨ä¸ºå¼€å‘者æ供更精准ã€æ›´é«˜æ•ˆçš„å¼€å‘环境,力求åšåˆ°ä¸€æ¬¡å¼€å‘,多系统部署。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p7909102101420"><a name="p7909102101420"></a><a name="p7909102101420"></a>所有系统</p> -</td> -</tr> -<tr id="row1698219916532"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p183071635131320"><a name="p183071635131320"></a><a name="p183071635131320"></a>电æºç®¡ç†æœåŠ¡</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p1534121801513"><a name="p1534121801513"></a><a name="p1534121801513"></a>电æºç®¡ç†æœåŠ¡å系统æ供如下功能:é‡å¯ç³»ç»Ÿï¼›ç®¡ç†ä¼‘çœ è¿è¡Œé”;系统电æºçŠ¶æ€ç®¡ç†å’ŒæŸ¥è¯¢ï¼›å……ç”µå’Œç”µæ± çŠ¶æ€æŸ¥è¯¢å’Œä¸ŠæŠ¥ï¼›æ˜¾ç¤ºäº®çå±çŠ¶æ€ç®¡ç†ï¼ŒåŒ…括显示亮度调节。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p0562145615152"><a name="p0562145615152"></a><a name="p0562145615152"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row1998212985315"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1230718353132"><a name="p1230718353132"></a><a name="p1230718353132"></a>æ³›SensoræœåŠ¡</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p114999919515"><a name="p114999919515"></a><a name="p114999919515"></a>æ³›Sensorä¸åŒ…å«ä¼ 感器和å°å™¨ä»¶ï¼Œä¼ 感器用于侦测环境ä¸æ‰€å‘生事件或å˜åŒ–,并将æ¤æ¶ˆæ¯å‘é€è‡³å…¶ä»–电å设备,å°å™¨ä»¶ç”¨äºŽå‘å¤–ä¼ é€’ä¿¡å·çš„设备,包括马达和LEDç¯ï¼Œå¯¹å¼€å‘者æ供控制马达振动和LEDç¯å¼€å…³çš„能力。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p7683136135317"><a name="p7683136135317"></a><a name="p7683136135317"></a>å°åž‹ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row1398249165320"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1930743511318"><a name="p1930743511318"></a><a name="p1930743511318"></a>多模输入</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p13832172015162"><a name="p13832172015162"></a><a name="p13832172015162"></a>OpenHarmony旨在为开å‘者æä¾›NUI(Natural User Interface)的交互方å¼ï¼Œæœ‰åˆ«äºŽä¼ 统æ“作系统的输入,在OpenHarmony上,我们将多ç§ç»´åº¦çš„输入整åˆåœ¨ä¸€èµ·ï¼Œå¼€å‘者å¯ä»¥å€ŸåŠ©åº”用程åºæ¡†æž¶ã€ç³»ç»Ÿè‡ªå¸¦çš„UI组件或API接å£è½»æ¾åœ°å®žçŽ°å…·æœ‰å¤šç»´ã€è‡ªç„¶äº¤äº’特点的应用程åºã€‚具体æ¥è¯´ï¼Œå¤šæ¨¡è¾“å…¥å系统目å‰æ”¯æŒä¼ 统的输入交互方å¼ï¼Œä¾‹å¦‚按键和触控。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p025515141075"><a name="p025515141075"></a><a name="p025515141075"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row209823955313"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1030711354137"><a name="p1030711354137"></a><a name="p1030711354137"></a>å¯åŠ¨æ¢å¤</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p54461340151820"><a name="p54461340151820"></a><a name="p54461340151820"></a>å¯åŠ¨æ¢å¤è´Ÿè´£åœ¨å†…æ ¸å¯åŠ¨ä¹‹åŽï¼Œåº”用å¯åŠ¨ä¹‹å‰çš„æ“作系统ä¸é—´å±‚çš„å¯åŠ¨ã€‚并æ供系统属性查询ã€ä¿®æ”¹åŠè®¾å¤‡æ¢å¤å‡ºåŽ‚设置的功能。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p8683362533"><a name="p8683362533"></a><a name="p8683362533"></a>所有系统</p> -</td> -</tr> -<tr id="row1982159115313"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p14307173571315"><a name="p14307173571315"></a><a name="p14307173571315"></a>å‡çº§æœåŠ¡</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p887484183"><a name="p887484183"></a><a name="p887484183"></a>å¯æ”¯æŒOpenHarmony设备的OTA(Over The Air)å‡çº§ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p10550164995117"><a name="p10550164995117"></a><a name="p10550164995117"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row89839920531"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p123071435151319"><a name="p123071435151319"></a><a name="p123071435151319"></a>å¸å·</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p2772313127"><a name="p2772313127"></a><a name="p2772313127"></a>支æŒåœ¨ç«¯ä¾§å¯¹æŽ¥åŽ‚商云å¸å·åº”用,æ供分布å¼å¸å·ç™»å½•çŠ¶æ€æŸ¥è¯¢å’Œæ›´æ–°çš„管ç†èƒ½åŠ›ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p19928023151913"><a name="p19928023151913"></a><a name="p19928023151913"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row1598389185315"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p11473102882017"><a name="p11473102882017"></a><a name="p11473102882017"></a>编译构建</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p22956349202"><a name="p22956349202"></a><a name="p22956349202"></a>编译构建å系统æ供了一个基于Gnå’Œninja的编译构建框架。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p183114819179"><a name="p183114819179"></a><a name="p183114819179"></a>所有系统</p> -</td> -</tr> -<tr id="row179834916539"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1347382819202"><a name="p1347382819202"></a><a name="p1347382819202"></a>测试</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p1850179125115"><a name="p1850179125115"></a><a name="p1850179125115"></a>å¼€å‘过程采用测试驱动开å‘模å¼ï¼Œå¼€å‘者基于系统新增特性å¯ä»¥é€šè¿‡å¼€å‘者自己开å‘用例ä¿è¯ï¼Œå¯¹äºŽç³»ç»Ÿå·²æœ‰ç‰¹æ€§çš„修改,也å¯é€šè¿‡ä¿®æ”¹é¡¹ç›®ä¸åŽŸæœ‰çš„测试用例ä¿è¯ï¼Œå¼€å‘者测试旨在帮助开å‘者在开å‘阶段就能开å‘出高质é‡ä»£ç 。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p15458348191719"><a name="p15458348191719"></a><a name="p15458348191719"></a>所有系统</p> -</td> -</tr> -<tr id="row1698317918532"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p11473172817202"><a name="p11473172817202"></a><a name="p11473172817202"></a>æ•°æ®ç®¡ç†</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p2030983518561"><a name="p2030983518561"></a><a name="p2030983518561"></a>æ•°æ®ç®¡ç†æ”¯æŒåº”用本地数æ®ç®¡ç†å’Œåˆ†å¸ƒå¼æ•°æ®ç®¡ç†ï¼š</p> -<a name="ul2727156145217"></a><a name="ul2727156145217"></a><ul id="ul2727156145217"><li>支æŒåº”用本地数æ®ç®¡ç†ï¼ŒåŒ…括轻é‡çº§å好数æ®åº“,关系型数æ®åº“。</li><li>支æŒåˆ†å¸ƒå¼æ•°æ®æœåŠ¡ï¼Œä¸ºåº”用程åºæä¾›ä¸åŒè®¾å¤‡é—´æ•°æ®åº“æ•°æ®åˆ†å¸ƒå¼çš„能力。</li></ul> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p193679548203"><a name="p193679548203"></a><a name="p193679548203"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row198318945311"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p14473132812018"><a name="p14473132812018"></a><a name="p14473132812018"></a>è¯è¨€ç¼–译è¿è¡Œæ—¶</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p17753537218"><a name="p17753537218"></a><a name="p17753537218"></a>è¯è¨€è¿è¡Œæ—¶æ供了JSã€C/C++è¯è¨€ç¨‹åºçš„编译ã€æ‰§è¡ŒçŽ¯å¢ƒï¼Œæ供支撑è¿è¡Œæ—¶çš„基础库,以åŠå…³è”çš„API接å£ã€ç¼–译器和é…套工具。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p14593146192111"><a name="p14593146192111"></a><a name="p14593146192111"></a>所有系统</p> -</td> -</tr> -<tr id="row098416935318"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p64731628132015"><a name="p64731628132015"></a><a name="p64731628132015"></a>分布å¼ä»»åŠ¡è°ƒåº¦</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p55320348170"><a name="p55320348170"></a><a name="p55320348170"></a>æ供系统æœåŠ¡çš„å¯åŠ¨ã€æ³¨å†Œã€æŸ¥è¯¢åŠç®¡ç†èƒ½åŠ›ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p76835611530"><a name="p76835611530"></a><a name="p76835611530"></a>所有系统</p> -</td> -</tr> -<tr id="row11522144014127"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p847382818209"><a name="p847382818209"></a><a name="p847382818209"></a>JS UI框架</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p18885204913282"><a name="p18885204913282"></a><a name="p18885204913282"></a>JS UI框架是OpenHarmony UIå¼€å‘框架,支æŒç±»Web范å¼ç¼–程。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p18278134513216"><a name="p18278134513216"></a><a name="p18278134513216"></a>所有系统</p> -</td> -</tr> -<tr id="row163116577176"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p9473192862015"><a name="p9473192862015"></a><a name="p9473192862015"></a>媒体</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p17895171152211"><a name="p17895171152211"></a><a name="p17895171152211"></a>æ供音频ã€è§†é¢‘ã€ç›¸æœºç‰ç®€å•æœ‰æ•ˆçš„媒体组件开å‘接å£ï¼Œä½¿å¾—应用开å‘者轻æ¾ä½¿ç”¨ç³»ç»Ÿçš„多媒体资æºã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p7683126105314"><a name="p7683126105314"></a><a name="p7683126105314"></a>所有系统</p> -</td> -</tr> -<tr id="row99841913538"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p34736280204"><a name="p34736280204"></a><a name="p34736280204"></a>事件通知</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p1328485917223"><a name="p1328485917223"></a><a name="p1328485917223"></a>公共事件管ç†å®žçŽ°äº†è®¢é˜…ã€é€€è®¢ã€å‘布ã€æŽ¥æ”¶å…¬å…±äº‹ä»¶ï¼ˆä¾‹å¦‚亮çå±äº‹ä»¶ã€USBæ’拔事件)的能力。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p19305121815138"><a name="p19305121815138"></a><a name="p19305121815138"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row199841792533"><td class="cellrowborder" align="left" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p6473102817205"><a name="p6473102817205"></a><a name="p6473102817205"></a>æ‚散软件æœåŠ¡</p> -</td> -<td class="cellrowborder" align="left" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p8502149175110"><a name="p8502149175110"></a><a name="p8502149175110"></a>æ供设置时间的能力。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p1962012112314"><a name="p1962012112314"></a><a name="p1962012112314"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row176674368222"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p3667203652214"><a name="p3667203652214"></a><a name="p3667203652214"></a>包管ç†å系统</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p12923326230"><a name="p12923326230"></a><a name="p12923326230"></a>æ供包安装ã€å¸è½½ã€æ›´æ–°ã€æŸ¥è¯¢ç‰èƒ½åŠ›ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p12667123619226"><a name="p12667123619226"></a><a name="p12667123619226"></a>所有系统</p> -</td> -</tr> -<tr id="row65111417226"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p612981114248"><a name="p612981114248"></a><a name="p612981114248"></a>电è¯æœåŠ¡</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p19521141152212"><a name="p19521141152212"></a><a name="p19521141152212"></a>æä¾›SIMå¡ã€æœç½‘ã€èœ‚çªæ•°æ®ã€èœ‚çªé€šè¯ã€çŸå½©ä¿¡ç‰èœ‚çªç§»åŠ¨ç½‘络基础通信能力,å¯ç®¡ç†å¤šç±»åž‹é€šè¯å’Œæ•°æ®ç½‘络连接,为应用开å‘者æ供便æ·ä¸€è‡´çš„通信API。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p124681352134"><a name="p124681352134"></a><a name="p124681352134"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row10194183317227"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p14129311172416"><a name="p14129311172416"></a><a name="p14129311172416"></a>公共基础类库</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p21941533132218"><a name="p21941533132218"></a><a name="p21941533132218"></a>公共基础库å˜æ”¾OpenHarmony通用的基础组件。这些基础组件å¯è¢«OpenHarmonyå„业务å系统åŠä¸Šå±‚应用所使用。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p1219413311229"><a name="p1219413311229"></a><a name="p1219413311229"></a>所有系统</p> -</td> -</tr> -<tr id="row9664349242"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p116653462411"><a name="p116653462411"></a><a name="p116653462411"></a>ç ”å‘工具链</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p15701144517139"><a name="p15701144517139"></a><a name="p15701144517139"></a>æ供设备连接调试器hdcï¼›æ供了性能跟踪能力和接å£ï¼›æ供了性能调优框架,旨在为开å‘者æ供一套性能调优平å°ï¼Œå¯ä»¥ç”¨æ¥åˆ†æžå†…å˜ã€æ€§èƒ½ç‰é—®é¢˜ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p1696110251415"><a name="p1696110251415"></a><a name="p1696110251415"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row1449910380242"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p238324932415"><a name="p238324932415"></a><a name="p238324932415"></a>分布å¼è½¯æ€»çº¿</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p17499153862420"><a name="p17499153862420"></a><a name="p17499153862420"></a>分布å¼è½¯æ€»çº¿æ—¨åœ¨ä¸ºOpenHarmony系统æ供跨进程或跨设备的通信能力,主è¦åŒ…å«è½¯æ€»çº¿å’Œè¿›ç¨‹é—´é€šä¿¡ä¸¤éƒ¨åˆ†ã€‚å…¶ä¸ï¼Œè½¯æ€»çº¿ä¸ºåº”用和系统æ供近场设备间分布å¼é€šä¿¡çš„能力,æä¾›ä¸åŒºåˆ†é€šä¿¡æ–¹å¼çš„设备å‘çŽ°ï¼Œè¿žæŽ¥ï¼Œç»„ç½‘å’Œä¼ è¾“åŠŸèƒ½ï¼›è€Œè¿›ç¨‹é—´é€šä¿¡åˆ™æä¾›äº†å¯¹è®¾å¤‡å†…æˆ–è®¾å¤‡é—´æ— å·®åˆ«çš„è¿›ç¨‹é—´é€šä¿¡èƒ½åŠ›ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p5499183812418"><a name="p5499183812418"></a><a name="p5499183812418"></a>所有系统</p> -</td> -</tr> -<tr id="row1733413367244"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p1238318490244"><a name="p1238318490244"></a><a name="p1238318490244"></a>XTS</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p2334113611248"><a name="p2334113611248"></a><a name="p2334113611248"></a>XTS是OpenHarmony兼容性测试套件的集åˆï¼Œå½“å‰åŒ…括acts(application compatibility test suite)应用兼容性测试套,åŽç»ä¼šæ‹“展dcts(device compatibility test suite)设备兼容性测试套ç‰ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p03341936102418"><a name="p03341936102418"></a><a name="p03341936102418"></a>所有系统</p> -</td> -</tr> -<tr id="row1817163212413"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p53831049112416"><a name="p53831049112416"></a><a name="p53831049112416"></a>系统应用</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p91717327249"><a name="p91717327249"></a><a name="p91717327249"></a>系统应用æ供了OpenHarmonyæ ‡å‡†ç‰ˆä¸Šçš„éƒ¨åˆ†ç³»ç»Ÿåº”ç”¨ï¼Œå¦‚æ¡Œé¢ã€SystemUIã€è®¾ç½®ç‰åº”用,为开å‘者æä¾›äº†æž„å»ºæ ‡å‡†ç‰ˆåº”ç”¨çš„å…·ä½“å®žä¾‹ï¼Œè¿™äº›åº”ç”¨æ”¯æŒåœ¨æ‰€æœ‰æ ‡å‡†ç‰ˆç³»ç»Ÿçš„设备上使用。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p10171133218245"><a name="p10171133218245"></a><a name="p10171133218245"></a>æ ‡å‡†ç³»ç»Ÿ</p> -</td> -</tr> -<tr id="row3577428102418"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p93831496249"><a name="p93831496249"></a><a name="p93831496249"></a>DFX</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p8578828122413"><a name="p8578828122413"></a><a name="p8578828122413"></a>DFX是OpenHarmonyéžåŠŸèƒ½å±žæ€§èƒ½åŠ›ï¼ŒåŒ…å«æ—¥å¿—系统ã€åº”用和系统事件日志接å£ã€äº‹ä»¶æ—¥å¿—订阅æœåŠ¡ã€æ•…障信æ¯ç”Ÿæˆé‡‡é›†ç‰åŠŸèƒ½ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p18578102822411"><a name="p18578102822411"></a><a name="p18578102822411"></a>所有系统</p> -</td> -</tr> -<tr id="row418795214250"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p860151102616"><a name="p860151102616"></a><a name="p860151102616"></a>å…¨çƒåŒ–</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p41871252102515"><a name="p41871252102515"></a><a name="p41871252102515"></a>当OpenHarmony设备或应用在全çƒä¸åŒåŒºåŸŸä½¿ç”¨æ—¶ï¼Œç³»ç»Ÿå’Œåº”用需è¦æ»¡è¶³ä¸åŒå¸‚场用户关于è¯è¨€ã€æ–‡åŒ–ä¹ ä¿—çš„éœ€æ±‚ã€‚å…¨çƒåŒ–å系统æ供支æŒå¤šè¯è¨€ã€å¤šæ–‡åŒ–的能力,包括资æºç®¡ç†èƒ½åŠ›å’Œå›½é™…化能力。</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p201658544174"><a name="p201658544174"></a><a name="p201658544174"></a>所有系统</p> -</td> -</tr> -<tr id="row16870124919255"><td class="cellrowborder" valign="top" width="11.148885111488852%" headers="mcps1.1.4.1.1 "><p id="p136021513265"><a name="p136021513265"></a><a name="p136021513265"></a>安全</p> -</td> -<td class="cellrowborder" valign="top" width="80.49195080491951%" headers="mcps1.1.4.1.2 "><p id="p2871134913255"><a name="p2871134913255"></a><a name="p2871134913255"></a>安全å系统包括系统安全ã€æ•°æ®å®‰å…¨ã€åº”用安全ç‰æ¨¡å—,为OpenHarmonyæ供了ä¿æŠ¤ç³»ç»Ÿå’Œå’Œç”¨æˆ·æ•°æ®çš„能力。安全å系统当å‰å¼€æºçš„功能,包括应用完整性ä¿æŠ¤ã€åº”用æƒé™ç®¡ç†ã€è®¾å¤‡è®¤è¯ã€å¯†é’¥ç®¡ç†æœåŠ¡ã€‚</p> -</td> -<td class="cellrowborder" valign="top" width="8.35916408359164%" headers="mcps1.1.4.1.3 "><p id="p1487113491251"><a name="p1487113491251"></a><a name="p1487113491251"></a>所有系统</p> -</td> -</tr> -</tbody> -</table> - -## 支æŒçš„å¼€å‘æ¿<a name="section25831825174123"></a> - -当å‰OpenHarmony社区支æŒ17款开å‘æ¿ï¼Œä¸‹è¡¨ä»‹ç»3款(æ¤å¤„选择三ç§ç³»ç»Ÿç±»åž‹é¦–款进入OpenHarmony主干的开å‘æ¿ï¼‰ï¼Œæ›´å¤šå¼€å‘æ¿ä¿¡æ¯ï¼Œè¯·å‚考[社区支æŒçš„å¼€å‘æ¿æ¸…å•](device-dev/dev-board-on-the-master.md)。 - -| 系统类型 | å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ› | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | -| -------- | -------- | -------- | -------- | -------- | -------- | -| æ ‡å‡†ç³»ç»Ÿ | 润和DAYU200 | RK3568 | 润和HH-SCDAYU200基于Rockchip RK3568,集æˆåŒæ ¸å¿ƒæž¶æž„GPU以åŠé«˜æ•ˆèƒ½NPUï¼›æ¿è½½å››æ ¸64ä½Cortex-A55 处ç†å™¨é‡‡ç”¨22nm先进工艺,主频高达2.0GHz;支æŒè“牙ã€Wi-Fiã€éŸ³é¢‘ã€è§†é¢‘和摄åƒå¤´ç‰åŠŸèƒ½ï¼Œæ‹¥æœ‰ä¸°å¯Œçš„扩展接å£ï¼Œæ”¯æŒå¤šç§è§†é¢‘输入输出接å£ï¼›é…ç½®åŒåƒå…†è‡ªé€‚应RJ45以太网å£ï¼Œå¯æ»¡è¶³NVRã€å·¥ä¸šç½‘å…³ç‰å¤šç½‘å£äº§å“需求。 | 影音娱ä¹ã€æ™ºæ…§å‡ºè¡Œã€æ™ºèƒ½å®¶å±…,如烟机ã€çƒ¤ç®±ã€è·‘æ¥æœºç‰ã€‚ | 代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) <br/> 社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | -| å°åž‹ç³»ç»Ÿ | Hispark_Taurus | Hi3516DV300 | Hi3516DV300是新一代Smart HD IPæ‘„åƒæœºSOC,集æˆæ–°ä¸€ä»£ISP(Image Signal Processor)ã€H.265视频压缩编ç 器ã€é«˜æ€§èƒ½NNIE引擎,在低ç 率ã€é«˜ç”»è´¨ã€æ™ºèƒ½å¤„ç†å’Œåˆ†æžã€ä½ŽåŠŸè€—ç‰æ–¹é¢æœ‰è¾ƒå¥½çš„性能。 | 带å±æ™ºèƒ½ç¡¬ä»¶ï¼Œæ¯”如带å±å†°ç®±ã€è½¦æœºç‰ã€‚ | 代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) <br/> 社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | -| è½»é‡ç³»ç»Ÿ | 欧智通V200ZR | BES2600 | Multi-modal V200Z-Rå¼€å‘æ¿æ˜¯åŸºäºŽæ’玄科技BES2600WM芯片的一款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”AIoT SoCå¼€å‘æ¿Multi-modal V200Z-Rå¼€å‘æ¿ï¼Œå•æ¨¡ç»„集æˆå››æ ¸ARM处ç†å™¨ï¼ˆæœ€é«˜ä¸»é¢‘1GHz),集æˆåŒé¢‘WiFi + åŒæ¨¡è“牙,支æŒæ ‡å‡†çš„802.11 a/b/g/n/å议,支æŒBT/BLE 5.2å议,内建多ç§å®¹é‡çš„RAM(最大42MB)和Flash(最大32MB),支æŒMIPI DSIåŠCSI,适用于å„ç§AIoT多模æ€VUI + GUI交互硬件场景。 | 智能硬件ã€å¸¦å±ç±»æ¨¡ç»„产å“,如音箱ã€æ‰‹è¡¨ç‰ã€‚ | 代ç 仓:<br/>[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br/>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br/>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) <br/> 社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | - -## 快速入门<a name="section44681652104210"></a> + +| å系统 | 简 介 | 适用范围 | +| -------- | -------- | -------- | +| å†…æ ¸ | 支æŒé€‚用于嵌入å¼è®¾å¤‡åŠèµ„æºå—é™è®¾å¤‡ï¼Œå…·æœ‰å°ä½“积ã€é«˜æ€§èƒ½ã€ä½ŽåŠŸè€—ç‰ç‰¹å¾çš„LiteOSå†…æ ¸ï¼›æ”¯æŒåŸºäºŽlinux kernelæ¼”è¿›çš„é€‚ç”¨äºŽæ ‡å‡†ç³»ç»Ÿçš„linuxå†…æ ¸ã€‚ | å°åž‹ç³»ç»Ÿ<br>æ ‡å‡†ç³»ç»Ÿ | +| 分布å¼æ–‡ä»¶ | æ供本地åŒæ¥JS文件接å£ã€‚ | æ ‡å‡†ç³»ç»Ÿ | +| 图形 | 主è¦åŒ…括UI组件ã€å¸ƒå±€ã€åŠ¨ç”»ã€å—体ã€è¾“入事件ã€çª—å£ç®¡ç†ã€æ¸²æŸ“绘制ç‰æ¨¡å—,构建基于轻é‡OS应用框架满足硬件资æºè¾ƒå°çš„物è”ç½‘è®¾å¤‡æˆ–è€…æž„å»ºåŸºäºŽæ ‡å‡†OS的应用框架满足富设备(如平æ¿å’Œè½»æ™ºèƒ½æœºç‰ï¼‰çš„OpenHarmony系统应用开å‘。 | 所有系统 | +| 驱动 | OpenHarmony驱动å系统采用Cé¢å‘对象编程模型构建,通过平å°è§£è€¦ã€å†…æ ¸è§£è€¦ï¼Œå…¼å®¹ä¸åŒå†…æ ¸ï¼Œæ供了归一化的驱动平å°åº•åº§ï¼Œæ—¨åœ¨ä¸ºå¼€å‘者æ供更精准ã€æ›´é«˜æ•ˆçš„å¼€å‘环境,力求åšåˆ°ä¸€æ¬¡å¼€å‘,多系统部署。 | 所有系统 | +| 电æºç®¡ç†æœåŠ¡ | 电æºç®¡ç†æœåŠ¡å系统æ供如下功能:é‡å¯ç³»ç»Ÿï¼›ç®¡ç†ä¼‘çœ è¿è¡Œé”;系统电æºçŠ¶æ€ç®¡ç†å’ŒæŸ¥è¯¢ï¼›å……ç”µå’Œç”µæ± çŠ¶æ€æŸ¥è¯¢å’Œä¸ŠæŠ¥ï¼›æ˜¾ç¤ºäº®çå±çŠ¶æ€ç®¡ç†ï¼ŒåŒ…括显示亮度调节。 | æ ‡å‡†ç³»ç»Ÿ | +| æ³›SensoræœåŠ¡ | æ³›Sensorä¸åŒ…å«ä¼ 感器和å°å™¨ä»¶ï¼Œä¼ 感器用于侦测环境ä¸æ‰€å‘生事件或å˜åŒ–,并将æ¤æ¶ˆæ¯å‘é€è‡³å…¶ä»–电å设备,å°å™¨ä»¶ç”¨äºŽå‘å¤–ä¼ é€’ä¿¡å·çš„设备,包括马达和LEDç¯ï¼Œå¯¹å¼€å‘者æ供控制马达振动和LEDç¯å¼€å…³çš„能力。 | å°åž‹ç³»ç»Ÿ | +| 多模输入 | OpenHarmony旨在为开å‘者æä¾›NUI(Natural User Interface)的交互方å¼ï¼Œæœ‰åˆ«äºŽä¼ 统æ“作系统的输入,在OpenHarmony上,我们将多ç§ç»´åº¦çš„输入整åˆåœ¨ä¸€èµ·ï¼Œå¼€å‘者å¯ä»¥å€ŸåŠ©åº”用程åºæ¡†æž¶ã€ç³»ç»Ÿè‡ªå¸¦çš„UI组件或API接å£è½»æ¾åœ°å®žçŽ°å…·æœ‰å¤šç»´ã€è‡ªç„¶äº¤äº’特点的应用程åºã€‚具体æ¥è¯´ï¼Œå¤šæ¨¡è¾“å…¥å系统目å‰æ”¯æŒä¼ 统的输入交互方å¼ï¼Œä¾‹å¦‚按键和触控。 | æ ‡å‡†ç³»ç»Ÿ | +| å¯åŠ¨æ¢å¤ | å¯åŠ¨æ¢å¤è´Ÿè´£åœ¨å†…æ ¸å¯åŠ¨ä¹‹åŽï¼Œåº”用å¯åŠ¨ä¹‹å‰çš„æ“作系统ä¸é—´å±‚çš„å¯åŠ¨ã€‚并æ供系统属性查询ã€ä¿®æ”¹åŠè®¾å¤‡æ¢å¤å‡ºåŽ‚设置的功能。 | 所有系统 | +| å‡çº§æœåŠ¡ | å¯æ”¯æŒOpenHarmony设备的OTA(Over The Air)å‡çº§ã€‚ | æ ‡å‡†ç³»ç»Ÿ | +| å¸å· | 支æŒåœ¨ç«¯ä¾§å¯¹æŽ¥åŽ‚商云å¸å·åº”用,æ供分布å¼å¸å·ç™»å½•çŠ¶æ€æŸ¥è¯¢å’Œæ›´æ–°çš„管ç†èƒ½åŠ›ã€‚ | æ ‡å‡†ç³»ç»Ÿ | +| 编译构建 | 编译构建å系统æ供了一个基于Gnå’Œninja的编译构建框架。 | 所有系统 | +| 测试 | å¼€å‘过程采用测试驱动开å‘模å¼ï¼Œå¼€å‘者基于系统新增特性å¯ä»¥é€šè¿‡å¼€å‘者自己开å‘用例ä¿è¯ï¼Œå¯¹äºŽç³»ç»Ÿå·²æœ‰ç‰¹æ€§çš„修改,也å¯é€šè¿‡ä¿®æ”¹é¡¹ç›®ä¸åŽŸæœ‰çš„测试用例ä¿è¯ï¼Œå¼€å‘者测试旨在帮助开å‘者在开å‘阶段就能开å‘出高质é‡ä»£ç 。 | 所有系统 | +| æ•°æ®ç®¡ç† | æ•°æ®ç®¡ç†æ”¯æŒåº”用本地数æ®ç®¡ç†å’Œåˆ†å¸ƒå¼æ•°æ®ç®¡ç†ï¼š<br>- 支æŒåº”用本地数æ®ç®¡ç†ï¼ŒåŒ…括轻é‡çº§å好数æ®åº“,关系型数æ®åº“。<br/>- 支æŒåˆ†å¸ƒå¼æ•°æ®æœåŠ¡ï¼Œä¸ºåº”用程åºæä¾›ä¸åŒè®¾å¤‡é—´æ•°æ®åº“æ•°æ®åˆ†å¸ƒå¼çš„能力。 | æ ‡å‡†ç³»ç»Ÿ | +| è¯è¨€ç¼–译è¿è¡Œæ—¶ | è¯è¨€è¿è¡Œæ—¶æ供了JSã€C/C++è¯è¨€ç¨‹åºçš„编译ã€æ‰§è¡ŒçŽ¯å¢ƒï¼Œæ供支撑è¿è¡Œæ—¶çš„基础库,以åŠå…³è”çš„API接å£ã€ç¼–译器和é…套工具。 | 所有系统 | +| 分布å¼ä»»åŠ¡è°ƒåº¦ | æ供系统æœåŠ¡çš„å¯åŠ¨ã€æ³¨å†Œã€æŸ¥è¯¢åŠç®¡ç†èƒ½åŠ›ã€‚ | 所有系统 | +| JS UI框架 | JS UI框架是OpenHarmony UIå¼€å‘框架,支æŒç±»Web范å¼ç¼–程。 | 所有系统 | +| 媒体 | æ供音频ã€è§†é¢‘ã€ç›¸æœºç‰ç®€å•æœ‰æ•ˆçš„媒体组件开å‘接å£ï¼Œä½¿å¾—应用开å‘者轻æ¾ä½¿ç”¨ç³»ç»Ÿçš„多媒体资æºã€‚ | 所有系统 | +| 事件通知 | 公共事件管ç†å®žçŽ°äº†è®¢é˜…ã€é€€è®¢ã€å‘布ã€æŽ¥æ”¶å…¬å…±äº‹ä»¶ï¼ˆä¾‹å¦‚亮çå±äº‹ä»¶ã€USBæ’拔事件)的能力。 | æ ‡å‡†ç³»ç»Ÿ | +| æ‚散软件æœåŠ¡ | æ供设置时间的能力。 | æ ‡å‡†ç³»ç»Ÿ | +| 包管ç†å系统 | æ供包安装ã€å¸è½½ã€æ›´æ–°ã€æŸ¥è¯¢ç‰èƒ½åŠ›ã€‚ | 所有系统 | +| 电è¯æœåŠ¡ | æä¾›SIMå¡ã€æœç½‘ã€èœ‚çªæ•°æ®ã€èœ‚çªé€šè¯ã€çŸå½©ä¿¡ç‰èœ‚çªç§»åŠ¨ç½‘络基础通信能力,å¯ç®¡ç†å¤šç±»åž‹é€šè¯å’Œæ•°æ®ç½‘络连接,为应用开å‘者æ供便æ·ä¸€è‡´çš„通信API。 | æ ‡å‡†ç³»ç»Ÿ | +| 公共基础类库 | 公共基础库å˜æ”¾OpenHarmony通用的基础组件。这些基础组件å¯è¢«OpenHarmonyå„业务å系统åŠä¸Šå±‚应用所使用。 | 所有系统 | +| ç ”å‘工具链 | æ供设备连接调试器hdcï¼›æ供了性能跟踪能力和接å£ï¼›æ供了性能调优框架,旨在为开å‘者æ供一套性能调优平å°ï¼Œå¯ä»¥ç”¨æ¥åˆ†æžå†…å˜ã€æ€§èƒ½ç‰é—®é¢˜ã€‚ | æ ‡å‡†ç³»ç»Ÿ | +| 分布å¼è½¯æ€»çº¿ | 分布å¼è½¯æ€»çº¿æ—¨åœ¨ä¸ºOpenHarmony系统æ供跨进程或跨设备的通信能力,主è¦åŒ…å«è½¯æ€»çº¿å’Œè¿›ç¨‹é—´é€šä¿¡ä¸¤éƒ¨åˆ†ã€‚å…¶ä¸ï¼Œè½¯æ€»çº¿ä¸ºåº”用和系统æ供近场设备间分布å¼é€šä¿¡çš„能力,æä¾›ä¸åŒºåˆ†é€šä¿¡æ–¹å¼çš„设备å‘çŽ°ï¼Œè¿žæŽ¥ï¼Œç»„ç½‘å’Œä¼ è¾“åŠŸèƒ½ï¼›è€Œè¿›ç¨‹é—´é€šä¿¡åˆ™æä¾›äº†å¯¹è®¾å¤‡å†…æˆ–è®¾å¤‡é—´æ— å·®åˆ«çš„è¿›ç¨‹é—´é€šä¿¡èƒ½åŠ›ã€‚ | 所有系统 | +| XTS | XTS是OpenHarmony兼容性测试套件的集åˆï¼Œå½“å‰åŒ…括acts(application compatibility test suite)应用兼容性测试套,åŽç»ä¼šæ‹“展dcts(device compatibility test suite)设备兼容性测试套ç‰ã€‚ | 所有系统 | +| 系统应用 | 系统应用æ供了OpenHarmonyæ ‡å‡†ç‰ˆä¸Šçš„éƒ¨åˆ†ç³»ç»Ÿåº”ç”¨ï¼Œå¦‚æ¡Œé¢ã€SystemUIã€è®¾ç½®ç‰åº”用,为开å‘者æä¾›äº†æž„å»ºæ ‡å‡†ç‰ˆåº”ç”¨çš„å…·ä½“å®žä¾‹ï¼Œè¿™äº›åº”ç”¨æ”¯æŒåœ¨æ‰€æœ‰æ ‡å‡†ç‰ˆç³»ç»Ÿçš„设备上使用。 | æ ‡å‡†ç³»ç»Ÿ | +| DFX | DFX是OpenHarmonyéžåŠŸèƒ½å±žæ€§èƒ½åŠ›ï¼ŒåŒ…å«æ—¥å¿—系统ã€åº”用和系统事件日志接å£ã€äº‹ä»¶æ—¥å¿—订阅æœåŠ¡ã€æ•…障信æ¯ç”Ÿæˆé‡‡é›†ç‰åŠŸèƒ½ã€‚ | 所有系统 | +| å…¨çƒåŒ– | 当OpenHarmony设备或应用在全çƒä¸åŒåŒºåŸŸä½¿ç”¨æ—¶ï¼Œç³»ç»Ÿå’Œåº”用需è¦æ»¡è¶³ä¸åŒå¸‚场用户关于è¯è¨€ã€æ–‡åŒ–ä¹ ä¿—çš„éœ€æ±‚ã€‚å…¨çƒåŒ–å系统æ供支æŒå¤šè¯è¨€ã€å¤šæ–‡åŒ–的能力,包括资æºç®¡ç†èƒ½åŠ›å’Œå›½é™…化能力。 | 所有系统 | +| 安全 | 安全å系统包括系统安全ã€æ•°æ®å®‰å…¨ã€åº”用安全ç‰æ¨¡å—,为OpenHarmonyæ供了ä¿æŠ¤ç³»ç»Ÿå’Œå’Œç”¨æˆ·æ•°æ®çš„能力。安全å系统当å‰å¼€æºçš„功能,包括应用完整性ä¿æŠ¤ã€åº”用æƒé™ç®¡ç†ã€è®¾å¤‡è®¤è¯ã€å¯†é’¥ç®¡ç†æœåŠ¡ã€‚ | 所有系统 | + +## 支æŒçš„å¼€å‘æ¿ + +当å‰OpenHarmony社区支æŒ17款开å‘æ¿ï¼Œä¸‹è¡¨ä»‹ç»3款(æ¤å¤„选择三ç§ç³»ç»Ÿç±»åž‹é¦–款进入OpenHarmony主干的开å‘æ¿ï¼‰ï¼Œæ›´å¤šå¼€å‘æ¿ä¿¡æ¯ï¼Œè¯·å‚考[社区支æŒçš„å¼€å‘æ¿æ¸…å•](device-dev/dev-board-on-the-master.md),社区æ¯æ—¥æž„建版本获å–地å€è¯·å‚考http://ci.openharmony.cn/dailys/dailybuilds + + |系统类型 | å¼€å‘æ¿åž‹å·| èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ›åŠé€‚é…案例 | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓| + |-------- | --------| --------| --------| -------- | -------- | + |æ ‡å‡†ç³»ç»Ÿ | 润和DAYU200 | RK3568 | 主è¦èƒ½åŠ›ï¼š<br/>润和HH-SCDAYU200<br/>基于<br/>Rockchip RK3568,集æˆåŒ<br/>æ ¸å¿ƒæž¶æž„GPU以åŠé«˜æ•ˆèƒ½NPUï¼›æ¿<br/>è½½å››æ ¸64ä½Cortex-A55 处<br/>ç†å™¨é‡‡ç”¨22nm先进工艺,主频高<br/>è¾¾2.0GHz;支æŒè“牙ã€Wi-Fiã€<br/>音频ã€è§†é¢‘和摄åƒå¤´ç‰åŠŸèƒ½ï¼Œæ‹¥<br/>有丰富的扩展接å£ï¼Œæ”¯æŒå¤šç§è§†<br/>频输入输出接å£ï¼›é…ç½®åŒåƒå…†è‡ª<br/>适应RJ45以太网å£ï¼Œå¯æ»¡è¶³<br/>NVR<br/>ã€å·¥ä¸šç½‘å…³ç‰å¤šç½‘å£äº§<br/>å“需求。<br/>适é…案例:<br/>[DAYU200适é…案例](device-dev/porting/porting-dayu200-on_standard-demo.md) | 影音娱ä¹ã€æ™ºæ…§<br/>出行ã€æ™º<br/>能家居,<br/>如烟机ã€<br/>烤箱ã€è·‘<br/>æ¥æœºç‰ã€‚ | [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope) <br/> | + |å°åž‹ç³»ç»Ÿ | Hispark_<br/>Taurus | Hi3516DV<br/>300 | 主è¦èƒ½åŠ›ï¼š<br/>Hi3516DV300是新一<br/>代Smart HD IPæ‘„åƒ<br/>机SOC,集æˆæ–°ä¸€ä»£<br/>ISP(Image Signal P<br/>rocessor)ã€H.265视频压缩编ç <br/>器ã€é«˜æ€§èƒ½NNIE引擎,在低ç 率<br/>ã€é«˜ç”»è´¨ã€æ™ºèƒ½å¤„ç†å’Œåˆ†æžã€ä½Ž<br/>功耗ç‰æ–¹é¢æœ‰è¾ƒå¥½çš„性能。 | 带å±æ™ºèƒ½ç¡¬ä»¶ï¼Œ<br/>比如带å±<br/>冰箱ã€è½¦<br/>机ç‰ã€‚ | [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](http://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon) <br/>| + |è½»é‡ç³»ç»Ÿ | Multi-modal<br/> V200Z-R | BES2600 | 主è¦èƒ½åŠ›ï¼š<br/>Multi-<br/>modal V200Z-Rå¼€å‘æ¿æ˜¯åŸº<br/>于æ’玄科技BES2600WM芯片的一<br/>款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”<br/>AIoT SoCå¼€å‘æ¿Multi-<br/>modal V200Z-Rå¼€å‘æ¿ï¼Œå•<br/>模组集æˆå››æ ¸ARM处ç†å™¨ï¼ˆæœ€é«˜<br/>主频1GHz),集æˆåŒé¢‘<br/>WiFi + åŒæ¨¡è“牙,<br/>支æŒæ ‡å‡†çš„<br/>802.11 a/b/g/n/å议,支<br/>æŒBT/BLE 5.2å议,内建<br/>多ç§å®¹é‡çš„RAM(最大42MB)和<br/>Flash(最大32MB),支æŒ<br/>MIPI DSIåŠCSI,适用于å„<br/>ç§AIoT多模æ€<br/>VUI + GUI交互硬件<br/>场景。<br/>适é…案例:<br/>[Multi-modal V200Z-R适é…案例](device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md) | 智能硬件ã€å¸¦å±<br/>类模组产<br/>å“,如音<br/>ç®±ã€æ‰‹è¡¨<br/>ç‰ã€‚ | [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br/>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br/>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic) <br/> | + +## 快速入门 - [设备开å‘快速入门](device-dev/quick-start/quickstart-ide-lite-overview.md) - [应用开å‘快速入门](application-dev/quick-start/start-overview.md) -## 代ç 仓地å€<a name="section107651249181914"></a> +## 代ç ä»“åœ°å€ OpenHarmony主库组织地å€ï¼š[https://gitee.com/openharmony](https://gitee.com/openharmony) @@ -374,7 +171,7 @@ OpenHarmony三方库组织地å€ï¼š[https://gitee.com/openharmony-tpc](https://g OpenHarmony归档组织地å€ï¼š[https://gitee.com/openharmony-retired](https://gitee.com/openharmony-retired) -## å¼€å‘者文档<a name="section21031470109"></a> +## å¼€å‘者文档 [访问官网](https://www.openharmony.cn/) @@ -382,29 +179,29 @@ OpenHarmony归档组织地å€ï¼š[https://gitee.com/openharmony-retired](https:// [English Version](https://gitee.com/openharmony/docs/tree/master/en) -## æºç 下载<a name="section39011923144212"></a> +## æºç 下载 获å–OpenHarmonyæºç :[下载说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md) -## 示例教程<a name="sectionsamples"></a> +## 示例教程 Samples:[示例代ç ](https://gitee.com/openharmony/app_samples) Codelabs:[教程指导](https://gitee.com/openharmony/codelabs) -## 如何å‚与<a name="section19611528174215"></a> +## 如何å‚与 å‚与社区:[社区介ç»](https://gitee.com/openharmony/community/blob/master/README.md) å‚与贡献:[如何贡献](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md) -## 许å¯åè®®<a name="section1245517472115"></a> +## 许å¯åè®® OpenHarmony主è¦éµå¾ªApache License V2.0å议,详情请å‚考å„代ç 仓LICENSE声明。 OpenHarmony引用三方开æºè½¯ä»¶åŠè®¸å¯è¯è¯´æ˜Žï¼Œå‚考[第三方开æºè½¯ä»¶è¯´æ˜Ž](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BC%80%E6%BA%90%E8%BD%AF%E4%BB%B6%E5%8F%8A%E8%AE%B8%E5%8F%AF%E8%AF%81%E8%AF%B4%E6%98%8E.md)。 -## è”系方å¼<a name="section61728335424"></a> +## è”ç³»æ–¹å¼ ç½‘ç«™ï¼š diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index f6edc6cc861e360a1f8a8ea92aadbccd255131a8..19b9ca337e53338101d7d995f08865062ed8b290 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -8,14 +8,12 @@ - 快速开始 - 快速入门 - [å¼€å‘准备](quick-start/start-overview.md) - - [使用eTSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](quick-start/start-with-ets.md) - - [使用eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](quick-start/start-with-ets-low-code.md) - - [使用JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](quick-start/start-with-js.md) - - [使用JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](quick-start/start-with-js-low-code.md) + - [使用eTSè¯è¨€å¼€å‘(Stage模型)](quick-start/start-with-ets-stage.md) + - [使用eTSè¯è¨€å¼€å‘(FA模型)](quick-start/start-with-ets-fa.md) + - [使用JSè¯è¨€å¼€å‘(FA模型)](quick-start/start-with-js-fa.md) - å¼€å‘基础知识 - [应用包结构说明(FA模型)](quick-start/package-structure.md) - [应用包结构说明(Stage模型)](quick-start/stage-structure.md) - - [资æºæ–‡ä»¶çš„分类](quick-start/basic-resource-file-categories.md) - [SysCap说明](quick-start/syscap.md) - [HarmonyAppProvisioné…置文件](quick-start/app-provision-structure.md) - å¼€å‘ @@ -34,6 +32,7 @@ - [设备使用信æ¯ç»Ÿè®¡](device-usage-statistics/Readme-CN.md) - [DFX](dfx/Readme-CN.md) - [国际化](internationalization/Readme-CN.md) + - [一次开å‘,多端部署](key-features/multi-device-app-dev/Readme-CN.md) - [IDLå·¥å…·è§„æ ¼åŠä½¿ç”¨è¯´æ˜Žä¹¦](IDL/idl-guidelines.md) - [Native API的相关指导](napi/Readme-CN.md) - 工具 @@ -42,8 +41,8 @@ - [示例代ç ](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - APIå‚考 - - [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](reference/arkui-js/Readme-CN.md) - [组件å‚考(基于TS扩展的声明å¼å¼€å‘范å¼ï¼‰](reference/arkui-ts/Readme-CN.md) + - [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](reference/arkui-js/Readme-CN.md) - æŽ¥å£ - [JSåŠTS APIå‚考](reference/apis/Readme-CN.md) - Native API diff --git a/zh-cn/application-dev/ability/ability-brief.md b/zh-cn/application-dev/ability/ability-brief.md index 548b3222b67a29d45dccaf472de44069d7b69fb8..3f8f7bce599193d6cce9d4a594d3188a380e4aed 100644 --- a/zh-cn/application-dev/ability/ability-brief.md +++ b/zh-cn/application-dev/ability/ability-brief.md @@ -31,4 +31,4 @@ Stage模型的设计,主è¦æ˜¯ä¸ºäº†å¼€å‘è€…æ›´åŠ æ–¹ä¾¿åœ°å¼€å‘å‡ºåˆ†å¸ƒå¼ ## 相关实例 针对Abilityå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [Page内和Page间导航跳转](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) \ No newline at end of file +- [Page内和Page间导航跳转(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/context-userguide.md b/zh-cn/application-dev/ability/context-userguide.md index 796f380175f0e29a0538012dec8ea95a077e05dc..c79fef74df0c3ff05ba95f2a6f5392df8dc85aac 100644 --- a/zh-cn/application-dev/ability/context-userguide.md +++ b/zh-cn/application-dev/ability/context-userguide.md @@ -7,10 +7,10 @@ ​ OpenHarmony的应用框架分为FA模型和Stage两ç§æ¨¡åž‹ã€‚对应å˜åœ¨ä¸¤å¥—Context机制适é…两ç§åº”用框架模型,其ä¸application/BaseContext属于通用的Context基类,里é¢åŒ…å«ä¸€ä¸ªå±žæ€§stageMode,用æ¥åŒºåˆ†å¼€å‘模型是FA还是Stage。 - FA模型 -åªæœ‰app/Contextä¸çš„方法属于FA模型对应的Context。该模å¼ä¸‹ï¼Œåº”用级别的Contextå’ŒAbility级别的Context都是该类型的实例,如果在应用级别的Context里é¢è°ƒç”¨äº†Ability级别的方法,会产生错误。所以开å‘者需è¦æ³¨æ„Context实例所代表的实际å«ä¹‰ã€‚ + åªæœ‰app/Contextä¸çš„方法属于FA模型对应的Context。该模å¼ä¸‹ï¼Œåº”用级别的Contextå’ŒAbility级别的Context都是该类型的实例,如果在应用级别的Context里é¢è°ƒç”¨äº†Ability级别的方法,会产生错误。所以开å‘者需è¦æ³¨æ„Context实例所代表的实际å«ä¹‰ã€‚ - Stage模型 -除了app/Context之外的Context都属于Stage模型,分别有application/Contextã€application/ApplicationContextã€application/AbilityStageContextã€application/ExtensionContextã€application/AbilityContextã€application/FormExtensionContextç‰Context。这些Context的介ç»åŠä½¿ç”¨æ–¹å¼å°†ä¼šåœ¨[Stage模型和Context详细介ç»](#stage模型和context详细介ç»)ç§è¿›è¡Œè¯´æ˜Žã€‚ + 除了app/Context之外的Context都属于Stage模型,分别有application/Contextã€application/ApplicationContextã€application/AbilityStageContextã€application/ExtensionContextã€application/AbilityContextã€application/FormExtensionContextç‰Context。这些Context的介ç»åŠä½¿ç”¨æ–¹å¼å°†ä¼šåœ¨[Stage模型和Context详细介ç»](#stage模型和context详细介ç»)ç§è¿›è¡Œè¯´æ˜Žã€‚  @@ -20,11 +20,11 @@ ​ FA模型åªæœ‰ä¸€ä¸ªContext定义。Contextä¸æ‰€æœ‰çš„功能都是通过方法æ¥æ供的,它æ供了一些featureAbilityä¸ä¸å˜åœ¨çš„方法,相当于featureAbility的一个扩展和补全。 -​**d.ts声明** +**d.ts声明** ​ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/app/context.d.ts -​**示例** +**示例** ```javascript import featureAbility from '@ohos.ability.featureAbility' @@ -223,7 +223,75 @@ export default class MainAbility extends Ability { å¡ç‰‡ä¸šåŠ¡ç›¸å…³ï¼Œç‚¹ä¸‹é¢é“¾æŽ¥äº†è§£ã€‚ -​ [FormExtensionContext](/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md) +​ [FormExtensionContext](../reference/apis/js-apis-formextensioncontext.md) + +### 在eTS页é¢ä¸è®¿é—®Context + +Stage模型下,在Abilityçš„`onWindowStageCreate`生命周期ä¸ï¼Œå¯ä»¥é€šè¿‡WindowStageçš„`SetUIContent`æ–¹æ³•åŠ è½½ä¸€ä¸ªeTS页é¢ã€‚在一些场景ä¸ï¼Œéœ€è¦åœ¨é¡µé¢å†…获å–Context调用相关API。 + +**获å–方法** + +在eTS页é¢ä¸é€šè¿‡ä»¥ä¸‹å…¨å±€æ–¹æ³•èŽ·å–当å‰é¡µé¢å…³è”çš„Context。 + +| 接å£å | æè¿° | +| :------------------------------------ | :--------------------------- | +| getContext(component: Object): Object | 获å–页é¢ä¸component所关è”çš„Context对象。 | + +**示例** + +```ts +// MainAbility.ts +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // åŠ è½½index页é¢ï¼Œå¹¶ä¼ 入当å‰Context + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() {} + + onForeground() {} + + onBackground() {} +}; +``` + +```ts +// pages/index.ets +import context from '@ohos.application.context' + +type Context = context.Context + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('GetContext') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + // 获å–当å‰componentå…³è”çš„Context + var context : Context = getContext(this) as Context + console.info("CacheDir:" + context.cacheDir) + }) + } + .width('100%') + } + .height('100%') + } +} +``` ## 常è§é”™è¯¯ä½¿ç”¨æ–¹å¼ diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index abf0fbccff62d597f714d5ae03c6b11674e665b5..6d658d0655c9c33b58d9f096aebc8e038b97cf28 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -32,11 +32,11 @@ Ability框架在API 8åŠæ›´æ—©ç‰ˆæœ¬ä½¿ç”¨FA模型。FA模型ä¸Ability分为Pag - [`DistributeCalc`:分布å¼è®¡ç®—器(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Preset/DistributeCalc) - [`DistributeGraffiti`:分布å¼æ¶‚鸦(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ability/DistributedGraffiti) -- [分布å¼è°ƒåº¦å¯åŠ¨è¿œç¨‹FA](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA) -- [分布å¼æ–°é—»å®¢æˆ·ç«¯](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo) -- [分布å¼æ‰‹å†™æ¿ï¼ˆeTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) -- [分布å¼é‰´æƒï¼ˆJS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/GameAuthOpenH) -- [分布å¼æ¸¸æˆæ‰‹æŸ„(eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/HandleGameApplication) -- [分布å¼é‚®ä»¶ï¼ˆeTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS) -- [分布å¼äº²å早教系统(eTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OpenHarmonyPictureGame) -- [分布å¼é¥æŽ§å™¨ï¼ˆeTS)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteControllerETS) \ No newline at end of file +- [分布å¼è°ƒåº¦å¯åŠ¨è¿œç¨‹FA(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteStartFA) +- [分布å¼æ–°é—»å®¢æˆ·ç«¯ï¼ˆJS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/NewsDemo) +- [分布å¼æ‰‹å†™æ¿ï¼ˆeTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/DistributeDatabaseDrawEts) +- [分布å¼é‰´æƒï¼ˆJS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/GameAuthOpenH) +- [分布å¼æ¸¸æˆæ‰‹æŸ„(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/HandleGameApplication) +- [分布å¼é‚®ä»¶ï¼ˆeTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS) +- [分布å¼äº²å早教系统(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OpenHarmonyPictureGame) +- [分布å¼é¥æŽ§å™¨ï¼ˆeTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteControllerETS) \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-dataability.md b/zh-cn/application-dev/ability/fa-dataability.md index 67dcdd8c71aeaff992259ea64c844249540bcb19..5ec1135c9c9eb5c7578b8441facb2b9831a7c022 100644 --- a/zh-cn/application-dev/ability/fa-dataability.md +++ b/zh-cn/application-dev/ability/fa-dataability.md @@ -1,12 +1,14 @@ # DataAbilityå¼€å‘指导 + ## åœºæ™¯ä»‹ç» + 基于Data模æ¿çš„Ability(以下简称“Dataâ€ï¼‰ï¼Œæœ‰åŠ©äºŽåº”用管ç†å…¶è‡ªèº«å’Œå…¶ä»–应用å˜å‚¨æ•°æ®çš„访问,并æ供与其他应用共享数æ®çš„方法。Dataæ—¢å¯ç”¨äºŽåŒè®¾å¤‡ä¸åŒåº”用的数æ®å…±äº«ï¼Œä¹Ÿæ”¯æŒè·¨è®¾å¤‡ä¸åŒåº”用的数æ®å…±äº«ã€‚ Dataæ供方å¯ä»¥è‡ªå®šä¹‰æ•°æ®çš„增ã€åˆ ã€æ”¹ã€æŸ¥ï¼Œä»¥åŠæ–‡ä»¶æ‰“å¼€ç‰åŠŸèƒ½ï¼Œå¹¶å¯¹å¤–æ供这些接å£ã€‚ ## URIä»‹ç» -Dataçš„æ供方和使用方都通过URI(Uniform Resource Identifier)æ¥æ ‡è¯†ä¸€ä¸ªå…·ä½“çš„æ•°æ®ï¼Œä¾‹å¦‚æ•°æ®åº“ä¸çš„æŸä¸ªè¡¨æˆ–ç£ç›˜ä¸Šçš„æŸä¸ªæ–‡ä»¶ã€‚HarmonyOSçš„URIä»åŸºäºŽURIé€šç”¨æ ‡å‡†ï¼Œæ ¼å¼å¦‚下: +Dataçš„æ供方和使用方都通过URI(Uniform Resource Identifier)æ¥æ ‡è¯†ä¸€ä¸ªå…·ä½“çš„æ•°æ®ï¼Œä¾‹å¦‚æ•°æ®åº“ä¸çš„æŸä¸ªè¡¨æˆ–ç£ç›˜ä¸Šçš„æŸä¸ªæ–‡ä»¶ã€‚OpenHarmonyçš„URIä»åŸºäºŽURIé€šç”¨æ ‡å‡†ï¼Œæ ¼å¼å¦‚下:  @@ -21,10 +23,9 @@ URI示例: - 跨设备场景:dataability://*device_id*/*com.domainname.dataability.persondata*/*person*/*10* - 本地设备:dataability:///*com.domainname.dataability.persondata*/*person*/*10* -``` -说明 -本地设备的“device_idâ€å—æ®µä¸ºç©ºï¼Œå› æ¤åœ¨â€œdataability:â€åŽé¢æœ‰ä¸‰ä¸ªâ€œ/â€ã€‚ -``` +> 说明 +> +> 本地设备的“device_idâ€å—æ®µä¸ºç©ºï¼Œå› æ¤åœ¨â€œdataability:â€åŽé¢æœ‰ä¸‰ä¸ªâ€œ/â€ã€‚ ## 接å£è¯´æ˜Ž diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index bae0e29ea3a3947ac0fe5db65d10a2b4e5256a85..58991ec7147c2789774dff1892c68f8a34d72653 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -32,7 +32,7 @@ }, onConnect(want) { console.log('ServiceAbility OnConnect'); - return null; + return new FirstServiceAbilityStub('test'); }, onDisconnect(want) { console.log('ServiceAbility OnDisConnect'); @@ -139,41 +139,36 @@ let promise = featureAbility.startAbility( ```javascript import prompt from '@system.prompt' - let mRemote; - function onConnectCallback(element, remote){ - console.log('onConnectLocalService onConnectDone element: ' + element); - console.log('onConnectLocalService onConnectDone remote: ' + remote); - mRemote = remote; - if (mRemote == null) { - prompt.showToast({ - message: "onConnectLocalService not connected yet" - }); - return; - } - let option = new rpc.MessageOption(); - let data = new rpc.MessageParcel(); - let reply = new rpc.MessageParcel(); - data.writeInt(1); - data.writeInt(99); - mRemote.sendRequest(1, data, reply, option).then((result) => { - console.log('sendRequest success'); - let msg = reply.readInt(); + var option = { + onConnect: function onConnectCallback(element, proxy) { + console.log(`onConnectLocalService onConnectDone`) + if (proxy === null) { + prompt.showToast({ + message: "Connect service failed" + }) + return + } + let data = rpc.MessageParcel.create() + let reply = rpc.MessageParcel.create() + let option = new rpc.MessageOption() + data.writeInterfaceToken("connect.test.token") + proxy.sendRequest(0, data, reply, option) prompt.showToast({ - message: "onConnectLocalService connect result: " + msg, - duration: 3000 - }); - }).catch((e) => { - console.log('sendRequest error:' + e); - }); - - } - - function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect Callback') - } - - function onFailedCallback(code){ - console.log('ConnectAbility onFailed Callback') + message: "Connect service success" + }) + }, + onDisconnect: function onDisconnectCallback(element) { + console.log(`onConnectLocalService onDisconnectDone element:${element}`) + prompt.showToast({ + message: "Disconnect service success" + }) + }, + onFailed: function onFailedCallback(code) { + console.log(`onConnectLocalService onFailed errCode:${code}`) + prompt.showToast({ + message: "Connect local service onFailed" + }) + } } ``` @@ -201,44 +196,27 @@ let promise = featureAbility.startAbility( ```javascript import rpc from "@ohos.rpc"; - let mMyStub; - export default { - onStart() { - class MyStub extends rpc.RemoteObject{ - constructor(des) { - if (typeof des === 'string') { - super(des); - } - return null; - } - onRemoteRequest(code, data, reply, option) { - console.log("ServiceAbility onRemoteRequest called"); - if (code === 1) { - let op1 = data.readInt(); - let op2 = data.readInt(); - console.log("op1 = " + op1 + ", op2 = " + op2); - reply.writeInt(op1 + op2); - } else { - console.log("ServiceAbility unknown request code"); - } - return true; - } - } - mMyStub = new MyStub("ServiceAbility-test"); - }, - onCommand(want, startId) { - console.log('ServiceAbility onCommand'); - }, - onConnect(want) { - console.log('ServiceAbility OnConnect'); - return mMyStub; - }, - onDisconnect(want) { - console.log('ServiceAbility OnDisConnect'); - }, - onStop() { - console.log('ServiceAbility onStop'); - }, + class FirstServiceAbilityStub extends rpc.RemoteObject { + constructor(des: any) { + if (typeof des === 'string') { + super(des) + } else { + return + } + } + + onRemoteRequest(code: number, data: any, reply: any, option: any) { + console.log(printLog + ` onRemoteRequest called`) + if (code === 1) { + let string = data.readString() + console.log(printLog + ` string=${string}`) + let result = Array.from(string).sort().join('') + console.log(printLog + ` result=${result}`) + reply.writeString(result) + } else { + console.log(printLog + ` unknown request code`) + } + return true; } ``` @@ -255,40 +233,36 @@ let promise = featureAbility.startAbility( ```ts import prompt from '@system.prompt' -let mRemote; -function onConnectCallback(element, remote){ - console.log('onConnectRemoteService onConnectDone element: ' + element); - console.log('onConnectRemoteService onConnectDone remote: ' + remote); - mRemote = remote; - if (mRemote == null) { - prompt.showToast({ - message: "onConnectRemoteService not connected yet" - }); - return; - } - let option = new rpc.MessageOption(); - let data = new rpc.MessageParcel(); - let reply = new rpc.MessageParcel(); - data.writeInt(1); - data.writeInt(99); - mRemote.sendRequest(1, data, reply, option).then((result) => { - console.log('sendRequest success'); - let msg = reply.readInt(); +var option = { + onConnect: function onConnectCallback(element, proxy) { + console.log(`onConnectRemoteService onConnectDone`) + if (proxy === null) { + prompt.showToast({ + message: "Connect service failed" + }) + return + } + let data = rpc.MessageParcel.create() + let reply = rpc.MessageParcel.create() + let option = new rpc.MessageOption() + data.writeInterfaceToken("connect.test.token") + proxy.sendRequest(0, data, reply, option) prompt.showToast({ - message: "onConnectRemoteService connect result: " + msg, - duration: 3000 - }); - }).catch((e) => { - console.log('sendRequest error:' + e); - }); -} - -function onDisconnectCallback(element){ - console.log('ConnectRemoteAbility onDisconnect Callback') -} - -function onFailedCallback(code){ - console.log('ConnectRemoteAbility onFailed Callback') + message: "Connect service success" + }) + }, + onDisconnect: function onDisconnectCallback(element) { + console.log(`onConnectRemoteService onDisconnectDone element:${element}`) + prompt.showToast({ + message: "Disconnect service success" + }) + }, + onFailed: function onFailedCallback(code) { + console.log(`onConnectRemoteService onFailed errCode:${code}`) + prompt.showToast({ + message: "Connect local service onFailed" + }) + } } ``` @@ -374,23 +348,25 @@ Service侧把自身的实例返回给调用侧的代ç 示例如下: ```ts import rpc from "@ohos.rpc"; -class FirstServiceAbilityStub extends rpc.RemoteObject{ - constructor(des) { +class FirstServiceAbilityStub extends rpc.RemoteObject { + constructor(des: any) { if (typeof des === 'string') { - super(des); + super(des) } else { - return null; + return } } - onRemoteRequest(code, data, reply, option) { - console.log("ServiceAbility onRemoteRequest called"); + + onRemoteRequest(code: number, data: any, reply: any, option: any) { + console.log(printLog + ` onRemoteRequest called`) if (code === 1) { - let op1 = data.readInt(); - let op2 = data.readInt(); - console.log("op1 = " + op1 + ", op2 = " + op2); - reply.writeInt(op1 + op2); + let string = data.readString() + console.log(printLog + ` string=${string}`) + let result = Array.from(string).sort().join('') + console.log(printLog + ` result=${result}`) + reply.writeString(result) } else { - console.log("ServiceAbility unknown request code"); + console.log(printLog + ` unknown request code`) } return true; } diff --git a/zh-cn/application-dev/ability/figures/fa-package-info.png b/zh-cn/application-dev/ability/figures/fa-package-info.png deleted file mode 100644 index 7117b264d03b66eb33655d7cf7e939e820a4cab4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/fa-package-info.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png b/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png deleted file mode 100644 index 4c94556b5c2516ad2978a9a31d833cfb2cf3dd01..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/page-ability-lifecycle-callbacks.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/stage-ability-continuation.md b/zh-cn/application-dev/ability/stage-ability-continuation.md index 260f37a05751269cf368f539214de8632c935e8e..b50cab8a17cfbcb49e8ff6098e410c76b1c3ae18 100755 --- a/zh-cn/application-dev/ability/stage-ability-continuation.md +++ b/zh-cn/application-dev/ability/stage-ability-continuation.md @@ -13,7 +13,8 @@ |接å£å | æè¿°| |:------ | :------| | onContinue(wantParam : {[key: string]: any}): OnContinueResult | è¿ç§»**å‘起端**在该回调ä¸ä¿å˜è¿ç§»æ‰€éœ€è¦çš„æ•°æ®ï¼ŒåŒæ—¶è¿”回是å¦åŒæ„è¿ç§»ï¼šAGREE表示åŒæ„,REJECT表示拒ç»ï¼›MISMATCH表示版本ä¸åŒ¹é…。 | -| onCreate(want: Want, param : LaunchParam): void | è¿ç§»**ç›®æ ‡ç«¯**在该回调ä¸å®Œæˆæ•°æ®æ¢å¤ï¼Œå¹¶è§¦å‘页é¢æ¢å¤ã€‚ | +| onCreate(want: Want, param: AbilityConstant.LaunchParam): void; | 多实例应用è¿ç§»**ç›®æ ‡ç«¯**在该回调ä¸å®Œæˆæ•°æ®æ¢å¤ï¼Œå¹¶è§¦å‘页é¢æ¢å¤ã€‚ | +| onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; | å•å®žä¾‹åº”用è¿ç§»**ç›®æ ‡ç«¯**在该回调ä¸å®Œæˆæ•°æ®æ¢å¤ï¼Œå¹¶è§¦å‘页é¢æ¢å¤ã€‚ | @@ -21,10 +22,12 @@  -è¿ç§»å®žé™…上是Abilityæºå¸¦æ•°æ®çš„跨端å¯åŠ¨ã€‚触å‘è¿ç§»åŠ¨ä½œæ—¶ï¼Œä¼šåœ¨A设备上通过系统回调应用的onContinue()方法,开å‘者需è¦åœ¨æ¤æ–¹æ³•ä¸å®žçŽ°å½“å‰æ•°æ®çš„ä¿å˜ã€‚然åŽç³»ç»Ÿå‘起在B设备上的跨端å¯åŠ¨ï¼Œå¹¶å°†æ•°æ®ä¸€åŒä¼ 输到B设备。B设备系统回调onCreate()方法,开å‘者需è¦åœ¨æ¤æ–¹æ³•ä¸å®žçŽ°ä¼ 输过æ¥çš„æ•°æ®çš„æ¢å¤ã€‚ +è¿ç§»å®žé™…上是Abilityæºå¸¦æ•°æ®çš„跨端å¯åŠ¨ã€‚触å‘è¿ç§»åŠ¨ä½œæ—¶ï¼Œä¼šåœ¨A设备上通过系统回调应用的onContinue()方法,开å‘者需è¦åœ¨æ¤æ–¹æ³•ä¸å®žçŽ°å½“å‰æ•°æ®çš„ä¿å˜ã€‚然åŽç³»ç»Ÿå‘起在B设备上的跨端å¯åŠ¨ï¼Œå¹¶å°†æ•°æ®ä¸€åŒä¼ 输到B设备。B设备系统回调onCreate()/onNewWant()方法,开å‘者需è¦åœ¨æ¤æ–¹æ³•ä¸å®žçŽ°ä¼ 输过æ¥çš„æ•°æ®çš„æ¢å¤ã€‚ ## å¼€å‘æ¥éª¤ +下文代ç 片段æ¥è‡ªå‚考[示例](https://gitee.com/openharmony/ability_dmsfwk/tree/master/services/dtbschedmgr/test/samples/continuationManualTestSuite)。 + ### è¿ç§»åº”用 1. é…ç½® @@ -32,9 +35,17 @@ - é…置应用支æŒè¿ç§» 在module.json5ä¸é…ç½®continuableå—段:true表示支æŒè¿ç§»ï¼Œfalse表示ä¸æ”¯æŒï¼Œé»˜è®¤ä¸ºfalse。é…置为falseçš„åº”ç”¨å°†è¢«ç³»ç»Ÿè¯†åˆ«ä¸ºæ— æ³•è¿ç§»ã€‚ - + ```javascript - "continuable": true + { + "module": { + "abilities": [ + { + "continuable": true, + } + ] + } + } ``` @@ -42,30 +53,53 @@ - é…置应用å¯åŠ¨ç±»åž‹ - è¿ç§»å½“å‰åªæ”¯æŒå¤šå®žä¾‹åº”用,需è¦åœ¨åœ¨module.json5ä¸é…ç½®launchTypeå—段为standard。 + 多实例应用在module.json5ä¸å°†launchTypeå—段é…置为standardï¼Œç›®æ ‡ç«¯å°†ä¼šæ‹‰èµ·ä¸€ä¸ªæ–°çš„åº”ç”¨ï¼Œå¹¶æ¢å¤é¡µé¢ï¼›å•å®žä¾‹å°†è¯¥å—段é…置为singletonï¼Œå¦‚æžœç›®æ ‡ç«¯åº”ç”¨å·²ç»æ‰“开,è¿ç§»å°†ä¼šå°†å·²æœ‰é¡µé¢æ ˆæ¸…ç©ºï¼Œå¹¶æ ¹æ®è¿ç§»æ•°æ®æ¢å¤é¡µé¢ã€‚关于å•å®žä¾‹ä¸Žå¤šå®žä¾‹çš„更多信æ¯è¯¦è§[abilityå¼€å‘指导](./stage-ability.md)å¯åŠ¨æ¨¡å¼ã€‚ + + 多实例: ```javascript - "launchType": "standard" + { + "module": { + "abilities": [ + { + "launchType": "standard", + } + ] + } + } ``` - - - + 缺çœæˆ–如下é…置为å•å®žä¾‹ï¼š + + ```javascript + { + "module": { + "abilities": [ + { + "launchType": "singleton", + } + ] + } + } + ``` + + + - 申请分布å¼æƒé™ 支æŒè·¨ç«¯è¿ç§»çš„应用需è¦åœ¨module.json5申请分布å¼æƒé™ DISTRIBUTED_DATASYNC。 - + ```javascript "requestPermissions": [ { "name": "ohos.permission.DISTRIBUTED_DATASYNC" }, ``` - + 这个æƒé™éœ€è¦åœ¨åº”用首次å¯åŠ¨çš„时候弹窗让用户授予,å¯ä»¥é€šè¿‡åœ¨abilityçš„onWindowStageCreateä¸æ·»åŠ 如下代ç 实现: - + ```javascript requestPermissions = async () => { let permissions: Array<string> = [ @@ -102,12 +136,11 @@ } } ``` - - -2. 实现onContinue()æŽ¥å£ + +2. 实现onContinueæŽ¥å£ onContinue()接å£åœ¨å‘起端被调用,主è¦ç”¨äºŽåœ¨è¿ç§»å‘起时,通知开å‘者ä¿å˜æŽ§ä»¶çŠ¶æ€å˜é‡å’Œå†…å˜ä¸æ•°æ®ï¼Œå‡†å¤‡è¿ç§»ã€‚当应用准备完æˆåŽï¼Œéœ€è¦è¿”回OnContinueResult.AGREE(0)表示åŒæ„è¿ç§»ï¼Œå¦åˆ™è¿”回相应的错误ç æ‹’ç»è¿ç§»ã€‚如果ä¸å®žçŽ°è¯¥æŽ¥å£ï¼Œç³»ç»Ÿå°†é»˜è®¤ä¸ºæ‹’ç»è¿ç§»ã€‚ @@ -119,22 +152,25 @@ ``` è¦å®žçŽ°è¿ç§»ï¼Œæ¤æŽ¥å£å¿…须实现并返回AGREE,å¦åˆ™é»˜è®¤ä¸ºæ‹’ç»è¿ç§»ã€‚ - + + å¦å¤–,在该接å£çš„å…¥å‚wantParamä¸å¯ä»¥èŽ·å–ç›®æ ‡è®¾å¤‡çš„deviceId(key为“targetDeviceâ€ï¼‰ï¼Œä»¥åŠç›®æ ‡è®¾å¤‡ä¸Šæ‰€å®‰è£…的应用的版本å·ï¼ˆkey为“versionâ€ï¼‰ã€‚版本å·å¯ç”¨æ¥ä¸Žæœ¬åº”用版本进行对比,åšå…¼å®¹æ€§åˆ¤æ–,如果判定本应用版本与远端ä¸å…¼å®¹ï¼Œå¯ä»¥è¿”回OnContinueResult.MISMATCHæ‹’ç»è¿ç§»ã€‚ + 示例 - + ```javascript - onContinue(wantParam : {[key: string]: any}) { - Logger.info("onContinue using distributedObject") - // set user input data into want params - wantParam["input"] = AppStorage.Get<string>('ContinueInput'); - Logger.info(`onContinue input = ${wantParam["input"]}`); - return AbilityConstant.OnContinueResult.AGREE - } + onContinue(wantParam : {[key: string]: any}) { + Logger.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`) + let workInput = AppStorage.Get<string>('ContinueWork'); + // set user input data into want params + wantParam["work"] = workInput // set user input data into want params + Logger.info(`onContinue input = ${wantParam["input"]}`); + return AbilityConstant.OnContinueResult.AGREE + } ``` - + -3. 在onCreate()接å£ä¸å®žçŽ°è¿ç§»é€»è¾‘ +3. 在onCreate/onNewWant接å£ä¸å®žçŽ°è¿ç§»é€»è¾‘ onCreate()接å£åœ¨è¿ç§»ç›®æ ‡ç«¯è¢«è°ƒç”¨ï¼Œåœ¨ç›®æ ‡ç«¯ability被拉起时,通知开å‘者åŒæ¥å·²ä¿å˜çš„内å˜æ•°æ®å’ŒæŽ§ä»¶çŠ¶æ€ï¼Œå®ŒæˆåŽè§¦å‘页é¢çš„æ¢å¤ã€‚如果ä¸å®žçŽ°è¯¥æŽ¥å£ä¸è¿ç§»ç›¸å…³é€»è¾‘,ability将会作为普通的å¯åŠ¨æ–¹å¼æ‹‰èµ·ï¼Œæ— 法æ¢å¤é¡µé¢ã€‚ @@ -142,22 +178,34 @@ 完æˆæ•°æ®æ¢å¤åŽï¼Œå¼€å‘者需è¦è°ƒç”¨restoreWindowStageæ¥è§¦å‘页é¢æ¢å¤ã€‚ - 示例 + + 在入å‚wantä¸ä¹Ÿå¯ä»¥é€šè¿‡want.parameters.versionæ¥èŽ·å–å‘起端的应用版本å·ã€‚ + + 示例 + ```javascript - onCreate(want, launchParam) { - Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) - globalThis.abilityWant = want; - if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) { - let input = want.parameters.input // get user data from want params - AppStorage.SetOrCreate<string>('ContinueInput', input) - Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`) - - this.contentStorage = new ContentStorage(); - this.context.restoreWindowStage(this.contentStorage); - } - } + import Ability from '@ohos.application.Ability'; + import distributedObject from '@ohos.data.distributedDataObject'; + + export default class MainAbility extends Ability { + storage : LocalStorag; + + onCreate(want, launchParam) { + Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) + if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) { + // get user data from want params + let workInput = want.parameters.work + Logger.info(`work input ${workInput}`) + AppStorage.SetOrCreate<string>('ContinueWork', workInput) + + this.storage = new LocalStorage(); + this.context.restoreWindowStage(this.storage); + } + } + } ``` +如果是å•å®žä¾‹åº”用,则åŒæ ·çš„代ç 实现onNewWant接å£å³å¯ã€‚ @@ -165,32 +213,42 @@ 使用分布å¼å¯¹è±¡ -分布å¼æ•°æ®å¯¹è±¡æ供了与本地å˜é‡ç±»ä¼¼çš„æ“作,实现两个设备的数æ®åŒæ¥ï¼Œå½“设备1的应用A的分布å¼æ•°æ®å¯¹è±¡å¢žã€åˆ ã€æ”¹æ•°æ®åŽï¼Œè®¾å¤‡2的应用A也å¯ä»¥èŽ·å–到对应的数æ®å˜åŒ–,åŒæ—¶è¿˜èƒ½ç›‘å¬æ•°æ®å˜æ›´ä»¥åŠå¯¹ç«¯æ•°æ®å¯¹è±¡çš„上下线。用法详è§[分布å¼å¯¹è±¡æŒ‡å¯¼æ–‡æ¡£](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/database/database-distributedobject-guidelines.md)。 +分布å¼æ•°æ®å¯¹è±¡æ供了与本地å˜é‡ç±»ä¼¼çš„æ“作,实现两个设备的数æ®åŒæ¥ï¼Œå½“设备1的应用A的分布å¼æ•°æ®å¯¹è±¡å¢žã€åˆ ã€æ”¹æ•°æ®åŽï¼Œè®¾å¤‡2的应用A也å¯ä»¥èŽ·å–到对应的数æ®å˜åŒ–,åŒæ—¶è¿˜èƒ½ç›‘å¬æ•°æ®å˜æ›´ä»¥åŠå¯¹ç«¯æ•°æ®å¯¹è±¡çš„上下线。用法详è§[分布å¼å¯¹è±¡æŒ‡å¯¼æ–‡æ¡£](../database/database-distributedobject-guidelines.md)。 è¿ç§»åœºæ™¯ä¸ï¼Œåˆ†å¸ƒå¼å¯¹è±¡ï¼ˆdistributedDataObject)主è¦ç”¨äºŽå°†æœ¬æœºå†…å˜æ•°æ®åŒæ¥åˆ°ç›®æ ‡è®¾å¤‡ã€‚ -- å‘起端在onContinue()ä¸ï¼Œå°†å¾…è¿ç§»çš„æ•°æ®å˜å…¥åˆ†å¸ƒå¼å¯¹è±¡ä¸ï¼Œç„¶åŽè®¾ç½®å¥½session id,并通过wantParamå°†session idä¼ åˆ°è¿œç«¯è®¾å¤‡ã€‚ +- å‘起端在onContinue()ä¸ï¼Œå°†å¾…è¿ç§»çš„æ•°æ®å˜å…¥åˆ†å¸ƒå¼å¯¹è±¡ä¸ï¼Œå¹¶è°ƒç”¨save接å£å°†æ•°æ®ä¿å˜å¹¶åŒæ¥åˆ°è¿œç«¯ï¼Œç„¶åŽè®¾ç½®å¥½session id,并通过wantParamå°†session idä¼ åˆ°è¿œç«¯è®¾å¤‡ã€‚ ```javascript import Ability from '@ohos.application.Ability'; import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:undefined}); + var g_object = distributedObject.createDistributedObject({data:undefined}); export default class MainAbility extends Ability { - contentStorage : ContentStorage sessionId : string; onContinue(wantParam : {[key: string]: any}) { - Logger.info("onContinue using distributedObject") - this.sessionId = distributedObject.genSessionId(); - //set distributed data object session id - g_object.setSessionId(this.sessionId); - g_object.name = "Amy"; - // set session id into want params - wantParam["session"] = this.sessionId; - return AbilityConstant.OnContinueResult.AGREE - } + Logger.info(`onContinue version = ${wantParam.version}, targetDevice: ${wantParam.targetDevice}`) + + if (g_object.__sessionId === undefined) { + this.sessionId = distributedObject.genSessionId() + Logger.info(`onContinue generate new sessionId`) + } + else { + this.sessionId = g_object.__sessionId; + } + + wantParam["session"] = this.sessionId + g_object.data = AppStorage.Get<string>('ContinueStudy'); + Logger.info(`onContinue sessionId = ${this.sessionId}, name = ${g_object.data}`) + g_object.setSessionId(this.sessionId); + g_object.save(wantParam.targetDevice, (result, data)=>{ + Logger.info("save callback"); + Logger.info("save sessionId " + data.sessionId); + Logger.info("save version " + data.version); + Logger.info("save deviceId " + data.deviceId); + }); ``` @@ -201,15 +259,11 @@ import Ability from '@ohos.application.Ability'; import distributedObject from '@ohos.data.distributedDataObject'; - var g_object = distributedObject.createDistributedObject({name:undefined}); + var g_object = distributedObject.createDistributedObject({data:undefined}); export default class MainAbility extends Ability { - contentStorage : ContentStorage - sessionId : string; + storage : LocalStorag; - statusCallback(sessionId, networkid, status) { - Logger.info(`continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`) - } onCreate(want, launchParam) { Logger.info(`MainAbility onCreate ${AbilityConstant.LaunchReason.CONTINUATION}`) @@ -218,15 +272,40 @@ this.sessionId = want.parameters.session Logger.info(`onCreate for continuation sessionId: ${this.sessionId}`) - g_object.on("status", this.statusCallback); - // set session id, so it will sync data from remote device - g_object.setSessionId(this.sessionId); + // in order to fetch from remote, reset g_object.data to undefined first + g_object.data = undefined; + // set session id, so it will fetch data from remote + g_object.setSessionId(this.sessionId); - this.contentStorage = new ContentStorage(); - this.context.restoreWindowStage(this.contentStorage); + AppStorage.SetOrCreate<string>('ContinueStudy', g_object.data) + this.storage = new LocalStorage(); + this.context.restoreWindowStage(this.storage); } + } } ``` + + + +### 其他说明 + +1. 超时机制: + + - å¦‚æžœç›®æ ‡ç«¯è¿ç§»åº”ç”¨æœªå®‰è£…ï¼Œç³»ç»Ÿä¼šåŽ»æŸ¥è¯¢åœ¨ç›®æ ‡ç«¯è®¾å¤‡ä¸Šèƒ½å¦å®‰è£…,这段最大时间为4s,超出æ¤æ—¶é—´ï¼Œè°ƒç”¨è€…会收到超时错误ç ,视为ä¸å¯åœ¨ç›®æ ‡ç«¯å®‰è£…。若å¯å®‰è£…,则系统会æç¤ºç”¨æˆ·åœ¨ç›®æ ‡ç«¯å®‰è£…ï¼Œå®‰è£…å®ŒæˆåŽå¯å†æ¬¡å°è¯•å‘èµ·è¿ç§»ã€‚ + - å¦‚æžœç›®æ ‡ç«¯è¿ç§»åº”用已安装 ,那么å‘èµ·è¿ç§»åŽè¶…时时间为20s,若超过æ¤æ—¶é—´ï¼Œè°ƒç”¨è€…会收到超时错误ç ,视为æ¤æ¬¡è¿ç§»å¤±è´¥ã€‚ + +2. 当å‰ç³»ç»Ÿé»˜è®¤æ”¯æŒé¡µé¢æ ˆä¿¡æ¯çš„è¿ç§»ï¼Œå³å‘起端页é¢æ ˆä¼šè¢«è‡ªåŠ¨è¿ç§»åˆ°ç›®æ ‡ç«¯ï¼Œæ— 需开å‘者适é…。 + + + +### çº¦æŸ + +1. è¿ç§»è¦æ±‚在åŒability之间进行,也就是需è¦ç›¸åŒçš„bundleNameã€moduleNameå’ŒabilityName,具体å«ä¹‰[应用包é…置文件说明](../quick-start/stage-structure.md)。 +2. 当å‰åº”用åªèƒ½å®žçŽ°è¿ç§»èƒ½åŠ›ï¼Œä½†è¿ç§»çš„动作åªèƒ½ç”±ç³»ç»Ÿå‘起。 + + +### 最佳实践 + 为了获得最佳体验,建议100kb以下的数æ®ç›´æŽ¥ä½¿ç”¨wantParamä¼ è¾“ï¼Œå¤§äºŽ100kbçš„æ•°æ®é‡‡ç”¨åˆ†å¸ƒå¼å¯¹è±¡ä¼ 输。 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index fc43d7b00c5d1a68fa67c98bd5988c65cb4bb001..061faac68db96402e30ad0cf89b1d1136c9c5660 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -72,7 +72,7 @@ Ability功能如下(Ability类,具体的API详è§[接å£æ–‡æ¡£](../reference ``` 4. 实现Ability生命周期接å£ã€‚ - 在`onWindowStageCreate(windowStage)`ä¸é€šè¿‡loadContent接å£è®¾ç½®åº”用è¦åŠ 载的页é¢ï¼Œwindow接å£çš„使用详è§[窗å£å¼€å‘指导](../windowmanager/window-guidelines.md)。 + 在`onWindowStageCreate(windowStage)`ä¸é€šè¿‡loadContent接å£è®¾ç½®åº”用è¦åŠ 载的页é¢ï¼Œwindow接å£çš„使用详è§[窗å£å¼€å‘指导](../windowmanager/application-window-stage.md)。 ```ts export default class MainAbility extends Ability { onCreate(want, launchParam) { diff --git a/zh-cn/application-dev/ability/stage-brief.md b/zh-cn/application-dev/ability/stage-brief.md index c1c6407128123a5ad0d06615919de171e5ddc42b..9099e1e557bbd9abd7f3a8fae0eee7de15764a49 100644 --- a/zh-cn/application-dev/ability/stage-brief.md +++ b/zh-cn/application-dev/ability/stage-brief.md @@ -95,3 +95,6 @@ 下图展示了应用的进程模型。  +## 相关实例 +针对Stage模型下的Abilityå¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`MissionManager`:系统任务管ç†ï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/MissionManager) diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md index 1cec47b60933e75be2f0a141e862a92a4d7f7ebf..e8126fa0d7b92f82c9a35d2b92fe3d5017f9ca4d 100644 --- a/zh-cn/application-dev/ability/stage-call.md +++ b/zh-cn/application-dev/ability/stage-call.md @@ -19,7 +19,7 @@ CalleråŠCallee功能如下:具体的API详è§[接å£æ–‡æ¡£](../reference/apis |接å£å|æè¿°| |:------|:------| |startAbilityByCall(want: Want): Promise\<Caller>|获å–指定通用组件的Caller通信接å£ï¼Œæ‹‰èµ·æŒ‡å®šé€šç”¨ç»„件并将其切æ¢åˆ°åŽå°ã€‚| -|on(method: string, callback: CaleeCallBack): void|通用组件Callee注册method对应的callback方法。| +|on(method: string, callback: CalleeCallBack): void|通用组件Callee注册method对应的callback方法。| |off(method: string): void|通用组件Callee去注册methodçš„callback方法。| |call(method: string, data: rpc.Sequenceable): Promise\<void>|å‘通用组件Calleeå‘é€çº¦å®šåºåˆ—化数æ®ã€‚| |callWithResult(method: string, data: rpc.Sequenceable): Promise\<rpc.MessageParcel>|å‘通用组件Calleeå‘é€çº¦å®šåºåˆ—化数æ®, 并将返回的约定åºåˆ—化数æ®å¸¦å›žã€‚| diff --git a/zh-cn/application-dev/application-dev-guide-for-gitee.md b/zh-cn/application-dev/application-dev-guide-for-gitee.md index d8c44107f5e18924a007d955a03c1ef97ea8a89a..e17831a387db2b9ff959a3cf458369760f0545e6 100644 --- a/zh-cn/application-dev/application-dev-guide-for-gitee.md +++ b/zh-cn/application-dev/application-dev-guide-for-gitee.md @@ -54,11 +54,14 @@ DevEco Studio工具是OpenHarmony应用开å‘的推èIDE工具。 APIå‚考æ供了OpenHarmonyå…¨é‡ç»„件和接å£çš„å‚考文档,å¯ä»¥å¸®åŠ©å¼€å‘者快速查找到指定接å£çš„详细æ述和调用方法。 内容包括: -- [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](reference/arkui-js/Readme-CN.md) + - [组件å‚考(基于TS扩展的声明å¼å¼€å‘范å¼ï¼‰](reference/arkui-ts/Readme-CN.md) -- 接å£å‚考 + + +- [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](reference/arkui-js/Readme-CN.md) +- 接å£å‚考 - [JSåŠTS APIå‚考](reference/apis/Readme-CN.md) - - Native API + - Native API - [Native APIå‚考](reference/native-apis/Readme-CN.md) - [æ ‡å‡†åº“](reference/native-lib/third_party_libc/musl.md) - [Node_API](reference/native-lib/third_party_napi/napi.md) diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index ebf83e6e6eb0d76d0b46697e0a8230e7c2578f03..1a2dba85bb227a47c8a76fcdd2872190a184c585 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -55,8 +55,14 @@ DevEco Studio工具是OpenHarmony应用开å‘的推èIDE工具。 APIå‚考æ供了OpenHarmonyå…¨é‡ç»„件和接å£çš„å‚考文档,å¯ä»¥å¸®åŠ©å¼€å‘者快速查找到指定接å£çš„详细æ述和调用方法。 内容包括: -- [接å£å‚考(JSåŠTS API)](reference/apis/js-apis-DataUriUtils.md) -- 接å£å‚考(Native API) - - [OpenHarmony Native API](reference/native-apis/_o_h___native_x_component.md) - - [Native APIæ ‡å‡†åº“](reference/native-lib/third_party_libc/musl.md) - - [Node_API](reference/native-lib/third_party_napi/napi.md) + +- [组件å‚考(基于TS扩展的声明å¼å¼€å‘范å¼ï¼‰](reference/arkui-ts/Readme-CN.md) + +- [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](reference/arkui-js/Readme-CN.md) + +- [接å£å‚考(JSåŠTS API)](reference/apis/js-apis-DataUriUtils.md) + +- 接å£å‚考(Native API) + - [OpenHarmony Native API](reference/native-apis/_o_h___native_x_component.md) + - [Native APIæ ‡å‡†åº“](reference/native-lib/third_party_libc/musl.md) + - [Node_API](reference/native-lib/third_party_napi/napi.md) diff --git a/zh-cn/application-dev/connectivity/http-request.md b/zh-cn/application-dev/connectivity/http-request.md index 90b3bb9829236ee4d07acccc23fff6f714034092..d71280393c8c3afc28b8d81bd26f11f7e84af841 100644 --- a/zh-cn/application-dev/connectivity/http-request.md +++ b/zh-cn/application-dev/connectivity/http-request.md @@ -74,4 +74,5 @@ httpRequest.request( ## 相关实例 针对HTTPæ•°æ®è¯·æ±‚,有以下相关实例å¯ä¾›å‚考: -- [`Http`:数æ®è¯·æ±‚(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http) \ No newline at end of file +- [`Http`:数æ®è¯·æ±‚(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Http) +- [使用HTTP实现与æœåŠ¡ç«¯é€šä¿¡ï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md index 37bd81e6f950e28c1047be1141eea33bb35225d1..ff1261dc0a27b968ba19d86f7bddc5fb401131a7 100755 --- a/zh-cn/application-dev/connectivity/ipc-rpc-overview.md +++ b/zh-cn/application-dev/connectivity/ipc-rpc-overview.md @@ -14,4 +14,4 @@ IPC(Inter-Process Communication)与RPC(Remote Procedure Call)机制用 ## ç›¸å…³æ¨¡å— -[分布å¼ä»»åŠ¡è°ƒåº¦å系统](https://gitee.com/openharmony/distributedschedule_dms_fwk) +[分布å¼ä»»åŠ¡è°ƒåº¦å系统](https://gitee.com/openharmony/ability_dmsfwk) diff --git a/zh-cn/application-dev/connectivity/socket-connection.md b/zh-cn/application-dev/connectivity/socket-connection.md index 1e39e74d1086ea44eca60bb766eecaa995236ce1..14d67dd82f1dcd79f481b5563dc96a098fb2a560 100644 --- a/zh-cn/application-dev/connectivity/socket-connection.md +++ b/zh-cn/application-dev/connectivity/socket-connection.md @@ -126,3 +126,5 @@ UDP与TCPæµç¨‹å¤§ä½“类似,下é¢ä»¥TCP为例: ## 相关实例 针对Socket连接开å‘,有以下相关实例å¯ä¾›å‚考: - [`Socket`:Socket 连接(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/Socket) +- [使用UDP实现与æœåŠ¡ç«¯é€šä¿¡ï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH) +- [使用TCP实现与æœåŠ¡ç«¯é€šä¿¡ï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/TcpSocketDemo) \ No newline at end of file diff --git a/zh-cn/application-dev/connectivity/websocket-connection.md b/zh-cn/application-dev/connectivity/websocket-connection.md index 8cd007bf75842aac584aa76cf97c1f986473962e..53598fc5031da880ebf59edba43fb29bcc8b626b 100644 --- a/zh-cn/application-dev/connectivity/websocket-connection.md +++ b/zh-cn/application-dev/connectivity/websocket-connection.md @@ -83,3 +83,8 @@ WebSocket连接功能主è¦ç”±webSocket模å—æ供。使用该功能需è¦ç”³ } }); ``` + +## 相关实例 + +针对WebSocket连接的开å‘,有以下相关实例å¯ä¾›å‚考: +- [`WebSocket`:WebSocket(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Network/WebSocket) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-distributedobject-guidelines.md b/zh-cn/application-dev/database/database-distributedobject-guidelines.md index 093eea5fb3b843c12779d67ce68c3812aa0885a8..61db857faf49b8f9f3d1adbdd14e1737c63712bc 100644 --- a/zh-cn/application-dev/database/database-distributedobject-guidelines.md +++ b/zh-cn/application-dev/database/database-distributedobject-guidelines.md @@ -128,16 +128,16 @@ ä»¥ä¸‹ä¸ºåŠ å…¥åŒæ¥ç»„网的代ç 示例: ```js - //å‘èµ·æ–¹ + // å‘èµ·æ–¹ var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true, - parent:{mother:"jack mom",father:"jack Dad"},list:[{mother:"jack mom"}, {father:"jack Dad"}]}); + parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]}); local_object.setSessionId(sessionId); - //被拉起方 + // 被拉起方 var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true, parent:undefined, list:undefined}); remote_object.setSessionId(sessionId); - //收到status上线åŽremote_objectåŒæ¥æ•°æ®ï¼Œå³nameå˜æˆjack,age是18 + // 收到status上线åŽremote_objectåŒæ¥æ•°æ®ï¼Œå³nameå˜æˆjack,age是18 ``` 5. 监å¬å¯¹è±¡æ•°æ®å˜æ›´ã€‚å¯ç›‘å¬å¯¹ç«¯æ•°æ®çš„å˜æ›´ï¼Œä»¥callback作为å˜æ›´å›žè°ƒå®žä¾‹ã€‚ @@ -166,16 +166,16 @@ local_object.name = "jack"; local_object.age = 19; local_object.isVis = false; - local_object.parent = {mother:"jack mom",father:"jack Dad"}; + local_object.parent = {mother:"jack mom", father:"jack Dad"}; local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}]; ``` >  **说明:** > 针对å¤æ‚类型的数æ®ä¿®æ”¹ï¼Œç›®å‰æ”¯æŒå¯¹æ ¹å±žæ€§çš„修改,暂ä¸æ”¯æŒå¯¹ä¸‹çº§å±žæ€§çš„修改。示例如下: ```js - //支æŒçš„ä¿®æ”¹æ–¹å¼ + // 支æŒçš„ä¿®æ”¹æ–¹å¼ local_object.parent = {mother:"mom", father:"dad"}; - //ä¸æ”¯æŒçš„ä¿®æ”¹æ–¹å¼ + // ä¸æ”¯æŒçš„ä¿®æ”¹æ–¹å¼ local_object.parent.mother = "mom"; ``` @@ -189,9 +189,9 @@ 以下为å–消监å¬æ•°æ®å˜æ›´çš„代ç 示例: ```js - //åˆ é™¤å˜æ›´å›žè°ƒchangeCallback + // åˆ é™¤å˜æ›´å›žè°ƒchangeCallback local_object.off("change", changeCallback); - //åˆ é™¤æ‰€æœ‰çš„å˜æ›´å›žè°ƒ + // åˆ é™¤æ‰€æœ‰çš„å˜æ›´å›žè°ƒ local_object.off("change"); ``` 9. 监å¬åˆ†å¸ƒå¼å¯¹è±¡çš„上下线。å¯ä»¥ç›‘å¬å¯¹ç«¯åˆ†å¸ƒå¼æ•°æ®å¯¹è±¡çš„上下线。 @@ -210,14 +210,14 @@ ```js // ä¿å˜æ•°æ®å¯¹è±¡ - local_object.save("local", (result, data)=>{ + local_object.save("local", (result, data) => { console.log("save callback"); console.info("save sessionId " + data.sessionId); console.info("save version " + data.version); console.info("save deviceId " + data.deviceId); }); // 撤回ä¿å˜çš„æ•°æ®å¯¹è±¡ - local_object.revokeSave((result, data) =>{ + local_object.revokeSave((result, data) => { console.log("revokeSave callback"); console.info("revokeSave sessionId " + data.sessionId); }); @@ -225,7 +225,7 @@ 2.Promiseæ–¹å¼ ```js // ä¿å˜æ•°æ®å¯¹è±¡ - g_object.save("local").then((result)=>{ + g_object.save("local").then((result) => { console.info("save sessionId " + result.sessionId); console.info("save version " + result.version); console.info("save deviceId " + result.deviceId); @@ -233,7 +233,7 @@ console.info("save local failed."); }); // 撤回ä¿å˜çš„æ•°æ®å¯¹è±¡ - g_object.revokeSave().then((result)=>{ + g_object.revokeSave().then((result) => { console.info("revokeSave success."); }, (result)=>{ console.info("revokeSave failed."); @@ -243,9 +243,9 @@ 以下为å–消监å¬æ•°æ®å˜æ›´çš„代ç 示例: ```js - //åˆ é™¤ä¸Šä¸‹çº¿å›žè°ƒstatusCallback + // åˆ é™¤ä¸Šä¸‹çº¿å›žè°ƒstatusCallback local_object.off("status", this.statusCallback); - //åˆ é™¤æ‰€æœ‰çš„ä¸Šä¸‹çº¿å›žè°ƒ + // åˆ é™¤æ‰€æœ‰çš„ä¸Šä¸‹çº¿å›žè°ƒ local_object.off("status"); ``` 12. 退出åŒæ¥ç»„网。分布å¼å¯¹è±¡é€€å‡ºç»„网åŽï¼Œæœ¬åœ°çš„æ•°æ®å˜æ›´å¯¹ç«¯ä¸ä¼šåŒæ¥ã€‚ @@ -254,12 +254,13 @@ ```js local_object.setSessionId(""); ``` -## å¼€å‘实例 +## 相关实例 针对分布å¼æ•°æ®å¯¹è±¡ï¼Œæœ‰ä»¥ä¸‹å¼€å‘实例å¯ä¾›å‚考: +- [`DistributedNote`:分布å¼å¤‡å¿˜å½•(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedNote) - [备忘录应用](https://gitee.com/openharmony/distributeddatamgr_objectstore/tree/master/samples/distributedNotepad) - -在备忘录应用ä¸ï¼Œå½“æŸä¸€ä¸ªè®¾å¤‡ä¸Šçš„备忘录事件å‘生å˜æ›´æ—¶ï¼Œé€šè¿‡åˆ†å¸ƒå¼æ•°æ®å¯¹è±¡å°†äº‹ä»¶å˜æ›´åŒæ¥åœ¨å¯ä¿¡ç»„网内的其他设备上,比如新增备忘录事件ã€ç¼–è¾‘äº‹ä»¶æ ‡é¢˜å’Œå†…å®¹ã€æ¸…空事件列表ç‰ã€‚ + 在备忘录应用ä¸ï¼Œå½“æŸä¸€ä¸ªè®¾å¤‡ä¸Šçš„备忘录事件å‘生å˜æ›´æ—¶ï¼Œé€šè¿‡åˆ†å¸ƒå¼æ•°æ®å¯¹è±¡å°†äº‹ä»¶å˜æ›´åŒæ¥åœ¨å¯ä¿¡ç»„网内的其他设备上,比如新增备忘录事件ã€ç¼–è¾‘äº‹ä»¶æ ‡é¢˜å’Œå†…å®¹ã€æ¸…空事件列表 + ç‰ã€‚ diff --git a/zh-cn/application-dev/database/database-mdds-guidelines.md b/zh-cn/application-dev/database/database-mdds-guidelines.md index 7e6bc5dd5f6323c485a6018ce8bb7fceac476f4f..4414dbbe7134d2483a48b3f55d768e9d788d1646 100644 --- a/zh-cn/application-dev/database/database-mdds-guidelines.md +++ b/zh-cn/application-dev/database/database-mdds-guidelines.md @@ -8,19 +8,18 @@ ## 接å£è¯´æ˜Ž 具体分布å¼æ•°æ®ç›¸å…³åŠŸèƒ½æŽ¥å£è¯·è§[分布å¼æ•°æ®ç®¡ç†](../reference/apis/js-apis-distributed-data.md)。 -OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§åŠŸèƒ½ï¼š **表1** 分布å¼æ•°æ®æœåŠ¡å…³é”®APIåŠŸèƒ½ä»‹ç» -| 功能分类 | 接å£å称 | æè¿° | -| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | -| 分布å¼æ•°æ®åº“创建。 | createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void<br/>createKVManager(config: KVManagerConfig): Promise<KVManager> | 创建一个KVManager对象实例,用于管ç†æ•°æ®åº“对象。 | -| 分布å¼æ•°æ®åº“创建。 | getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void<br/>getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> | 指定Optionså’ŒstoreId,创建并获å–KVStoreæ•°æ®åº“。 | -| 分布å¼æ•°æ®å¢žã€åˆ ã€æ”¹ã€æŸ¥ã€‚ | put(key: string, value: Uint8Array \| string \| number \| boolean, callback: AsyncCallback<void>): void<br/>put(key: string, value: Uint8Array \| string \| number \| boolean): Promise<void> | æ’入和更新数æ®ã€‚ | -| 分布å¼æ•°æ®å¢žã€åˆ ã€æ”¹ã€æŸ¥ã€‚ | delete(key: string, callback: AsyncCallback<void>): void<br/>delete(key: string): Promise<void> | åˆ é™¤æ•°æ®ã€‚ | -| 分布å¼æ•°æ®å¢žã€åˆ ã€æ”¹ã€æŸ¥ã€‚ | get(key: string, callback: AsyncCallback<Uint8Array \| string \| boolean \| number>): void<br/>get(key: string): Promise<Uint8Array \| string \| boolean \| number> | 查询数æ®ã€‚ | -| 订阅分布å¼æ•°æ®å˜åŒ–。 | on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void<br/>on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void | 订阅数æ®åº“ä¸æ•°æ®çš„å˜åŒ–。 | -| 分布å¼æ•°æ®åŒæ¥ã€‚ | sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | 在手动模å¼ä¸‹ï¼Œè§¦å‘æ•°æ®åº“åŒæ¥ã€‚ | +| 接å£å称 | æè¿° | +| ------------------------------------------------------------ | ----------------------------------------------- | +| createKVManager(config:KVManagerConfig,callback:AsyncCallback<KVManager>):void<br/>createKVManager(config:KVManagerConfig):Promise<KVManager> | 创建一个`KVManager`对象实例,用于管ç†æ•°æ®åº“对象。 | +| getKVStore<TextendsKVStore>(storeId:string,options:Options,callback:AsyncCallback<T>):void<br/>getKVStore<TextendsKVStore>(storeId:string,options:Options):Promise<T> | 指定`Options`å’Œ`storeId`,创建并获å–`KVStore`æ•°æ®åº“。 | +| put(key:string,value:Uint8Array\|string\|number\|boolean,callback:AsyncCallback<void>):void<br/>put(key:string,value:Uint8Array\|string\|number\|boolean):Promise<void> | æ’入和更新数æ®ã€‚ | +| delete(key:string,callback:AsyncCallback<void>):void<br/>delete(key:string):Promise<void> | åˆ é™¤æ•°æ®ã€‚ | +| get(key:string,callback:AsyncCallback<Uint8Array\|string\|boolean\|number>):void<br/>get(key:string):Promise<Uint8Array\|string\|boolean\|number> | 查询数æ®ã€‚ | +| on(event:'dataChange',type:SubscribeType,observer:Callback<ChangeNotification>):void<br/>on(event:'syncComplete',syncCallback:Callback<Array<[string,number]>>):void | 订阅数æ®åº“ä¸æ•°æ®çš„å˜åŒ–。 | +| sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | 在手动模å¼ä¸‹ï¼Œè§¦å‘æ•°æ®åº“åŒæ¥ã€‚ | @@ -35,7 +34,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ ``` 2. æ ¹æ®é…ç½®æž„é€ åˆ†å¸ƒå¼æ•°æ®åº“管ç†ç±»å®žä¾‹ã€‚ - 1. æ ¹æ®åº”用上下文创建KvManagerConfig对象。 + 1. æ ¹æ®åº”用上下文创建`kvManagerConfig`对象。 2. 创建分布å¼æ•°æ®åº“管ç†å™¨å®žä¾‹ã€‚ 以下为创建分布å¼æ•°æ®åº“管ç†å™¨çš„代ç 示例: @@ -64,7 +63,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ 3. 获å–/创建分布å¼æ•°æ®åº“。 1. 声明需è¦åˆ›å»ºçš„分布å¼æ•°æ®åº“IDæ述。 - 2. 创建分布å¼æ•°æ®åº“,建议关é—自动åŒæ¥åŠŸèƒ½(autoSync:false),需è¦åŒæ¥æ—¶ä¸»åŠ¨è°ƒç”¨sync接å£ã€‚ + 2. 创建分布å¼æ•°æ®åº“,建议关é—自动åŒæ¥åŠŸèƒ½ï¼ˆ`autoSync:false`),需è¦åŒæ¥æ—¶ä¸»åŠ¨è°ƒç”¨`sync`接å£ã€‚ 以下为创建分布å¼æ•°æ®åº“的代ç 示例: ```js @@ -91,9 +90,10 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ } ``` - >  **说明:** - > 组网设备间åŒæ¥æ•°æ®çš„场景,建议在应用å¯åŠ¨æ—¶æ‰“开分布å¼æ•°æ®åº“,获å–æ•°æ®åº“çš„å¥æŸ„。在该å¥æŸ„(如上例ä¸çš„kvStoreï¼‰çš„ç”Ÿå‘½å‘¨æœŸå†…æ— éœ€é‡å¤åˆ›å»ºæ•°æ®åº“,å¯ç›´æŽ¥ä½¿ç”¨å¥æŸ„对数æ®åº“进行数æ®çš„æ’å…¥ç‰æ“作。 - + > **说明:** + > + > 组网设备间åŒæ¥æ•°æ®çš„场景,建议在应用å¯åŠ¨æ—¶æ‰“开分布å¼æ•°æ®åº“,获å–æ•°æ®åº“çš„å¥æŸ„。在该å¥æŸ„(如示例ä¸çš„`kvStore`ï¼‰çš„ç”Ÿå‘½å‘¨æœŸå†…æ— éœ€é‡å¤åˆ›å»ºæ•°æ®åº“,å¯ç›´æŽ¥ä½¿ç”¨å¥æŸ„对数æ®åº“进行数æ®çš„æ’å…¥ç‰æ“作。 + 4. 订阅分布å¼æ•°æ®å˜åŒ–。 以下为订阅å•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“æ•°æ®å˜åŒ–通知的代ç 示例: ```js @@ -103,7 +103,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ ``` 5. 将数æ®å†™å…¥åˆ†å¸ƒå¼æ•°æ®åº“。 - 1. æž„é€ éœ€è¦å†™å…¥åˆ†å¸ƒå¼æ•°æ®åº“çš„Key(é”®)å’ŒValue(值)。 + 1. æž„é€ éœ€è¦å†™å…¥åˆ†å¸ƒå¼æ•°æ®åº“çš„`Key`(键)和`Value`(值)。 2. 将键值数æ®å†™å…¥åˆ†å¸ƒå¼æ•°æ®åº“。 以下为将å—符串类型键值数æ®å†™å…¥åˆ†å¸ƒå¼æ•°æ®åº“的代ç 示例: @@ -125,7 +125,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ ``` 6. 查询分布å¼æ•°æ®åº“æ•°æ®ã€‚ - 1. æž„é€ éœ€è¦ä»Žå•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“ä¸æŸ¥è¯¢çš„Key(é”®)。 + 1. æž„é€ éœ€è¦ä»Žå•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“ä¸æŸ¥è¯¢çš„`Key`(键)。 2. 从å•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“ä¸èŽ·å–æ•°æ®ã€‚ 以下为从分布å¼æ•°æ®åº“ä¸æŸ¥è¯¢å—符串类型数æ®çš„代ç 示例: @@ -149,9 +149,13 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ ``` 7. åŒæ¥æ•°æ®åˆ°å…¶ä»–设备。 - 1.选择åŒä¸€ç»„网环境下的设备以åŠåŒæ¥æ¨¡å¼ï¼Œè¿›è¡Œæ•°æ®åŒæ¥ã€‚ + 选择åŒä¸€ç»„网环境下的设备以åŠåŒæ¥æ¨¡å¼ï¼Œè¿›è¡Œæ•°æ®åŒæ¥ã€‚ - 以下为å•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“进行数æ®åŒæ¥çš„代ç 示例,其ä¸deviceIdså¯ç”±deviceManager调用getTrustedDeviceListSync()方法得到,1000表示最大延迟时间为1000ms: + > **说明**: + > + > å…¶ä¸`deviceManager`模å—的接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + + 以下为å•ç‰ˆæœ¬åˆ†å¸ƒå¼æ•°æ®åº“进行数æ®åŒæ¥çš„代ç 示例: ```js import deviceManager from '@ohos.distributedHardware.deviceManager'; @@ -160,7 +164,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ deviceManager.createDeviceManager("bundleName", (err, value) => { if (!err) { devManager = value; - // get deviceIds + // deviceIdsç”±deviceManager调用getTrustedDeviceListSync方法得到 let deviceIds = []; if (devManager != null) { var devices = devManager.getTrustedDeviceListSync(); @@ -169,6 +173,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ } } try{ + // 1000表示最大延迟时间为1000ms kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); }catch (e) { console.log("An unexpected error occurred. Error:" + e); @@ -178,5 +183,7 @@ OpenHarmony系统ä¸çš„分布å¼æ•°æ®æœåŠ¡æ¨¡å—为开å‘者æ供下é¢å‡ ç§ ``` ## 相关实例 针对分布å¼æ•°æ®å¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`DistributedDataGobang`:分布å¼äº”å棋(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedDataGobang) +- [`DDMQuery`:结果集与谓è¯ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DDMQuery) - [`KvStore`:分布å¼æ•°æ®åº“(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore) -- [分布å¼æ•°æ®åº“](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) +- [分布å¼æ•°æ®åº“(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData) \ No newline at end of file diff --git a/zh-cn/application-dev/database/database-preference-guidelines.md b/zh-cn/application-dev/database/database-preference-guidelines.md index 14e25f9916b5b76deed13334993231ea7f586f20..76f3ff7808a49ab03bc09f5ad26297be6fa67385 100644 --- a/zh-cn/application-dev/database/database-preference-guidelines.md +++ b/zh-cn/application-dev/database/database-preference-guidelines.md @@ -167,3 +167,6 @@ console.info("Deleted failed with err: " + err) }) ``` +## 相关实例 +针对首选项开å‘,有以下相关实例å¯ä¾›å‚考: +- [`Preferences`:首选项(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/data/Preferences) diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index 8a46eeaf4e5bb678fa39eecd48c52c0dea5c7b4c..26df601aaf7dfcff5ff6fc1bce3a06640529c5b9 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -210,6 +210,16 @@ | RdbStore |restore(srcName:string, callback: AsyncCallback<void>):void| 从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,结果以callbackå½¢å¼è¿”回。<br/>- srcName:指定数æ®åº“的备份文件å。<br/>- callback:指定callback回调函数。 | | RdbStore |restore(srcName:string): Promise<void>| 从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,结果以promiseå½¢å¼è¿”回。<br/>- srcName:指定数æ®åº“的备份文件å。 | +**事务** + +**表15** 事务 + +| ç±»å | 接å£å | æè¿° | +| -------- | -------- | -------- | +| RdbStore |beginTransaction():void| 在开始执行SQLè¯å¥ä¹‹å‰ï¼Œå¼€å§‹äº‹åŠ¡ã€‚ | +| RdbStore |commit():void| æ交已执行的SQLè¯å¥ã€‚ | +| RdbStore |rollBack():void| 回滚已ç»æ‰§è¡Œçš„SQLè¯å¥ã€‚ | + ## å¼€å‘æ¥éª¤ 1. 创建数æ®åº“。 @@ -278,9 +288,9 @@ ```js "requestPermissions": - { - "name": "ohos.permission.DISTRIBUTED_DATASYNC" - } + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } ``` (2) 获å–应用æƒé™ã€‚ @@ -321,7 +331,7 @@ promise.then((result) => { console.log('sync done.') for (let i = 0; i < result.length; i++) { - console.log('device=' + result[i][0] + ' status=' + result[i][1]) + console.log('device=' + result[i][0] + 'status=' + result[i][1]) } }).catch((err) => { console.log('sync failed') @@ -339,7 +349,7 @@ ```js function storeObserver(devices) { for (let i = 0; i < devices.length; i++) { - console.log('device=' + device[i] + ' data changed') + console.log('device=' + device[i] + 'data changed') } } try { @@ -372,17 +382,17 @@ ```js let promiseBackup = rdbStore.backup("dbBackup.db") - promiseBackup.then(()=>{ + promiseBackup.then(() => { console.info('Backup success.') - }).catch((err)=>{ + }).catch((err) => { console.info('Backup failed, err: ' + err) }) ``` ```js let promiseRestore = rdbStore.restore("dbBackup.db") - promiseRestore.then(()=>{ + promiseRestore.then(() => { console.info('Restore success.') - }).catch((err)=>{ + }).catch((err) => { console.info('Restore failed, err: ' + err) }) ``` @@ -391,4 +401,4 @@ 针对关系型数æ®åº“å¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Rdb`:关系型数æ®åº“(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Rdb) - [`DistributedRdb`:分布å¼å…³ç³»åž‹æ•°æ®åº“(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/data/DistributedRdb) -- [关系型数æ®åº“](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) +- [关系型数æ®åº“(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Data/JSRelationshipData) diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md index 9a43e1571aff77f8223461b3c472fefef2c1d7e8..bb10ceb9914da5f59bcf07d919c55b89932160c2 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md @@ -436,4 +436,7 @@ import stats from '@ohos.bundleState'; } }); ``` +## 相关实例 +针对设备使用信æ¯ç»Ÿè®¡ï¼Œæœ‰ä»¥ä¸‹ç›¸å…³å®žä¾‹å¯ä¾›å‚考: +- [`DeviceUsageStatistics`:设备使用信æ¯ç»Ÿè®¡ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/DeviceUsageStatistics) diff --git a/zh-cn/application-dev/device/device-location-geocoding.md b/zh-cn/application-dev/device/device-location-geocoding.md index d15b8df3418540ef13cedde828173a1948d9e8fc..8e87eab224a108cd6b620b3bda272c39abda82e8 100644 --- a/zh-cn/application-dev/device/device-location-geocoding.md +++ b/zh-cn/application-dev/device/device-location-geocoding.md @@ -39,13 +39,30 @@ import geolocation from '@ohos.geolocation'; ``` -2. 获å–转化结果。 +2. 查询geoCoderæœåŠ¡æ˜¯å¦å¯ç”¨ã€‚ + - 调用isGeoServiceAvailable查询geoCoderæœåŠ¡æ˜¯å¦å¯ç”¨ï¼Œå¦‚æžœæœåŠ¡å¯ç”¨å†ç»§ç»è¿›è¡Œæ¥éª¤3。 + + ``` + geolocation.isGeoServiceAvailable((err, data) => { + if (err) { + console.log('isGeoServiceAvailable err: ' + JSON.stringify(err)); + } else { + console.log('isGeoServiceAvailable data: ' + JSON.stringify(data)); + } + }); + ``` + +3. 获å–转化结果。 - 调用getAddressesFromLocation,åæ ‡è½¬åŒ–åœ°ç†ä½ç½®ä¿¡æ¯ã€‚ ``` var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; - geolocation.getAddressesFromLocation(reverseGeocodeRequest, (data) => { - console.log('getAddressesFromLocation: ' + JSON.stringify(data)); + geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { + if (err) { + console.log('getAddressesFromLocation err: ' + JSON.stringify(err)); + } else { + console.log('getAddressesFromLocation data: ' + JSON.stringify(data)); + } }); ``` @@ -54,8 +71,12 @@ ``` var geocodeRequest = {"description": "上海市浦东新区xxè·¯xxå·", "maxItems": 1}; - geolocation.getAddressesFromLocationName(geocodeRequest, (data) => { - console.log('getAddressesFromLocationName: ' + JSON.stringify(data)); + geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { + if (err) { + console.log('getAddressesFromLocationName err: ' + JSON.stringify(err)); + } else { + console.log('getAddressesFromLocationName data: ' + JSON.stringify(data)); + } }); ``` diff --git a/zh-cn/application-dev/device/device-location-info.md b/zh-cn/application-dev/device/device-location-info.md index f5953d7740e91b796b940456e4e3ad0557727110..9aa69b81798ff67508e57c70ca22374e6da16907 100644 --- a/zh-cn/application-dev/device/device-location-info.md +++ b/zh-cn/application-dev/device/device-location-info.md @@ -84,7 +84,7 @@ } ``` - é…ç½®å—段详细说明è§ã€‚ + é…ç½®å—段详细说明è§[应用包结构é…置文件的说明](../quick-start/stage-structure.md)。 2. 导入geolocation模å—,所有与基础定ä½èƒ½åŠ›ç›¸å…³çš„功能API,都是通过该模å—æ供的。 @@ -123,7 +123,7 @@ 以导航场景为例,实例化方å¼å¦‚下: ``` - var requestInfo = {'scenario': 0x301, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + var requestInfo = {'scenario': geolocation.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` **æ–¹å¼äºŒï¼š** @@ -152,7 +152,7 @@ 以定ä½ç²¾åº¦ä¼˜å…ˆç–略为例,实例化方å¼å¦‚下: ``` - var requestInfo = {'priority': 0x201, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; + var requestInfo = {'priority': geolocation.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` 4. 实例化Callback对象,用于å‘系统æä¾›ä½ç½®ä¸ŠæŠ¥çš„途径。 @@ -179,8 +179,12 @@ 如果应用使用场景ä¸éœ€è¦å®žæ—¶çš„设备ä½ç½®ï¼Œå¯ä»¥èŽ·å–系统缓å˜çš„最近一次历å²å®šä½ç»“果。 ``` - geolocation.getLastLocation((data) => { - console.log('getLastLocation: data: ' + JSON.stringify(data)); + geolocation.getLastLocation((err, data) => { + if (err) { + console.log('getLastLocation: err: ' + JSON.stringify(err)); + } else { + console.log('getLastLocation: data: ' + JSON.stringify(data)); + } }); ``` diff --git a/zh-cn/application-dev/device/device-location-overview.md b/zh-cn/application-dev/device/device-location-overview.md index 31bab927335cab41b6d135f890840f2f3e576502..d6a7606f38bc5ad49b72d9c8818ba2c0ec905d63 100644 --- a/zh-cn/application-dev/device/device-location-overview.md +++ b/zh-cn/application-dev/device/device-location-overview.md @@ -37,3 +37,9 @@ 使用设备的ä½ç½®èƒ½åŠ›ï¼Œéœ€è¦ç”¨æˆ·è¿›è¡Œç¡®è®¤å¹¶ä¸»åŠ¨å¼€å¯ä½ç½®å¼€å…³ã€‚如果ä½ç½®å¼€å…³æ²¡æœ‰å¼€å¯ï¼Œç³»ç»Ÿä¸ä¼šå‘任何应用æä¾›ä½ç½®æœåŠ¡ã€‚ 设备ä½ç½®ä¿¡æ¯å±žäºŽç”¨æˆ·æ•æ„Ÿæ•°æ®ï¼Œæ‰€ä»¥å³ä½¿ç”¨æˆ·å·²ç»å¼€å¯ä½ç½®å¼€å…³ï¼Œåº”用在获å–设备ä½ç½®å‰ä»éœ€å‘用户申请ä½ç½®è®¿é—®æƒé™ã€‚在用户确认å…许åŽï¼Œç³»ç»Ÿæ‰ä¼šå‘应用æä¾›ä½ç½®æœåŠ¡ã€‚ + +## 相关实例 + +针对ä½ç½®æœåŠ¡ï¼Œæœ‰ä»¥ä¸‹ç›¸å…³å®žä¾‹å¯ä¾›å‚考: + +-[`Location`:ä½ç½®æœåŠ¡ï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/device/Location) diff --git a/zh-cn/application-dev/device/sensor-guidelines.md b/zh-cn/application-dev/device/sensor-guidelines.md index 6259723f5680f363646aca21d9341c6a22435622..8ffc74e20dea5ce602b497d67405ed87312ccf87 100644 --- a/zh-cn/application-dev/device/sensor-guidelines.md +++ b/zh-cn/application-dev/device/sensor-guidelines.md @@ -87,7 +87,7 @@ ``` import sensor from "@ohos.sensor" sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){ - console.info("Subscription succeeded. data = " + data);//调用æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® + console.info("Subscription succeeded. data = " + data);// 调用æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® } ); ``` @@ -101,7 +101,7 @@ ``` import sensor from "@ohos.sensor" sensor.off(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function() { - console.info("Succeeded in unsubscribing from acceleration sensor data.");//注销æˆåŠŸï¼Œè¿”回打å°ç»“æžœ + console.info("Succeeded in unsubscribing from acceleration sensor data.");// 注销æˆåŠŸï¼Œè¿”回打å°ç»“æžœ } ); ``` @@ -115,7 +115,7 @@ ``` import sensor from "@ohos.sensor" sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { - console.info("Data obtained successfully. data=" + data);//获å–æ•°æ®æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® + console.info("Data obtained successfully. data=" + data);// 获å–æ•°æ®æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® } ); ``` @@ -129,7 +129,7 @@ ``` try { sensor.once(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data) { - console.info("Data obtained successfully. data=" + data);//获å–æ•°æ®æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® + console.info("Data obtained successfully. data=" + data);// 获å–æ•°æ®æˆåŠŸï¼Œæ‰“å°å¯¹åº”ä¼ æ„Ÿå™¨çš„æ•°æ® }); } catch (error) { console.error(error); diff --git a/zh-cn/application-dev/device/usb-guidelines.md b/zh-cn/application-dev/device/usb-guidelines.md index a4b96c2735fcca119917c6c1fcd24e892ac4a3a0..938786fd4b316a19c78b20867a4ee57e560f4e6e 100644 --- a/zh-cn/application-dev/device/usb-guidelines.md +++ b/zh-cn/application-dev/device/usb-guidelines.md @@ -153,3 +153,6 @@ USB设备å¯ä½œä¸ºHost设备连接Device设备进行数æ®ä¼ 输。开å‘示例 usb.releaseInterface(pipe, interface1); usb.closePipe(pipe); ``` +## 相关实例 +针对USB管ç†å¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`USBManager`:USB管ç†ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/USBManager) diff --git a/zh-cn/application-dev/internationalization/intl-guidelines.md b/zh-cn/application-dev/internationalization/intl-guidelines.md index ceb2f492b42a98e0aa6e1df30db8d801d3cf314c..0f3584a39921fe3065bc46b3ae296c297267442f 100644 --- a/zh-cn/application-dev/internationalization/intl-guidelines.md +++ b/zh-cn/application-dev/internationalization/intl-guidelines.md @@ -328,4 +328,6 @@ 针对Intlå¼€å‘,有以下相关实例å¯ä¾›å‚考: --[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) \ No newline at end of file +-[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/International) + +-[`International`:国际化(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/International) \ No newline at end of file diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/cases.md b/zh-cn/application-dev/key-features/multi-device-app-dev/cases.md deleted file mode 100644 index cf634a1e5c8f4ec793c48d6e7621ec4c18f01160..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/cases.md +++ /dev/null @@ -1,9 +0,0 @@ -# 案例应用 - - -æœ¬ç« å°†ä»ŽOpenHarmony预置的系统应用ä¸ï¼Œé€‰æ‹©ä¸€äº›è¾ƒä¸ºå…¸åž‹çš„案例,从页é¢å¼€å‘和工程结构的角度,介ç»"一多"的具体实践。OpenHarmony的产å“å½¢æ€åœ¨ä¸æ–丰富ä¸ï¼Œå½“å‰ä¸»è¦æœ‰é»˜è®¤è®¾å¤‡å’Œå¹³æ¿ä¸¤ç§äº§å“å½¢æ€ï¼Œæœ¬ç« 的具体实践也将围绕这两ç§äº§å“å½¢æ€å±•å¼€ã€‚ - - -- **[çŸä¿¡åº”用](sms-intro.md)** - -- **[æ¡Œé¢åº”用](cases-home-screen.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/interaction-events-unification.md b/zh-cn/application-dev/key-features/multi-device-app-dev/interaction-events-unification.md index de8757da2e44363a30aa616132fbb78fd77ef031..20e03164ee6e4865b3caac476d04e88a5a30fec3 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/interaction-events-unification.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/interaction-events-unification.md @@ -42,7 +42,7 @@ 一个完整的拖拽事件,包å«å¤šä¸ªæ‹–拽å事件,如下表所示(请访问拖拽事件了解详细用法)。当å‰è§¦æŽ§å±å’Œé¼ æ ‡çš„æ‹–æ‹½äº‹ä»¶å·²ç»å®žçŽ°â€äº¤äº’归一â€ï¼Œå¯¹è§¦æŽ§å±çš„支æŒæ£åœ¨å¼€å‘ä¸ã€‚ - | å称 | 功能æè¿° | +| å称 | 功能æè¿° | | -------- | -------- | | onDragStart | 绑定A组件,触控å±é•¿æŒ‰/é¼ æ ‡å·¦é”®æŒ‰ä¸‹åŽç§»åŠ¨è§¦å‘ | | onDragEnter | 绑定B组件,触控å±æ‰‹æŒ‡ã€é¼ æ ‡ç§»åŠ¨è¿›å…¥Bç»„ä»¶çž¬é—´è§¦å‘ | diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md b/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md index 481ccd596210d4541bf68da4b55d5a02049a21bb..474da8065f0ad6a0d8bd97afcca584ee260fbfc0 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/layout-intro.md @@ -13,3 +13,8 @@ 下é¢å°†è¯¦ç»†ä»‹ç»è¿™äº›å¸ƒå±€èƒ½åŠ›ã€‚ +## 相关实例 +针对一次开å‘,多端部署,有以下相关实例å¯ä¾›å‚考: +- [`AdaptiveCapabilities`:多设备自适应能力(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/MultiDeviceAppDev/AdaptiveCapabilities) +- [`JsAdaptiveCapabilities`:多设备自适应能力(JS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/MultiDeviceAppDev/JsAdaptiveCapabilities) +- [一次开å‘多端部署(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/MultiDeploymentEts) diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/page-development.md b/zh-cn/application-dev/key-features/multi-device-app-dev/page-development.md deleted file mode 100644 index 876cb0ac1b64b0642a34b48618548b80959814c2..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/page-development.md +++ /dev/null @@ -1,13 +0,0 @@ -# 一多能力的页é¢å¼€å‘ä»‹ç» - - -æœ¬ç« ä»‹ç»å¦‚何使用方舟开å‘框架"一多"能力,开å‘出在多设备上æ£å¸¸æ˜¾ç¤ºçš„页é¢ã€‚方舟开å‘框架更推èå¼€å‘者使用声明å¼å¼€å‘范å¼å¼€å‘åº”ç”¨ï¼Œæ•…æœ¬ç« çš„å†…å®¹å’Œç¤ºä¾‹éƒ½åŸºäºŽå£°æ˜Žå¼å¼€å‘范å¼ï¼Œæ‰€æœ‰ç¤ºä¾‹ä»£ç å‡å¯ä»¥ä»Ž[ç 云开æºä»£ç 仓](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/AdaptiveCapabilities)ä¸èŽ·å–。 - - -- **[布局能力](layout-intro.md)** - -- **[交互归一](interaction-events-unification.md)** - -- **[多æ€ç»„件](polymorphic-components.md)** - -- **[资æºä½¿ç”¨](resource-usage.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/resource-usage.md b/zh-cn/application-dev/key-features/multi-device-app-dev/resource-usage.md index 4915ade834a8f61eb902b015f1cd090a7122e6a4..20129df52a83ba41e72039ef1ee3320624da9b66 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/resource-usage.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/resource-usage.md @@ -38,7 +38,7 @@ 在工程ä¸ï¼Œé€šè¿‡ "$r('app.type.name')" çš„å½¢å¼å¼•ç”¨åº”用资æºã€‚app代表是应用内resources目录ä¸å®šä¹‰çš„资æºï¼›type 代表资æºç±»åž‹ï¼ˆæˆ–资æºçš„å˜æ”¾ä½ç½®ï¼‰ï¼Œå¯ä»¥å– colorã€floatã€stringã€pluralå’Œmedia,name代表资æºå‘½å,由开å‘者定义资æºæ—¶ç¡®å®šã€‚ >  **说明:** -> - å¯ä»¥æŸ¥çœ‹[声明å¼å¼€å‘范å¼èµ„æºè®¿é—®](../../ui/ts-application-resource-access.md),了解资æºè®¿é—®çš„更多细节。 +> - å¯ä»¥æŸ¥çœ‹[声明å¼å¼€å‘范å¼èµ„æºè®¿é—®](../../ui/ts-resource-access.md),了解资æºè®¿é—®çš„更多细节。 > > - ç±»Webå¼€å‘范å¼çš„资æºæ–‡ä»¶è·¯å¾„åŠèµ„æºé™å®šè¯çš„使用与声明å¼èŒƒå¼ä¸åŒï¼Œè¯¦æƒ…请å‚考[ç±»Webå¼€å‘范å¼èµ„æºé™å®šä¸Žè®¿é—®](../../ui/js-framework-resource-restriction.md)åŠ[ç±»Webå¼€å‘范å¼æ–‡ä»¶ç»„织](../../ui/js-framework-file.md)。 diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index 4ff544ab9d076efd6ca9ad5cd3a6ed2157b227dc..d0793ffdd3396a75f81a3af585dd59d865078e3f 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -5,6 +5,7 @@ - [音频æ’放开å‘指导](audio-playback.md) - [音频录制开å‘指导](audio-recorder.md) - [音频渲染开å‘指导](audio-renderer.md) + - [音频æµç®¡ç†å¼€å‘指导](audio-stream-manager.md) - [音频采集开å‘指导](audio-capturer.md) - [OpenSL ESæ’放开å‘指导](opensles-playback.md) - [OpenSL ES录音开å‘指导](opensles-capture.md) diff --git a/zh-cn/application-dev/media/audio-interruptmode.md b/zh-cn/application-dev/media/audio-interruptmode.md index 6bd6386ab04a6f2894df3e4619b780e8078e4a5a..897fa18ec4091959fc8883d637d53f14c7b9e8b8 100644 --- a/zh-cn/application-dev/media/audio-interruptmode.md +++ b/zh-cn/application-dev/media/audio-interruptmode.md @@ -48,7 +48,7 @@ ```js var mode_ = audio.InterruptMode.SHARE_MODE; - await this.audioRenderer.setInterruptMode(mode_).then(()=>{ + await this.audioRenderer.setInterruptMode(mode_).then(() => { console.log('[JSAR] [SetInterruptMode] 设置: ' + (mode_ == 0 ? "共享模å¼":"独立焦点模å¼") + "æˆåŠŸ" ); }); ``` diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index f58d0a7c980c3fc5313cf8e92f42dfb961fb4ad3..6313ac85397e94b8e26c955ff647fc2d5c6208f3 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -193,12 +193,12 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = nextFdPath; //设置src属性,并é‡æ–°è§¦å‘触å‘'dataLoad'事件回调 + audioPlayer.src = nextFdPath; // 设置src属性,并é‡æ–°è§¦å‘触å‘'dataLoad'事件回调 } async audioPlayerDemo() { - let audioPlayer = media.createAudioPlayer(); //创建一个音频æ’放实例 - this.setCallBack(audioPlayer); //设置事件回调 + let audioPlayer = media.createAudioPlayer(); // 创建一个音频æ’放实例 + this.setCallBack(audioPlayer); // 设置事件回调 let fdPath = 'fd://' // path路径的ç æµå¯é€šè¿‡"hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" 命令,将其推é€åˆ°è®¾å¤‡ä¸Š let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; @@ -210,7 +210,7 @@ export class AudioDemo { }).catch((err) => { console.info('open fd failed err is' + err); }); - audioPlayer.src = fdPath; //设置src属性,并触å‘'dataLoad'事件回调 + audioPlayer.src = fdPath; // 设置src属性,并触å‘'dataLoad'事件回调 } } ``` @@ -258,5 +258,5 @@ export class AudioDemo { - [`JsDistributedMusicPlayer`:分布å¼éŸ³ä¹æ’放(JS)(API7)](https://gitee.com/openharmony/app_samples/tree/master/ability/JsDistributedMusicPlayer) - [`JsAudioPlayer`:音频æ’放和管ç†ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsAudioPlayer) -- [`eTsAudioPlayer`: 音频æ’放器(eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) -- [音频æ’放器](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) \ No newline at end of file +- [`eTsAudioPlayer`: 音频æ’放器(eTS)(API8)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [音频æ’放器(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 91cb1835192acfebfcaa207d73e471c3c0895c8b..4fad7945ff6db32a2746751839a35427f5825674 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -192,5 +192,5 @@ export class AudioRecorderDemo { - [`Recorder`:录音机(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/Recorder) - [`JsRecorder`:录音机(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JSRecorder) -- [`eTsAudioPlayer`: 音频æ’放器(eTS)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) -- [音频æ’放器](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) +- [`eTsAudioPlayer`: 音频æ’放器(eTS)(API8)](https://gitee.com/openharmony/app_samples/blob/master/media/Recorder/entry/src/main/ets/MainAbility/pages/Play.ets) +- [音频æ’放器(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/Media/Audio_OH_ETS) diff --git a/zh-cn/application-dev/media/audio-stream-manager.md b/zh-cn/application-dev/media/audio-stream-manager.md new file mode 100644 index 0000000000000000000000000000000000000000..19602da3f2b02f21fa29742ac6a7f5425ec386b4 --- /dev/null +++ b/zh-cn/application-dev/media/audio-stream-manager.md @@ -0,0 +1,158 @@ +# 音频æµç®¡ç†å¼€å‘指导 + +## åœºæ™¯ä»‹ç» + +AudioStreamManageræ供了音频æµç®¡ç†çš„方法。开å‘者å¯ä»¥é€šè¿‡æœ¬æŒ‡å¯¼äº†è§£åº”用如何通过AudioStreamManager管ç†éŸ³é¢‘æµã€‚ + +### 工作æµç¨‹ + +在进行应用开å‘的过程ä¸ï¼Œå¼€å‘者需è¦ä½¿ç”¨getStreamManager()创建一个AudioStreamManager实例,进而通过该实例管ç†éŸ³é¢‘æµã€‚å¼€å‘者å¯é€šè¿‡è°ƒç”¨on('audioRendererChange')ã€on('audioCapturerChange')监å¬éŸ³é¢‘æ’放应用和音频录制应用,在应用状æ€å˜åŒ–ã€è®¾å¤‡å˜åŒ–ã€éŸ³é¢‘属性å˜åŒ–时获得通知。åŒæ—¶å¯é€šè¿‡off('audioRendererChange')ã€off('audioCapturerChange')å–消相关事件的监å¬ã€‚与æ¤åŒæ—¶ï¼Œå¼€å‘者å¯ä»¥é€šè¿‡è°ƒç”¨ï¼ˆå¯é€‰ï¼‰ä½¿ç”¨getCurrentAudioRendererInfoArray()获å–当å‰éŸ³é¢‘æ’放应用的音频æµå”¯ä¸€IDã€éŸ³é¢‘æ’放客户端的UIDã€éŸ³é¢‘状æ€ç‰ä¿¡æ¯ï¼ŒåŒç†å¯è°ƒç”¨getCurrentAudioCapturerInfoArray()获å–音频录制应用的信æ¯ã€‚其具体调用关系å¯å‚考音频æµç®¡ç†è°ƒç”¨å…³ç³»å›¾ã€‚ + +详细APIå«ä¹‰å¯å‚考:[音频管ç†API文档AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9) + +**图1** 音频æµç®¡ç†è°ƒç”¨å…³ç³»å›¾ + + + +## å¼€å‘æ¥éª¤ + +1. 创建AudioStreamManager实例。 + + 在使用AudioStreamManagerçš„APIå‰ï¼Œéœ€è¦ä½¿ç”¨getStreamManager()创建一个AudioStreamManager实例。 + + ```js + var audioStreamManager = audio.getStreamManager(); + ``` + +2. (å¯é€‰ï¼‰ä½¿ç”¨on('audioRendererChange')监å¬éŸ³é¢‘渲染器更改事件。 +如果音频æµç›‘å¬åº”用需è¦åœ¨éŸ³é¢‘æ’放应用状æ€å˜åŒ–ã€è®¾å¤‡å˜åŒ–ã€éŸ³é¢‘属性å˜åŒ–时获å–通知,å¯ä»¥è®¢é˜…该事件。更多事件请å‚考[APIå‚考文档](../reference/apis/js-apis-audio.md)。 + + ```js + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('## RendererChange on is called for ' + i + ' ##'); + console.info('StreamId for ' + i + ' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + }); + ``` + +3. (å¯é€‰ï¼‰ä½¿ç”¨off('audioRendererChange')å–消监å¬éŸ³é¢‘渲染器更改事件。 + + ```js + audioStreamManager.off('audioRendererChange'); + console.info('######### RendererChange Off is called #########'); + ``` + +4. (å¯é€‰ï¼‰ä½¿ç”¨on('audioCapturerChange')监å¬éŸ³é¢‘æ•èŽ·å™¨æ›´æ”¹äº‹ä»¶ã€‚ +如果音频æµç›‘å¬åº”用需è¦åœ¨éŸ³é¢‘录制应用状æ€å˜åŒ–ã€è®¾å¤‡å˜åŒ–ã€éŸ³é¢‘属性å˜åŒ–时获å–通知,å¯ä»¥è®¢é˜…该事件。更多事件请å‚考[APIå‚考文档](../reference/apis/js-apis-audio.md)。 + + ```js + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(' ## audioCapturerChange on is called for element ' + i + ' ##'); + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + }); + ``` + +5. (å¯é€‰ï¼‰ä½¿ç”¨off('audioCapturerChange')å–消监å¬éŸ³é¢‘æ•èŽ·å™¨æ›´æ”¹äº‹ä»¶ã€‚ + + ```js + audioStreamManager.off('audioCapturerChange'); + console.info('######### CapturerChange Off is called #########'); + ``` + +6. (å¯é€‰ï¼‰ä½¿ç”¨getCurrentAudioRendererInfoArray()获å–当å‰éŸ³é¢‘渲染器的信æ¯ã€‚ +该接å£å¯èŽ·å–音频æµå”¯ä¸€ID,音频æ’放客户端的UID,音频状æ€ä»¥åŠéŸ³é¢‘æ’放器的其他信æ¯ã€‚需注æ„的是若对第三方音频æµç›‘å¬åº”用未é…ç½®ohos.permission.USE_BLUETOOTHæƒé™ï¼Œåˆ™æŸ¥è¯¢åˆ°çš„设备å称和设备地å€ä¸ºç©ºå—符串,若æ£ç¡®é…ç½®æƒé™ï¼Œåˆ™æ˜¾ç¤ºçš„实际的设备å称和设备地å€ä¿¡æ¯ã€‚ + + ```js + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('StreamId for ' + i +' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream' + i +' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannnelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + } + }).catch((err) => { + console.log('getCurrentAudioRendererInfoArray :ERROR: ' + err.message); + }); + ``` + +7. (å¯é€‰ï¼‰ä½¿ç”¨getCurrentAudioCapturerInfoArray()获å–当å‰éŸ³é¢‘æ•èŽ·å™¨çš„ä¿¡æ¯ã€‚ +该接å£å¯èŽ·å–音频æµå”¯ä¸€ID,音频录制客户端的UID,音频状æ€ä»¥åŠéŸ³é¢‘æ•èŽ·å™¨çš„其他信æ¯ã€‚需注æ„的是若对第三方音频æµç›‘å¬åº”用未é…ç½®ohos.permission.USE_BLUETOOTHæƒé™ï¼Œåˆ™æŸ¥è¯¢åˆ°çš„设备å称和设备地å€ä¸ºç©ºå—符串,若æ£ç¡®é…ç½®æƒé™ï¼Œåˆ™æ˜¾ç¤ºçš„实际的设备å称和设备地å€ä¿¡æ¯ã€‚ + + ```js + await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('getCurrentAudioCapturerInfoArray: **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name) + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + } + }).catch((err) => { + console.log('getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/figures/zh-ch_image_audio_stream_manager.png b/zh-cn/application-dev/media/figures/zh-ch_image_audio_stream_manager.png new file mode 100644 index 0000000000000000000000000000000000000000..b5c72f9d662abb75e177534a888eef14d48d62ab Binary files /dev/null and b/zh-cn/application-dev/media/figures/zh-ch_image_audio_stream_manager.png differ diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index 551617ff75dbe68caf8eef4e678000760daafc49..deda457636e444120cee5a4577ebe1fed567b5fa 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -296,4 +296,11 @@ public async init(surfaceId: any) { // 调用Camera方法将surfaceIdä¼ é€’ç»™Camera。camera会通过surfaceId获å–surface,并生产出surface buffer。 } -``` \ No newline at end of file +``` + +## 相关实例 + +针对图片开å‘,有以下相关实例å¯ä¾›å‚考: + +- [`Image`:图片处ç†ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/Image) +- [`GamePuzzle`:拼图(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/GamePuzzle) \ No newline at end of file diff --git a/zh-cn/application-dev/media/opensles-playback.md b/zh-cn/application-dev/media/opensles-playback.md index 3f3b891f824fc15004f8a8f1e0d6150f3d765875..66e90957f3fe127f53714bf6615bb4f85541b61a 100644 --- a/zh-cn/application-dev/media/opensles-playback.md +++ b/zh-cn/application-dev/media/opensles-playback.md @@ -39,7 +39,7 @@ 0 }; - //具体å‚数需è¦æ ¹æ®éŸ³é¢‘æ–‡ä»¶æ ¼å¼è¿›è¡Œé€‚é… + // 具体å‚数需è¦æ ¹æ®éŸ³é¢‘æ–‡ä»¶æ ¼å¼è¿›è¡Œé€‚é… SLDataFormat_PCM pcmFormat = { SL_DATAFORMAT_PCM, 2, @@ -82,7 +82,7 @@ return; } - //wavFile_ 需è¦è®¾ç½®ä¸ºç”¨æˆ·æƒ³è¦æ’放的文件æ述符 + // wavFile_ 需è¦è®¾ç½®ä¸ºç”¨æˆ·æƒ³è¦æ’放的文件æ述符 wavFile_ = fopen(path, "rb"); (*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_); ``` diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index d68991c0a1fff0d436b57b04fc9cdfd2090dd54e..bb8a935684e397beef11c5ce4476b81a0a04fa1d 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -445,4 +445,5 @@ export class VideoPlayerDemo { ## 相关实例 针对视频æ’放开å‘,有以下相关实例å¯ä¾›å‚考: -- [`VideoPlayer`:视频æ’放(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) \ No newline at end of file +- [`VideoPlayer`:视频æ’放(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/media/VideoPlayer) +- [视频æ’放器(eTS)(API 9)](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoPlayerStage) \ No newline at end of file diff --git a/zh-cn/application-dev/napi/napi-guidelines.md b/zh-cn/application-dev/napi/napi-guidelines.md index f5702ff4654bf4f2e16ddee68d9bd9c705de75bc..95c03925de5ba06ea0eb08e22ab390dc51a946e2 100644 --- a/zh-cn/application-dev/napi/napi-guidelines.md +++ b/zh-cn/application-dev/napi/napi-guidelines.md @@ -10,23 +10,28 @@ js侧通过`import`引入native侧包å«å¤„ç†js逻辑的so,如:`import hell ## å¼€å‘建议 -### 1. 注册建议 +### 注册建议 * nm_register_func对应的函数需è¦åŠ 上static,防æ¢ä¸Žå…¶ä»–so里的符å·å†²çªã€‚ * 模å—注册的入å£ï¼Œå³ä½¿ç”¨\_\_attribute\_\_((constructor))修饰的函数的函数å需è¦ç¡®ä¿ä¸ä¸Žå…¶ä»–模å—é‡å¤ã€‚ -### 2. so命å规则 + +### so命å规则 * æ¯ä¸ªæ¨¡å—对应一个so * 如模å—å为`hello`,则soçš„åå—为`libhello.so`,`napi_module`ä¸`nm_modname`å—段应为`hello`,大å°å†™ä¸Žæ¨¡å—åä¿æŒä¸€è‡´ï¼Œåº”用使用时写作:`import hello from 'libhello.so'` -### 3. js对象线程é™åˆ¶ +### js对象线程é™åˆ¶ ark引擎会对js对象线程使用进行ä¿æŠ¤ï¼Œä¸æ£ç¡®ä½¿ç”¨ä¼šå¼•èµ·åº”用crash。 * napi接å£åªèƒ½åœ¨js线程使用。 * env与线程绑定,ä¸èƒ½è·¨çº¿ç¨‹ä½¿ç”¨ã€‚native侧js对象åªèƒ½åœ¨åˆ›å»ºæ—¶çš„线程使用,å³ä¸Žçº¿ç¨‹æ‰€æŒæœ‰çš„env绑定。 -### 4. napi_create_async_work接å£è¯´æ˜Ž +### 头文件引入é™åˆ¶ + +在使用napi的对象和方法时需è¦å¼•ç”¨"napi/native_api.h"。å¦åˆ™åœ¨åªå¼•å…¥ä¸‰æ–¹åº“头文件时,会出现未支æŒ**接å£æ— 法找到的编译报错**。 + +### napi_create_async_work接å£è¯´æ˜Ž napi_create_async_work里有两个回调: @@ -635,4 +640,9 @@ export default { }) } } -``` \ No newline at end of file +``` +## 相关实例 +针对Native APIçš„å¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`NativeAPI`:NativeAPI(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Native/NativeAPI) +- [第一个Native C++应用(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/NativeTemplateDemo) +- [Native Component(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/NativeAPI/XComponent) \ No newline at end of file diff --git a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md index 6b718b96f3c7e4c517856c28e20b998870027eff..309b35884a463fa5048b1ea03ae70a27a472ecdf 100644 --- a/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/notification/background-agent-scheduled-reminder-guide.md @@ -283,3 +283,6 @@ let alarm : reminderAgent.ReminderRequestAlarm = { - [`AlarmClock`:åŽå°ä»£ç†æ醒(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Notification/AlarmClock) +- [`FlipClock`:翻页时钟(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/CompleteApps/FlipClock) + +- [闹钟应用(eTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/CommonEventAndNotification/AlarmClock) \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index 3d62e542dff3976fd41ff705a616067c563f8be3..781fc318540701a0b14a9bad97c4fc1710a5d18b 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -2,14 +2,11 @@ - 快速入门 - [å¼€å‘准备](start-overview.md) - - [使用eTSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](start-with-ets.md) - - [使用eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](start-with-ets-low-code.md) - - [使用JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](start-with-js.md) - - [使用JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](start-with-js-low-code.md) + - [使用eTSè¯è¨€å¼€å‘(Stage模型)](start-with-ets-stage.md) + - [使用eTSè¯è¨€å¼€å‘(FA模型)](start-with-ets-fa.md) + - [使用JSè¯è¨€å¼€å‘(FA模型)](start-with-js-fa.md) - å¼€å‘基础知识 - [应用包结构说明(FA模型)](package-structure.md) - [应用包结构说明(Stage模型)](stage-structure.md) - - [资æºæ–‡ä»¶çš„分类](basic-resource-file-categories.md) - [SysCap说明](syscap.md) - - [HarmonyAppProvisioné…置文件](app-provision-structure.md) - + - [HarmonyAppProvisioné…置文件](app-provision-structure.md) \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/figures/01.png b/zh-cn/application-dev/quick-start/figures/01.png new file mode 100644 index 0000000000000000000000000000000000000000..ab9a01795cd6795448b16e53b7400cc7806e455c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/01.png differ diff --git a/zh-cn/application-dev/quick-start/figures/02.png b/zh-cn/application-dev/quick-start/figures/02.png new file mode 100644 index 0000000000000000000000000000000000000000..9b06d46ea1285613c00efc7cce55e7dbe2b74a2c Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/02.png differ diff --git a/zh-cn/application-dev/quick-start/figures/04.png b/zh-cn/application-dev/quick-start/figures/04.png new file mode 100644 index 0000000000000000000000000000000000000000..792837f2620a8c44dcf69ad7a56e8aed6693bf24 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/04.png differ diff --git a/zh-cn/application-dev/quick-start/figures/06.png b/zh-cn/application-dev/quick-start/figures/06.png new file mode 100644 index 0000000000000000000000000000000000000000..bdfc0acf1c46ded2b471894dc20af970f3c50836 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/06.png differ diff --git a/zh-cn/application-dev/quick-start/figures/07.png b/zh-cn/application-dev/quick-start/figures/07.png new file mode 100644 index 0000000000000000000000000000000000000000..3749dcb06daed21f87088a9a46afa6d0d87bef3f Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/07.png differ diff --git a/zh-cn/application-dev/quick-start/figures/09.png b/zh-cn/application-dev/quick-start/figures/09.png new file mode 100644 index 0000000000000000000000000000000000000000..ac6dbbab11846274c42bfdd61f7bd5dfe0ace99f Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/09.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311015192.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311015192.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311015192.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175120.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175120.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175120.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175132.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175132.png new file mode 100644 index 0000000000000000000000000000000000000000..2f401b2f8aa84e89bdef25bcf615ff1a621ab6d6 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311175132.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334932.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334932.png new file mode 100644 index 0000000000000000000000000000000000000000..42b475577bcc805372336be8971afa5c69c284bd Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334932.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334944.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334944.png new file mode 100644 index 0000000000000000000000000000000000000000..9ce82237297b06c04113d0368d7145661de0d997 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334944.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334972.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334972.png new file mode 100644 index 0000000000000000000000000000000000000000..6499d0b2de7ee290b958059d13d9d19995e0e511 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334972.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334976.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334976.png new file mode 100644 index 0000000000000000000000000000000000000000..7891c03e8fab1eaaf6159964fc338e0be9bb080a Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311334976.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494580.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494580.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494580.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494592.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494592.png new file mode 100644 index 0000000000000000000000000000000000000000..a88a2ec512c0fa4f374d1e9ac03a27c717aeab58 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494592.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494604.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494604.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001311494604.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934577.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934577.png new file mode 100644 index 0000000000000000000000000000000000000000..6499d0b2de7ee290b958059d13d9d19995e0e511 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934577.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934589.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934589.png new file mode 100644 index 0000000000000000000000000000000000000000..2f401b2f8aa84e89bdef25bcf615ff1a621ab6d6 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001363934589.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054485.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054485.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1ea01d448434e7cfd94e174474e72b57d3b4cc Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054485.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png new file mode 100644 index 0000000000000000000000000000000000000000..a69b0c6f3b047e5961b05b40b663ce972a90b459 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364173989.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364173989.png new file mode 100644 index 0000000000000000000000000000000000000000..f4b6f516a8340914c41600ef24012dd3699648b6 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364173989.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364174013.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364174013.png new file mode 100644 index 0000000000000000000000000000000000000000..12978dc861aaa1f826404d9c6838bb8628381615 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364174013.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254729.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254729.png new file mode 100644 index 0000000000000000000000000000000000000000..7fba7aab32a92752b341af024ef97e5acfe3d73d Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254729.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254741.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254741.png new file mode 100644 index 0000000000000000000000000000000000000000..fbbde9923a131d3ab69257b28cfe33ca2a1040cf Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254741.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254773.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254773.png new file mode 100644 index 0000000000000000000000000000000000000000..6499d0b2de7ee290b958059d13d9d19995e0e511 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364254773.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128756.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128756.png deleted file mode 100644 index 6d16295957cdeaa957b4d5e3d03c1129e9e83e07..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128756.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128844.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128844.png deleted file mode 100644 index 8d7478096eaa6f49421ede9c55174d69bc97e7a4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128844.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128894.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128894.png deleted file mode 100644 index 5eaba9fabdafa12eca1da0822b4386d02530e793..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128894.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128998.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128998.png index cccca58909932db46aa1befe4bfccb84f8eba059..a6040c1b6bc6436fb40c62a4155bdcf61ef329e9 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128998.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655128998.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129041.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129041.png index 038118b55274fc0f4b02e03aa6fc96cf119d3858..53b19d01dc341dbded0580a6133f1022e28c20f1 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129041.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129041.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129232.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129232.png index 28dd39be98b6aa006bbea9a727a8c3eee940e0a5..7472fcaee2baa112efbe3dd15e229125bb524879 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129232.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129232.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129305.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129305.png deleted file mode 100644 index 8160c10a4ef4d3cbe8074576915ba198ebc2159e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129305.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129333.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129333.png index 6e343ebc68da42ad9402c313d175a90082fd75e1..40c14ab488732274441ef1d20d5a47f6b8aa38d2 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129333.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129333.png differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129398.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129398.png index b7b29950bb4f3ac3c4815c20317964a3d9572a97..41fea9d7e6d14534b3f051be32b75033d7da1210 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129398.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001655129398.png differ diff --git a/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md b/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md index 09bedd312ab92be022c61795f7ee73cc7ce8f74c..127195c13996d901aca61941cf0cb0c6959d96de 100644 --- a/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md +++ b/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md @@ -6,19 +6,17 @@ 三方开å‘者通过DevEco Studio自动下载的**API8版本**SDKå‡ä¸º**public版本**。public-SDK**ä¸æ”¯æŒ**å¼€å‘者使用**所有的系统API**,包括animator组件ã€xcomponent组件ã€@ohos.application.abilityManager.d.tsã€@ohos.application.formInfo.d.tsã€@ohos.bluetooth.d.tsç‰ï¼Œå¦‚工程必须ä¾èµ–于系统API,请按照以下æ¥éª¤æ›¿æ¢**full-SDK**。 -## 下载full-SDK(这里以3.1.1 Release版本为例) +> **说明**:本文ä¸çš„截图仅为å‚考,具体的显示界é¢è¯·ä»¥å®žé™…使用的DevEco Studioå’ŒSDK的版本为准。 -full-SDK需è¦æ‰‹åŠ¨ä¸‹è½½ã€‚请å‚考[OpenHarmony 3.1.1 Release版本说明书](https://gitee.com/openharmony/docs/blob/master/zh-cn/release-notes/OpenHarmony-v3.1.1-release.md)ä¸çš„获å–æ–¹å¼ï¼ŒèŽ·å–所需的æ“作系统的full-SDK。 - - - - +## 下载full-SDK +full-SDK需è¦æ‰‹åŠ¨ä¸‹è½½ã€‚请å‚考[版本说明书](../../release-notes/OpenHarmony-v3.2-beta2.md)ä¸çš„获å–æ–¹å¼ï¼Œä»Žé•œåƒç«™ç‚¹èŽ·å–所需的æ“作系统的full-SDK。 ## 查看本地SDK路径(æ¤å¤„以ets工程为例,1.0工程请以相åŒæ–¹å¼æ›¿æ¢js-SDK) + 打开DevEco Studio——>Tools——>OpenHarmony SDK Manager,查看本地SDK安装路径。  @@ -40,11 +38,11 @@ full-SDK需è¦æ‰‹åŠ¨ä¸‹è½½ã€‚请å‚考[OpenHarmony 3.1.1 Release版本说明书] -2. 替æ¢SDK,以public-SDK-3.1.6.6版本为例。 +2. 替æ¢SDK,以public-SDK-3.x.x.x版本为例。 以windows为例: - a.解压已下载的full-SDK文件:`ets-windows-3.1.6.5-Release.zip` + a.解压已下载的full-SDK文件:`ets-windows-3.x.x.x-Release.zip`  @@ -60,34 +58,35 @@ full-SDK需è¦æ‰‹åŠ¨ä¸‹è½½ã€‚请å‚考[OpenHarmony 3.1.1 Release版本说明书]  - `oh-uni-package.json`文件é…置信æ¯å¦‚下: + `oh-uni-package.json`文件é…置信æ¯å¦‚下,其ä¸ï¼Œ`apiVersion`的值以SDK对应的API version为准,`version`的值以SDK文件的版本å·ä¸ºå‡†ï¼š ``` { - "apiVersion": "8", + "apiVersion": "X", "displayName": "Ets", "meta": { "metaVersion": "3.0.0" }, "path": "ets", "releaseType": "Release", - "version": "3.1.6.6" + "version": "3.x.x.x" } ``` + - **åˆ é™¤åŽŸSDK(3.1.6.6)目录ä¸çš„所有文件**(å¦åˆ™å¯èƒ½ä¼šå¯¼è‡´æ–‡ä»¶æ— 法全部覆盖) + **åˆ é™¤åŽŸSDK(3.x.x.x)目录ä¸çš„所有文件**(å¦åˆ™å¯èƒ½ä¼šå¯¼è‡´æ–‡ä»¶æ— 法全部覆盖) **æ‹·è´full-SDK至本地SDK路径** - 将下载的full-SDK文件包ä¸`ets`目录下的所有文件替æ¢è‡³æœ¬åœ°SDK路径下`ets\3.1.6.6`ç›®å½•ä¸ + 将下载的full-SDK文件包ä¸`ets`目录下的所有文件替æ¢è‡³æœ¬åœ°SDK路径下`ets\3.x.x.x`ç›®å½•ä¸ ä¿®æ”¹`oh-uni-package.json`é…置文件的versionå—段为当å‰SDKç‰ˆæœ¬å· - 在`3.1.6.6\build-tools\ets-loader`目录ä¸æ‰“å¼€cmd/powerShell窗å£ï¼Œè¾“入命令`npm install`下载**node_modules**ä¾èµ–包 + 在`3.x.x.x\build-tools\ets-loader`目录ä¸æ‰“å¼€cmd/powerShell窗å£ï¼Œè¾“入命令`npm install`下载**node_modules**ä¾èµ–包  diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index 2f4e477c43adf0fe6f6eb9fa2d9177143e8ce59b..fab0b688c882f775baca2f5675fbab106a1db7db 100644 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -505,6 +505,7 @@ skills示例: | name | 需è¦ä½¿ç”¨çš„æƒé™å称。 | å—符串 | å¦ | | reason | æ述申请æƒé™çš„åŽŸå› ã€‚ä¸èƒ½è¶…过256个å—节。需è¦åšå¤šè¯ç§é€‚é…。 | å—符串 | 分情况:当申请的æƒé™ä¸ºuser_grant时,必须填写æ¤å—段,å¦åˆ™ä¸å…许在应用市场上架;其它æƒé™å¯ç¼ºçœï¼Œç¼ºçœä¸ºç©º | | usedScene | æè¿°æƒé™ä½¿ç”¨çš„场景和时机。场景类型有:abilityã€when。ability:abilityçš„å称,å¯é…置多个。when:调用时机,å¯å¡«çš„值有inuse(使用时)ã€always(始终) | 对象 | ability分情况:申请的æƒé™æœ‰user_grant时,ability必填;没有user_grantæ—¶å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚whenå¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œinuse†| +具体示例å¯å‚考[访问控制开å‘指导](../security/accesstoken-guidelines.md#fa模型)。 表22 js对象的内部结构说明 @@ -591,7 +592,7 @@ shortcuts示例: | isDefault | 表示该å¡ç‰‡æ˜¯å¦ä¸ºé»˜è®¤å¡ç‰‡ï¼Œæ¯ä¸ªAbility有且åªæœ‰ä¸€ä¸ªé»˜è®¤å¡ç‰‡ã€‚<br />true:默认å¡ç‰‡ã€‚<br />false:éžé»˜è®¤å¡ç‰‡ã€‚ | 布尔值 | ä¸å¯ç¼ºçœ | | type | 表示å¡ç‰‡çš„类型。å–值范围如下:<br />JS:JSå¡ç‰‡ã€‚ | å—符串 | ä¸å¯ç¼ºçœ | | colorMode | 表示å¡ç‰‡çš„ä¸»é¢˜æ ·å¼ï¼Œå–值范围如下:<br />auto:自适应。<br />dark:深色主题。<br />light:浅色主题。 | å—符串 | å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œautoâ€ã€‚ | -| supportDimensions | 表示å¡ç‰‡æ”¯æŒçš„å¤–è§‚è§„æ ¼ï¼Œå–值范围:<br />1 * 2:表示1è¡Œ2åˆ—çš„äºŒå®«æ ¼ã€‚<br />2 * 2:表示2è¡Œ2åˆ—çš„å››å®«æ ¼ã€‚<br />2 * 4:表示2è¡Œ4åˆ—çš„å…«å®«æ ¼ã€‚<br />4 * 4:表示4è¡Œ4列的åå…å®«æ ¼ã€‚ | å—符串数组 | ä¸å¯ç¼ºçœ | +| supportDimensions | 表示å¡ç‰‡æ”¯æŒçš„å¤–è§‚è§„æ ¼ï¼Œå–值范围:<br />1 * 2:表示1è¡Œ2åˆ—çš„äºŒå®«æ ¼ã€‚<br />2 * 1:表示2è¡Œ1åˆ—çš„äºŒå®«æ ¼ã€‚<br />2 * 2:表示2è¡Œ2åˆ—çš„å››å®«æ ¼ã€‚<br />2 * 4:表示2è¡Œ4åˆ—çš„å…«å®«æ ¼ã€‚<br />4 * 4:表示4è¡Œ4列的åå…å®«æ ¼ã€‚ | å—符串数组 | ä¸å¯ç¼ºçœ | | defaultDimension | 表示å¡ç‰‡çš„é»˜è®¤å¤–è§‚è§„æ ¼ï¼Œå–值必须在该å¡ç‰‡supportDimensionsé…置的列表ä¸ã€‚ | å—符串 | ä¸å¯ç¼ºçœ | | updateEnabled | 表示å¡ç‰‡æ˜¯å¦æ”¯æŒå‘¨æœŸæ€§åˆ·æ–°ï¼Œå–值范围:<br />true:表示支æŒå‘¨æœŸæ€§åˆ·æ–°ï¼Œå¯ä»¥åœ¨å®šæ—¶åˆ·æ–°ï¼ˆupdateDuration)和定点刷新(scheduledUpdateTime)两ç§æ–¹å¼ä»»é€‰å…¶ä¸€ï¼Œä¼˜å…ˆé€‰æ‹©å®šæ—¶åˆ·æ–°ã€‚<br />false:表示ä¸æ”¯æŒå‘¨æœŸæ€§åˆ·æ–°ã€‚ | 布尔类型 | ä¸å¯ç¼ºçœ | | scheduledUpdateTime | 表示å¡ç‰‡çš„定点刷新的时刻,采用24å°æ—¶åˆ¶ï¼Œç²¾ç¡®åˆ°åˆ†é’Ÿã€‚ | å—符串 | å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œ0:0â€ã€‚ | diff --git a/zh-cn/application-dev/quick-start/stage-structure.md b/zh-cn/application-dev/quick-start/stage-structure.md index f8540d4a1276d1d5d1f60d10c46215a3e49ab3c0..808ab2b55571653ca795e7f37379ad2821828e8a 100644 --- a/zh-cn/application-dev/quick-start/stage-structure.md +++ b/zh-cn/application-dev/quick-start/stage-structure.md @@ -163,25 +163,25 @@ hap包的é…置信æ¯ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰hap包生效。 表3 module对象内部结构 -| 属性å称 | å«ä¹‰ | æ•°æ®ç±»åž‹ | 是å¦å¯ç¼ºçœ | -| ------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------- | -| name | è¯¥æ ‡ç¾æ ‡è¯†å½“å‰moduleçš„åå—,module打包æˆhapåŽï¼Œè¡¨ç¤ºhapçš„åç§°ï¼Œæ ‡ç¾å€¼é‡‡ç”¨å—符串表示(最大长度31个å—节),该å称在整个应用è¦å”¯ä¸€ã€‚ | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| type | è¯¥æ ‡ç¾è¡¨ç¤ºå½“å‰hap的类型。类型有三ç§ï¼Œåˆ†åˆ«æ˜¯entryã€featureå’Œhar。 | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| srcEntrance | è¯¥æ ‡ç¾è¡¨ç¤ºhap所对应的入å£js代ç è·¯å¾„ï¼Œæ ‡ç¾å€¼ä¸ºå—符串(最长为127å—节)。 | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœã€‚ | -| description | è¯¥æ ‡ç¾æ ‡è¯†hap包的æè¿°ä¿¡æ¯ï¼Œæ ‡ç¾å€¼æ˜¯æ˜¯å—符串类型或对æ述内容的资æºç´¢å¼•ï¼Œä»¥æ”¯æŒå¤šè¯è¨€ã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | -| process | è¯¥æ ‡ç¾æ ‡è¯†hap的进程åï¼Œæ ‡ç¾å€¼ä¸ºå—符串类型(最长为31个å—节)。如果在hapæ ‡ç¾ä¸‹é…置了process,该应用的所有ability都è¿è¡Œåœ¨è¯¥è¿›ç¨‹ä¸ã€‚ | å—符串 | å¯ç¼ºçœï¼Œç¼ºçœä¸ºhapçš„å称。 | -| mainElement | è¯¥æ ‡ç¾æ ‡è¯†hapçš„å…¥å£abilityå称或者extensionå称。åªæœ‰é…置为mainElementçš„ability或者extensionæ‰å…许在æœåŠ¡ä¸å¿ƒéœ²å‡ºã€‚创建OpenHarmony原å化æœåŠ¡æ—¶ï¼Œè¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | å—符串 | OpenHarmonyåº”ç”¨ä¸‹ï¼Œè¯¥æ ‡ç¾å¯ç¼ºçœã€‚ | -| deviceTypes | è¯¥æ ‡ç¾æ ‡è¯†hapå¯ä»¥è¿è¡Œåœ¨å“ªç±»è®¾å¤‡ä¸Šï¼Œæ ‡ç¾å€¼é‡‡ç”¨å—符串数组的表示,系统预定义的设备类型è§è¡¨4。<br />与syscapä¸åŒçš„是,deviceTypes是以设备类型为粒度,而syscap是以设备能力(例如è“牙ã€wifi)为粒度。 | å—符串数组 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœï¼Œå¯ä»¥ä¸ºç©ºå€¼ã€‚ | -| deliveryWithInstall | è¯¥æ ‡ç¾æ ‡è¯†å½“å‰hap是å¦åœ¨ç”¨æˆ·ä¸»åŠ¨å®‰è£…的时候安装,true表示主动安装时安装,false表示主动安装时ä¸å®‰è£…。 | 布尔值 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| installationFree | 表示当å‰HAP是å¦æ”¯æŒå…安装特性。所有Hap包都需è¦é…ç½®ä¸å¯ç¼ºçœã€‚<br/>true :表示支æŒå…安装特性,且符åˆå…安装约æŸã€‚<br/>false :表示ä¸æ”¯æŒå…安装特性。<br/><br/>当entry.hap该å—段é…置为true时,与该entry.hap相关的所有feature.hap该å—段也需è¦é…置为true。<br/>当entry.hap该å—段é…置为false时,与该entry.hap相关的å„feature.hap该å—段å¯æŒ‰ä¸šåŠ¡éœ€æ±‚é…ç½®true或false。 | 布尔值 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| virtualMachine | è¯¥æ ‡ç¾ç”¨äºŽæ ‡è¯†å½“å‰hapè¿è¡Œçš„ç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ï¼Œä¾›äº‘ç«¯åˆ†å‘使用,如应用市场和分å‘ä¸å¿ƒã€‚<br/>è¯¥æ ‡ç¾å€¼ä¸ºå—ç¬¦ä¸²ã€‚å¦‚æžœç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ä¸ºæ–¹èˆŸè™šæ‹Ÿæœºï¼Œåˆ™å…¶å€¼ä¸ºâ€arkâ€ï¼› å¦‚æžœç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ä¸æ˜¯æ–¹èˆŸè™šæ‹Ÿæœºï¼Œåˆ™å…¶å€¼ä¸ºâ€defaultâ€ã€‚è¯¥æ ‡ç¾ç”±IDE构建hap的时候自动æ’入。解包工具解æžæ—¶ï¼Œå¦‚æžœhapåŒ…æ²¡æœ‰è¯¥æ ‡ç¾ï¼Œè®¾ç½®è¯¥æ ‡ç¾å€¼ä¸ºâ€defaultâ€ã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œdefaultâ€ã€‚ | -| uiSyntax | syntax定义该JS Componentçš„è¯æ³•ç±»åž‹ã€‚<br />hmlæ ‡è¯†è¯¥JS Component使用hml/css/js进行开å‘ï¼›<br/>etsæ ‡è¯†è¯¥JS Component使用ets声明å¼è¯æ³•è¿›è¡Œå¼€å‘。 | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œé»˜è®¤å€¼ä¸ºhml | -| pages | è¯¥æ ‡ç¾æ˜¯ä¸€ä¸ªprofile资æºï¼Œç”¨äºŽåˆ—举JS Componentä¸æ¯ä¸ªé¡µé¢ä¿¡æ¯ã€‚pages使用å‚考pages示例。 | 对象 | 在有abilityçš„åœºæ™¯ä¸‹ï¼Œè¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| metadata | è¯¥æ ‡ç¾æ ‡è¯†Hap的自定义元信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰moduleã€æˆ–者abilityã€æˆ–者extensionAbility生效。metadataå‚考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | -| abilities | æ述元能力的é…置信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰ability生效。abilitieså‚考[abilities对象内部结构](#abilities对象内部结构)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | -| extensionAbilities | æè¿°extensionAbilitiesçš„é…置信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰extensionAbility生效。extensionAbilitieså‚考[extensionAbility对象的内部结构说明](#extensionAbility对象的内部结构说明)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | -| requestPermissions | è¯¥æ ‡ç¾æ ‡è¯†åº”用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„类型。requestPermissionså‚考[requestPermissions对象内部结构](#requestPermissions对象内部结构)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | -| testRunner | æ¤æ ‡ç¾ç”¨äºŽæ”¯æŒå¯¹æµ‹è¯•æ¡†æž¶çš„é…置,å‚考[testRunner对象内部结构说明](#testRunner对象内部结构)说明。 | 对象 | å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©º | +| 属性å称 | å«ä¹‰ | æ•°æ®ç±»åž‹ | 是å¦å¯ç¼ºçœ | +| -------------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------- | +| name | è¯¥æ ‡ç¾æ ‡è¯†å½“å‰moduleçš„åå—,module打包æˆhapåŽï¼Œè¡¨ç¤ºhapçš„åç§°ï¼Œæ ‡ç¾å€¼é‡‡ç”¨å—符串表示(最大长度31个å—节),该å称在整个应用è¦å”¯ä¸€ã€‚ | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| type | è¯¥æ ‡ç¾è¡¨ç¤ºå½“å‰hap的类型。类型有三ç§ï¼Œåˆ†åˆ«æ˜¯entryã€featureå’Œhar。 | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| srcEntrance | è¯¥æ ‡ç¾è¡¨ç¤ºhap所对应的入å£js代ç è·¯å¾„ï¼Œæ ‡ç¾å€¼ä¸ºå—符串(最长为127å—节)。 | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœã€‚ | +| description | è¯¥æ ‡ç¾æ ‡è¯†hap包的æè¿°ä¿¡æ¯ï¼Œæ ‡ç¾å€¼æ˜¯æ˜¯å—符串类型或对æ述内容的资æºç´¢å¼•ï¼Œä»¥æ”¯æŒå¤šè¯è¨€ã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | +| process | è¯¥æ ‡ç¾æ ‡è¯†hap的进程åï¼Œæ ‡ç¾å€¼ä¸ºå—符串类型(最长为31个å—节)。如果在hapæ ‡ç¾ä¸‹é…置了process,该应用的所有ability都è¿è¡Œåœ¨è¯¥è¿›ç¨‹ä¸ã€‚ | å—符串 | å¯ç¼ºçœï¼Œç¼ºçœä¸ºhapçš„å称。 | +| mainElement | è¯¥æ ‡ç¾æ ‡è¯†hapçš„å…¥å£abilityå称或者extensionå称。åªæœ‰é…置为mainElementçš„ability或者extensionæ‰å…许在æœåŠ¡ä¸å¿ƒéœ²å‡ºã€‚创建OpenHarmony原å化æœåŠ¡æ—¶ï¼Œè¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | å—符串 | OpenHarmonyåº”ç”¨ä¸‹ï¼Œè¯¥æ ‡ç¾å¯ç¼ºçœã€‚ | +| deviceTypes | è¯¥æ ‡ç¾æ ‡è¯†hapå¯ä»¥è¿è¡Œåœ¨å“ªç±»è®¾å¤‡ä¸Šï¼Œæ ‡ç¾å€¼é‡‡ç”¨å—符串数组的表示,系统预定义的设备类型è§è¡¨4。<br />与syscapä¸åŒçš„是,deviceTypes是以设备类型为粒度,而syscap是以设备能力(例如è“牙ã€wifi)为粒度。 | å—符串数组 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœï¼Œå¯ä»¥ä¸ºç©ºå€¼ã€‚ | +| deliveryWithInstall | è¯¥æ ‡ç¾æ ‡è¯†å½“å‰hap是å¦åœ¨ç”¨æˆ·ä¸»åŠ¨å®‰è£…的时候安装,true表示主动安装时安装,false表示主动安装时ä¸å®‰è£…。 | 布尔值 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| installationFree | 表示当å‰HAP是å¦æ”¯æŒå…安装特性。所有Hap包都需è¦é…ç½®ä¸å¯ç¼ºçœã€‚<br/>true :表示支æŒå…安装特性,且符åˆå…安装约æŸã€‚<br/>false :表示ä¸æ”¯æŒå…安装特性。<br/><br/>当entry.hap该å—段é…置为true时,与该entry.hap相关的所有feature.hap该å—段也需è¦é…置为true。<br/>当entry.hap该å—段é…置为false时,与该entry.hap相关的å„feature.hap该å—段å¯æŒ‰ä¸šåŠ¡éœ€æ±‚é…ç½®true或false。 | 布尔值 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| virtualMachine | è¯¥æ ‡ç¾ç”¨äºŽæ ‡è¯†å½“å‰hapè¿è¡Œçš„ç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ï¼Œä¾›äº‘ç«¯åˆ†å‘使用,如应用市场和分å‘ä¸å¿ƒã€‚<br/>è¯¥æ ‡ç¾å€¼ä¸ºå—ç¬¦ä¸²ã€‚å¦‚æžœç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ä¸ºæ–¹èˆŸè™šæ‹Ÿæœºï¼Œåˆ™å…¶å€¼ä¸ºâ€arkâ€ï¼› å¦‚æžœç›®æ ‡è™šæ‹Ÿæœºç±»åž‹ä¸æ˜¯æ–¹èˆŸè™šæ‹Ÿæœºï¼Œåˆ™å…¶å€¼ä¸ºâ€defaultâ€ã€‚è¯¥æ ‡ç¾ç”±IDE构建hap的时候自动æ’入。解包工具解æžæ—¶ï¼Œå¦‚æžœhapåŒ…æ²¡æœ‰è¯¥æ ‡ç¾ï¼Œè®¾ç½®è¯¥æ ‡ç¾å€¼ä¸ºâ€defaultâ€ã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œdefaultâ€ã€‚ | +| uiSyntax(deprecated) | syntax定义该JS Componentçš„è¯æ³•ç±»åž‹ã€‚<br />hmlæ ‡è¯†è¯¥JS Component使用hml/css/js进行开å‘ï¼›<br/>etsæ ‡è¯†è¯¥JS Component使用ets声明å¼è¯æ³•è¿›è¡Œå¼€å‘。 | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œé»˜è®¤å€¼ä¸ºhml,该å—段从API9开始废弃。 | +| pages | è¯¥æ ‡ç¾æ˜¯ä¸€ä¸ªprofile资æºï¼Œç”¨äºŽåˆ—举JS Componentä¸æ¯ä¸ªé¡µé¢ä¿¡æ¯ã€‚pages使用å‚考pages示例。 | 对象 | 在有abilityçš„åœºæ™¯ä¸‹ï¼Œè¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| metadata | è¯¥æ ‡ç¾æ ‡è¯†Hap的自定义元信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰moduleã€æˆ–者abilityã€æˆ–者extensionAbility生效。metadataå‚考[metadata对象内部结构](#metadata对象内部结构)。 | 数组 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | +| abilities | æ述元能力的é…置信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰ability生效。abilitieså‚考[abilities对象内部结构](#abilities对象内部结构)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | +| extensionAbilities | æè¿°extensionAbilitiesçš„é…置信æ¯ï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„ç±»åž‹ï¼Œè¯¥æ ‡ç¾ä¸‹çš„é…ç½®åªå¯¹å½“å‰extensionAbility生效。extensionAbilitieså‚考[extensionAbility对象的内部结构说明](#extensionAbility对象的内部结构说明)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | +| requestPermissions | è¯¥æ ‡ç¾æ ‡è¯†åº”用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆï¼Œæ ‡ç¾å€¼ä¸ºæ•°ç»„类型。requestPermissionså‚考[requestPermissions对象内部结构](#requestPermissions对象内部结构)。 | 对象 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | +| testRunner | æ¤æ ‡ç¾ç”¨äºŽæ”¯æŒå¯¹æµ‹è¯•æ¡†æž¶çš„é…置,å‚考[testRunner对象内部结构说明](#testRunner对象内部结构)说明。 | 对象 | å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©º | 表4 deviceTypes对象的系统预定义设备 @@ -439,7 +439,7 @@ skills示例 | description | è¯¥æ ‡ç¾æ ‡è¯†extensionAbilityçš„æè¿°ï¼Œæ ‡ç¾å€¼æ˜¯æ˜¯å—符串类型或对æ述内容的资æºç´¢å¼•ï¼Œä»¥æ”¯æŒå¤šè¯è¨€ã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | | icon | è¯¥æ ‡ç¾æ ‡è¯†extensionAbilityå›¾æ ‡ï¼Œæ ‡ç¾å€¼ä¸ºèµ„æºæ–‡ä»¶çš„索引。如果extensionAbility被é…置为MainElementï¼Œè¯¥æ ‡ç¾å¿…é¡»é…置。 | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | | label | è¯¥æ ‡ç¾æ ‡è¯†extensionAbility对用户显示的åç§°ï¼Œæ ‡ç¾å€¼é…置为该å称的资æºç´¢å¼•ä»¥æ”¯æŒå¤šè¯è¨€ã€‚<br/>如果extensionAbility被é…置为MainElementï¼Œè¯¥æ ‡ç¾å¿…é¡»é…置,且应用内唯一。 | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | -| type | è¯¥æ ‡ç¾æ ‡è¯†extensionAbility的类型,å–值为formã€workSchedulerã€inputMethodã€serviceã€accessibilityã€dataShareã€fileShareã€staticSubscriberã€wallpaperã€backupã€windowå…¶ä¸ä¹‹ä¸€ã€‚ | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | +| type | è¯¥æ ‡ç¾æ ‡è¯†extensionAbility的类型,å–值为formã€workSchedulerã€inputMethodã€serviceã€accessibilityã€dataShareã€fileShareã€staticSubscriberã€wallpaperã€backupã€windowã€enterpriseAdminã€thumbnailã€previewå…¶ä¸ä¹‹ä¸€ã€‚ | å—符串 | è¯¥æ ‡ç¾ä¸å¯ç¼ºçœã€‚ | | permissions | è¯¥æ ‡ç¾æ ‡è¯†è¢«å…¶å®ƒåº”用的ability调用时需è¦ç”³è¯·çš„æƒé™çš„集åˆï¼Œå—符串数组类型,æ¯ä¸ªæ•°ç»„å…ƒç´ ä¸ºä¸€ä¸ªæƒé™å称,通常采用åå‘域åæ–¹å¼è¡¨ç¤ºï¼ˆæœ€å¤§255å—节),å¯ä»¥æ˜¯ç³»ç»Ÿé¢„定义的æƒé™ï¼Œä¹Ÿå¯ä»¥æ˜¯è¯¥åº”用自定义的æƒé™ã€‚如果是åŽè€…,需与defPermissionsæ ‡ç¾ä¸å®šä¹‰çš„æŸä¸ªæƒé™çš„nameæ ‡ç¾å€¼ä¸€è‡´ã€‚ | å—符串数组 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | | uri | è¯¥æ ‡ç¾æ ‡è¯†abilityæ供的数æ®uri,为å—符数组类型(最大长度255),用åå‘域åçš„æ ¼å¼è¡¨ç¤ºã€‚è¯¥æ ‡ç¾åœ¨type为dataShare类型的extensionAbility时,ä¸å¯ç¼ºçœã€‚ | å—符串 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | | skills | è¯¥æ ‡ç¾æ ‡è¯†ability能够接收的æ„图的特å¾é›†ï¼Œä¸ºæ•°ç»„æ ¼å¼ã€‚<br />é…置规则 : entry包å¯ä»¥é…置多个具有入å£èƒ½åŠ›çš„skillsæ ‡ç¾ï¼ˆé…置了action.system.homeå’Œentity.system.home)的ability,其ä¸ç¬¬ä¸€ä¸ªé…置了skillsæ ‡ç¾çš„abilityä¸çš„labelå’Œicon作为OpenHarmonyæœåŠ¡æˆ–应用的labelå’Œicon。<br/>OpenHarmonyæœåŠ¡çš„Feature包ä¸èƒ½é…置具有入å£èƒ½åŠ›çš„skillsæ ‡ç¾ã€‚<br/>OpenHarmony应用的Feature包å¯ä»¥é…置具有入å£èƒ½åŠ›çš„skillsæ ‡ç¾ã€‚ <br />skills内部结构å‚考[skills对象内部结构](#skills对象内部结构)。 | 数组 | è¯¥æ ‡ç¾å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºç©ºã€‚ | @@ -507,6 +507,7 @@ requestPermissions示例 : } } ``` +æƒé™è®¿é—®çš„更多说明,å¯å‚考[访问控制开å‘指导](../security/accesstoken-guidelines.md) #### form对象内部结构 @@ -528,7 +529,7 @@ formsæ ‡ç¾è¡¨ç¤ºå¡ç‰‡çš„é…置,formå¡ç‰‡æ˜¯å¯ä»¥åµŒå…¥æ¡Œé¢ä¸Šå¹¶æŽ¥æ”¶ | window | è¯¥æ ‡ç¾æ ‡è¯†JSå¡ç‰‡çš„自适应能力。window结构å‚考表12。 | 对象 | å¯ç¼ºçœï¼Œç¼ºçœä¸ºç©ºã€‚ | | isDefault | 表示该å¡ç‰‡æ˜¯å¦ä¸ºé»˜è®¤å¡ç‰‡ï¼Œæ¯ä¸ªAbility有且åªæœ‰ä¸€ä¸ªé»˜è®¤å¡ç‰‡ã€‚ true :默认å¡ç‰‡ã€‚ false :éžé»˜è®¤å¡ç‰‡ã€‚ | 布尔值 | å¦ | | colorMode | 表示å¡ç‰‡çš„ä¸»é¢˜æ ·å¼ï¼Œå–值范围如下 : auto :自适应。 dark :深色主题。 light :浅色主题。 | å—符串 | å¯ç¼ºçœï¼Œç¼ºçœå€¼ä¸ºâ€œautoâ€ã€‚ | -| supportDimensions | 表示å¡ç‰‡æ”¯æŒçš„å¤–è§‚è§„æ ¼ï¼Œå–值范围 : 1 * 2 :表示1è¡Œ2åˆ—çš„äºŒå®«æ ¼ã€‚ 2 * 2 :表示2è¡Œ2åˆ—çš„å››å®«æ ¼ã€‚ 2 * 4 :表示2è¡Œ4åˆ—çš„å…«å®«æ ¼ã€‚ 4 * 4 :表示4è¡Œ4列的åå…å®«æ ¼ã€‚ | å—符串数组 | å¦ | +| supportDimensions | 表示å¡ç‰‡æ”¯æŒçš„å¤–è§‚è§„æ ¼ï¼Œå–值范围 : 1 * 2 :表示1è¡Œ2åˆ—çš„äºŒå®«æ ¼ã€‚ 2 * 1 :表示2è¡Œ1åˆ—çš„äºŒå®«æ ¼ã€‚ 2 * 2 :表示2è¡Œ2åˆ—çš„å››å®«æ ¼ã€‚ 2 * 4 :表示2è¡Œ4åˆ—çš„å…«å®«æ ¼ã€‚ 4 * 4 :表示4è¡Œ4列的åå…å®«æ ¼ã€‚ | å—符串数组 | å¦ | | defaultDimension | 表示å¡ç‰‡çš„é»˜è®¤å¤–è§‚è§„æ ¼ï¼Œå–值必须在该å¡ç‰‡supportDimensionsé…置的列表ä¸ã€‚ | å—符串 | å¦ | | updateDuration | è¯¥æ ‡ç¾æ ‡è¯†å¡ç‰‡å®šæ—¶åˆ·æ–°çš„更新频率,å•ä½ä¸º30分钟,å–值为30çš„å€æ•°å€¼ã€‚å¡ç‰‡çš„最高频率为æ¯30分钟刷新一次,和定点刷新二选一,二者都é…置的情况下,定时优先。 | 数值 | å¯ç¼ºçœï¼Œç¼ºçœä¸ºç©ºã€‚ | | metadata | è¯¥æ ‡ç¾è¡¨ç¤ºå¡ç‰‡çš„自定义信æ¯ã€‚metadata内部结构å‚考表5。 | 对象 | å¯ç¼ºçœï¼Œç¼ºçœä¸ºç©ºã€‚ | diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index e26343b37162e4c7436b52725907bec71a3d37d6..84d4c8befae5580f86210b8141a06189eebaa8d1 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -3,7 +3,7 @@ 本文档适用于OpenHarmony应用开å‘çš„åˆå¦è€…。通过构建一个简å•çš„具有页é¢è·³è½¬/返回功能的应用(如下图所示),快速了解工程目录的主è¦æ–‡ä»¶ï¼Œç†Ÿæ‚‰OpenHarmony应用开å‘æµç¨‹ã€‚ - + 在开始之å‰ï¼Œæ‚¨éœ€è¦äº†è§£æœ‰å…³OpenHarmony应用的一些基本概念:UI框架的简å•è¯´æ˜Žã€Ability的基本概念。 @@ -16,37 +16,37 @@ OpenHarmonyæ供了一套UIå¼€å‘框架,å³æ–¹èˆŸå¼€å‘框架(ArkUI框架)。方舟开å‘框架å¯ä¸ºå¼€å‘者æ供应用UIå¼€å‘所必需的能力,比如多ç§ç»„件ã€å¸ƒå±€è®¡ç®—ã€åŠ¨ç”»èƒ½åŠ›ã€UI交互ã€ç»˜åˆ¶ç‰ã€‚ -方舟开å‘框架针对ä¸åŒç›®çš„和技术背景的开å‘者æ供了两ç§å¼€å‘范å¼ï¼Œåˆ†åˆ«æ˜¯åŸºäºŽJS扩展的类Webå¼€å‘范å¼ï¼ˆç®€ç§°â€œç±»Webå¼€å‘范å¼â€ï¼‰å’ŒåŸºäºŽTS扩展的声明å¼å¼€å‘范å¼ï¼ˆç®€ç§°â€œå£°æ˜Žå¼å¼€å‘范å¼â€ï¼‰ã€‚以下是两ç§å¼€å‘范å¼çš„简å•å¯¹æ¯”。 +方舟开å‘框架针对ä¸åŒç›®çš„和技术背景的开å‘者æ供了两ç§å¼€å‘范å¼ï¼Œåˆ†åˆ«æ˜¯åŸºäºŽTS扩展的声明å¼å¼€å‘范å¼ï¼ˆç®€ç§°â€œå£°æ˜Žå¼å¼€å‘范å¼â€ï¼‰å’ŒåŸºäºŽJS扩展的类Webå¼€å‘范å¼ï¼ˆç®€ç§°â€œç±»Webå¼€å‘范å¼â€ï¼‰ã€‚以下是两ç§å¼€å‘范å¼çš„简å•å¯¹æ¯”。 | **å¼€å‘范å¼å称** | **è¯è¨€ç”Ÿæ€** | **UIæ›´æ–°æ–¹å¼** | **适用场景** | **适用人群** | | -------- | -------- | -------- | -------- | -------- | -| ç±»Webå¼€å‘èŒƒå¼ | JSè¯è¨€ | æ•°æ®é©±åŠ¨æ›´æ–° | ç•Œé¢è¾ƒä¸ºç®€å•çš„程åºåº”用和å¡ç‰‡ | Webå‰ç«¯å¼€å‘人员 | | 声明å¼å¼€å‘èŒƒå¼ | 扩展的TSè¯è¨€ï¼ˆeTS) | æ•°æ®é©±åŠ¨æ›´æ–° | å¤æ‚度较大ã€å›¢é˜Ÿåˆä½œåº¦è¾ƒé«˜çš„ç¨‹åº | 移动系统应用开å‘人员ã€ç³»ç»Ÿåº”用开å‘人员 | +| ç±»Webå¼€å‘èŒƒå¼ | JSè¯è¨€ | æ•°æ®é©±åŠ¨æ›´æ–° | ç•Œé¢è¾ƒä¸ºç®€å•çš„程åºåº”用和å¡ç‰‡ | Webå‰ç«¯å¼€å‘人员 | -对于JSè¯è¨€å¼€å‘时,低代ç æ–¹å¼åœ¨DevEco Studio V2.2 Beta1åŠæ›´é«˜ç‰ˆæœ¬ä¸æ”¯æŒã€‚ - -对于eTSè¯è¨€å¼€å‘,低代ç æ–¹å¼åœ¨DevEco Studio V3.0 Beta3åŠæ›´é«˜ç‰ˆæœ¬ä¸æ”¯æŒã€‚ - -OpenHarmony低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,éµå¾ªJSå¼€å‘规范,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 -更多UI框架的开å‘内容åŠæŒ‡å¯¼ï¼Œè¯·å‚è§[UIå¼€å‘](../ui/arkui-overview.md)。 +更多UI框架的开å‘内容åŠæŒ‡å¯¼ï¼Œè¯¦è§[UIå¼€å‘](../ui/arkui-overview.md)。 ### Ability Ability是应用所具备能力的抽象,也是应用程åºçš„é‡è¦ç»„æˆéƒ¨åˆ†ã€‚一个应用å¯ä»¥å…·å¤‡å¤šç§èƒ½åŠ›ï¼ˆå³å¯ä»¥åŒ…å«å¤šä¸ªAbility)。OpenHarmony支æŒåº”用以Ability为å•ä½è¿›è¡Œéƒ¨ç½²ã€‚ -Ability分为[FA(Feature Ability)](../../glossary.md#f)å’Œ[PA(Particle Ability)](../../glossary.md#p)两ç§ç±»åž‹ï¼Œæ¯ç§ç±»åž‹ä¸ºå¼€å‘者æ供了ä¸åŒçš„模æ¿ï¼Œä»¥ä¾¿å®žçŽ°ä¸åŒçš„业务功能。其ä¸ï¼ŒFA支æŒ[Page Ability](../ability/fa-pageability.md)模æ¿ï¼Œä»¥æ供与用户交互的能力。一个Page Abilityå¯ä»¥å«æœ‰ä¸€ä¸ªæˆ–多个页é¢ï¼ˆå³Page),Page Ability与Page的关系如下图所示: +Ability框架模型结构具有两ç§å½¢æ€ï¼š - +- **FA模型**:API 8åŠå…¶æ›´æ—©ç‰ˆæœ¬çš„应用程åºåªèƒ½ä½¿ç”¨FA模型进行开å‘。更多FA模型的内容详è§[FA模型综述](../ability/fa-brief.md)。 -快速入门æ供了一个å«æœ‰ä¸¤ä¸ªé¡µé¢çš„Page Ability实例。更多Abilityçš„å¼€å‘内容åŠæŒ‡å¯¼ï¼Œè¯·å‚è§[Abilityå¼€å‘](../ability/ability-brief.md)。 +- **Stage模型**:从API 9开始,Ability框架引入并支æŒä½¿ç”¨Stage模型进行开å‘。更多Stage模型的内容详è§[Stage模型综述](../ability/stage-brief.md)。 + +FA模型和Stage模型的工程目录结构å˜åœ¨å·®å¼‚,Stage模型åªæ”¯æŒä½¿ç”¨eTSè¯è¨€è¿›è¡Œå¼€å‘。 + +关于FA模型和Stage模型的整体架构和设计æ€æƒ³ç‰æ›´å¤šåŒºåˆ«ï¼Œè¯¦è§[Ability框架概述](../ability/ability-brief.md)。 + +快速入门æ供了一个å«æœ‰ä¸¤ä¸ªé¡µé¢çš„Abilityçš„å¼€å‘实例。更多Abilityçš„å¼€å‘内容åŠæŒ‡å¯¼ï¼Œè¯·è§[Abilityå¼€å‘](../ability/ability-brief.md)。 ## 工具准备 -1. 安装最新版[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)。 +1. 安装最新版[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)。 2. 请å‚考[é…ç½®OpenHarmony SDK](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-setting-up-environment-0000001263160443),完æˆ**DevEco Studio**的安装和开å‘环境é…置。 -完æˆä¸Šè¿°æ“作åŠåŸºæœ¬æ¦‚念的ç†è§£åŽï¼Œå¯å‚ç…§[使用eTSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](start-with-ets.md)ã€[使用eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](start-with-ets-low-code.md)ã€[使用JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](start-with-js.md)ã€[使用JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](start-with-js-low-code.md)ä¸çš„ä»»ä¸€ç« èŠ‚è¿›è¡Œä¸‹ä¸€æ¥ä½“验和å¦ä¹ 。 - +完æˆä¸Šè¿°æ“作åŠåŸºæœ¬æ¦‚念的ç†è§£åŽï¼Œå¯å‚ç…§[使用eTSè¯è¨€è¿›è¡Œå¼€å‘(Stage模型)](start-with-ets-stage.md)ã€[使用eTSè¯è¨€å¼€å‘(FA模型)](start-with-ets-fa.md)ã€[使用JSè¯è¨€å¼€å‘(FA模型)](../quick-start/start-with-js-fa.md)ä¸çš„ä»»ä¸€ç« èŠ‚è¿›è¡Œä¸‹ä¸€æ¥ä½“验和å¦ä¹ 。 diff --git a/zh-cn/application-dev/quick-start/start-with-ets-fa.md b/zh-cn/application-dev/quick-start/start-with-ets-fa.md new file mode 100644 index 0000000000000000000000000000000000000000..c8477362458afba74c5a66612f81adf89537dc48 --- /dev/null +++ b/zh-cn/application-dev/quick-start/start-with-ets-fa.md @@ -0,0 +1,284 @@ +# 使用eTSè¯è¨€å¼€å‘(FA模型) + + +> **说明:** +> 请使用**DevEco Studio V3.0.0.601 Beta1**åŠæ›´é«˜ç‰ˆæœ¬ã€‚ +> +> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.991 Beta4**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获å–下载链接。 + + +## 创建eTS工程 + +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已ç»æ‰“开了一个工程,请在èœå•æ 选择**File** > **New** > **Create Project**æ¥åˆ›å»ºä¸€ä¸ªæ–°å·¥ç¨‹ã€‚选择**OpenHarmony**模æ¿åº“,选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 +  + +2. 进入é…置工程界é¢ï¼Œ**Compile SDK** 选择“**8**â€ï¼ˆ**Complie SDK**选择“**9**â€æ—¶æ³¨æ„åŒæ¥é€‰æ‹©**Model** 为“**FA**â€ï¼Œæ¤å¤„以选择“**8**â€ä¸ºä¾‹ï¼‰ï¼Œ**Language**选择“**eTS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ +  + + > **说明:** + > DevEco Studio V3.0 Beta3åŠæ›´é«˜ç‰ˆæœ¬æ”¯æŒä½¿ç”¨eTS[低代ç å¼€å‘](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)æ–¹å¼ã€‚ + > + > 低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 + > + > 如需使用低代ç å¼€å‘æ–¹å¼ï¼Œè¯·æ‰“开上图ä¸çš„Enable Super Visual开关。 + +3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ + + +## eTS工程目录结构 + +- **entry**:OpenHarmony工程模å—,编译构建生æˆä¸€ä¸ª[HAP](../../glossary.md#hap)包。 + - **src > main > ets**:用于å˜æ”¾etsæºç 。 + - **src > main > ets > MainAbility**:应用/æœåŠ¡çš„å…¥å£ã€‚ + - **src > main > ets > MainAbility > pages**:MainAbility包å«çš„页é¢ã€‚ + - **src > main > ets > MainAbility > pages > index.ets**:pages列表ä¸çš„第一个页é¢ï¼Œå³åº”用的首页入å£ã€‚ + - **src > main > ets > MainAbility > app.ets**:承载Ability生命周期。 + - **src > main > resources**:用于å˜æ”¾åº”用/æœåŠ¡æ‰€ç”¨åˆ°çš„资æºæ–‡ä»¶ï¼Œå¦‚图形ã€å¤šåª’体ã€å—符串ã€å¸ƒå±€æ–‡ä»¶ç‰ã€‚关于资æºæ–‡ä»¶ï¼Œè¯¦è§[资æºæ–‡ä»¶çš„分类](../ui/ui-ts-basic-resource-file-categories.md)。 + - **src > main > config.json**:模å—é…置文件。主è¦åŒ…å«HAP包的é…置信æ¯ã€åº”用/æœåŠ¡åœ¨å…·ä½“设备上的é…置信æ¯ä»¥åŠåº”用/æœåŠ¡çš„全局é…置信æ¯ã€‚具体的é…置文件说明,详è§[应用包结构é…置文件的说明(FA模型)](package-structure.md)。 + - **build-profile.json5**:当å‰çš„模å—ä¿¡æ¯ ã€ç¼–译信æ¯é…置项,包括buildOptionã€targetsé…ç½®ç‰ã€‚ + - **hvigorfile.js**:模å—级编译构建任务脚本,开å‘者å¯ä»¥è‡ªå®šä¹‰ç›¸å…³ä»»åŠ¡å’Œä»£ç 实现。 + +- **build-profile.json5**:应用级é…置信æ¯ï¼ŒåŒ…括ç¾åã€äº§å“é…ç½®ç‰ã€‚ + +- **hvigorfile.js**:应用级编译构建任务脚本。 + + +## æž„å»ºç¬¬ä¸€ä¸ªé¡µé¢ + +1. 使用文本组件。 + 工程åŒæ¥å®ŒæˆåŽï¼Œåœ¨â€œ**Project**â€çª—å£ï¼Œç‚¹å‡»â€œ**entry > src > main > ets > MainAbility > pages**â€ï¼Œæ‰“开“**index.ets**â€æ–‡ä»¶ï¼Œå¯ä»¥çœ‹åˆ°é¡µé¢ç”±Text组件组æˆã€‚“**index.ets**â€æ–‡ä»¶çš„示例如下: + + + ```ts + // index.ets + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } + } + ``` + +2. æ·»åŠ æŒ‰é’®ã€‚ + 在默认页é¢åŸºç¡€ä¸Šï¼Œæˆ‘ä»¬æ·»åŠ ä¸€ä¸ªButton组件,作为按钮å“应用户点击,从而实现跳转到å¦ä¸€ä¸ªé¡µé¢ã€‚“**index.ets**â€æ–‡ä»¶çš„示例如下: + + + ```ts + // index.ets + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // æ·»åŠ æŒ‰é’®ï¼Œä»¥å“应用户点击 + Button() { + Text('Next') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') + } + .height('100%') + } + } + ``` + +3. 在编辑窗å£å³ä¸Šè§’的侧边工具æ ,点击Previewer,打开预览器。第一个页é¢æ•ˆæžœå¦‚下图所示: +  + + +## æž„å»ºç¬¬äºŒä¸ªé¡µé¢ + +1. 创建第二个页é¢ã€‚ + - 新建第二个页é¢æ–‡ä»¶ã€‚在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > ets > MainAbility**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > eTS File**â€ï¼Œå‘½å为“**second**â€ï¼Œç‚¹å‡»â€œ**Finish**â€ã€‚å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: + +  + + > **说明:** + > å¼€å‘者也å¯ä»¥åœ¨å³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹æ—¶ï¼Œé€‰æ‹©â€œ**New > Page**â€ï¼Œåˆ™æ— 需手动é…置相关页é¢è·¯ç”±ã€‚ + - é…置第二个页é¢çš„路由。在config.json文件ä¸çš„“module - js - pagesâ€ä¸‹é…置第二个页é¢çš„路由“pages/secondâ€ã€‚示例如下: + + ```json + { + "module": { + "js": [ + { + "pages": [ + "pages/index", + "pages/second" + ], + } + ] + } + } + ``` + +2. æ·»åŠ æ–‡æœ¬åŠæŒ‰é’®ã€‚ + å‚照第一个页é¢ï¼Œåœ¨ç¬¬äºŒä¸ªé¡µé¢æ·»åŠ Text组件ã€Button组件ç‰ï¼Œå¹¶è®¾ç½®å…¶æ ·å¼ã€‚“**second.ets**â€æ–‡ä»¶çš„示例如下: + + + ```ts + // second.ets + @Entry + @Component + struct Second { + @State message: string = 'Hi there' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + } + .width('100%') + } + .height('100%') + } + } + ``` + + +## 实现页é¢é—´çš„跳转 + +页é¢é—´çš„导航å¯ä»¥é€šè¿‡é¡µé¢è·¯ç”±routeræ¥å®žçŽ°ã€‚页é¢è·¯ç”±routeræ ¹æ®é¡µé¢urlæ‰¾åˆ°ç›®æ ‡é¡µé¢ï¼Œä»Žè€Œå®žçŽ°è·³è½¬ã€‚使用页é¢è·¯ç”±è¯·å¯¼å…¥router模å—。 + +1. 第一个页é¢è·³è½¬åˆ°ç¬¬äºŒä¸ªé¡µé¢ã€‚ + 在第一个页é¢ä¸ï¼Œè·³è½¬æŒ‰é’®ç»‘定onClick事件,点击按钮时跳转到第二页。“**index.ets**â€æ–‡ä»¶çš„示例如下: + + + ```ts + // index.ets + import router from '@ohos.router'; + + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // æ·»åŠ æŒ‰é’®ï¼Œä»¥å“应用户点击 + Button() { + Text('Next') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // 跳转按钮绑定onClick事件,点击时跳转到第二页 + .onClick(() => { + router.push({ url: 'pages/second' }) + }) + } + .width('100%') + } + .height('100%') + } + } + ``` + +2. 第二个页é¢è¿”回到第一个页é¢ã€‚ + 在第二个页é¢ä¸ï¼Œè¿”回按钮绑定onClick事件,点击按钮时返回到第一页。“**second.ets**â€æ–‡ä»¶çš„示例如下: + + + ```ts + // second.ets + import router from '@ohos.router'; + + @Entry + @Component + struct Second { + @State message: string = 'Hi there' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('Back') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // 返回按钮绑定onClick事件,点击按钮时返回到第一页 + .onClick(() => { + router.back() + }) + } + .width('100%') + } + .height('100%') + } + } + ``` + +3. 打开index.ets文件,点击预览器ä¸çš„按钮进行刷新。效果如下图所示: +  + + +## 使用真机è¿è¡Œåº”用 + +1. å°†æè½½OpenHarmonyæ ‡å‡†ç³»ç»Ÿçš„å¼€å‘æ¿ä¸Žç”µè„‘连接。 + +2. 点击**File**> **Project Structure...** > **Project**>**SigningConfigs** ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: +  + +3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: +  + +æ喜您已ç»ä½¿ç”¨eTSè¯è¨€å¼€å‘(FA模型)完æˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ diff --git a/zh-cn/application-dev/quick-start/start-with-ets-low-code.md b/zh-cn/application-dev/quick-start/start-with-ets-low-code.md deleted file mode 100644 index ac80b5edac057582e6cb6e3b189d088c0a2860d7..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start-with-ets-low-code.md +++ /dev/null @@ -1,203 +0,0 @@ -# 使用eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰ - - ->  **说明:** -> 该特性在**DevEco Studio V3.0 Beta3**åŠæ›´é«˜ç‰ˆæœ¬ä¸æ”¯æŒã€‚ -> -> ç›®å‰eTS低代ç å¼€å‘æ–¹å¼æ”¯æŒçš„组件较少,更多组件的支æŒå°†åœ¨åŽç»ç‰ˆæœ¬ä¸å®žçŽ°ã€‚ -> -> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获å–下载链接。 - - -OpenHarmony低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 - - -使用低代ç å¼€å‘应用或æœåŠ¡æœ‰ä»¥ä¸‹ä¸¤ç§å¼€å‘æ–¹å¼ï¼š - - -- 直接创建一个支æŒä½Žä»£ç å¼€å‘的新工程以进行开å‘。本文以æ¤æ–¹å¼ä¸ºä¾‹è¿›è¡Œè¯´æ˜Žã€‚ - -- 在已有工程ä¸ï¼Œåˆ›å»ºvisual文件æ¥è¿›è¡Œå¼€å‘。æ¤ç§æ–¹å¼çš„æ“作å¯å‚考[创建visual文件支æŒä½Žä»£ç å¼€å‘](#构建第二个页é¢)。 - - -## 创建新工程支æŒä½Žä»£ç å¼€å‘ - -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已有一个工程,请点击**File** > **New** > **Create Project**。选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 - -  - -2. 进入é…置工程界é¢ï¼Œæ‰“开“**Enable Super Visual**â€å¼€å…³ï¼Œ**UI Syntax**选择“**eTS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ - -  - -3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ - - -## 低代ç å¼€å‘工程项目文件 - -工程åŒæ¥å®ŒæˆåŽï¼Œè‡ªåŠ¨ç”Ÿæˆä»¥ä¸‹ç›®å½•ç»“构: - - - -- **entry > src > main > ets > MainAbility > pages > index.ets**:低代ç 页é¢çš„逻辑æ述文件,定义了页é¢é‡Œæ‰€ç”¨åˆ°çš„所有的逻辑关系,比如数æ®ã€äº‹ä»¶ç‰ï¼Œè¯¦æƒ…请å‚考[TSè¯æ³•ç³–](../ui/ts-syntactic-sugar.md)。如果创建了多个低代ç 页é¢ï¼Œåˆ™pages目录下会生æˆå¤šä¸ªé¡µé¢æ–‡ä»¶å¤¹åŠå¯¹åº”çš„ets文件。 - -- **entry > src > main > supervisual > MainAbility > pages > index.visual**:visual文件å˜å‚¨ä½Žä»£ç 页é¢çš„æ•°æ®æ¨¡åž‹ï¼ŒåŒå‡»è¯¥æ–‡ä»¶å³å¯æ‰“开低代ç 页é¢ï¼Œè¿›è¡Œå¯è§†åŒ–å¼€å‘设计。如果创建了多个低代ç 页é¢ï¼Œåˆ™pages目录下会生æˆå¤šä¸ªé¡µé¢æ–‡ä»¶å¤¹åŠå¯¹åº”çš„visual文件。 - - -## æž„å»ºç¬¬ä¸€ä¸ªé¡µé¢ - -工程åŒæ¥å®ŒæˆåŽï¼Œç¬¬ä¸€ä¸ªé¡µé¢å·²æœ‰ä¸€ä¸ªå®¹å™¨ã€ä¸€æ®µæ–‡æœ¬ï¼ˆHello World)显示。为了更详细地了解低代ç å¼€å‘ï¼Œæˆ‘ä»¬å°†åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件,从零开始完æˆé¡µé¢çš„æ·»åŠ ã€è®¾ç½®ã€‚ - -第一个页é¢å†…有一个容器ã€ä¸€æ®µæ–‡æœ¬å’Œä¸€ä¸ªæŒ‰é’®ï¼Œé€šè¿‡Columnã€Textå’ŒButton组件æ¥å®žçŽ°ã€‚å…¶ä¸ï¼ŒColumn为沿垂直方å‘布局的容器组件,具体使用请è§[Column](../reference/arkui-ts/ts-container-column.md)。 - -1. åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。<a name="delete_origin_content"></a> - 打开index.visual文件,选ä¸ç”»å¸ƒä¸çš„组件,å•å‡»é¼ æ ‡å³é”®ï¼Œé€‰æ‹©Deleteåˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。æ“作如下所示: - -  - -2. æ·»åŠ å®¹å™¨ï¼Œè®¾ç½®Columnå®¹å™¨çš„æ ·å¼å’Œå±žæ€§ã€‚<a name="add_container"></a> - 选ä¸UI Controlä¸çš„Column组件,将其拖至画布。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(General),设置Column组件的高度Height为100%,使其å 满å±å¹•ï¼›ç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(Feature),设置Column组件的AlignItemsæ ·å¼ä¸ºcenter,使得其å组件在水平轴上居ä¸æ˜¾ç¤ºã€‚æ“作如下所示: - -  - -3. æ·»åŠ æ–‡æœ¬ã€‚ - 选ä¸UI Controlä¸çš„Text组件,将其拖至画布,å†æ‹–至Column组件的ä¸å¤®åŒºåŸŸã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(Feature),设置Text组件的Content属性为“this.messageâ€ï¼ˆå³â€œHello Worldâ€ï¼‰ï¼›è®¾ç½®ç»„件的FontSizeæ ·å¼ä¸º30fp,使得其文å—放大;设置组件的TextAlignæ ·å¼ä¸ºcenter,使得组件文å—å±…ä¸æ˜¾ç¤ºã€‚å†é€‰ä¸ç”»å¸ƒä¸Šçš„Text组件,拖动放大。æ“作如下所示: - -  - -4. æ·»åŠ æŒ‰é’®ã€‚ - 选ä¸UI Controlä¸çš„Button组件,将其拖至画布,å†æ‹–至Text组件下é¢ã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(General),设置Button组件的Height为40vp;点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(Feature),设置Button组件的Label属性为“Nextâ€ï¼›è®¾ç½®Button组件的FontSizeæ ·å¼ä¸º25fp,使得其文å—放大。æ“作如下所示: - -  - -5. 在编辑窗å£å³ä¸Šè§’的侧边工具æ ,点击Previewer,打开预览器。第一个页é¢æ•ˆæžœå¦‚下图所示: - -  - - -## æž„å»ºç¬¬äºŒä¸ªé¡µé¢ - -1. 创建第二个页é¢ã€‚ - 在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > ets > MainAbility**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > Visual**â€ï¼Œå‘½å为“**second**â€ï¼Œå•å‡»â€œ**Finish**â€ï¼Œå³å®Œæˆç¬¬äºŒä¸ªé¡µé¢çš„创建。å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: - -  - -2. [åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。](#delete_origin_content) - -3. [æ·»åŠ å®¹å™¨ï¼Œè®¾ç½®Columnå®¹å™¨çš„æ ·å¼å’Œå±žæ€§ã€‚](#add_container) - -4. æ·»åŠ æ–‡æœ¬ã€‚ - - - 在second.ets文件ä¸ï¼Œå°†æœ¬é¡µé¢çš„message文本内容设置为“Hi thereâ€ï¼Œç¤ºä¾‹å¦‚下: - - ```ts - // second.ets - @Entry - @Component - struct Second { - @State message: string = 'Hi there' - - /** - * In low-code mode, do not add anything to the build function, as it will be - * overwritten by the content generated by the .visual file in the build phase. - */ - build() { - - } - } - ``` - - 选ä¸Text组件,将其拖至画布,å†æ‹–至Column组件的ä¸å¤®åŒºåŸŸã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(Feature),设置Text组件的Content属性为“this.messageâ€ï¼ˆå³â€œHi thereâ€ï¼‰ï¼›è®¾ç½®Text组件的FontSizeæ ·å¼ä¸º30fp;设置组件的TextAlignæ ·å¼ä¸ºcenter。å†é€‰ä¸ç”»å¸ƒä¸Šçš„Text组件,拖动放大。æ“作如下所示: - -  - -5. æ·»åŠ æŒ‰é’®ã€‚ - 选ä¸UI Controlä¸çš„Button组件,将其拖至画布,å†æ‹–至Text组件下é¢ã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(General),设置Button组件的Height为40vp;点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å›¾æ ‡(Feature),设置Button组件的Value属性为“Backâ€ï¼›è®¾ç½®ç»„件的FontSizeæ ·å¼ä¸º25fp,使得其文å—放大。æ“作如下所示: - -  - - -## 实现页é¢é—´çš„跳转 - -页é¢é—´çš„导航å¯ä»¥é€šè¿‡é¡µé¢è·¯ç”±routeræ¥å®žçŽ°ã€‚页é¢è·¯ç”±routeræ ¹æ®é¡µé¢urlæ‰¾åˆ°ç›®æ ‡é¡µé¢ï¼Œä»Žè€Œå®žçŽ°è·³è½¬ã€‚使用页é¢è·¯ç”±è¯·å¯¼å…¥router模å—。 - -1. 第一个页é¢è·³è½¬åˆ°ç¬¬äºŒä¸ªé¡µé¢ã€‚ - 在第一个页é¢ä¸ï¼Œè·³è½¬æŒ‰é’®ç»‘定onclick方法,点击按钮时跳转到第二页。需åŒæ—¶å¤„ç†ets文件åŠvisual文件。 - - “**index.ets**â€ç¤ºä¾‹å¦‚下: - - ```ts - // index.ets - import router from '@ohos.router'; - - @Entry - @Component - struct Index { - @State message: string = 'Hello World' - - /** - * In low-code mode, do not add anything to the build function, as it will be - * overwritten by the content generated by the .visual file in the build phase. - */ - onclick() { - router.push({ - url: 'pages/second', // 指定è¦è·³è½¬çš„é¡µé¢ - }) - } - - build() { - } - } - ``` - - - “**index.visual**â€ï¼š 打开index.visual,选ä¸ç”»å¸ƒä¸Šçš„Button组件。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„äº‹ä»¶å›¾æ ‡(Eventsï¼‰ï¼Œé¼ æ ‡ç‚¹å‡»OnClick事件的输入框,选择this.onclick,如下所示: - -  - -2. 第二个页é¢è¿”回到第一个页é¢ã€‚ - 在第二个页é¢ä¸ï¼Œè¿”回按钮绑定back方法,点击按钮时返回到第一页。需åŒæ—¶å¤„ç†ets文件åŠvisual文件。 - - - “**second.ets**â€ç¤ºä¾‹å¦‚下: - - ```ts - // second.ets - import router from '@ohos.router'; - - @Entry - @Component - struct Second { - @State message: string = 'Hi there' - - /** - * In low-code mode, do not add anything to the build function, as it will be - * overwritten by the content generated by the .visual file in the build phase. - */ - back() { - router.back() - } - - build() { - - } - } - ``` - - “**second.visual**â€ï¼š 打开second.visual,选ä¸ç”»å¸ƒä¸Šçš„Button组件。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„äº‹ä»¶å›¾æ ‡(Eventsï¼‰ï¼Œé¼ æ ‡ç‚¹å‡»OnClick事件的输入框,选择this.back,如下所示: - -  - -3. 打开index.visual或index.ets文件,点击预览器ä¸çš„  按钮进行刷新。效果如下图所示: - -  - - -## 使用真机è¿è¡Œåº”用 - -1. å°†æè½½OpenHarmonyæ ‡å‡†ç³»ç»Ÿçš„å¼€å‘æ¿ä¸Žç”µè„‘连接。 - -2. 点击**File** > **Project Structure** > **Project** > **Signing Configs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: - -  - -3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: - -  - -æ喜您已ç»ä½¿ç”¨eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰å®Œæˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ diff --git a/zh-cn/application-dev/quick-start/start-with-ets.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md similarity index 54% rename from zh-cn/application-dev/quick-start/start-with-ets.md rename to zh-cn/application-dev/quick-start/start-with-ets-stage.md index 7c921bc9145276d79ef4303aa951705c0e042d08..f8c2493e72073c120599477c6bd1d580fa7be23e 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -1,46 +1,57 @@ -# 使用eTSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰ +# 使用eTSè¯è¨€å¼€å‘(Stage模型) ->  **说明:** -> 请使用**DevEco Studio V3.0.0.601 Beta1**åŠæ›´é«˜ç‰ˆæœ¬ã€‚ + +> **说明:** +> 请使用**DevEco Studio V3.0.0.900 Beta3**åŠæ›´é«˜ç‰ˆæœ¬ã€‚ > -> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获å–下载链接。 +> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.991 Beta4**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获å–下载链接。 ## 创建eTS工程 -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已有一个工程,请点击**File** > **New** > **Create Project**。选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已ç»æ‰“开了一个工程,请在èœå•æ 选择**File** > **New** > **Create Project**æ¥åˆ›å»ºä¸€ä¸ªæ–°å·¥ç¨‹ã€‚选择**OpenHarmony**模æ¿åº“,选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 +  -  +2. 进入é…置工程界é¢ï¼Œ**Compile SDK**选择“**9**â€ï¼Œ**Model** 选择“**Stage**â€ï¼Œ**Language** 选择“**eTS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ +  -2. 进入é…置工程界é¢ï¼Œ**UI Syntax**选择“**eTS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ + > **说明:** + > + > 支æŒä½¿ç”¨eTS[低代ç å¼€å‘](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)æ–¹å¼ã€‚ + > + > 低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 + > + > 如需使用低代ç å¼€å‘æ–¹å¼ï¼Œè¯·æ‰“开上图ä¸çš„Enable Super Visual开关。 + +3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ -  -3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ +## eTS工程目录结构 + -## eTS工程项目文件 +- **AppScope > app.json5**:应用的全局é…置信æ¯ã€‚ -- **entry** :OpenHarmony工程模å—,编译构建生æˆä¸€ä¸ª[HAP](../../glossary.md#hap)包。 - - **src > main > ets** :用于å˜æ”¾etsæºç 。 - - **src > main > ets > MainAbility** :应用/æœåŠ¡çš„å…¥å£ã€‚ - - **src > main > ets > MainAbility > pages** :MainAbility包å«çš„页é¢ã€‚ - - **src > main > ets > MainAbility > pages > index.ets** :pages列表ä¸çš„第一个页é¢ï¼Œå³åº”用的首页入å£ã€‚ - - **src > main > ets > MainAbility > app.ets** :承载Ability生命周期。 - - **src > main > resources** :用于å˜æ”¾åº”用/æœåŠ¡æ‰€ç”¨åˆ°çš„资æºæ–‡ä»¶ï¼Œå¦‚图形ã€å¤šåª’体ã€å—符串ã€å¸ƒå±€æ–‡ä»¶ç‰ã€‚ - - **src > main > config.json** :模å—é…置文件。主è¦åŒ…å«HAP包的é…置信æ¯ã€åº”用/æœåŠ¡åœ¨å…·ä½“设备上的é…置信æ¯ä»¥åŠåº”用/æœåŠ¡çš„全局é…置信æ¯ã€‚具体的é…置文件说明,详è§[应用包结构é…置文件的说明](package-structure.md)。 - - **build-profile.json5** :当å‰çš„模å—ä¿¡æ¯ ã€ç¼–译信æ¯é…置项,包括buildOptionã€targetsé…ç½®ç‰ã€‚ - - **hvigorfile.js** :模å—级编译构建任务脚本,开å‘者å¯ä»¥è‡ªå®šä¹‰ç›¸å…³ä»»åŠ¡å’Œä»£ç 实现。 +- **entry**:OpenHarmony工程模å—,编译构建生æˆä¸€ä¸ª[HAP](../../glossary.md#hap)包。 + - **src > main > ets**:用于å˜æ”¾etsæºç 。 + - **src > main > ets > Application > AbilityStage.ts**:实现AbilityStage接å£ã€‚ + - **src > main > ets > MainAbility**:应用/æœåŠ¡çš„å…¥å£ã€‚ + - **src > main > ets > MainAbility > MainAbility.ts**:承载Ability生命周期。 + - **src > main > ets > pages**:MainAbility包å«çš„页é¢ã€‚ + - **src > main > resources**:用于å˜æ”¾åº”用/æœåŠ¡æ‰€ç”¨åˆ°çš„资æºæ–‡ä»¶ï¼Œå¦‚图形ã€å¤šåª’体ã€å—符串ã€å¸ƒå±€æ–‡ä»¶ç‰ã€‚关于资æºæ–‡ä»¶ï¼Œè¯¦è§[资æºæ–‡ä»¶çš„分类](../ui/ui-ts-basic-resource-file-categories.md)。 + - **src > main > module.json5**:模å—é…置文件。主è¦åŒ…å«HAP包的é…置信æ¯ã€åº”用/æœåŠ¡åœ¨å…·ä½“设备上的é…置信æ¯ä»¥åŠåº”用/æœåŠ¡çš„全局é…置信æ¯ã€‚具体的é…置文件说明,详è§[应用包结构é…置文件的说明(Stage模型)](stage-structure.md)。 + - **build-profile.json5**:当å‰çš„模å—ä¿¡æ¯ ã€ç¼–译信æ¯é…置项,包括buildOptionã€targetsé…ç½®ç‰ã€‚ + - **hvigorfile.js**:模å—级编译构建任务脚本,开å‘者å¯ä»¥è‡ªå®šä¹‰ç›¸å…³ä»»åŠ¡å’Œä»£ç 实现。 -- **build-profile.json5** :应用级é…置信æ¯ï¼ŒåŒ…括ç¾åã€äº§å“é…ç½®ç‰ã€‚ +- **build-profile.json5**:应用级é…置信æ¯ï¼ŒåŒ…括ç¾åã€äº§å“é…ç½®ç‰ã€‚ -- **hvigorfile.js** :应用级编译构建任务脚本。 +- **hvigorfile.js**:应用级编译构建任务脚本。 ## æž„å»ºç¬¬ä¸€ä¸ªé¡µé¢ 1. 使用文本组件。 -工程åŒæ¥å®ŒæˆåŽï¼Œåœ¨â€œ**Project**â€çª—å£ï¼Œç‚¹å‡»â€œ**entry > src > main > ets > MainAbility > pages**â€ï¼Œæ‰“开“**index.ets**â€æ–‡ä»¶ï¼Œå¯ä»¥çœ‹åˆ°é¡µé¢ç”±Text组件组æˆã€‚“**index.ets**â€æ–‡ä»¶çš„示例如下: + 工程åŒæ¥å®ŒæˆåŽï¼Œåœ¨â€œ**Project**â€çª—å£ï¼Œç‚¹å‡»â€œ**entry > src > main > ets > MainAbility > pages**â€ï¼Œæ‰“开“**index.ets**â€æ–‡ä»¶ï¼Œå¯ä»¥çœ‹åˆ°é¡µé¢ç”±Text组件组æˆã€‚“**index.ets**â€æ–‡ä»¶çš„示例如下: ```ts @@ -103,46 +114,33 @@ ``` 3. 在编辑窗å£å³ä¸Šè§’的侧边工具æ ,点击Previewer,打开预览器。第一个页é¢æ•ˆæžœå¦‚下图所示: - -  +  ## æž„å»ºç¬¬äºŒä¸ªé¡µé¢ 1. 创建第二个页é¢ã€‚ - - 新建第二个页é¢æ–‡ä»¶ã€‚在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > ets > MainAbility**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > eTS File**â€ï¼Œå‘½å为“**second**â€ï¼Œç‚¹å‡»â€œ**Finish**â€ã€‚å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: - -  + - 新建第二个页é¢æ–‡ä»¶ã€‚在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > ets**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > eTS File**â€ï¼Œå‘½å为“**second**â€ï¼Œç‚¹å‡»â€œ**Finish**â€ã€‚å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: - > 说明: - > - > å¼€å‘者也å¯ä»¥åœ¨å³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹æ—¶ï¼Œé€‰æ‹©â€œ**new > Page**â€ï¼Œåˆ™æ— 需手动é…置相关页é¢çš„路由。 +  - - é…置第二个页é¢çš„路由。在config.json文件ä¸çš„“module - js - pagesâ€ä¸‹é…置第二个页é¢çš„路由“pages/secondâ€ã€‚示例如下: - - ``` + > **说明:** + > å¼€å‘者也å¯ä»¥åœ¨å³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹æ—¶ï¼Œé€‰æ‹©â€œ**New > Page**â€ï¼Œåˆ™æ— 需手动é…置相关页é¢è·¯ç”±ã€‚ + - é…置第二个页é¢çš„路由。在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > resources > base > profile **â€ï¼Œåœ¨main_pages.json文件ä¸çš„“srcâ€ä¸‹é…置第二个页é¢çš„路由“pages/secondâ€ã€‚示例如下: + + ```json { - ... - "module": { - ... - "js": [ - { - ... - "pages": [ - "pages/index", - "pages/second" - ] - ... - } - ] - } + "src": [ + "pages/index", + "pages/second" + ] } - ``` + ``` 2. æ·»åŠ æ–‡æœ¬åŠæŒ‰é’®ã€‚ å‚照第一个页é¢ï¼Œåœ¨ç¬¬äºŒä¸ªé¡µé¢æ·»åŠ Text组件ã€Button组件ç‰ï¼Œå¹¶è®¾ç½®å…¶æ ·å¼ã€‚“**second.ets**â€æ–‡ä»¶çš„示例如下: - + ```ts // second.ets @Entry @@ -268,21 +266,18 @@ } ``` -3. 打开index.ets文件,点击预览器ä¸çš„  按钮进行刷新。 效果如下图所示: - -  +3. 打开index.ets文件,点击预览器ä¸çš„按钮进行刷新。效果如下图所示: +  ## 使用真机è¿è¡Œåº”用 1. å°†æè½½OpenHarmonyæ ‡å‡†ç³»ç»Ÿçš„å¼€å‘æ¿ä¸Žç”µè„‘连接。 -2. 点击**File** > **Project Structure** > **Project** > **SigningConfigs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: - -  - -3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: +2. 点击**File**> **Project Structure...** > **Project**>**SigningConfigs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: +  -  +3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: +  -æ喜您已ç»ä½¿ç”¨eTSè¯è¨€ï¼ˆä¼ 统代ç æ–¹å¼ï¼‰å¼€å‘完æˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ +æ喜您已ç»ä½¿ç”¨eTSè¯è¨€å¼€å‘(Stage模型)完æˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ diff --git a/zh-cn/application-dev/quick-start/start-with-js.md b/zh-cn/application-dev/quick-start/start-with-js-fa.md similarity index 57% rename from zh-cn/application-dev/quick-start/start-with-js.md rename to zh-cn/application-dev/quick-start/start-with-js-fa.md index 32ce2eb43af404acb80112678764d37cd3e79cb9..d735f4a0ed5d2805161164eeb23327019b0cc10c 100644 --- a/zh-cn/application-dev/quick-start/start-with-js.md +++ b/zh-cn/application-dev/quick-start/start-with-js-fa.md @@ -1,40 +1,45 @@ -# 使用JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰ +# 使用JSè¯è¨€å¼€å‘(FA模型) ->  **说明:** -> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获å–下载链接。 +> **说明:** +> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.991 Beta4**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获å–下载链接。 ## 创建JS工程 -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已有一个工程,请点击**File** > **New** > **Create Project**。选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已ç»æ‰“开了一个工程,请在èœå•æ 选择**File** > **New** > **Create Project**æ¥åˆ›å»ºä¸€ä¸ªæ–°å·¥ç¨‹ã€‚选择**OpenHarmony**模æ¿åº“,选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 +  -  +2. 进入é…置工程界é¢ï¼Œ**Compile SDK**选择“**8**â€ï¼ˆ**Complie SDK**选择“**9**â€æ—¶æ³¨æ„åŒæ¥é€‰æ‹© **Model** 为“**FA**â€ï¼Œæ¤å¤„以选择“**8**â€ä¸ºä¾‹ï¼‰ï¼Œ**Language**选择“**JS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ +  -2. 进入é…置工程界é¢ï¼Œ**UI Syntax**选择“**JS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ - -  + > **说明:** + > DevEco Studio V2.2 Beta1åŠæ›´é«˜ç‰ˆæœ¬æ”¯æŒä½¿ç”¨JS[低代ç å¼€å‘](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)æ–¹å¼ã€‚ + > + > 低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 + > + > 如需使用低代ç å¼€å‘æ–¹å¼ï¼Œè¯·æ‰“开上图ä¸çš„Enable Super Visual开关。 3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ -## JS工程项目文件 +## JS工程目录结构 - **entry**:OpenHarmony工程模å—,编译构建生æˆä¸€ä¸ª[HAP](../../glossary.md#hap)包。 - - **src > main > js** :用于å˜æ”¾jsæºç 。 - - **src > main > js > MainAbility** :应用/æœåŠ¡çš„å…¥å£ã€‚ - - **src > main > js > MainAbility > i18n** :用于é…ç½®ä¸åŒè¯è¨€åœºæ™¯èµ„æºå†…容,比如应用文本è¯æ¡ã€å›¾ç‰‡è·¯å¾„ç‰èµ„æºã€‚ - - **src > main > js > MainAbility > pages** :MainAbility包å«çš„页é¢ã€‚ - - **src > main > js > MainAbility > app.js** :承载Ability生命周期。 + - **src > main > js**:用于å˜æ”¾jsæºç 。 + - **src > main > js > MainAbility**:应用/æœåŠ¡çš„å…¥å£ã€‚ + - **src > main > js > MainAbility > i18n**:用于é…ç½®ä¸åŒè¯è¨€åœºæ™¯èµ„æºå†…容,比如应用文本è¯æ¡ã€å›¾ç‰‡è·¯å¾„ç‰èµ„æºã€‚ + - **src > main > js > MainAbility > pages**:MainAbility包å«çš„页é¢ã€‚ + - **src > main > js > MainAbility > app.js**:承载Ability生命周期。 - - **src > main > resources** :用于å˜æ”¾åº”用/æœåŠ¡æ‰€ç”¨åˆ°çš„资æºæ–‡ä»¶ï¼Œå¦‚图形ã€å¤šåª’体ã€å—符串ã€å¸ƒå±€æ–‡ä»¶ç‰ã€‚ - - **src > main > config.json** :模å—é…置文件。主è¦åŒ…å«HAP包的é…置信æ¯ã€åº”用/æœåŠ¡åœ¨å…·ä½“设备上的é…置信æ¯ä»¥åŠåº”用/æœåŠ¡çš„全局é…置信æ¯ã€‚具体的é…置文件说明,详è§[应用包结构é…置文件的说明](package-structure.md)。 - - **build-profile.json5** :当å‰çš„模å—ä¿¡æ¯ ã€ç¼–译信æ¯é…置项,包括buildOptionã€targetsé…ç½®ç‰ã€‚ - - **hvigorfile.js** :模å—级编译构建任务脚本,开å‘者å¯ä»¥è‡ªå®šä¹‰ç›¸å…³ä»»åŠ¡å’Œä»£ç 实现。 + - **src > main > resources**:用于å˜æ”¾åº”用/æœåŠ¡æ‰€ç”¨åˆ°çš„资æºæ–‡ä»¶ï¼Œå¦‚图形ã€å¤šåª’体ã€å—符串ã€å¸ƒå±€æ–‡ä»¶ç‰ã€‚关于资æºæ–‡ä»¶ï¼Œè¯¦è§[资æºé™å®šä¸Žè®¿é—®](../ui/js-framework-resource-restriction.md)。 + - **src > main > config.json**:模å—é…置文件。主è¦åŒ…å«HAP包的é…置信æ¯ã€åº”用/æœåŠ¡åœ¨å…·ä½“设备上的é…置信æ¯ä»¥åŠåº”用/æœåŠ¡çš„全局é…置信æ¯ã€‚具体的é…置文件说明,详è§[应用包结构é…置文件的说明(FA模型)](package-structure.md)。 + - **build-profile.json5**:当å‰çš„模å—ä¿¡æ¯ ã€ç¼–译信æ¯é…置项,包括buildOptionã€targetsé…ç½®ç‰ã€‚ + - **hvigorfile.js**:模å—级编译构建任务脚本,开å‘者å¯ä»¥è‡ªå®šä¹‰ç›¸å…³ä»»åŠ¡å’Œä»£ç 实现。 -- **build-profile.json5** :应用级é…置信æ¯ï¼ŒåŒ…括ç¾åã€äº§å“é…ç½®ç‰ã€‚ +- **build-profile.json5**:应用级é…置信æ¯ï¼ŒåŒ…括ç¾åã€äº§å“é…ç½®ç‰ã€‚ -- **hvigorfile.js** :应用级编译构建任务脚本。 +- **hvigorfile.js**:应用级编译构建任务脚本。 ## æž„å»ºç¬¬ä¸€ä¸ªé¡µé¢ @@ -44,7 +49,7 @@ ```html - <!--index.hml--> + <!-- index.hml --> <div class="container"> <text class="title"> Hello World @@ -57,7 +62,7 @@ ```html - <!--index.hml--> + <!-- index.hml --> <div class="container"> <text class="title"> Hello World @@ -73,6 +78,7 @@ ```css + /* index.css */ .container { display: flex; flex-direction: column; @@ -103,9 +109,7 @@ ``` 4. 在编辑窗å£å³ä¸Šè§’的侧边工具æ ,点击Previewer,打开预览器。第一个页é¢æ•ˆæžœå¦‚下图所示: - - -  +  ## æž„å»ºç¬¬äºŒä¸ªé¡µé¢ @@ -113,14 +117,14 @@ 1. 创建第二个页é¢ã€‚ 在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > js > MainAbility**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > Page**â€ï¼Œå‘½å为“**second**â€ï¼Œç‚¹å‡»â€œ**Finish**â€ï¼Œå³å®Œæˆç¬¬äºŒä¸ªé¡µé¢çš„创建。å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: -  +  2. æ·»åŠ æ–‡æœ¬åŠæŒ‰é’®ã€‚ å‚照第一个页é¢ï¼Œåœ¨ç¬¬äºŒä¸ªé¡µé¢æ·»åŠ 文本ã€æŒ‰é’®åŠç‚¹å‡»æŒ‰é’®ç»‘定页é¢è¿”回ç‰ã€‚“**second.hml**â€æ–‡ä»¶çš„示例如下: ```html - <!--second.hml--> + <!-- second.hml --> <div class="container"> <text class="title"> Hi there @@ -131,9 +135,10 @@ </div> ``` -3. 设置页é¢æ ·å¼ã€‚“**second.css**â€æ–‡ä»¶çš„示例如下: +3. **设置页é¢æ ·å¼ã€‚**“**second.css**â€æ–‡ä»¶çš„示例如下: ```css + /* second.css */ .container { display: flex; flex-direction: column; @@ -200,24 +205,18 @@ } ``` -3. 打开index文件夹下的任æ„一个文件,点击预览器ä¸çš„  按钮进行刷新。效果如下图所示: - -  +3. 打开index文件夹下的任æ„一个文件,点击预览器ä¸çš„按钮进行刷新。效果如下图所示: +  ## 使用真机è¿è¡Œåº”用 1. å°†æè½½OpenHarmonyæ ‡å‡†ç³»ç»Ÿçš„å¼€å‘æ¿ä¸Žç”µè„‘连接。 -2. 点击**File** > **Project Structure** > **Project** > **Signing Configs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: - -  - -3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: +2. 点击**File**> **Project Structure...** > **Project**>**Signing Configs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: +  -  +3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: +  -æ喜您已ç»ä½¿ç”¨JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰å®Œæˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ -## 相关实例 -针对使用JSè¯è¨€ï¼ˆä¼ 统代ç æ–¹å¼ï¼‰å¼€å‘快速入门,有以下相关实例å¯ä¾›å‚考: -- [`JsHelloWorld`ï¼šä½ å¥½ä¸–ç•Œï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/JsHelloWorld) +æ喜您已ç»ä½¿ç”¨JSè¯è¨€å¼€å‘(FA模型)完æˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ diff --git a/zh-cn/application-dev/quick-start/start-with-js-low-code.md b/zh-cn/application-dev/quick-start/start-with-js-low-code.md deleted file mode 100644 index bdd4bfad89140eacc919502e19bd0993885a3dff..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start-with-js-low-code.md +++ /dev/null @@ -1,170 +0,0 @@ -# 使用JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰ - - ->  **说明:** -> 该特性在**DevEco Studio V2.2 Beta1**åŠæ›´é«˜ç‰ˆæœ¬ä¸æ”¯æŒã€‚ -> -> 为确ä¿è¿è¡Œæ•ˆæžœï¼Œæœ¬æ–‡ä»¥ä½¿ç”¨**DevEco Studio V3.0.0.900 Beta3**版本为例,点击[æ¤å¤„](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony)获å–下载链接。 - - -OpenHarmony低代ç å¼€å‘æ–¹å¼å…·æœ‰ä¸°å¯Œçš„UIç•Œé¢ç¼–辑功能,通过å¯è§†åŒ–ç•Œé¢å¼€å‘æ–¹å¼å¿«é€Ÿæž„建布局,å¯æœ‰æ•ˆé™ä½Žå¼€å‘者的上手æˆæœ¬å¹¶æå‡å¼€å‘者构建UIç•Œé¢çš„效率。 - - -使用低代ç å¼€å‘应用或æœåŠ¡æœ‰ä»¥ä¸‹ä¸¤ç§å¼€å‘æ–¹å¼ï¼š - - -- 直接创建一个支æŒä½Žä»£ç å¼€å‘的新工程以进行开å‘。本文以æ¤æ–¹å¼ä¸ºä¾‹è¿›è¡Œè¯´æ˜Žã€‚ - -- 在已有工程ä¸ï¼Œåˆ›å»ºvisual文件æ¥è¿›è¡Œå¼€å‘。æ¤ç§æ–¹å¼çš„æ“作å¯å‚考[创建visual文件支æŒä½Žä»£ç å¼€å‘](#构建第二个页é¢)。 - - -## 创建新工程支æŒä½Žä»£ç å¼€å‘ - ->  **说明:** -> 该功能在DevEco Studio 3.0 Beta2åŠæ›´é«˜ç‰ˆæœ¬ä¸æ”¯æŒï¼Œä¸”compileSdkVersion必须为7或以上。 - -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已有一个工程,请点击**File** > **New** > **Create Project**。选择模æ¿â€œ**Empty Ability**â€ï¼Œç‚¹å‡»**Next**进行下一æ¥é…置。 - -  - -2. 进入é…置工程界é¢ï¼Œæ‰“开“**Enable Super Visual**â€å¼€å…³ï¼Œ**UI Syntax**选择“**JS**â€ï¼Œå…¶ä»–å‚æ•°ä¿æŒé»˜è®¤è®¾ç½®å³å¯ã€‚ - -  - -3. 点击**Finish**,工具会自动生æˆç¤ºä¾‹ä»£ç 和相关资æºï¼Œç‰å¾…工程创建完æˆã€‚ - - -## 低代ç å¼€å‘工程项目文件 - -工程åŒæ¥å®ŒæˆåŽï¼Œè‡ªåŠ¨ç”Ÿæˆä»¥ä¸‹ç›®å½•ç»“构: - - - -- **entry > src > main > js > MainAbility > pages > index > index.js** :低代ç 页é¢çš„逻辑æ述文件,定义了页é¢é‡Œæ‰€ç”¨åˆ°çš„所有的逻辑关系,比如数æ®ã€äº‹ä»¶ç‰ï¼Œè¯¦æƒ…请å‚考[JSè¯æ³•å‚考](../ui/js-framework-syntax-js.md)。如果创建了多个低代ç 页é¢ï¼Œåˆ™pages目录下会生æˆå¤šä¸ªé¡µé¢æ–‡ä»¶å¤¹åŠå¯¹åº”çš„js文件。 - - >  **说明:** - > 使用低代ç 页é¢å¼€å‘时,其关è”js文件的åŒçº§ç›®å½•ä¸ä¸èƒ½åŒ…å«hmlå’Œcss页é¢ï¼Œä¾‹å¦‚上图ä¸çš„ **js > MainAbility > pages > index** 目录下ä¸èƒ½åŒ…å«hml与css文件,å¦åˆ™ä¼šå‡ºçŽ°ç¼–译报错。 - -- **entry > src > main > supervisual > MainAbility > pages > index > index.visual** :visual文件å˜å‚¨ä½Žä»£ç 页é¢çš„æ•°æ®æ¨¡åž‹ï¼ŒåŒå‡»è¯¥æ–‡ä»¶å³å¯æ‰“开低代ç 页é¢ï¼Œè¿›è¡Œå¯è§†åŒ–å¼€å‘设计。如果创建了多个低代ç 页é¢ï¼Œåˆ™pages目录下会生æˆå¤šä¸ªé¡µé¢æ–‡ä»¶å¤¹åŠå¯¹åº”çš„visual文件。 - - -## æž„å»ºç¬¬ä¸€ä¸ªé¡µé¢ - -工程åŒæ¥å®ŒæˆåŽï¼Œç¬¬ä¸€ä¸ªé¡µé¢å·²æœ‰ä¸€ä¸ªå®¹å™¨ã€ä¸€æ®µæ–‡æœ¬ï¼ˆHello World)显示。为了更详细地了解低代ç å¼€å‘ï¼Œæˆ‘ä»¬å°†åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件,从零开始完æˆé¡µé¢çš„æ·»åŠ ã€è®¾ç½®ã€‚ - -第一个页é¢å†…有一个容器ã€ä¸€æ®µæ–‡æœ¬å’Œä¸€ä¸ªæŒ‰é’®ï¼Œé€šè¿‡Divã€Textå’ŒButton组件æ¥å®žçŽ°ã€‚ - -1. åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。<a name= delete_origin_content></a> - 打开index.visual文件,选ä¸ç”»å¸ƒä¸çš„组件,å•å‡»é¼ æ ‡å³é”®ï¼Œé€‰æ‹©Deleteåˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。æ“作如下所示: - -  - -2. æ·»åŠ å®¹å™¨ï¼Œè®¾ç½®Divå®¹å™¨çš„æ ·å¼å’Œå±žæ€§ã€‚<a name = add_container></a> - 选ä¸UI Controlä¸çš„Div组件,将其拖至画布。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(General),设置Div组件的高度Height为100%,使其å 满å±å¹•ï¼›ç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(Flex),设置Div组件的FlexDirectionæ ·å¼ä¸ºcolumn,使Div的主轴垂直;设置Div组件的JustifyContentæ ·å¼ä¸ºcenter,使得其å组件在主轴上居ä¸æ˜¾ç¤ºï¼›è®¾ç½®Div组件的AlignItemsæ ·å¼ä¸ºcenter,使得其å组件在交å‰è½´ä¸Šå±…ä¸æ˜¾ç¤ºã€‚æ“作如下所示: - -  - -3. æ·»åŠ æ–‡æœ¬ã€‚ - 选ä¸UI Controlä¸çš„Text组件,将其拖至Div组件的ä¸å¤®åŒºåŸŸã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å±žæ€§å›¾æ ‡(Properties),设置Text组件的Content属性为“Hello Worldâ€ï¼›ç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(Feature),设置组件的FontSizeæ ·å¼ä¸º60px,使得其文å—放大;设置组件的TextAlignæ ·å¼ä¸ºcenter,使得组件文å—å±…ä¸æ˜¾ç¤ºã€‚å†é€‰ä¸ç”»å¸ƒä¸Šçš„Text组件,拖动放大。æ“作如下所示: - -  - -4. æ·»åŠ æŒ‰é’®ã€‚ - 选ä¸UI Controlä¸çš„Button组件,将其拖至Text组件下é¢ã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å±žæ€§å›¾æ ‡(Properties),设置Button组件的Value属性为“Nextâ€ï¼Œç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(Feature),设置组件的FontSizeæ ·å¼ä¸º40px,使得其文å—放大;å†é€‰ä¸ç”»å¸ƒä¸Šçš„Button组件,拖动放大。æ“作如下所示: - -  - -5. 在编辑窗å£å³ä¸Šè§’的侧边工具æ ,点击Previewer,打开预览器。第一个页é¢æ•ˆæžœå¦‚下图所示: - -  - - -## æž„å»ºç¬¬äºŒä¸ªé¡µé¢ - -1. 创建第二个页é¢ã€‚ - 在“**Project**â€çª—å£ï¼Œæ‰“开“**entry > src > main > js > MainAbility**â€ï¼Œå³é”®ç‚¹å‡»â€œ**pages**â€æ–‡ä»¶å¤¹ï¼Œé€‰æ‹©â€œ**New > Visual**â€ï¼Œå‘½å为“**second**â€ï¼Œå•å‡»â€œ**Finish**â€ï¼Œå³å®Œæˆç¬¬äºŒä¸ªé¡µé¢çš„创建。 - 新建visual文件的æ“作如下: - - <img src="figures/zh-cn_image_202206250937.png" alt="create-newVisual" style="zoom: 67%;" /> - - å¯ä»¥çœ‹åˆ°æ–‡ä»¶ç›®å½•ç»“构如下: - -  - -2. [åˆ é™¤ç”»å¸ƒåŽŸæœ‰æ¨¡æ¿ç»„件。](#delete_origin_content) - -3. [æ·»åŠ å®¹å™¨ï¼Œè®¾ç½®Divå®¹å™¨çš„æ ·å¼å’Œå±žæ€§ã€‚](#add_container) - -4. æ·»åŠ æ–‡æœ¬ã€‚ - 选ä¸Text组件,拖至Div组件的ä¸å¤®åŒºåŸŸã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å±žæ€§å›¾æ ‡(Properties),设置Text组件的Content属性为“Hi thereâ€ï¼›ç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(Feature),设置组件的FontSizeæ ·å¼ä¸º60px;设置组件的TextAlignæ ·å¼ä¸ºcenter。å†é€‰ä¸ç”»å¸ƒä¸Šçš„Text组件,拖动放大。æ“作如下所示: - -  - -5. æ·»åŠ æŒ‰é’®ã€‚ - 选ä¸UI Controlä¸çš„Button组件,将其拖至Text组件下é¢ã€‚点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„å±žæ€§å›¾æ ‡(Properties),设置Button组件的Value属性为“Backâ€ï¼Œç‚¹å‡»å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„æ ·å¼å›¾æ ‡(Feature),设置组件的FontSizeæ ·å¼ä¸º40px,使得其文å—放大;å†é€‰ä¸ç”»å¸ƒä¸Šçš„Button组件,拖动放大。æ“作如下所示: - -  - - -## 实现页é¢é—´çš„跳转 - -页é¢é—´çš„导航å¯ä»¥é€šè¿‡[页é¢è·¯ç”±router](../ui/ui-js-building-ui-routes.md)æ¥å®žçŽ°ã€‚页é¢è·¯ç”±routeræ ¹æ®é¡µé¢urlæ‰¾åˆ°ç›®æ ‡é¡µé¢ï¼Œä»Žè€Œå®žçŽ°è·³è½¬ã€‚使用页é¢è·¯ç”±è¯·å¯¼å…¥router模å—。 - -1. 第一个页é¢è·³è½¬åˆ°ç¬¬äºŒä¸ªé¡µé¢ã€‚ - 在第一个页é¢ä¸ï¼Œè·³è½¬æŒ‰é’®ç»‘定onclick方法,点击按钮时跳转到第二页。需åŒæ—¶å¤„ç†js文件åŠvisual文件。 - - “**index.js**â€ç¤ºä¾‹å¦‚下: - - ```js - import router from '@ohos.router'; - - export default { - onclick() { - router.push({ - url:'pages/second/second', // 指定è¦è·³è½¬çš„é¡µé¢ - }) - } - } - ``` - - - “**index.visual**â€ï¼š 打开index.visual,选ä¸ç”»å¸ƒä¸Šçš„Button组件。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„äº‹ä»¶å›¾æ ‡(Eventsï¼‰ï¼Œé¼ æ ‡ç‚¹å‡»Click事件的输入框,选择onclick,如下所示: - -  - -2. 第二个页é¢è¿”回到第一个页é¢ã€‚ - 在第二个页é¢ä¸ï¼Œè¿”回按钮绑定back方法,点击按钮时返回到第一页。 - - 需åŒæ—¶å¤„ç†js文件åŠvisual文件。 - - - “**second.js**â€ç¤ºä¾‹å¦‚下: - - ```js - import router from '@ohos.router'; - - export default { - back() { - router.back() - } - } - ``` - - “**second.visual**â€ï¼š 打开second.visual,选ä¸ç”»å¸ƒä¸Šçš„Button组件。点击å³ä¾§å±žæ€§æ ·å¼æ ä¸çš„äº‹ä»¶å›¾æ ‡(Eventsï¼‰ï¼Œé¼ æ ‡ç‚¹å‡»Click事件的输入框,选择back,如下所示: - -  - -3. 打开index.visual或index.js文件,点击预览器ä¸çš„  按钮进行刷新。效果如下图所示: - -  - - -## 使用真机è¿è¡Œåº”用 - -1. å°†æè½½OpenHarmonyæ ‡å‡†ç³»ç»Ÿçš„å¼€å‘æ¿ä¸Žç”µè„‘连接。 - -2. 点击**File** > **Project Structure** > **Project** > **Signing Configs**ç•Œé¢å‹¾é€‰â€œ**Automatically generate signing**â€ï¼Œç‰å¾…自动ç¾å完æˆå³å¯ï¼Œç‚¹å‡»â€œ**OK**â€ã€‚如下图所示: - -  - -3. 在编辑窗å£å³ä¸Šè§’的工具æ ,点击按钮è¿è¡Œã€‚效果如下图所示: - -  - -æ喜您已ç»ä½¿ç”¨JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰å®Œæˆäº†ç¬¬ä¸€ä¸ªOpenHarmony应用,快æ¥[探索更多的OpenHarmony功能](../application-dev-guide.md)å§ã€‚ diff --git a/zh-cn/application-dev/reference/Readme-CN.md b/zh-cn/application-dev/reference/Readme-CN.md index 55918480abbc69f4a8ffa9f23b9f3e41af207321..fb4b5ce23d9743a121f179a5ab6470713323e2c9 100644 --- a/zh-cn/application-dev/reference/Readme-CN.md +++ b/zh-cn/application-dev/reference/Readme-CN.md @@ -1,10 +1,9 @@ # å¼€å‘å‚考 -- [基于JS扩展的类Webå¼€å‘范å¼](arkui-js/Readme-CN.md) -- [基于TS扩展的声明å¼å¼€å‘范å¼](arkui-ts/Readme-CN.md) +- [组件å‚考(基于TS扩展的声明å¼å¼€å‘范å¼ï¼‰](arkui-ts/Readme-CN.md) +- [组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰](arkui-js/Readme-CN.md) - [接å£å‚考(JSåŠTS API)](apis/Readme-CN.md) - 接å£å‚考(Native API) - - [OpenHarmony Native API](./native-apis/Readme-CN.md) - - [Native APIæ ‡å‡†åº“](native-lib/third_party_libc/musl.md) - - [Node_API](native-lib/third_party_napi/napi.md) + - [OpenHarmony Native API](native-apis/Readme-CN.md) + - [Native APIæ ‡å‡†åº“](native-lib/Readme-CN.md) diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 9048aec6ed20ef8faef94dd42c35c8b766aefbfa..c5624597587250de137733ebd6d8ffb36bbccb48 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,56 +1,65 @@ -# æŽ¥å£ +# æŽ¥å£ - [å¼€å‘说明](development-intro.md) - Ability框架 - - [@ohos.ability.dataUriUtils (DataUriUtils模å—)](js-apis-DataUriUtils.md) - - [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md) - - [@ohos.ability.wantConstant (wantConstant)](js-apis-ability-wantConstant.md) - - [@ohos.application.Ability (Ability)](js-apis-application-ability.md) - - [@ohos.application.AbilityConstant (AbilityConstant)](js-apis-application-abilityConstant.md) - - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](js-apis-abilityDelegatorRegistry.md) - - [@ohos.application.AbilityStage (AbilityStage)](js-apis-application-abilitystage.md) - - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md) - - [@ohos.application.appManager (appManager)](js-apis-appmanager.md) - - [@ohos.application.Configuration (Configuration)](js-apis-configuration.md) - - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-configurationconstant.md) - - [@ohos.application.DataShareExtensionAbility (æ•°æ®å…±äº«æ‰©å±•èƒ½åŠ›)](js-apis-application-DataShareExtensionAbility.md) - - [@ohos.ability.featureAbility (FeatureAbility模å—)](js-apis-featureAbility.md) - - [@ohos.application.formBindingData (å¡ç‰‡æ•°æ®ç»‘定类)](js-apis-formbindingdata.md) - - [@ohos.application.FormExtension (FormExtension)](js-apis-formextension.md) - - [@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.missionManager (missionManager)](js-apis-missionManager.md) - - [@ohos.application.formProvider (FormProvider)](js-apis-formprovider.md) - - [@ohos.ability.particleAbility (particleAbility模å—)](js-apis-particleAbility.md) - - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-service-extension-ability.md) - - [@ohos.application.StartOptions (StartOptions)](js-apis-application-StartOptions.md) - - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md) - - [@ohos.application.uriPermissionManager (uriPermissionManager)](js-apis-uripermissionmanager.md) - - [@ohos.application.Want (Want)](js-apis-application-Want.md) - - [@ohos.application.WindowExtensionAbility (窗å£æ‰©å±•èƒ½åŠ›)](js-apis-application-WindowExtensionAbility.md) - - [@ohos.wantAgent (WantAgent模å—)](js-apis-wantAgent.md) - - ability/[dataAbilityHelper (DataAbilityHelper模å—)](js-apis-dataAbilityHelper.md) - - app/[context (Context模å—)](js-apis-Context.md) - - application/[AbilityContext (AbilityContext)](js-apis-ability-context.md) - - application/[ApplicationContext (ApplicationContext)](js-apis-application-applicationContext.md) - - application/[abilityDelegator (AbilityDelegator)](js-apis-application-abilityDelegator.md) - - application/[abilityDelegatorArgs (AbilityDelegatorArgs)](js-apis-application-abilityDelegatorArgs.md) - - application/[abilityMonitor (AbilityMonitor)](js-apis-application-abilityMonitor.md) - - application/[AbilityRunningInfo (AbilityRunningInfo)](js-apis-abilityrunninginfo.md) - - application/[AbilityStageContext (AbilityStageContext)](js-apis-abilitystagecontext.md) - - application/[Context (Context)](js-apis-application-context.md) - - application/[ExtensionContext (ExtensionContext)](js-apis-extension-context.md) - - application/[ExtensionRunningInfo (ExtensionRunningInfo)](js-apis-extensionrunninginfo.md) - - application/[FormExtensionContext (FormExtensionContext)](js-apis-formextensioncontext.md) - - application/[MissionSnapshot (MissionSnapshot)](js-apis-application-MissionSnapshot.md) - - application/[PermissionRequestResult (PermissionRequestResult)](js-apis-permissionrequestresult.md) - - application/[ProcessRunningInfo (ProcessRunningInfo)](js-apis-processrunninginfo.md) - - application/[ServiceExtensionContext (ServiceExtensionContext)](js-apis-service-extension-context.md) - - application/[shellCmdResult (ShellCmdResult)](js-apis-application-shellCmdResult.md) - - application/[MissionInfo (MissionInfo)](js-apis-application-missionInfo.md) + - FA模型 + - [@ohos.ability.featureAbility (FeatureAbility模å—)](js-apis-featureAbility.md) + - [@ohos.ability.particleAbility (particleAbility模å—)](js-apis-particleAbility.md) + - ability/[dataAbilityHelper (DataAbilityHelper模å—)](js-apis-dataAbilityHelper.md) + - app/[context (Context模å—)](js-apis-Context.md) + - Stage模型 + - [@ohos.application.Ability (Ability)](js-apis-application-ability.md) + - [@ohos.application.AbilityConstant (AbilityConstant)](js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage (AbilityStage)](js-apis-application-abilitystage.md) + - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md) + - [@ohos.application.DataShareExtensionAbility (æ•°æ®å…±äº«æ‰©å±•èƒ½åŠ›)](js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.FormExtension (FormExtension)](js-apis-formextension.md) + - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-service-extension-ability.md) + - [@ohos.application.StartOptions (StartOptions)](js-apis-application-StartOptions.md) + - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md) + - [@ohos.application.WindowExtensionAbility (窗å£æ‰©å±•èƒ½åŠ›)](js-apis-application-WindowExtensionAbility.md) + - application/[AbilityContext (AbilityContext)](js-apis-ability-context.md) + - application/[ApplicationContext (ApplicationContext)](js-apis-application-applicationContext.md) + - application/[AbilityStageContext (AbilityStageContext)](js-apis-abilitystagecontext.md) + - application/[Context (Context)](js-apis-application-context.md) + - application/[ExtensionContext (ExtensionContext)](js-apis-extension-context.md) + - application/[FormExtensionContext (FormExtensionContext)](js-apis-formextensioncontext.md) + - application/[PermissionRequestResult (PermissionRequestResult)](js-apis-permissionrequestresult.md) + - application/[ServiceExtensionContext (ServiceExtensionContext)](js-apis-service-extension-context.md) + - 通用 + - [@ohos.ability.dataUriUtils (DataUriUtils模å—)](js-apis-DataUriUtils.md) + - [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md) + - [@ohos.ability.wantConstant (wantConstant)](js-apis-ability-wantConstant.md) + - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](js-apis-abilityDelegatorRegistry.md) + - [@ohos.application.abilityManager (AbilityManager)](js-apis-application-abilityManager.md) + - [@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionContext)](js-apis-accessibility-extension-context.md) + - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](js-apis-application-AccessibilityExtensionAbility.md) + - [@ohos.application.appManager (appManager)](js-apis-appmanager.md) + - [@ohos.application.Configuration (Configuration)](js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-configurationconstant.md) + - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-EnvironmentCallback.md) + - [@ohos.application.errorManager (ErrorManager)](js-apis-errorManager.md) + - [@ohos.application.formBindingData (å¡ç‰‡æ•°æ®ç»‘定类)](js-apis-formbindingdata.md) + - [@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.formProvider (FormProvider)](js-apis-formprovider.md) + - [@ohos.application.missionManager (missionManager)](js-apis-missionManager.md) + - [@ohos.application.Want (Want)](js-apis-application-Want.md) + - [@ohos.continuation.continuationManager (ContinuationExtraParams)](js-apis-continuation-continuationExtraParams.md) + - [@ohos.continuation.continuationManager (continuationManager)](js-apis-continuation-continuationManager.md) + - [@ohos.wantAgent (WantAgent模å—)](js-apis-wantAgent.md) + - application/[abilityDelegator (AbilityDelegator)](js-apis-application-abilityDelegator.md) + - application/[abilityDelegatorArgs (AbilityDelegatorArgs)](js-apis-application-abilityDelegatorArgs.md) + - application/[abilityMonitor (AbilityMonitor)](js-apis-application-abilityMonitor.md) + - application/[AbilityRunningInfo (AbilityRunningInfo)](js-apis-abilityrunninginfo.md) + - application/[ExtensionRunningInfo (ExtensionRunningInfo)](js-apis-extensionrunninginfo.md) + - application/[MissionSnapshot (MissionSnapshot)](js-apis-application-MissionSnapshot.md) + - application/[ProcessRunningInfo (ProcessRunningInfo)](js-apis-processrunninginfo.md) + - application/[shellCmdResult (ShellCmdResult)](js-apis-application-shellCmdResult.md) + - continuation/[ContinuationResult (ContinuationResult)](js-apis-continuation-continuationResult.md) - 公共事件与通知 - [@ohos.commonEvent (公共事件模å—)](js-apis-commonEvent.md) @@ -62,16 +71,25 @@ - [@ohos.bundle (Bundle模å—)](js-apis-Bundle.md) - [@ohos.bundle.defaultAppManager (Bundle模å—)](js-apis-bundle-defaultAppManager.md) + - [@ohos.bundle.innerBundleManager (innerBundleManager模å—(JS端SDK接å£))](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundleState (设备使用信æ¯ç»Ÿè®¡)](js-apis-deviceUsageStatistics.md) + - [@ohos.distributedBundle (distributedBundle模å—(JS端SDK接å£))](js-apis-Bundle-distributedBundle.md) - [@ohos.zlib (Zip模å—)](js-apis-zlib.md) - bundle/[AbilityInfo (AbilityInfo)](js-apis-bundle-AbilityInfo.md) - bundle/[ApplicationInfo (ApplicationInfo)](js-apis-bundle-ApplicationInfo.md) - bundle/[BundleInfo (BundleInfo)](js-apis-bundle-BundleInfo.md) + - bundle/[BundleInstaller (BundleInstaller)](js-apis-bundle-BundleInstaller.md) - bundle/[CustomizeData (CustomizeData)](js-apis-bundle-CustomizeData.md) + - bundle/[DispatchInfo (DispatchInfo)](js-apis-dispatchInfo.md) + - bundle/[ElementName (ElementName)](js-apis-bundle-ElementName.md) - bundle/[ExtensionAbilityInfo (ExtensionAbilityInfo)](js-apis-bundle-ExtensionAbilityInfo.md) - bundle/[HapModuleInfo (HapModuleInfo)](js-apis-bundle-HapModuleInfo.md) + - bundle/[LauncherAbilityInfo (LauncherAbilityInfo)](js-apis-bundle-LauncherAbilityInfo.md) - bundle/[Metadata (Metadata)](js-apis-bundle-Metadata.md) - bundle/[ModuleInfo (ModuleInfo)](js-apis-bundle-ModuleInfo.md) + - bundle/[PermissionDef (PermissionDef)](js-apis-bundle-PermissionDef.md) + - bundle/[RemoteAbilityInfo (RemoteAbilityInfo)](js-apis-bundle-remoteAbilityInfo.md) + - bundle/[ShortcutInfo (ShortcutInfo)](js-apis-bundle-ShortcutInfo.md) - UIç•Œé¢ - [@ohos.animator (动画)](js-apis-animator.md) @@ -81,6 +99,7 @@ - [@ohos.uiAppearance(用户界é¢å¤–观)](js-apis-uiappearance.md) - å›¾å½¢å›¾åƒ + - [@ohos.animation.windowAnimationManager (窗å£åŠ¨ç”»ç®¡ç†)](js-apis-windowAnimationManager.md) - [@ohos.display (å±å¹•å±žæ€§)](js-apis-display.md) - [@ohos.effectKit (图åƒæ•ˆæžœ)](js-apis-effectKit.md) - [@ohos.screen (å±å¹•)](js-apis-screen.md) @@ -102,6 +121,7 @@ - 资æºè°ƒåº¦ - [@ohos.backgroundTaskManager (åŽå°ä»»åŠ¡ç®¡ç†)](js-apis-backgroundTaskManager.md) + - [@ohos.distributedMissionManager (分布å¼ä»»åŠ¡ç®¡ç†)](js-apis-distributedMissionManager.md) - [@ohos.workScheduler (延迟任务调度)](js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](js-apis-WorkSchedulerExtensionAbility.md) - å®šåˆ¶ç®¡ç† @@ -180,7 +200,9 @@ - [@ohos.screenLock (é”å±ç®¡ç†)](js-apis-screen-lock.md) - [@ohos.systemTime (设置系统时间)](js-apis-system-time.md) - [@ohos.wallpaper (å£çº¸)](js-apis-wallpaper.md) + - [@ohos.systemTimer(设置系统时间)](js-apis-system-timer.md) - [Timer (定时器)](js-apis-timer.md) + - è®¾å¤‡ç®¡ç† - [@ohos.batteryInfo (电é‡ä¿¡æ¯)](js-apis-battery-info.md) @@ -260,4 +282,4 @@ - [@system.sensor (ä¼ æ„Ÿå™¨)](js-apis-system-sensor.md) - [@system.storage (æ•°æ®å˜å‚¨)](js-apis-system-storage.md) - [@system.vibrator (振动)](js-apis-system-vibrate.md) - - [console (日志打å°)](js-apis-logs.md) \ No newline at end of file + - [console (日志打å°)](js-apis-logs.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md new file mode 100644 index 0000000000000000000000000000000000000000..cd16f889508f3adcefabc621304527d06c1a2b88 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md @@ -0,0 +1,308 @@ +# innerBundleManager模å—(JS端SDK接å£) + +本模å—æä¾›å†…éƒ¨åŒ…çš„ç®¡ç† + +> **说明:** +> +> 本模å—首批接å£ä»ŽAPI version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + +## å¯¼å…¥æ¨¡å— + +``` +import innerBundleManager from '@ohos.bundle.innerBundleManager'; +``` + +## 系统能力 + +SystemCapability.BundleManager.BundleFramework + +## æƒé™åˆ—表 + +| æƒé™ | æƒé™ç‰çº§ | æè¿° | +| ------------------------------------------ | ------------ | ---------------------------- | +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | å¯æŸ¥è¯¢æ‰€æœ‰åº”ç”¨ä¿¡æ¯ | +| ohos.permission.LISTEN_BUNDLE_CHANGE | system_grant | å…许该应用获å–应用å˜åŒ–消æ¯ã€‚ | + +æƒé™ç‰çº§å‚考[æƒé™ç‰çº§è¯´æ˜Ž](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) + +## innerBundleManager.getLauncherAbilityInfos + +getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å获å–LauncherAbilityInfos,使用callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | +| bundleName | string | 是 | è¦æŸ¥è¯¢çš„应用程åºåŒ…å称。 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回程åºä¿¡æ¯ã€‚ | + + + +## innerBundleManager.getLauncherAbilityInfos + +getLauncherAbilityInfos(bundleName: string, userId: number) : Promise<Array<LauncherAbilityInfo>> + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å获å–LauncherAbilityInfos,使用Promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------ | ---- | ----------------------------------------------------- | +| bundleName | string | 是 | è¦æŸ¥è¯¢çš„应用程åºåŒ…å称。 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------- | +| Promise\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Promiseå½¢å¼è¿”回程åºä¿¡æ¯ã€‚ | + +## innerBundleManager.on + +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback<string>) : void; + +注册Callback。 + +**需è¦æƒé™ï¼š** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------------- | --------------------- | ---- | ---------------------------------------------------- | +| type | "BundleStatusChange" | 是 | 指示应执行命令。 | +| bundleStatusCallback | BundleStatusCallback | 是 | 指示è¦æ³¨å†Œçš„回调。 | +| callback | AsyncCallback\<string> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回æ£ç¡®ç»“果或错误信æ¯ã€‚ | + +## innerBundleManager.on + +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise<string> + +注册Callback。 + +**需è¦æƒé™ï¼š** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------------- | -------------------- | ---- | ------------------ | +| type | "BundleStatusChange" | 是 | 指示应执行命令。 | +| bundleStatusCallback | BundleStatusCallback | 是 | 指示è¦æ³¨å†Œçš„回调。 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------------------- | +| Promise\<string> | Promiseå½¢å¼è¿”回æ£ç¡®ç»“果或错误信æ¯ã€‚ | + +## innerBundleManager.off + +off(type:"BundleStatusChange", callback: AsyncCallback<string>) : void; + +å–消注册Callback。 + +**需è¦æƒé™ï¼š** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | --------------------- | ---- | ---------------------------------------------------- | +| type | "BundleStatusChange" | 是 | 指示应执行命令。 | +| callback | AsyncCallback\<string> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回æ£ç¡®ç»“果或错误信æ¯ã€‚ | + +## innerBundleManager.off + +off(type:"BundleStatusChange"): Promise<string> + +å–消注册Callback。 + +**需è¦æƒé™ï¼š** + +ohos.permission.LISTEN_BUNDLE_CHANGE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---- | -------------------- | ---- | ---------------- | +| type | "BundleStatusChange" | 是 | 指示应执行命令。 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------------------- | +| Promise\<string> | Promiseå½¢å¼è¿”回æ£ç¡®ç»“果或错误信æ¯ã€‚ | + +## innerBundleManager.getAllLauncherAbilityInfos + +getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; + +以异æ¥æ–¹æ³•èŽ·å–所有的LauncherAbilityInfos,使用callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回程åºä¿¡æ¯ã€‚ | + +## innerBundleManager.getAllLauncherAbilityInfos + +getAllLauncherAbilityInfos(userId: number) : Promise<Array<LauncherAbilityInfo>> + +以异æ¥æ–¹æ³•èŽ·å–LauncherAbilityInfos,使用Promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------ | ------ | ---- | ----------------------------------------------------- | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------- | +| Promise\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Promiseå½¢å¼è¿”回程åºä¿¡æ¯ã€‚ | + +## innerBundleManager.getShortcutInfos + +getShortcutInfos(bundleName :string, callback: AsyncCallback<Array<ShortcutInfo>>) : void; + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å获å–å¿«æ·æ–¹å¼ä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------------------------------------------------------------ | ---- | ---------------------------------------------- | +| bundleName | string | 是 | è¦æŸ¥è¯¢çš„应用程åºåŒ…å称。 | +| callback | AsyncCallback\<Array<[ShortcutInfo](js-apis-bundle-ShortcutInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回快æ·æ–¹å¼ä¿¡æ¯ã€‚ | + +## innerBundleManager.getShortcutInfos + +getShortcutInfos(bundleName : string) : Promise<Array<ShortcutInfo>> + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å获å–å¿«æ·æ–¹å¼ä¿¡æ¯ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------ | ---- | ------------------------ | +| bundleName | string | 是 | è¦æŸ¥è¯¢çš„应用程åºåŒ…å称。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------------------------------- | ----------------------------- | +| Promise\<Array<[ShortcutInfo](js-apis-bundle-ShortcutInfo.md)>> | Promiseå½¢å¼è¿”回快æ·æ–¹å¼ä¿¡æ¯ã€‚ | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md new file mode 100644 index 0000000000000000000000000000000000000000..a32fdcc7d7e01ff4e05ce885ec2cdfeee288c6dc --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @@ -0,0 +1,139 @@ +# distributedBundle模å—(JS端SDK接å£) + +本模å—æ供分布å¼åŒ…çš„ç®¡ç† + +> **说明:** +> +> 本模å—首批接å£ä»ŽAPI version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + +## å¯¼å…¥æ¨¡å— + +``` +import distributedBundle from '@ohos.distributedBundle'; +``` + +## 系统能力 + +SystemCapability.BundleManager.DistributedBundleFramework + +## æƒé™åˆ—表 + +| æƒé™ | æƒé™ç‰çº§ | æè¿° | +| ------------------------------------------ | ------------ | ------------------ | +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | å¯æŸ¥è¯¢æ‰€æœ‰åº”ç”¨ä¿¡æ¯ | + +æƒé™ç‰çº§å‚考[æƒé™ç‰çº§è¯´æ˜Ž](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback<RemoteAbilityInfo>): void; + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„ElementName获å–有关远程设备AbilityInfoä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.DistributedBundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementNameä¿¡æ¯ã€‚ | +| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回远程基本能力信æ¯ã€‚ | + + + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName): Promise<RemoteAbilityInfo> + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„ElementName获å–有关远程设备AbilityInfoä¿¡æ¯ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.DistributedBundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ----------- | -------------------------------------------- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 获得的ElementNameä¿¡æ¯ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promiseå½¢å¼è¿”回远程基本能力信æ¯ã€‚ | + +## distributedBundle.getRemoteAbilityInfos + +getRemoteAbilityInfos(elementNames: Array<ElementName>, callback: AsyncCallback<Array<RemoteAbilityInfo>>): void; + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„ElementName获å–有关远程设备AbilityInfosä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.DistributedBundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementNameä¿¡æ¯,最大数组长度为10 | +| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回远程基本能力信æ¯ã€‚ | + + + +## distributedBundle.getRemoteAbilityInfos + +getRemoteAbilityInfos(elementNames: Array<ElementName>): Promise<Array<RemoteAbilityInfo>> + +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„ElementName获å–有关远程设备AbilityInfosä¿¡æ¯ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.DistributedBundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------------ | --------------------------------------------------- | ---- | ----------------------- | +| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | 是 | ElementNameä¿¡æ¯,最大数组长度为10。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\<Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Promiseå½¢å¼è¿”回远程基本能力信æ¯ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index 45f2c957bafe33532b81c6b87f3a7c92d6a628d2..61dd1a23ddb25ee89c13f0527597e0cb37e14c99 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -374,6 +374,466 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { }) ``` +## bundle.getBundleInstaller + +getBundleInstaller(): Promise<BundleInstaller>; + +获å–ç”¨äºŽå®‰è£…åŒ…çš„æŽ¥å£ + +**需è¦æƒé™ï¼š** + +ohos.permission.INSTALL_BUNDLE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | -------------------------------------------- | +| Promise<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 返回值为Promise对象,Promiseä¸åŒ…å«å®‰è£…ä¿¡æ¯ã€‚ | + +## bundle.getBundleInstaller + +getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void; + +获å–ç”¨äºŽå®‰è£…åŒ…çš„æŽ¥å£ + +**需è¦æƒé™ï¼š** + +ohos.permission.INSTALL_BUNDLE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ------------------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是 | 安装应用程åºåŒ…。 | + +## bundle.cleanBundleCacheFiles<sup>8+</sup> + +cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback<void>): void; + +清除指定应用程åºçš„缓å˜æ•°æ® + +**需è¦æƒé™ï¼š** + +ohos.permission.REMOVE_CACHE_FILES + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------------------- | ---- | ------------------------------------- | +| bundleName | string | 是 | 指示è¦æ¸…除其缓å˜æ•°æ®çš„应用程åºåŒ…å称. | +| callback | AsyncCallback\<void> | 是 | 为返回æ“作结果而调用的回调。 | + +## bundle.cleanBundleCacheFiles<sup>8+</sup> + +cleanBundleCacheFiles(bundleName: string): Promise<void> + +清除指定应用程åºçš„缓å˜æ•°æ® + +**需è¦æƒé™ï¼š** + +ohos.permission.REMOVE_CACHE_FILES + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------ | ---- | ------------------------------------- | +| bundleName | string | 是 | 指示è¦æ¸…除其缓å˜æ•°æ®çš„应用程åºåŒ…å称. | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ------------------------------------ | +| Promise\<void> | 返回值为Promise对象,Promiseä¸ä¸ºç©ºã€‚ | + +## bundle.setApplicationEnabled<sup>8+</sup> + +setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback<void>): void; + +设置是å¦å¯ç”¨æŒ‡å®šçš„åº”ç”¨ç¨‹åº + +**需è¦æƒé™ï¼š** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------------------- | ---- | ----------------------------------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| isEnable | boolean | 是 | 指定是å¦å¯ç”¨åº”用程åºã€‚true表示å¯ç”¨ï¼Œfalseç¦ç”¨ã€‚ | +| callback | AsyncCallback\<void> | 是 | 为返回æ“作结果而调用的回调。 | + +## bundle.setApplicationEnabled<sup>8+</sup> + +setApplicationEnabled(bundleName: string, isEnable: boolean): Promise<void> + +设置是å¦å¯ç”¨æŒ‡å®šçš„åº”ç”¨ç¨‹åº + +**需è¦æƒé™ï¼š** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------- | ---- | ----------------------------------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| isEnable | boolean | 是 | 指定是å¦å¯ç”¨åº”用程åºã€‚true表示å¯ç”¨ï¼Œfalseç¦ç”¨ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ------------------------------------ | +| Promise\<void> | 返回值为Promise对象,Promiseä¸ä¸ºç©ºã€‚ | + +## bundle.setAbilityEnabled<sup>8+</sup> + +setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback<void>): void; + +设置是å¦å¯ç”¨æŒ‡å®šçš„功能 + +**需è¦æƒé™ï¼š** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | -------------------------------------------- | ---- | ----------------------------------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Abilityä¿¡æ¯ã€‚ | +| isEnable | boolean | 是 | 指定是å¦å¯ç”¨åº”用程åºã€‚true表示å¯ç”¨ï¼Œfalseç¦ç”¨ã€‚ | +| callback | AsyncCallback\<void> | 是 | 为返回æ“作结果而调用的回调。 | + +## bundle.setAbilityEnabled<sup>8+</sup> + +setAbilityEnabled(info: AbilityInfo, isEnable: boolean): Promise<void> + +设置是å¦å¯ç”¨æŒ‡å®šçš„功能 + +**需è¦æƒé™ï¼š** + +ohos.permission.CHANGE_ABILITY_ENABLED_STATE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | -------------------------------------------- | ---- | ----------------------------------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Abilityä¿¡æ¯ã€‚ | +| isEnable | boolean | 是 | 指定是å¦å¯ç”¨åº”用程åºã€‚true表示å¯ç”¨ï¼Œfalseç¦ç”¨ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ------------------------------------ | +| Promise\<void> | 返回值为Promise对象,Promiseä¸ä¸ºç©ºã€‚ | + +## bundle.getPermissionDef<sup>8+</sup> + +getPermissionDef(permissionName: string, callback: AsyncCallback<PermissionDef>): void; + +按æƒé™å称获å–æƒé™çš„è¯¦ç»†ä¿¡æ¯ + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | +| permissionName | string | 是 | 指定æƒé™çš„å称。 | +| callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回定义的æƒé™ä¿¡æ¯ã€‚ | + +## bundle.getPermissionDef<sup>8+</sup> + +getPermissionDef(permissionName: string): Promise<PermissionDef> + +按æƒé™å称获å–æƒé™çš„è¯¦ç»†ä¿¡æ¯ + +**需è¦æƒé™ï¼š** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------- | ------ | ---- | ---------------- | +| permissionName | string | 是 | 指定æƒé™çš„å称。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------ | ------------------------------------------------------ | +| Promise<[PermissionDef](js-apis-bundle-PermissionDef)> | 返回值为Promise对象,Promiseä¸åŒ…å«å®šä¹‰çš„æƒé™ä¿¡æ¯å¯¹è±¡ã€‚ | + +## bundle.setModuleUpgradeFlag<sup>9+</sup> + +setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback<void>):void; + +设置模å—是å¦éœ€è¦å‡çº§ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ----------- | --------------------------- | ---- | ---------------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| moduleName | string | 是 | 应用程åºæ¨¡å—å称。 | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | ä»…ä¾›å†…éƒ¨ç³»ç»Ÿä½¿ç”¨æ ‡å¿—ä½ | +| callback | AsyncCallback\<void> | 是 | 为返回æ“作结果而调用的回调。 | + +## bundle.setModuleUpgradeFlag<sup>9+</sup> + +setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise<void> + +设置模å—是å¦éœ€è¦å‡çº§ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ----------- | --------------------------- | ---- | ---------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| moduleName | string | 是 | 应用程åºæ¨¡å—å称。 | +| upgradeFlag | [UpgradeFlag](#upgradeflag) | 是 | ä»…ä¾›å†…éƒ¨ç³»ç»Ÿä½¿ç”¨æ ‡å¿—ä½ | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ------------------------------------ | +| Promise\<void> | 返回值为Promise对象,Promiseä¸ä¸ºç©ºã€‚ | + +## bundle.isModuleRemovable<sup>9+</sup> + +isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback<boolean>): void; + +检查指定模å—是å¦è¢«ç§»é™¤ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ---------------------- | ---- | --------------------------------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| moduleName | string | 是 | 应用程åºæ¨¡å—å称。 | +| callback | AsyncCallback\<boolean> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回booleanä¿¡æ¯ã€‚ | + +## bundle.isModuleRemovable<sup>9+</sup> + +isModuleRemovable(bundleName: string, moduleName: string): Promise<boolean> + +检查指定模å—是å¦è¢«ç§»é™¤ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ------ | ---- | ------------------ | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| moduleName | string | 是 | 应用程åºæ¨¡å—å称。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ---------------------------- | +| Promise\<boolean> | Promiseå½¢å¼è¿”回booleanä¿¡æ¯ã€‚ | + +## bundle.getBundlePackInfo<sup>9+</sup> + +getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback<pack.BundlePackInfo>): void; + +基于bundleNameå’ŒbundleFlags获å–bundlePackInfo + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------- | ---------------------------------- | ---- | ---------------------------------------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| bundlePackFlag | pack.BundlePackFlag | 是 | 指示è¦æŸ¥è¯¢çš„åº”ç”¨åŒ…æ ‡å¿— | +| callback | AsyncCallback<pack.BundlePackInfo> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回BundlePackInfoä¿¡æ¯ã€‚ | + +## bundle.getBundlePackInfo<sup>9+</sup> + +getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise<pack.BundlePackInfo>; + +基于bundleNameå’ŒbundleFlags获å–bundlePackInfo + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------- | ------------------- | ---- | ---------------------- | +| bundleName | string | 是 | 应用程åºåŒ…å称。 | +| bundlePackFlag | pack.BundlePackFlag | 是 | 指示è¦æŸ¥è¯¢çš„åº”ç”¨åŒ…æ ‡å¿— | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------- | ----------------------------------- | +| Promise<pack.BundlePackInfo> | Promiseå½¢å¼è¿”回BundlePackInfoä¿¡æ¯ã€‚ | + +## bundle.getDispatcherVersion<sup>9+</sup> + +getDispatcherVersion(callback: AsyncCallback<DispatchInfo>): void; + +获å–有关dispatcherç‰ˆæœ¬çš„ä¿¡æ¯ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<[DispatchInfo](js-apis-dispatchInfo.md)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回[DispatchInfo](js-apis-dispatchInfo.md)ä¿¡æ¯ã€‚ | + +## bundle.getDispatcherVersion<sup>9+</sup> + +getDispatcherVersion(): Promise<DispatchInfo>; + +获å–有关dispatcherç‰ˆæœ¬çš„ä¿¡æ¯ + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**系统API:** + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------ | ------------------------------------------------------------ | +| Promise<[DispatchInfo](js-apis-dispatchInfo.md)> | Promiseå½¢å¼è¿”回[DispatchInfo](js-apis-dispatchInfo.md)ä¿¡æ¯ã€‚ | ## bundle.getAllApplicationInfo @@ -1050,7 +1510,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId) queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback<Array\<AbilityInfo>>): void -以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„æ„图获å–获å–指定用户下Abilityä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„æ„图获å–指定用户下Abilityä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 **需è¦æƒé™ï¼š** @@ -1437,8 +1897,8 @@ SystemCapability.BundleManager.BundleFramework | å称 | 类型 | å¿…å¡« | æè¿° | | -------------- | ------ | ---- | ---------------------------------------- | | want | [Want](js-apis-application-Want.md) | 是 | 包å«è¦æŸ¥è¯¢çš„应用程åºåŒ…å称的æ„图。 | -| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#ExtensionAbilityType9) | -| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#ExtensionFlag9) | +| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) | +| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#extensionflag9) | | userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0 | **返回值:** @@ -1486,8 +1946,8 @@ SystemCapability.BundleManager.BundleFramework | å称 | 类型 | å¿…å¡« | æè¿° | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | want | [Want](js-apis-application-Want.md) | 是 | 指示包å«è¦æŸ¥è¯¢çš„应用程åºåŒ…å称的æ„图。 | -| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#ExtensionAbilityType9) | -| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#ExtensionFlag9)| +| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) | +| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#extensionflag9)| | userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0 | | callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回ExtensionAbilityä¿¡æ¯ã€‚ | @@ -1529,8 +1989,8 @@ SystemCapability.BundleManager.BundleFramework | å称 | 类型 | å¿…å¡« | æè¿° | | -------------- | ---------------------------------------- | ---- | ---------------------------------------- | | want | [Want](js-apis-application-Want.md) | 是 | 指示包å«è¦æŸ¥è¯¢çš„应用程åºåŒ…å称的æ„图。 | -| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#ExtensionAbilityType9) | -| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#ExtensionFlag9) | +| extensionType | number | 是 | 用于指定查找的extensionAbilityInfo的类型。 默认值:0,å–值范围:枚举值: [ExtensionAbilityType](#extensionabilitytype9) | +| extensionFlags | number | 是 | 用于指定返回ExtensionAbilityInfoä¿¡æ¯ã€‚默认值:0,å–值范围:枚举值: [ExtensionFlags](#extensionflag9) | | callback | AsyncCallback<Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)>> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回ExtensionAbilityä¿¡æ¯ã€‚ | **示例:** @@ -1687,12 +2147,14 @@ bundle.getProfileByExtensionAbility(moduleName, extensionAbilityName, metadataNa setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\<void>): void; -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä»¥å¼‚æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameå’Œstatusæ¥è®¾ç½®å¯¹åº”应用的处置状æ€ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameå’Œstatusæ¥è®¾ç½®å¯¹åº”应用的处置状æ€ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 **需è¦æƒé™ï¼š** ohos.permission.MANAGE_DISPOSED_APP_STATUS **系统能力:** SystemCapability.BundleManager.BundleFramework +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + **å‚数:** | å称 | 类型 | å¿…å¡« | æè¿° | @@ -1717,12 +2179,14 @@ bundle.setDisposedStatus(bundleName, status, caller) setDisposedStatus(bundleName: string, status: number): Promise\<void>; -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä»¥å¼‚æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameå’Œstatusæ¥è®¾ç½®å¯¹åº”应用的处置状æ€ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameå’Œstatusæ¥è®¾ç½®å¯¹åº”应用的处置状æ€ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 **需è¦æƒé™ï¼š** ohos.permission.MANAGE_DISPOSED_APP_STATUS **系统能力:** SystemCapability.BundleManager.BundleFramework +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + **å‚数:** | å称 | 类型 | å¿…å¡« | æè¿° | @@ -1753,12 +2217,14 @@ bundle.setDisposedStatus(bundleName, status).then(data=>{ getDisposedStatus(bundleName: string, callback: AsyncCallback\<number>): void; -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä»¥å¼‚æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameæ¥èŽ·å–对应应用的处置状æ€ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameæ¥èŽ·å–对应应用的处置状æ€ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 **需è¦æƒé™ï¼š** ohos.permission.MANAGE_DISPOSED_APP_STATUS **系统能力:** SystemCapability.BundleManager.BundleFramework +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + **å‚数:** | å称 | 类型 | å¿…å¡« | æè¿° | @@ -1781,12 +2247,14 @@ bundle.getDisposedStatus(bundleName, caller) getDisposedStatus(bundleName: string): Promise\<number>; -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä»¥å¼‚æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameæ¥èŽ·å–对应应用的处置状æ€ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 +以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„bundleNameæ¥èŽ·å–对应应用的处置状æ€ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回结果。 **需è¦æƒé™ï¼š** ohos.permission.MANAGE_DISPOSED_APP_STATUS **系统能力:** SystemCapability.BundleManager.BundleFramework +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + **å‚数:** | å称 | 类型 | å¿…å¡« | æè¿° | @@ -1897,15 +2365,15 @@ Ability类型 | LANDSCAPE | æ— | å±å¹•æ–¹å‘--æ¨ªå± | | PORTRAIT | æ— | å±å¹•æ–¹å‘--ç«–å± | | FOLLOW_RECENT | æ— | å±å¹•æ–¹å‘--紧跟上一个组件 | -| LANDSCAPE_INVERTED |æ— | å±å¹•æ–¹å‘--åå‘æ¨ªå± | -| PORTRAIT_INVERTED |æ— | å±å¹•æ–¹å‘--åå‘ç«–å± | -| AUTO_ROTATION |æ— | å±å¹•æ–¹å‘--éšä¼ 感器旋转 | -| AUTO_ROTATION_LANDSCAPE |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨æ¨ªå±æ—‹è½¬ï¼ŒåŒ…括了横å±å’Œåå‘æ¨ªå± | -| AUTO_ROTATION_PORTRAIT |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨ç«–å±æ—‹è½¬ï¼ŒåŒ…括了竖å±å’Œåå‘ç«–å± | -| AUTO_ROTATION_RESTRICTED |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘å¯éšä¼ 感器旋转 | -| AUTO_ROTATION_LANDSCAPE_RESTRICTED |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘å¯éšä¼ 感器旋转为横å±ï¼Œ 包括了横å±å’Œåå‘æ¨ªå± | -| AUTO_ROTATION_PORTRAIT_RESTRICTED |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘éšå¯ä¼ 感器旋转为竖å±ï¼Œ 包括了横å±å’Œåå‘æ¨ªå± | -| LOCKED |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³å…³é—,方å‘é”定 | +| LANDSCAPE_INVERTED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--åå‘æ¨ªå± | +| PORTRAIT_INVERTED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--åå‘ç«–å± | +| AUTO_ROTATION<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--éšä¼ 感器旋转 | +| AUTO_ROTATION_LANDSCAPE<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨æ¨ªå±æ—‹è½¬ï¼ŒåŒ…括了横å±å’Œåå‘æ¨ªå± | +| AUTO_ROTATION_PORTRAIT<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨ç«–å±æ—‹è½¬ï¼ŒåŒ…括了竖å±å’Œåå‘ç«–å± | +| AUTO_ROTATION_RESTRICTED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘å¯éšä¼ 感器旋转 | +| AUTO_ROTATION_LANDSCAPE_RESTRICTED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘å¯éšä¼ 感器旋转为横å±ï¼Œ 包括了横å±å’Œåå‘æ¨ªå± | +| AUTO_ROTATION_PORTRAIT_RESTRICTED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³æ‰“å¼€ï¼Œæ–¹å‘éšå¯ä¼ 感器旋转为竖å±ï¼Œ 包括了横å±å’Œåå‘æ¨ªå± | +| LOCKED<sup>9+</sup> |æ— | å±å¹•æ–¹å‘--ä¼ æ„Ÿå™¨å¼€å…³å…³é—,方å‘é”定 | ## LaunchMode å¯åŠ¨æ¨¡å¼ @@ -1945,9 +2413,12 @@ ExtensionAbility的类型 | FILE_SHARE<sup>9+</sup> | 6 | ExtensionAbility的类型包括文件共享 | | STATIC_SUBSCRIBER<sup>9+</sup> | 7 | ExtensionAbility的类型包括订阅者 | | WALLPAPER<sup>9+</sup> | 8 | ExtensionAbility的类型包括墙纸 | -| BACKUP<sup>9+</sup> | 9 | ExtensionAbility的类型包括数æ®å¤‡ä»½æ¢å¤ | +| BACKUP<sup>9+</sup> | 9 | ExtensionAbility的类型包括数æ®å¤‡ä»½æ¢å¤ | +| WINDOW<sup>9+</sup> | 10 | ExtensionAbility的类型包括窗å£ç±»åž‹æ‰©å±•ä¿¡æ¯ | | ENTERPRISE_ADMIN<sup>9+</sup> | 11 | ExtensionAbility的类型包括ä¼ä¸šç®¡ç†å‘˜ | -| UNSPECIFIED<sup>9+</sup> | 20 | ExtensionAbility未指定类型 | +| THUMBNAIL<sup>9+</sup> | 13 | ExtensionAbility的类型包括缩略图 | +| PREVIEW<sup>9+</sup> | 14 | ExtensionAbility的类型包括预览 | +| UNSPECIFIED<sup>9+</sup> | 255 | ExtensionAbility未指定类型 | ## ExtensionFlag<sup>9+</sup> @@ -1994,6 +2465,20 @@ ExtensionAbility的类型 | å称 | 类型 | 说明 | | ------------------ | ---- | ---- | -| FULLSCREEN | æ— | å…¨å±æ¨¡å¼ | -| SPLIT | æ— | 分å±æ¨¡å¼ | -| FLOATING | æ— | æ‚¬æµ®æ¨¡å¼ | +| FULL_SCREEN<sup>9+</sup> | 0 | å…¨å±æ¨¡å¼ | +| SPLIT<sup>9+</sup> | 1 | 分å±æ¨¡å¼ | +| FLOATING<sup>9+</sup> | 2 | æ‚¬æµ®æ¨¡å¼ | + +## UpgradeFlag + +æ¤é¡¹ä»…供内部系统使用 + +**系统API:**æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 值 | 说明 | +| ----------------------------- | ---- | ---------------- | +| NOT_UPGRADE<sup>9+</sup> | 0 | 模å—æ— éœ€å‡çº§ | +| SINGLE_UPGRADE<sup>9+</sup> | 1 | å•ä¸ªæ¨¡å—需è¦å‡çº§ | +| RELATION_UPGRADE<sup>9+</sup> | 2 | 关系模å—需è¦å‡çº§ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index f85c67797499cb5968532c13f0a50412a06f5b3c..1352981c55e13ae8451df234cb434a5f7bb4138c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -3,7 +3,7 @@ Context模å—æ供了ability或application的上下文的能力,包括å…许访问特定于应用程åºçš„资æºã€è¯·æ±‚和验è¯æƒé™ç‰ã€‚ > **说明:** -> +> > 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > 本模å—接å£ä»…å¯åœ¨FA模型下使用。 @@ -29,9 +29,9 @@ getOrCreateLocalDir(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback\<string> | 是 | 返回应用程åºçš„æœ¬åœ°æ ¹ç›®å½•ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ------------- | +| callback | AsyncCallback\<string> | 是 | 返回应用程åºçš„æœ¬åœ°æ ¹ç›®å½•ã€‚ | **示例:** @@ -57,8 +57,8 @@ getOrCreateLocalDir(): Promise\<string> **返回值:** -| 类型 | 说明 | -| ---------------- | ---------------------- | +| 类型 | 说明 | +| ---------------- | ----------- | | Promise\<string> | 应用程åºçš„æœ¬åœ°æ ¹ç›®å½•ã€‚ | **示例:** @@ -83,11 +83,11 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| ---------- | --------------------------------------- | ---- | ------------------------------------- | -| permission | string | 是 | 指定æƒé™çš„å称。 | -| options | [PermissionOptions](#permissionoptions) | 是 | æƒé™é€‰é¡¹ã€‚ | -| callback | AsyncCallback\<number> | 是 | 返回æƒé™éªŒè¯ç»“果,0有æƒé™ï¼Œ-1æ— æƒé™ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | --------------------------------------- | ---- | -------------------- | +| permission | string | 是 | 指定æƒé™çš„å称。 | +| options | [PermissionOptions](#permissionoptions) | 是 | æƒé™é€‰é¡¹ã€‚ | +| callback | AsyncCallback\<number> | 是 | 返回æƒé™éªŒè¯ç»“果,0有æƒé™ï¼Œ-1æ— æƒé™ã€‚ | **示例:** @@ -112,10 +112,10 @@ verifyPermission(permission: string, callback: AsyncCallback\<number>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| ---------- | ---------------------- | ---- | ------------------------------------- | -| permission | string | 是 | 指定æƒé™çš„å称。 | -| callback | AsyncCallback\<number> | 是 | 返回æƒé™éªŒè¯ç»“果,0有æƒé™ï¼Œ-1æ— æƒé™ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ---------------------- | ---- | -------------------- | +| permission | string | 是 | 指定æƒé™çš„å称。 | +| callback | AsyncCallback\<number> | 是 | 返回æƒé™éªŒè¯ç»“果,0有æƒé™ï¼Œ-1æ— æƒé™ã€‚ | **示例:** @@ -135,15 +135,15 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\<numb **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| ---------- | --------------------------------------- | ---- | ---------------- | -| permission | string | 是 | 指定æƒé™çš„å称。 | -| options | [PermissionOptions](#permissionoptions) | å¦ | æƒé™é€‰é¡¹ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | --------------------------------------- | ---- | -------- | +| permission | string | 是 | 指定æƒé™çš„å称。 | +| options | [PermissionOptions](#permissionoptions) | å¦ | æƒé™é€‰é¡¹ã€‚ | **返回值:** -| 类型 | 说明 | -| ---------------- | ----------------------------------------------------------- | +| 类型 | 说明 | +| ---------------- | ---------------------------------- | | Promise\<number> | 如果pidå’Œuid具有æƒé™ï¼Œåˆ™ä½¿ç”¨0进行异æ¥å›žè°ƒï¼›å¦åˆ™ä½¿ç”¨-1回调。 | **示例:** @@ -170,11 +170,11 @@ requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, res **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| permissions | Array\<string> | 是 | 指示è¦è¯·æ±‚çš„æƒé™åˆ—表。æ¤å‚æ•°ä¸èƒ½ä¸ºnull。 | -| requestCode | number | 是 | 指示è¦ä¼ 递给PermissionRequestResult的请求代ç 。 | -| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | 是 | 返回授æƒç»“果信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------------- | ---------------------------------------- | ---- | ----------------------------------- | +| permissions | Array\<string> | 是 | 指示è¦è¯·æ±‚çš„æƒé™åˆ—表。æ¤å‚æ•°ä¸èƒ½ä¸ºnull。 | +| requestCode | number | 是 | 指示è¦ä¼ 递给PermissionRequestResult的请求代ç 。 | +| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | 是 | 返回授æƒç»“果信æ¯ã€‚ | **示例:** @@ -206,9 +206,9 @@ getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback\<ApplicationInfo> | 是 | 返回当å‰åº”用程åºçš„ä¿¡æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ------------------------------- | ---- | ------------ | +| callback | AsyncCallback\<ApplicationInfo> | 是 | 返回当å‰åº”用程åºçš„ä¿¡æ¯ã€‚ | **示例:** @@ -230,8 +230,8 @@ getApplicationInfo(): Promise\<ApplicationInfo> **返回值:** -| 类型 | 说明 | -| ------------------------- | ------------------ | +| 类型 | 说明 | +| ------------------------- | --------- | | Promise\<ApplicationInfo> | 当å‰åº”用程åºçš„ä¿¡æ¯ | **示例:** @@ -257,9 +257,9 @@ getBundleName(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ----------------------------- | -| callback | AsyncCallback\<string> | 是 | 返回当å‰abilityçš„æ†ç»‘包å称。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ------------------ | +| callback | AsyncCallback\<string> | 是 | 返回当å‰abilityçš„æ†ç»‘包å称。 | **示例:** @@ -281,8 +281,8 @@ getBundleName(): Promise\<string> **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | ---------------- | | Promise\<string> | 当å‰abilityçš„æ†ç»‘包å称。 | **示例:** @@ -296,6 +296,225 @@ context.getBundleName().then((data) => { }); ``` +## Context.getDisplayOrientation<sup>7+</sup> + +getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void + +获å–æ¤èƒ½åŠ›çš„当å‰æ˜¾ç¤ºæ–¹å‘(callbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ------------------------------------------------------------ | ---- | ------------------ | +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | 是 | 表示å±å¹•æ˜¾ç¤ºæ–¹å‘。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getDisplayOrientation() +``` + +## Context.getDisplayOrientation<sup>7+</sup> + +getDisplayOrientation(): Promise\<bundle.DisplayOrientation>; + +获å–æ¤èƒ½åŠ›çš„当å‰æ˜¾ç¤ºæ–¹å‘(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | --------- | +| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | 表示å±å¹•æ˜¾ç¤ºæ–¹å‘。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.getDisplayOrientation().then((data) => { + console.info("=======================>getDisplayOrientationCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setDisplayOrientation<sup>7+</sup> + +setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback\<void>): void + +设置当å‰èƒ½åŠ›çš„显示方å‘(callbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ----------- | ---------------------------------------- | ---- | ------------ | +| orientation | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) | 是 | 指示当å‰èƒ½åŠ›çš„æ–°æ–¹å‘。。 | +| callback | AsyncCallback\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | 是 | 表示å±å¹•æ˜¾ç¤ºæ–¹å‘。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import bundle from '@ohos.bundle' +var context = featureAbility.getContext(); +var orientation=bundle.DisplayOrientation.UNSPECIFIED +context.setDisplayOrientation(orientation, (err) => { + console.log('---------- setDisplayOrientation fail, err: -----------', err); +}); +``` + +## Context.setDisplayOrientation<sup>7+</sup> + +setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void>; + +设置当å‰èƒ½åŠ›çš„显示方å‘(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | +| orientation | [bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation) | +| Promise\<[bundle.DisplayOrientation](js-apis-Bundle.md#displayorientation)> | 表示å±å¹•æ˜¾ç¤ºæ–¹å‘。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +import bundle from '@ohos.bundle' +var context = featureAbility.getContext(); +var orientation=bundle.DisplayOrientation.UNSPECIFIED +context.setDisplayOrientation(orientation).then((data) => { + console.info("=======================>setDisplayOrientationCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setShowOnLockScreen<sup>7+</sup> + +setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void + +设置æ¯å½“显示é”å±æ—¶æ˜¯å¦åœ¨é”å±é¡¶éƒ¨æ˜¾ç¤ºæ¤åŠŸèƒ½ï¼Œä½¿è¯¥åŠŸèƒ½ä¿æŒæ¿€æ´»çŠ¶æ€ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | -------------------- | ---- | ---------------------------------------- | +| show | boolean | 是 | 指定是å¦åœ¨é”å±é¡¶éƒ¨æ˜¾ç¤ºæ¤åŠŸèƒ½ã€‚值true表示在é”å±ä¸Šæ˜¾ç¤ºï¼Œå€¼false表示ä¸æ˜¾ç¤ºã€‚ | +| callback | AsyncCallback\<void> | 是 | 返回回调结果。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var show=true +context.setShowOnLockScreen(show, (err) => { + console.log('---------- setShowOnLockScreen fail, err: -----------', err); +}); +``` + +## Context.setShowOnLockScreen<sup>7+</sup> + +setShowOnLockScreen(show: boolean): Promise\<void>; + +设置æ¯å½“显示é”å±æ—¶æ˜¯å¦åœ¨é”å±é¡¶éƒ¨æ˜¾ç¤ºæ¤åŠŸèƒ½ï¼Œä½¿è¯¥åŠŸèƒ½ä¿æŒæ¿€æ´»çŠ¶æ€ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---- | ------- | ---- | ---------------------------------------- | +| show | boolean | 是 | 指定是å¦åœ¨é”å±é¡¶éƒ¨æ˜¾ç¤ºæ¤åŠŸèƒ½ã€‚值true表示在é”å±ä¸Šæ˜¾ç¤ºï¼Œå€¼false表示ä¸æ˜¾ç¤ºã€‚ | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------- | +| Promise\<void> | 使用Promiseå½¢å¼è¿”回结果 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var show=true +context.setShowOnLockScreen(show).then((data) => { + console.info("=======================>setShowOnLockScreenCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.setWakeUpScreen<sup>7+</sup> + +setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void + +设置æ¢å¤æ¤åŠŸèƒ½æ—¶æ˜¯å¦å”¤é†’å±å¹•ã€‚(callbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | -------------------- | ---- | --------------------------------- | +| wakeUp | boolean | 是 | 指定是å¦å”¤é†’å±å¹•ã€‚值true表示唤醒它,值false表示ä¸å”¤é†’它。 | +| callback | AsyncCallback\<void> | 是 | 返回回调结果。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var wakeUp=true +context.setWakeUpScreen(wakeUp, (err) => { + console.log('---------- setWakeUpScreen fail, err: -----------', err); +}); +``` + +## Context.setWakeUpScreen<sup>7+</sup> + +setWakeUpScreen(wakeUp: boolean): Promise\<void>; + +设置æ¢å¤æ¤åŠŸèƒ½æ—¶æ˜¯å¦å”¤é†’å±å¹•ã€‚(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------ | ------- | ---- | --------------------------------- | +| wakeUp | boolean | 是 | 指定是å¦å”¤é†’å±å¹•ã€‚值true表示唤醒它,值false表示ä¸å”¤é†’它。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------- | +| Promise\<void> | 使用Promiseå½¢å¼è¿”回结果 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +var wakeUp=true +context.setWakeUpScreen(wakeUp).then((data) => { + console.info("=======================>setWakeUpScreenCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + + ## Context.getProcessInfo<sup>7+</sup> @@ -308,9 +527,9 @@ getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | --------------------------- | ---- | -------------------- | -| callback | AsyncCallback\<ProcessInfo> | 是 | 返回当å‰è¿›ç¨‹çš„ä¿¡æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | --------------------------- | ---- | ---------- | +| callback | AsyncCallback\<ProcessInfo> | 是 | 返回当å‰è¿›ç¨‹çš„ä¿¡æ¯ã€‚ | **示例:** @@ -332,8 +551,8 @@ getProcessInfo(): Promise\<ProcessInfo> **返回值:** -| 类型 | 说明 | -| --------------------- | -------------- | +| 类型 | 说明 | +| --------------------- | ------- | | Promise\<ProcessInfo> | 当å‰è¿›ç¨‹çš„ä¿¡æ¯ | **示例:** @@ -361,9 +580,9 @@ getElementName(callback: AsyncCallback\<ElementName>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | --------------------------- | ---- | ---------------------------------------------- | -| callback | AsyncCallback\<ElementName> | 是 | 返回当å‰abilityçš„ohos.bundle.ElementName对象。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | --------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\<ElementName> | 是 | 返回当å‰abilityçš„ohos.bundle.ElementName对象。 | **示例:** @@ -387,8 +606,8 @@ getElementName(): Promise\<ElementName> **返回值:** -| 类型 | 说明 | -| --------------------- | ------------------------------------------ | +| 类型 | 说明 | +| --------------------- | ------------------------------------ | | Promise\<ElementName> | 当å‰abilityçš„ohos.bundle.ElementName对象。 | **示例:** @@ -412,9 +631,9 @@ getProcessName(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\<string> | 是 | 返回当å‰è¿›ç¨‹çš„å称。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ---------- | +| callback | AsyncCallback\<string> | 是 | 返回当å‰è¿›ç¨‹çš„å称。 | **示例:** @@ -436,8 +655,8 @@ getProcessName(): Promise\<string> **返回值:** -| 类型 | 说明 | -| ---------------- | -------------------- | +| 类型 | 说明 | +| ---------------- | ---------- | | Promise\<string> | 返回当å‰è¿›ç¨‹çš„å称。 | **示例:** @@ -463,9 +682,9 @@ getCallingBundle(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<string> | 是 | 返回调用ability的包å称。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ---------------- | +| callback | AsyncCallback\<string> | 是 | 返回调用ability的包å称。 | **示例:** @@ -487,8 +706,8 @@ getCallingBundle(): Promise\<string> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | -------------- | | Promise\<string> | 调用ability的包å称。 | **示例:** @@ -512,9 +731,9 @@ getCacheDir(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<string> | 是 | 返回该应用程åºçš„内部å˜å‚¨ç›®å½•ã€‚| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | --------------- | +| callback | AsyncCallback\<string> | 是 | 返回该应用程åºçš„内部å˜å‚¨ç›®å½•ã€‚ | **示例:** @@ -540,8 +759,8 @@ getCacheDir(): Promise\<string> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | --------------- | | Promise\<string> | 获å–该应用程åºçš„内部å˜å‚¨ç›®å½•ã€‚ | **示例:** @@ -565,9 +784,9 @@ getFilesDir(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<string> | 是 | 返回内部å˜å‚¨å™¨ä¸Šæ¤åº”用程åºçš„文件目录。| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ------------------- | +| callback | AsyncCallback\<string> | 是 | 返回内部å˜å‚¨å™¨ä¸Šæ¤åº”用程åºçš„文件目录。 | **示例:** @@ -593,8 +812,8 @@ getFilesDir(): Promise\<string> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | ------------------- | | Promise\<string> | 返回内部å˜å‚¨å™¨ä¸Šæ¤åº”用程åºçš„文件目录。 | **示例:** @@ -620,9 +839,9 @@ getOrCreateDistributedDir(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<string> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回Ability或应用的分布å¼æ–‡ä»¶è·¯å¾„。如果分布å¼æ–‡ä»¶è·¯å¾„ä¸å˜åœ¨ï¼Œç³»ç»Ÿå°†åˆ›å»ºä¸€ä¸ªè·¯å¾„并返回创建的路径。| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback\<string> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回Ability或应用的分布å¼æ–‡ä»¶è·¯å¾„。如果分布å¼æ–‡ä»¶è·¯å¾„ä¸å˜åœ¨ï¼Œç³»ç»Ÿå°†åˆ›å»ºä¸€ä¸ªè·¯å¾„并返回创建的路径。 | **示例:** @@ -650,8 +869,8 @@ getOrCreateDistributedDir(): Promise\<string> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | ----------------------------------- | | Promise\<string> | Ability或应用的分布å¼æ–‡ä»¶è·¯å¾„。如果是第一次调用,则将创建目录。 | **示例:** @@ -674,9 +893,9 @@ getAppType(callback: AsyncCallback\<string>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<string> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回æ¤åº”用程åºçš„类型。| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------- | ---- | -------------------------------- | +| callback | AsyncCallback\<string> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回æ¤åº”用程åºçš„类型。 | **示例:** @@ -702,8 +921,8 @@ getAppType(): Promise\<string> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------- | ------------------ | | Promise\<string> | Promiseå½¢å¼è¿”回æ¤åº”用的类型。 | **示例:** @@ -726,9 +945,9 @@ getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[HapModuleInfo](#hapmoduleinfo)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回应用的ModuleInfo对象。| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回应用的ModuleInfo对象。 | **示例:** @@ -754,9 +973,9 @@ getHapModuleInfo(): Promise\<HapModuleInfo> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | -| Promise\<[HapModuleInfo](#hapmoduleinfo)> | 返回应用的ModuleInfo对象。 | +| 类型 | 说明 | +| ---------------------------------------- | ------------------ | +| Promise\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | 返回应用的ModuleInfo对象。 | **示例:** @@ -770,7 +989,7 @@ context.getHapModuleInfo().then((data) => { ## Context.getAppVersionInfo<sup>7+</sup> -getAppVersionInfo(callback: AsyncCallback\<HapModuleInfo>): void +getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void 获å–应用的版本信æ¯ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ @@ -778,9 +997,9 @@ getAppVersionInfo(callback: AsyncCallback\<HapModuleInfo>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回应用版本信æ¯ã€‚| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback\<[AppVersionInfo](#appversioninfo)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回应用版本信æ¯ã€‚ | **示例:** @@ -806,8 +1025,8 @@ getAppVersionInfo(): Promise\<AppVersionInfo> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | --------- | | Promise\<[AppVersionInfo](#appversioninfo)> | 返回应用版本信æ¯ã€‚ | **示例:** @@ -830,9 +1049,9 @@ getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回当å‰å½’属Ability详细信æ¯ã€‚| +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ---------------------------------------- | ---- | --------------------------------------- | +| callback | AsyncCallback\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | 回调函数,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸å¤„ç†æŽ¥å£è¿”回值,返回当å‰å½’属Ability详细信æ¯ã€‚ | **示例:** @@ -858,8 +1077,8 @@ getAbilityInfo(): Promise\<AbilityInfo> **返回值:** -| 类型 | 说明 | -| --------------- | ------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ------------------ | | Promise\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 返回当å‰å½’属Ability详细信æ¯ã€‚ | **示例:** @@ -882,9 +1101,9 @@ getApplicationContext(): Context **返回值:** -| 类型 | 说明 | -| --------- |------ | -| Context | 返回应用上下文信æ¯ã€‚ | +| 类型 | 说明 | +| ------- | ---------- | +| Context | 返回应用上下文信æ¯ã€‚ | **示例:** @@ -893,52 +1112,136 @@ import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext().getApplicationContext(); ``` -## PermissionOptions<sup>7+</sup> +## Context.isUpdatingConfigurations<sup>7+</sup> + +isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void; + +检查æ¤èƒ½åŠ›çš„é…置是å¦æ£åœ¨æ›´æ”¹ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core -| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | -| ---- | -------- | ------ | ---- | ------ | -| pid | åªè¯» | number | å¦ | 进程id。 | -| uid | åªè¯» | number | å¦ | 用户id。 | +**å‚数:** -## PermissionRequestResult<sup>7+</sup> +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | ----------------------- | ---- | ----------------------------- | +| callback | AsyncCallback\<boolean> | 是 | 如果该能力的é…ç½®æ£åœ¨æ›´æ”¹ï¼Œåˆ™ä¸ºtrue,å¦åˆ™ä¸ºfalse。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.isUpdatingConfigurations((err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}); +``` + +## Context.isUpdatingConfigurations<sup>7+</sup> + +isUpdatingConfigurations(): Promise\<boolean>; + +检查æ¤èƒ½åŠ›çš„é…置是å¦æ£åœ¨æ›´æ”¹ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ----------------------------- | +| Promise\<boolean> | 如果该能力的é…ç½®æ£åœ¨æ›´æ”¹ï¼Œåˆ™ä¸ºtrue,å¦åˆ™ä¸ºfalse。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.isUpdatingConfigurations().then((data) => { + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + +## Context.printDrawnCompleted<sup>7+</sup> + +printDrawnCompleted(callback: AsyncCallback\<void>): void; + +通知系统绘制æ¤é¡µé¢åŠŸèƒ½æ‰€éœ€çš„时间(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core -| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | -| ----------- | -------- | -------------- | ---- | ------------------ | -| requestCode | åªè¯» | number | 是 | ç”¨æˆ·ä¼ å…¥çš„è¯·æ±‚ä»£ç 。 | -| permissions | åªè¯» | Array\<string> | 是 | ç”¨æˆ·ä¼ å…¥çš„æƒé™ã€‚ | -| authResults | åªè¯» | Array\<number> | 是 | 请求æƒé™çš„结果。 | - -## HapModuleInfo<sup>7+</sup> - -Hap模å—ä¿¡æ¯ - -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ------ | ------ | ------ | ------ | ------ | -| name | string | 是 | å¦ | 模å—å称。 | -| description | string | 是 | å¦ | 模å—æè¿°ä¿¡æ¯ã€‚ | -| descriptionId | number | 是 | å¦ | æè¿°ä¿¡æ¯ID。 | -| icon | string | 是 | å¦ | 模å—å›¾æ ‡ã€‚ | -| label | string | 是 | å¦ | 模å—æ ‡ç¾ã€‚ | -| labelId | number | 是 | å¦ | 模å—æ ‡ç¾ID。 | -| iconId | number | 是 | å¦ | 模å—å›¾æ ‡ID。 | -| backgroundImg | string | 是 | å¦ | 模å—背景图片。 | -| supportedModes | number | 是 | å¦ | 模å—支æŒçš„模å¼ã€‚ | -| reqCapabilities | Array\<string> | 是 | å¦ | 模å—è¿è¡Œéœ€è¦çš„能力。 | -| deviceTypes | Array\<string> | 是 | å¦ | 支æŒè¿è¡Œçš„设备类型。 | -| abilityInfo | Array\<AbilityInfo> | 是 | å¦ | Abilityä¿¡æ¯ã€‚ | -| moduleName | string | 是 | å¦ | 模å—å。 | -| mainAbilityName | string | 是 | å¦ | å…¥å£Abilityå称。 | -| installationFree | boolean | 是 | å¦ | 是å¦æ”¯æŒå…安装。 | -| mainElementName | string | 是 | å¦ | å…¥å£abilityä¿¡æ¯ã€‚ | +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| -------- | -------------------- | ---- | ----------- | +| callback | AsyncCallback\<void> | 是 | 表示被指定的回调方法。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.printDrawnCompleted((err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}); +``` + +## Context.printDrawnCompleted<sup>7+</sup> + +printDrawnCompleted(): Promise\<void>; + +通知系统绘制æ¤é¡µé¢åŠŸèƒ½æ‰€éœ€çš„时间(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------- | +| Promise\<void> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility' +var context = featureAbility.getContext(); +context.printDrawnCompleted().then((data) => { + console.info("====>data====>" + JSON.stringify(data)); +}); +``` + + +## PermissionOptions<sup>7+</sup> + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | +| ---- | ---- | ------ | ---- | ----- | +| pid | åªè¯» | number | å¦ | 进程id。 | +| uid | åªè¯» | number | å¦ | 用户id。 | + +## PermissionRequestResult<sup>7+</sup> + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | +| ----------- | ---- | -------------- | ---- | ---------- | +| requestCode | åªè¯» | number | 是 | ç”¨æˆ·ä¼ å…¥çš„è¯·æ±‚ä»£ç 。 | +| permissions | åªè¯» | Array\<string> | 是 | ç”¨æˆ·ä¼ å…¥çš„æƒé™ã€‚ | +| authResults | åªè¯» | Array\<number> | 是 | 请求æƒé™çš„结果。 | ## AppVersionInfo<sup>7+</sup> -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ------ | ------ | ------| ------ | ------ | -| appName | string | 是 | å¦ | 模å—å称。 | -| versionCode | number | 是 | å¦ | 模å—æè¿°ä¿¡æ¯ã€‚ | -| versionName | string | 是 | å¦ | æè¿°ä¿¡æ¯ID。 | +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------- | ------ | ---- | ---- | ------- | +| appName | string | 是 | å¦ | 模å—å称。 | +| versionCode | number | 是 | å¦ | 模å—æè¿°ä¿¡æ¯ã€‚ | +| versionName | string | 是 | å¦ | æè¿°ä¿¡æ¯ID。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index 28d16f24adfd7b394fb1c87c064cf0df0827e76f..cb4b8bd411517a037b4589f67b1d0311ea4a8dfa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -4,13 +4,15 @@ å¼€å‘者在开å‘应用时,通过å¤å†™è¯¥æ¨¡å—的接å£ï¼Œåœ¨å»¶è¿Ÿä»»åŠ¡è§¦å‘的时候,系统会通过接å£å›žè°ƒåº”用,开å‘者在回调接å£é‡Œé¢å¯ä»¥å¤„ç†è‡ªå·±çš„任务逻辑。 ->  **说明:** -> 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> **说明:** +> +> - 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> - 本模å—接å£ä»…å¯åœ¨Stage模型下使用。 ## å¯¼å…¥æ¨¡å— -``` +```ts import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' ``` @@ -24,13 +26,13 @@ onWorkStart(work: workScheduler.WorkInfo): void **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---- | --------------------- | ---- | -------------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---- | ---------------------------------------- | ---- | -------------- | | work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示è¦æ·»åŠ 到执行队列的工作。 | **示例:** - ``` + ```ts export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { onWorkStart(workInfo) { console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); @@ -48,14 +50,14 @@ onWorkStop(work: workScheduler.WorkInfo): void **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---- | --------------------- | ---- | -------------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---- | ---------------------------------------- | ---- | -------------- | | work | [workScheduler.WorkInfo](js-apis-workScheduler.md#workinfo) | 是 | 指示è¦æ·»åŠ 到执行队列的工作。 | **示例:** - ``` + ```ts export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { onWorkStop(workInfo) { console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index 8b00de96a429eff67462bc5d2cdaf7bb5d447ecc..f834060bd898647d06fc810281923bde08a42fd7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -36,7 +36,7 @@ class MainAbility extends Ability { startAbility(want: Want, callback: AsyncCallback<void>): void -å¯åŠ¨Ability。 +å¯åŠ¨Ability(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -65,7 +65,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void -å¯åŠ¨Ability。 +å¯åŠ¨Ability(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -98,7 +98,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& startAbility(want: Want, options?: StartOptions): Promise<void>; -å¯åŠ¨Ability。通过Promise返回结果。 +å¯åŠ¨Ability(promiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -139,7 +139,7 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void; -å¯åŠ¨Ability并在结æŸçš„时候返回执行结果。 +å¯åŠ¨Ability并在结æŸçš„时候返回执行结果(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -167,7 +167,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; -å¯åŠ¨Ability并在结æŸçš„时候返回执行结果。 +å¯åŠ¨Ability并在结æŸçš„时候返回执行结果(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -200,7 +200,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>; -å¯åŠ¨Ability并在结æŸçš„时候返回执行结果。 +å¯åŠ¨Ability并在结æŸçš„时候返回执行结果(promiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -248,7 +248,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | callback | AsyncCallback\<AbilityResult\> | 是 | å¯åŠ¨Ability的回调函数,返回Ability结果。 | **示例:** @@ -284,7 +284,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | [StartOptions](js-apis-application-StartOptions.md) | 是 | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | | callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | @@ -306,11 +306,11 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp ``` - ## AbilityContext.startAbilityForResultWithAccount +## AbilityContext.startAbilityForResultWithAccount startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<AbilityResult\>; -å¯åŠ¨ä¸€ä¸ªAbility并在该Abilityå¸å·é”€æ¯æ—¶è¿”回执行结果(callbackå½¢å¼ï¼‰ã€‚ +å¯åŠ¨ä¸€ä¸ªAbility并在该Abilityå¸å·é”€æ¯æ—¶è¿”回执行结果(promiseå½¢å¼ï¼‰ã€‚ **需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS @@ -323,7 +323,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | [StartOptions](js-apis-application-StartOptions.md) | å¦ | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | **返回值:** @@ -352,13 +352,277 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO console.log('---------- startAbilityForResultWithAccount fail, err: -----------', err); }) ``` +## AbilityContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(callbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want, (err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## AbilityContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want): Promise\<void>; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want) + .then((data) => { + console.log('---------- startServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }) + ``` +## AbilityContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(callbackå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## AbilityContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(Promiseå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` +## AbilityContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want, (err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## AbilityContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want): Promise\<void>; + +åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want) + .then((data) => { + console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## AbilityContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +使用å¸æˆ·åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## AbilityContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +使用å¸æˆ·åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` ## AbilityContext.terminateSelf terminateSelf(callback: AsyncCallback<void>): void; -åœæ¢Ability自身。 +åœæ¢Ability自身(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -381,7 +645,7 @@ terminateSelf(callback: AsyncCallback<void>): void; terminateSelf(): Promise<void>; -åœæ¢Ability自身。通过Promise返回结果。 +åœæ¢Ability自身(promiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -406,7 +670,7 @@ terminateSelf(): Promise<void>; terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; -åœæ¢Ability,并返回给调用startAbilityForResult 接å£è°ƒç”¨æ–¹çš„相关信æ¯ã€‚ +åœæ¢Ability,并返回给调用startAbilityForResult 接å£è°ƒç”¨æ–¹çš„相关信æ¯ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -435,7 +699,7 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi terminateSelfWithResult(parameter: AbilityResult): Promise<void>; -åœæ¢Ability,并返回给调用startAbilityForResult 接å£ç›¸å…³ä¿¡æ¯ã€‚ +åœæ¢Ability,并返回给调用startAbilityForResult 接å£è°ƒç”¨æ–¹çš„相关信æ¯ï¼ˆpromiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -468,7 +732,7 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; connectAbility(want: Want, options: ConnectOptions): number; -使用AbilityInfo.AbilityType.SERVICE模æ¿å°†å½“å‰èƒ½åŠ›è¿žæŽ¥åˆ°ä¸€ä¸ªèƒ½åŠ›ã€‚ +使用AbilityInfo.AbilityType.SERVICE模æ¿å°†å½“å‰Ability连接到一个Ability。 **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -509,7 +773,7 @@ connectAbility(want: Want, options: ConnectOptions): number; connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; -使用AbilityInfo.AbilityType.SERVICE模æ¿å’Œaccount将当å‰èƒ½åŠ›è¿žæŽ¥åˆ°ä¸€ä¸ªèƒ½åŠ›ã€‚ +使用AbilityInfo.AbilityType.SERVICE模æ¿å’Œaccount将当å‰Ability连接到一个Ability。 **需è¦æƒé™ï¼š** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS @@ -522,7 +786,7 @@ connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | å¦ | 远端对象实例。 | **返回值:** @@ -553,7 +817,7 @@ connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions disconnectAbility(connection: number): Promise\<void>; -å·²æˆåŠŸè¿žæŽ¥æŽ¥å£ã€‚ +æ–开连接(promiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -563,7 +827,7 @@ disconnectAbility(connection: number): Promise\<void>; | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| connection | number | 是 | 连接的能力的数å—代ç 。 | +| connection | number | 是 | 连接的Abilityçš„æ•°å—代ç 。 | **返回值:** @@ -586,7 +850,7 @@ disconnectAbility(connection: number): Promise\<void>; disconnectAbility(connection: number, callback:AsyncCallback\<void>): void; -å·²æˆåŠŸè¿žæŽ¥æŽ¥å£ã€‚ +æ–开连接(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -596,7 +860,7 @@ disconnectAbility(connection: number, callback:AsyncCallback\<void>): void; | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| connection | number | 是 | 连接的能力的数å—代ç 。 | +| connection | number | 是 | 连接的Abilityçš„æ•°å—代ç 。 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法。 | **示例:** @@ -666,7 +930,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | **示例:** @@ -701,7 +965,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。| | options | [StartOptions](js-apis-application-StartOptions.md) | å¦ | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | | callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | @@ -740,7 +1004,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | [StartOptions](js-apis-application-StartOptions.md) | å¦ | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | **示例:** @@ -768,7 +1032,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; -拉起弹窗请求用户授æƒã€‚ +拉起弹窗请求用户授æƒï¼ˆcallbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -794,7 +1058,7 @@ requestPermissionsFromUser(permissions: Array<string>, requestCallback: As requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>; -拉起弹窗请求用户授æƒã€‚通过Promise返回结果。 +拉起弹窗请求用户授æƒï¼ˆpromiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -827,7 +1091,7 @@ requestPermissionsFromUser(permissions: Array<string>) : Promise<Permis setMissionLabel(label: string, callback:AsyncCallback<void>): void; -设置ability在任务ä¸æ˜¾ç¤ºçš„å称。 +设置ability在任务ä¸æ˜¾ç¤ºçš„å称(callbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -851,7 +1115,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; setMissionLabel(label: string): Promise<void> -设置ability在任务ä¸æ˜¾ç¤ºçš„å称。 +设置ability在任务ä¸æ˜¾ç¤ºçš„å称(promiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -880,7 +1144,7 @@ setMissionLabel(label: string): Promise<void> setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void; -设置当å‰abilityçš„ä»»åŠ¡æ ‡ç¾ã€‚ +设置当å‰ability在任务ä¸æ˜¾ç¤ºçš„å›¾æ ‡ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -890,7 +1154,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void; | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| icon | image.PixelMap | 是 | 在最近的任务ä¸æ˜¾ç¤ºçš„èƒ½åŠ›å›¾æ ‡ã€‚ | +| icon | image.PixelMap | 是 | 在最近的任务ä¸æ˜¾ç¤ºçš„abilityå›¾æ ‡ã€‚ | | callback | AsyncCallback\<void> | 是 | 指定的回调函数的结果。 | **示例:** @@ -922,7 +1186,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void; setMissionIcon(icon: image.PixelMap): Promise\<void>; -设置当å‰abilityçš„ä»»åŠ¡æ ‡ç¾ã€‚ +设置当å‰ability在任务ä¸æ˜¾ç¤ºçš„å›¾æ ‡ï¼ˆpromiseå½¢å¼ï¼‰ã€‚ **系统能力**:SystemCapability.Ability.AbilityRuntime.Core @@ -932,7 +1196,7 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>; | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| icon | image.PixelMap | 是 | 在最近的任务ä¸æ˜¾ç¤ºçš„èƒ½åŠ›å›¾æ ‡ã€‚ | +| icon | image.PixelMap | 是 | 在最近的任务ä¸æ˜¾ç¤ºçš„abilityå›¾æ ‡ã€‚ | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md b/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md index 12d235ff4d1f2fce3a3ebc99ddc8ea270a57867b..0eb99bb244a381fb2391f073bf9befd0421a0d92 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -1,6 +1,6 @@ # wantConstant -wantConstant模å—æä¾›wantä¸actionå’Œentityçš„æƒé™åˆ—表的能力,包括系统公共事件å®ï¼Œç³»ç»Ÿå…¬å…±äº‹ä»¶å称ç‰ã€‚ +wantConstant模å—æä¾›wantä¸æ“作want常数和解释Flags说明的能力。 > **说明:** > @@ -20,32 +20,34 @@ wantæ“作的常数。 | å称 | 值 | æè¿° | | ------------ | ------------------ | ---------------------- | -| ACTION_HOME | ohos.want.action.home | 指示返回原点的æ“作。 | -| ACTION_DIAL | ohos.want.action.dial | 指示å¯åŠ¨æ˜¾ç¤ºå°é”®ç›˜çš„页é¢åŠŸèƒ½çš„æ“作 | -| ACTION_SEARCH | ohos.want.action.search | 指示å¯åŠ¨é¡µé¢æœç´¢åŠŸèƒ½çš„æ“作。 | -| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | 指示å¯åŠ¨æä¾›æ— çº¿ç½‘ç»œè®¾ç½®çš„é¡µé¢åŠŸèƒ½çš„æ“作,例如,Wi-Fi选项。 | -| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | 指示å¯åŠ¨ç®¡ç†å·²å®‰è£…应用程åºçš„页é¢åŠŸèƒ½çš„æ“作。 | -| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | 指示å¯åŠ¨æ˜¾ç¤ºæŒ‡å®šåº”用程åºè¯¦ç»†ä¿¡æ¯çš„页é¢åŠŸèƒ½çš„æ“作。 | -| ACTION_SET_ALARM | ohos.want.action.setAlarm | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥è®¾ç½®é—¹é’Ÿçš„æ“åšä½œã€‚ | -| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | 指示å¯åŠ¨æ˜¾ç¤ºæ‰€æœ‰è¦æŠ¥çš„页é¢åŠŸèƒ½çš„æ“作时钟。 | -| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | 指示å¯åŠ¨ç”¨äºŽä½¿é—¹é’Ÿç¡çœ 的页é¢åŠŸèƒ½çš„æ“作。 | -| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | 指示å¯åŠ¨åˆ 除闹钟的页é¢åŠŸèƒ½çš„æ“作。 | -| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥å…³é—计时器的æ“作。 | -| ACTION_SEND_SMS | ohos.want.action.sendSms | 指示å¯åŠ¨å‘é€sms的页é¢åŠŸèƒ½çš„æ“作。 | -| ACTION_CHOOSE | ohos.want.action.choose | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥æ‰“å¼€è”系人或图片的æ“作。 | -| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | 指示å¯åŠ¨é¡µé¢æ‹ç…§åŠŸèƒ½çš„æ“作。 | -| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥æ‹æ‘„视频的æ“作。 | -| ACTION_SELECT | ohos.want.action.select | 指示显示应用程åºé€‰æ‹©å¯¹è¯æ¡†çš„æ“作。 | -| ACTION_SEND_DATA | ohos.want.action.sendData | 指示å‘é€å•ä¸ªæ•°æ®è®°å½•çš„æ“作。 | +| ACTION_HOME | ohos.want.action.home | 指示返回原点的æ“作。 | +| ACTION_DIAL | ohos.want.action.dial | 指示å¯åŠ¨æ˜¾ç¤ºå°é”®ç›˜çš„页é¢åŠŸèƒ½çš„æ“作 | +| ACTION_SEARCH | ohos.want.action.search | 指示å¯åŠ¨é¡µé¢æœç´¢åŠŸèƒ½çš„æ“作。 | +| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | 指示å¯åŠ¨æä¾›æ— çº¿ç½‘ç»œè®¾ç½®çš„é¡µé¢åŠŸèƒ½çš„æ“作,例如,Wi-Fi选项。 | +| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | 指示å¯åŠ¨ç®¡ç†å·²å®‰è£…应用程åºçš„页é¢åŠŸèƒ½çš„æ“作。 | +| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | 指示å¯åŠ¨æ˜¾ç¤ºæŒ‡å®šåº”用程åºè¯¦ç»†ä¿¡æ¯çš„页é¢åŠŸèƒ½çš„æ“作。 | +| ACTION_SET_ALARM | ohos.want.action.setAlarm | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥è®¾ç½®é—¹é’Ÿçš„æ“åšä½œã€‚ | +| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | 指示å¯åŠ¨æ˜¾ç¤ºæ‰€æœ‰è¦æŠ¥çš„页é¢åŠŸèƒ½çš„æ“作时钟。 | +| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | 指示å¯åŠ¨ç”¨äºŽä½¿é—¹é’Ÿç¡çœ 的页é¢åŠŸèƒ½çš„æ“作。 | +| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | 指示å¯åŠ¨åˆ 除闹钟的页é¢åŠŸèƒ½çš„æ“作。 | +| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥å…³é—计时器的æ“作。 | +| ACTION_SEND_SMS | ohos.want.action.sendSms | 指示å¯åŠ¨å‘é€sms的页é¢åŠŸèƒ½çš„æ“作。 | +| ACTION_CHOOSE | ohos.want.action.choose | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥æ‰“å¼€è”系人或图片的æ“作。 | +| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | 指示å¯åŠ¨é¡µé¢æ‹ç…§åŠŸèƒ½çš„æ“作。 | +| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | 指示å¯åŠ¨é¡µé¢åŠŸèƒ½ä»¥æ‹æ‘„视频的æ“作。 | +| ACTION_SELECT | ohos.want.action.select | 指示显示应用程åºé€‰æ‹©å¯¹è¯æ¡†çš„æ“作。 | +| ACTION_SEND_DATA | ohos.want.action.sendData | 指示å‘é€å•ä¸ªæ•°æ®è®°å½•çš„æ“作。 | | ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | 指示å‘é€å¤šä¸ªæ•°æ®è®°å½•çš„æ“作。 | -| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | 指示请求媒体扫æ仪扫ææ–‡ä»¶å¹¶å°†æ–‡ä»¶æ·»åŠ åˆ°åª’ä½“åº“çš„æ“作。 | -| ACTION_VIEW_DATA | ohos.want.action.viewData | 指示查看数æ®çš„æ“作。 | -| ACTION_EDIT_DATA | ohos.want.action.editData | 指示编辑数æ®çš„æ“作。 | -| INTENT_PARAMS_INTENT | ability.want.params.INTENT | 指示将使用连接选å–显示的选项的æ“作。 | -| INTENT_PARAMS_TITLE | ability.want.params.TITLE | 指示与连接选å–显示的选项一起使用时的å—符åºåˆ—对è¯æ¡†æ ‡é¢˜ã€‚ | +| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | 指示请求媒体扫æ仪扫ææ–‡ä»¶å¹¶å°†æ–‡ä»¶æ·»åŠ åˆ°åª’ä½“åº“çš„æ“作。 | +| ACTION_VIEW_DATA | ohos.want.action.viewData | 指示查看数æ®çš„æ“作。 | +| ACTION_EDIT_DATA | ohos.want.action.editData | 指示编辑数æ®çš„æ“作。 | +| INTENT_PARAMS_INTENT | ability.want.params.INTENT | 指示用行为选择器æ¥å±•ç¤ºé€‰æ‹©çš„æ“作。 | +| INTENT_PARAMS_TITLE | ability.want.params.TITLE | 指示与行为选择器一起使用时的å—符åºåˆ—对è¯æ¡†æ ‡é¢˜ã€‚ | | ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | 指示选择文件的æ“作。 | -| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | 指示与连接å‘é€æ•°æ®ä¸€èµ·ä½¿ç”¨æ—¶ï¼ŒåŒ…å«ä¸Žæ„图相关è”çš„æ•°æ®æµçš„URI。 | +| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | 指示å‘é€æ•°æ®æ—¶ä¸Žç›®æ ‡å…³è”çš„æ•°æ®æµçš„URI | | ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | 指示æä¾›oauthæœåŠ¡çš„æ“作。 | +| ACTION_MARKER_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | 表示从应用程åºå¸‚场下载应用程åºçš„çš„æ“作。<br>**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | + ## wantConstant.Entity @@ -55,11 +57,11 @@ want实体的常数。 | å称 | 值 | æè¿° | | ------------ | ------------------ | ---------------------- | -| ENTITY_DEFAULT | entity.system.default | 指示默认实体,如果未指定该实体,则使用该实体。 | -| ENTITY_HOME | entity.system.homel | 指示主å±å¹•å®žä½“。 | -| ENTITY_VOICE | entity.system.voice | 表示è¯éŸ³äº¤äº’实体。 | -| ENTITY_BROWSABLE | entity.system.browsable | 指示æµè§ˆå™¨ç±»åˆ«ã€‚ | -| ENTITY_VIDEO | entity.system.video | 指示视频类别。 | +| ENTITY_DEFAULT | entity.system.default | 指示默认实体,如果未指定该实体,则使用该实体。 | +| ENTITY_HOME | entity.system.home | 指示主å±å¹•å®žä½“。 | +| ENTITY_VOICE | entity.system.voice | 表示è¯éŸ³äº¤äº’实体。 | +| ENTITY_BROWSABLE | entity.system.browsable | 指示æµè§ˆå™¨ç±»åˆ«ã€‚ | +| ENTITY_VIDEO | entity.system.video | 指示视频类别。 | ## wantConstant.Flags @@ -76,11 +78,11 @@ Flags说明。 | FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是å¦å¯ä»¥å°†æœ¬åœ°è®¾å¤‡ä¸Šçš„功能è¿ç§»åˆ°è¿œç¨‹è®¾å¤‡ã€‚ | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是å¦å±žäºŽOHOS。 | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是å¦å¯åŠ¨æŸä¸ªèƒ½åŠ›ã€‚ | -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上å¯èƒ½æŒä¹…化的授æƒã€‚<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照å‰ç¼€åŒ¹é…çš„æ–¹å¼éªŒè¯URIæƒé™ã€‚<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上å¯èƒ½æŒä¹…化的授æƒã€‚<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照å‰ç¼€åŒ¹é…çš„æ–¹å¼éªŒè¯URIæƒé™ã€‚<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支æŒåˆ†å¸ƒå¼è°ƒåº¦ç³»ç»Ÿä¸çš„多设备å¯åŠ¨ã€‚ | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | æŒ‡ç¤ºæ— è®ºä¸»æœºåº”ç”¨ç¨‹åºæ˜¯å¦å·²å¯åŠ¨ï¼Œéƒ½å°†å¯åŠ¨ä½¿ç”¨æœåŠ¡æ¨¡æ¿çš„功能。 | -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示è¿ç§»æ˜¯å¯æ‹‰å›žçš„。<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示è¿ç§»æ˜¯å¯æ‹‰å›žçš„。<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能。 | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用åŽå°æ¨¡å¼å®‰è£…该功能。 | | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的æ“作。å¯ä»¥ä¸ºä¼ 递给 **[ohos.app.Context](js-apis-ability-context.md)** ä¸**startAbility**方法的**Want**设置æ¤æ ‡å¿—,并且必须与**flag_ABILITY_NEW_MISSION**一起使用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index af042fbd6f43103babce2fea8e620354d3fb547a..122835b12e2fece6d2d17e30fba9b8d06cc93ef8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -104,7 +104,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grantæƒé™ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.GRANT_SENSITIVE_PERMISSIONS @@ -142,7 +142,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grantæƒé™ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.GRANT_SENSITIVE_PERMISSIONS @@ -178,7 +178,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grantæƒé™ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS @@ -216,7 +216,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grantæƒé™ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS @@ -252,7 +252,7 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g 获å–指定应用的指定æƒé™çš„flag,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.GET_SENSITIVE_PERMISSIONS or ohos.permission.GRANT_SENSITIVE_PERMISSIONS or ohos.permission.REVOKE_SENSITIVE_PERMISSIONS diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md index 33b9ff847ac76c6f00d67e2734547894aa287344..5f9195932a5a290805d973bc0780bd30947c057b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -25,9 +25,9 @@ abilitymanager.getAbilityRunningInfos((err,data) => { | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | -------- | -------- | -------- | -------- | -------- | -| ability | ElementName | 是 | å¦ | Ability匹é…ä¿¡æ¯ | -| pid | number | 是 | å¦ | 进程ID。 | -| uid | number | 是 | å¦ | 用户ID。 | -| processName | string | 是 | å¦ | 进程å称。 | -| startTime | number | 是 | å¦ | Abilityå¯åŠ¨æ—¶é—´ã€‚ | -| abilityState | [abilityManager.AbilityState](js-apis-abilityManager.md#abilityState) | 是 | å¦ | Ability状æ€ã€‚ | \ No newline at end of file +| ability | ElementName | 是 | å¦ | Ability匹é…ä¿¡æ¯ | +| pid | number | 是 | å¦ | 进程ID。 | +| uid | number | 是 | å¦ | 用户ID。 | +| processName | string | 是 | å¦ | 进程å称。 | +| startTime | number | 是 | å¦ | Abilityå¯åŠ¨æ—¶é—´ã€‚ | +| abilityState | [abilityManager.AbilityState](js-apis-application-abilityManager.md#abilitystate) | 是 | å¦ | Ability状æ€ã€‚ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md index a9c61d030a405cc3c6d4dd1eb574f733a4936303..affa083e8924ad08aaf674be55f9acbaf455b1fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md @@ -12,7 +12,7 @@ AccessibilityExtensionContext模å—æä¾›æ‰©å±•çš„ä¸Šä¸‹æ–‡çš„èƒ½åŠ›ï¼ŒåŒ…æ‹¬å… ## å¯¼å…¥æ¨¡å— ```js -import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExtensionAbility' +import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' ``` ## FocusDirection @@ -21,13 +21,13 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | -| up | 表示å‘上查询。 | -| down | 表示å‘上查询。 | -| left | 表示å‘左查询。 | -| right | 表示å‘å³æŸ¥è¯¢ã€‚ | -| forward | 表示å‘å‰æŸ¥è¯¢ã€‚ | +| å称 | æè¿° | +| -------- | ------- | +| up | 表示å‘上查询。 | +| down | 表示å‘上查询。 | +| left | 表示å‘左查询。 | +| right | 表示å‘å³æŸ¥è¯¢ã€‚ | +| forward | 表示å‘å‰æŸ¥è¯¢ã€‚ | | backward | 表示å‘åŽæŸ¥è¯¢ã€‚ | ## FocusType @@ -36,10 +36,10 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | +| å称 | æè¿° | +| ------------- | ----------- | | accessibility | è¡¨ç¤ºæ— éšœç¢çš„焦点类型。 | -| normal | 表示普通的焦点类型。 | +| normal | 表示普通的焦点类型。 | ## Rect @@ -49,12 +49,12 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte ### å‚æ•° -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| ------ | -------- | ---- | ---- | ------------------ | -| left | number | 是 | å¦ | 矩形区域的左边界。 | -| top | number | 是 | å¦ | 矩形区域的上边界。 | -| width | number | 是 | å¦ | 矩形区域的宽度。 | -| height | number | 是 | å¦ | 矩形区域的高度。 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| ------ | ------ | ---- | ---- | --------- | +| left | number | 是 | å¦ | 矩形区域的左边界。 | +| top | number | 是 | å¦ | 矩形区域的上边界。 | +| width | number | 是 | å¦ | 矩形区域的宽度。 | +| height | number | 是 | å¦ | 矩形区域的高度。 | ## WindowType @@ -62,10 +62,10 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | +| å称 | æè¿° | +| ----------- | --------- | | application | 表示应用窗å£ç±»åž‹ã€‚ | -| system | 表示系统窗å£ç±»åž‹ã€‚ | +| system | 表示系统窗å£ç±»åž‹ã€‚ | ## AccessibilityExtensionContext.setEventTypeFilter @@ -77,14 +77,14 @@ setEventTypeFilter(type: Array<accessibility.EventType>): Promise\<boolean>; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| type | Array<[EventType](js-apis-accessibility.md#EventType)> | 是 | 关注的事件类型。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ---- | ---------------------------------------- | ---- | -------- | +| type | Array<[EventType](js-apis-accessibility.md#EventType)> | 是 | 关注的事件类型。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ---------------------- | --------------------- | | Promise<boolean> | Promise对象。返回当å‰è®¾ç½®æ˜¯å¦æˆåŠŸã€‚ | **示例:** @@ -103,14 +103,14 @@ setTargetBundleName(targetNames: Array\<string>): Promise\<boolean>; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| targetNames | Array<string> | 是 | å…³æ³¨çš„ç›®æ ‡åŒ…å。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ----------- | ------------------- | ---- | -------- | +| targetNames | Array<string> | 是 | å…³æ³¨çš„ç›®æ ‡åŒ…å。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ---------------------- | --------------------- | | Promise<boolean> | Promise对象。返回当å‰è®¾ç½®æ˜¯å¦æˆåŠŸã€‚ | **示例:** @@ -129,14 +129,14 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| isAccessibilityFocus | boolean | å¦ | 获å–的是å¦æ˜¯æ— éšœç¢ç„¦ç‚¹å…ƒç´ ,默认为å¦ã€‚ | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------------------- | ------- | ---- | ------------------- | +| isAccessibilityFocus | boolean | å¦ | 获å–的是å¦æ˜¯æ— éšœç¢ç„¦ç‚¹å…ƒç´ ,默认为å¦ã€‚ | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ----------------------------------- | ---------------------- | | Promise<AccessibilityElement> | Promise对象。返回当å‰å¯¹åº”çš„ç„¦ç‚¹å…ƒç´ ã€‚ | **示例:** @@ -157,14 +157,14 @@ getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| windowId | number | å¦ | 指定获å–æ ¹èŠ‚ç‚¹å…ƒç´ çš„çª—å£ï¼ŒæœªæŒ‡å®šåˆ™ä»Žå½“å‰æ´»è·ƒçª—å£èŽ·å–。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ------ | ---- | --------------------------- | +| windowId | number | å¦ | 指定获å–æ ¹èŠ‚ç‚¹å…ƒç´ çš„çª—å£ï¼ŒæœªæŒ‡å®šåˆ™ä»Žå½“å‰æ´»è·ƒçª—å£èŽ·å–。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ----------------------------------- | ----------------------- | | Promise<AccessibilityElement> | Promise对象。返回当å‰å¯¹åº”çš„æ ¹èŠ‚ç‚¹å…ƒç´ ã€‚ | **示例:** @@ -185,14 +185,14 @@ getWindows(displayId?: number): Promise<Array\<AccessibilityElement>>; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| displayId | number | å¦ | 指定获å–窗å£ä¿¡æ¯çš„å±å¹•ï¼ŒæœªæŒ‡å®šåˆ™ä»Žé»˜è®¤ä¸»å±å¹•èŽ·å–。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| --------- | ------ | ---- | ------------------------- | +| displayId | number | å¦ | 指定获å–窗å£ä¿¡æ¯çš„å±å¹•ï¼ŒæœªæŒ‡å®šåˆ™ä»Žé»˜è®¤ä¸»å±å¹•èŽ·å–。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ------------------------ | | Promise<Array<AccessibilityElement>> | Promise对象。返回当å‰å¯¹åº”的窗å£åˆ—表信æ¯ã€‚ | **示例:** @@ -213,15 +213,15 @@ gestureInject(gesturePath: GesturePath, listener: Callback\<boolean>): Promise\< **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| gesturePath | [GesturePath](js-apis-application-AccessibilityExtensionAbility.md#GesturePath) | 是 | 表示手势的路径信æ¯ã€‚ | -| listener | Callback<boolean> | 是 | 表示注入手势执行结果的回调。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ----------- | ---------------------------------------- | ---- | -------------- | +| gesturePath | [GesturePath](js-apis-application-AccessibilityExtensionAbility.md#GesturePath) | 是 | 表示手势的路径信æ¯ã€‚ | +| listener | Callback<boolean> | 是 | 表示注入手势执行结果的回调。 | **返回值:** -| 类型 | 说明 | -| -------------------------------- | --------------------------------------- | +| 类型 | 说明 | +| ---------------------- | ---------------------- | | Promise<boolean> | Promise对象。返回注入手势的调用结果。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md index 401e5ac41004c10d47b0a4c81916b1a4294ef40e..0d8938368963b9292500935644d9da40895e6260 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md @@ -15,7 +15,7 @@ import accessibility from '@ohos.accessibility'; 辅助应用状æ€ç±»åž‹ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -27,7 +27,7 @@ import accessibility from '@ohos.accessibility'; æ— éšœç¢è¾…助应用类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -42,7 +42,7 @@ import accessibility from '@ohos.accessibility'; 辅助应用信æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core ### 属性 @@ -61,7 +61,7 @@ import accessibility from '@ohos.accessibility'; 应用所支æŒçš„ç›®æ ‡åŠ¨ä½œã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -86,7 +86,7 @@ import accessibility from '@ohos.accessibility'; 辅助应用能力类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -100,7 +100,7 @@ import accessibility from '@ohos.accessibility'; å—幕å—体边缘类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Hearing +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Hearing | å称 | æè¿° | | -------- | -------- | @@ -114,7 +114,7 @@ import accessibility from '@ohos.accessibility'; å—幕å—体。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Hearing +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Hearing | å称 | æè¿° | | -------- | -------- | @@ -131,7 +131,7 @@ import accessibility from '@ohos.accessibility'; å—å¹•é£Žæ ¼ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Hearing +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Hearing | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | -------- | -------- | -------- | -------- | -------- | @@ -146,6 +146,8 @@ import accessibility from '@ohos.accessibility'; å—幕é…置。 +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.BarrierFree.Accessibility.Hearing + ### 属性 | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | @@ -153,26 +155,22 @@ import accessibility from '@ohos.accessibility'; | enabled | boolean | 是 | å¦ | 表示是å¦å¯ç”¨å—幕é…置。 | | style | [CaptionsStyle](#captionsstyle8) | 是 | å¦ | 表示å—å¹•é£Žæ ¼ã€‚ | -### 方法 - 下列 API 示例ä¸éƒ½éœ€è¦ä½¿ç”¨ [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) èŽ·å– captionsManager 实例,å†é€šè¿‡æ¤å®žä¾‹è°ƒç”¨å¯¹åº”的方法。 -#### on('enableChange') +### on('enableChange') on(type: 'enableChange', callback: Callback<boolean>): void; 注册å—幕é…ç½®å¯ç”¨çš„监å¬å‡½æ•°ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing - -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监å¬å—幕é…ç½®å¯ç”¨çŠ¶æ€ã€‚ | | callback | Callback<boolean> | 是 | 回调函数,在å¯ç”¨çŠ¶æ€å˜åŒ–时将状æ€é€šè¿‡æ¤å‡½æ•°è¿›è¡Œé€šçŸ¥ã€‚ | -- 示例 +- **示例:** ```typescript captionsManager.on('enableChange',(data) => { @@ -180,22 +178,20 @@ on(type: 'enableChange', callback: Callback<boolean>): void; }) ``` -#### on('styleChange') +### on('styleChange') on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; 注册å—å¹•é£Žæ ¼å˜åŒ–的监å¬å‡½æ•°ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing - -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监å¬å—å¹•é£Žæ ¼å˜åŒ–。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在å—å¹•é£Žæ ¼å˜åŒ–时通过æ¤å‡½æ•°è¿›è¡Œé€šçŸ¥ã€‚ | -- 示例 +- **示例:** ```typescript captionsManager.on('styleChange',(data) => { @@ -203,43 +199,39 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; }) ``` -#### off('enableChange') +### off('enableChange') off(type: 'enableChange', callback?: Callback<boolean>): void; 移除å—幕é…ç½®å¯ç”¨çš„监å¬å‡½æ•°ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing - -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监å¬å—幕é…ç½®å¯ç”¨çŠ¶æ€ã€‚ | | callback | Callback<boolean> | å¦ | 回调函数,在å¯ç”¨çŠ¶æ€å˜åŒ–时将状æ€é€šè¿‡æ¤å‡½æ•°è¿›è¡Œé€šçŸ¥ã€‚ | -- 示例 +- **示例:** ```typescript captionsManager.off('enableChange') ``` -#### off('styleChange') +### off('styleChange') off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; 移除å—å¹•é£Žæ ¼å˜åŒ–的监å¬å‡½æ•°ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing - -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | å—å¹•é£Žæ ¼å˜åŒ–。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | å¦ | 回调函数,在å—å¹•é£Žæ ¼å˜åŒ–时通过æ¤å‡½æ•°è¿›è¡Œé€šçŸ¥ã€‚ | -- 示例 +- **示例:** ```typescript captionsManager.off('styleChange') @@ -249,7 +241,7 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; ç•Œé¢å˜æ›´äº‹ä»¶ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core ### 属性 @@ -270,21 +262,19 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; | endIndex | number | 是 | 是 | ç”»é¢æ˜¾ç¤ºæ¡ç›®çš„结æŸåºå·ã€‚ | | itemCount | number | 是 | 是 | æ¡ç›®æ€»æ•°ã€‚ | -### 方法 - -#### constructor +### constructor constructor(jsonObject) æž„é€ å‡½æ•°ã€‚ -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | jsonObject | string | 是 | 创建对象所需è¦çš„ JSON æ ¼å¼å—符串。 | -- 示例 +- **示例:** ```typescript let eventInfo = new accessibility.EventInfo({"type":"click","bundleName":"com.example.MyApplication","triggerAction":"click"}) @@ -294,7 +284,7 @@ constructor(jsonObject) æ— éšœç¢äº‹ä»¶ç±»åž‹ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -314,7 +304,7 @@ constructor(jsonObject) æ–‡æœ¬æ— éšœç¢å¯¼èˆªç§»åŠ¨ç²’度。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -328,7 +318,7 @@ constructor(jsonObject) 窗å£å˜åŒ–类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.BarrierFree.Accessibility.Core | å称 | æè¿° | | -------- | -------- | @@ -344,22 +334,22 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A 查询辅助应用列表。 -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状æ€ã€‚ | -- 返回值: +- **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 返回辅助应用信æ¯åˆ—表。 | -- 示例 +- **示例:** ```typescript accessibility.getAbilityLists("spoken", "enable") @@ -387,9 +377,9 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn 查询辅助应用列表。 -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -397,7 +387,7 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状æ€ã€‚ | | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信æ¯åˆ—表。 | -- 示例 +- **示例:** ```typescript accessibility.getAbilityLists("visual", "enable", (err, data) => { @@ -426,15 +416,15 @@ getCaptionsManager(): CaptionsManager 获å–æ— éšœç¢å—幕é…置。 -**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing +**系统能力**:SystemCapability.BarrierFree.Accessibility.Hearing -- 返回值: +- **返回值:** | 类型 | 说明 | | -------- | -------- | | [CaptionsManager](#captionsmanager8) | æ— éšœç¢å—幕é…置管ç†ã€‚ | -- 示例 +- **示例:** ```typescript captionsManager = accessibility.getCaptionsManager() @@ -448,14 +438,14 @@ on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callbac **系统能力**:以下å„项对应的系统能力有所ä¸åŒï¼Œè¯¦è§ä¸‹è¡¨ã€‚ -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | type | string | 是 | 监å¬çš„事件类型。<br/>- type 为'accessibilityStateChange'时表示监å¬ç±»åž‹ä¸ºè¾…助功能å¯ç”¨çŠ¶æ€å˜åŒ–监å¬ï¼›<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Core<br/>- type 为'touchGuideStateChange'时表示监å¬ç±»åž‹ä¸ºè§¦æ‘¸æµè§ˆå¯ç”¨çŠ¶æ€å˜åŒ–监å¬ã€‚<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | type | string | 是 | 监å¬çš„事件类型。<br/>- type 为'accessibilityStateChange'时表示监å¬ç±»åž‹ä¸ºè¾…助功能å¯ç”¨çŠ¶æ€å˜åŒ–监å¬ï¼›<br/>**系统能力**:SystemCapability.BarrierFree.Accessibility.Core<br/>- type 为'touchGuideStateChange'时表示监å¬ç±»åž‹ä¸ºè§¦æ‘¸æµè§ˆå¯ç”¨çŠ¶æ€å˜åŒ–监å¬ã€‚<br/>**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision | | callback | Callback<boolean> | 是 | 回调函数,在å¯ç”¨çŠ¶æ€å˜åŒ–时将状æ€é€šè¿‡æ¤å‡½æ•°è¿›è¡Œé€šçŸ¥ã€‚ | -- 示例 +- **示例:** ```typescript accessibility.on('accessibilityStateChange',(data) => { @@ -471,14 +461,14 @@ off(type: ‘accessibilityStateChange ’ | ‘touchGuideStateChange’, callbac **系统能力**:以下å„项对应的系统能力有所ä¸åŒï¼Œè¯¦è§ä¸‹è¡¨ã€‚ -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | type | string | å¦ | 监å¬çš„事件类型。<br/>- type 为'accessibilityStateChange'时表示监å¬ç±»åž‹ä¸ºè¾…助功能å¯ç”¨çŠ¶æ€å˜åŒ–监å¬ï¼›<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Core<br/>- type 为'touchGuideStateChange'时表示监å¬ç±»åž‹ä¸ºè§¦æ‘¸æµè§ˆå¯ç”¨çŠ¶æ€å˜åŒ–监å¬ã€‚<br/>**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | type | string | å¦ | 监å¬çš„事件类型。<br/>- type 为'accessibilityStateChange'时表示监å¬ç±»åž‹ä¸ºè¾…助功能å¯ç”¨çŠ¶æ€å˜åŒ–监å¬ï¼›<br/>**系统能力**:SystemCapability.BarrierFree.Accessibility.Core<br/>- type 为'touchGuideStateChange'时表示监å¬ç±»åž‹ä¸ºè§¦æ‘¸æµè§ˆå¯ç”¨çŠ¶æ€å˜åŒ–监å¬ã€‚<br/>**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision | | callback | Callback<boolean> | å¦ | è¦å–消的监å¬å›žè°ƒå‡½æ•°ã€‚ | -- 示例 +- **示例:** ```typescript accessibility.off('accessibilityStateChange',(data) => { @@ -492,15 +482,15 @@ isOpenAccessibility(): Promise<boolean> 判æ–是å¦å¯ç”¨äº†è¾…助功能。 -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- 返回值: +- **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 如果辅助功能已å¯ç”¨ï¼Œåˆ™è¿”回 trueï¼›å¦åˆ™è¿”回 false。 | -- 示例 +- **示例:** ```typescript accessibility.isOpenAccessibility() @@ -517,15 +507,15 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void 判æ–是å¦å¯ç”¨äº†è¾…助功能。 -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- å‚æ•° +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已å¯ç”¨ï¼Œåˆ™è¿”回 trueï¼›å¦åˆ™è¿”回 false。 | -- 示例 +- **示例:** ```typescript accessibility.isOpenAccessibility((err, data) => { @@ -543,15 +533,15 @@ isOpenTouchGuide(): Promise<boolean> 判æ–触摸æµè§ˆæ¨¡å¼æ˜¯å¦å¼€å¯ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision -- 返回值: +- **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<boolean> | 如果触摸æµè§ˆæ¨¡å¼å·²å¼€å¯ï¼Œåˆ™è¿”回 trueï¼›å¦åˆ™è¿”回 false。 | -- 示例 +- **示例:** ```typescript accessibility.isOpenTouchGuide() @@ -568,15 +558,15 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void 判æ–触摸æµè§ˆæ¨¡å¼æ˜¯å¦å¼€å¯ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Vision -- å‚æ•° +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸æµè§ˆæ¨¡å¼å·²å¼€å¯ï¼Œåˆ™è¿”回 trueï¼›å¦åˆ™è¿”回 false。 | -- 示例 +- **示例:** ```typescript accessibility.isOpenTouchGuide((err, data) => { @@ -594,21 +584,21 @@ sendEvent(event: EventInfo): Promise<void> å‘é€æ— éšœç¢äº‹ä»¶ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | æ— éšœç¢äº‹ä»¶å¯¹è±¡ã€‚ | -- 返回值: +- **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise<void> | 以 Promise å½¢å¼è¿”回结果,如果å‘é€æ— éšœç¢äº‹ä»¶æˆåŠŸï¼Œåˆ™ data 有数æ®è¿”回;如果å‘é€æ— éšœç¢äº‹ä»¶å¤±è´¥ï¼Œåˆ™ err 有数æ®è¿”回。 | -- 示例 +- **示例:** ```typescript accessibility.sendEvent(this.eventInfo) @@ -625,16 +615,16 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void å‘é€æ— éšœç¢äº‹ä»¶ã€‚ -**系统能力**:SystemCapability.Barrierfree.Accessibility.Core +**系统能力**:SystemCapability.BarrierFree.Accessibility.Core -- å‚数: +- **å‚数:** | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果å‘é€æ— éšœç¢äº‹ä»¶æˆåŠŸï¼Œåˆ™ AsyncCallback ä¸ data 有数æ®è¿”回;如果å‘é€æ— éšœç¢äº‹ä»¶å¤±è´¥ï¼Œåˆ™ AsyncCallback ä¸ err 有数æ®è¿”回。 | -- 示例 +- **示例:** ```typescript accessibility.sendEvent(this.eventInfo,(err, data) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-animator.md b/zh-cn/application-dev/reference/apis/js-apis-animator.md index 35c8f7ce114b4f83f6b4287244696e3c9f652b4d..54966570a6c4af2578a2dc3d250edd033c4cba16 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-animator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-animator.md @@ -3,13 +3,13 @@ 本模å—æ供组件动画效果,包括定义动画ã€å¯åŠ¨åŠ¨ç”»å’Œä»¥ç›¸å的顺åºæ’放动画ç‰ã€‚ > **说明:** -> +> > 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— -``` +```js import animator from '@ohos.animator'; ``` @@ -23,18 +23,18 @@ createAnimator(options: AnimatorOptions): AnimatorResult **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。| +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------------------- | ------------- | | [AnimatorResult](#animatorresult) | Animator结果接å£ã€‚ | **示例:** - ``` + ```html <!-- hml --> <div class="container"> <div class="Animation" style="height: {{divHeight}}px; width: {{divWidth}}px; background-color: red;" onclick="Show"> @@ -42,7 +42,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult </div> ``` - ``` + ```js // js export default { data : { @@ -94,12 +94,12 @@ update(options: AnimatorOptions): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。| +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | ------- | +| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。 | **示例:** -``` +```js animator.update(options); ``` @@ -112,7 +112,7 @@ play(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.play(); ``` @@ -125,7 +125,7 @@ finish(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.finish(); ``` @@ -138,7 +138,7 @@ pause(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.pause(); ``` @@ -151,7 +151,7 @@ cancel(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.cancel(); ``` @@ -164,7 +164,7 @@ reverse(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.reverse(); ``` @@ -177,12 +177,12 @@ onframe: (progress: number) => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| progress | number | 是 | 动画的当å‰è¿›åº¦ã€‚| +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------ | ---- | -------- | +| progress | number | 是 | 动画的当å‰è¿›åº¦ã€‚ | **示例:** -``` +```js animator.onframe(); ``` @@ -195,7 +195,7 @@ onfinish: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.onfinish(); ``` @@ -208,7 +208,7 @@ oncancel: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.oncancel(); ``` @@ -221,7 +221,7 @@ onrepeat: () => void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** -``` +```js animator.onrepeat(); ``` @@ -231,13 +231,13 @@ animator.onrepeat(); **系统能力:** SystemCapability.ArkUI.ArkUI.Full -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| duration | number | 是 | 动画æ’放的时长,å•ä½æ¯«ç§’,默认为0。 | -| easing | string | 是 | 动画æ’值曲线,默认为'ease'。 | -| delay | number | 是 | 动画延时æ’放时长,å•ä½æ¯«ç§’,默认为0,å³ä¸å»¶æ—¶ã€‚ | -| fill | "none" \| "forwards" \| "backwards" \| "both" | 是 | 动画执行åŽæ˜¯å¦æ¢å¤åˆ°åˆå§‹çŠ¶æ€ï¼Œé»˜è®¤å€¼ä¸º"none"。动画执行åŽï¼ŒåŠ¨ç”»ç»“æŸæ—¶çš„状æ€ï¼ˆåœ¨æœ€åŽä¸€ä¸ªå…³é”®å¸§ä¸å®šä¹‰ï¼‰å°†ä¿ç•™ã€‚ | -| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | 是 | 动画æ’放模å¼ï¼Œé»˜è®¤å€¼"normal"。| -| iterations | number | 是 | 动画æ’放次数,默认值1。设置为0æ—¶ä¸æ’放,设置为-1æ—¶æ— é™æ¬¡æ’放。 | -| begin | number | 是 | 动画æ’值起点,默认为0。 | -| end | number | 是 | 动画æ’值终点,默认为1。 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ---------- | ---------------------------------------- | ---- | ---------------------------------------- | +| duration | number | 是 | 动画æ’放的时长,å•ä½æ¯«ç§’,默认为0。 | +| easing | string | 是 | 动画æ’值曲线,默认为'ease'。 | +| delay | number | 是 | 动画延时æ’放时长,å•ä½æ¯«ç§’,默认为0,å³ä¸å»¶æ—¶ã€‚ | +| fill | "none" \| "forwards" \| "backwards" \| "both" | 是 | 动画执行åŽæ˜¯å¦æ¢å¤åˆ°åˆå§‹çŠ¶æ€ï¼Œé»˜è®¤å€¼ä¸º"none"。动画执行åŽï¼ŒåŠ¨ç”»ç»“æŸæ—¶çš„状æ€ï¼ˆåœ¨æœ€åŽä¸€ä¸ªå…³é”®å¸§ä¸å®šä¹‰ï¼‰å°†ä¿ç•™ã€‚ | +| direction | "normal" \| "reverse" \| "alternate" \| "alternate-reverse" | 是 | 动画æ’放模å¼ï¼Œé»˜è®¤å€¼"normal"。 | +| iterations | number | 是 | 动画æ’放次数,默认值1。设置为0æ—¶ä¸æ’放,设置为-1æ—¶æ— é™æ¬¡æ’放。 | +| begin | number | 是 | 动画æ’值起点,默认为0。 | +| end | number | 是 | 动画æ’值终点,默认为1。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 6104eeb9f27dcf9c9da172d6eb6ead4d3f0ac77f..347fb90a3897cfd8b25d44c40574ad9869e3bee4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -89,7 +89,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) ### addAccount -addAccount(name: string, extraInfo: string): Promise<void> +addAccount(name: string, extraInfo?: string): Promise<void> å°†æ¤åº”用的å¸å·å或é¢å¤–ä¿¡æ¯ï¼ˆèƒ½è½¬æ¢æˆstring类型的其它信æ¯ï¼‰æ·»åŠ 到å¸å·ç®¡ç†æœåŠ¡ä¸ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 @@ -100,7 +100,7 @@ addAccount(name: string, extraInfo: string): Promise<void> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | --------- | ------ | ---- | ---------------------------------------- | | name | string | 是 | è¦æ·»åŠ 的应用å¸å·å称。 | -| extraInfo | string | 是 | è¦æ·»åŠ 的应用å¸å·çš„é¢å¤–ä¿¡æ¯ï¼ˆèƒ½è½¬æ¢æˆstring类型的其它信æ¯ï¼‰ï¼Œé¢å¤–ä¿¡æ¯ä¸èƒ½æ˜¯åº”用å¸å·çš„æ•æ„Ÿä¿¡æ¯ï¼ˆå¦‚应用账å·å¯†ç )。 | +| extraInfo | string | å¦ | è¦æ·»åŠ 的应用å¸å·çš„é¢å¤–ä¿¡æ¯ï¼ˆèƒ½è½¬æ¢æˆstring类型的其它信æ¯ï¼‰ï¼Œé¢å¤–ä¿¡æ¯ä¸èƒ½æ˜¯åº”用å¸å·çš„æ•æ„Ÿä¿¡æ¯ï¼ˆå¦‚应用账å·å¯†ç )。 | **返回值:** @@ -1696,7 +1696,7 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>, cal | name | string | 是 | 应用å¸æˆ·çš„å称。 | | owner | string | 是 | 应用å¸æˆ·çš„所有者。| | labels | Array<string> | 是 | æ ‡ç¾æ•°ç»„。 | -| callback | AsyncCallback<void> | 是 | 检查结果的回调。 | +| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | **示例:** @@ -1710,7 +1710,7 @@ checkAccountLabels(name: string, owner: string, labels: Array<string>, cal ### checkAccountLabels<sup>9+</sup> -checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<void> +checkAccountLabels(name: string, owner: string, labels: Array<string>): Promise<boolean> 检查指定å¸æˆ·æ˜¯å¦å…·æœ‰ç‰¹å®šçš„æ ‡ç¾é›†åˆï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 @@ -1771,7 +1771,7 @@ selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback& ### selectAccountsByOptions<sup>9+</sup> -selectAccountsByOptions(options: SelectAccountsOptions): Promise<void> +selectAccountsByOptions(options: SelectAccountsOptions): Promise<Array<AppAccountInfo>> æ ¹æ®é€‰é¡¹é€‰æ‹©è¯·æ±‚æ–¹å¯è®¿é—®çš„å¸æˆ·åˆ—表,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 @@ -1836,7 +1836,7 @@ verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): ### verifyCredential<sup>9+</sup> -verifyCredential(name: string, owner: string, options, callback: AuthenticatorCallback): void; +verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; 验è¯ç”¨æˆ·å‡æ®ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 @@ -1952,10 +1952,11 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.AppAccount。 -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ------ | ---- | -------- | -| authType | string | 是 | 令牌的鉴æƒç±»åž‹ã€‚ | -| token | string | 是 | 令牌的å–值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | -------------- | ----- | ---------------- | +| authType | string | 是 | 令牌的鉴æƒç±»åž‹ã€‚ | +| token | string | 是 | 令牌的å–值。 | +| account<sup>9+</sup> | AppAccountInfo | å¦ | 令牌所属的å¸å·ä¿¡æ¯ã€‚| ## AuthenticatorInfo<sup>8+</sup> @@ -1977,7 +1978,7 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | --------------- | --------------------------- | ----- | ------------------- | -| allowedAccounts | Array<[AppAccountInfo](#appAccountinfo)> | å¦ | å…许的å¸å·æ•°ç»„。 | +| allowedAccounts | Array<[AppAccountInfo](#appaccountinfo)> | å¦ | å…许的å¸å·æ•°ç»„。 | | allowedOwners | Array<string> | å¦ | å…许的å¸å·æ‰€æœ‰è€…数组。 | | requiredLabels | Array<string> | å¦ | 认è¯å™¨çš„æ ‡ç¾æ ‡è¯†ã€‚ | @@ -2011,21 +2012,21 @@ setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callbac **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.AppAccount。 -| å称 | 默认值 | 说明 | -| ----------------------------- | ---------------------- | ------------- | -| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示æ“作,éšå¼æ·»åŠ å¸å·ã€‚ | -| ACTION_AUTHENTICATE | "authenticate" | 表示æ“作,鉴æƒã€‚ | -| KEY_NAME | "name" | 表示键å,应用å¸å·å称。 | -| KEY_OWNER | "owner" | 表示键å,应用å¸å·æ‰€æœ‰è€…。 | -| KEY_TOKEN | "token" | 表示键å,令牌。 | -| KEY_ACTION | "action" | 表示键å,æ“作。 | -| KEY_AUTH_TYPE | "authType" | 表示键å,鉴æƒç±»åž‹ã€‚ | -| KEY_SESSION_ID | "sessionId" | 表示键å,会è¯æ ‡è¯†ã€‚ | -| KEY_CALLER_PID | "callerPid" | 表示键å,调用方PID。 | -| KEY_CALLER_UID | "callerUid" | 表示键å,调用方UID。 | -| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键å,调用方包å。 | -| KEY_REQUIRED_LABELS | "requiredLabels" | 表示键åï¼Œå¿…éœ€çš„æ ‡ç¾ã€‚ | -| KEY_BOOLEAN_RESULT | "booleanResult" | 表示键å,布尔返回值。 | +| å称 | 默认值 | 说明 | +| -------------------------------- | ---------------------- | ----------------------- | +| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示æ“作,éšå¼æ·»åŠ å¸å·ã€‚ | +| ACTION_AUTHENTICATE | "authenticate" | 表示æ“作,鉴æƒã€‚ | +| KEY_NAME | "name" | 表示键å,应用å¸å·å称。 | +| KEY_OWNER | "owner" | 表示键å,应用å¸å·æ‰€æœ‰è€…。| +| KEY_TOKEN | "token" | 表示键å,令牌。 | +| KEY_ACTION | "action" | 表示键å,æ“作。 | +| KEY_AUTH_TYPE | "authType" | 表示键å,鉴æƒç±»åž‹ã€‚ | +| KEY_SESSION_ID | "sessionId" | 表示键å,会è¯æ ‡è¯†ã€‚ | +| KEY_CALLER_PID | "callerPid" | 表示键å,调用方PID。 | +| KEY_CALLER_UID | "callerUid" | 表示键å,调用方UID。 | +| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键å,调用方包å。 | +| KEY_REQUIRED_LABELS<sup>9+</sup> | "requiredLabels" | 表示键åï¼Œå¿…éœ€çš„æ ‡ç¾ã€‚ | +| KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | 表示键å,布尔返回值。 | ## ResultCode<sup>8+</sup> @@ -2124,7 +2125,7 @@ onRequestRedirected: (request: Want) => void ### onRequestContinued<sup>9+</sup> -onRequestContinued: () => void +onRequestContinued?: () => void 通知请求被继ç»å¤„ç†ã€‚ diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md index 586b0c7e0b71b32a282cb8053593672cf3c98fd6..90037d0d882506a98d94d0a1c3e66e0b183ea4cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md @@ -11,7 +11,7 @@ ## å¯¼å…¥æ¨¡å— ```ts -import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExtensionAbility' +import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility' ``` ## AccessibilityEvent @@ -22,11 +22,11 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte ### 属性 -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| eventType | [EventType](js-apis-accessibility.md#EventType) \| [WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](touchguidetype) \| [GestureType](gesturetype) \| [PageUpdateType](pageupdatetype) | 是 | å¦ | 具体事件类型。 | -| target | AccessibilityElement | 是 | å¦ | å‘ç”Ÿäº‹ä»¶çš„ç›®æ ‡ç»„ä»¶ã€‚ | -| timeStamp | number | 是 | å¦ | 事件时间戳。 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| --------- | ---------------------------------------- | ---- | ---- | ---------- | +| eventType | [EventType](js-apis-accessibility.md#EventType) \| [WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](touchguidetype) \| [GestureType](gesturetype) \| [PageUpdateType](pageupdatetype) | 是 | å¦ | 具体事件类型。 | +| target | AccessibilityElement | 是 | å¦ | å‘ç”Ÿäº‹ä»¶çš„ç›®æ ‡ç»„ä»¶ã€‚ | +| timeStamp | number | 是 | å¦ | 事件时间戳。 | ## GesturePath @@ -36,26 +36,24 @@ import AccessibilityExtensionAbility from './@ohos.application.AccessibilityExte ### 属性 -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| points | Array<[GesturePoint](gesturepoint)> | 是 | 是 | 手势。 | -| durationTime | number | 是 | 是 | 手势总耗时。 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| ------------ | ---------------------------------------- | ---- | ---- | ------ | +| points | Array<[GesturePoint](gesturepoint)> | 是 | 是 | 手势。 | +| durationTime | number | 是 | 是 | 手势总耗时。 | -### 方法 - -#### constructor +### constructor constructor(durationTime: number) æž„é€ å‡½æ•°ã€‚ -- å‚数: +- **å‚数:** - | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | durationTime | number | 是 | 手势总耗时。 | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | + | ------------ | ------ | ---- | ------ | + | durationTime | number | 是 | 手势总耗时。 | -- 示例 +- **示例:** ```typescript let gesturePath = new GesturePath(100); @@ -69,27 +67,25 @@ constructor(durationTime: number) ### 属性 -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| positionX | number | 是 | 是 | 触摸点Xåæ ‡ã€‚ | -| positionY | number | 是 | 是 | 触摸点Yåæ ‡ã€‚ | - -### 方法 +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| positionX | number | 是 | 是 | 触摸点Xåæ ‡ã€‚ | +| positionY | number | 是 | 是 | 触摸点Yåæ ‡ã€‚ | -#### constructor +### constructor constructor(positionX: number, positionY: number) æž„é€ å‡½æ•°ã€‚ -- å‚数: +- **å‚数:** - | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | positionX | number | 是 | 触摸点Xåæ ‡ã€‚ | - | positionY | number | 是 | 触摸点Yåæ ‡ã€‚ | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | + | --------- | ------ | ---- | ------- | + | positionX | number | 是 | 触摸点Xåæ ‡ã€‚ | + | positionY | number | 是 | 触摸点Yåæ ‡ã€‚ | -- 示例 +- **示例:** ```typescript let gesturePoint = new GesturePoint(100, 200); @@ -101,24 +97,24 @@ constructor(positionX: number, positionY: number) **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | -| left | 表示å‘左的手势。 | +| å称 | æè¿° | +| ------------- | ------------ | +| left | 表示å‘左的手势。 | | leftThenRight | 表示先å‘å·¦å†å‘å³çš„手势。 | -| leftThenUp | 表示先å‘å·¦å†å‘上的手势。 | -| leftThenDown | 表示先å‘å·¦å†å‘下的手势。 | -| right | 表示å‘å³çš„手势。 | +| leftThenUp | 表示先å‘å·¦å†å‘上的手势。 | +| leftThenDown | 表示先å‘å·¦å†å‘下的手势。 | +| right | 表示å‘å³çš„手势。 | | rightThenLeft | 表示先å‘å³å†å‘左的手势。 | -| rightThenUp | 表示先å‘å³å†å‘上的手势。 | +| rightThenUp | 表示先å‘å³å†å‘上的手势。 | | rightThenDown | 表示先å‘å³å†å‘下的手势。 | -| up | 表示å‘上的手势。 | -| upThenLeft | 表示先å‘上å†å‘左的手势。 | -| upThenRight | 表示先å‘上å†å‘å³çš„手势。 | -| upThenDown | 表示先å‘上å†å‘下的手势。 | -| down | 表示å‘下的手势。 | -| downThenLeft | 表示先å‘下å†å‘左的手势。 | +| up | 表示å‘上的手势。 | +| upThenLeft | 表示先å‘上å†å‘左的手势。 | +| upThenRight | 表示先å‘上å†å‘å³çš„手势。 | +| upThenDown | 表示先å‘上å†å‘下的手势。 | +| down | 表示å‘下的手势。 | +| downThenLeft | 表示先å‘下å†å‘左的手势。 | | downThenRight | 表示先å‘下å†å‘å³çš„手势。 | -| downThenUp | 表示先å‘下å†å‘上的手势。 | +| downThenUp | 表示先å‘下å†å‘上的手势。 | ## PageUpdateType @@ -126,10 +122,10 @@ constructor(positionX: number, positionY: number) **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | +| å称 | æè¿° | +| ----------------- | --------- | | pageContentUpdate | 表示页é¢å†…容刷新。 | -| pageStateUpdate | 表示页é¢çŠ¶æ€åˆ·æ–°ã€‚ | +| pageStateUpdate | 表示页é¢çŠ¶æ€åˆ·æ–°ã€‚ | ## TouchGuideType @@ -137,10 +133,10 @@ constructor(positionX: number, positionY: number) **系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.Barrierfree.Accessibility.Core -| å称 | æè¿° | -| -------- | -------- | +| å称 | æè¿° | +| ---------- | ------------ | | touchBegin | 表示触摸æµè§ˆæ—¶å¼€å§‹è§¦æ‘¸ã€‚ | -| touchEnd | 表示触摸æµè§ˆæ—¶ç»“æŸè§¦æ‘¸ã€‚ | +| touchEnd | 表示触摸æµè§ˆæ—¶ç»“æŸè§¦æ‘¸ã€‚ | ## AccessibilityExtensionAbility.onConnect @@ -192,9 +188,9 @@ onAccessibilityEvent(event: AccessibilityEvent): void; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| event | [AccessibilityEvent](accessibilityevent) | 是 | æ— éšœç¢äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚æ— è¿”å›žå€¼ã€‚ | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ----- | ---------------------------------------- | ---- | --------------- | +| event | [AccessibilityEvent](accessibilityevent) | 是 | æ— éšœç¢äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚æ— è¿”å›žå€¼ã€‚ | **示例:** @@ -217,9 +213,9 @@ onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | -| ----- | ------ | ------ | ------ | -| keyEvent | [KeyEvent](js-apis-inputeventclient.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截æ¤æŒ‰é”®ã€‚ | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------- | +| keyEvent | [KeyEvent](js-apis-inputeventclient.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截æ¤æŒ‰é”®ã€‚ | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md index f5105c22fdff8d1f43160f864127996ad58c0de8..a9969fa276267dbb85a746d61bfddf44fa15beef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -53,7 +53,7 @@ let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " let rdbStore; export default class DataShareExtAbility extends DataShareExtensionAbility { - onCreate(want: Want, callback: AsyncCallback<void>) { + onCreate(want, callback) { rdb.getRdbStore(this.context, { name: DB_NAME }, 1, function (err, data) { @@ -90,7 +90,7 @@ getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Ar ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { - getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>) { + getFileTypes(uri, mimeTypeFilter, callback) { let err = {"code":0}; let ret = new Array("type01", "type02", "type03"); callback(err, ret); @@ -118,7 +118,7 @@ openFile?(uri: string, mode: string, callback: AsyncCallback<number>): voi ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { - openFile(uri: string, mode: string, callback: AsyncCallback<number>) { + openFile(uri, mode, callback) { let err = {"code":0}; let fd = 0; callback(err,fd); @@ -145,13 +145,22 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe **示例:** ```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + export default class DataShareExtAbility extends DataShareExtensionAbility { - insert(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<number>) { - if (value == null) { + insert(uri, valueBucket, callback) { + if (valueBucket == null) { console.info('invalid valueBuckets'); return; } - rdbStore.insert(TBL_NAME, value, function (err, ret) { + rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) { console.info('callback ret:' + ret); if (callback != undefined) { callback(err, ret); @@ -174,19 +183,28 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示è¦æ›´æ–°çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | | valueBucket | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示è¦æ›´æ–°çš„æ•°æ®ã€‚ | | callback | AsyncCallback<number> | 是 | 回调函数。返回更新的数æ®è®°å½•æ•°ã€‚ | **示例:** ```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + export default class DataShareExtAbility extends DataShareExtensionAbility { - update(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback<number>) { + update(uri, predicates, valueBucket, callback) { if (predicates == null || predicates == undefined) { return; } - rdbStore.update(TBL_NAME, value, predicates, function (err, ret) { + rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) { if (callback != undefined) { callback(err, ret); } @@ -208,14 +226,23 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba | å称 | å‚数类型 | å¿…å¡« | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- | | uri | string | 是 | 指示è¦åˆ 除的数æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | | callback | AsyncCallback<number> | 是 | å›žè°ƒå‡½æ•°ã€‚è¿”å›žå·²åˆ é™¤çš„æ•°æ®è®°å½•æ•°ã€‚ | **示例:** ```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + export default class DataShareExtAbility extends DataShareExtensionAbility { - delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>) { + delete(uri, predicates, callback) { if (predicates == null || predicates == undefined) { return; } @@ -241,15 +268,24 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns | å称 | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示è¦æŸ¥è¯¢çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚ | | columns | Array<string> | 是 | 指示è¦æŸ¥è¯¢çš„列。如果æ¤å‚数为空,则查询所有列。 | | callback | AsyncCallback<Object> | 是 | 回调函数。返回查询到的结果集。 | **示例:** ```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + export default class DataShareExtAbility extends DataShareExtensionAbility { - query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<Object>) { + query(uri, predicates, columns, callback) { if (predicates == null || predicates == undefined) { return; } @@ -284,7 +320,7 @@ getType?(uri: string, callback: AsyncCallback<string>): void ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { - getType(uri: string, callback: AsyncCallback<string>) { + getType(uri, callback) { let err = {"code":0}; let ret = "image"; callback(err, ret); @@ -311,8 +347,17 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy **示例:** ```ts +import rdb from '@ohos.data.rdb'; + +let DB_NAME = "DB00.db"; +let TBL_NAME = "TBL00"; +let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS " ++ TBL_NAME ++ " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)"; +let rdbStore; + export default class DataShareExtAbility extends DataShareExtensionAbility { - batchInsert(uri: string, valueBuckets: Array<ValuesBucket>, callback: AsyncCallback<number>) { + batchInsert(uri, valueBuckets, callback) { if (valueBuckets == null || valueBuckets.length == undefined) { console.info('invalid valueBuckets'); return; @@ -348,7 +393,7 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { - normalizeUri(uri: string, callback: AsyncCallback<string>) { + normalizeUri(uri, callback) { let err = {"code":0}; let ret = "normalize+" + uri; callback(err, ret); @@ -375,7 +420,7 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void ```ts export default class DataShareExtAbility extends DataShareExtensionAbility { - denormalizeUri(uri: string, callback: AsyncCallback<string>) { + denormalizeUri(uri, callback) { let err = {"code":0}; let ret = "denormalize+" + uri; callback(err, ret); diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md b/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md index 87582b604b7fe39292cd326b5ab92aaff06fc3e6..06acb55c355e949e5e386777627392887aefcf6c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-StartOptions.md @@ -19,5 +19,5 @@ import StartOptions from '@ohos.application.StartOptions'; | å称 | å¯è¯» | å¯å†™ | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -------- | -------- | -| windowMode | 是 | å¦ | number | å¦ | 窗å£æ¨¡å¼ã€‚ | +| [windowMode](js-apis-application-abilityConstant.md#AbilityConstant.WindowMode) | 是 | å¦ | number | å¦ | 窗å£æ¨¡å¼ã€‚ | | displayId | 是 | å¦ | number | å¦ | 显示ID。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md index fe90a7f82ece3a649a0d803391df1eec09697f6d..4caa15330e98b80ea127c89dc122d50e85fe298b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-Want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-Want.md @@ -31,15 +31,87 @@ import Want from '@ohos.application.Want'; **示例:** -``` js - var want = { - "deviceId": "", // deviceId为空表示本设备 - "bundleName": "com.extreme.test", - "abilityName": "MainAbility", - "moduleName": "entry" // moduleNameéžå¿…选 - }; - this.context.startAbility(want, (error) => { - // 显å¼æ‹‰èµ·Ability,通过bundleNameã€abilityNameå’ŒmoduleNameå¯ä»¥å”¯ä¸€ç¡®å®šä¸€ä¸ªAbility - console.log("error.code = " + error.code) - }) -``` +- 基础用法 + + ``` js + var want = { + "deviceId": "", // deviceId为空表示本设备 + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleNameéžå¿…选 + }; + this.context.startAbility(want, (error) => { + // 显å¼æ‹‰èµ·Ability,通过bundleNameã€abilityNameå’ŒmoduleNameå¯ä»¥å”¯ä¸€ç¡®å®šä¸€ä¸ªAbility + console.log("error.code = " + error.code) + }) + ``` + +- ä¼ é€’FDæ•°æ®ï¼ŒFD表示文件æ述符(FileDescriptor) + + ``` js + var fd; + try { + fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + } catch(e) { + console.log("openSync fail:" + JSON.stringify(e)); + } + var want = { + "deviceId": "", // deviceId为空表示本设备 + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleNameéžå¿…选 + "parameters": { + "keyFd":{"type":"FD", "value":fd} + } + }; + this.context.startAbility(want, (error) => { + // 显å¼æ‹‰èµ·Ability,通过bundleNameã€abilityNameå’ŒmoduleNameå¯ä»¥å”¯ä¸€ç¡®å®šä¸€ä¸ªAbility + console.log("error.code = " + error.code) + }) + ``` + +- ä¼ é€’RemoteObjectæ•°æ® + + ``` js + class Stub extends rpc.RemoteObject { + constructor(des) { + if (typeof des == 'string') { + super(des); + } else { + return null; + } + } + + onRemoteRequest(code, data, reply, option) { + if (code === 1) { + console.log('onRemoteRequest called') + let token = data.readInterfaceToken(); + let num = data.readInt(); + this.method(); + return true; + } + return false; + } + + method() { + console.log('method called'); + } + } + + var remoteObject = new Stub('want-test'); + var want = { + "deviceId": "", // deviceId为空表示本设备 + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleNameéžå¿…选 + "parameters": { + "keyRemoteObject":{"type":"RemoteObject", "value":remoteObject} + } + }; + this.context.startAbility(want, (error) => { + // 显å¼æ‹‰èµ·Ability,通过bundleNameã€abilityNameå’ŒmoduleNameå¯ä»¥å”¯ä¸€ç¡®å®šä¸€ä¸ªAbility + console.log("error.code = " + error.code) + }) + ``` + + diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md index fa422cfa48a23fb8c081fc713fef454c4c607e87..1f7f75be6ffaa26d40de89879149f88bd7f81d4c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @@ -1,5 +1,5 @@ # 窗å£æ‰©å±•èƒ½åŠ› -WindowExtensionAbility基于ExtensionAbility,WindowExtensionAbilityä¸å±•ç¤ºçš„内容作为一个控件(AbilityComponent)内容展示在其他应用窗å£ä¸ï¼Œå®žçŽ°åœ¨ä¸€ä¸ªçª—å£ä¸å±•ç¤ºå¤šä¸ªåº”用程åºå†…容的功能。 +WindowExtensionAbility基于ExtensionAbility。WindowExtensionAbilityä¸å±•ç¤ºçš„内容å¯ä½œä¸ºä¸€ä¸ªæŽ§ä»¶(AbilityComponent)内容展示在其他应用窗å£ä¸ã€‚ > **说明:** > @@ -7,7 +7,7 @@ WindowExtensionAbility基于ExtensionAbility,WindowExtensionAbilityä¸å±•ç¤º > > 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ > ->本模å—接å£ä»…å¯åœ¨Stage模型下使用。 +> 本模å—接å£ä»…å¯åœ¨Stage模型下使用。 ## å¯¼å…¥æ¨¡å— diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md index 312d3b9386dad297d43ac202f4135b5966a463f4..725fe66632197cdb28c3b434f4f7cbab38d5f6c8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityConstant.md @@ -62,3 +62,17 @@ import AbilityConstant from '@ohos.application.AbilityConstant'; | AGREE | 0 | åŒæ„。 | | REJECT | 1 | æ‹’ç»ã€‚ | | MISMATCH | 2 | ä¸åŒ¹é…。| + +## AbilityConstant.WindowMode + +å¯åŠ¨Ability时的窗å£æ¨¡å¼ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +| å˜é‡ | å–值 | 说明 | +| --- | --- | --- | +| WINDOW_MODE_UNDEFINED | 0 | 未定义窗å£æ¨¡å¼ã€‚ | +| WINDOW_MODE_FULLSCREEN | 1 | å…¨å±æ¨¡å¼ã€‚ | +| WINDOW_MODE_SPLIT_PRIMARY | 100 | 分å±å¤šçª—å£ä¸»è¦æ¨¡å¼ã€‚ | +| WINDOW_MODE_SPLIT_SECONDARY | 101 | 分å±å¤šçª—å£æ¬¡è¦æ¨¡å¼ã€‚ | +| WINDOW_MODE_FLOATING | 102 | 自由悬浮形å¼çª—å£æ¨¡å¼ã€‚ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md index fada27b850de9f6e3b4dcf1951a2f24bb755a728..b9f2671b47aadb433d38996a93195c64d378da44 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -628,7 +628,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => { -### printSync +### printSync<sup>9+</sup> printSync(msg: string): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md index 3c585bdd09536059377027115a5c85e561674196..4d3076f97c57dd54f485927a5cef3ca0ad6d4de2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorArgs.md @@ -20,11 +20,13 @@ var args = AbilityDelegatorRegistry.getArguments(); 测试å‚æ•°ä¿¡æ¯ +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ------------------- | ---------------------- | ---- | ---- | ------------------------------------------------------------ | -| bundleName | string | 是 | 是 | 当å‰è¢«æµ‹è¯•åº”用的包å<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| parameters | {[key:string]: string} | 是 | 是 | 当å‰å¯åŠ¨å•å…ƒæµ‹è¯•çš„å‚æ•°<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| testCaseNames | string | 是 | 是 | 测试用例å称<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| testRunnerClassName | string | 是 | 是 | 执行测试用例的测试执行器的å称<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | +| bundleName | string | 是 | 是 | 当å‰è¢«æµ‹è¯•åº”用的包å | +| parameters | {[key:string]: string} | 是 | 是 | 当å‰å¯åŠ¨å•å…ƒæµ‹è¯•çš„å‚æ•° | +| testCaseNames | string | 是 | 是 | 测试用例å称 | +| testRunnerClassName | string | 是 | 是 | 执行测试用例的测试执行器的å称 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index f220273cbfb22a312c7253d21c6df0b3044cbabc..40c41150c22f760f78e81ba284058bbb85900e43 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -11,7 +11,7 @@ AbilityLifecycleCallback模å—æ供应用上下文ApplicationContext的生命 ## å¯¼å…¥æ¨¡å— ```js -import AbilityLifecycleCallback from "@ohos.application.abilityLifecycleCallback"; +import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback"; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md index 5e86a3af6fe71b6da688d16a5067d65afe994a1d..e49bb16733a7c5028e172f7d5f393bdf00bd778f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md @@ -7,7 +7,7 @@ AbilityManager模å—æ供对Ability相关信æ¯å’ŒçŠ¶æ€ä¿¡æ¯è¿›è¡ŒèŽ·å–〠> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ -# å¯¼å…¥æ¨¡å— +## å¯¼å…¥æ¨¡å— ```js import AbilityManager from '@ohos.application.abilityManager' diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md index df6b0968eef4ed2d6026faf4872d04b3890fa49c..64ffa05699b2148d5440938e8c9d6001005cfd12 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityMonitor.md @@ -33,15 +33,17 @@ abilityDelegator.addAbilityMonitor(monitor, (err : any) => { Ability监å¬å™¨ +系统能力:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | | abilityName | string | 是 | 是 | 当å‰AbilityMonitor绑定的abilityå称<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability被å¯åŠ¨åˆå§‹åŒ–时的回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability状æ€å˜æˆå‰å°æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability状æ€å˜æˆåŽå°æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability被销æ¯å‰çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被创建时的回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被é‡è½½æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被销æ¯å‰çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | +| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability被å¯åŠ¨åˆå§‹åŒ–时的回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ | +| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability状æ€å˜æˆå‰å°æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ | +| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability状æ€å˜æˆåŽå°æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ | +| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | ability被销æ¯å‰çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/> | +| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被创建时的回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/> | +| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被é‡è½½æ—¶çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/> | +| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | 是 | 是 | window stage被销æ¯å‰çš„回调函数<br/>ä¸è®¾ç½®è¯¥å±žæ€§åˆ™ä¸èƒ½æ”¶åˆ°è¯¥ç”Ÿå‘½å‘¨æœŸå›žè°ƒ<br/> | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md index 91a467c2e41ffbe9e3d062249cf264025bb39894..7705d4bd7c71ddb7ae42fd1ce52e838849a4b8fb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md @@ -28,7 +28,7 @@ registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): **number** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------------------------ | -------- | ---- | ------------------------------ | -| [AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) | callback | 是 | 回调方法,返回注册监å¬äº‹ä»¶çš„ID。 | +| callback | [AbilityLifecycleCallback](js-apis-application-abilityLifecycleCallback.md) | 是 | 回调方法,返回注册监å¬äº‹ä»¶çš„ID。 | **返回值:** @@ -98,7 +98,7 @@ unregisterAbilityLifecycleCallback(callbackId: **number**, callback: AsyncCallb | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------------- | -------- | ---- | -------------------------- | | callbackId | number | 是 | 注册监å¬åº”用内生命周期的ID。 | -| AsyncCallback | callback | 是 | 回调方法。 | +| callback | AsyncCallback\<void> | 是 | 回调方法。 | **示例:** @@ -123,7 +123,7 @@ registerEnvironmentCallback(callback: EnvironmentCallback): **number**; | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------------------------ | -------- | ---- | ------------------------------ | -| [EnvironmentCallback](js-apis-application-EnvironmentCallback.md) | callback | 是 | 回调方法,返回注册监å¬äº‹ä»¶çš„ID。 | +| callback | [EnvironmentCallback](js-apis-application-EnvironmentCallback.md) | 是 | 回调方法,返回注册监å¬äº‹ä»¶çš„ID。 | **返回值:** @@ -175,7 +175,7 @@ unregisterEnvironmentCallback(callbackId: **number**, callback: AsyncCallback<* | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------------- | -------- | ---- | -------------------------- | | callbackId | number | 是 | 注册监å¬ç³»ç»ŸçŽ¯å¢ƒå˜åŒ–çš„ID。 | -| AsyncCallback | callback | 是 | 回调方法。 | +| callback | AsyncCallback\<void> | 是 | 回调方法。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index 14d20ed469c29dfc7746238e8c11f22b2bfa3412..b8f385ca6ed186b99659199e936c60975e6263d7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -7,8 +7,6 @@ Context模å—æ供开å‘者è¿è¡Œä»£ç 的上下文环境的能力,包括查 > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > 本模å—接å£ä»…å¯åœ¨Stage模型下使用。 -æ供开å‘者è¿è¡Œä»£ç 的上下文环境,包括应用信æ¯ã€ResourceManagerç‰ä¿¡æ¯ã€‚ - ## 使用说明 通过AbilityContextç‰ç»§æ‰¿å®žçŽ°ã€‚ @@ -27,7 +25,7 @@ import AbilityContext from '@ohos.application.Ability' **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core - | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | -------- | -------- | -------- | -------- | -------- | | resourceManager | resmgr.ResourceManager; | 是 | å¦ | ResourceManager对象。 | | applicationInfo | ApplicationInfo | 是 | å¦ | 当å‰åº”用信æ¯ã€‚ | @@ -47,8 +45,12 @@ createBundleContext(bundleName: string): Context; 创建指定应用上下文。 +**需è¦æƒé™**:ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + **系统能力**:SystemCapability.Ability.AbilityRuntime.Core +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -117,6 +119,8 @@ createModuleContext(bundleName: string, moduleName: string): Context; **系统能力**:SystemCapability.Ability.AbilityRuntime.Core +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md b/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md index ae8f7c42862086343031cddbc6fb0a81ccee88d7..2c9f76234fb7eec46f45e2faf3d09f2bf980b7ae 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-shellCmdResult.md @@ -30,5 +30,5 @@ Shell命令执行结果 | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | --------- | ------ | ---- | ---- | ------------------------------------------------------------ | -| stdResult | string | 是 | 是 | æ ‡å‡†è¾“å‡ºå†…å®¹<br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | -| exitCode | number | 是 | 是 | 结果ç <br/>**系统能力:** SystemCapability.Ability.AbilityRuntime.Core | +| stdResult | string | 是 | 是 | æ ‡å‡†è¾“å‡ºå†…å®¹ | +| exitCode | number | 是 | 是 | 结果ç | diff --git a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md index 84c6d3ed3a651a88a562c9d6a1b8278bf979e27b..f4ac20aea83ca20d982eef78c375949a77094f3f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -210,7 +210,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo registerApplicationStateObserver(observer: ApplicationStateObserver): number; -注册应用程åºçŠ¶æ€è§‚测器。 +注册全部应用程åºçŠ¶æ€è§‚测器。 **需è¦æƒé™**:ohos.permission.RUNNING_STATE_OBSERVER @@ -244,6 +244,48 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number; const observerCode = app.registerApplicationStateObserver(applicationStateObserver); console.log('-------- observerCode: ---------', observerCode); + ``` + +## appManager.registerApplicationStateObserver<sup>9+</sup> + +registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number; + +注册指定应用程åºçŠ¶æ€è§‚测器。 + +**需è¦æƒé™**:ohos.permission.RUNNING_STATE_OBSERVER + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| observer | ApplicationStateObserver | å¦ | 返回观察者的数å—代ç 。 | +| bundleNameList | Array<string> | å¦ | 表示需è¦æ³¨å†Œç›‘å¬çš„bundleName数组。最大值128。 | + +**示例:** + + ```js + var applicationStateObserver = { + onForegroundApplicationChanged(appStateData) { + console.log('------------ onForegroundApplicationChanged -----------', appStateData); + }, + onAbilityStateChanged(abilityStateData) { + console.log('------------ onAbilityStateChanged -----------', abilityStateData); + }, + onProcessCreated(processData) { + console.log('------------ onProcessCreated -----------', processData); + }, + onProcessDied(processData) { + console.log('------------ onProcessDied -----------', processData); + } + } + var bundleNameList = ['bundleName1', 'bundleName2']; + const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList); + console.log('-------- observerCode: ---------', observerCode); + ``` ## appManager.unregisterApplicationStateObserver<sup>8+</sup> @@ -348,7 +390,7 @@ getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void; ## appManager.getForegroundApplications<sup>8+</sup> -getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>; +getForegroundApplications(): Promise\<Array\<AppStateData>>; 获å–å‰å°è¿›ç¨‹çš„应用程åºã€‚ @@ -393,7 +435,7 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | - | accountId | number | 是 | accountçš„Id。 | + | accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | **示例:** @@ -427,7 +469,7 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | bundleName | string | 是 | 应用包å。 | - | accountId | number | 是 | accountçš„Id。 | + | accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | callback | AsyncCallback\<void\> | 是 | 切æ–account进程的回调函数。 | **示例:** @@ -588,6 +630,144 @@ clearUpApplicationData(bundleName: string): Promise\<void>; ``` +## ApplicationStateObserver.onForegroundApplicationChanged<sup>8+</sup> + +onForegroundApplicationChanged(appStateData: AppStateData): void; + +将在å‰å°æˆ–åŽå°åº”用程åºæ›´æ”¹æ—¶è°ƒç”¨ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| appStateData | [AppStateData](#appstatedata) | å¦ | 状æ€æ›´æ”¹çš„应用程åºä¿¡æ¯ã€‚ | + +**示例:** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const foregroundApplicationInfo = ApplicationStateObserver.onForegroundApplicationChanged(); +console.log('-------- foregroundApplicationInfo: ---------', foregroundApplicationInfo); +``` + +## ApplicationStateObserver.onAbilityStateChanged<sup>8+</sup> + +onAbilityStateChanged(abilityStateData: AbilityStateData): void; + +将在能力状æ€æ›´æ”¹æ—¶è°ƒç”¨ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| abilityStateData | [AbilityStateData](#abilitystatedata) | å¦ | 状æ€æ›´æ”¹çš„能力信æ¯ã€‚ | + +**示例:** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const abilityStateChangedInfo = ApplicationStateObserver.onAbilityStateChanged(); +console.log('-------- abilityStateChangedInfo: ---------', abilityStateChangedInfo); +``` + +## ApplicationStateObserver.onProcessCreated<sup>8+</sup> + +onProcessCreated(processData: ProcessData): void; + +将在创建进程时调用。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| processData | [ProcessData](#processdata) | å¦ | 进程信æ¯ã€‚ | + +**示例:** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const processCreatedInfo = ApplicationStateObserver.onProcessCreated(); +console.log('-------- processCreatedInfo: ---------', processCreatedInfo); +``` + +## ApplicationStateObserver.onProcessDied<sup>8+</sup> + +onProcessDied(processData: ProcessData): void; + +将在进程终æ¢æ—¶è°ƒç”¨ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| processData | ProcessData | å¦ | 进程信æ¯ã€‚ | + +**示例:** + +```js +import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver' +const processDiedInfo = ApplicationStateObserver.onProcessDied(); +console.log('-------- processDiedInfo: ---------', processDiedInfo); +``` + +## AppStateData + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName<sup>8+</sup> | åªè¯» | string | å¦ | 包å。 | +| uid<sup>8+</sup> | åªè¯» | number | å¦ | 用户ID。 | +| state<sup>8+</sup> | åªè¯» | number | å¦ | 应用状æ€ã€‚ | + +## AbilityStateData + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| pid<sup>8+</sup> | number | 是 | å¦ | 进程ID。 | +| bundleName<sup>8+</sup> | string | 是 | å¦ | 应用包å。 | +| abilityName<sup>8+</sup> | string | 是 | å¦ | Abilityå称。 | +| uid<sup>8+</sup> | number | 是 | å¦ | 用户ID。 | +| state<sup>8+</sup> | number | 是 | å¦ | Ability状æ€ã€‚ | +| moduleName<sup>9+</sup> | string | 是 | å¦ | Ability所属的HAP包的å称。 | +| abilityType<sup>8+</sup> | string | 是 | å¦ | 能力类型ã€é¡µé¢æˆ–æœåŠ¡ç‰ã€‚ | + +## ProcessData + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Mission + +**系统API**:该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| pid<sup>8+</sup> | number | 是 | å¦ | 进程ID。 | +| bundleName<sup>8+</sup> | string | 是 | å¦ | 应用包å。 | +| uid<sup>8+</sup> | number | 是 | å¦ | 用户ID。 | + + + ## ProcessRunningInfo **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Core diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 447df9f4cb228e42e98ba27916768b987d9b67d1..f42b90abb0d58da82d213a56dff3f0a9bad5b56a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -36,6 +36,24 @@ getAudioManager(): AudioManager var audioManager = audio.getAudioManager(); ``` +## audio.getStreamManager<sup>9+</sup> + +getStreamManager(): AudioStreamManager + +获å–音频æµç®¡ç†å™¨å®žä¾‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Core + +**返回值:** +| 类型 | 说明 | +| -------------------------------------------------| ------------------------------- | +| [AudioStreamManager](#audiostreammanager9) | 返回音频æµç®¡ç†å™¨å®žä¾‹ã€‚ | + +**示例:** +``` +var audioStreamManager = audio.getStreamManager(); +``` + ## audio.createAudioRenderer<sup>8+</sup> createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<AudioRenderer>): void @@ -44,7 +62,7 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<Audi **系统能力:** SystemCapability.Multimedia.Audio.Renderer -**å‚æ•°**: +**å‚数:**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------------- | ---- | ---------------- | @@ -56,31 +74,30 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<Audi ``` import audio from '@ohos.multimedia.audio'; var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } var audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 1 + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 } var audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo } audio.createAudioRenderer(audioRendererOptions,(err, data) => { - if (err) { - console.error(`AudioRenderer Created : Error: ${err.message}`); - } - else { - console.info('AudioRenderer Created : Success : SUCCESS'); - let audioRenderer = data; - } + if (err) { + console.error(`AudioRenderer Created: Error: ${err.message}`); + } else { + console.info('AudioRenderer Created: Success: SUCCESS'); + let audioRenderer = data; + } }); ``` @@ -110,29 +127,29 @@ createAudioRenderer(options: AudioRendererOptions): Promise<AudioRenderer\> import audio from '@ohos.multimedia.audio'; var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } var audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 1 + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 } var audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo } var audioRenderer; audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRenderer Created : ERROR : '+err.message); + console.info('AudioFrameworkRenderLog: AudioRenderer Created : ERROR : ' + err.message); }); ``` @@ -156,30 +173,29 @@ createAudioCapturer(options: AudioCapturerOptions, callback: AsyncCallback<Audio ``` import audio from '@ohos.multimedia.audio'; var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } var audioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 1 + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 } var audioCapturerOptions = { - streamInfo: audioStreamInfo, - capturerInfo: audioCapturerInfo + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo } -audio.createAudioCapturer(audioCapturerOptions,(err, data) => { - if (err) { - console.error(`AudioCapturer Created : Error: ${err.message}`); - } - else { - console.info('AudioCapturer Created : Success : SUCCESS'); - let audioCapturer = data; - } +audio.createAudioCapturer(audioCapturerOptions, (err, data) => { + if (err) { + console.error(`AudioCapturer Created : Error: ${err.message}`); + } else { + console.info('AudioCapturer Created : Success : SUCCESS'); + let audioCapturer = data; + } }); ``` @@ -209,28 +225,28 @@ createAudioCapturer(options: AudioCapturerOptions): Promise<AudioCapturer\> import audio from '@ohos.multimedia.audio'; var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } var audioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 1 + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 } var audioCapturerOptions = { - streamInfo: audioStreamInfo, - capturerInfo: audioCapturerInfo + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo } var audioCapturer; audio.createAudioCapturer(audioCapturerOptions).then((data) => { - audioCapturer = data; - console.info('AudioCapturer Created : Success : Stream Type: SUCCESS'); + audioCapturer = data; + console.info('AudioCapturer Created : Success : Stream Type: SUCCESS'); }).catch((err) => { - console.info('AudioCapturer Created : ERROR : '+err.message); + console.info('AudioCapturer Created : ERROR : ' + err.message); }); ``` @@ -252,7 +268,7 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { 枚举,焦点模型。 -**系统能力:** SystemCapability.Multimedia.Audio.InterruptMode +**系统能力:** SystemCapability.Multimedia.Audio.Core | å称 | 默认值 | æè¿° | | ---------------------------- | ------ | ---------- | @@ -331,13 +347,14 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Audio.Core -| å称 | 默认值 | æè¿° | -| --------------------- | ------ | -------------------------- | -| SAMPLE_FORMAT_INVALID | -1 | æ— æ•ˆæ ¼å¼ã€‚ | -| SAMPLE_FORMAT_U8 | 0 | æ— ç¬¦å·8ä½æ•´æ•°ã€‚ | -| SAMPLE_FORMAT_S16LE | 1 | 带符å·çš„16ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ | -| SAMPLE_FORMAT_S24LE | 2 | 带符å·çš„24ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ | -| SAMPLE_FORMAT_S32LE | 3 | 带符å·çš„32ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ | +| å称 | 默认值 | æè¿° | +| ---------------------------------- | ------ | -------------------------- | +| SAMPLE_FORMAT_INVALID | -1 | æ— æ•ˆæ ¼å¼ã€‚ | +| SAMPLE_FORMAT_U8 | 0 | æ— ç¬¦å·8ä½æ•´æ•°ã€‚ | +| SAMPLE_FORMAT_S16LE | 1 | 带符å·çš„16ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ | +| SAMPLE_FORMAT_S24LE | 2 | 带符å·çš„24ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ <br>由于系统é™åˆ¶ï¼Œè¯¥é‡‡æ ·æ ¼å¼ä»…部分设备支æŒï¼Œè¯·æ ¹æ®å®žé™…情况使用。| +| SAMPLE_FORMAT_S32LE | 3 | 带符å·çš„32ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ <br>由于系统é™åˆ¶ï¼Œè¯¥é‡‡æ ·æ ¼å¼ä»…部分设备支æŒï¼Œè¯·æ ¹æ®å®žé™…情况使用。| +| SAMPLE_FORMAT_F32LE<sup>9+</sup> | 4 | 带符å·çš„32ä½æ•´æ•°ï¼Œå°å°¾æ•°ã€‚ <br>由于系统é™åˆ¶ï¼Œè¯¥é‡‡æ ·æ ¼å¼ä»…部分设备支æŒï¼Œè¯·æ ¹æ®å®žé™…情况使用。| ## AudioChannel<sup>8+</sup> @@ -409,6 +426,17 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { | STREAM_USAGE_VOICE_COMMUNICATION | 2 | è¯éŸ³é€šä¿¡ã€‚ | | STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | 通知铃声。 | +## FocusType<sup>9+</sup> + +表示焦点类型的枚举。 + +**系统能力:**: SystemCapability.Multimedia.Audio.Core + +| å称 | 默认值 | æè¿° | +| ---------------------------------- | ------ | ------------------------------- | +| FOCUS_TYPE_RECORDING | 0 | 在录制场景使用,å¯æ‰“æ–其他音频。 | + + ## AudioState<sup>8+</sup> 枚举,音频状æ€ã€‚ @@ -510,6 +538,17 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { | usage | [StreamUsage](#streamusage) | 是 | 音频æµä½¿ç”¨ç±»åž‹ã€‚ | | rendererFlags | number | 是 | éŸ³é¢‘æ¸²æŸ“å™¨æ ‡å¿—ã€‚ | +## AudioRendererFlag<sup>9+</sup> + +枚举,决定输出ç–ç•¥çš„éŸ³é¢‘æ¸²æŸ“å™¨æ ‡å¿—ã€‚ + +**系统能力**: SystemCapability.Multimedia.Audio.Core + +| å称 | 默认值 | 说明 | +| ------------------| ------------ | ---------------------- | +| FLAG_NONE | 0 | æ— ç‰¹æ®Šç–略。 | +| FLAG_LOW_LATENCY | 1 | ä½¿ç”¨ä½Žå»¶è¿Ÿè¿›ç¨‹çš„æ ‡å¿—ã€‚ | + ## AudioRendererOptions<sup>8+</sup> 音频渲染器选项信æ¯ã€‚ @@ -576,12 +615,12 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { æ述设备连接状æ€å˜åŒ–和设备信æ¯ã€‚ -**系统能力:**SystemCapability.Multimedia.Audio.Device +**系统能力:** SystemCapability.Multimedia.Audio.Device | å称 | 类型 | å¿…å¡« | 说明 | | :---------------- | :------------------------------------------------ | :--- | :----------------- | -| type | [DeviceChangeType](#DeviceChangeType) | 是 | 设备连接状æ€å˜åŒ–。 | -| deviceDescriptors | [AudioDeviceDescriptors](#AudioDeviceDescriptors) | 是 | 设备信æ¯ã€‚ | +| type | [DeviceChangeType](#devicechangetype) | 是 | 设备连接状æ€å˜åŒ–。 | +| deviceDescriptors | [AudioDeviceDescriptors](#audiodevicedescriptors) | 是 | 设备信æ¯ã€‚ | ## DeviceChangeType @@ -616,6 +655,17 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => { | source | [SourceType](#sourcetype) | 是 | 音æºç±»åž‹ã€‚ | | capturerFlags | number | 是 | éŸ³é¢‘é‡‡é›†å™¨æ ‡å¿—ã€‚ | +## AudioRendererDataInfo<sup>9+</sup> + +音频渲染器的数æ®ä¿¡æ¯ã€‚ + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | ----------- | -------| ------------------------ | +| buffer | ArrayBuffer | 是 | è¦å¡«å……的缓冲区。 | +| flags | number | 是 | 缓冲区扩展信æ¯ã€‚ | + ## SourceType<sup>8+</sup><a name="sourcetype"></a> 枚举,音æºç±»åž‹ã€‚ @@ -651,7 +701,7 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l 设置指定æµçš„音é‡ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY,仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY<br/>仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -667,11 +717,11 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l ``` audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { - if (err) { - console.error('Failed to set the volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful volume setting.'); + if (err) { + console.error('Failed to set the volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate a successful volume setting.'); }); ``` @@ -681,7 +731,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> 设置指定æµçš„音é‡ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY,仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY<br/>仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -702,7 +752,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> ``` audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { - console.log('Promise returned to indicate a successful volume setting.'); + console.log('Promise returned to indicate a successful volume setting.'); }); ``` @@ -725,11 +775,11 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): v ``` audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the volume is obtained.'); + if (err) { + console.error('Failed to obtain the volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the volume is obtained.'); }); ``` @@ -757,7 +807,7 @@ getVolume(volumeType: AudioVolumeType): Promise<number> ``` audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.log('Promise returned to indicate that the volume is obtained.' + value); + console.log('Promise returned to indicate that the volume is obtained.' + value); }); ``` @@ -780,11 +830,11 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) ``` audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the minimum volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the minimum volume is obtained.' + value); + if (err) { + console.error('Failed to obtain the minimum volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the minimum volume is obtained.' + value); }); ``` @@ -812,7 +862,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise<number> ``` audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.log('Promised returned to indicate that the minimum volume is obtained.' + value); + console.log('Promised returned to indicate that the minimum volume is obtained.' + value); }); ``` @@ -835,11 +885,11 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) ``` audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the maximum volume. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the maximum volume is obtained.' + value); + if (err) { + console.error('Failed to obtain the maximum volume. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the maximum volume is obtained.' + value); }); ``` @@ -867,7 +917,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise<number> ``` audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { - console.log('Promised returned to indicate that the maximum volume is obtained.'); + console.log('Promised returned to indicate that the maximum volume is obtained.'); }); ``` @@ -877,7 +927,7 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void 设置指定音é‡æµé™éŸ³ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY,仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY<br/>仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -893,11 +943,11 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void ``` audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { - if (err) { - console.error('Failed to mute the stream. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the stream is muted.'); + if (err) { + console.error('Failed to mute the stream. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the stream is muted.'); }); ``` @@ -907,7 +957,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> 设置指定音é‡æµé™éŸ³ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY,仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_NOTIFICATION_POLICY<br/>仅设置铃声(å³volumeType为AudioVolumeType.RINGTONE)在é™éŸ³å’Œéžé™éŸ³çŠ¶æ€åˆ‡æ¢æ—¶éœ€è¦è¯¥æƒé™ã€‚ **系统能力:** SystemCapability.Multimedia.Audio.Volume @@ -929,7 +979,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> ``` audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { - console.log('Promise returned to indicate that the stream is muted.'); + console.log('Promise returned to indicate that the stream is muted.'); }); ``` @@ -953,11 +1003,11 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): voi ``` audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the mute status. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); + if (err) { + console.error('Failed to obtain the mute status. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the mute status of the stream is obtained.' + value); }); ``` @@ -986,7 +1036,7 @@ isMute(volumeType: AudioVolumeType): Promise<boolean> ``` audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { - console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); + console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value); }); ``` @@ -1009,11 +1059,11 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): v ``` audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error('Failed to obtain the active status of the stream. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value); + if (err) { + console.error('Failed to obtain the active status of the stream. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the active status of the stream is obtained.' + value); }); ``` @@ -1041,7 +1091,7 @@ isActive(volumeType: AudioVolumeType): Promise<boolean> ``` audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { - console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); + console.log('Promise returned to indicate that the active status of the stream is obtained.' + value); }); ``` @@ -1066,11 +1116,11 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void ``` audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { - if (err) { - console.error('Failed to set the ringer mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful setting of the ringer mode.'); + if (err) { + console.error('Failed to set the ringer mode.​ ${err.message}'); + return; + } + console.log('Callback invoked to indicate a successful setting of the ringer mode.'); }); ``` @@ -1100,7 +1150,7 @@ setRingerMode(mode: AudioRingMode): Promise<void> ``` audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => { - console.log('Promise returned to indicate a successful setting of the ringer mode.'); + console.log('Promise returned to indicate a successful setting of the ringer mode.'); }); ``` @@ -1123,11 +1173,11 @@ getRingerMode(callback: AsyncCallback<AudioRingMode>): void ``` audioManager.getRingerMode((err, value) => { - if (err) { - console.error('Failed to obtain the ringer mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); + if (err) { + console.error('Failed to obtain the ringer mode.​ ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); }); ``` @@ -1150,7 +1200,7 @@ getRingerMode(): Promise<AudioRingMode> ``` audioManager.getRingerMode().then((value) => { - console.log('Promise returned to indicate that the ringer mode is obtained.' + value); + console.log('Promise returned to indicate that the ringer mode is obtained.' + value); }); ``` @@ -1178,11 +1228,11 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback<void> ``` audioManager.setAudioParameter('key_example', 'value_example', (err) => { - if (err) { - console.error('Failed to set the audio parameter. ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful setting of the audio parameter.'); + if (err) { + console.error('Failed to set the audio parameter. ${err.message}'); + return; + } + console.log('Callback invoked to indicate a successful setting of the audio parameter.'); }); ``` @@ -1215,7 +1265,7 @@ setAudioParameter(key: string, value: string): Promise<void> ``` audioManager.setAudioParameter('key_example', 'value_example').then(() => { - console.log('Promise returned to indicate a successful setting of the audio parameter.'); + console.log('Promise returned to indicate a successful setting of the audio parameter.'); }); ``` @@ -1240,11 +1290,11 @@ getAudioParameter(key: string, callback: AsyncCallback<string>): void ``` audioManager.getAudioParameter('key_example', (err, value) => { - if (err) { - console.error('Failed to obtain the value of the audio parameter. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value); + if (err) { + console.error('Failed to obtain the value of the audio parameter. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the value of the audio parameter is obtained.' + value); }); ``` @@ -1274,7 +1324,7 @@ getAudioParameter(key: string): Promise<string> ``` audioManager.getAudioParameter('key_example').then((value) => { - console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); + console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value); }); ``` @@ -1296,11 +1346,11 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescrip **示例:** ``` audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { - if (err) { - console.error('Failed to obtain the device list. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the device list is obtained.'); + if (err) { + console.error('Failed to obtain the device list. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the device list is obtained.'); }); ``` @@ -1328,7 +1378,7 @@ getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> ``` audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { - console.log('Promise returned to indicate that the device list is obtained.'); + console.log('Promise returned to indicate that the device list is obtained.'); }); ``` @@ -1352,11 +1402,11 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCa ``` audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { - if (err) { - console.error('Failed to set the active status of the device. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the device is set to the active status.'); + if (err) { + console.error('Failed to set the active status of the device. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the device is set to the active status.'); }); ``` @@ -1386,7 +1436,7 @@ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void& ``` audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { - console.log('Promise returned to indicate that the device is set to the active status.'); + console.log('Promise returned to indicate that the device is set to the active status.'); }); ``` @@ -1409,11 +1459,11 @@ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean& ``` audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { - if (err) { - console.error('Failed to obtain the active status of the device. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the active status of the device is obtained.'); + if (err) { + console.error('Failed to obtain the active status of the device. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the active status of the device is obtained.'); }); ``` @@ -1442,7 +1492,7 @@ isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean> ``` audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => { - console.log('Promise returned to indicate that the active status of the device is obtained.' + value); + console.log('Promise returned to indicate that the active status of the device is obtained.' + value); }); ``` @@ -1467,11 +1517,11 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void ``` audioManager.setMicrophoneMute(true, (err) => { - if (err) { - console.error('Failed to mute the microphone. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the microphone is muted.'); + if (err) { + console.error('Failed to mute the microphone. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the microphone is muted.'); }); ``` @@ -1501,7 +1551,7 @@ setMicrophoneMute(mute: boolean): Promise<void> ``` audioManager.setMicrophoneMute(true).then(() => { - console.log('Promise returned to indicate that the microphone is muted.'); + console.log('Promise returned to indicate that the microphone is muted.'); }); ``` @@ -1525,11 +1575,11 @@ isMicrophoneMute(callback: AsyncCallback<boolean>): void ``` audioManager.isMicrophoneMute((err, value) => { - if (err) { - console.error('Failed to obtain the mute status of the microphone. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value); + if (err) { + console.error('Failed to obtain the mute status of the microphone. ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the mute status of the microphone is obtained.' + value); }); ``` @@ -1554,7 +1604,7 @@ isMicrophoneMute(): Promise<boolean> ``` audioManager.isMicrophoneMute().then((value) => { - console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); + console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value); }); ``` @@ -1566,6 +1616,8 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +ç›®å‰æ¤è®¢é˜…接å£åœ¨å•è¿›ç¨‹å¤šAudioManager实例的使用场景下,仅最åŽä¸€ä¸ªå®žä¾‹çš„订阅生效,其他实例的订阅会被覆盖(å³ä½¿æœ€åŽä¸€ä¸ªå®žä¾‹æ²¡æœ‰è¿›è¡Œè®¢é˜…ï¼‰ï¼Œå› æ¤æŽ¨è使用å•ä¸€AudioManager实例进行开å‘。 + **系统能力:** SystemCapability.Multimedia.Audio.Volume **å‚数:** @@ -1579,9 +1631,9 @@ on(type: 'volumeChange', callback: Callback\<VolumeEvent>): void ``` audioManager.on('volumeChange', (volumeEvent) => { - console.log('VolumeType of stream: ' + volumeEvent.volumeType); - console.log('Volume level: ' + volumeEvent.volume); - console.log('Whether to updateUI: ' + volumeEvent.updateUi); + console.log('VolumeType of stream: ' + volumeEvent.volumeType); + console.log('Volume level: ' + volumeEvent.volume); + console.log('Whether to updateUI: ' + volumeEvent.updateUi); }); ``` @@ -1606,7 +1658,7 @@ on(type: 'ringerModeChange', callback: Callback\<AudioRingMode>): void ``` audioManager.on('ringerModeChange', (ringerMode) => { - console.log('Updated ringermode: ' + ringerMode); + console.log('Updated ringermode: ' + ringerMode); }); ``` @@ -1623,16 +1675,16 @@ on(type: 'deviceChange', callback: Callback<DeviceChangeAction\>): void | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | | type | string | 是 | 订阅的事件的类型。支æŒäº‹ä»¶ï¼š'deviceChange' | -| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)\> | 是 | 获å–设备更新详情。 | +| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | 是 | 获å–设备更新详情。 | **示例:** ``` audioManager.on('deviceChange', (deviceChanged) => { - console.info("device change type : " + deviceChanged.type); - console.info("device descriptor size : " + deviceChanged.deviceDescriptors.length); - console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceRole); - console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceType); + console.info("device change type : " + deviceChanged.type); + console.info("device descriptor size : " + deviceChanged.deviceDescriptors.length); + console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceRole); + console.info("device change descriptor : " + deviceChanged.deviceDescriptors[0].deviceType); }); ``` @@ -1649,13 +1701,13 @@ off(type: 'deviceChange', callback?: Callback<DeviceChangeAction\>): void | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------------------------------- | ---- | ------------------------------------------ | | type | string | 是 | 订阅的事件的类型。支æŒäº‹ä»¶ï¼š'deviceChange' | -| callback | Callback<[DeviceChangeAction](#DeviceChangeAction)> | å¦ | 获å–设备更新详情。 | +| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | å¦ | 获å–设备更新详情。 | **示例:** ``` audioManager.off('deviceChange', (deviceChanged) => { - console.log("Should be no callback."); + console.log("Should be no callback."); }); ``` @@ -1679,19 +1731,19 @@ on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\<InterruptAc ``` var interAudioInterrupt = { - streamUsage:2, - contentType:0, - pauseWhenDucked:true + streamUsage:2, + contentType:0, + pauseWhenDucked:true }; 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)); - } - if (InterruptAction.actionType === 1) { - console.log("An audio interruption event starts."); - console.log("Audio interruption event:" + JSON.stringify(InterruptAction)); - } + if (InterruptAction.actionType === 0) { + console.log("An event to gain the audio focus starts."); + console.log("Focus gain event:" + JSON.stringify(InterruptAction)); + } + if (InterruptAction.actionType === 1) { + console.log("An audio interruption event starts."); + console.log("Audio interruption event:" + JSON.stringify(InterruptAction)); + } }); ``` @@ -1715,15 +1767,15 @@ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\<Interrupt ``` var interAudioInterrupt = { - streamUsage:2, - contentType:0, - pauseWhenDucked:true + streamUsage:2, + contentType:0, + pauseWhenDucked:true }; 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)); - } + if (InterruptAction.actionType === 0) { + console.log("An event to release the audio focus starts."); + console.log("Focus release event:" + JSON.stringify(InterruptAction)); + } }); ``` @@ -1748,11 +1800,11 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void ``` audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { - if (err) { - console.error('Failed to set the audio scene mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate a successful setting of the audio scene mode.'); + if (err) { + console.error('Failed to set the audio scene mode.​ ${err.message}'); + return; + } + console.log('Callback invoked to indicate a successful setting of the audio scene mode.'); }); ``` @@ -1782,9 +1834,9 @@ setAudioScene\(scene: AudioScene\): Promise<void\> ``` audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { - console.log('Promise returned to indicate a successful setting of the audio scene mode.'); + 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'); + console.log('Failed to set the audio scene mode'); }); ``` @@ -1806,11 +1858,11 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void ``` audioManager.getAudioScene((err, value) => { - if (err) { - console.error('Failed to obtain the audio scene mode.​ ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the audio scene mode is obtained.' + value); + if (err) { + console.error('Failed to obtain the audio scene mode.​ ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the audio scene mode is obtained.' + value); }); ``` @@ -1833,9 +1885,513 @@ getAudioScene\(\): Promise<AudioScene\> ``` audioManager.getAudioScene().then((value) => { - console.log('Promise returned to indicate that the audio scene mode is obtained.' + value); + console.log('Promise returned to indicate that the audio scene mode is obtained.' + value); }).catch ((err) => { - console.log('Failed to obtain the audio scene mode'); + console.log('Failed to obtain the audio scene mode'); +}); +``` + +## AudioStreamManager<sup>9+</sup> + +管ç†éŸ³é¢‘æµã€‚在使用AudioStreamManagerçš„APIå‰ï¼Œéœ€è¦ä½¿ç”¨[getStreamManager](#audiogetstreammanager9)获å–AudioStreamManager实例。 + +### getCurrentAudioRendererInfoArray<sup>9+</sup> + +getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void + +获å–当å‰éŸ³é¢‘渲染器的信æ¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | -------- | --------------------------- | +| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | 是 | 回调函数,返回当å‰éŸ³é¢‘渲染器的信æ¯ã€‚ | + +**示例:** +``` +audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); + if (err) { + console.log('getCurrentAudioRendererInfoArray :ERROR: '+ err.message); + resultFlag = false; + } else { + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('StreamId for' + i + 'is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for' + i + 'is:' + AudioRendererChangeInfo.clientUid); + console.info('Content' + i + 'is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream'+ i + 'is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag'+ i +' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for' + i +' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i +':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCount' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + } + } +}); +``` + +### getCurrentAudioRendererInfoArray<sup>9+</sup> + +getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray> + +获å–当å‰éŸ³é¢‘渲染器的信æ¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------------------------------------------| --------------------------------------- | +| Promise<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Promise对象,返回当å‰éŸ³é¢‘渲染器信æ¯ã€‚ | + +**示例:** +``` +await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('getCurrentAudioRendererInfoArray ######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('StreamId for ' + i +' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream' + i +' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannnelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + } +}).catch((err) => { + console.log('getCurrentAudioRendererInfoArray :ERROR: ' + err.message); +}); +``` + +### getCurrentAudioCapturerInfoArray<sup>9+</sup> + +getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void + +获å–当å‰éŸ³é¢‘采集器的信æ¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| ---------- | ----------------------------------- | --------- | -------------------------------------------------------- | +| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数,返回当å‰éŸ³é¢‘采集器的信æ¯ã€‚ | + +**示例:** +``` +audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); + if (err) { + console.log('getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + } else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for '+ i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i +'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + } + } +}); +``` + +### getCurrentAudioCapturerInfoArray<sup>9+</sup> + +getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray> + +获å–当å‰éŸ³é¢‘采集器的信æ¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -----------------------------------------------------------------------------| ----------------------------------- | +| Promise<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Promise对象,返回当å‰éŸ³é¢‘渲染器信æ¯ã€‚ | + +**示例:** +``` +await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name) + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + } +}).catch((err) => { + console.log('getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); +}); +``` + +### on('audioRendererChange')<sup>9+</sup> + +on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArray>): void + +监å¬éŸ³é¢‘渲染器更改事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------- | --------- | ------------------------------------------------------------------------ | +| type | string | 是 | 事件类型,支æŒçš„事件`'audioRendererChange'`:当音频渲染器å‘生更改时触å‘。 | +| callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | 是 | 回调函数。 | + +**示例:** +``` +audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('## RendererChange on is called for ' + i + ' ##'); + console.info('StreamId for ' + i + ' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } +}); +``` + +### off('audioRendererChange')<sup>9+</sup> + +off(type: "audioRendererChange"); + +å–消监å¬éŸ³é¢‘渲染器更改事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------- | ---- | ---------------- | +| type | string | 是 | 事件类型,支æŒçš„事件`'audioRendererChange'`:音频渲染器更改事件。 | + +**示例:** +``` +audioStreamManager.off('audioRendererChange'); +console.info('######### RendererChange Off is called #########'); +``` + +### on('audioCapturerChange')<sup>9+</sup> + +on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArray>): void + +监å¬éŸ³é¢‘æ•èŽ·å™¨æ›´æ”¹äº‹ä»¶ã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Capturer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------- | --------- | ------------------------------------------------------------------- ---- | +| type | string | 是 | 事件类型,支æŒçš„事件`'audioCapturerChange'`:当音频采集器å‘生更改时触å‘。 | +| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数。 | + +**示例:** +``` +audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(' ## CapChange on is called for element ' + i + ' ##'); + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } +}); +``` + +### off('audioCapturerChange')<sup>9+</sup> + +off(type: "audioCapturerChange"); + +å–消监å¬éŸ³é¢‘æ•èŽ·å™¨æ›´æ”¹äº‹ä»¶ã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Capturer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | --- | ------------------------------------------------------------- | +| type | string |是 | 事件类型,支æŒçš„事件`'audioCapturerChange'`:音频采集器更改事件。 | + +**示例:** +``` +audioStreamManager.off('audioCapturerChange'); +console.info('######### CapturerChange Off is called #########'); + +``` + +### isAudioRendererLowLatencySupported<sup>9+</sup> + +isAudioRendererLowLatencySupported(streaminfo: AudioStreamInfo, callback: Callback<boolean>): void; + +检查系统是å¦æ”¯æŒéŸ³é¢‘渲染器ä¸çš„低延迟é…置。使用callback异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| ---------- | ----------------------- | -------- | --------------------------------------- | +| streaminfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 音频渲染器æµä¿¡æ¯ã€‚ | +| callback | Callback<boolean> | 是 | 返回系统是å¦æ”¯æŒéŸ³é¢‘渲染器ä¸çš„低延迟é…置。 | + +**示例:** + +``` +var audioManager = audio.getAudioManager(); + +var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioStreamManager = audioManager.getStreamManager(); +audioStreamManager.isAudioRendererLowLatencySupported(AudioStreamInfo, (result) => { + console.info('isAudioRendererLowLatencySupported success var = ' + result); +}); +``` + +### isAudioRendererLowLatencySupported<sup>9+</sup> + +isAudioRendererLowLatencySupported(streaminfo: AudioStreamInfo): Promise<boolean> + +检查系统是å¦æ”¯æŒéŸ³é¢‘渲染器ä¸çš„低延迟é…置。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ------------------------------------ | ---- | ------------| +| streaminfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | æ•°æ®æµä¿¡æ¯ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ---------------------------------------------------- | +| Promise<void> | Promiseæ–¹å¼å¼‚æ¥è¿”回系统是å¦æ”¯æŒéŸ³é¢‘渲染器ä¸çš„低延迟é…置。 | + +**示例:** + +``` +var audioManager = audio.getAudioManager(); + +var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioStreamManager = await audioManager.getStreamManager(); +var result = audioStreamManager.isAudioRendererLowLatencySupported(AudioStreamInfo); +console.info('isAudioRendererLowLatencySupported success var =' + result); +``` + +## AudioRendererChangeInfo<sup>9+</sup> + +æ述音频渲染器更改信æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Audio.Renderer + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- | +| streamId | number | 是 | å¦ | 音频æµå”¯ä¸€id。 | +| clientUid | number | 是 | å¦ | 音频渲染器客户端应用程åºçš„Uid。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | å¦ | 音频渲染器信æ¯ã€‚ | +| rendererState | [AudioState](#audiostate) | 是 | å¦ | 音频状æ€ã€‚<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚| + +## AudioRendererChangeInfoArray<sup>9+</sup> + +AudioRenderChangeInfo数组,åªè¯»ã€‚ + +**系统能力:**: SystemCapability.Multimedia.Audio.Renderer + +**示例:** + +``` +import audio from '@ohos.multimedia.audio'; + +var audioStreamManager; +var audioStreamManagerCB; +var Tag = "AFCapLog : "; +var resultFlag = false; + +await audioManager.getStreamManager().then(async function (data) { + audioStreamManager = data; + console.info(Tag + 'Get AudioStream Manager : Success '); +}).catch((err) => { + console.info(Tag + 'Get AudioStream Manager : ERROR : ' + err.message); +}); + +audioManager.getStreamManager((err, data) => { + if (err) { + console.error(Tag + 'Get AudioStream Manager : ERROR : ' + err.message); + } else { + audioStreamManagerCB = data; + console.info(Tag + 'Get AudioStream Manager : Success '); + } +}); + +audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + console.info(Tag+'## RendererChange on is called for ' + i + ' ##'); + console.info(Tag+'StreamId for ' + i + 'is:' + AudioRendererChangeInfoArray[i].streamId); + console.info(Tag+'ClientUid for ' + i + 'is:' + AudioRendererChangeInfoArray[i].clientUid); + console.info(Tag+'Content for ' + i + 'is:' + AudioRendererChangeInfoArray[i].rendererInfo.content); + console.info(Tag+'Stream for ' + i + 'is:' + AudioRendererChangeInfoArray[i].rendererInfo.usage); + console.info(Tag+'Flag ' + i + 'is:' + AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags); + console.info(Tag+'State for ' + i + 'is:' + AudioRendererChangeInfoArray[i].rendererState); + var devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(Tag+'Id:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].id); + console.info(Tag+'Type:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info(Tag+'Role:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info(Tag+'Name:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].name); + console.info(Tag+'Addr:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].address); + console.info(Tag+'SR:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info(Tag+'C' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info(Tag+'CM:' + i + ':' + AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) { + resultFlag = true; + console.info(Tag + 'ResultFlag for '+ i +' is:'+ resultFlag); + } + } +}); +``` + +## AudioCapturerChangeInfo<sup>9+</sup> + +æ述音频æ•èŽ·å™¨æ›´æ”¹ä¿¡æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Audio.Capturer + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- | +| streamId | number | 是 | å¦ | 音频æµå”¯ä¸€id。 | +| clientUid | number | 是 | å¦ | 音频渲染器客户端应用程åºçš„Uid。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | å¦ | 音频渲染器信æ¯ã€‚ | +| capturerState | [AudioState](#audiostate) | 是 | å¦ | 音频状æ€ã€‚<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚| + +## AudioCapturerChangeInfoArray<sup>9+</sup> + +AudioCapturerChangeInfo数组,åªè¯»ã€‚ + +**系统能力:** SystemCapability.Multimedia.Audio.Capturer + +**示例:** + +``` +import audio from '@ohos.multimedia.audio'; + +const audioManager = audio.getAudioManager(); +var Tag = "AFCapLog : "; +var resultFlag = false; +audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(Tag + ' ## CapChange on is called for element ' + i + ' ##'); + console.info(Tag + 'StrId for ' + i +'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info(Tag + 'CUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info(Tag + 'Src for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info(Tag + 'Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info(Tag + 'State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(Tag + 'Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info(Tag + 'Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info(Tag + 'Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info(Tag + 'Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); + console.info(Tag + 'Addr:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info(Tag + 'SR:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info(Tag + 'C' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info(Tag + 'CM:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { + resultFlag = true; + console.info(Tag + 'ResultFlag for element ' + i + ' is: ' + resultFlag); + } + } }); ``` @@ -1845,10 +2401,16 @@ audioManager.getAudioScene().then((value) => { **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Audio.Device -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ---------- | ------------------------- | ---- | ---- | ---------- | -| deviceRole | [DeviceRole](#devicerole) | 是 | å¦ | 设备角色。 | -| deviceType | [DeviceType](#devicetype) | 是 | å¦ | 设备类型。 | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------------------------- | -------------------------- | ---- | ---- | ---------- | +| deviceRole | [DeviceRole](#devicerole) | 是 | å¦ | 设备角色。 | +| deviceType | [DeviceType](#devicetype) | 是 | å¦ | 设备类型。 | +| id<sup>9+</sup> | number | 是 | å¦ | 设备id。 | +| name<sup>9+</sup> | string | 是 | å¦ | 设备å称。 | +| address<sup>9+</sup> | string | 是 | å¦ | 设备地å€ã€‚ | +| sampleRates<sup>9+</sup> | Array<number> | 是 | å¦ | 支æŒçš„é‡‡æ ·çŽ‡ã€‚ | +| channelCounts<sup>9+</sup> | Array<number> | 是 | å¦ | 支æŒçš„通é“数。 | +| channelMasks<sup>9+</sup> | Array<number> | 是 | å¦ | 支æŒçš„通é“掩ç 。 | ## AudioDeviceDescriptors @@ -1860,23 +2422,21 @@ audioManager.getAudioScene().then((value) => { import audio from '@ohos.multimedia.audio'; function displayDeviceProp(value) { - deviceRoleValue = value.deviceRole; - deviceTypeValue = value.deviceType; - + deviceRoleValue = value.deviceRole; + deviceTypeValue = value.deviceType; } var deviceRoleValue = null; var deviceTypeValue = null; const promise = audio.getAudioManager().getDevices(1); promise.then(function (value) { - console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG'); - value.forEach(displayDeviceProp); - if (deviceTypeValue != null && deviceRoleValue != null){ - console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS'); - } - else{ - console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL'); - } + console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG'); + value.forEach(displayDeviceProp); + if (deviceTypeValue != null && deviceRoleValue != null){ + console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS'); + } else { + console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL'); + } }); ``` @@ -1904,7 +2464,7 @@ getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void 获å–当å‰è¢«åˆ›å»ºçš„音频渲染器的信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -1916,10 +2476,10 @@ getRendererInfo(callback: AsyncCallback<AudioRendererInfo\>): void ``` audioRenderer.getRendererInfo((err, rendererInfo) => { - console.log('Renderer GetRendererInfo:'); - console.log('Renderer content:' + rendererInfo.content); - console.log('Renderer usage:' + rendererInfo.usage); - console.log('Renderer flags:' + rendererInfo.rendererFlags); + console.log('Renderer GetRendererInfo:'); + console.log('Renderer content:' + rendererInfo.content); + console.log('Renderer usage:' + rendererInfo.usage); + console.log('Renderer flags:' + rendererInfo.rendererFlags); }); ``` @@ -1929,7 +2489,7 @@ getRendererInfo(): Promise<AudioRendererInfo\> 获å–当å‰è¢«åˆ›å»ºçš„音频渲染器的信æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -1942,13 +2502,13 @@ getRendererInfo(): Promise<AudioRendererInfo\> ``` var resultFlag = true; audioRenderer.getRendererInfo().then((rendererInfo) => { - console.log('Renderer GetRendererInfo:'); - console.log('Renderer content:' + rendererInfo.content); - console.log('Renderer usage:' + rendererInfo.usage); - console.log('Renderer flags:' + rendererInfo.rendererFlags); + console.log('Renderer GetRendererInfo:'); + console.log('Renderer content:' + rendererInfo.content); + console.log('Renderer usage:' + rendererInfo.usage); + console.log('Renderer flags:' + rendererInfo.rendererFlags); }).catch((err) => { - console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); - resultFlag = false; + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: ' + err.message); + resultFlag = false; }); ``` @@ -1958,7 +2518,7 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void 获å–音频æµä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -1970,11 +2530,11 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void ``` audioRenderer.getStreamInfo((err, streamInfo) => { - console.log('Renderer GetStreamInfo:'); - console.log('Renderer sampling rate:' + streamInfo.samplingRate); - console.log('Renderer channel:' + streamInfo.channels); - console.log('Renderer format:' + streamInfo.sampleFormat); - console.log('Renderer encoding type:' + streamInfo.encodingType); + console.log('Renderer GetStreamInfo:'); + console.log('Renderer sampling rate:' + streamInfo.samplingRate); + console.log('Renderer channel:' + streamInfo.channels); + console.log('Renderer format:' + streamInfo.sampleFormat); + console.log('Renderer encoding type:' + streamInfo.encodingType); }); ``` @@ -1984,7 +2544,7 @@ getStreamInfo(): Promise<AudioStreamInfo\> 获å–音频æµä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -1996,13 +2556,13 @@ getStreamInfo(): Promise<AudioStreamInfo\> ``` audioRenderer.getStreamInfo().then((streamInfo) => { - console.log('Renderer GetStreamInfo:'); - console.log('Renderer sampling rate:' + streamInfo.samplingRate); - console.log('Renderer channel:' + streamInfo.channels); - console.log('Renderer format:' + streamInfo.sampleFormat); - console.log('Renderer encoding type:' + streamInfo.encodingType); + console.log('Renderer GetStreamInfo:'); + console.log('Renderer sampling rate:' + streamInfo.samplingRate); + console.log('Renderer channel:' + streamInfo.channels); + console.log('Renderer format:' + streamInfo.sampleFormat); + console.log('Renderer encoding type:' + streamInfo.encodingType); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+err.message); }); ``` @@ -2012,7 +2572,7 @@ start(callback: AsyncCallback<void\>): void å¯åŠ¨éŸ³é¢‘渲染器。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2024,11 +2584,11 @@ start(callback: AsyncCallback<void\>): void ``` audioRenderer.start((err) => { - if (err) { - console.error('Renderer start failed.'); - } else { - console.info('Renderer start success.'); - } + if (err) { + console.error('Renderer start failed.'); + } else { + console.info('Renderer start success.'); + } }); ``` @@ -2038,7 +2598,7 @@ start(): Promise<void\> å¯åŠ¨éŸ³é¢‘渲染器。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2050,9 +2610,9 @@ start(): Promise<void\> ``` audioRenderer.start().then(() => { - console.log('Renderer started'); + console.log('Renderer started'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: ' + err.message); }); ``` @@ -2062,7 +2622,7 @@ pause(callback: AsyncCallback\<void>): void æš‚åœæ¸²æŸ“。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2074,11 +2634,11 @@ pause(callback: AsyncCallback\<void>): void ``` audioRenderer.pause((err) => { - if (err) { - console.error('Renderer pause failed'); - } else { - console.log('Renderer paused.'); - } + if (err) { + console.error('Renderer pause failed'); + } else { + console.log('Renderer paused.'); + } }); ``` @@ -2088,7 +2648,7 @@ pause(): Promise\<void> æš‚åœæ¸²æŸ“。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2100,9 +2660,9 @@ pause(): Promise\<void> ``` audioRenderer.pause().then(() => { - console.log('Renderer paused'); + console.log('Renderer paused'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+err.message); }); ``` @@ -2112,7 +2672,7 @@ drain(callback: AsyncCallback\<void>): void 检查缓冲区是å¦å·²è¢«è€—尽。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2124,11 +2684,11 @@ drain(callback: AsyncCallback\<void>): void ``` audioRenderer.drain((err) => { - if (err) { - console.error('Renderer drain failed'); - } else { - console.log('Renderer drained.'); - } + if (err) { + console.error('Renderer drain failed'); + } else { + console.log('Renderer drained.'); + } }); ``` @@ -2138,7 +2698,7 @@ drain(): Promise\<void> 检查缓冲区是å¦å·²è¢«è€—尽。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2150,9 +2710,9 @@ drain(): Promise\<void> ``` audioRenderer.drain().then(() => { - console.log('Renderer drained successfully'); + console.log('Renderer drained successfully'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+ err.message); }); ``` @@ -2162,7 +2722,7 @@ stop(callback: AsyncCallback\<void>): void åœæ¢æ¸²æŸ“。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2174,11 +2734,11 @@ stop(callback: AsyncCallback\<void>): void ``` audioRenderer.stop((err) => { - if (err) { - console.error('Renderer stop failed'); - } else { - console.log('Renderer stopped.'); - } + if (err) { + console.error('Renderer stop failed'); + } else { + console.log('Renderer stopped.'); + } }); ``` @@ -2188,7 +2748,7 @@ stop(): Promise\<void> åœæ¢æ¸²æŸ“。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2200,9 +2760,9 @@ stop(): Promise\<void> ``` audioRenderer.stop().then(() => { - console.log('Renderer stopped successfully'); + console.log('Renderer stopped successfully'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: ' + err.message); }); ``` @@ -2212,7 +2772,7 @@ release(callback: AsyncCallback\<void>): void 释放音频渲染器。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2224,11 +2784,11 @@ release(callback: AsyncCallback\<void>): void ``` audioRenderer.release((err) => { - if (err) { - console.error('Renderer release failed'); - } else { - console.log('Renderer released.'); - } + if (err) { + console.error('Renderer release failed'); + } else { + console.log('Renderer released.'); + } }); ``` @@ -2238,7 +2798,7 @@ release(): Promise\<void> 释放渲染器。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2250,9 +2810,9 @@ release(): Promise\<void> ``` audioRenderer.release().then(() => { - console.log('Renderer released successfully'); + console.log('Renderer released successfully'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+ err.message); }); ``` @@ -2262,7 +2822,7 @@ write(buffer: ArrayBuffer, callback: AsyncCallback\<number>): void 写入缓冲区。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2276,16 +2836,52 @@ write(buffer: ArrayBuffer, callback: AsyncCallback\<number>): void ``` import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility' +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION + rendererFlags: 0 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data)=> { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ' + err.message); + }); +var bufferSize; +audioRenderer.getBufferSize().then((data)=> { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS ' + data); + bufferSize = data; + }).catch((err) => { + console.info.('AudioFrameworkRenderLog: getBufferSize: ERROR: ' + err.message); + }); +console.info('Buffer size:'+bufferSize); +var context = featureAbility.getContext(); +var path = await context.getCacheDir(); +var filePath = path + "/StarWars10s-2C-48000-4SW.wav"; let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); ss.readSync(buf); audioRenderer.write(buf, (err, writtenbytes) => { - if (writtenbytes < 0) { - console.error('write failed.'); - } else { - console.log('Actual written bytes: ' + writtenbytes); - } + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.log('Actual written bytes: ' + writtenbytes); + } }); ``` @@ -2295,7 +2891,7 @@ write(buffer: ArrayBuffer): Promise\<number> 写入缓冲区。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2308,19 +2904,54 @@ write(buffer: ArrayBuffer): Promise\<number> ``` import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility' +var audioStreamInfo = { + samplingRate:audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels:audio.AudioChannel.CHANNEL_2, + sampleFormat:audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType:audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ' + err.message); + }); +var bufferSize; +audioRenderer.getBufferSize().then((data) => { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS ' + data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: ' + err.message); + }); +console.info('BufferSize: ' + bufferSize); +var context = featureAbility.getContext(); +var path = await context.getCacheDir(); var filePath = 'data/StarWars10s-2C-48000-4SW.wav'; let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); ss.readSync(buf); audioRenderer.write(buf).then((writtenbytes) => { - if (writtenbytes < 0) { - console.error('write failed.'); - } else { - console.log('Actual written bytes: ' + writtenbytes); - } + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.log('Actual written bytes: ' + writtenbytes); + } }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+ err.message); }); ``` @@ -2330,7 +2961,7 @@ getAudioTime(callback: AsyncCallback\<number>): void 获å–时间戳(从 1970 å¹´ 1 月 1 日开始)。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2342,7 +2973,7 @@ getAudioTime(callback: AsyncCallback\<number>): void ``` audioRenderer.getAudioTime((err, timestamp) => { - console.log('Current timestamp: ' + timestamp); + console.log('Current timestamp: ' + timestamp); }); ``` @@ -2352,7 +2983,7 @@ getAudioTime(): Promise\<number> 获å–时间戳(从 1970 å¹´ 1 月 1 日开始)。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2364,9 +2995,9 @@ getAudioTime(): Promise\<number> ``` audioRenderer.getAudioTime().then((timestamp) => { - console.log('Current timestamp: ' + timestamp); + console.log('Current timestamp: ' + timestamp); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+err.message); }); ``` @@ -2376,7 +3007,7 @@ getBufferSize(callback: AsyncCallback\<number>): void 获å–音频渲染器的最å°ç¼“冲区大å°ã€‚使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2388,9 +3019,9 @@ getBufferSize(callback: AsyncCallback\<number>): void ``` var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { - if (err) { - console.error('getBufferSize error'); - } + if (err) { + console.error('getBufferSize error'); + } }); ``` @@ -2400,7 +3031,7 @@ getBufferSize(): Promise\<number> 获å–音频渲染器的最å°ç¼“冲区大å°ã€‚使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2411,12 +3042,39 @@ getBufferSize(): Promise\<number> **示例:** ``` +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; + +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +var audioRenderer; +audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info('AudioFrameworkRenderLog: AudioRenderer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRenderer Created: ERROR: ' + err.message); + }); var bufferSize; -await audioRenderer.getBufferSize().then(async function (data) => { - console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data); - bufferSize=data; +audioRenderer.getBufferSize().then((data) => { + console.info('AudioFrameworkRenderLog: getBufferSize: SUCCESS ' + data); + bufferSize = data; }).catch((err) => { - console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message); + console.info('AudioFrameworkRenderLog: getBufferSize: ERROR: ' + err.message); }); ``` @@ -2426,7 +3084,7 @@ setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\<void>): void 设置音频渲染速率。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2439,11 +3097,11 @@ setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\<void>): void ``` audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => { - if (err) { - console.error('Failed to set params'); - } else { - console.log('Callback invoked to indicate a successful render rate setting.'); - } + if (err) { + console.error('Failed to set params'); + } else { + console.log('Callback invoked to indicate a successful render rate setting.'); + } }); ``` @@ -2453,7 +3111,7 @@ setRenderRate(rate: AudioRendererRate): Promise\<void> 设置音频渲染速率。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2471,9 +3129,9 @@ setRenderRate(rate: AudioRendererRate): Promise\<void> ``` audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { - console.log('setRenderRate SUCCESS'); + console.log('setRenderRate SUCCESS'); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+ err.message); }); ``` @@ -2483,7 +3141,7 @@ getRenderRate(callback: AsyncCallback\<AudioRendererRate>): void 获å–当å‰æ¸²æŸ“速率。使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2495,7 +3153,7 @@ getRenderRate(callback: AsyncCallback\<AudioRendererRate>): void ``` audioRenderer.getRenderRate((err, renderrate) => { - console.log('getRenderRate: ' + renderrate); + console.log('getRenderRate: ' + renderrate); }); ``` @@ -2505,7 +3163,7 @@ getRenderRate(): Promise\<AudioRendererRate> 获å–当å‰æ¸²æŸ“速率。使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **返回值:** @@ -2517,14 +3175,14 @@ getRenderRate(): Promise\<AudioRendererRate> ``` audioRenderer.getRenderRate().then((renderRate) => { - console.log('getRenderRate: ' + renderRate); + console.log('getRenderRate: ' + renderRate); }).catch((err) => { - console.log('ERROR: '+err.message); + console.log('ERROR: '+ err.message); }); ``` ### setInterruptMode<sup>9+</sup> -setInterruptMode(interruptMode: InterruptMode): Promise<void> +setInterruptMode(mode: InterruptMode): Promise<void> 设置应用的焦点模型。使用Promise异æ¥å›žè°ƒã€‚ @@ -2532,9 +3190,9 @@ setInterruptMode(interruptMode: InterruptMode): Promise<void> **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| interruptMode | [InterruptMode](#InterruptMode) | 是 | 焦点模型。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ---------------------------------- | ------ | ---------- | +| mode | [InterruptMode](#interruptmode9) | 是 | 焦点模型。 | **返回值:** @@ -2545,13 +3203,32 @@ setInterruptMode(interruptMode: InterruptMode): Promise<void> **示例:** ``` -audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE).then(() => { - console.log('Promise returned to indicate a successful volume setting.'); +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 +} +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +let mode = 0; +audioRenderer.setInterruptMode(mode).then(data=>{ + console.log("setInterruptMode Success!"); +}).catch(err=>{ + console.log("setInterruptMode Fail:" + err.message); }); ``` ### setInterruptMode<sup>9+</sup> -setInterruptMode(interruptMode: InterruptMode, callback: Callback\<void>): void +setInterruptMode(mode: InterruptMode, callback: Callback\<void>): void 设置应用的焦点模型。使用Callback回调返回执行结果。 @@ -2559,16 +3236,36 @@ setInterruptMode(interruptMode: InterruptMode, callback: Callback\<void>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -|interruptMode | [InterruptMode](#InterruptMode) | 是 | 焦点模型。| -|callback | Callback\<void> | 是 |回调返回执行结果。| +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ------ | -------------- | +|mode | [InterruptMode](#interruptmode9) | 是 | 焦点模型。| +|callback | Callback\<void> | 是 |回调返回执行结果。| **示例:** ``` -audioManager.setInterruptMode(audio.InterruptType.SHARE_MODE,()=>{ - console.log('Callback returned to indicate a successful volume setting.'); +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 +} +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} +let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +let mode = 1; +audioRenderer.setInterruptMode(mode, (err, data)=>{ + if(err){ + console.log("setInterruptMode Fail:" + err.message); + } + console.log("setInterruptMode Success!"); }); ``` ### on('interrupt')<sup>9+</sup> @@ -2577,7 +3274,7 @@ on(type: 'interrupt', callback: Callback\<InterruptEvent>): void 监å¬éŸ³é¢‘ä¸æ–事件。使用callback获å–ä¸æ–事件。 -**系统能力**: SystemCapability.Multimedia.Audio.Renderer +**系统能力:** SystemCapability.Multimedia.Audio.Renderer **å‚数:** @@ -2592,48 +3289,47 @@ on(type: 'interrupt', callback: Callback\<InterruptEvent>): void 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: - console.log('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.log('Force stopped. Stop writing'); - isPlay = false; - break; + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Force paused. Stop writing'); + isPlay = false; + break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.log('Force stopped. Stop writing'); + isPlay = false; + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + console.log('Resume force paused renderer or ignore'); + 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'); } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.log('Resume force paused renderer or ignore'); - 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'); - if (isPlay == true) { - isPlay == false; - console.info('AudioInterruptMusic: Media PAUSE : TRUE'); - } - else { - isPlay = true; - console.info('AudioInterruptMusic: Media PLAY : TRUE'); - } - break; + break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Choose to pause or ignore'); + if (isPlay == true) { + isPlay == false; + console.info('AudioInterruptMusic: Media PAUSE : TRUE'); + } else { + isPlay = true; + console.info('AudioInterruptMusic: Media PLAY : TRUE'); } + break; } + } }); ``` @@ -2657,9 +3353,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void ``` audioRenderer.on('markReach', 1000, (position) => { - if (position == "1000") { - console.log('ON Triggered successfully'); - } + if (position == 1000) { + console.log('ON Triggered successfully'); + } }); ``` @@ -2704,9 +3400,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void ``` audioRenderer.on('periodReach', 1000, (position) => { - if (position == "1000") { - console.log('ON Triggered successfully'); - } + if (position == 1000) { + console.log('ON Triggered successfully'); + } }); ``` @@ -2749,15 +3445,44 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void ``` audioRenderer.on('stateChange', (state) => { - if (state == 1) { - console.log("audio renderer state is: STATE_PREPARED"); - } - if (state == 2) { - console.log("audio renderer state is: STATE_RUNNING"); - } + if (state == 1) { + console.log("audio renderer state is: STATE_PREPARED"); + } + if (state == 2) { + console.log("audio renderer state is: STATE_RUNNING"); + } }); ``` +### on('dataRequest') <sup>9+</sup> + +on(type: "dataRequest", callback: Callback\<AudioRendererDataInfo>): void; + +订阅音频数æ®requeset事件回调。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------- | --------- | ------------------------------------------------------------------- | +| type | string | 是 | 事件类型。值**dataRequest**表示数æ®è¯·æ±‚事件。 | +| callback | [AudioRendererDataInfo](#audiorendererdatainfo9) | 是 | 需è¦éŸ³é¢‘æ•°æ®æ—¶è°ƒç”¨å›žè°ƒã€‚| + +**示例:** +``` +const path = '/data/storage/el2/ba se/haps/entry/cache/PinkPanther60-44100-1c.wav'; + let ss = fileio.createStreamSync(path, 'r'); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let rlen = 0; + audioRenderer.on('dataRequest', (audioRendererDataInfo) => { + var viewObject = new DataView(audioRendererDataInfo.buffer); + rlen += ss.readSync(viewObject.buffer); + console.info('AudioRenderLog: bytes read from file: ' + rlen); + }) +``` + ## AudioCapturer<sup>8+</sup> æ供音频采集的相关接å£ã€‚在调用AudioCapturer的接å£å‰ï¼Œéœ€è¦å…ˆé€šè¿‡[createAudioCapturer](#audiocreateaudiocapturer8)创建实例。 @@ -2794,13 +3519,13 @@ getCapturerInfo(callback: AsyncCallback<AudioCapturerInfo\>): void ``` audioCapturer.getCapturerInfo((err, capturerInfo) => { - if (err) { - console.error('Failed to get capture info'); - } else { - console.log('Capturer getCapturerInfo:'); - console.log('Capturer source:' + capturerInfo.source); - console.log('Capturer flags:' + capturerInfo.capturerFlags); - } + if (err) { + console.error('Failed to get capture info'); + } else { + console.log('Capturer getCapturerInfo:'); + console.log('Capturer source:' + capturerInfo.source); + console.log('Capturer flags:' + capturerInfo.capturerFlags); + } }); ``` @@ -2823,16 +3548,16 @@ getCapturerInfo(): Promise<AudioCapturerInfo\> ``` audioCapturer.getCapturerInfo().then((audioParamsGet) => { - if (audioParamsGet != undefined) { - console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); - console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); - console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); - }else { - console.info('AudioFrameworkRecLog: audioParamsGet is : '+audioParamsGet); - console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: '); - } + if (audioParamsGet != undefined) { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + } else { + console.info('AudioFrameworkRecLog: audioParamsGet is : '+ audioParamsGet); + console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: '); + } }).catch((err) => { - console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+ err.message); }); ``` @@ -2854,15 +3579,15 @@ getStreamInfo(callback: AsyncCallback<AudioStreamInfo\>): void ``` audioCapturer.getStreamInfo((err, streamInfo) => { - if (err) { - console.error('Failed to get stream info'); - } else { - console.log('Capturer GetStreamInfo:'); - console.log('Capturer sampling rate:' + streamInfo.samplingRate); - console.log('Capturer channel:' + streamInfo.channels); - console.log('Capturer format:' + streamInfo.sampleFormat); - console.log('Capturer encoding type:' + streamInfo.encodingType); - } + if (err) { + console.error('Failed to get stream info'); + } else { + console.log('Capturer GetStreamInfo:'); + console.log('Capturer sampling rate:' + streamInfo.samplingRate); + console.log('Capturer channel:' + streamInfo.channels); + console.log('Capturer format:' + streamInfo.sampleFormat); + console.log('Capturer encoding type:' + streamInfo.encodingType); + } }); ``` @@ -2884,13 +3609,13 @@ getStreamInfo(): Promise<AudioStreamInfo\> ``` audioCapturer.getStreamInfo().then((audioParamsGet) => { - console.info('getStreamInfo:'); - console.info('sampleFormat:' + audioParamsGet.sampleFormat); - console.info('samplingRate:' + audioParamsGet.samplingRate); - console.info('channels:' + audioParamsGet.channels); - console.info('encodingType:' + audioParamsGet.encodingType); + console.info('getStreamInfo:'); + console.info('sampleFormat:' + audioParamsGet.sampleFormat); + console.info('samplingRate:' + audioParamsGet.samplingRate); + console.info('channels:' + audioParamsGet.channels); + console.info('encodingType:' + audioParamsGet.encodingType); }).catch((err) => { - console.log('getStreamInfo :ERROR: ' + err.message); + console.log('getStreamInfo :ERROR: ' + err.message); }); ``` @@ -2902,7 +3627,7 @@ start(callback: AsyncCallback<void\>): void **系统能力:** SystemCapability.Multimedia.Audio.Capturer -**å‚æ•°** +**å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | :------- | :------------------- | :--- | :----------------------------- | @@ -2912,11 +3637,11 @@ start(callback: AsyncCallback<void\>): void ``` audioCapturer.start((err) => { - if (err) { - console.error('Capturer start failed.'); - } else { - console.info('Capturer start success.'); - } + if (err) { + console.error('Capturer start failed.'); + } else { + console.info('Capturer start success.'); + } }); ``` @@ -2938,17 +3663,40 @@ start(): Promise<void\> **示例:** ``` +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; + +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 +} + +var audioCapturer; +var stateFlag; +audio.createAudioCapturer(audioCapturerOptions).then((data) => { + audioCapturer = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created: ERROR: ' + err.message); + }); audioCapturer.start().then(() => { - console.info('AudioFrameworkRecLog: ---------START---------'); - console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); - console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state); - console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); - if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { - stateFlag = true; - } + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer: STATE: ' + audioCapturer.state); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS '); + if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { + console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); + } }).catch((err) => { - console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); - stateFlag=false; + console.info('AudioFrameworkRecLog: Capturer start :ERROR : ' + err.message); + stateFlag = false; }); ``` @@ -2970,11 +3718,11 @@ stop(callback: AsyncCallback<void\>): void ``` audioCapturer.stop((err) => { - if (err) { - console.error('Capturer stop failed'); - } else { - console.log('Capturer stopped.'); - } + if (err) { + console.error('Capturer stop failed'); + } else { + console.log('Capturer stopped.'); + } }); ``` @@ -2997,15 +3745,13 @@ stop(): Promise<void\> ``` audioCapturer.stop().then(() => { - console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); - console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); - if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ - stateFlag=true; - console.info('AudioFrameworkRecLog: resultFlag : '+stateFlag); - } + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS'); + if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ + console.info('AudioFrameworkRecLog: State is Stopped': '); + } }).catch((err) => { - console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); - stateFlag=false; + console.info('AudioFrameworkRecLog: Capturer stop: ERROR: '+ err.message); }); ``` @@ -3027,11 +3773,11 @@ release(callback: AsyncCallback<void\>): void ``` audioCapturer.release((err) => { - if (err) { - console.error('capturer release failed'); - } else { - console.log('capturer released.'); - } + if (err) { + console.error('capturer release failed'); + } else { + console.log('capturer released.'); + } }); ``` @@ -3053,15 +3799,14 @@ release(): Promise<void\> **示例:** ``` +var stateFlag; audioCapturer.release().then(() => { - console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); - console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); - console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapturer.state); - stateFlag=true; - console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapturer.state); + console.info('AudioFrameworkRecLog: stateFlag : ' + stateFlag); }).catch((err) => { - console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); - stateFlag=false + console.info('AudioFrameworkRecLog: Capturer stop: ERROR: ' + err.message); }); ``` @@ -3074,7 +3819,7 @@ read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\ **系统能力:** SystemCapability.Multimedia.Audio.Capturer -**å‚æ•°** +**å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | :------------- | :-------------------------- | :--- | :------------------------------- | @@ -3085,10 +3830,17 @@ read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer\ **示例:** ``` +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS ' + data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize: EROOR: ' + err.message); + }); audioCapturer.read(bufferSize, true, async(err, buffer) => { - if (!err) { - console.log("Success in reading the buffer data"); - } + if (!err) { + console.log("Success in reading the buffer data"); + } }); ``` @@ -3117,10 +3869,18 @@ read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer\> **示例:** ``` +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize: SUCCESS ' + data); + bufferSize = data; + }).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize: ERROR ' + err.message); + }); +console.info('Buffer size: ' + bufferSize); audioCapturer.read(bufferSize, true).then((buffer) => { - console.info('buffer read successfully'); + console.info('buffer read successfully'); }).catch((err) => { - console.info('ERROR : '+err.message); + console.info('ERROR : ' + err.message); }); ``` @@ -3143,7 +3903,7 @@ getAudioTime(callback: AsyncCallback<number\>): void ``` audioCapturer.getAudioTime((err, timestamp) => { - console.log('Current timestamp: ' + timestamp); + console.log('Current timestamp: ' + timestamp); }); ``` @@ -3166,9 +3926,9 @@ getAudioTime(): Promise<number\> ``` audioCapturer.getAudioTime().then((audioTime) => { - console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime ); + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime ); }).catch((err) => { - console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message); }); ``` @@ -3191,14 +3951,14 @@ getBufferSize(callback: AsyncCallback<number\>): void ``` audioCapturer.getBufferSize((err, bufferSize) => { - if (!err) { - console.log('BufferSize : ' + bufferSize); - audioCapturer.read(bufferSize, true).then((buffer) => { - console.info('Buffer read is ' + buffer ); - }).catch((err) => { - console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); - }); - } + if (!err) { + console.log('BufferSize : ' + bufferSize); + audioCapturer.read(bufferSize, true).then((buffer) => { + console.info('Buffer read is ' + buffer ); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message); + }); + } }); ``` @@ -3220,12 +3980,12 @@ getBufferSize(): Promise<number\> **示例:** ``` -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('AudioFrameworkRecordLog: getBufferSize :ERROR : '+err.message); +var bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info('AudioFrameworkRecLog: getBufferSize :SUCCESS ' + data); + bufferSize = data; +}).catch((err) => { + console.info('AudioFrameworkRecLog: getBufferSize :ERROR : ' + err.message); }); ``` @@ -3250,9 +4010,9 @@ on(type: 'markReach', frame: number, callback: (position: number) => {}): void ``` audioCapturer.on('markReach', 1000, (position) => { - if (position == "1000") { - console.log('ON Triggered successfully'); - } + if (position == 1000) { + console.log('ON Triggered successfully'); + } }); ``` @@ -3296,9 +4056,9 @@ on(type: "periodReach", frame: number, callback: (position: number) => {}): void ``` audioCapturer.on('periodReach', 1000, (position) => { - if (position == "1000") { - console.log('ON Triggered successfully'); - } + if (position == 1000) { + console.log('ON Triggered successfully'); + } }); ``` @@ -3341,11 +4101,11 @@ on(type: 'stateChange', callback: Callback<AudioState\>): void ``` audioCapturer.on('stateChange', (state) => { - if (state == 1) { - console.log("audio capturer state is: STATE_PREPARED"); - } - if (state == 2) { - console.log("audio capturer state is: STATE_RUNNING"); - } + if (state == 1) { + console.log("audio capturer state is: STATE_PREPARED"); + } + if (state == 2) { + console.log("audio capturer state is: STATE_RUNNING"); + } }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 72df09a27aeea1ded115ce80ff357e4eb0be6258..9ca31d90c80c2b07be0cfe4b763b2cda079b7cde 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -8,13 +8,13 @@ 应用ä¸å˜åœ¨ç”¨æˆ·èƒ½å¤Ÿç›´è§‚æ„Ÿå—到的且需è¦ä¸€ç›´åœ¨åŽå°è¿è¡Œçš„业务时(如,åŽå°æ’放音ä¹ï¼‰ï¼Œå¯ä»¥ä½¿ç”¨é•¿æ—¶ä»»åŠ¡æœºåˆ¶ã€‚ ->  **说明:** +> **说明:** > 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— -``` +```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; ``` @@ -143,12 +143,12 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| --------- | ---------------------------------- | ---- | ------------------------ | -| context | [Context](js-apis-Context.md) | 是 | 应用è¿è¡Œçš„上下文。 | -| bgMode | [BackgroundMode](#backgroundmode8) | 是 | å‘系统申请的åŽå°æ¨¡å¼ã€‚ | -| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知å‚数,用于指定长时任务通知点击åŽè·³è½¬çš„ç•Œé¢ã€‚ | -| callback | AsyncCallback<void> | 是 | callbackå½¢å¼è¿”回å¯åŠ¨é•¿æ—¶ä»»åŠ¡çš„结果。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ---------------------------------- | ---- | ---------------------------------------- | +| context | Context | 是 | 应用è¿è¡Œçš„上下文。<br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。 | +| bgMode | [BackgroundMode](#backgroundmode8) | 是 | å‘系统申请的åŽå°æ¨¡å¼ã€‚ | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知å‚数,用于指定长时任务通知点击åŽè·³è½¬çš„ç•Œé¢ã€‚ | +| callback | AsyncCallback<void> | 是 | callbackå½¢å¼è¿”回å¯åŠ¨é•¿æ—¶ä»»åŠ¡çš„结果。 | **示例**: ```js @@ -195,11 +195,11 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| --------- | ---------------------------------- | ---- | ----------------------- | -| context | [Context](js-apis-Context.md) | 是 | 应用è¿è¡Œçš„上下文。 | -| bgMode | [BackgroundMode](#backgroundmode8) | 是 | å‘系统申请的åŽå°æ¨¡å¼ã€‚ | -| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知å‚数,用于指定长时任务通知点击跳转的界é¢ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ---------------------------------- | ---- | ---------------------------------------- | +| context | Context | 是 | 应用è¿è¡Œçš„上下文。<br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。 | +| bgMode | [BackgroundMode](#backgroundmode8) | 是 | å‘系统申请的åŽå°æ¨¡å¼ã€‚ | +| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知å‚数,用于指定长时任务通知点击跳转的界é¢ã€‚ | **返回值** | 类型 | 说明 | @@ -244,10 +244,10 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------- | ---- | ---------------------- | -| context | [Context](js-apis-Context.md) | 是 | 应用è¿è¡Œçš„上下文。 | -| callback | AsyncCallback<void> | 是 | callbackå½¢å¼è¿”回å¯åŠ¨é•¿æ—¶ä»»åŠ¡çš„结果。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| context | Context | 是 | 应用è¿è¡Œçš„上下文。<br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。 | +| callback | AsyncCallback<void> | 是 | callbackå½¢å¼è¿”回å¯åŠ¨é•¿æ—¶ä»»åŠ¡çš„结果。 | **示例**: ```js @@ -275,9 +275,9 @@ stopBackgroundRunning(context: Context): Promise<void> **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------- | ----------------------------- | ---- | --------- | -| context | [Context](js-apis-Context.md) | 是 | 应用è¿è¡Œçš„上下文。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------- | ---- | ---------------------------------------- | +| context | Context | 是 | 应用è¿è¡Œçš„上下文。<br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。 | **返回值** | 类型 | 说明 | @@ -301,7 +301,7 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() 延迟挂起信æ¯ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | --------------- | ------ | ---- | ---------------------------------------- | @@ -311,16 +311,16 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() ## BackgroundMode<sup>8+</sup> -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask - -| å‚æ•°å | å‚数值 | æè¿° | -| ----------------------- | ------ | ------------------------------------------------------------ | -| DATA_TRANSFER | 1 | æ•°æ®ä¼ 输 | -| AUDIO_PLAYBACK | 2 | 音频æ’放 | -| AUDIO_RECORDING | 3 | 录音 | -| LOCATION | 4 | 定ä½å¯¼èˆª | -| BLUETOOTH_INTERACTION | 5 | è“牙相关 | -| MULTI_DEVICE_CONNECTION | 6 | å¤šè®¾å¤‡äº’è” | -| WIFI_INTERACTION | 7 | WLAN相关<br />**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| VOIP | 8 | 音视频通è¯<br />**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效) | \ No newline at end of file +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + +| å‚æ•°å | å‚数值 | æè¿° | +| ----------------------- | ---- | --------------------- | +| DATA_TRANSFER | 1 | æ•°æ®ä¼ 输 | +| AUDIO_PLAYBACK | 2 | 音频æ’放 | +| AUDIO_RECORDING | 3 | 录音 | +| LOCATION | 4 | 定ä½å¯¼èˆª | +| BLUETOOTH_INTERACTION | 5 | è“牙相关 | +| MULTI_DEVICE_CONNECTION | 6 | å¤šè®¾å¤‡äº’è” | +| WIFI_INTERACTION | 7 | WLAN相关<br />æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| VOIP | 8 | 音视频通è¯<br />æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效) | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md index ce7214ccc18f0fccef021cff0f346bd490fad497..05e0522d4d06bac796b5019314caec9f5d6f6b31 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -1,9 +1,10 @@ # è“牙 +è“牙模å—æä¾›äº†åŸºç¡€çš„ä¼ ç»Ÿè“牙能力以åŠBLE的扫æã€å¹¿æ’ç‰åŠŸèƒ½ã€‚ + >  **说明:** > 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 -è“牙模å—æä¾›äº†åŸºç¡€çš„ä¼ ç»Ÿè“牙能力以åŠBLE的扫æã€å¹¿æ’ç‰åŠŸèƒ½ã€‚ ## å¯¼å…¥æ¨¡å— @@ -343,7 +344,7 @@ setBluetoothScanMode(mode: ScanMode, duration: number): boolean | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------- | ---- | ---------------------------- | | mode | [ScanMode](#scanmode) | 是 | è“牙扫æ模å¼ã€‚ | -| duration | number | 是 | 设备å¯è¢«å‘现的æŒç»æ—¶é—´ï¼Œå•ä½ä¸ºç§’;设置为0则æŒç»å¯å‘现。 | +| duration | number | 是 | 设备å¯è¢«å‘现的æŒç»æ—¶é—´ï¼Œå•ä½ä¸ºæ¯«ç§’;设置为0则æŒç»å¯å‘现。 | **返回值:** @@ -388,7 +389,7 @@ startBluetoothDiscovery(): boolean å¼€å¯è“牙扫æ,å¯ä»¥å‘现远端设备。 -**需è¦æƒé™**:ohos.permission.DISCOVER_BLUETOOTHï¼›ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.DISCOVER_BLUETOOTH å’Œ ohos.permission.LOCATION **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1011,7 +1012,7 @@ bluetooth.off('sppRead', clientNumber); ``` -## bluetooth.getProfile<sup>8+</sup><a name="getProfile"></a> +## bluetooth.getProfile<sup>8+</sup><a name="bt-getProfile"></a> getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile @@ -1029,7 +1030,7 @@ getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfi | 类型 | 说明 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [A2dpSourceProfile](#A2dpSourceProfile)或[HandsFreeAudioGatewayProfile](#HandsFreeAudioGatewayProfile) | 对应的profile的对象实例,当å‰æ”¯æŒA2dpSourceProfile, HandsFreeAudioGatewayProfile。 | +| [A2dpSourceProfile](#a2dpsourceprofile)或[HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile) | 对应的profile的对象实例,当å‰æ”¯æŒA2dpSourceProfile, HandsFreeAudioGatewayProfile。 | **示例:** @@ -1037,9 +1038,9 @@ getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfi let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); ``` -## bluetooth.getProfile<sup>9+</sup><a name="getProfile"></a> +## bluetooth.getProfileInst<sup>9+</sup><a name="getProfileInst"></a> -getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile +getProfileInst(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile 通过ProfileId,获å–profile的对象实例,API9新增了HidHostProfile,PanProfile。 @@ -1055,12 +1056,12 @@ getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfi | 类型 | 说明 | | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [A2dpSourceProfile](#A2dpSourceProfile)或 [HandsFreeAudioGatewayProfile](#HandsFreeAudioGatewayProfile)或[HidHostProfile](#HidHostProfile)或[PanProfile](#PanProfile) | 对应的profile的对象实例,当å‰æ”¯æŒA2dpSourceProfile/HandsFreeAudioGatewayProfile/HidHostProfile/PanProfile。 | +| [A2dpSourceProfile](#a2dpsourceprofile)或 [HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile)或[HidHostProfile](#hidhostprofile)或[PanProfile](#panprofile) | 对应的profile的对象实例,当å‰æ”¯æŒA2dpSourceProfile/HandsFreeAudioGatewayProfile/HidHostProfile/PanProfile。 | **示例:** ```js -let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); +let hidHost = bluetooth.getProfileInst(bluetooth.ProfileId.PROFILE_HID_HOST); ``` @@ -1143,7 +1144,7 @@ startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void å‘èµ·BLE扫ææµç¨‹ã€‚ -**需è¦æƒé™**:ohos.permission.DISCOVER_BLUETOOTHï¼›ohos.permission.MANAGE_BLUETOOTHï¼›ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.DISCOVER_BLUETOOTH å’Œ ohos.permission.MANAGE_BLUETOOTH å’Œ ohos.permission.LOCATION **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -1451,14 +1452,12 @@ a2dpSrc.off('connectionStateChange', onReceiveEvent); ``` -### getPlayingState<sup>9+</sup> +### getPlayingState<sup>8+</sup> getPlayingState(device: string): PlayingState 获å–设备的æ’放状æ€ã€‚ -**需è¦æƒé™**:ohos.permission.USE_BLUETOOTH - **系统能力**:SystemCapability.Communication.Bluetooth.Core。 **å‚数:** @@ -1612,7 +1611,7 @@ hfpAg.off('connectionStateChange', onReceiveEvent); 使用HidHostProfile方法之å‰éœ€è¦åˆ›å»ºè¯¥ç±»çš„实例进行æ“作,通过getProfile()æ–¹æ³•æž„é€ æ¤å®žä¾‹ã€‚ -### connect<sup>9+</sup><a name="connect"></a> +### connect<sup>9+</sup><a name="HidHost-connect"></a> connect(device: string): boolean @@ -1644,7 +1643,7 @@ let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); ``` -### disconnect<sup>9+</sup><a name="disconnect"></a> +### disconnect<sup>9+</sup><a name="HidHost-disconnect"></a> disconnect(device: string): boolean @@ -1742,7 +1741,7 @@ hidHost.off('connectionStateChange', onReceiveEvent); 使用PanProfile方法之å‰éœ€è¦åˆ›å»ºè¯¥ç±»çš„实例进行æ“作,通过getProfile()æ–¹æ³•æž„é€ æ¤å®žä¾‹ã€‚ -### disconnect<sup>9+</sup><a name="disconnect"></a> +### disconnect<sup>9+</sup><a name="PanP-disconnect"></a> disconnect(device: string): boolean @@ -1837,7 +1836,7 @@ panProfile.off('connectionStateChange', onReceiveEvent); ### setTethering<sup>9+</sup><a name="setTethering"></a> -setTethering(value: boolean): boolean +setTethering(enable: boolean): void 设置网络共享状æ€ã€‚ @@ -1875,8 +1874,6 @@ isTetheringOn(): boolean æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**需è¦æƒé™**:ohos.permission.DISCOVER_BLUETOOTH - **系统能力**:SystemCapability.Communication.Bluetooth.Core。 **返回值:** @@ -2019,7 +2016,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; // 创建characteristics @@ -2129,7 +2126,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', @@ -2709,7 +2706,9 @@ client端获å–è“牙低功耗设备的所有æœåŠ¡ï¼Œå³æœåŠ¡å‘现。 ```js // Promise æ¨¡å¼ -gattClientDevice.getServices().then(result => { +let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX'); +device.connect(); +device.getServices().then(result => { console.info("getServices successfully:" + JSON.stringify(result)); }); ``` @@ -3051,7 +3050,7 @@ let descV = new Uint8Array(arrayBuffer); descV[0] = 11; let descriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', - descriptorUuid: '00001830-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; + descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer}; descriptors[0] = descriptor; let arrayBufferC = new ArrayBuffer(8); let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', @@ -3536,7 +3535,7 @@ let rssi = gattClient.getRssiValue().then((data) => { | serviceSolicitationUuidMask<sup>9+</sup> | string | 是 | 是 | 表示过滤包å«è¯¥UUIDæœåŠ¡è¯·æ±‚掩ç 的设备,例如:FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF。 | | serviceData<sup>9+</sup> | ArrayBuffer | 是 | 是 | 表示过滤包å«è¯¥æœåŠ¡ç›¸å…³æ•°æ®çš„设备,例如:[0x90,0x00,0xF1,0xF2]。 | | serviceDataMask<sup>9+</sup> | ArrayBuffer | 是 | 是 | 表示过滤包å«è¯¥æœåŠ¡ç›¸å…³æ•°æ®æŽ©ç 的设备,例如:[0xFF,0xFF,0xFF,0xFF]。 | -| manufacturerId<sup>9+</sup> | number | 是 | 是 | 表示过滤包å«è¯¥åˆ¶é€ 商ID的设备,例如:0x0006。 | +| manufactureId<sup>9+</sup> | number | 是 | 是 | 表示过滤包å«è¯¥åˆ¶é€ 商ID的设备,例如:0x0006。 | | manufactureData<sup>9+</sup> | ArrayBuffer | 是 | 是 | 表示过滤包å«è¯¥åˆ¶é€ 商相关数æ®çš„设备,例如:[0x1F,0x2F,0x3F]。 | | manufactureDataMask<sup>9+</sup> | ArrayBuffer | 是 | 是 | 表示过滤包å«è¯¥åˆ¶é€ 商相关数æ®æŽ©ç 的设备,例如:[0xFF,0xFF,0xFF]。 | @@ -3617,7 +3616,7 @@ let rssi = gattClient.getRssiValue().then((data) => { | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ----------- | ------- | ---- | ---- | ---------------------------------------- | -| interval | number | 是 | 是 | 表示广æ’间隔,最å°å€¼è®¾ç½®32个slot表示20ms,最大值设置16777215个slot,默认值设置为1600个slot表示1s。 | +| interval | number | 是 | 是 | 表示广æ’间隔,最å°å€¼è®¾ç½®32个slot表示20ms,最大值设置16384个slot,默认值设置为1600个slot表示1s。 | | txPower | number | 是 | 是 | 表示å‘é€åŠŸçŽ‡ï¼Œæœ€å°å€¼è®¾ç½®-127,最大值设置1,默认值设置-7,å•ä½dbm。 | | connectable | boolean | 是 | 是 | 表示是å¦æ˜¯å¯è¿žæŽ¥å¹¿æ’,默认值设置为true。 | @@ -3828,7 +3827,7 @@ let rssi = gattClient.getRssiValue().then((data) => { ## ProfileId<sup>8+</sup><a name="ProfileId"></a> -è“牙profile枚举,API9新增PROFILE_HID_HOST。 +è“牙profile枚举,API9新增PROFILE_HID_HOST,PROFILE_PAN_NETWORK。 **系统能力**:SystemCapability.Communication.Bluetooth.Core。 @@ -3836,4 +3835,5 @@ let rssi = gattClient.getRssiValue().then((data) => { | -------------------------------- | ------ | --------------- | | PROFILE_A2DP_SOURCE | 0x0001 | 表示A2DP profile。 | | PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | 表示HFP profile。 | -| PROFILE_HID_HOST<sup>9+</sup> | 0x0006 | 表示HID profile。 | \ No newline at end of file +| PROFILE_HID_HOST<sup>9+</sup> | 0x0006 | 表示HID profile。 | +| PROFILE_PAN_NETWORK<sup>9+</sup> | 0x0007 | 表示PAN profile。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-buffer.md b/zh-cn/application-dev/reference/apis/js-apis-buffer.md new file mode 100644 index 0000000000000000000000000000000000000000..e538e236f79a915e13cb1a30dd7b9bc9495ed3ad --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-buffer.md @@ -0,0 +1,2444 @@ +# Buffer + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + +Buffer对象用于表示固定长度的å—节åºåˆ—,是专门å˜æ”¾äºŒè¿›åˆ¶æ•°æ®çš„缓å˜åŒºã€‚ + +**推è使用场景:** å¯ç”¨äºŽå¤„ç†å¤§é‡äºŒè¿›åˆ¶æ•°æ®ï¼Œå¤„ç†å›¾ç‰‡ã€æ–‡ä»¶æŽ¥æ”¶ä¸Šä¼ ã€ç½‘络åè®®ç‰ç‰ + +## å¯¼å…¥æ¨¡å— + +```ts +import buffer from '@ohos.buffer'; +``` + +## Buffer + +### alloc + +alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer + +创建`size`个å—节长度的Buffer实例,并åˆå§‹åŒ–。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| size | number | 是 | 指定的Buffer实例长度,å•ä½ï¼šå—节。 | +| fill | string \| Buffer \| number | å¦ | 预填充的值,默认值: 0 | +| encoding | BufferEncoding | å¦ | ç¼–ç æ–¹å¼ï¼ˆå½“`fill`为string时,æ‰æœ‰æ„义)。 默认值: 'utf-8' | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 带åˆå§‹åŒ–çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.alloc(5); +let buf2 = buffer.alloc(5, 'a'); +let buf3 = buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); +``` + +### allocUninitializedFromPool + +allocUninitializedFromPool(size: number): Buffer + +创建指定大å°çš„未被åˆå§‹åŒ–Buffer实例。内å˜ä»Žç¼“å†²æ± åˆ†é…。 +创建的Buffer的内容未知,需è¦ä½¿ç”¨fill()函数æ¥åˆå§‹åŒ–Buffer实例。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| size | number | 是 | 指定的Buffer实例长度,å•ä½ï¼šå—节。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 未åˆå§‹åŒ–çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(10); +buf.fill(0); +``` + +### allocUninitialized + +allocUninitialized(size: number): Buffer + +创建指定大å°çš„未被åˆå§‹åŒ–Buffer实例。内å˜ä¸ä»Žç¼“å†²æ± åˆ†é…。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| size | number | 是 |指定的Buffer实例长度,å•ä½ï¼šå—节。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 未åˆå§‹åŒ–çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitialized(10); +buf.fill(0); +``` + +### byteLength + +byteLength(string: string | Buffer | TypeArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number + +æ ¹æ®ä¸åŒçš„ç¼–ç 方法,返回å—符串的å—节数。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| string | string \| Buffer \| TypeArray \| DataView \| ArrayBuffer \| SharedArrayBuffer | 是 | 指定å—符串。 | +| encoding | BufferEncoding | å¦ | ç¼–ç æ–¹å¼ã€‚ 默认值: 'utf-8' | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 返回å—符串的å—节数 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let str = '\u00bd + \u00bc = \u00be'; +console.log('${str}: ${str.length} characters, ${buffer.byteLength(str, 'utf-8')} bytes'); +// 打å°: ½ + ¼ = ¾: 9 characters, 12 bytes +``` + +### compare + +compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): number + +返回比较buf1å’Œbuf2的结果, 通常用于对Buffer实例的数组进行排åºã€‚ + + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| buf1 | Buffer \| Uint8Array | 是 | 待比较数组。 | +| buf2 | Buffer \| Uint8Array | 是 | 待比较数组。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 如果buf1与buf2相åŒï¼Œåˆ™è¿”回0<br/>如果排åºæ—¶buf1ä½äºŽbuf2之åŽï¼Œåˆ™è¿”回1<br/>如果排åºæ—¶buf1ä½äºŽbuf2之å‰ï¼Œåˆ™è¿”回-1。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from('1234'); +let buf2 = buffer.from('0123'); + +console.log(buf1.compare(buf2)); +// æ‰“å° 1 +``` + +### concat + +concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer + +å°†`list`ä¸çš„实例内容å¤åˆ¶`totalLength`å—节长度到新的Buffer实例ä¸å¹¶è¿”回。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| list | Buffer[] \| Uint8Array[] | 是 | 实例数组。 | +| totalLength | number | å¦ | 需è¦èžåˆçš„总å—节长度。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 返回新Buffer的实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from("1234"); +let buf2 = buffer.from("abcd"); +let buf = buffer.concat([buf1, buf2]); +console.log(buf); // <Buffer 31 32 33 34 61 62 63 64> +``` + +### from + +from(array: number[]): Buffer + +æ ¹æ®æŒ‡å®šæ•°ç»„创建新的Buffer实例。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| array | number[] | 是 | 指定数组。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ–°çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let arrayList = new ArrayList(); + +let buf = buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); +console.log(buf); +// 打å°: <Buffer 62 75 66 66 65 72> +``` + +### from + +from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer + +创建指定长度的与`arrayBuffer`共享内å˜çš„Buffer实例 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| arrayBuffer | ArrayBuffer \| SharedArrayBuffer | 是 | 实例对象。 | +| byteOffset | number | å¦ | å—节å移é‡ï¼Œé»˜è®¤å€¼: 0。 | +| length | number | å¦ | å—节长度, 默认值: arrayBuffer.byteLength - byteOffset。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 返回一个共享内å˜çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let ab = new ArrayBuffer(10); +let buf = buffer.from(ab, 0, 2); +``` + +### from + +from(data: Buffer | Uint8Array): Buffer + +创建并å¤åˆ¶`data`æ•°æ®åˆ°æ–°çš„Buffer实例并返回。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| data | Buffer \| Uint8Array | 是 | 实例数æ®ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ–°çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from('buffer'); +let buf2 = buffer.from(buf1); +``` + +### from + +from(object: Object, offsetOrEncoding: number | string, length: number): Buffer + +æ ¹æ®æŒ‡å®šçš„`object`类型数æ®ï¼Œåˆ›å»ºæ–°çš„Buffer实例。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| object | Object | 是 | 支æŒSymbol.toPrimitive或valueOf()的对象 | +| offsetOrEncoding | number \| string | å¦ | å—节å移é‡æˆ–ç¼–ç 。 | +| length | number | å¦ | å—节长度。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ–°çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from(new String('this is a test')); +``` + +### from + +from(string: string, encoding?: BufferEncoding): Buffer + +æ ¹æ®æŒ‡å®šç¼–ç æ ¼å¼çš„å—符串,创建新的Buffer实例。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| string | string | 是 | å—符串 | +| encoding | BufferEncoding | å¦ | ç¼–ç æ ¼å¼ã€‚ 默认值: 'utf-8'。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ–°çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from('this is a test'); +let buf2 = buffer.from('7468697320697320612074c3a97374', 'hex'); + +console.log(buf1.toString()); // 打å°: this is a test +console.log(buf2.toString()); +``` + + +### isBuffer + +isBuffer(obj: Object): boolean + +判æ–`obj`是å¦ä¸ºBuffer。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| obj | Object | 是 | 判æ–对象 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | 如果obj是Buffer,则返回true,å¦åˆ™è¿”回false。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +buffer.isBuffer(buffer.alloc(10)); // true +buffer.isBuffer(buffer.from('foo')); // true +buffer.isBuffer('a string'); // false +buffer.isBuffer([]); // false +buffer.isBuffer(new Uint8Array(1024)); // false +``` + +### isEncoding + +isEncoding(encoding: string): boolean + +判æ–`encoding`是å¦ä¸ºæ”¯æŒçš„ç¼–ç æ ¼å¼ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| encoding | string | 是 | ç¼–ç æ ¼å¼ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | true或者false。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +console.log(Buffer.isEncoding('utf-8')); // 打å°: true +console.log(Buffer.isEncoding('hex')); // 打å°: true +console.log(Buffer.isEncoding('utf/8')); // 打å°: false +console.log(Buffer.isEncoding('')); // 打å°: false +``` + +### compare + +compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1 + +`this`实例对象与`target`实例对象进行比较,返回buf在排åºä¸çš„顺åºï¼Œ-1:å‰æŽ’åºï¼Œ0:与buf相åŒï¼Œ1:åŽæŽ’åºã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| target | Buffer \| Uint8Array | 是 | è¦æ¯”较的实例对象。 | +| targetStart | number | å¦ | `target`实例ä¸å¼€å§‹çš„å移é‡ã€‚ 默认值: 0。 | +| targetEnd | number | å¦ | `target`实例ä¸ç»“æŸçš„å移é‡ï¼ˆä¸åŒ…括本身)。 默认值: target.lengt。 | +| sourceStart | number | å¦ | `this`实例ä¸å¼€å§‹çš„å移é‡ã€‚ 默认值: 0。 | +| sourceEnd | number | å¦ | `this`实例ä¸ç»“æŸçš„å移é‡ï¼ˆä¸åŒ…括本身)。 默认值: buf.length。 | + +| 类型 | 说明 | +| -------- | -------- | +| number | 比较结果。-1:å‰æŽ’åºï¼Œ0:与buf相åŒï¼Œ1:åŽæŽ’åºã€‚ | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]); +let buf2 = buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]); + +console.log(buf1.compare(buf2, 5, 9, 0, 4)); // 打å°: 0 +console.log(buf1.compare(buf2, 0, 6, 4)); // 打å°: -1 +console.log(buf1.compare(buf2, 5, 6, 5)); // 打å°: 1 +``` + +### copy + +copy(target: Buffer| Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number + +å°†`this`实例ä¸æŒ‡å®šä½ç½®çš„æ•°æ®å¤åˆ¶åˆ°`target`的指定ä½ç½®ä¸Šï¼Œå¹¶è¿”回å¤åˆ¶çš„å—节总长度。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| target | Buffer \| Uint8Array | 是 | è¦å¤åˆ¶åˆ°çš„Buffer或Uint8Array实例。 | +| targetStart | number | å¦ | `target`实例ä¸å¼€å§‹å†™å…¥çš„å移é‡ã€‚ 默认值: 0。 | +| sourceStart | number | å¦ | `this`实例ä¸å¼€å§‹å¤åˆ¶çš„å移é‡ã€‚ 默认值: 0。 | +| sourceEnd | number | å¦ | `this`实例ä¸ç»“æŸå¤åˆ¶çš„å移é‡ï¼ˆä¸åŒ…括)。 默认值: buf.length。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | å¤åˆ¶çš„å—节总长度。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.allocUninitializedFromPool(26); +let buf2 = buffer.allocUninitializedFromPool(26).fill('!'); + +for (let i = 0; i < 26; i++) { + buf1[i] = i + 97; +} + +buf1.copy(buf2, 8, 16, 20); +console.log(buf2.toString('ascii', 0, 25)); +// 打å°: !!!!!!!!qrst!!!!!!!!!!!!! +``` + +### entries + +entries(): IterableIterator<[number, number]> + +返回一个包å«keyå’Œvalueçš„è¿ä»£å™¨ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from('buffer'); +for (let pair of buf.entries()) { + console.log(pair); +} +``` + +### equals + +equals(otherBuffer: Buffer | Uint8Array): boolean + +比较`this`实例和otherBuffer实例是å¦ç›¸ç‰ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| otherBuffer | Buffer \| Uint8Array | 是 | æ¯”è¾ƒçš„ç›®æ ‡å¯¹è±¡ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | 相ç‰åˆ™è¿”回true,å¦åˆ™è¿”回false。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from('ABC'); +let buf2 = buffer.from('414243', 'hex'); +let buf3 = buffer.from('ABCD'); + +console.log(buf1.equals(buf2)); // 打å°: true +console.log(buf1.equals(buf3)); // 打å°: false + +``` + +### fill + +fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer + +用`value`å¡«å……`this`实例指定ä½ç½®çš„æ•°æ®ï¼Œé»˜è®¤ä¸ºå¾ªçŽ¯å¡«å……,并返回填充åŽçš„Buffer实例。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | string \| Buffer \| Uint8Array \| number | 是 | 用于填充的值。 | +| offset | number | å¦ | 起始å移é‡ã€‚ 默认值: 0。 | +| end | number | å¦ | 结æŸå移é‡ï¼ˆä¸åŒ…括在内)。 默认值: buf.length。 | +| encoding | BufferEncoding | å¦ | å—符编ç æ ¼å¼ï¼ˆ`value`为stringæ‰æœ‰æ„义)。 默认值: 'utf-8'。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | å¡«å……åŽçš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let b = buffer.allocUninitializedFromPool(50).fill('h'); +console.log(b.toString()); +``` + + +### includes + +includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean + +检查Buffer对象是å¦åŒ…å«`value`值。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | string \| number \| Buffer \| Uint8Array | 是 | è¦æœç´¢çš„内容。 | +| byteOffset | number | å¦ | å—节å移é‡ã€‚ 如果为负数,则从末尾开始计算å移é‡ã€‚ 默认值: 0。 | +| encoding | BufferEncoding | å¦ | å—符编ç æ ¼å¼ã€‚ 默认值: 'utf-8'。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| boolean | å˜åœ¨ä¸ºtrue,å¦åˆ™ä¸ºfalse。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from('this is a buffer'); +console.log(buf.includes('this')); // 打å°: true +console.log(buf.includes('be')); // 打å°: false +``` + +### indexOf + +indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number + +查找`this`实例ä¸ç¬¬ä¸€æ¬¡å‡ºçŽ°`value`的索引,如果ä¸åŒ…å«`value`,则为-1 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | string \| number \| Buffer \| Uint8Array | 是 | è¦æœç´¢çš„内容。 | +| byteOffset | number | å¦ | å—节å移é‡ã€‚ 如果为负数,则从末尾开始计算å移é‡ã€‚ 默认值: 0。 | +| encoding | BufferEncoding | å¦ | å—符编ç æ ¼å¼ã€‚ 默认值: 'utf-8'。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 第一次出现ä½ç½®ã€‚ | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from('this is a buffer'); +console.log(buf.indexOf('this')); // 打å°: 0 +console.log(buf.indexOf('is')); // 打å°: 2 +``` + +### keys + +keys(): IterableIterator<number> + +返回一个包å«key值的è¿ä»£å™¨ + +**系统能力:** SystemCapability.Utils.Lang + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| IterableIterator<number> | è¿ä»£å™¨ã€‚ | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from('buffer'); +for (const key of buf.keys()) { + console.log(key); +} +``` + +### lastIndexOf + +lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number + +返回`this`实例ä¸æœ€åŽä¸€æ¬¡å‡ºçŽ°`value`的索引,如果对象ä¸åŒ…å«ï¼Œåˆ™ä¸º-1。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | string \| number \| Buffer \| Uint8Array | 是 | è¦æœç´¢çš„内容。 | +| byteOffset | number | å¦ | å—节å移é‡ã€‚ 如果为负数,则从末尾开始计算å移é‡ã€‚ 默认值: 0。 | +| encoding | BufferEncoding | å¦ | å—符编ç æ ¼å¼ã€‚ 默认值: 'utf-8'。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 最åŽä¸€æ¬¡å‡ºçŽ°`value`值的索引。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from('this buffer is a buffer'); +console.log(buf.lastIndexOf('this')); // 打å°: 0 +console.log(buf.lastIndexOf('buffer')); // 打å°: 17 +``` + + +### readBigInt64BE + +readBigInt64BE(offset: number): number + +从指定的`offset`处读å–有符å·çš„大端åº64ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, + 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]); +console.log(buf.readBigInt64BE(0)); +``` + +### readBigInt64LE + +readBigInt64LE(offset: number): number + +从指定的`offset`处读å–æ— ç¬¦å·çš„å°ç«¯åº64ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, + 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]); +console.log(buf.readBigInt64LE(0)); +``` + +### readBigUInt64BE + +readBigUInt64BE(offset: number): number + +从指定的`offset`处读å–æ— ç¬¦å·çš„大端åº64ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, + 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]); +console.log(buf.readBigUInt64BE(0)); +``` + +### readBigUInt64LE + +readBigUInt64LE(offset: number): number + +从指定的`offset`处读å–æ— ç¬¦å·çš„å°ç«¯åº64ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, + 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78]); +console.log(buf.readBigUInt64LE(0)); +``` + +### readDoubleBE + +readDoubleBE(offset: number): number + +从指定`offset`处读å–64ä½å¤§ç«¯åºåŒç²¾åº¦å€¼ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); +console.log(buf.readDoubleBE(0)); +``` + +### readDoubleLE + +readDoubleLE(offset: number): number + +从指定`offset`处读å–64ä½å°ç«¯åºåŒç²¾åº¦å€¼ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); +console.log(buf.readDoubleLE(0)); +``` + +### readFloatBE + +readFloatBE(offset: number): number + +从指定`offset`处读å–32ä½å¤§ç«¯åºæµ®ç‚¹æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); +console.log(buf.readFloatBE(0)); +``` + +### readFloatLE + +readFloatLE(offset: number): number + +从指定`offset`处读å–32ä½å°ç«¯åºæµ®ç‚¹æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); +console.log(buf.readFloatLE(0)); +``` + +### readInt8 + +readInt8(offset: number): number + +从指定的`offset`处读å–有符å·çš„8ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([-1, 5]); +console.log(buf.readInt8(0)); // 打å°: -1 +console.log(buf.readInt8(1)); // 打å°: 5 +``` + +### readInt16BE + +readInt16BE(offset: number): number + +从指定的`offset`处读å–有符å·çš„大端åº16ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = Buffer.from([0, 5]); +console.log(buf.readInt16BE(0)); // 打å°: 5 +``` + +### readInt16LE + +readInt16LE(offset: number): number + +从指定的`offset`处读å–有符å·çš„å°ç«¯åº16ä½æ•´æ•° + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = Buffer.from([0, 5]); +console.log(buf.readInt16BE(0)); // 打å°: 1280 +``` + +### readInt32BE + +readInt32BE(offset: number): number + +从指定的`offset`处读å–有符å·çš„大端åº32ä½æ•´æ•° + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0, 0, 0, 5]); +console.log(buf.readInt32BE(0)); // 打å°: 5 +``` + +### readInt32LE + +readInt32LE(offset: number): number + +从指定的`offset`处读å–有符å·çš„å°ç«¯åº32ä½æ•´æ•° + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | 是 | å移é‡ã€‚默认值: 0。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0, 0, 0, 5]); +console.log(buf.readInt32LE(0)); // 打å°: 83886080 +``` + +### readIntBE + +readIntBE(offset: number, byteLength: number): number + +从指定的`offset`处的buf读å–byteLength个å—节,并将结果解释为支æŒæœ€é«˜48ä½ç²¾åº¦çš„大端åºã€äºŒè¿›åˆ¶è¡¥ç 有符å·å€¼ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | 读å–çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = Buffer.from("ab"); +let num = buf.readIntBE(0, 1); +console.log(num); // 97 +``` + + +### readIntLE + +readIntLE(offset: number, byteLength: number): number + +从指定的`offset`处的buf读å–`byteLength`个å—节,并将结果解释为支æŒæœ€é«˜48ä½ç²¾åº¦çš„å°ç«¯åºã€äºŒè¿›åˆ¶è¡¥ç 有符å·å€¼ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | 读å–çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); +console.log(buf.readIntLE(0, 6).toString(16)); +``` + +### readUInt8 + +readUInt8(offset: number): number + +从`offset`处读å–8ä½æ— 符å·æ•´åž‹æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([1, -2]); +console.log(buf.readUInt8(0)); +console.log(buf.readUInt8(1)); +``` + +### readUInt16BE + +readUInt16BE(offset: number): number + +从指定的`offset`处的buf读å–æ— ç¬¦å·çš„大端åº16ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56]); +console.log(buf.readUInt16BE(0).toString(16)); +console.log(buf.readUInt16BE(1).toString(16)); +``` + +### readUInt16LE + +readUInt16LE(offset: number): number + +从指定的`offset`处的buf读å–æ— ç¬¦å·çš„å°ç«¯åº16ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56]); +console.log(buf.readUInt16LE(0).toString(16)); +console.log(buf.readUInt16LE(1).toString(16)); +``` + +### readUInt32BE + +readUInt32BE(offset: number): number + +从指定的`offset`处的buf读å–æ— ç¬¦å·çš„大端åº32ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56, 0x78]); +console.log(buf.readUInt32BE(0).toString(16)); +``` + +### readUInt32LE + +readUInt32LE(offset: number): number + +从指定的`offset`处的buf读å–æ— ç¬¦å·çš„å°ç«¯åº32ä½æ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56, 0x78]); +console.log(buf.readUInt32LE(0).toString(16)); +``` + +### readUIntBE + +readUIntBE(offset: number, byteLength: number): number + +从指定的`offset`处的buf读å–`byteLength`个å—节,并将结果解释为支æŒæœ€é«˜48ä½ç²¾åº¦çš„æ— ç¬¦å·å¤§ç«¯åºæ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦è¯»å–çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); +console.log(buf.readUIntBE(0, 6).toString(16)); +``` + +### readUIntLE + +readUIntLE(offset: number, byteLength: number): number + +从指定的`offset`处的buf读å–`byteLength`个å—节,并将结果解释为支æŒæœ€é«˜48ä½ç²¾åº¦çš„æ— ç¬¦å·å°ç«¯åºæ•´æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦è¯»å–çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 读å–出的内容。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); +console.log(buf.readUIntLE(0, 6).toString(16)); +``` + +### subarray + +subarray(start?: number, end?: number): Buffer + +截å–指定ä½ç½®çš„`this`实例并返回。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| start | number | å¦ | 截å–开始ä½ç½®ã€‚ 默认值: 0。 | +| end | number | å¦ | 截å–结æŸä½ç½®ï¼ˆä¸åŒ…括在内)。 默认值: buf.length。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ–°çš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.allocUninitializedFromPool(26); + +for (let i = 0; i < 26; i++) { + buf1[i] = i + 97; +} +const buf2 = buf1.subarray(0, 3); +console.log(buf2.toString('ascii', 0, buf2.length)); +// 打å°: abc +``` + +### swap16 + +swap16(): Buffer + +å°†`this`å®žä¾‹è§£é‡Šä¸ºæ— ç¬¦å·çš„16ä½æ•´æ•°æ•°ç»„,并就地交æ¢å—节顺åºã€‚ + +**系统能力:** SystemCapability.Utils.Lang + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 交æ¢ä¹‹åŽçš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); +console.log(buf1); // 打å°: <Buffer 01 02 03 04 05 06 07 08> + +buf1.swap16(); +console.log(buf1); // 打å°: <Buffer 02 01 04 03 06 05 08 07> +``` + +### swap32 + +swap32(): Buffer + +å°†`this`å®žä¾‹è§£é‡Šä¸ºæ— ç¬¦å·çš„32ä½æ•´æ•°æ•°ç»„,并就地交æ¢å—èŠ‚é¡ºåº + +**系统能力:** SystemCapability.Utils.Lang + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 交æ¢ä¹‹åŽçš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); +console.log(buf1); // 打å°: <Buffer 01 02 03 04 05 06 07 08> + +buf1.swap32(); +console.log(buf1); // 打å°: <Buffer 04 03 02 01 08 07 06 05> +``` + +### swap64 + +swap64(): Buffer + +å°†`this`å®žä¾‹è§£é‡Šä¸ºæ— ç¬¦å·çš„64ä½æ•´æ•°æ•°ç»„,并就地交æ¢å—èŠ‚é¡ºåº + +**系统能力:** SystemCapability.Utils.Lang + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | 交æ¢ä¹‹åŽçš„Buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); +console.log(buf1); // 打å°: <Buffer 01 02 03 04 05 06 07 08> +buf1.swap64(); +console.log(buf1); // 打å°: <Buffer 08 07 06 05 04 03 02 01> +``` + +### toJSON + +toJSON(): Object + +å°†buf转为JSON并返回。 + +**系统能力:** SystemCapability.Utils.Lang + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Object | JSON对象。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); +let buf2 = buffer.from(buf1.toJSON()) +let json = JSON.stringify(buf2); +console.log(json); +// 打å°: {"type":"Buffer","data":[1,2,3,4,5]} +``` + +### toString + +toString(encoding?: string, start?: number, end?: number): string + +å°†`this`实例ä¸æŒ‡å®šä½ç½®æ•°æ®è½¬æˆæŒ‡å®šç¼–ç æ ¼å¼å—符串并返回。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| encoding | string | å¦ | å—符编ç æ ¼å¼ã€‚ 默认值: 'utf-8'。 | +| start | number | å¦ | 开始ä½ç½®ã€‚ 默认值: 0。 | +| end | number | å¦ | 结æŸä½ç½®ã€‚ 默认值: buf.length。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| string | å—符串。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.allocUninitializedFromPool(26); +for (let i = 0; i < 26; i++) { + buf1[i] = i + 97; +} +console.log(buf1.toString('utf-8')); +// 打å°: abcdefghijklmnopqrstuvwxyz +``` + +### values + +values(): IterableIterator<number> + +返回一个包å«valueçš„è¿ä»£å™¨ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| IterableIterator<number> | è¿ä»£å™¨ã€‚ | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf1 = buffer.from('buffer'); +for (const value of buf.values()) { + console.log(value); +} +``` + +### write + +write(str: string, offset?: number, length?: number, encoding?: string): number + +从bufçš„offsetå移写入指定编ç çš„å—符串str,写入的å—节长度为length + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| str | string | 是 | è¦å†™å…¥Bufferçš„å—符串。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| length | number | å¦ | 最大å—节长度。 默认值: (buf.length - offset)。| +| encoding | BufferEncoding | å¦ | å—符编ç 。 默认值: 'utf8'。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 返回写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.alloc(256); +let len = buf.write('\u00bd + \u00bc = \u00be', 0); +console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); +// 打å°: 12 bytes: ½ + ¼ = ¾ + +let buffer = Buffer.alloc(10); +let length = buffer.write('abcd', 8); +``` + +### writeBigInt64BE + +writeBigInt64BE(value: number, offset?: number): number + +从bufçš„offsetå移写入大端åºçš„64ä½BigIntåž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeBigInt64BE(0x0102030405060708n, 0); +``` + +### writeBigInt64LE + +writeBigInt64LE(value : number, offset? : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„64ä½BigIntåž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeBigInt64LE(0x0102030405060708n, 0); +``` + +### writeBigUInt64BE + +writeBigUInt64BE(value : number, offset? : number): number + +从bufçš„offsetå移写入大端åºçš„64ä½BigUIntåž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeBigUInt64BE(0xdecafafecacefaden, 0); +``` + +### writeBigUInt64LE + +writeBigUInt64LE(value : number, offset? : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„64ä½BigUIntåž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeBigUInt64LE(0xdecafafecacefaden, 0); +``` + +### writeDoubleBE + +writeDoubleBE(value : number, offset? : number): number + +从bufçš„offsetå移写入大端åºçš„64ä½æœ‰ç¬¦å·åŒæµ®ç‚¹åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeDoubleBE(123.456, 0); +``` + +### writeDoubleLE + +writeDoubleLE(value : number, offset? : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„64ä½æœ‰ç¬¦å·åŒæµ®ç‚¹åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeDoubleLE(123.456, 0); +``` + +### writeFloatBE + +writeFloatBE(value : number, offset? : number): number + +从bufçš„offsetå移写入大端åºçš„32ä½æœ‰ç¬¦å·æµ®ç‚¹åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeFloatBE(0xcafebabe, 0); +``` + + +### writeFloatLE + +writeFloatLE(value : number, offset? : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„32ä½æœ‰ç¬¦å·æµ®ç‚¹åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(8); +buf.writeFloatLE(0xcafebabe, 0); +``` + +### writeInt8 + +writeInt8(value : number, offset? : number): number + +从bufçš„offsetå移写入8ä½æœ‰ç¬¦å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(2); +buf.writeInt8(2, 0); +buf.writeInt8(-2, 1); +``` + + +### writeInt16BE + +writeInt16BE(value : number, offset? : number): number + +从bufçš„offsetå移写入大端åºçš„16ä½æœ‰ç¬¦å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(2); +buf.writeInt16BE(0x0102, 0); +``` + + +### writeInt16LE + +writeInt16LE(value : number, offset : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„16ä½æœ‰ç¬¦å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(2); +buf.writeInt16LE(0x0304, 0); +``` + +### writeInt32BE + +writeInt32BE(value : number, offset : number): number + +从bufçš„offsetå移写入大端åºçš„32ä½æœ‰ç¬¦å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeInt32BE(0x01020304, 0); +``` + + +### writeInt32LE + +writeInt32LE(value : number, offset : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„32ä½æœ‰ç¬¦å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeInt32LE(0x05060708, 0); +``` + +### writeIntBE + +writeIntBE(value : number, offset : number, byteLength : number): number + +从bufçš„offsetå移写入大端åºçš„有符å·valueæ•°æ®,valueå—节长度为byteLength + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦å†™å…¥çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(6); +buf.writeIntBE(0x1234567890ab, 0, 6); +``` + + +### writeIntLE + +writeIntLE(value : number, offset : number, byteLength : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„有符å·valueæ•°æ®,valueå—节长度为byteLength + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦å†™å…¥çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(6); +buf.writeIntLE(0x1234567890ab, 0, 6); +``` + +### writeUInt8 + +writeUInt8(value : number, offset : number): number + +从bufçš„offsetå移写入8ä½æ— 符å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeUInt8(0x3, 0); +buf.writeUInt8(0x4, 1); +buf.writeUInt8(0x23, 2); +buf.writeUInt8(0x42, 3); +``` + +### writeUInt16BE + +writeUInt16BE(value : number, offset : number): number + +从bufçš„offsetå移写入大端åºçš„16ä½æ— 符å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeUInt16BE(0xdead, 0); +buf.writeUInt16BE(0xbeef, 2); +``` + +### writeUInt16LE + +writeUInt16LE(value : number, offset : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„16ä½æ— 符å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeUInt16LE(0xdead, 0); +buf.writeUInt16LE(0xbeef, 2); +``` + +### writeUInt32BE + +writeUInt32BE(value : number, offset : number): number + +从bufçš„offsetå移写入大端åºçš„32ä½æ— 符å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°æ®ã€‚ | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeUInt32BE(0xfeedface, 0); +``` + +### writeUInt32LE + +writeUInt32LE(value : number, offset : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„32ä½æ— 符å·æ•´åž‹æ•°æ®value + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°å—。 | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(4); +buf.writeUInt32LE(0xfeedface, 0); +``` + +### writeUIntBE + +writeUIntBE(value : number, offset : number, byteLength : number): number + +从bufçš„offsetå移写入大端åºçš„æ— ç¬¦å·valueæ•°æ®,valueå—节长度为byteLength + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°æ®ã€‚ | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦å†™å…¥çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(6); +buf.writeUIntBE(0x1234567890ab, 0, 6); +``` + +### writeUIntLE + +writeUIntLE(value : number, offset : number, byteLength : number): number + +从bufçš„offsetå移写入å°ç«¯åºçš„æ— ç¬¦å·valueæ•°æ®,valueå—节长度为byteLength + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 写入 buf çš„æ•°æ®ã€‚ | +| offset | number | å¦ | å移é‡ã€‚ 默认值: 0。 | +| byteLength | number | å¦ | è¦å†™å…¥çš„å—节数。 | + + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| number | 写入的å—节数。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.allocUninitializedFromPool(6); +buf.writeUIntLE(0x1234567890ab, 0, 6); +``` + +### transcode + +transcode(source : Buffer | Uint8Array, fromEnc : string, toEnc : string): Buffer + +将给定的Buffer或Uint8Array实例从一ç§å—符编ç é‡æ–°ç¼–ç 为å¦ä¸€ç§ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| source | Buffer \| Uint8Array | 是 | 实例对象。 | +| fromEnc | string | 是 | 当å‰ç¼–ç 。 | +| toEnc | string | 是 | ç›®æ ‡ç¼–ç 。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Buffer | æ ¹æ®å½“å‰ç¼–ç 转æ¢æˆç›®æ ‡ç¼–ç ,并返回一个新的buffer实例。 | + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let buf = buffer.alloc(50); +let newBuf = buf.transcode(buffer.from('€'), 'utf8', 'ascii'); +console.log(newBuf.toString('ascii')); +``` + +## Blob + +### 属性 + +**系统能力:** SystemCapability.Utils.Lang + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| size | number | 是 | å¦ | Blob实例的总å—节大å°ã€‚ | +| type | string | 是 | å¦ | Blob实例的内容类型。 | + +### constructor + +constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options: Object) + +Blobçš„æž„é€ å‡½æ•°ã€‚ + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| sources | string[] \| ArrayBuffer[] \| TypedArray[] \| DataView[] \| Blob[] | 是 | Blob实例的数æ®æºã€‚ | +| options | Object | å¦ | options:<br/>- endings:'transparent'或'native'<br/>- type:Blob内容类型 | + + +**示例:** + +```ts +import buffer from '@ohos.buffer'; + +let blob1 = new buffer.Blob(['a', 'b', 'c']); +let blob1 = new buffer.Blob(['a', 'b', 'c'], {endings:'native', type: 'MIME'}); +``` + +### encode + +arrayBuffer(): Promise<ArrayBuffer> + +å°†Blobä¸çš„æ•°æ®æ”¾å…¥åˆ°ArrayBufferä¸ï¼Œå¹¶è¿”回一个Promise。 + +**系统能力:** SystemCapability.Utils.Lang + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Promise<ArrayBuffer> | 返回包å«Blobæ•°æ®çš„ArrayBufferçš„Promise。 | + +**示例:** + ```ts + let blob = new buffer.Blob(['a', 'b', 'c']); + let pro = blob.arrayBuffer(); + pro.then(val => { + console.log(val) + }); + ``` +### slice + +slice(start?: number, end?: number, type?: string): Blob + +创建并返回一个å¤åˆ¶åŽŸblob对象ä¸start到endä½ç½®æ•°æ®çš„æ–°blob实例对象。 + +**系统能力:** SystemCapability.Utils.Lang + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| start | number | å¦ | 起始ä½ç½®ã€‚ | +| end | number | å¦ | 结æŸä½ç½®ã€‚ | +| type | string | å¦ | 内容类型。 | + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Blob | æ–°çš„Blob实例对象。 | + +**示例:** + ```ts + let blob = new buffer.Blob(['a', 'b', 'c']); + let blob2 = blob.slice(0, 2); + let blob3 = blob.slice(0, 2, "MIME"); + ``` + + ### text + +text(): Promise<string> + +返回一个Promise,该Promiseä¸çš„值为UTF8ç¼–ç 类型的文本。 + +**系统能力:** SystemCapability.Utils.Lang + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Promise<string> | 包å«ä»¥UTF8ç¼–ç 的文本的Promise。 | + +**示例:** + ```ts + let blob = new buffer.Blob(['a', 'b', 'c']); + let pro = blob.text(); + pro.then(val => { + console.log(val) + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md index 44e8685a7a3a9d2f5090d88dbd29bb767203f4db..63f8bccac119926565f26255908d60c15c88c489 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-AbilityInfo.md @@ -7,9 +7,9 @@ -Abilityä¿¡æ¯ - +Abilityä¿¡æ¯ï¼Œæœªåšç‰¹æ®Šè¯´æ˜Žçš„属性,å‡é€šè¿‡GET_BUNDLE_DEFAULTèŽ·å– +## AbilityInfo **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework @@ -24,24 +24,24 @@ Abilityä¿¡æ¯ | iconId | number | 是 | å¦ | Abilityçš„å›¾æ ‡id | | moduleName | string | 是 | å¦ | Ability所属的HAP包的å称 | | process | string | 是 | å¦ | Ability的进程,如果ä¸è®¾ç½®ï¼Œé»˜è®¤ä¸ºåŒ…çš„å称 | -| targetAbility | string | 是 | å¦ | 当å‰Abilityé‡ç”¨çš„ç›®æ ‡Ability | -| backgroundModes | number | 是 | å¦ | 表示åŽå°æœåŠ¡çš„类型 | +| targetAbility | string | 是 | å¦ | 当å‰Abilityé‡ç”¨çš„ç›®æ ‡Ability<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | +| backgroundModes | number | 是 | å¦ | 表示åŽå°æœåŠ¡çš„类型<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | | isVisible | boolean | 是 | å¦ | 判æ–Ability是å¦å¯ä»¥è¢«å…¶ä»–应用调用 | -| formEnabled | boolean | 是 | å¦ | 判æ–Ability是å¦æä¾›å¡ç‰‡èƒ½åŠ› | -| type | AbilityType | 是 | å¦ | Ability类型 | +| formEnabled | boolean | 是 | å¦ | 判æ–Ability是å¦æä¾›å¡ç‰‡èƒ½åŠ›<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | +| type | AbilityType | 是 | å¦ | Ability类型<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | | orientation | DisplayOrientation | 是 | å¦ | Abilityçš„æ˜¾ç¤ºæ¨¡å¼ | | launchMode | LaunchMode | 是 | å¦ | Abilityçš„å¯åŠ¨æ¨¡å¼ | -| permissions | Array\<string> | 是 | å¦ | 被其他应用Ability调用时需è¦ç”³è¯·çš„æƒé™é›†åˆ | +| permissions | Array\<string> | 是 | å¦ | 被其他应用Ability调用时需è¦ç”³è¯·çš„æƒé™é›†åˆ<br />é€šè¿‡ä¼ å…¥GET_ABILITY_INFO_WITH_PERMISSIONèŽ·å– | | deviceTypes | Array\<string> | 是 | å¦ | Ability支æŒçš„设备类型 | | deviceCapabilities | Array\<string> | 是 | å¦ | Ability需è¦çš„设备能力 | -| readPermission | string | 是 | å¦ | 读å–Abilityæ•°æ®æ‰€éœ€çš„æƒé™ | -| writePermission | string | 是 | å¦ | å‘Ability写数æ®æ‰€éœ€çš„æƒé™ | -| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | å¦ | 应用程åºçš„é…ç½®ä¿¡æ¯ | -| uri | string | 是 | å¦ | 获å–Ability的统一资æºæ ‡è¯†ç¬¦ï¼ˆURI) | +| readPermission | string | 是 | å¦ | 读å–Abilityæ•°æ®æ‰€éœ€çš„æƒé™<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | +| writePermission | string | 是 | å¦ | å‘Ability写数æ®æ‰€éœ€çš„æƒé™<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | +| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | å¦ | 应用程åºçš„é…置信æ¯<br />é€šè¿‡ä¼ å…¥GET_ABILITY_INFO_WITH_APPLICATIONèŽ·å– | +| uri | string | 是 | å¦ | 获å–Ability的统一资æºæ ‡è¯†ç¬¦ï¼ˆURI)<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | | labelId | number | 是 | å¦ | Abilityçš„æ ‡ç¾id | -| subType | AbilitySubType | 是 | å¦ | Abilityä¸æžšä¸¾ä½¿ç”¨çš„模æ¿çš„å类型 | -| metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | å¦ | abilityçš„è‡ªå®šä¹‰ä¿¡æ¯ | -| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | å¦ | abilityçš„å…ƒä¿¡æ¯ | +| subType | AbilitySubType | 是 | å¦ | Abilityä¸æžšä¸¾ä½¿ç”¨çš„模æ¿çš„å类型<br />æ¤å±žæ€§ä»…å¯åœ¨FA模型下使用 | +| metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | 是 | å¦ | ability的自定义信æ¯<br />é€šè¿‡ä¼ å…¥GET_ABILITY_INFO_WITH_METADATAèŽ·å– | +| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | å¦ | ability的元信æ¯<br />é€šè¿‡ä¼ å…¥GET_ABILITY_INFO_WITH_METADATAèŽ·å– | | enabled<sup>8+</sup> | boolean | 是 | å¦ | ability是å¦å¯ç”¨ | | supportWindowMode<sup>9+</sup> | Array\<[SupportWindowMode](js-apis-Bundle.md)> | 是 | å¦ | ability支æŒçš„窗å£æ¨¡å¼ | | maxWindowRatio<sup>9+</sup> | number | 是 | å¦ | ability支æŒçš„最大的窗å£æ¯”例 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md index d2a181f5e3014483f941d2f1c3f5f20eaa3369e0..14e35a748a226853453725b3e638a90cabc30b8f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @@ -3,7 +3,7 @@ >  **说明:** > 本模å—首批接å£ä»ŽAPI version 7 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 -应用程åºä¿¡æ¯ +应用程åºä¿¡æ¯ï¼Œæœªåšç‰¹æ®Šè¯´æ˜Žçš„属性,å‡é€šè¿‡GET_BUNDLE_DEFAULTèŽ·å– ## ApplicationInfo @@ -25,17 +25,17 @@ | process | string | 是 | å¦ | 应用程åºçš„进程,如果ä¸è®¾ç½®ï¼Œé»˜è®¤ä¸ºåŒ…çš„å称。 | | supportedModes | number | 是 | å¦ | 应用程åºæ”¯æŒçš„è¿è¡Œæ¨¡å¼ã€‚ | | moduleSourceDirs | Array\<string> | 是 | å¦ | 应用程åºçš„资æºå˜æ”¾çš„相对路径。 | -| permissions | Array\<string> | 是 | å¦ | 访问应用程åºæ‰€éœ€çš„æƒé™ã€‚ | +| permissions | Array\<string> | 是 | å¦ | 访问应用程åºæ‰€éœ€çš„æƒé™ã€‚<br />é€šè¿‡ä¼ å…¥GET_APPLICATION_INFO_WITH_PERMISSIONèŽ·å– | | moduleInfos | Array\<[ModuleInfo](js-apis-bundle-ModuleInfo.md)> | 是 | å¦ | 应用程åºçš„模å—ä¿¡æ¯ã€‚ | | entryDir | string | 是 | å¦ | 应用程åºçš„文件ä¿å˜è·¯å¾„。 | | codePath<sup>8+</sup> | string | 是 | å¦ | 应用程åºçš„安装目录。 | -| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | å¦ | 应用程åºçš„自定义元信æ¯ã€‚ | -| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | 是 | å¦ | 应用程åºçš„元信æ¯ã€‚ | +| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | å¦ | 应用程åºçš„自定义元信æ¯ã€‚<br />é€šè¿‡ä¼ å…¥GET_APPLICATION_INFO_WITH_METADATAèŽ·å– | +| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | 是 | å¦ | 应用程åºçš„元信æ¯ã€‚<br />é€šè¿‡ä¼ å…¥GET_APPLICATION_INFO_WITH_METADATAèŽ·å– | | removable<sup>8+</sup> | boolean | 是 | å¦ | 应用程åºæ˜¯å¦å¯ä»¥è¢«ç§»é™¤ã€‚ | | accessTokenId<sup>8+</sup> | number | 是 | å¦ | 应用程åºçš„accessTokenId。 | | uid<sup>8+</sup> | number | 是 | å¦ | 应用程åºçš„uid。 | | entityType<sup>8+</sup> | string | 是 | å¦ | 应用程åºçš„实体类型。 | -| fingerprint<sup>9+</sup> | string | 是 | å¦ | 应用程åºçš„ç¾åè¯ä¹¦æŒ‡çº¹ä¿¡æ¯ï¼Œå³å¼€å‘者申请的ç¾åè¯ä¹¦çš„sha256值。 | +| fingerprint<sup>9+</sup> | string | 是 | å¦ | 应用程åºçš„ç¾åè¯ä¹¦æŒ‡çº¹ä¿¡æ¯ï¼Œå³å¼€å‘者申请的ç¾åè¯ä¹¦çš„sha256值。<br />é€šè¿‡ä¼ å…¥GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINTèŽ·å– | | iconResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | å¦ | 应用程åºçš„å›¾æ ‡èµ„æºä¿¡æ¯ã€‚ | | labelResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | å¦ | 应用程åºçš„æ ‡ç¾èµ„æºä¿¡æ¯ã€‚ | | descriptionResource<sup>9+</sup> | [Resource](js-apis-resource-manager.md#resource9) | 是 | å¦ | 应用程åºçš„æ述资æºä¿¡æ¯ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInfo.md index 80ace94cbd2a31c487b360e029480feb54394d27..f92370a7861bdb78dbcd0df1ae92e6eab04d1f38 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInfo.md @@ -7,38 +7,38 @@ -åº”ç”¨åŒ…çš„ä¿¡æ¯ +应用包的信æ¯ï¼Œæœªåšç‰¹æ®Šè¯´æ˜Žçš„属性,å‡é€šè¿‡GET_BUNDLE_DEFAULTèŽ·å– ## BundleInfo **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------ | -| name | string | 是 | å¦ | 应用包的å称 | -| type | string | 是 | å¦ | 应用包类型 | -| appId | string | 是 | å¦ | 应用包里应用程åºçš„id | -| uid | number | 是 | å¦ | 应用包里应用程åºçš„uid | -| installTime | number | 是 | å¦ | HAP包安装时间 | -| updateTime | number | 是 | å¦ | HAP包更新时间 | -| appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | å¦ | 应用程åºçš„é…ç½®ä¿¡æ¯ | -| abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | å¦ | Abilityçš„é…ç½®ä¿¡æ¯ | -| reqPermissions | Array\<string> | 是 | å¦ | 应用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆ | -| reqPermissionDetails | Array\<[ReqPermissionDetail](#ReqPermissionDetail)> | 是 | å¦ | 应用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆçš„è¯¦ç»†ä¿¡æ¯ | -| vendor | string | 是 | å¦ | 应用包的供应商 | -| versionCode | number | 是 | å¦ | åº”ç”¨åŒ…çš„ç‰ˆæœ¬å· | -| versionName | string | 是 | å¦ | 应用包的版本文本æè¿°ä¿¡æ¯ | -| compatibleVersion | number | 是 | å¦ | è¿è¡Œåº”用包所需è¦æœ€ä½Žçš„SDKç‰ˆæœ¬å· | -| targetVersion | number | 是 | å¦ | è¿è¡Œåº”用包所需è¦æœ€é«˜SDKç‰ˆæœ¬å· | -| isCompressNativeLibs | boolean | 是 | å¦ | 是å¦åŽ‹ç¼©åº”用包的本地库,默认为true | -| hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | 是 | å¦ | 模å—çš„é…ç½®ä¿¡æ¯ | -| entryModuleName | string | 是 | å¦ | Entry的模å—å称 | -| cpuAbi | string | 是 | å¦ | 应用包的cpuAbiä¿¡æ¯ | -| isSilentInstallation | string | 是 | å¦ | 是å¦é€šè¿‡é™é»˜å®‰è£… | -| minCompatibleVersionCode | number | 是 | å¦ | 分布å¼åœºæ™¯ä¸‹çš„应用包兼容的最低版本 | -| entryInstallationFree | boolean | 是 | å¦ | Entry是å¦æ”¯æŒå…安装 | -| reqPermissionStates<sup>8+</sup> | Array\<number> | 是 | å¦ | 申请æƒé™çš„æŽˆäºˆçŠ¶æ€ | -| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | 是 | å¦ | abilityçš„å¯æ‰©å±•ä¿¡æ¯ | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| --------------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ | +| name | string | 是 | å¦ | 应用包的å称 | +| type | string | 是 | å¦ | 应用包类型 | +| appId | string | 是 | å¦ | 应用包里应用程åºçš„id | +| uid | number | 是 | å¦ | 应用包里应用程åºçš„uid | +| installTime | number | 是 | å¦ | HAP包安装时间 | +| updateTime | number | 是 | å¦ | HAP包更新时间 | +| appInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | å¦ | 应用程åºçš„é…ç½®ä¿¡æ¯ | +| abilityInfos | Array\<[AbilityInfo](js-apis-bundle-AbilityInfo.md)> | 是 | å¦ | Abilityçš„é…置信æ¯<br />é€šè¿‡ä¼ å…¥GET_BUNDLE_WITH_ABILITIESèŽ·å– | +| reqPermissions | Array\<string> | 是 | å¦ | 应用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆ<br />é€šè¿‡ä¼ å…¥GET_BUNDLE_WITH_REQUESTED_PERMISSIONèŽ·å– | +| reqPermissionDetails | Array\<[ReqPermissionDetail](#reqpermissiondetail)> | 是 | å¦ | 应用è¿è¡Œæ—¶éœ€å‘系统申请的æƒé™é›†åˆçš„详细信æ¯<br />é€šè¿‡ä¼ å…¥GET_BUNDLE_WITH_REQUESTED_PERMISSIONèŽ·å– | +| vendor | string | 是 | å¦ | 应用包的供应商 | +| versionCode | number | 是 | å¦ | åº”ç”¨åŒ…çš„ç‰ˆæœ¬å· | +| versionName | string | 是 | å¦ | 应用包的版本文本æè¿°ä¿¡æ¯ | +| compatibleVersion | number | 是 | å¦ | è¿è¡Œåº”用包所需è¦æœ€ä½Žçš„SDKç‰ˆæœ¬å· | +| targetVersion | number | 是 | å¦ | è¿è¡Œåº”用包所需è¦æœ€é«˜SDKç‰ˆæœ¬å· | +| isCompressNativeLibs | boolean | 是 | å¦ | 是å¦åŽ‹ç¼©åº”用包的本地库,默认为true | +| hapModuleInfos | Array\<[HapModuleInfo](js-apis-bundle-HapModuleInfo.md)> | 是 | å¦ | 模å—çš„é…ç½®ä¿¡æ¯ | +| entryModuleName | string | 是 | å¦ | Entry的模å—å称 | +| cpuAbi | string | 是 | å¦ | 应用包的cpuAbiä¿¡æ¯ | +| isSilentInstallation | string | 是 | å¦ | 是å¦é€šè¿‡é™é»˜å®‰è£… | +| minCompatibleVersionCode | number | 是 | å¦ | 分布å¼åœºæ™¯ä¸‹çš„应用包兼容的最低版本 | +| entryInstallationFree | boolean | 是 | å¦ | Entry是å¦æ”¯æŒå…安装 | +| reqPermissionStates<sup>8+</sup> | Array\<number> | 是 | å¦ | 申请æƒé™çš„æŽˆäºˆçŠ¶æ€ | +| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | 是 | å¦ | abilityçš„å¯æ‰©å±•ä¿¡æ¯<br />é€šè¿‡ä¼ å…¥GET_BUNDLE_WITH_EXTENSION_ABILITYèŽ·å– | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md new file mode 100644 index 0000000000000000000000000000000000000000..003becc599ab3271b038237b783994d0751a8681 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -0,0 +1,105 @@ +# BundleInstaller + + + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 7 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +在设备上安装ã€å‡çº§å’Œåˆ 除æ†ç»‘包 + + + +## 系统能力 + +SystemCapability.BundleManager.BundleFramework + +## BundleInstaller.install + +install(bundleFilePaths: Array<string>, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +以异æ¥æ–¹æ³•åœ¨HAPä¸å®‰è£…应用程åºï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.INSTALL_BUNDLE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| bundleFilePaths | Array<string> | 是 | 指示å˜å‚¨åº”用程åºåŒ…的路径。路径应该是当å‰åº”用程åºçš„æ•°æ®ç›®å½•çš„相对路径。 | +| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他å‚数。 | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回安装状æ€ä¿¡æ¯ã€‚ | + +## BundleInstaller.uninstall + +uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +以异æ¥æ–¹æ³•å¸è½½åº”用程åºï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.INSTALL_BUNDLE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | 是 | 包å | +| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他å‚数。 | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回安装状æ€ä¿¡æ¯ã€‚ | + +## BundleInstaller.recover + +recover(bundleName: string, param: InstallParam, callback: AsyncCallback<InstallStatus>): void; + +以异æ¥æ–¹æ³•æ¢å¤ä¸€ä¸ªåº”用程åºï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** + +ohos.permission.INSTALL_BUNDLE + +**系统能力:** + +SystemCapability.BundleManager.BundleFramework + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| bundleName | string | 是 | 包å | +| param | [InstallParam](#installparam) | 是 | 指定安装所需的其他å‚数。 | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | 是 | 程åºå¯åŠ¨ä½œä¸ºå…¥å‚的回调函数,返回安装状æ€ä¿¡æ¯ã€‚ | + +## InstallParam + +应用程åºå®‰è£…å¸è½½ä¿¡æ¯ + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | 说明 | +| ----------- | ------- | ------------------ | +| userId | number | 指示用户id | +| installFlag | number | æŒ‡ç¤ºå®‰è£…æ ‡å¿— | +| isKeepData | boolean | 指示å‚数是å¦æœ‰æ•°æ® | + +## InstallStatus + +应用程åºå®‰è£…çŠ¶æ€ + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------ | +| status | bundle.[InstallErrorCode](js-apis-Bundle.md#installerrorcode) | 是 | å¦ | 表示安装或å¸è½½é”™è¯¯çŠ¶æ€ç | +| statusMessage | string | 是 | å¦ | 表示安装或å¸è½½çš„å—ç¬¦ä¸²ç»“æžœä¿¡æ¯ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md index 33b58e0721464c04d2f6d966a9322f02c0b8322b..c7fc3de209c93551ef06d170a8b941c91fa5821d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md @@ -2,17 +2,17 @@ -**说明:** +>  **说明:** > 本模å—首批接å£ä»ŽAPI version 7 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 - - ElementNameä¿¡æ¯ ## ElementName **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + + | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ----------------------- | ---------| ---- | ---- | ------------------------- | | deviceId | string | 是 | 是 | 设备id | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md index 879d9f4b48468c5a564f9e9685dcc262e60fe762..6ca778bf7ca5bb9f2fec9af3680d485fb27ac12e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ExtensionAbilityInfo.md @@ -7,7 +7,7 @@ -ExtensionAbilityä¿¡æ¯ +ExtensionAbilityä¿¡æ¯ï¼Œæœªåšç‰¹æ®Šè¯´æ˜Žçš„属性,å‡é€šè¿‡GET_BUNDLE_DEFAULTèŽ·å– ## ExtensionAbilityInfo diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md index f21241cda3ae6467ea1198b4496961725a4f9c90..8cb5642e31bd0805ae7b5f0424406506c1df763d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-HapModuleInfo.md @@ -7,7 +7,7 @@ -Hap模å—ä¿¡æ¯ +Hap模å—ä¿¡æ¯ï¼Œæœªåšç‰¹æ®Šè¯´æ˜Žçš„属性,å‡é€šè¿‡GET_BUNDLE_DEFAULTèŽ·å– ## HapModuleInfo @@ -35,4 +35,5 @@ Hap模å—ä¿¡æ¯ | mainElementName<sup>9+</sup> | string | 是 | å¦ | å…¥å£abilityä¿¡æ¯ | | extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | 是 | å¦ | extensionAbilityä¿¡æ¯ | | metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | 是 | å¦ | Abilityçš„å…ƒä¿¡æ¯ | -| hashValue<sup>9+</sup> | string | 是 | å¦ | Moduleçš„Hash值 | \ No newline at end of file +| hashValue<sup>9+</sup> | string | 是 | å¦ | Moduleçš„Hash值<br />é€šè¿‡ä¼ å…¥GET_BUNDLE_WITH_HASH_VALUEèŽ·å– | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..c2ca416a6b9ee5a46f61672259d39951481abce6 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-LauncherAbilityInfo.md @@ -0,0 +1,23 @@ +# LauncherAbilityInfo + + + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +LauncherAbilityInfoä¿¡æ¯ + +## LauncherAbilityInfo + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ | +| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | å¦ | launcher ability的应用程åºçš„é…ç½®ä¿¡æ¯ | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | å¦ | launcher abilityçš„ElementNameä¿¡æ¯ | +| labelId | number | 是 | å¦ | launcher abilityçš„æ ‡ç¾ID | +| iconId | number | 是 | å¦ | launcher abilityçš„å›¾æ ‡ID | +| userId | number | 是 | å¦ | launcher ability的用户ID | +| installTime | number | 是 | å¦ | launcher ability的安装时间 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-PermissionDef.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-PermissionDef.md new file mode 100644 index 0000000000000000000000000000000000000000..62cc922bfff3498be6dbba4c3ecc935bbc6c7221 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-PermissionDef.md @@ -0,0 +1,21 @@ +# PermissionDef + + + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +é…置文件ä¸å®šä¹‰çš„æƒé™è¯¦ç»†ä¿¡æ¯ + +## **PermissionDef** + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------------- | ------ | ---- | ---- | -------------- | +| permissionName | string | 是 | å¦ | 用户æƒé™å称 | +| grantMode | number | 是 | å¦ | æƒé™çš„æŽˆäºˆæ¨¡å¼ | +| labelId | number | 是 | å¦ | æƒé™çš„æ ‡ç¾ID | +| descriptionId | number | 是 | å¦ | æè¿°æƒé™çš„ID | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..2a1eb5a9b7e34e472b584258e8014939910c785d --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @@ -0,0 +1,47 @@ +# ShortcutInfo + + + +> **说明:** +> +> 本模å—首批接å£ä»ŽAPI version 7 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +é…置文件ä¸å®šä¹‰çš„å¿«æ·æ–¹å¼ä¿¡æ¯ã€‚ + + + +## ShortcutWant + +å¿«æ·æ–¹å¼æ‰€æŒ‡å‘çš„ç›®æ ‡ä¿¡æ¯ã€‚ + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------------------------- | ------ | ---- | ---- | -------------------- | +| targetBundle | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„ç›®æ ‡æ†ç»‘包 | +| targetModule<sup>9+</sup> | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„ç›®æ ‡æ¨¡å— | +| targetClass | string | 是 | å¦ | å¿«æ·æ–¹å¼æ‰€éœ€çš„ç›®æ ‡ç±» | + +## ShortcutInfo + +å¿«æ·æ–¹å¼å±žæ€§ä¿¡æ¯ã€‚ + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- | +| id | string | 是 | å¦ | å¿«æ·æ–¹å¼æ‰€å±žåº”用程åºçš„Id | +| bundleName | string | 是 | å¦ | 包å«å¿«æ·æ–¹å¼çš„包å称 | +| hostAbility | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„本地Abilityä¿¡æ¯ | +| icon | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„å›¾æ ‡ | +| iconId<sup>8+</sup> | number | 是 | å¦ | å¿«æ·æ–¹å¼çš„å›¾æ ‡Id | +| label | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„æ ‡ç¾ | +| labelId<sup>8+</sup> | number | 是 | å¦ | å¿«æ·æ–¹å¼çš„æ ‡ç¾Id | +| disableMessage | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„ç¦ç”¨æ¶ˆæ¯ | +| wants | Array<[ShortcutWant](#shortcutwant)> | 是 | å¦ | å¿«æ·æ–¹å¼æ‰€éœ€è¦çš„ä¿¡æ¯ | +| isStatic | boolean | 是 | å¦ | å¿«æ·æ–¹å¼æ˜¯å¦ä¸ºé™æ€ | +| isHomeShortcut | boolean | 是 | å¦ | å¿«æ·æ–¹å¼æ˜¯å¦ä¸ºä¸»é¡µé¢å¿«æ·æ–¹å¼ | +| isEnabled | boolean | 是 | å¦ | 是å¦å¯ç”¨å¿«æ·æ–¹å¼ | +| moduleName<sup>9+</sup> | string | 是 | å¦ | å¿«æ·æ–¹å¼çš„模å—å | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md index 502a72801becf2d912d4da660d1e78c13dd98c93..7e2f8e3deede69d1204b7b91589a4f5d7a73167d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-defaultAppManager.md @@ -96,7 +96,7 @@ getDefaultApplication(type: string, userId?: number): Promise\<BundleInfo> **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -141,7 +141,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<Bun **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -181,7 +181,7 @@ getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -220,7 +220,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -268,7 +268,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -317,7 +317,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -365,7 +365,7 @@ resetDefaultApplication(type: string, userId?: number): Promise\<void> **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -404,7 +404,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<v **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** @@ -444,7 +444,7 @@ resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; **系统能力:** SystemCapability.BundleManager.BundleFramework -**System API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ +**系统API:** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ **å‚数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..37601a3c83847c49bdab956e6782934c4f5c5499 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md @@ -0,0 +1,20 @@ +# RemoteAbilityInfo + + + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +包å«åŸºæœ¬è¿œç¨‹èƒ½åŠ›ä¿¡æ¯ + +## RemoteAbilityInfo + + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | å¦ | 指明的abilityä¿¡æ¯ | +| label | string | 是 | å¦ | 指明abilityçš„æ ‡ç¾ä¿¡æ¯ | +| icon | string | 是 | å¦ | 指明的abilityçš„å›¾æ ‡ä¿¡æ¯ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md index add046e1ff964c4f3d54cf4e5657f74a456b0c62..b35171946c40d103048917acf969d8173553a8fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md @@ -18,7 +18,10 @@ startTrace(name: string, taskId: number, expectedTime?: number): void æ ‡è®°ä¸€ä¸ªæ—¶é—´ç‰‡è·Ÿè¸ªä»»åŠ¡çš„å¼€å§‹ã€‚ -**系统能力:** SystemCapability.Developtools.Bytrace +> **说明:** +> 如果有多个相åŒname的任务需è¦è¿½è¸ªæˆ–者对åŒä¸€ä¸ªä»»åŠ¡è¦è¿½è¸ªå¤šæ¬¡ï¼Œå¹¶ä¸”这些跟踪任务会åŒæ—¶è¢«æ‰§è¡Œï¼Œåˆ™æ¯æ¬¡è°ƒç”¨startTraceçš„taskIdå¿…é¡»ä¸ä¸€è‡´ã€‚如果具有相åŒname的跟踪任务是串行执行的,则taskIdå¯ä»¥ç›¸åŒã€‚在下é¢bytrace.finishTrace的示例ä¸ä¼šä¸¾ä¾‹è¯´æ˜Žã€‚ + +**系统能力:** SystemCapability.HiviewDFX.HiTrace **å‚数:** @@ -28,8 +31,6 @@ startTrace(name: string, taskId: number, expectedTime?: number): void | taskId | number | 是 | 时间片跟踪任务id | | expectedTime | number | å¦ | 期望的耗时时间(å•ä½ï¼šms) | ->  **说明:** -> 如果有多个相åŒname的任务需è¦è¿½è¸ªæˆ–者对åŒä¸€ä¸ªä»»åŠ¡è¦è¿½è¸ªå¤šæ¬¡ï¼Œå¹¶ä¸”这些跟踪任务会åŒæ—¶è¢«æ‰§è¡Œï¼Œåˆ™æ¯æ¬¡è°ƒç”¨startTraceçš„taskIdå¿…é¡»ä¸ä¸€è‡´ã€‚如果具有相åŒname的跟踪任务是串行执行的,则taskIdå¯ä»¥ç›¸åŒã€‚在下é¢bytrace.finishTrace的示例ä¸ä¼šä¸¾ä¾‹è¯´æ˜Žã€‚ **示例:** @@ -44,7 +45,10 @@ finishTrace(name: string, taskId: number): void æ ‡è®°ä¸€ä¸ªæ—¶é—´ç‰‡è·Ÿè¸ªäº‹ä»¶çš„ç»“æŸã€‚ -**系统能力:** SystemCapability.Developtools.Bytrace +> **说明:**<br> +> finishTraceçš„nameå’ŒtaskId必须与æµç¨‹å¼€å§‹çš„startTrace对应å‚数值一致。 + +**系统能力:** SystemCapability.HiviewDFX.HiTrace **å‚数:** @@ -53,8 +57,6 @@ finishTrace(name: string, taskId: number): void | name | string | 是 | 时间片跟踪任务å称 | | taskId | number | 是 | 时间片跟踪任务id | -> **说明:**<br> -> finishTraceçš„nameå’ŒtaskId必须与æµç¨‹å¼€å§‹çš„startTrace对应å‚数值一致。 **示例:** @@ -90,7 +92,7 @@ traceByValue(name: string, count: number): void æ ‡è®°é¢„è¿½è¸ªè€—æ—¶ä»»åŠ¡çš„æ•°å€¼å˜é‡ï¼Œè¯¥å˜é‡çš„数值会ä¸æ–å˜åŒ–。 -**系统能力:** SystemCapability.Developtools.Bytrace +**系统能力:** SystemCapability.HiviewDFX.HiTrace **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index 4b67f61a0c4270e6764eb411710754b43c1c9702..485b10f670342d3aa081ab927f735d305404e184 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -514,15 +514,2241 @@ promise.then(data => { }); ``` +## call.muteRinger<sup>8+</sup> + +muteRinger\(callback: AsyncCallback<void\>\): void + +如果æ¥ç”µé“ƒå£°å“起,设备将åœæ¢é“ƒå£°ã€‚å¦åˆ™ï¼Œæ¤æ–¹æ³•ä¸èµ·ä½œç”¨ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.muteRinger((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.muteRinger<sup>8+</sup> + +muteRinger\(\): Promise<void\> + +如果æ¥ç”µé“ƒå£°å“起,设备将åœæ¢é“ƒå£°ã€‚å¦åˆ™ï¼Œæ¤æ–¹æ³•ä¸èµ·ä½œç”¨ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.muteRinger(); +promise.then(data => { + console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.answer<sup>7+</sup> + +answer\(callback: AsyncCallback<void\>\): void + +接å¬æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.ANSWER_CALL + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.answer((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.answer<sup>7+</sup> + +answer\(callId: number, callback: AsyncCallback<void\>\): void + +接å¬æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.ANSWER_CALL + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ----------------------------------------------- | +| callId | number | 是 | 呼å«Id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.answer(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.answer<sup>7+</sup> + +answer(callId?: number\): Promise<void\> + +接å¬æ¥ç”µã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.ANSWER_CALL + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| callId | number | å¦ | 呼å«Id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。从API Version 9开始为å¯é€‰å‚数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.answer(1); +promise.then(data => { + console.log(`answer success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`answer fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.hangup<sup>7+</sup> + +hangup\(callback: AsyncCallback<void\>\): void + +挂æ–电è¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.hangup((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.hangup<sup>7+</sup> + +hangup\(callId: number, callback: AsyncCallback<void\>\): void + +挂æ–电è¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ----------------------------------------------- | +| callId | number | 是 | 呼å«id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.hangup(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.hangup<sup>7+</sup> + +hangup\(callId?: number\): Promise<void\> + +挂æ–电è¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| callId | number | å¦ | 呼å«id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。从API Version 9开始为å¯é€‰å‚数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.hangup(1); +promise.then(data => { + console.log(`hangup success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`hangup fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.reject<sup>7+</sup> + +reject\(callback: AsyncCallback<void\>\): void + +æ‹’ç»æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.reject((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.reject<sup>7+</sup> + +reject\(options: RejectMessageOptions, callback: AsyncCallback<void\>\): void + +æ‹’ç»æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------- | ---- | -------------- | +| options | [RejectMessageOptions](#rejectmessageoptions7) | 是 | æ‹’ç»æ¶ˆæ¯é€‰é¡¹ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let rejectMessageOptions={ + messageContent: "拦截陌生å·ç " +} +call.reject(rejectMessageOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.reject<sup>7+</sup> + +reject(callId: number, callback: AsyncCallback<void\>): <void\> + +æ‹’ç»æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ----------------------------------------------- | +| callId | number | 是 | 呼å«Id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.reject(1); +promise.then(data => { + console.log(`reject success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`reject fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.reject<sup>7+</sup> + +reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback<void\>\): void + +æ‹’ç»æ¥ç”µã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | +| callId | number | 是 | 呼å«Id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。 | +| options | [RejectMessageOptions](#rejectmessageoptions7) | 是 | æ‹’ç»æ¶ˆæ¯é€‰é¡¹ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let rejectMessageOptions={ + messageContent: "拦截陌生å·ç " +} +call.reject(1, rejectMessageOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.reject<sup>7+</sup> + +reject(callId?: number, options?: RejectMessageOptions\): Promise<void\> + +æ‹’ç»æ¥ç”µã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | +| callId | number | å¦ | 呼å«Id。å¯ä»¥é€šè¿‡è®¢é˜…callDetailsChange事件获得。从API Version 9开始为å¯é€‰å‚数。 | +| options | [RejectMessageOptions](#rejectmessageoptions7) | å¦ | æ‹’ç»æ¶ˆæ¯é€‰é¡¹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let rejectMessageOptions={ + messageContent: "拦截陌生å·ç " +} +let promise = call.reject(1, rejectMessageOptions); +promise.then(data => { + console.log(`reject success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`reject fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.holdCall<sup>7+</sup> + +holdCall\(callId: number, callback: AsyncCallback<void\>\): void + +ä¿æŒé€šè¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.holdCall(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.holdCall<sup>7+</sup> + +holdCall\(callId: number\): Promise<void\> + +ä¿æŒé€šè¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.holdCall(1); +promise.then(data => { + console.log(`holdCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.unHoldCall<sup>7+</sup> + +unHoldCall\(callId: number, callback: AsyncCallback<void\>\): void + +å–消ä¿æŒé€šè¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.unHoldCall(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.unHoldCall<sup>7+</sup> + +unHoldCall\(callId: number\): Promise<void\> + +å–消ä¿æŒé€šè¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.unHoldCall(1); +promise.then(data => { + console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.switchCall<sup>7+</sup> + +switchCall\(callId: number, callback: AsyncCallback<void\>\): void + +切æ¢å‘¼å«ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.switchCall(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.switchCall<sup>7+</sup> + +switchCall\(callId: number\): Promise<void\> + +切æ¢å‘¼å«ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.switchCall(1); +promise.then(data => { + console.log(`switchCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.combineConference<sup>7+</sup> + +combineConference\(callId: number, callback: AsyncCallback<void\>\): void + +åˆå¹¶é€šè¯ï¼Œå°†ä¸¤é€šç”µè¯åˆå¹¶æˆä¼šè®®ç”µè¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.combineConference(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.combineConference<sup>7+</sup> + +combineConference\(callId: number\): Promise<void\> + +åˆå¹¶é€šè¯ï¼Œå°†ä¸¤é€šç”µè¯åˆå¹¶æˆä¼šè®®ç”µè¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.combineConference(1); +promise.then(data => { + console.log(`combineConference success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getMainCallId<sup>7+</sup> + +getMainCallId\(callId: number, callback: AsyncCallback<number\>\): void + +获å–主呼å«Id。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ------------------------ | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<number> | 是 | 回调函数。返回主呼å«Id。 | + +**示例:** + +```js +call.getMainCallId(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getMainCallId<sup>7+</sup> + +getMainCallId\(callId: number\): Promise<number\> + +获å–主呼å«Id。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回主呼å«Id。 | + +**示例:** + +```js +let promise = call.getMainCallId(1); +promise.then(data => { + console.log(`getMainCallId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getMainCallId fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getSubCallIdList<sup>7+</sup> + +getSubCallIdList\(callId: number, callback: AsyncCallback<Array<string\>\>\): void + +获å–å呼å«Id列表。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------ | ---- | ---------------------------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<Array<string\>\> | 是 | 回调函数。返回å呼å«Id列表。 | + +**示例:** + +```js +call.getSubCallIdList(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getSubCallIdList<sup>7+</sup> + +getSubCallIdList\(callId: number\): Promise<Array<string\>\> + +获å–å呼å«Id列表。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | ----------------------------------- | +| Promise<Array<string\>> | 以Promiseå½¢å¼å¼‚æ¥è¿”回å呼å«Id列表。 | + +**示例:** + +```js +let promise = call.getSubCallIdList(1); +promise.then(data => { + console.log(`getSubCallIdList success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getSubCallIdList fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getCallIdListForConference<sup>7+</sup> + +getCallIdListForConference\(callId: number, callback: AsyncCallback<Array<string\>>\): void + +获å–会议的呼å«Id列表。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | -------------------------------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<Array<string\>> | 是 | 回调函数。返回会议的呼å«Id列表。 | + +**示例:** + +```js +call.getCallIdListForConference(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getCallIdListForConference<sup>7+</sup> + +getCallIdListForConference\(callId: number\): Promise<Array<string\>\> + +获å–会议的呼å«Id列表。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | --------------------------------------- | +| Promise<Array<string\>> | 以Promiseå½¢å¼å¼‚æ¥è¿”回会议的呼å«Id列表。 | + +**示例:** + +```js +let promise = call.getCallIdListForConference(1); +promise.then(data => { + console.log(`getCallIdListForConference success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCallIdListForConference fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getCallWaitingStatus<sup>7+</sup> + +getCallWaitingStatus\(slotId: number, callback: AsyncCallback<CallWaitingStatus\>\): void + +获å–呼å«ç‰å¾…状æ€ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | 是 | 回调函数。<br/>返回呼å«ç‰å¾…状æ€ã€‚<br/>- 0:ç¦ç”¨å‘¼å«ç‰å¾… <br/>- 1:å¯ç”¨å‘¼å«ç‰å¾… | + +**示例:** + +```js +call.getCallWaitingStatus(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getCallWaitingStatus<sup>7+</sup> + +getCallWaitingStatus\(slotId: number\): Promise<CallWaitingStatus\> + +获å–呼å«ç‰å¾…状æ€ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | ------------------------------------------------------------ | +| Promise<[CallWaitingStatus](#callwaitingstatus7)> | 以Promiseå½¢å¼å¼‚æ¥è¿”回呼å«ç‰å¾…状æ€ã€‚<br/>- 0:ç¦ç”¨å‘¼å«ç‰å¾… <br/>- 1:å¯ç”¨å‘¼å«ç‰å¾… | + +**示例:** + +```js +let promise = call.getCallWaitingStatus(0); +promise.then(data => { + console.log(`getCallWaitingStatus success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCallWaitingStatus fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.setCallWaiting<sup>7+</sup> + +setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback<void\>\): void + +设置呼å«ç‰å¾…。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------------------------------------------------ | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| activate | boolean | 是 | 呼å«ç‰å¾…是å¦å¤„于å¯ç”¨çŠ¶æ€ã€‚<br/>- false:ç¦ç”¨å‘¼å«ç‰å¾…<br/>- true:å¯ç”¨å‘¼å«ç‰å¾… | +| callback | AsyncCallback<void\> | 是 | 回调函数。 | + +**示例:** + +```js +call.setCallWaiting(0, true, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setCallWaiting<sup>7+</sup> + +setCallWaiting\(slotId: number, activate: boolean\): Promise<void\> + +设置呼å«ç‰å¾…。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------- | ---- | ------------------------------------------------------------ | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| activate | boolean | 是 | 呼å«ç‰å¾…是å¦å¤„于å¯ç”¨çŠ¶æ€ã€‚<br/>- false:ç¦ç”¨å‘¼å«ç‰å¾…<br/>- true:å¯ç”¨å‘¼å«ç‰å¾… | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.setCallWaiting(0, true); +promise.then(data => { + console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.startDTMF<sup>7+</sup> + +startDTMF\(callId: number, character: string, callback: AsyncCallback<void\>\): void + +å¯åŠ¨åŒéŸ³å¤šé¢‘。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | -------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| character | string | 是 | DTMFç 。 | +| callback | AsyncCallback<void\> | 是 | 回调函数。 | + +**示例:** + +```js +call.startDTMF(1, "0", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.startDTMF<sup>7+</sup> + +startDTMF\(callId: number, character: string\): Promise<void\> + +å¯åŠ¨åŒéŸ³å¤šé¢‘。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | +| character | string | 是 | DTMFç 。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回。 | + +**示例:** + +```js +let promise = call.startDTMF(1, "0"); +promise.then(data => { + console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.stopDTMF<sup>7+</sup> + +stopDTMF\(callId: number, callback: AsyncCallback<void\>\): void + +åœæ¢åŒéŸ³å¤šé¢‘。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.stopDTMF(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.stopDTMF<sup>7+</sup> + +stopDTMF\(callId: number\): Promise<void\> + +åœæ¢åŒéŸ³å¤šé¢‘。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.stopDTMF(1); +promise.then(data => { + console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.isInEmergencyCall<sup>7+</sup> + +isInEmergencyCall\(callback: AsyncCallback<boolean\>\): void + +判æ–是å¦æ£åœ¨å¤„于紧急呼å«ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | ---------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +```js +call.isInEmergencyCall((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.isInEmergencyCall<sup>7+</sup> + +isInEmergencyCall\(\): Promise<boolean\> + +判æ–是å¦æ£åœ¨å¤„于紧急呼å«ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<boolean> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.isInEmergencyCall(); +promise.then(data => { + console.log(`isInEmergencyCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isInEmergencyCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.on('callDetailsChange')<sup>7+</sup> + +on\(type: 'callDetailsChange', callback: Callback<CallAttributeOptions\>\): void + +订阅callDetailsChange事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------- | ---- | -------------------------- | +| type | string | 是 | 通è¯æ—¶ç›‘å¬é€šè¯è¯¦æƒ…çš„å˜åŒ–。 | +| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | 是 | 回调函数。 | + +**示例:** + +```js +call.on('callDetailsChange', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.on('callEventChange')<sup>8+</sup> + +on\(type: 'callEventChange', callback: Callback<CallEventOptions\>\): void + +订阅callEventChange事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ---- | -------------------------- | +| type | string | 是 | 通è¯æ—¶ç›‘å¬é€šè¯äº‹ä»¶çš„å˜åŒ–。 | +| callback | Callback<[CallEventOptions](#calleventoptions8)> | 是 | 回调函数。 | + +**示例:** + +```js +call.on('callEventChange', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.on('callDisconnectedCause')<sup>8+</sup> + +on\(type: 'callDisconnectedCause', callback: Callback<DisconnectedDetails\>): void + +订阅callDisconnectedCause事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------ | ---- | -------------------------- | +| type | string | 是 | 通è¯æ—¶ç›‘å¬æ–å¼€è¿žæŽ¥çš„åŽŸå› ã€‚ | +| callback | Callback<[DisconnectedDetails](#disconnecteddetails8)> | 是 | 回调函数。 | + +**示例:** + +```js +call.on('callDisconnectedCause', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.on('mmiCodeResult')<sup>9+</sup> + +on\(type: 'mmiCodeResult', callback: Callback<MmiCodeResults\>\): void + +订阅mmiCodeResult事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------------------- | ---- | --------------------- | +| type | string | 是 | 通è¯æ—¶ç›‘å¬MMIç 结果。 | +| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | 是 | 回调函数。 | + +**示例:** + +```js +isNewCallAllowedcall.on('mmiCodeResult', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.off('callDetailsChange')<sup>7+</sup> + +off\(type: 'callDetailsChange', callback?: Callback<CallAttributeOptions\>\): void + +å–消订阅callDetailsChange事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------------------------------- | ---- | ---------------------------------- | +| type | string | 是 | 通è¯ç»“æŸæ—¶å–消监å¬é€šè¯è¯¦æƒ…çš„å˜åŒ–。 | +| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | å¦ | 回调函数。 | + +**示例:** + +```js +call.off('callDetailsChange', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.off('callEventChange')<sup>8+</sup> + +off\(type: 'callEventChange', callback?: Callback<CallEventOptions\>\): void + +å–消订阅callEventChange事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------------------------- | +| type | string | 是 | 通è¯ç»“æŸæ—¶å–消监å¬é€šè¯äº‹ä»¶çš„å˜åŒ–。 | +| callback | Callback<[CallEventOptions](#calleventoptions8)> | å¦ | 回调函数。 | + +**示例:** + +```js +call.off('callEventChange', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.off('callDisconnectedCause')<sup>8+</sup> + +off\(type: 'callDisconnectedCause', callback?: Callback<DisconnectedDetails\>\): void + +å–消订阅callDisconnectedCause事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------------------- | ---- | -------------------- | +| type | 'callDisconnectedCause' | 是 | 调用æ–å¼€è¿žæŽ¥çš„åŽŸå› ã€‚ | +| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails8)> | å¦ | 回调函数。 | + +**示例:** + +```js +call.off('callDisconnectedCause', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.off('mmiCodeResult')<sup>9+</sup> + +off\(type: 'mmiCodeResult', callback?: Callback<MmiCodeResults\>\): void + +å–消订阅mmiCodeResult事件。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ---- | ----------- | +| type | 'mmiCodeResult' | 是 | MMIç 结果。 | +| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | å¦ | 回调函数。 | + +**示例:** + +```js +call.off('mmiCodeResult', (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.isNewCallAllowed<sup>8+</sup> + +isNewCallAllowed\(callback: AsyncCallback<boolean\>\): void + +判æ–是å¦å…许å†æ‹¨æ‰“一通新电è¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | ---------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +```js +call.isNewCallAllowed((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.isNewCallAllowed<sup>8+</sup> + +isNewCallAllowed\(\): Promise<boolean\> + +判æ–是å¦å…许å†æ‹¨æ‰“一通新电è¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<boolean> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.isNewCallAllowed(); +promise.then(data => { + console.log(`isNewCallAllowed success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isNewCallAllowed fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.separateConference<sup>8+</sup> + +separateConference\(callId: number, callback: AsyncCallback<void\>\): void + +分离会议电è¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callId | number | 是 | 呼å«Id。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.separateConference(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.separateConference<sup>8+</sup> + +separateConference\(callId: number\): Promise<void\> + +分离会议电è¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| callId | number | 是 | 呼å«Id。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.separateConference(1); +promise.then(data => { + console.log(`separateConference success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getCallRestrictionStatus<sup>8+</sup> + +getCallRestrictionStatus\(slotId: number, type: CallRestrictionType, callback: AsyncCallback<RestrictionStatus\>\): void + +获å–呼å«é™åˆ¶çŠ¶æ€ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [CallRestrictionType](#callrestrictiontype8) | 是 | 呼å«é™åˆ¶ç±»åž‹ã€‚ | +| callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | 是 | 回调函数。返回é™åˆ¶çŠ¶æ€ã€‚ | + +**示例:** + +```js +call.getCallRestrictionStatus(0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getCallRestrictionStatus<sup>8+</sup> + +getCallRestrictionStatus\(slotId: number, type: CallRestrictionType\): Promise<RestrictionStatus\> + +获å–呼å«é™åˆ¶çŠ¶æ€ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | -------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [CallRestrictionType](#callrestrictiontype8) | 是 | 呼å«é™åˆ¶ç±»åž‹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | --------------------------- | +| Promise<[RestrictionStatus](#restrictionstatus8)> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.getCallRestrictionStatus(0, 1); +promise.then(data => { + console.log(`getCallRestrictionStatus success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCallRestrictionStatus fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.setCallRestriction<sup>8+</sup> + +setCallRestriction\(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback<void\>\): void + +设置呼å«é™åˆ¶çŠ¶æ€ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| info | [CallRestrictionInfo](#callrestrictioninfo8) | 是 | 呼å«é™åˆ¶ä¿¡æ¯ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let callRestrictionInfo={ + type: 1, + password: "123456", + mode: 1 +} +call.setCallRestriction(0, callRestrictionInfo, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setCallRestriction<sup>8+</sup> + +setCallRestriction\(slotId: number, info: CallRestrictionInfo\): Promise<void\> + +设置呼å«é™åˆ¶çŠ¶æ€ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | -------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| info | [CallRestrictionInfo](#callrestrictioninfo8) | 是 | 呼å«é™åˆ¶ä¿¡æ¯ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let callRestrictionInfo={ + type: 1, + password: "123456", + mode: 1 +} +let promise = call.setCallRestriction(0, callRestrictionInfo); +promise.then(data => { + console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.getCallTransferInfo<sup>8+</sup> + +getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCallback<CallTransferResult\>\): void + +获å–呼å«è½¬ç§»ä¿¡æ¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [CallTransferType](#calltransfertype8) | 是 | 呼å«è½¬ç§»ç±»åž‹ã€‚ | +| callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | 是 | 回调函数。返回呼å«è½¬ç§»ä¿¡æ¯ã€‚ | + +**示例:** + +```js +let callTransferTyp={ + CallTransferType: 1 +} +call.getCallTransferInfo(0, callTransferTyp, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.getCallTransferInfo<sup>8+</sup> + +getCallTransferInfo\(slotId: number, type: CallTransferType): Promise<CallTransferResult\> + +获å–呼å«è½¬ç§»ä¿¡æ¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | -------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [CallTransferType](#calltransfertype8) | 是 | 呼å«è½¬ç§»ç±»åž‹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------------------- | --------------------------- | +| Promise<[CallTransferResult](#calltransferresult8)> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let callTransferTyp={ + CallTransferType: 1 +} +let promise = call.getCallTransferInfo(0, callTransferTyp); +promise.then(data => { + console.log(`getCallTransferInfo success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCallTransferInfo fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.setCallTransfer<sup>8+</sup> + +setCallTransfer\(slotId: number, info: CallTransferInfo, callback: AsyncCallback<void\>\): void + +设置呼å«è½¬ç§»ä¿¡æ¯ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| info | [CallTransferInfo](#calltransferinfo8) | 是 | 呼å«è½¬ç§»ä¿¡æ¯ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let callTransferInfo={ + transferNum: "111", + type: 1, + settingType: 1 +} +call.setCallTransfer(0, callTransferInfo, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setCallTransfer<sup>8+</sup> + +setCallTransfer\(slotId: number, info: CallTransferInfo): Promise<void\> + +设置呼å«è½¬ç§»ä¿¡æ¯ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| info | [CallTransferInfo](#calltransferinfo8) | 是 | 呼å«è½¬ç§»ä¿¡æ¯ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let callTransferInfo={ + transferNum: "111", + type: 1, + settingType: 1 +} +let promise = call.setCallTransfer(0, callTransferInfo); +promise.then(data => { + console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.isRinging<sup>8+</sup> + +isRinging\(callback: AsyncCallback<boolean\>\): void + +判æ–是å¦æ£åœ¨å“铃。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | ---------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +```js +call.isRinging((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.isRinging<sup>8+</sup> + +isRinging\(\): Promise<boolean\> + +判æ–是å¦æ£åœ¨å“铃。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<boolean> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.isRinging(); +promise.then(data => { + console.log(`isRinging success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isRinging fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.setMuted<sup>8+</sup> + +setMuted\(callback: AsyncCallback<void\>\): void + +设置通è¯ä¸çš„é™éŸ³ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.setMuted((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setMuted<sup>8+</sup> + +setMuted\(\): Promise<void\> + +设置通è¯ä¸çš„é™éŸ³ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.setMuted(); +promise.then(data => { + console.log(`setMuted success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.cancelMuted<sup>8+</sup> + +cancelMuted(callback: AsyncCallback<void\>): void + +å–消通è¯ä¸çš„é™éŸ³ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ---------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.cancelMuted((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.cancelMuted<sup>8+</sup> + +cancelMuted(): Promise<void\> + +å–消通è¯ä¸çš„é™éŸ³ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.cancelMuted(); +promise.then(data => { + console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.setAudioDevice<sup>8+</sup> + +setAudioDevice\(device: AudioDevice, callback: AsyncCallback<void\>\): void + +设置通è¯éŸ³é¢‘设备。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | ---------- | +| device | [AudioDevice](#audiodevice8) | 是 | 音频设备。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.setAudioDevice(1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setAudioDevice<sup>8+</sup> + +setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback<void\>\): void + +设置通è¯éŸ³é¢‘设备。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------ | ---- | -------------- | +| device | [AudioDevice](#audiodevice8) | 是 | 音频设备。 | +| options | [AudioDeviceOptions](#audiodeviceoptions9) | 是 | 音频设备å‚数。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let audioDeviceOptions={ + bluetoothAddress: "IEEE 802-2014" +} +call.setAudioDevice(1, bluetoothAddress, (err, value) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## call.setAudioDevice<sup>8+</sup> + +setAudioDevice(device: AudioDevice, options?: AudioDeviceOptions): Promise<void\> + +设置通è¯éŸ³é¢‘设备。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------------------ | ---- | ------------------ | +| device | [AudioDevice](#audiodevice8) | 是 | 音频设备。 | +| options | [AudioDeviceOptions](#audiodeviceoptions9) | å¦ | 音频设备å‚æ•°å‚数。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回设置结果。 | + +**示例:** + +```js +let audioDeviceOptions={ + bluetoothAddress: "IEEE 802-2014" +} +let promise = call.setAudioDevice(1, audioDeviceOptions); +promise.then(data => { + console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.joinConference<sup>8+</sup> + +joinConference(mainCallId: number, callNumberList: Array<string\>, callback: AsyncCallback<void\>): void + +åŠ å…¥ä¼šè®®ã€‚ä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ------------------------- | ---- | --------------- | +| mainCallId | number | 是 | 主通è¯Id。 | +| callNumberList | Array<string\> | 是 | 呼å«å·ç 列表。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.joinConference(1, "138XXXXXXXX", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.joinConference<sup>8+</sup> + +joinConference(mainCallId: number, callNumberList: Array<string\>): Promise<void\> + +åŠ å…¥ä¼šè®®ã€‚ä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | -------------- | ---- | --------------- | +| mainCallId | number | 是 | 主通è¯Id。 | +| callNumberList | Array<string\> | 是 | 呼å«å·ç 列表。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.joinConference(1, "138XXXXXXXX"); +promise.then(data => { + console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.updateImsCallMode<sup>8+</sup> + +updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback<void\>): void + +æ›´æ–°Ims呼å«æ¨¡å¼ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | -------------- | +| callId | number | 是 | 呼å«Id。 | +| mode | [ImsCallMode](#imscallmode8) | 是 | Ims呼å«æ¨¡å¼ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.updateImsCallMode(1, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.updateImsCallMode<sup>8+</sup> + +updateImsCallMode(callId: number, mode: ImsCallMode): Promise<void\> + +æ›´æ–°Ims呼å«æ¨¡å¼ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ---------------------------- | ---- | -------------- | +| callId | number | 是 | 呼å«Id。 | +| mode | [ImsCallMode](#imscallmode8) | 是 | Ims呼å«æ¨¡å¼ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.updateImsCallMode(1, 1); +promise.then(data => { + console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.enableImsSwitch<sup>8+</sup> + +enableImsSwitch(slotId: number, callback: AsyncCallback<void\>): void + +å¯ç”¨Ims开关。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.enableImsSwitch(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.enableImsSwitch<sup>8+</sup> + +enableImsSwitch(slotId: number): Promise<void\> + +å¯ç”¨Ims开关。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.enableImsSwitch(0); +promise.then(data => { + console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.disableImsSwitch<sup>8+</sup> + +disableImsSwitch(slotId: number, callback: AsyncCallback<void\>): void + +ç¦ç”¨Ims开关。使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +call.disableImsSwitch(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.disableImsSwitch<sup>8+</sup> + +disableImsSwitch(slotId: number): Promise<void\> + +ç¦ç”¨Ims开关。使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.disableImsSwitch(0); +promise.then(data => { + console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## call.isImsSwitchEnabled<sup>8+</sup> + +isImsSwitchEnabled(slotId: number, callback: AsyncCallback<boolean\>): void + +判æ–Ims开关是å¦å¯ç”¨ã€‚使用callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +```js +call.isImsSwitchEnabled(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## call.isImsSwitchEnabled<sup>8+</sup> + +isImsSwitchEnabled(slotId: number): Promise<boolean\> + +判æ–Ims开关是å¦å¯ç”¨ã€‚使用Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CallManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promiseå½¢å¼å¼‚æ¥è¿”回结果。 | + +**示例:** + +```js +let promise = call.isImsSwitchEnabled(0); +promise.then(data => { + console.log(`isImsSwitchEnabled success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isImsSwitchEnabled fail, promise: err->${JSON.stringify(err)}`); +}); +``` + ## DialOptions 拨打电è¯çš„å¯é€‰å‚数。 **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ------- | ---- | ------------------------------------------------------------ | -| extras | boolean | å¦ | æ ¹æ®extras的值判æ–是å¦ä¸ºè§†é¢‘通è¯ï¼Œé»˜è®¤ä¸ºè¯éŸ³é€šè¯ã€‚<br/>- true:视频通è¯ã€‚<br/>- false:è¯éŸ³é€šè¯ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ---------------------------------- | ---- | ------------------------------------------------------------ | +| extras | boolean | å¦ | æ ¹æ®extras的值判æ–是å¦ä¸ºè§†é¢‘通è¯ï¼Œé»˜è®¤ä¸ºè¯éŸ³é€šè¯ã€‚<br/>- true:视频通è¯ã€‚<br/>- false:è¯éŸ³é€šè¯ã€‚ | +| accountId | number | å¦ | å¸æˆ·Id。从API version 8开始支æŒã€‚æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| videoState | [VideoStateType](#videostatetype7) | å¦ | 视频状æ€ç±»åž‹ã€‚从API version 8开始支æŒã€‚æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| dialScene | [DialScene](#dialscene8) | å¦ | 拨å·åœºæ™¯ã€‚从API version 8开始支æŒã€‚æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| dialType | [DialType](#dialtype8) | å¦ | 拨å·ç±»åž‹ã€‚从API version 8开始支æŒã€‚æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | ## CallState @@ -555,4 +2781,396 @@ promise.then(data => { | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ----------- | ------ | ---- | ---------------------------------------------------------- | -| countryCode | string | å¦ | 国家ç ,支æŒæ‰€æœ‰å›½å®¶çš„国家ç ,如:CN(ä¸å›½ï¼‰ã€‚默认为:CN。 | \ No newline at end of file +| countryCode | string | å¦ | 国家ç ,支æŒæ‰€æœ‰å›½å®¶çš„国家ç ,如:CN(ä¸å›½ï¼‰ã€‚默认为:CN。 | + +## ImsCallMode<sup>8+</sup> + +IP多媒体系统调用模å¼ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ---------------------- | ---- | ------------------ | +| CALL_MODE_AUDIO_ONLY | 0 | ä»…é™éŸ³é¢‘å‘¼å« | +| CALL_MODE_SEND_ONLY | 1 | ä»…å‘é€å‘¼å« | +| CALL_MODE_RECEIVE_ONLY | 2 | ä»…æŽ¥æ”¶å‘¼å« | +| CALL_MODE_SEND_RECEIVE | 3 | å…许å‘é€å’ŒæŽ¥æ”¶å‘¼å« | +| CALL_MODE_VIDEO_PAUSED | 4 | æš‚åœè§†é¢‘å‘¼å« | + +## AudioDevice<sup>8+</sup> + +音频设备。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| -------------------- | ---- | ------------ | +| DEVICE_EARPIECE | 0 | 耳机设备 | +| DEVICE_SPEAKER | 1 | 扬声器设备 | +| DEVICE_WIRED_HEADSET | 2 | 有线耳机设备 | +| DEVICE_BLUETOOTH_SCO | 3 | è“牙SCO设备 | + +## CallRestrictionType<sup>8+</sup> + +呼å«é™åˆ¶ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| --------------------------------------------- | ---- | -------------------------- | +| RESTRICTION_TYPE_ALL_INCOMING | 0 | é™åˆ¶æ‰€æœ‰å‘¼å…¥ | +| RESTRICTION_TYPE_ALL_OUTGOING | 1 | é™åˆ¶æ‰€æœ‰å‘¼å‡º | +| RESTRICTION_TYPE_INTERNATIONAL | 2 | é™åˆ¶å›½é™…é€šè¯ | +| RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME | 3 | é™åˆ¶é™¤å½’å±žå›½ä»¥å¤–çš„å›½é™…é€šè¯ | +| RESTRICTION_TYPE_ROAMING_INCOMING | 4 | é™åˆ¶æ¼«æ¸¸å‘¼å…¥ | +| RESTRICTION_TYPE_ALL_CALLS | 5 | é™åˆ¶æ‰€æœ‰é€šè¯ | +| RESTRICTION_TYPE_OUTGOING_SERVICES | 6 | é™åˆ¶ä¼ 出业务 | +| RESTRICTION_TYPE_INCOMING_SERVICES | 7 | é™åˆ¶å‘¼å…¥ä¸šåŠ¡ | + +## CallTransferInfo<sup>8+</sup> + +呼å«è½¬ç§»ä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ---------------------------------------------------- | ---- | ---------------- | +| transferNum | string | 是 | è½¬ç§»ç¼–å· | +| type | [CallTransferType](#calltransfertype8) | 是 | 呼å«è½¬ç§»ç±»åž‹ | +| settingType | [CallTransferSettingType](#calltransfersettingtype8) | 是 | 设置呼å«è½¬ç§»ç±»åž‹ | + +## CallTransferType<sup>8+</sup> + +呼å«è½¬ç§»ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| --------------------------- | ---- | ------------ | +| TRANSFER_TYPE_UNCONDITIONAL | 0 | æ— æ¡ä»¶è½¬ç§» | +| TRANSFER_TYPE_BUSY | 1 | 忙线转移 | +| TRANSFER_TYPE_NO_REPLY | 2 | æ— å›žå¤è½¬ç§» | +| TRANSFER_TYPE_NOT_REACHABLE | 3 | æ— æ³•è®¿é—®è½¬ç§» | + +## CallTransferSettingType<sup>8+</sup> + +设置呼å«è½¬ç§»ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| -------------------------- | ---- | ------------ | +| CALL_TRANSFER_DISABLE | 0 | ç¦ç”¨å‘¼å«è½¬ç§» | +| CALL_TRANSFER_ENABLE | 1 | å¯ç”¨å‘¼å«è½¬ç§» | +| CALL_TRANSFER_REGISTRATION | 3 | 登记呼å«è½¬ç§» | +| CALL_TRANSFER_ERASURE | 4 | 消除呼å«è½¬ç§» | + +## CallAttributeOptions<sup>7+</sup> + +调用属性选项。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ---------------------------------------- | ---- | -------------- | +| accountNumber | string | 是 | å¸å·å·ç | +| speakerphoneOn | boolean | 是 | æ‰¬å£°å™¨æŽ¥é€šç”µè¯ | +| accountId | number | 是 | å¸æˆ·Id | +| videoState | [VideoStateType](#videostatetype7) | 是 | 视频状æ€ç±»åž‹ | +| startTime | number | 是 | 开始时间 | +| isEcc | boolean | 是 | 是å¦æ˜¯Ecc | +| callType | [CallType](#calltype7) | 是 | 通è¯ç±»åž‹ | +| callId | number | 是 | 呼å«Id | +| callState | [DetailedCallState](#detailedcallstate7) | 是 | 详细呼å«çŠ¶æ€ | +| conferenceState | [ConferenceState](#conferencestate7) | 是 | ä¼šè®®çŠ¶æ€ | + +## ConferenceState<sup>7+</sup> + +会议状æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ---------------------------- | ---- | -------------- | +| TEL_CONFERENCE_IDLE | 0 | 电è¯ä¼šè®®ç©ºé—² | +| TEL_CONFERENCE_ACTIVE | 1 | 电è¯ä¼šè®®æ¿€æ´» | +| TEL_CONFERENCE_DISCONNECTING | 2 | 电è¯ä¼šè®®æ–å¼€ | +| TEL_CONFERENCE_DISCONNECTED | 3 | 电è¯ä¼šè®®å·²æ–å¼€ | + +## CallType<sup>7+</sup> + +通è¯ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ------------- | ---- | ------------ | +| TYPE_CS | 0 | CSé€šè¯ | +| TYPE_IMS | 1 | IMSé€šè¯ | +| TYPE_OTT | 2 | OTTé€šè¯ | +| TYPE_ERR_CALL | 3 | å…¶ä»–ç±»åž‹é€šè¯ | + +## VideoStateType<sup>7+</sup> + +视频状æ€ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ---------- | ---- | -------- | +| TYPE_VOICE | 0 | è¯éŸ³çŠ¶æ€ | +| TYPE_VIDEO | 1 | è§†é¢‘çŠ¶æ€ | + +## DetailedCallState<sup>7+</sup> + +详细的呼å«çŠ¶æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ------------------------- | ---- | -------------- | +| CALL_STATUS_ACTIVE | 0 | 激活呼å«çŠ¶æ€ | +| CALL_STATUS_HOLDING | 1 | ä¿æŒå‘¼å«çŠ¶æ€ | +| CALL_STATUS_DIALING | 2 | 呼å«çŠ¶æ€æ‹¨å· | +| CALL_STATUS_ALERTING | 3 | 电è¯æŠ¥è¦çŠ¶æ€ | +| CALL_STATUS_INCOMING | 4 | 呼å«ä¼ å…¥çŠ¶æ€ | +| CALL_STATUS_WAITING | 5 | 呼å«ç‰å¾…çŠ¶æ€ | +| CALL_STATUS_DISCONNECTED | 6 | 呼å«çŠ¶æ€å·²æ–å¼€ | +| CALL_STATUS_DISCONNECTING | 7 | 呼å«çŠ¶æ€æ–å¼€ | +| CALL_STATUS_IDLE | 8 | 呼å«çŠ¶æ€ç©ºé—² | + +## CallRestrictionInfo<sup>8+</sup> + +呼å«é™åˆ¶ä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------------------- | ---- | ------------ | +| type | [CallRestrictionType](#callrestrictiontype8) | 是 | 呼å«é™åˆ¶ç±»åž‹ | +| password | string | 是 | 密ç | +| mode | [CallRestrictionMode](#callrestrictionmode8) | 是 | 呼å«é™åˆ¶æ¨¡å¼ | + +## CallRestrictionMode<sup>8+</sup> + +呼å«é™åˆ¶æ¨¡å¼ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ----------------------------- | ---- | ------------ | +| RESTRICTION_MODE_DEACTIVATION | 0 | é™åˆ¶æ¨¡å¼åœç”¨ | +| RESTRICTION_MODE_ACTIVATION | 1 | é™åˆ¶æ¨¡å¼æ¿€æ´» | + +## CallEventOptions<sup>8+</sup> + +呼å«äº‹ä»¶çš„å¯é€‰å‚数。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------------------ | ---- | -------------- | +| eventId | [CallAbilityEventId](#callabilityeventid8) | 是 | 呼å«èƒ½åŠ›äº‹ä»¶Id | + +## CallAbilityEventId<sup>8+</sup> + +呼å«èƒ½åŠ›äº‹ä»¶Id。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ------------------------ | ---- | --------------- | +| EVENT_DIAL_NO_CARRIER | 1 | 拨å·æ— 载波事件 | +| EVENT_INVALID_FDN_NUMBER | 2 | æ— æ•ˆçš„FDNå·äº‹ä»¶ | + +## DialScene<sup>8+</sup> + +拨å·åœºæ™¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| --------------- | ---- | ------------ | +| CALL_NORMAL | 0 | 呼å«æ£å¸¸ | +| CALL_PRIVILEGED | 1 | 呼å«ç‰¹æƒ | +| CALL_EMERGENCY | 2 | æ‹¨æ‰“ç´§æ€¥ç”µè¯ | + +## DialType<sup>8+</sup> + +拨å·ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| -------------------- | ---- | ---------------- | +| DIAL_CARRIER_TYPE | 0 | 载波拨å·ç±»åž‹ | +| DIAL_VOICE_MAIL_TYPE | 1 | è¯éŸ³é‚®ä»¶æ‹¨å·ç±»åž‹ | +| DIAL_OTT_TYPE | 2 | OTT拨å·ç±»åž‹ | + +## RejectMessageOptions<sup>7+</sup> + +æ‹’ç»æ¶ˆæ¯å¯é€‰å‚数。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ------ | ---- | -------- | +| messageContent | string | 是 | 消æ¯å†…容 | + +## CallTransferResult<sup>8+</sup> + +呼å«è½¬ç§»ç»“果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ---------------------------------- | ---- | -------- | +| status | [TransferStatus](#transferstatus8) | 是 | è½¬ç§»çŠ¶æ€ | +| number | string | 是 | å·ç | + +## CallWaitingStatus<sup>7+</sup> + +呼å«ç‰å¾…状æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| -------------------- | ---- | ------------ | +| CALL_WAITING_DISABLE | 0 | ç¦ç”¨å‘¼å«ç‰å¾… | +| CALL_WAITING_ENABLE | 1 | å¯ç”¨å‘¼å«ç‰å¾… | + +## RestrictionStatus<sup>8+</sup> + +é™åˆ¶çŠ¶æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ------------------- | ---- | -------- | +| RESTRICTION_DISABLE | 0 | ç¦ç”¨é™åˆ¶ | +| RESTRICTION_ENABLE | 1 | å¯ç”¨é™åˆ¶ | + +## TransferStatus<sup>8+</sup> + +转移状æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ---------------- | ---- | -------- | +| TRANSFER_DISABLE | 0 | ç¦ç”¨è½¬ç§» | +| TRANSFER_ENABLE | 1 | å¯ç”¨è½¬ç§» | + +## DisconnectedDetails<sup>8+</sup> + +æ–开连接的详细信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| --------------------------- | ---- | ---------------------- | +| UNASSIGNED_NUMBER | 1 | 未分é…çš„å·ç (空å·) | +| NO_ROUTE_TO_DESTINATION | 3 | æ— è‡³ç›®çš„åœ°çš„è·¯ç”± | +| CHANNEL_UNACCEPTABLE | 6 | ä¸å¯æŽ¥å—的通路 | +| OPERATOR_DETERMINED_BARRING | 8 | è¿è¥å•†é—é” | +| NORMAL_CALL_CLEARING | 16 | 清除æ£å¸¸å‘¼å« | +| USER_BUSY | 17 | 用户忙 | +| NO_USER_RESPONDING | 18 | æ— ç”¨æˆ·å“应 | +| USER_ALERTING_NO_ANSWER | 19 | 已有用户æé†’ï¼Œä½†æ— åº”ç” | +| CALL_REJECTED | 21 | 呼å«æ‹’ç» | +| NUMBER_CHANGED | 22 | å·ç æ”¹å˜ | +| DESTINATION_OUT_OF_ORDER | 27 | 终点故障 | +| INVALID_NUMBER_FORMAT | 28 | æ— æ•ˆå·ç æ ¼å¼ | +| NETWORK_OUT_OF_ORDER | 38 | 网络故障 | +| TEMPORARY_FAILURE | 41 | 临时故障 | +| INVALID_PARAMETER | 1025 | æ— æ•ˆå‚æ•° | +| SIM_NOT_EXIT | 1026 | SIMå¡æœªé€€å‡º | +| SIM_PIN_NEED | 1027 | 需è¦SIMå¡PINç | +| CALL_NOT_ALLOW | 1029 | ä¸å…è®¸å‘¼å« | +| SIM_INVALID | 1045 | SIMå¡æ— 效 | +| UNKNOWN | 1279 | æœªçŸ¥åŽŸå› | + +## MmiCodeResults<sup>9+</sup> + +MMIç 结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | -------------------------------- | ---- | --------------- | +| result | [MmiCodeResult](#mmicoderesult9) | 是 | MMIç 结果 | +| message | string | 是 | MMIç æ¶ˆæ¯ | + +## MmiCodeResult<sup>9+</sup> + +MMIç 结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 值 | 说明 | +| ---------------- | ---- | ------------- | +| MMI_CODE_SUCCESS | 0 | 表示MMIç æˆåŠŸ | +| MMI_CODE_FAILED | 1 | 表示MMIç 失败 | + +## AudioDeviceOptions<sup>9+</sup> + +音频设备选项。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CallManager。 + +| å称 | 类型 | å¿…å¡« | 说明 | +| ---------------- | ------ | ---- | -------- | +| bluetoothAddress | string | å¦ | è“ç‰™åœ°å€ | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index e3124823564897b99dcfe5ff043c215f26b74338..610a016686600e2073147458dda2598c5e556fa6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -20,9 +20,9 @@ getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): voi **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------------------- | ---- | ---------------------------------- | -| context | Context | 是 | 应用上下文。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- | ---- | ---------------------------- | +| context | Context | 是 | 应用上下文。 | | callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获å–相机管ç†å™¨å®žä¾‹ã€‚ | **示例:** @@ -53,8 +53,8 @@ getCameraManager(context: Context): Promise<CameraManager\> **返回值:** -| 类型 | 说明 | -| ----------------------------------------- | ----------------------------------------- | +| 类型 | 说明 | +| ----------------------------------------- | ----------------------------------- | | Promise<[CameraManager](#cameramanager)\> | 使用Promiseçš„æ–¹å¼èŽ·å–一个相机管ç†å™¨å®žä¾‹ã€‚ | **示例:** @@ -73,84 +73,78 @@ camera.getCameraManager(context).then((cameraManager) => { | å称 | 值 | 说明 | | ------------------------- | ---- | ------------ | -| CAMERA_STATUS_APPEAR | 0 | 相机å˜åœ¨ã€‚ | -| CAMERA_STATUS_DISAPPEAR | 1 | 相机ä¸å˜åœ¨ã€‚ | -| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。 | -| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。 | +| CAMERA_STATUS_APPEAR | 0 | 新的相机出现。 | +| CAMERA_STATUS_DISAPPEAR | 1 | 相机被移除。 | +| CAMERA_STATUS_AVAILABLE | 2 | 相机å¯ç”¨ã€‚ | +| CAMERA_STATUS_UNAVAILABLE | 3 | 相机ä¸å¯ç”¨ã€‚ | +## Profile -## CameraPosition - -枚举,相机方å‘。 +相机é…置信æ¯é¡¹ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| --------------------------- | ---- | ---------------- | -| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方å‘相机。 | -| CAMERA_POSITION_BACK | 1 | åŽç½®ç›¸æœºã€‚ | -| CAMERA_POSITION_FRONT | 2 | å‰ç½®ç›¸æœºã€‚ | +| å称 | 类型 | åªè¯» | 说明 | +| -------- | ----------------------------- |---- | ------------- | +| format | [CameraFormat](#cameraformat) | 是 | è¾“å‡ºæ ¼å¼ã€‚ | +| size | [Size](#size) | 是 | 分辨率。 | -## CameraType +## FrameRateRange -枚举,相机类型。 + 帧率范围。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ----------------------- | ---- | ---------------- | -| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。 | -| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | -| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。 | -| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | -| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。 | - +| å称 | 类型 | åªè¯» | 说明 | +| ------------------------- | ------ | ---- | ------------------- | +| min | number | 是 | 最å°é€ŸçŽ‡ï¼Œå•ä½fps | +| max | number | 是 | 最大速率,å•ä½fps | -## ConnectionType +## VideoProfile -枚举,相机连接类型。 +视频é…置信æ¯é¡¹ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ---------------------------- | ---- | ------------- | -| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。 | -| CAMERA_CONNECTION_REMOTE | 2 | 分布å¼ç›¸æœºã€‚ | +| å称 | 类型 | åªè¯» | 说明 | +| ------------------------- | ----------------------------------------- | --- |------------ | +| frameRateRanges | [FrameRateRange](#frameraterange) | 是 | 帧率。 | -## Size +## CameraOutputCapability -用于表示相机预览ã€ç…§ç‰‡ã€è§†é¢‘支æŒçš„尺寸大å°ã€‚ +相机输出能力项。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ------ | ------ | ---- | ---- | ------------ | -| height | string | 是 | 是 | 图åƒçš„高度。 | -| width | number | 是 | 是 | 图åƒçš„宽度。 | +| å称 | 类型 | åªè¯» | 说明 | +| ----------------------------- | -------------------------------------------------- | --- |------------------- | +| previewProfiles | Array<[Profile](#profile)\> | 是 | 支æŒçš„预览é…置信æ¯ã€‚ | +| photoProfiles | Array<[Profile](#profile)\> | 是 | 支æŒçš„æ‹ç…§é…置信æ¯ã€‚ | +| videoProfiles | Array<[VideoProfile](#videoprofile)\> | 是 | 支æŒçš„录åƒé…置信æ¯ã€‚ | +| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | 支æŒçš„metadataæµç±»åž‹ä¿¡æ¯ã€‚| ## CameraManager 相机管ç†å™¨ç±»ï¼Œä½¿ç”¨å‰éœ€è¦é€šè¿‡getCameraManager获å–相机管ç†å®žä¾‹ã€‚ -### getCameras +### getSupportedCameras -getCameras(callback: AsyncCallback<Array<Camera\>\>): void +getSupportedCameras(callback: AsyncCallback<Array<CameraDevice\>\>): void -异æ¥èŽ·å–设备支æŒçš„相机列表,通过注册回调函数获å–结果。 +获å–支æŒæŒ‡å®šçš„相机设备对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback<Array<[Camera](#camera)\>\> | 是 | 使用callbackæ–¹å¼èŽ·å–支æŒçš„相机列表。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback<Array<[CameraDevice](#cameradevice)\>\> | 是 | 使用callbackæ–¹å¼èŽ·å–支æŒçš„相机列表。 | **示例:** ```js -cameraManager.getCameras((err, cameras) => { +cameraManager.getSupportedCameras((err, cameras) => { if (err) { console.error('Failed to get the cameras. ${err.message}'); return; @@ -159,866 +153,1025 @@ cameraManager.getCameras((err, cameras) => { }) ``` -### getCameras +### getSupportedCameras -getCameras(): Promise<Array<Camera\>\> +getSupportedCameras(): Promise<Array<CameraDevice\>\> -异æ¥èŽ·å–设备支æŒçš„相机列表,通过Promise获å–结果。 +获å–支æŒæŒ‡å®šçš„相机设备对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ----------------------------------- | ----------------------------- | -| Promise<Array<[Camera](#camera)\>\> | 使用promise获å–支æŒç›¸æœºåˆ—表。 | +| 类型 | 说明 | +| ----------------------------------------------- | ------------------------- | +| Promise<Array<[CameraDevice](#cameradevice)\>\> | 使用promise获å–支æŒç›¸æœºåˆ—表。 | **示例:** ```js -cameraManager.getCameras().then((cameraArray) => { +cameraManager.getSupportedCameras().then((cameraArray) => { console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); }) ``` -### createCameraInput - -createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void +### getSupportedOutputCapability -使用相机ID异æ¥åˆ›å»ºCameraInput实例,通过注册回调函数获å–结果。 +getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback<CameraOutputCapability\>): void -**需è¦æƒé™ï¼š** ohos.permission.CAMERA +查询相机设备在模å¼ä¸‹æ”¯æŒçš„输出能力,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| cameraId | string | 是 | 指定相机ID。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获å–CameraInput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------------------------- | -- | -------------------------- | +| camera | [CameraDevice](#cameraDevice) | 是 | CameraDevice对象。 | +| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | 是 | 使用callbackæ–¹å¼èŽ·å–相机输出能力。 | **示例:** ```js -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { +cameraManager.getSupportedOutputCapability(cameraDevice, (err, cameras) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error('Failed to get the cameras. ${err.message}'); return; } - console.log('Callback returned with the CameraInput instance.'); + console.log('Callback returned with an array of supported outputCapability: ' + cameras.length); }) ``` -### createCameraInput - -createCameraInput(cameraId: string): Promise<CameraInput\> +### getSupportedOutputCapability -使用相机ID异æ¥åˆ›å»ºCameraInput实例,通过Promise获å–结果。 +getSupportedOutputCapability(camera:CameraDevice): Promise<CameraOutputCapability\> -**需è¦æƒé™ï¼š** ohos.permission.CAMERA +查询相机设备在模å¼ä¸‹æ”¯æŒçš„输出能力,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------ | ---- | ------------ | -| cameraId | string | 是 | 指定相机ID。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------- | ---- | ---------- | +| camera | [CameraDevice](#cameraDevice) | 是 | CameraDevice对象。| **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CameraInput的实例。 | +| 类型 | 说明 | +| -------------------------------------------------------------- | ----------------------------- | +| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回相机输出能力。 | + **示例:** ```js -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); +cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { + console.log('Promise returned with an array of supported outputCapability: ' + cameraArray.length); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput\>): void +### isCameraMuted -使用相机ä½ç½®å’Œç›¸æœºç±»åž‹å¼‚æ¥åˆ›å»ºCameraInput实例,通过注册回调函数获å–结果。 +isCameraMuted(callback: AsyncCallback<boolean\>): void -**需è¦æƒé™ï¼š** ohos.permission.CAMERA +查询相机是å¦è¢«ç¦ç”¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获å–CameraInput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,回调返回trueå³ç›¸æœºè¢«ç¦ç”¨ï¼Œå¦åˆ™ä¸ºfalse。 | **示例:** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { +cameraManager.isCameraMuted((err, status) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error('Failed to get the cameraMuted status. ${err.message}'); return; } - console.log('Callback returned with the CameraInput instance'); + console.log('Callback returned with cameraMuted status'); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInput\> +### isCameraMuted -使用相机ä½ç½®å’Œç›¸æœºç±»åž‹å¼‚æ¥åˆ›å»ºCameraInput实例,通过Promise获å–结果。 +isCameraMuted(): Promise<boolean\> -**需è¦æƒé™ï¼š** ohos.permission.CAMERA +查询相机是å¦è¢«ç¦ç”¨ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------------- | ---- | ---------- | -| position | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | -| type | [CameraType](#cameratype) | 是 | 相机类型。 | - **返回值:** -| 类型 | 说明 | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CameraInput的实例。 | +| 类型 | 说明 | +| ------------------------------------ | --------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回相机是å¦ç¦ç”¨çš„结果。 | + **示例:** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); +cameraManager.isCameraMuted().then((status) => { + console.log('Promise returned with the status whether camera is muted.'); }) ``` -### on('cameraStatus') +### isCameraMuteSupported -on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void +isCameraMuteSupported(callback: AsyncCallback<boolean\>): void + +查询是å¦æ”¯æŒç›¸æœºç¦ç”¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 -监å¬ç›¸æœºçš„状æ€å˜åŒ–,通过注册回调函数获å–相机的状æ€å˜åŒ–。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'cameraStatus',å³ç›¸æœºçŠ¶æ€å˜åŒ–事件。 | -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获å–相机状æ€å˜åŒ–ä¿¡æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<boolean\> | 是 | 使用callbackæ–¹å¼èŽ·å–是å¦æ”¯æŒç›¸æœºç¦ç”¨çš„结果。 | **示例:** ```js -cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { +cameraManager.isCameraMuteSupported((err, status) => { if (err) { - console.error('Failed to get cameraStatus callback. ${err.message}'); + console.error('Failed to get the cameraMuteSupported. ${err.message}'); return; } - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); + console.log('Callback returned with the status whether cameraMuteSupported.'); }) ``` -## Camera +### isCameraMuteSupported -调用[camera.getCameraManager](#cameragetcameramanager)åŽï¼Œå°†è¿”回Camera实例,包括相机IDã€ä½ç½®ã€ç±»åž‹ã€è¿žæŽ¥ç±»åž‹ç‰ç›¸æœºç›¸å…³çš„元数æ®ã€‚ +isCameraMuteSupported(): Promise<boolean\> -**系统能力:** SystemCapability.Multimedia.Camera.Core。 +查询是å¦æ”¯æŒç›¸æœºç¦ç”¨ï¼Œé€šè¿‡Promise获å–结果。 -| å称 | 类型 | åªè¯» | 说明 | -| -------------- | --------------------------------- | ---- | -------------- | -| cameraId | string | 是 | 相机ID。 | -| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | -| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | -| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。 | +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**示例:** +**需è¦æƒé™ï¼š** ohos.permission.CAMERA -```js -async function getCameraInfo("cameraId") { - var cameraManager = await camera.getCameraManager(); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var connectionType = cameraObj.connectionType; -} -``` +**系统能力:** SystemCapability.Multimedia.Camera.Core -## CameraStatusInfo +**返回值:** -相机管ç†å™¨å›žè°ƒè¿”回的接å£å®žä¾‹ï¼Œè¡¨ç¤ºç›¸æœºçŠ¶æ€ä¿¡æ¯ã€‚ +| 类型 | 说明 | +| --------------------- | ----------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回是å¦æ”¯æŒç›¸æœºç¦ç”¨çš„结果。 | -**系统能力:** SystemCapability.Multimedia.Camera.Core。 -| å称 | 类型 | 说明 | -| ------ | ----------------------------- | ---------- | -| camera | [Camera](#camera) | 相机信æ¯ã€‚ | -| status | [CameraStatus](#camerastatus) | 相机状æ€ã€‚ | +**示例:** +```js +cameraManager.isCameraMuteSupported().then((status) => { + console.log('Promise returned with the status whether cameraMuteSupported.'); +}) +``` -## CameraInput +### muteCamera -相机输入类。在使用该类的方法å‰ï¼Œéœ€è¦å…ˆæž„建一个CameraInput实例。 +muteCamera(mute:boolean, callback: AsyncCallback<void\>): void -### getCameraId +ç¦ç”¨ç›¸æœºï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 -getCameraId(callback: AsyncCallback<string\>\): void +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -异æ¥èŽ·å–该CameraInput实例的相机ID,通过注册回调函数获å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback<string\> | 是 | 回调函数,用于获å–相机ID。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------ | +| mute | boolean | 是 | 是å¦ç¦ç”¨ç›¸æœºã€‚ | +| callback | AsyncCallback<void\> | 是 | 使用callbackæ–¹å¼èŽ·å–相机ç¦ç”¨çš„结果。 | **示例:** ```js -cameraInput.getCameraId((err, cameraId) => { +cameraManager.muteCamera(isMuted, (err) => { if (err) { - console.error('Failed to get the camera ID. ${err.message}'); + console.error('Failed to mute the camera. ${err.message}'); return; } - console.log('Callback returned with the camera ID: ' + cameraId); + console.log('Callback returned with the muteCamera.'); }) ``` -### getCameraId +### muteCamera + +muteCamera(mute:boolean): Promise<void\> + +ç¦ç”¨ç›¸æœºï¼Œé€šè¿‡Promise获å–结果。 -getCameraId(): Promise<string\> +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -异æ¥èŽ·å–该CameraInput实例的相机ID,通过Promise获å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | ------------ | +| mute | boolean | 是 | 是å¦ç¦ç”¨ç›¸æœºã€‚ | + **返回值:** -| 类型 | 说明 | -| ---------------- | ----------------------------- | -| Promise<string\> | 使用Promiseçš„æ–¹å¼èŽ·å–相机ID。 | +| 类型 | 说明 | +| ----------------------------------- | ----------------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回是å¦ç¦ç”¨ç›¸æœºçš„结果。 | + **示例:** -```js -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); +```js +cameraManager.muteCamera(isMuted).then(() => { + console.log('Promise returned muteCamera.'); }) ``` +### createCameraInput -### hasFlash +createCameraInput(camera: CameraDevice, callback: AsyncCallback<CameraInput\>): void -hasFlash(callback: AsyncCallback<boolean\>): void +使用CameraDevice对象异æ¥åˆ›å»ºCameraInput实例,通过注册回调函数获å–结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -判æ–设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示设备支æŒé—ªå…‰ç¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | --------------------------------- | +| camera | [CameraDevice](#cameraDevice) | 是 | CameraDevice对象。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获å–CameraInput实例。 | **示例:** ```js -cameraInput.hasFlash((err, status) => { +cameraManager.createCameraInput(camera, (err, cameraInput) => { if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); + console.error('Failed to create the CameraInput instance. ${err.message}'); return; } - console.log('Callback returned with flash light support status: ' + status); + console.log('Callback returned with the CameraInput instance.'); }) ``` -### hasFlash +### createCameraInput -hasFlash(): Promise<boolean\> +createCameraInput(camera: CameraDevice): Promise<CameraInput\> + +使用CameraDevice对象异æ¥åˆ›å»ºCameraInput实例,通过Promise获å–结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -判æ–设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œé€šè¿‡Promise获å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------- | ---- | ---------- | +| camera | [CameraDevice](#cameraDevice) | 是 | CameraDevice对象。 | + **返回值:** -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------- | -| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒé—ªå…‰ç¯ã€‚ | +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------ | +| Promise<[CameraInput](#camerainput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CameraInput的实例。 | **示例:** ```js -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); +cameraManager.createCameraInput(camera).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` -### isFlashModeSupported +### createCameraInput -isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): void +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback<CameraInput\>): void + +æ ¹æ®ç›¸æœºä½ç½®å’Œç±»åž‹åˆ›å»ºCameraInput实例,通过注册回调函数获å–结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -判æ–设备是å¦æ”¯æŒæŒ‡å®šé—ªå…‰ç¯æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ----------------------- | ---- | ---------------------------------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | -| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支æŒè¯¥é—ªå…‰ç¯æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | --------------------------------- | +| position | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | +| type | [CameraType](#cameratype) | 是 | 相机类型。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获å–CameraInput实例。 | **示例:** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); + console.error('Failed to create the CameraInput instance. ${err.message}'); return; } - console.log('Callback returned with the flash mode support status: ' + status); + console.log('Callback returned with the CameraInput instance'); }) ``` -### isFlashModeSupported +### createCameraInput -isFlashModeSupported(flashMode: FlashMode): Promise<boolean\> +createCameraInput(position: CameraPosition, type:CameraType ): Promise<CameraInput\> + +æ ¹æ®ç›¸æœºä½ç½®å’Œç±»åž‹åˆ›å»ºCameraInput实例,通过Promise获å–结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -判æ–设备是å¦æ”¯æŒæŒ‡å®šé—ªå…‰ç¯æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------- | ---- | ------------ | +| position | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | +| type | [CameraType](#cameratype) | 是 | 相机类型。 | **返回值:** -| 类型 | 说明 | -| ----------------- | ------------------------------------------------------------ | -| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒè¯¥é—ªå…‰ç¯æ¨¡å¼ã€‚ | +| 类型 | 说明 | +| ------------------------------------- | ------------------------------------ | +| Promise<[CameraInput](#camerainput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CameraInput的实例。 | **示例:** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { - console.log('Promise returned with flash mode support status.' + status); +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` -### setFlashMode - -setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void - -设置闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +### createPreviewOutput -进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥ï¼š +createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void -1. 设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œå¯ä½¿ç”¨æ–¹æ³•[hasFlash](#hasflash)。 -2. 设备是å¦æ”¯æŒæŒ‡å®šçš„闪光ç¯æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFlashModeSupported](#isflashmodesupported)。 +创建预览输出对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ----------------------- | ---- | ------------------------ | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„预览é…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获å–çš„SurfaceID。| +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获å–PreviewOutput实例。| **示例:** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { +cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => { if (err) { - console.error('Failed to set the flash mode ${err.message}'); + console.error('Failed to gcreate previewOutput. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setFlashMode.'); + console.log('Callback returned with previewOutput created.'); }) ``` -### setFlashMode - -setFlashMode(flashMode: FlashMode): Promise<void\> - -设置闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +### createPreviewOutput -进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥ï¼š +createPreviewOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\> -1. 设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œå¯ä½¿ç”¨æ–¹æ³•[hasFlash](#hasflash)。 -2. 设备是å¦æ”¯æŒæŒ‡å®šçš„闪光ç¯æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFlashModeSupported](#isflashmodesupported)。 +创建预览输出对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------| ---- | ----------------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„预览é…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)或者[ImageReceiver](js-apis-image.md#imagereceiver9)组件获å–çš„SurfaceID。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–PreviewOutput的实例。 | **示例:** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); +cameraManager.createPreviewOutput(profile, survaceId).then((previewoutput) => { + console.log('Promise returned with previewOutput created.'); }) ``` -### getFlashMode +### createDeferredPreviewOutput -getFlashMode(callback: AsyncCallback<FlashMode\>): void +createDeferredPreviewOutput(profile: Profile, callback: AsyncCallback<PreviewOutput\>): void -获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +尚未获å–surfaceID时创建预览输出对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- | ---- | --------------------------------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„预览é…置信æ¯ã€‚ | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获å–PreviewOutput实例。 | **示例:** ```js -cameraInput.getFlashMode((err, flashMode) => { +cameraManager.createDeferredPreviewOutput(profile, (err, previewoutput) => { if (err) { - console.error('Failed to get the flash mode ${err.message}'); + console.error('Failed to create deferredPreviewOutput. ${err.message}'); return; } - console.log('Callback returned with current flash mode: ' + flashMode); + console.log('Callback returned with deferredPreviewOutput created.'); }) ``` -### getFlashMode +### createDeferredPreviewOutput -getFlashMode(): Promise<FlashMode\> +createDeferredPreviewOutput(profile: Profile): Promise<PreviewOutput\> -获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +尚未获å–surfaceID时创建预览输出对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------| ---- | ---------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„预览é…置信æ¯ã€‚ | + **返回值:** -| 类型 | 说明 | -| --------------------------------- | --------------------------------------- | -| Promise<[FlashMode](#flashmode)\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰çš„闪光ç¯æ¨¡å¼ã€‚ | +| 类型 | 说明 | +| ----------------------------------------- | --------------------------------------- | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–PreviewOutput的实例。 | **示例:** ```js -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); +cameraManager.createDeferredPreviewOutput(profile).then((previewoutput) => { + console.log('Promise returned with DefeerredPreviewOutput created.'); }) ``` -### isFocusModeSupported +### createPhotoOutput -isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void +createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void -判æ–设备是å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +创建æ‹ç…§è¾“出对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | -| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支æŒè¯¥ç„¦è·æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„æ‹ç…§é…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获å–çš„SurfaceID。| +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获å–PhotoOutput实例。 | **示例:** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { +cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => { if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); + console.error('Failed to create photoOutput. ${err.message}'); return; } - console.log('Callback returned with the focus mode support status: ' + status); + console.log('Callback returned with photoOutput created.'); }) ``` -### isFocusModeSupported +### createPhotoOutput -isFocusModeSupported(afMode: FocusMode): Promise<boolean\> +createPhotoOutput(profile: Profile, surfaceId: string): Promise<PreviewOutput\> -判æ–设备是å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +创建æ‹ç…§è¾“出对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------| ---- | ----------- | +| profile | [Profile](#profile) | 是 | 支æŒçš„æ‹ç…§é…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获å–çš„SurfaceID。| **返回值:** -| 类型 | 说明 | -| ----------------- | ----------------------------------------------------------- | -| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒè¯¥ç„¦è·æ¨¡å¼ã€‚ | +| 类型 | 说明 | +| ------------------------------------- | -------------------------------------- | +| Promise<[PhotoOutput](#photooutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–PhotoOutput的实例。 | **示例:** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { - console.log('Promise returned with focus mode support status.' + status); +cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => { + console.log('Promise returned with photoOutput created.'); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void +### createVideoOutput -设置焦è·æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback<VideoOutput\>): void -进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥è®¾å¤‡æ˜¯å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFocusModeSupported](#isfocusmodesupported)。 +创建录åƒè¾“出对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------- | ---- | ------------------------ | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | ------------------------------ | +| profile | [VideoProfile](#videoprofile) | 是 | 支æŒçš„录åƒé…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获å–çš„SurfaceID。| +| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获å–VideoOutput实例。 | **示例:** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { +cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => { if (err) { - console.error('Failed to set the focus mode ${err.message}'); + console.error('Failed to create videoOutput. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setFocusMode.'); + console.log('Callback returned with an array of supported outputCapability: ' + cameras.length); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode): Promise<void\> +### createVideoOutput -设置焦è·æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +createVideoOutput(profile: VideoProfile, surfaceId: string): Promise<VideoOutput\> -进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥è®¾å¤‡æ˜¯å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFocusModeSupported](#isfocusmodesupported)。 +创建录åƒè¾“出对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------| ---- | ---------- | +| profile | [VideoProfile](#videoprofile) | 是 | 支æŒçš„录åƒé…置信æ¯ã€‚ | +| surfaceId| string | 是 | 从[VideoRecorder](js-apis-media.md#videorecorder9)获å–çš„SurfaceID。| **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| ------------------------------------- | -------------------------------------- | +| Promise<[VideoOutput](#videooutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–videoOutput的实例。 | **示例:** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); +cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => { + console.log('Promise returned with videoOutput created.'); }) ``` -### getFocusMode +### createMetadataOutput -getFocusMode(callback: AsyncCallback<FocusMode\>): void +createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType\>, callback: AsyncCallback<MetadataOutput\>): void -获å–当å‰è®¾å¤‡çš„焦è·æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +创建metadataæµè¾“出对象,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获å–当å‰è®¾å¤‡çš„焦è·æ¨¡å¼ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------------------- | -------------------------------------------------- | --- | ---------------------------- | +| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadataæµç±»åž‹ã€‚ | +| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | 是 | 回调函数,用于获å–MetadataOutput实例。 | **示例:** ```js -cameraInput.getFocusMode((err, afMode) => { +cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => { if (err) { - console.error('Failed to get the focus mode ${err.message}'); + console.error('Failed to create metadataOutput. ${err.message}'); return; } - console.log('Callback returned with current focus mode: ' + afMode); + console.log('Callback returned with metadataOutput created.'); }) ``` -### getFocusMode +### createMetadataOutput -getFocusMode(): Promise<FocusMode\> +createMetadataOutput(metadataObjectTypes: Array<MetadataObjectType\>): Promise<MetadataOutput> -获å–当å‰è®¾å¤‡çš„焦è·æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 +创建metadataæµè¾“出对象,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------------------- | -------------------------------------------------- | --- | -------------- | +| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | 是 | metadataæµç±»åž‹ã€‚ | + **返回值:** -| 类型 | 说明 | -| ------------------- | ------------------------------------- | -| Promise<FocusMode\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰çš„焦è·æ¨¡å¼ã€‚ | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------------- | +| Promise<[MetadataOutput](#metadataoutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–MetadataOutput的实例。 | **示例:** ```js -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); +cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataoutput) => { + console.log('Promise returned with metadataOutput created.'); }) ``` -### getZoomRatioRange +### createCaptureSession -getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void +createCaptureSession(callback: AsyncCallback<CaptureSession\>): void -获å–å¯å˜ç„¦è·æ¯”范围,通过注册回调函数获å–结果。 +创建CaptureSession实例,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------ | ---- | ------------------------ | -| callback | AsyncCallback<Array<number\>\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------------------- | ----------------------------------------- | ----------- | ---------------------------- | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获å–æ‹ç…§ä¼šè¯å®žä¾‹ã€‚ | **示例:** ```js -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { +cameraManager.createCaptureSession((err, capturesession) => { if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); + console.error('Failed to create captureSession. ${err.message}'); return; } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); + console.log('Callback returned with captureSession created.'); }) ``` -### getZoomRatioRange +### createCaptureSession -getZoomRatioRange\(\): Promise<Array<number\>\> +createCaptureSession(): Promise<CaptureSession\> -获å–å¯å˜ç„¦è·æ¯”范围,通过Promise获å–结果。 +创建CaptureSession实例,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ------------------------ | ------------------------------------------- | -| Promise<Array<number\>\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰çš„å¯å˜ç„¦è·æ¯”范围。 | +| 类型 | 说明 | +| ------------------------------------------- | ---------------------------------------- | +| Promise<[CaptureSession](#capturesession)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CaptureSession的实例。 | **示例:** ```js -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); +cameraManager.createCaptureSession().then((capturesession) => { + console.log('Promise returned with captureSession created.'); }) ``` -### setZoomRatio +### on('cameraStatus') -setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void +on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void -设置å¯å˜ç„¦è·æ¯”,通过注册回调函数获å–结果。 +镜头状æ€å›žè°ƒï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–相机的状æ€å˜åŒ–。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | -------------------- | ---- | ------------------------ | -| zoomRatio | number | 是 | å¯å˜ç„¦è·æ¯”。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------- | ---- | --------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'cameraStatus',å³é•œå¤´çŠ¶æ€å˜åŒ–事件。 | +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获å–镜头状æ€å˜åŒ–ä¿¡æ¯ã€‚ | **示例:** ```js -cameraInput.setZoomRatio(1, (err) => { +cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); + console.error('Failed to get cameraStatus callback. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setZoomRatio.'); + console.log('camera : ' + cameraStatusInfo.camera.cameraId); + console.log('status: ' + cameraStatusInfo.status); }) ``` -### setZoomRatio +### on('cameraMute') -setZoomRatio(zoomRatio: number): Promise<void\> +on(type: 'cameraMute', callback: AsyncCallback<boolean\>): void + +监å¬ç›¸æœºç¦ç”¨çš„状æ€å˜åŒ–,通过注册回调函数获å–相机的状æ€å˜åŒ–。 -设置å¯å˜ç„¦è·æ¯”,通过Promise获å–结果。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.CAMERA **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------ | ---- | ------------ | -| zoomRatio | number | 是 | å¯å˜ç„¦è·æ¯”。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'cameraMute',å³ç›¸æœºçŠ¶ç¦ç”¨æ€å˜åŒ–事件。 | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,用于获å–相机是å¦ç¦ç”¨ã€‚ | -**返回值:** +**示例:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +```js +cameraManager.on('cameraMute', (err, status) => { + if (err) { + console.error('Failed to get cameraMute callback. ${err.message}'); + return; + } + console.log('status: ' + status); +}) +``` + +## CameraStatusInfo + +相机管ç†å™¨å›žè°ƒè¿”回的接å£å®žä¾‹ï¼Œè¡¨ç¤ºç›¸æœºçŠ¶æ€ä¿¡æ¯ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core。 + +| å称 | 类型 | 说明 | +| ------ | ----------------------------- | ---------- | +| camera | [CameraDevice](#CameraDevice) | 相机信æ¯ã€‚ | +| status | [CameraStatus](#camerastatus) | 相机状æ€ã€‚ | + +## CameraPosition + +枚举,相机ä½ç½®ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| --------------------------- | ---- | -------------- | +| CAMERA_POSITION_UNSPECIFIED | 0 | 相机ä½ç½®æœªæŒ‡å®šã€‚ | +| CAMERA_POSITION_BACK | 1 | åŽç½®ç›¸æœºã€‚ | +| CAMERA_POSITION_FRONT | 2 | å‰ç½®ç›¸æœºã€‚ | + +## CameraType + +枚举,相机类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ----------------------- | ---- | -------------- | +| CAMERA_TYPE_UNSPECIFIED | 0 | 相机类型未指定。 | +| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。 | +| CAMERA_TYPE_ULTRA_WIDE | 2 | 超广角相机。 | +| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。 | +| CAMERA_TYPE_TRUE_DEPTH | 4 | 带景深信æ¯çš„相机。 | + +## ConnectionType + +枚举,相机连接类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ---------------------------- | ---- | ------------- | +| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。 | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | USB连接的相机。 | +| CAMERA_CONNECTION_REMOTE | 2 | 远程连接的相机。 | + +## CameraDevice + +相机设备信æ¯ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core。 + +| å称 | 类型 | åªè¯» | 说明 | +| -------------- | --------------------------------- | ---- | ---------- | +| cameraId | string | 是 | CameraDevice对象| +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机ä½ç½®ã€‚ | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | +| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。 | **示例:** ```js -cameraInput.setZoomRatio(1).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); -}) +async function getCameraInfo("cameraId") { + var cameraManager = await camera.getCameraManager(context); + var cameras = await cameraManager.getSupportedCameras(); + var cameraObj = cameras[0]; + var cameraId = cameraObj.cameraId; + var cameraPosition = cameraObj.cameraPosition; + var cameraType = cameraObj.cameraType; + var connectionType = cameraObj.connectionType; +} ``` -### getZoomRatio +## Size -getZoomRatio(callback: AsyncCallback<number\>): void +枚举,输出能力查询。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------ | ------ | ---- | ---- | ------------ | +| height | number | 是 | 是 | 图åƒå°ºå¯¸é«˜(åƒç´ )。 | +| width | number | 是 | 是 | 图åƒå°ºå¯¸å®½(åƒç´ )。 | + +## Point + +枚举,点åæ ‡ç”¨äºŽå¯¹ç„¦ã€æ›å…‰é…置。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core -获å–当å‰çš„å¯å˜ç„¦è·æ¯”,通过注册回调函数获å–结果。 +| å称 | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------ | +| x | number | 是 | 点的xåæ ‡ã€‚ | +| y | number | 是 | 点的yåæ ‡ã€‚ | + +## CameraFormat + +æžšä¸¾ï¼Œè¾“å‡ºæ ¼å¼ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 默认值 | 说明 | +| ----------------------- | --------- | ------------ | +| CAMERA_FORMAT_YUV_420_SP| 1003 | YUV 420 SPæ ¼å¼çš„图片。 | +| CAMERA_FORMAT_JPEG | 2000 | JPEGæ ¼å¼çš„图片。 | + +## CameraInput + +会è¯ä¸[CaptureSession](#capturesession)使用的相机信æ¯ã€‚ + +### open + +open\(callback: AsyncCallback<void\>\): void + +打开相机,通过注册回调函数获å–状æ€ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------- | ---- | ------------------------ | -| callback | AsyncCallback<number\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -cameraInput.getZoomRatio((err, zoomRatio) => { +cameraInput.open((err) => { if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); + console.error('Failed to open the camera. ${err.message}'); return; } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); + console.log('Callback returned with camera opened.'); }) ``` -### getZoomRatio +### open -getZoomRatio(): Promise<number\> +open(): Promise<void\> -获å–当å‰çš„å¯å˜ç„¦è·æ¯”,通过Promise获å–结果。 +打开相机,通过Promise获å–相机的状æ€ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| ---------------- | --------------------------- | -| Promise<number\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); +cameraInput.open().then(() => { + console.log('Promise returned with camera opened.'); }) ``` -### release +### close -release\(callback: AsyncCallback<void\>\): void +close\(callback: AsyncCallback<void\>\): void -释放相机实例,通过注册回调函数获å–结果。 +å…³é—相机,通过注册回调函数获å–状æ€ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -cameraInput.release((err) => { +cameraInput.close((err) => { if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); + console.error('Failed to close the cameras. ${err.message}'); return; } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); + console.log('Callback returned with camera closed.'); +}) ``` -### release +### close -release(): Promise<void\> +close(): Promise<void\> -释放相机实例,通过Promise获å–结果。 +å…³é—相机,通过Promise获å–状æ€ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); +cameraInput.close().then(() => { + console.log('Promise returned with camera closed.'); }) ``` -### on('focusStateChange') +### release -on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void +release\(callback: AsyncCallback<void\>\): void -监å¬ç„¦è·çš„状æ€å˜åŒ–,通过注册回调函数获å–结果。 +释放资æºï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'focusStateChange',å³ç„¦è·çŠ¶æ€å˜åŒ–事件。 | -| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获å–焦è·çŠ¶æ€ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); +cameraInput.release((err) => { + if (err) { + console.error('Failed to release the CameraInput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); +}); +``` + +### release + +release(): Promise<void\> + +释放资æºï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +cameraInput.release().then(() => { + console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); }) ``` @@ -1032,10 +1185,10 @@ on(type: 'error', callback: ErrorCallback<CameraInputError\>): void **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------------------- | :--- | :----------------------------------------------- | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------- | ---- | ------------------------------------------- | | type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³CameraInput错误事件。 | -| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | 是 | 回调函数,用于获å–结果。 | +| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | 是 | 回调函数,用于获å–结果。 | **示例:** @@ -1045,24 +1198,29 @@ cameraInput.on('error', (cameraInputError) => { }) ``` -## CameraInputErrorCode +## CameraInputErrorCode -枚举,CameraInput的错误ç 。 +枚举,[CameraInput](#camerainput)错误类型。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +| å称 | 值 | 说明 | +| ------------------------- | ---- | ---------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_NO_PERMISSION | 0 | 没有æƒé™ã€‚ | +| ERROR_DEVICE_PREEMPTED | 1 | 相机被抢å 。 | +| ERROR_DEVICE_DISCONNECTED | 2 | 相机æ–开连接。 | +| ERROR_DEVICE_IN_USE | 3 | 相机æ£åœ¨ä½¿ç”¨ã€‚ | +| ERROR_DRIVER_ERROR | 4 | 驱动错误。 | -## CameraInputError +## CameraInputError -CameraInput错误对象。 +[CameraInput](#camerainput)错误ç 。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 类型 | 说明 | -| ---- | ------------------------------------------- | -------------------------- | +| å称 | 类型 | 说明 | +| ---- | --------------------------------------------- | --------------------- | | code | [CameraInputErrorCode](#camerainputerrorcode) | CameraInputä¸çš„错误ç 。 | @@ -1072,96 +1230,78 @@ CameraInput错误对象。 **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| å称 | 值 | 说明 | -| ---------------------- | ---- | ------------ | +| å称 | 值 | 说明 | +| ---------------------- | ---- | ---------- | | FLASH_MODE_CLOSE | 0 | 闪光ç¯å…³é—。 | -| FLASH_MODE_OPEN | 1 | 闪光ç¯å¼€å¯ã€‚ | +| FLASH_MODE_OPEN | 1 | 闪光ç¯æ‰“开。 | | FLASH_MODE_AUTO | 2 | 自动闪光ç¯ã€‚ | | FLASH_MODE_ALWAYS_OPEN | 3 | 闪光ç¯å¸¸äº®ã€‚ | -## FocusMode +## ExposureMode -枚举,焦è·æ¨¡å¼ã€‚ +枚举,æ›å…‰æ¨¡å¼ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| å称 | 值 | 说明 | -| -------------------------- | ---- | ------------------ | -| FOCUS_MODE_MANUAL | 0 | 手动å˜ç„¦æ¨¡å¼ã€‚ | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | è¿žç»è‡ªåŠ¨å˜ç„¦æ¨¡å¼ã€‚ | -| FOCUS_MODE_AUTO | 2 | 自动å˜ç„¦æ¨¡å¼ã€‚ | -| FOCUS_MODE_LOCKED | 3 | 定焦模å¼ã€‚ | +| å称 | 值 | 说明 | +| ----------------------------- | ---- | ----------- | +| EXPOSURE_MODE_LOCKED | 0 | é”定æ›å…‰æ¨¡å¼ã€‚ | +| EXPOSURE_MODE_AUTO | 1 | 自动æ›å…‰æ¨¡å¼ã€‚ | +| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | è¿žç»è‡ªåŠ¨æ›å…‰ã€‚ | -## FocusState +## FocusMode -枚举,焦è·çŠ¶æ€ã€‚ +枚举,焦è·æ¨¡å¼ã€‚ **系统能力:** SystemCapability.Multimedia.Camera.Core。 -| å称 | 值 | 说明 | -| --------------------- | ---- | ------------ | -| FOCUS_STATE_SCAN | 0 | 扫æ状æ€ã€‚ | -| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。 | -| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。 | - -## camera.createCaptureSession - -createCaptureSession\(context: Context, callback: AsyncCallback<CaptureSession\>\): void - -获å–CaptureSession实例,通过注册回调函数获å–结果。 - -**系统能力:** SystemCapability.Multimedia.Camera.Core - -**å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------------------------- | ---- | -------------------------------------- | -| context | Context | 是 | 应用上下文。 | -| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获å–CaptureSession实例。 | +| å称 | 值 | 说明 | +| -------------------------- | ---- | ------------ | +| FOCUS_MODE_MANUAL | 0 | 手动对焦。 | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | è¿žç»è‡ªåŠ¨å¯¹ç„¦ã€‚ | +| FOCUS_MODE_AUTO | 2 | 自动å˜ç„¦ã€‚ | +| FOCUS_MODE_LOCKED | 3 | 对焦é”定。 | -**示例:** +## FocusState -```js -camera.createCaptureSession((context), (err, captureSession) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); -``` +枚举,焦è·çŠ¶æ€ã€‚ -## camera.createCaptureSession +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -createCaptureSession(context: Context\): Promise<CaptureSession\>; +| å称 | 值 | 说明 | +| --------------------- | ---- | --------- | +| FOCUS_STATE_SCAN | 0 | 触å‘对焦。 | +| FOCUS_STATE_FOCUSED | 1 | 对焦æˆåŠŸã€‚ | +| FOCUS_STATE_UNFOCUSED | 2 | 未完æˆå¯¹ç„¦ã€‚ | -获å–CaptureSession实例,通过Promise获å–结果。 +## ExposureState -**系统能力:** SystemCapability.Multimedia.Camera.Core +枚举,æ›å…‰çŠ¶æ€ã€‚ -**å‚数:** +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -| å称 | 类型 | å¿…å¡« | 说明 | -| ------- | ------- | ---- | ------------ | -| context | Context | 是 | 应用上下文。 | +| å称 | 值 | 说明 | +| ------------------------- | ---- | -------- | +| EXPOSURE_STATE_SCAN | 0 | æ›å…‰ä¸ã€‚ | +| EXPOSURE_STATE_CONVERGED | 1 | æ›å…‰æ”¶æ•›ã€‚ | -**返回值:** +## VideoStabilizationMode -| 类型 | 说明 | -| ------------------------------------------- | ----------------------------------------- | -| Promise<[CaptureSession](#capturesession)\> | 使用Promiseçš„æ–¹å¼èŽ·å–CaptureSession实例。 | +枚举,视频防抖模å¼ã€‚ -**示例:** +**系统能力:** SystemCapability.Multimedia.Camera.Core。 -```js -camera.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); -}) -``` +| å称 | 值 | 说明 | +| --------- | ---- | ------------ | +| OFF | 0 | å…³é—视频防抖功能。 | +| LOW | 1 | 使用基础防抖算法。 | +| MIDDLE | 2 | 使用防抖效果一般的防抖算法,防抖效果优于LOW类型。 | +| HIGH | 3 | 使用防抖效果最好的防抖算法,防抖效果优于MIDDLE类型。 | +| AUTO | 4 | 自动进行选择。 | ## CaptureSession -æ‹ç…§ä¼šè¯ç±»ã€‚ +æ‹ç…§ä¼šè¯ç±»ï¼Œä¿å˜ä¸€æ¬¡ç›¸æœºè¿è¡Œæ‰€éœ€è¦çš„所有资æº[CameraInput](#camerainput)ã€[CameraOutput](#cameraoutput),并å‘相机设备申请完æˆç›¸æœºåŠŸèƒ½(录åƒï¼Œæ‹ç…§)。 ### beginConfig @@ -1173,8 +1313,8 @@ beginConfig\(callback: AsyncCallback<void\>\): void **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** @@ -1199,8 +1339,8 @@ beginConfig\(\): Promise<void\> **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | @@ -1216,14 +1356,14 @@ captureSession.beginConfig().then(() => { commitConfig\(callback: AsyncCallback<void\>\): void -æ交会è¯é…置,通过注册回调函数获å–结果。 +æ交é…置信æ¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** @@ -1242,14 +1382,14 @@ captureSession.commitConfig((err) => { commitConfig\(\): Promise<void\> -æ交会è¯é…置,通过Promise获å–结果。 +æ交é…置信æ¯ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** @@ -1260,546 +1400,529 @@ captureSession.commitConfig().then(() => { }) ``` -### addInput +### canAddInput -addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void +canAddInput(cameraInput: CameraInput, callback: AsyncCallback<boolean\>): void -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个CameraInput实例,通过注册回调函数获å–结果。 +判æ–是å¦å¯ä»¥æ·»åŠ [CameraInput](#camerainput)到会è¯ä¸ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | | cameraInput | [CameraInput](#camerainput) | 是 | 需è¦æ·»åŠ çš„CameraInput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.addInput(cameraInput, (err) => { +captureSession.canAddInput(cameraInput, (err, status) => { if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); + console.error('Can not add cameraInput. ${err.message}'); return; } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); + console.log('Callback returned with cameraInput can added.'); +}) ``` -### addInput +### canAddInput -addInput\(cameraInput: CameraInput\): Promise<void\> +canAddInput(cameraInput: CameraInput): Promise<boolean\> -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个CameraInput实例,通过Promise获å–结果。 +判æ–是å¦å¯ä»¥æ·»åŠ [CameraInput](#camerainput)到会è¯ä¸ï¼Œé€šè¿‡æ³¨Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | | cameraInput | [CameraInput](#camerainput) | 是 | 需è¦æ·»åŠ çš„CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| -------------- | -------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); +captureSession.canAddInput(cameraInput).then(() => { + console.log('Promise returned with cameraInput can added.'); }) ``` -### addOutput +### addInput -addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void +addInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个PreviewOutput实例,通过注册回调函数获å–结果。 +把[CameraInput](#camerainput)åŠ å…¥åˆ°ä¼šè¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需è¦æ·»åŠ çš„PreviewOutput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦æ·»åŠ çš„CameraInput实例。 | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.addOutput(previewOutput, (err) => { +captureSession.addInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); + console.error('Failed to add the CameraInput instance. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); + console.log('Callback invoked to indicate that the CameraInput instance is added.'); }); ``` -### addOutput +### addInput -addOutput\(previewOutput: PreviewOutput\): Promise<void\> +addInput\(cameraInput: CameraInput\): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个PreviewOutput实例,通过Promise获å–结果。 +把[CameraInput](#camerainput)åŠ å…¥åˆ°ä¼šè¯ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需è¦æ·»åŠ çš„PreviewOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦æ·»åŠ çš„CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); +captureSession.addInput(cameraInput).then(() => { + console.log('Promise used to indicate that the CameraInput instance is added.'); }) ``` -### addOutput +### removeInput -addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback<void\>\): void +removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个PhotoOutput实例,通过注册回调函数获å–结果。 +移除[CameraInput](#camerainput),通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需è¦æ·»åŠ çš„PhotoOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦ç§»é™¤çš„CameraInput实例。 | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.addOutput(photoOutput, (err) => { +captureSession.removeInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); + console.error('Failed to remove the CameraInput instance. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); + console.log('Callback invoked to indicate that the cameraInput instance is removed.'); }); ``` -### addOutput +### removeInput -addOutput\(photoOutput: PhotoOutput\): Promise<void\> +removeInput\(cameraInput: CameraInput\): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个PhotoOutput实例,通过Promise获å–结果。 +移除[CameraInput](#camerainput),通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需è¦æ·»åŠ çš„PhotoOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------ | +| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦ç§»é™¤çš„CameraInput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\<void> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); +captureSession.removeInput(cameraInput).then(() => { + console.log('Promise returned to indicate that the cameraInput instance is removed.'); }) ``` -### addOutput +### canAddOutput -addOutput\(videoOutput: VideoOutput, callback: AsyncCallback<void\>\): void +canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback<boolean\>\): void -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个VideoOutput实例,通过注册回调函数获å–结果。 +查询是å¦å¯ä»¥æ·»åŠ [CameraOutput](#cameraoutput)到会è¯ä¸ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需è¦æ·»åŠ çš„VideoOutput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦æ·»åŠ çš„CameraOutput实例。 | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.addOutput(videoOutput, (err) => { +captureSession.canAddOutput(cameraOutput, (err, status) => { if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); + console.error('Can not add cameraOutput. ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); + console.log('Callback returned with cameraOutput can added.'); +}) ``` -### addOutput +### canAddOutput -addOutput\(videoOutput: VideoOutput\): Promise<void\> +canAddOutput(cameraOutput: CameraOutput): Promise<boolean\> -在当å‰ä¼šè¯ä¸ï¼Œæ·»åŠ 一个VideoOutput实例,通过Promise获å–结果。 +查询是å¦å¯ä»¥æ·»åŠ [CameraOutput](#cameraoutput)到会è¯ä¸ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需è¦æ·»åŠ çš„VideoOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦æ·»åŠ çš„CameraOutput实例。 | + **返回值:** -| 类型 | 说明 | +| 类型 | 说明 | | -------------- | --------------------------- | -| Promise\<void> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + **示例:** ```js -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); +captureSession.canAddOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput can added.'); }) ``` -### removeInput +### addOutput -removeInput\(cameraInput: CameraInput, callback: AsyncCallback<void\>\): void +addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªCameraInput实例,通过注册回调函数获å–结果。 +把[CameraOutput](#cameraoutput)åŠ å…¥åˆ°ä¼šè¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦ç§»é™¤çš„CameraInput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------ | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦æ·»åŠ çš„CameraOutput实例。 | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.removeInput(cameraInput, (err) => { +captureSession.addOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the CameraInput instance. ${err.message}'); + console.error('Failed to add output. ${err.message}'); return; } - console.log('Callback invoked to indicate that the cameraInput instance is removed.'); -}); + console.log('Callback returned with output added.'); +}) ``` -### removeInput +### addOutput -removeInput\(cameraInput: CameraInput\): Promise<void\> +addOutput\(cameraOutput: CameraOutput\): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªCameraInput实例,通过Promise获å–结果。 +把[CameraOutput](#cameraoutput)åŠ å…¥åˆ°ä¼šè¯ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | 是 | 需è¦ç§»é™¤çš„CameraInput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦æ·»åŠ çš„CameraOutput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise\<void> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.removeInput(cameraInput).then(() => { - console.log('Promise returned to indicate that the cameraInput instance is removed.'); +captureSession.addOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput added.'); }) ``` ### removeOutput -removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback<void\>\): void +removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªPreviewOutput实例,通过注册回调函数获å–结果。 +从会è¯ä¸ç§»é™¤[CameraOutput](#cameraoutput),通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需è¦ç§»é™¤çš„PreviewOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------ | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦ç§»é™¤çš„CameraOutput实例。 | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.removeOutput(previewOutput, (err) => { +captureSession.removeOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); + console.error('Failed to remove the CameraOutput instance. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); + console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); }); ``` ### removeOutput -removeOutput(previewOutput: PreviewOutput): Promise<void\> +removeOutput(cameraOutput: CameraOutput): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªPreviewOutput实例,通过Promise获å–结果。 +从会è¯ä¸ç§»é™¤[CameraOutput](#cameraoutput),通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需è¦ç§»é™¤çš„PreviewOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | 是 | 需è¦ç§»é™¤çš„CameraOutput实例。 | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); +captureSession.removeOutput(cameraOutput).then(() => { + console.log('Promise returned to indicate that the CameraOutput instance is removed.'); }) ``` -### removeOutput +### start -removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback<void\>): void +start\(callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªPhotoOutput实例,通过注册回调函数获å–结果。 +开始会è¯å·¥ä½œï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需è¦ç§»é™¤çš„PhotoOutput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.removeOutput(photoOutput, (err) => { +captureSession.start((err) => { if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); + console.error('Failed to start the session ${err.message}'); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); + console.log('Callback invoked to indicate the session start success.'); }); ``` -### removeOutput +### start -removeOutput(photoOutput: PhotoOutput): Promise<void\> +start\(\): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªPhotoOutput实例,通过Promise获å–结果。 +开始会è¯å·¥ä½œï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | 是 | 需è¦ç§»é™¤çš„PhotoOutput实例。 | - - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - **示例:** ```js -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); +captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); }) ``` -### removeOutput +### stop -removeOutput(videoOutput: VideoOutput, callback: AsyncCallback<void\>): void +stop\(callback: AsyncCallback<void\>\): void -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªVideoOutput实例,通过注册回调函数获å–结果。 +åœæ¢ä¼šè¯å·¥ä½œï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需è¦ç§»é™¤çš„VideoOutput实例。 | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.removeOutput(videoOutput, (err) => { +captureSession.stop((err) => { if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); + console.error('Failed to stop the session ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); + console.log('Callback invoked to indicate the session stop success.'); }); ``` -### removeOutput +### stop -removeOutput(videoOutput: VideoOutput): Promise<void\> +stop(): Promise<void\> -在当å‰ä¼šè¯ä¸ï¼Œç§»é™¤ä¸€ä¸ªVideoOutput实例,通过Promise获å–结果。 +åœæ¢ä¼šè¯å·¥ä½œï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | 是 | 需è¦ç§»é™¤çš„VideoOutput实例。 | - - **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - **示例:** ```js -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); +captureSession.stop().then(() => { + console.log('Promise returned to indicate the session stop success.'); }) ``` -### start +### lockForControl -start\(callback: AsyncCallback<void\>\): void +lockForControl(callback: AsyncCallback<void\>): void -å¯åŠ¨æ‹ç…§ä¼šè¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +请求以独å æ–¹å¼æŽ§åˆ¶è®¾å¤‡çš„硬件属性[CameraInput](#camerainput),需è¦è°ƒç”¨[unlockForControl](#unlockforcontrol),通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.start((err) => { +captureSession.lockForControl((err) => { if (err) { - console.error('Failed to start the session ${err.message}'); + console.error('Failed to lock. ${err.message}'); return; } - console.log('Callback invoked to indicate the session start success.'); -}); + console.log('Locked.'); +}) ``` -### start +### lockForControl -start\(\): Promise<void\> +lockForControl(): Promise<void\> -å¯åŠ¨æ‹ç…§ä¼šè¯ï¼Œé€šè¿‡Promise获å–结果。 +请求以独å æ–¹å¼æŽ§åˆ¶è®¾å¤‡çš„硬件属性[CameraInput](#camerainput),需è¦è°ƒç”¨[unlockForControl](#unlockforcontrol),通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); +captureSession.lockForControl().then(() => { + console.log('Locked.'); }) ``` -### stop +### unlockForControl -stop\(callback: AsyncCallback<void\>\): void +unlockForControl(callback: AsyncCallback<void\>): void -åœæ¢æ‹ç…§ä¼šè¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +控制生效,并放弃对设备é…置的排他控制,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -captureSession.stop((err) => { +captureSession.unlockForControl((err) => { if (err) { - console.error('Failed to stop the session ${err.message}'); + console.error('Failed to unlock. ${err.message}'); return; } - console.log('Callback invoked to indicate the session stop success.'); -}); + console.log('Unlocked.'); +}) ``` -### stop +### unlockForControl -stop(): Promise<void\> +unlockForControl(): Promise<void\> -åœæ¢æ‹ç…§ä¼šè¯ï¼Œé€šè¿‡Promise获å–结果。 +控制生效,并放弃对设备é…置的排他控制,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -captureSession.stop().then(() => { - console.log('Promise returned to indicate the session stop success.'); +captureSession.unlockForControl().then(() => { + console.log('Unlocked.'); }) ``` @@ -1807,14 +1930,14 @@ captureSession.stop().then(() => { release\(callback: AsyncCallback<void\>\): void -释放CaptureSession实例,通过注册回调函数获å–结果。 +释放会è¯èµ„æºï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | | callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** @@ -1833,14 +1956,14 @@ captureSession.release((err) => { release(): Promise<void\> -释放CaptureSession实例,通过Promise获å–结果。 +释放会è¯èµ„æºï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** @@ -1851,900 +1974,2536 @@ captureSession.release().then(() => { }) ``` -### on('error') +### hasFlash -on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void +hasFlash(callback: AsyncCallback<boolean\>): void -监å¬æ‹ç…§ä¼šè¯çš„错误事件,通过注册回调函数获å–结果。 +检测是å¦æœ‰é—ªå…‰ç¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³æ‹ç…§ä¼šè¯é”™è¯¯äº‹ä»¶ã€‚ | -| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示设备支æŒé—ªå…‰ç¯ã€‚ | **示例:** ```js -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); +cameraInput.hasFlash((err, status) => { + if (err) { + console.error('Failed to check whether the device has flash light. ${err.message}'); + return; + } + console.log('Callback returned with flash light support status: ' + status); }) ``` -## CaptureSessionErrorCode +### hasFlash -枚举,æ‹ç…§ä¼šè¯çš„错误ç 。 +hasFlash(): Promise<boolean\> -**系统能力:** SystemCapability.Multimedia.Camera.Core +检测是å¦æœ‰é—ªå…‰ç¯ï¼Œé€šè¿‡Promise获å–结果。 -| å称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +**系统能力:** SystemCapability.Multimedia.Camera.Core -## CaptureSessionError +**返回值:** -æ‹ç…§ä¼šè¯é”™è¯¯å¯¹è±¡ã€‚ +| 类型 | 说明 | +| ----------------- | ----------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒé—ªå…‰ç¯ã€‚ | -**系统能力:** SystemCapability.Multimedia.Camera.Core +**示例:** -| å称 | 类型 | 说明 | -| ---- | ------------------------------------------- | -------------------------- | -| code | [CaptureSessionError](#capturesessionerror) | CaptureSessionä¸çš„错误ç 。 | +```js +cameraInput.hasFlash().then((status) => { + console.log('Promise returned with the flash light support status:' + status); +}) +``` -## camera.createPreviewOutput +### isFlashModeSupported -createPreviewOutput(surfaceId: string, callback: AsyncCallback<PreviewOutput\>): void +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback<boolean\>): void -获å–PreviewOutput实例,通过注册回调函数获å–结果。 +检测闪光ç¯æ¨¡å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ----------------------------------------------- | ---- | ------------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获å–çš„Surface ID。 | -| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获å–PreviewOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ----------------------- | ---- | --------------------------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支æŒè¯¥é—ªå…‰ç¯æ¨¡å¼ã€‚ | **示例:** ```js -camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => { +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); + console.error('Failed to check whether the flash mode is supported. ${err.message}'); return; } - console.log('Callback returned with previewOutput instance'); -}); + console.log('Callback returned with the flash mode support status: ' + status); +}) ``` -## camera.createPreviewOutput +### isFlashModeSupported -createPreviewOutput(surfaceId: string): Promise\<PreviewOutput> +isFlashModeSupported(flashMode: FlashMode): Promise<boolean\> -获å–PreviewOutput实例,通过Promise获å–结果。 +检测闪光ç¯æ¨¡å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------ | ---- | ---------------------------------- | -| surfaceId | string | 是 | 从XComponent组件获å–çš„Surface ID。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ----------------------- | ---- | ------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | **返回值:** -| 类型 | 说明 | -| ----------------------------------------- | --------------------------- | -| Promise<[PreviewOutput](#previewoutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | +| 类型 | 说明 | +| ----------------- | ---------------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒè¯¥é—ªå…‰ç¯æ¨¡å¼ã€‚ | **示例:** ```js -camera.createPreviewOutput("surfaceId").then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { + console.log('Promise returned with flash mode support status.' + status); }) ``` -## PreviewOutput +### setFlashMode -预览输出类。 +setFlashMode(flashMode: FlashMode, callback: AsyncCallback<void\>): void -### release +设置闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 -release(callback: AsyncCallback<void\>): void +进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥ï¼š -释放PreviewOutput实例,通过注册回调函数获å–结果。 +1. 设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œå¯ä½¿ç”¨æ–¹æ³•[hasFlash](#hasflash)。 +2. 设备是å¦æ”¯æŒæŒ‡å®šçš„闪光ç¯æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFlashModeSupported](#isflashmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ----------------------- | ---- | --------------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -previewOutput.release((err) => { +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); + console.error('Failed to set the flash mode ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); + console.log('Callback returned with the successful execution of setFlashMode.'); +}) ``` -### release +### setFlashMode -release(): Promise<void\> +setFlashMode(flashMode: FlashMode): Promise<void\> + +设置闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 + +进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥ï¼š -释放PreviewOutput实例,通过Promise获å–结果。 +1. 设备是å¦æ”¯æŒé—ªå…‰ç¯ï¼Œå¯ä½¿ç”¨æ–¹æ³•[hasFlash](#hasflash)。 +2. 设备是å¦æ”¯æŒæŒ‡å®šçš„闪光ç¯æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFlashModeSupported](#isflashmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ----------------------- | ---- | ------------- | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光ç¯æ¨¡å¼ã€‚ | + **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ------------------------ | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - **示例:** ```js -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFlashMode.'); }) ``` -### on('frameStart') +### getFlashMode -on(type: 'frameStart', callback: AsyncCallback<void\>): void +getFlashMode(callback: AsyncCallback<FlashMode\>): void -监å¬é¢„览帧å¯åŠ¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------- | :--- | :------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameStart',å³å¸§å¯åŠ¨äº‹ä»¶ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | --------------------------------- | +| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ã€‚ | **示例:** ```js -previewOutput.on('frameStart', () => { - console.log('Preview frame started'); +cameraInput.getFlashMode((err, flashMode) => { + if (err) { + console.error('Failed to get the flash mode ${err.message}'); + return; + } + console.log('Callback returned with current flash mode: ' + flashMode); }) ``` -### on('frameEnd') +### getFlashMode -on(type: 'frameEnd', callback: AsyncCallback<void\>): void +getFlashMode(): Promise<FlashMode\> -监å¬é¢„览帧结æŸï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +获å–当å‰è®¾å¤‡çš„闪光ç¯æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** +**返回值:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameEnd',å³å¸§ç»“æŸäº‹ä»¶ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| 类型 | 说明 | +| --------------------------------- | --------------------------------- | +| Promise<[FlashMode](#flashmode)\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰çš„闪光ç¯æ¨¡å¼ã€‚ | **示例:** ```js -previewOutput.on('frameEnd', () => { - console.log('Preview frame ended'); +cameraInput.getFlashMode().then((flashMode) => { + console.log('Promise returned with current flash mode : ' + flashMode); }) ``` -### on('error') +### isExposureModeSupported -on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void +isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback<boolean\>): void; -监å¬é¢„览输出的错误事件,通过注册回调函数获å–结果。 +检测æ›å…‰æ¨¡å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³é¢„览输出错误事件。 | -| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | æ›å…‰æ¨¡å¼ã€‚ | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,用于获å–是å¦æ”¯æŒæ›å…‰æ¨¡å¼ã€‚ | **示例:** ```js -previewOutput.on('error', (previewOutputError) => { - console.log('Preview output error code: ' + previewOutputError.code); +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log('Failed to check exposure mode supported ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of isExposureModeSupported'); }) ``` -## PreviewOutputErrorCode +### isExposureModeSupported -枚举,预览输出的错误ç 。 +isExposureModeSupported(aeMode: ExposureMode): Promise<boolean\> + +检测æ›å…‰æ¨¡å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +**å‚数:** -## PreviewOutputError +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | æ›å…‰æ¨¡å¼ã€‚ | -预览输出错误对象。 +**返回值:** -**系统能力:** SystemCapability.Multimedia.Camera.Core +| å称 | 说明 | +| ----------------- |--------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–支æŒçš„æ›å…‰æ¨¡å¼ã€‚ | -| å称 | 类型 | 说明 | -| ---- | ------------------------------------------------- | ---------------------- | -| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | PreviewOutputä¸çš„错误ç 。 | +**示例:** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log('Promise returned with exposure mode supported : ' + isSupported); +}) +``` -## camera.createPhotoOutput +### getExposureMode -createPhotoOutput(surfaceId: string, callback: AsyncCallback<PhotoOutput\>): void +getExposureMode(callback: AsyncCallback<ExposureMode\>): void -获å–PhotoOutput实例,通过注册回调函数获å–结果。 +获å–当å‰æ›å…‰æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获å–çš„Surface ID。 | -| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获å–PhotoOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ---------------------------------------- | +| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | 是 | 回调函数,用于获å–当å‰æ›å…‰æ¨¡å¼ã€‚ | **示例:** ```js -camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => { +cameraInput.getExposureMode((err, exposureMode) => { if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; + console.log('Failed to get the exposure mode ${err.message}'); + return ; } - console.log('Callback returned with the PhotoOutput instance.'); -}); + console.log('Callback returned with current exposure mode:' + exposureMode); +}) ``` -## camera.createPhotoOutput +### getExposureMode -createPhotoOutput(surfaceId: string): Promise<PhotoOutput\> +getExposureMode(): Promise<ExposureMode\> -获å–PhotoOutput实例,通过Promise获å–结果。 +获å–当å‰æ›å…‰æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** - -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从[ImageReceiver](js-apis-image.md#imagereceiver9)获å–çš„Surface ID。 | - **返回值:** -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[PhotoOutput](#photooutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–PhotoOutput实例。 | +| å称 | 说明 | +| --------------------------------------- |------------------------------- | +| Promise<[ExposureMode](#exposuremode)\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰æ›å…‰æ¨¡å¼ã€‚ | **示例:** ```js -camera.createPhotoOutput("surfaceId").then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); +cameraInput.getExposureMode().then((exposureMode) => { + console.log('Promise returned with current exposure mode : ' + exposureMode); }) ``` -## ImageRotation -枚举,图片旋转角度。 +### setExposureMode + +setExposureMode(aeMode: ExposureMode, callback: AsyncCallback<void\>): void + +设置æ›å…‰æ¨¡å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ------------ | ---- | --------------- | -| ROTATION_0 | 0 | 图片旋转0度。 | -| ROTATION_90 | 90 | 图片旋转90度。 | -| ROTATION_180 | 180 | 图片旋转180度。 | -| ROTATION_270 | 270 | 图片旋转270度。 | - -## QualityLevel +**å‚数:** -枚举,图片质é‡ã€‚ +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ----------------------- | +| aeMode | [ExposureMode](#exposuremode) | 是 | æ›å…‰æ¨¡å¼ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–设置结果。 | -**系统能力:** SystemCapability.Multimedia.Camera.Core +**示例:** -| å称 | 值 | 说明 | -| -------------------- | ---- | -------------- | -| QUALITY_LEVEL_HIGH | 0 | 图片质é‡é«˜ã€‚ | -| QUALITY_LEVEL_MEDIUM | 1 | 图片质é‡ä¸ç‰ã€‚ | -| QUALITY_LEVEL_LOW | 2 | 图片质é‡å·®ã€‚ | +```js +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log('Failed to set the exposure mode ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of setExposureMode'); +}) +``` +### setExposureMode -## PhotoCaptureSetting +setExposureMode(aeMode: ExposureMode): Promise<void\> -æ‹æ‘„照片的设置。 +设置æ›å…‰æ¨¡å¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------- | ---- | -------------- | -| quality | [QualityLevel](#qualitylevel) | å¦ | 图片质é‡ã€‚ | -| rotation | [ImageRotation](#imagerotation) | å¦ | 图片旋转角度。 | +**返回值:** +| å称 | 说明 | +| ----------------- |---------------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–设置结果。 | -## PhotoOutput +**示例:** -照片输出类。 +```js +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => { + console.log('Promise returned with the successful execution of setExposureMode.'); +}) +``` -### capture +### getMeteringPoint -capture(callback: AsyncCallback<void\>): void +getMeteringPoint(callback: AsyncCallback<Point\>): void -æ‹ç…§ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +查询æ›å…‰åŒºåŸŸä¸å¿ƒç‚¹ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ------------------------ | +| callback | AsyncCallback<[Point](#point)\>| 是 | 回调函数,用于获å–当å‰æ›å…‰ç‚¹ã€‚ | **示例:** ```js -photoOutput.capture((err) => { +cameraInput.getMeteringPoint((err, exposurePoint) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; + console.log('Failed to get the current exposure point ${err.message}'); + return ; } - console.log('Callback invoked to indicate the photo capture request success.'); -}); + console.log('Callback returned with current exposure point:' + exposurePoint); +}) ``` -### capture +### getMeteringPoint -capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void +getMeteringPoint(): Promise<Point\> + +查询æ›å…‰åŒºåŸŸä¸å¿ƒç‚¹ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| å称 | 说明 | +| ------------------------- |----------------------------- | +| Promise<[Point](#point)\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰æ›å…‰ç‚¹ã€‚ | + +**示例:** + +```js +cameraInput.getMeteringPoint().then((exposurePoint) => { + console.log('Promise returned with current exposure point : ' + exposurePoint); +}) +``` + +### setMeteringPoint -æ ¹æ®æ‹ç…§è®¾ç½®æ‹ç…§ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +setMeteringPoint(point: Point, callback: AsyncCallback<point\>): void + +设置æ›å…‰åŒºåŸŸä¸å¿ƒç‚¹ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------------------- | ---- | ------------------------ | -| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | æ‹ç…§è®¾ç½®ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | -------------------------------| ---- | ------------------- | +| exposurePoint | [Point](#point) | 是 | æ›å…‰ç‚¹ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -photoOutput.capture(settings, (err) => { +var Point1 = {x: 1, y: 1}; + +cameraInput.setMeteringPoint(Point1,(err) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; + console.log('Failed to set the exposure point ${err.message}'); + return ; } - console.log('Callback invoked to indicate the photo capture request success.'); -}); + console.log('Callback returned with the successful excution of setMeteringPoint'); +}) ``` -### capture +### setMeteringPoint -capture(setting?: PhotoCaptureSetting): Promise<void\> +setMeteringPoint(point: Point): Promise<void\> -æ ¹æ®æ‹ç…§è®¾ç½®æ‹ç…§ï¼Œé€šè¿‡Promise获å–结果。 +设置æ›å…‰åŒºåŸŸä¸å¿ƒç‚¹ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| ------- | ------------------------------------------- | ---- | ---------- | -| setting | [PhotoCaptureSetting](#photocapturesetting) | å¦ | æ‹ç…§è®¾ç½®ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------------- | -------------------------------| ---- | ------------------- | +| exposurePoint | [Point](#point) | 是 | æ›å…‰ç‚¹ã€‚ | **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - +| å称 | 说明 | +| ----------------- |------------------------ | +| Promise<void\> | 使用Promiseçš„æ–¹å¼è¿”回结果。 | **示例:** ```js -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); +var Point2 = {x: 2, y: 2}; + +cameraInput.setMeteringPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setMeteringPoint'); }) ``` -### release +### getExposureBiasRange -release(callback: AsyncCallback<void\>): void +getExposureBiasRange(callback: AsyncCallback<Array<number\>\>): void -释放PhotoOutput实例,通过注册回调函数获å–结果。 +查询æ›å…‰è¡¥å¿èŒƒå›´ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ----------------------------- | +| callback | AsyncCallback<Array<number\>\> | 是 | 回调函数,用于获å–è¡¥å¿èŒƒå›´çš„数组。 | **示例:** ```js -photoOutput.release((err) => { +cameraInput.getExposureBiasRange((err, biasRangeArray) => { if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; + console.log('Failed to get the array of compenstation range ${err.message}'); + return ; } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); + console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); +}) ``` -### release +### getExposureBiasRange -release(): Promise<void\> +getExposureBiasRange(): Promise<Array<number\>\> -释放PhotoOutput实例,通过Promise获å–结果。 +查询æ›å…‰è¡¥å¿èŒƒå›´ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - +| å称 | 说明 | +| ----------------- |-------------------------------------- | +| Promise<Array<number\>\> | 使用Promiseçš„æ–¹å¼èŽ·å–æ›å…‰è¡¥å¿èŒƒå›´ã€‚ | **示例:** ```js -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log('Promise returned with exposure mode supported : ' + isSupported); }) ``` -### on('captureStart') +### setExposureBias -on(type: 'captureStart', callback: AsyncCallback<number\>): void +setExposureBias(exposureBias: number, callback: AsyncCallback<void\>): void -监å¬æ‹ç…§å¯åŠ¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–Capture ID。 +设置æ›å…‰è¡¥å¿ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +进行设置之å‰ï¼Œå»ºè®®å…ˆé€šè¿‡æ–¹æ³•[getExposureBiasRange](#getexposurebiasrange)查询支æŒçš„范围。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :--------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'captureStart',å³æ‹ç…§å¯åŠ¨äº‹ä»¶ã€‚ | -| callback | AsyncCallback<number\> | 是 | 使用callbackçš„æ–¹å¼èŽ·å–Capture ID。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------| ---- | ------------------- | +| exposureBias | number | 是 | æ›å…‰è¡¥å¿ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -photoOutput.on('captureStart', (err, captureId) => { - console.log('photo capture stated, captureId : ' + captureId); +cameraInput.setExposureBias(-4,(err) => { + if (err) { + console.log('Failed to set the exposure bias ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of setExposureBias'); }) ``` -### on('frameShutter') +### setExposureBias -on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void +setExposureBias(exposureBias: number): Promise<void\> -监å¬å¿«é—¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +设置æ›å…‰è¡¥å¿ï¼Œé€šè¿‡Promise获å–结果。 + +进行设置之å‰ï¼Œå»ºè®®å…ˆé€šè¿‡æ–¹æ³•[getExposureBiasRange](#getexposurebiasrange)查询支æŒçš„范围。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameShutter',å³å¸§åˆ·æ–°äº‹ä»¶ã€‚ | -| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获å–相关信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------------- | --------- | ---- | --------- | +| exposureBias | number | 是 | æ›å…‰è¡¥å¿ã€‚ | + +**返回值:** + +| å称 | 说明 | +| ----------------- |------------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -photoOutput.on('frameShutter', (frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +cameraInput.setExposureBias(-4).then(() => { + console.log('Promise returned with the successful execution of setExposureBias.'); }) ``` -### on('captureEnd') +### getExposureValue -on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void +getExposureValue(callback: AsyncCallback<number\>): void -监å¬æ‹ç…§åœæ¢ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +查询当å‰æ›å…‰å€¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------------------------------------ | :--- | :--------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'captureEnd',å³æ‹ç…§åœæ¢äº‹ä»¶ã€‚ | -| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获å–相关信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------| ---- | --------------------- | +| callback | AsyncCallback<number\> | 是 | 回调函数,用于获å–æ›å…‰å€¼ã€‚ | **示例:** ```js -photoOutput.on('captureEnd', (captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); +cameraInput.getExposureValue((err, exposureValue) => { + if (err) { + console.log('Failed to get the exposure value ${err.message}'); + return ; + } + console.log('Callback returned with the exposure value: ' + exposureValue); }) ``` -### on('error') +### getExposureValue -on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void +getExposureValue(): Promise<number\> -监å¬æ‹ç…§çš„错误事件,通过注册回调函数获å–结果。 +查询当å‰æ›å…‰å€¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** +**返回值:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :---------------------------------------------------- | :--- | :---------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³æ‹ç…§é”™è¯¯äº‹ä»¶ã€‚ | -| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | +| å称 | 说明 | +| ----------------- |-------------------------- | +| Promise<number\> | 使用Promiseçš„æ–¹å¼èŽ·å–æ›å…‰å€¼ã€‚ | **示例:** ```js -photoOutput.on('error', (photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); +cameraInput.getExposureValue().then((exposureValue) => { + console.log('Promise returned with exposure value: ' + exposureValue); }) ``` -## FrameShutterInfo +### isFocusModeSupported + +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback<boolean\>): void -快门事件信æ¯ã€‚ +检测对焦模å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------ | ---- | ----------------------------- | -| captureId | number | 是 | CaptureId,本次æ‹æ‘„动作的ID。 | -| timestamp | number | 是 | 时间戳。 | +**å‚数:** -## CaptureEndInfo +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | -------------------------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回true表示支æŒè¯¥ç„¦è·æ¨¡å¼ã€‚ | -æ‹ç…§åœæ¢ä¿¡æ¯ã€‚ +**示例:** -**系统能力:** SystemCapability.Multimedia.Camera.Core +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { + if (err) { + console.error('Failed to check whether the focus mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the focus mode support status: ' + status); +}) +``` -| å称 | 类型 | å¿…å¡« | 说明 | -| ---------- | ------ | ---- | ----------------------------- | -| captureId | number | 是 | CaptureId,本次æ‹æ‘„动作的ID。 | -| frameCount | number | 是 | 帧计数。 | +### isFocusModeSupported -## PhotoOutputErrorCode +isFocusModeSupported(afMode: FocusMode): Promise<boolean\> -枚举,æ‹ç…§è¾“出的错误ç 。 +检测对焦模å¼æ˜¯å¦æ”¯æŒï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------- | ---- | ------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | -## PhotoOutputError +**返回值:** -æ‹ç…§è¾“出错误对象。 +| 类型 | 说明 | +| ----------------- | --------------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回true表示设备支æŒè¯¥ç„¦è·æ¨¡å¼ã€‚ | -**系统能力:** SystemCapability.Multimedia.Camera.Core +**示例:** -| å称 | 类型 | 说明 | -| ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | PhotoOutputä¸çš„错误ç 。 | +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { + console.log('Promise returned with focus mode support status.' + status); +}) +``` -## camera.createVideoOutput +### setFocusMode + +setFocusMode(afMode: FocusMode, callback: AsyncCallback<void\>): void -createVideoOutput(surfaceId: string, callback: AsyncCallback<VideoOutput\>): void +设置对焦模å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 -获å–VideoOutput实例,通过注册回调函数获å–结果。 +进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥è®¾å¤‡æ˜¯å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFocusModeSupported](#isfocusmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获å–çš„Surface ID。 | -| callback | AsyncCallback<[VideoOutput](#videooutput)\> | 是 | 回调函数,用于获å–VideoOutput实例。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | ------------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -camera.createVideoOutput(("surfaceId"), (err, videoOutput) => { +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); + console.error('Failed to set the focus mode ${err.message}'); return; } - console.log('Callback returned with the VideoOutput instance'); -}); + console.log('Callback returned with the successful execution of setFocusMode.'); +}) ``` -## camera.createVideoOutput +### setFocusMode + +setFocusMode(afMode: FocusMode): Promise<void\> -createVideoOutput(surfaceId: string): Promise<VideoOutput\> +设置对焦模å¼ï¼Œé€šè¿‡Promise获å–结果。 -获å–VideoOutput实例,通过Promise获å–结果。 +进行设置之å‰ï¼Œéœ€è¦å…ˆæ£€æŸ¥è®¾å¤‡æ˜¯å¦æ”¯æŒæŒ‡å®šçš„焦è·æ¨¡å¼ï¼Œå¯ä½¿ç”¨æ–¹æ³•[isFocusModeSupported](#isfocusmodesupported)。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | 是 | 从VideoRecorder获å–çš„Surface ID。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------- | ---- | ------------- | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦è·æ¨¡å¼ã€‚ | **返回值:** -| 类型 | 说明 | -| ------------------------------------- | -------------------------------------- | -| Promise<[VideoOutput](#videooutput)\> | 使用Promiseçš„æ–¹å¼èŽ·å–VideoOutput实例。 | +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -camera.createVideoOutput("surfaceId" -).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFocusMode.'); }) ``` -## VideoOutput - -视频输出类。 - -### start +### getFocusMode -start(callback: AsyncCallback<void\>): void +getFocusMode(callback: AsyncCallback<FocusMode\>): void -开始æ‹æ‘„视频,通过注册回调函数获å–结果。 +获å–当å‰çš„对焦模å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获å–当å‰è®¾å¤‡çš„焦è·æ¨¡å¼ã€‚ | **示例:** ```js -videoOutput.start((err) => { +cameraInput.getFocusMode((err, afMode) => { if (err) { - console.error('Failed to start the video output ${err.message}'); + console.error('Failed to get the focus mode ${err.message}'); return; } - console.log('Callback invoked to indicate the video output start success.'); -}); + console.log('Callback returned with current focus mode: ' + afMode); +}) ``` -### start +### getFocusMode -start(): Promise<void\> +getFocusMode(): Promise<FocusMode\> -开始æ‹æ‘„视频,通过Promise获å–结果。 +获å–当å‰çš„对焦模å¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - +| 类型 | 说明 | +| ------------------- | -------------------------------- | +| Promise<FocusMode\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰çš„焦è·æ¨¡å¼ã€‚ | **示例:** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); +cameraInput.getFocusMode().then((afMode) => { + console.log('Promise returned with current focus mode : ' + afMode); }) ``` -### stop +### setFocusPoint -stop(callback: AsyncCallback<void\>): void +setFocusPoint(point: Point, callback: AsyncCallback<void\>): void -åœæ¢æ‹æ‘„视频,通过注册回调函数获å–结果。 +设置焦点,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | ------------------- | +| point | [Point](#Point) | 是 | 焦点。 | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -videoOutput.stop((err) => { +var Point1 = {x: 1, y: 1}; + +cameraInput.setFocusPoint(Point1, (err) => { if (err) { - console.error('Failed to stop the video output ${err.message}'); + console.error('Failed to set the focus point ${err.message}'); return; } - console.log('Callback invoked to indicate the video output stop success.'); -}); + console.log('Callback returned with the successful execution of setFocusPoint.'); +}) ``` -### stop +### setFocusPoint -stop(): Promise<void\> +setFocusPoint(point: Point): Promise<void\> -åœæ¢æ‹æ‘„视频,通过Promise获å–结果。 +设置焦点,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | +| 类型 | 说明 | +| -------------- | ----------------------- | | Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | **示例:** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); +var Point2 = {x: 2, y: 2}; + +cameraInput.setFocusPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setFocusPoint.'); }) ``` -### release +### getFocusPoint -release(callback: AsyncCallback<void\>): void +getFocusPoint(callback: AsyncCallback<Point\>): void -释放VideoOutput实例,通过注册回调函数获å–结果。 +查询焦点,通过注册回调函数获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------- | ---- | ----------------------- | +| callback | AsyncCallback<[Point](#point)\> | 是 | 回调函数,用于获å–当å‰ç„¦ç‚¹ã€‚ | **示例:** ```js -videoOutput.release((err) => { +cameraInput.getFocusPoint((err, point) => { if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); + console.error('Failed to get the current focus point ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); + console.log('Callback returned with the current focus point: ' + JSON.stringify(point)); +}) ``` -### release +### getFocusPoint -release(): Promise<void\> +getFocusPoint(): Promise<Point\> -释放VideoOutput实例,通过Promise获å–结果。 +查询焦点,通过Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -| -------------- | --------------------------- | -| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | - +| 类型 | 说明 | +| --------------- | --------------------------- | +| Promise<Point\> | 使用Promiseçš„æ–¹å¼èŽ·å–当å‰ç„¦ç‚¹ã€‚ | **示例:** ```js -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); +cameraInput.getFocusPoint().then((point) => { + console.log('Promise returned with the current focus point: ' + JSON.stringify(point)); }) ``` -### on('frameStart') +### getFocalLength -on(type: 'frameStart', callback: AsyncCallback<void\>): void +getFocalLength(callback: AsyncCallback<number\>): void -监å¬è§†é¢‘帧开å¯ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +查询焦è·å€¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------- | :--- | :----------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameStart',å³è§†é¢‘帧开å¯äº‹ä»¶ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ----------------------- | +| callback | AsyncCallback<number\> | 是 | 回调函数,用于获å–当å‰ç„¦è·ã€‚ | **示例:** ```js -videoOutput.on('frameStart', () => { - console.log('Video frame started'); +cameraInput.getFocalLength((err, focalLength) => { + if (err) { + console.error('Failed to get the current focal length ${err.message}'); + return; + } + console.log('Callback returned with the current focal length: ' + focalLength); }) ``` -### on('frameEnd') +### getFocalLength -on(type: 'frameEnd', callback: AsyncCallback<void\>): void +getFocalLength(): Promise<number\> -监å¬è§†é¢‘帧结æŸï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 +查询焦è·å€¼ï¼Œé€šè¿‡Promise获å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core -**å‚数:** +**返回值:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :------------------- | :--- | :--------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameEnd',å³è§†é¢‘帧结æŸäº‹ä»¶ã€‚ | -| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | +| 类型 | 说明 | +| ---------------- | ----------------------- | +| Promise<number\> | 使用Promiseçš„æ–¹å¼èŽ·å–焦è·ã€‚ | **示例:** ```js -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); +cameraInput.getFocalLength().then((focalLength) => { + console.log('Promise returned with the current focal length: ' + focalLength); }) ``` -### on('error') +### getZoomRatioRange -on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void +getZoomRatioRange\(callback: AsyncCallback<Array<number\>\>\): void -监å¬è§†é¢‘输出的错误事件,通过注册回调函数获å–结果。 +获å–支æŒçš„å˜ç„¦èŒƒå›´ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 **系统能力:** SystemCapability.Multimedia.Camera.Core **å‚数:** -| å称 | 类型 | å¿…å¡« | 说明 | -| :------- | :----------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³è§†é¢‘输出错误事件。 | -| callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------ | ---- | ------------------- | +| callback | AsyncCallback<Array<number\>\> | 是 | 回调函数,用于获å–结果。 | **示例:** ```js -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); -}) -``` - +cameraInput.getZoomRatioRange((err, zoomRatioRange) => { + if (err) { + console.error('Failed to get the zoom ratio range. ${err.message}'); + return; + } + console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### getZoomRatioRange + +getZoomRatioRange\(\): Promise<Array<number\>\> + +获å–支æŒçš„å˜ç„¦èŒƒå›´ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------------ | --------------------------- | +| Promise<Array<number\>\> | 使用Promiseçš„æ–¹å¼èŽ·å–å˜ç„¦èŒƒå›´ã€‚ | + +**示例:** + +```js +cameraInput.getZoomRatioRange().then((zoomRatioRange) => { + console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number, callback: AsyncCallback<void\>): void + +设置å˜ç„¦æ¯”,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | -------------------- | ---- | ------------------- | +| zoomRatio | number | 是 | å¯å˜ç„¦è·æ¯”。 | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +cameraInput.setZoomRatio(1, (err) => { + if (err) { + console.error('Failed to set the zoom ratio value ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setZoomRatio.'); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number): Promise<void\> + +设置å˜ç„¦æ¯”,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ------ | ---- | --------- | +| zoomRatio | number | 是 | å¯å˜ç„¦è·æ¯”。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +cameraInput.setZoomRatio(1).then(() => { + console.log('Promise returned with the successful execution of setZoomRatio.'); +}) +``` + +### getZoomRatio + +getZoomRatio(callback: AsyncCallback<number\>): void + +获å–当å‰çš„å˜ç„¦æ¯”,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ------------------- | +| callback | AsyncCallback<number\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +cameraInput.getZoomRatio((err, zoomRatio) => { + if (err) { + console.error('Failed to get the zoom ratio ${err.message}'); + return; + } + console.log('Callback returned with current zoom ratio: ' + zoomRatio); +}) +``` + +### getZoomRatio + +getZoomRatio(): Promise<number\> + +获å–当å‰çš„å˜ç„¦æ¯”,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ----------------------- | +| Promise<number\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +cameraInput.getZoomRatio().then((zoomRatio) => { + console.log('Promise returned with current zoom ratio : ' + zoomRatio); +}) +``` + +### isVideoStablizationModeSupported + +isVideoStablizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback<boolean\>): void + +查询是å¦æ”¯æŒæŒ‡å®šçš„视频防抖模å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------- | ---- | ------------------------------ | +| vsMode | [VideoStabilizationMode](#videostabilizationMode) | 是 | 视频防抖模å¼ã€‚ | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回视频防抖模å¼æ˜¯å¦æ”¯æŒã€‚ | + +**示例:** + +```js +captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => { + if (err) { + console.error('Failed to check whether video stabilization mode supported. ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of isVideoStabilizationModeSupported: ' + status); +}) +``` + +### isVideoStablizationModeSupported + +isVideoStablizationModeSupported(vsMode: VideoStabilizationMode): Promise<boolean\> + +查询是å¦æ”¯æŒæŒ‡å®šçš„视频防抖模å¼ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | --------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回视频防抖模å¼æ˜¯å¦æ”¯æŒã€‚ | + +**示例:** + +```js +captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => { + console.log('Promise returned with video stabilization mode supported: ' + isSupported); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(callback: AsyncCallback<VideoStabilizationMode\>): void + +查询当å‰æ£åœ¨ä½¿ç”¨çš„视频防抖模å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<VideoStabilizationMode\> | 是 | 回调函数,返回视频防抖是å¦æ£åœ¨ä½¿ç”¨ã€‚ | + +**示例:** + +```js +captureSession.getActiveVideoStabilizationMode((err, vsMode) => { + if (err) { + console.error('Failed to get active video stabilization mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.'); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(): Promise<VideoStabilizationMode\> + +查询当å‰æ£åœ¨ä½¿ç”¨çš„视频防抖模å¼ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ------------------------------------------------- | +| Promise<VideoStabilizationMode\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回视频防抖当å‰æ˜¯å¦æ£åœ¨ä½¿ç”¨ã€‚ | + +**示例:** + +```js +captureSession.getActiveVideoStabilizationMode().then((vsMode) => { + console.log('Promise returned with the current video stabilization mode: ' + vsMode); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback<void\>): void + +设置视频防抖模å¼ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------- | ---- | --------------------- | +| mode | [VideoStabilizationMode](#videostabilizationmode) | 是 | 需è¦è®¾ç½®çš„视频防抖模å¼ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数。 | + +**示例:** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => { + if (err) { + console.error('Failed to set the video stabilization mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode): Promise<void\> + +设置视频防抖,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------------------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回设置的视频防抖模å¼çš„结果。 | + +**示例:** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF).then(() => { + console.log('Promise returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### on('focusStateChange') + +on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void + +监å¬ç„¦è·çš„状æ€å˜åŒ–,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'focusStateChange',å³ç„¦è·çŠ¶æ€å˜åŒ–事件。 | +| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获å–焦è·çŠ¶æ€ã€‚ | + +**示例:** + +```js +cameraInput.on('focusStateChange', (focusState) => { + console.log('Focus state : ' + focusState); +}) +``` + +### on('exposureStateChange') + +on(type: 'exposureStateChange', callback: AsyncCallback<ExposureState\>): void + +监å¬æ›å…‰çš„状æ€å˜åŒ–,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | ---------------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'exposureStateChange',å³æ›å…‰çŠ¶æ€å˜åŒ–事件。| +| callback | AsyncCallback<[ExposureState](#exposureState)\> | 是 | 回调函数,用于获å–æ›å…‰çŠ¶æ€ã€‚ | + +**示例:** + +```js +cameraInput.on('exposureStateChange', (exposureState) => { + console.log('Exposuer state : ' + exposureState); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback<CaptureSessionError\>): void + +监å¬æ‹ç…§ä¼šè¯çš„错误事件,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³æ‹ç…§ä¼šè¯é”™è¯¯äº‹ä»¶ã€‚ | +| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +captureSession.on('error', (captureSessionError) => { + console.log('Capture session error code: ' + captureSessionError.code); +}) +``` + +## CaptureSessionErrorCode + +枚举,会è¯é”™è¯¯ç±»åž‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ----------------------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 0 | 资æºä¸è¶³ã€‚ | +| ERROR_TIMEOUT | 1 | 超时。 | + +## CaptureSessionError + +会è¯é”™è¯¯ç 。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | 说明 | +| ---- | ------------------------------------------- | -------------------------- | +| code | [CaptureSessionError](#capturesessionerror) | CaptureSessionä¸çš„错误ç 。 | + +## CameraOutput + +会è¯ä¸[CaptureSession](#capturesession)使用的输出信æ¯ï¼Œoutput的基类。 + +### release + +release(callback: AsyncCallback<void\>): void + +释放输出资æºï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.release((err) => { + if (err) { + console.error('Failed to release the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); +}); +``` + +### release + +release(): Promise<void\> + +释放输出资æºï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +previewOutput.release().then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +}) +``` + +## PreviewOutput + +预览输出类。继承[CameraOutput](#cameraOutput) + +### addDeferredSurface + +addDeferredSurface(surfaceId: string, callback: AsyncCallback<void\>): void + +在previewOutput生æˆä¹‹åŽæ·»åŠ surface,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------------------------------------------------------- | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)组件获å–çš„SurfaceID。| +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.addDeferredSurface('surfaceId', (err) => { + if (err) { + console.error('Failed to add deferredSurface. ${err.message}'); + return; + } + console.log('Callback returned with deferredSurface added.'); +}) +``` + +### addDeferredSurface + +addDeferredSurface(surfaceId: string): Promise<void\> + +在previewOutput生æˆä¹‹åŽæ·»åŠ surface,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -----------| ---- | ------------------------------------------------------------------------------ | +| surfaceId| string | 是 | 从[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)组件获å–çš„SurfaceID。| + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +previewOutput.addDeferredSurface('surfaceId').then(() => { + console.log('Promise returned with deferredSurface added.'); +}) +``` + +### start + +start(callback: AsyncCallback<void\>): void + +开始输出预览æµï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.start((err) => { + if (err) { + console.error('Failed to start the previewOutput. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput started.'); +}) +``` + +### start + +start(): Promise<void\> + +开始输出预览æµï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +previewOutput.start().then(() => { + console.log('Promise returned with previewOutput started.'); +}) +``` + +### stop + +stop(callback: AsyncCallback<void\>): void + +åœæ¢è¾“出预览æµï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.stop((err) => { + if (err) { + console.error('Failed to stop the previewOutput. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput stoped.'); +}) +``` + +### stop + +stop(): Promise<void\> + +åœæ¢è¾“出预览æµï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +previewOutput.stop().then(() => { + console.log('Callback returned with previewOutput stoped.'); +}) +``` + +### on('frameStart') + +on(type: 'frameStart', callback: AsyncCallback<void\>): void + +监å¬é¢„览帧å¯åŠ¨ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | --------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameStart',å³å¸§å¯åŠ¨äº‹ä»¶ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.on('frameStart', () => { + console.log('Preview frame started'); +}) +``` + +### on('frameEnd') + +on(type: 'frameEnd', callback: AsyncCallback<void\>): void + +监å¬é¢„览帧结æŸï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameEnd',å³å¸§ç»“æŸäº‹ä»¶ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +previewOutput.on('frameEnd', () => { + console.log('Preview frame ended'); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback<PreviewOutputError\>): void + +监å¬é¢„览输出的错误事件,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------------- | ---- | ------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³é¢„览输出错误事件。| +| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +previewOutput.on('error', (previewOutputError) => { + console.log('Preview output error code: ' + previewOutputError.code); +}) +``` + +## PreviewOutputErrorCode + +枚举,预览输出错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | + +## PreviewOutputError + +预览输出错误ç 。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | 说明 | +| ---- | ------------------------------------------------- | ---------------------- | +| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | PreviewOutputä¸çš„错误ç 。 | + +## ImageRotation + +枚举,图片旋转角度。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ------------ | ---- | ------------- | +| ROTATION_0 | 0 | 图片旋转0度。 | +| ROTATION_90 | 90 | 图片旋转90度。 | +| ROTATION_180 | 180 | 图片旋转180度。 | +| ROTATION_270 | 270 | 图片旋转270度。 | + +## Location + +图片地ç†ä½ç½®ä¿¡æ¯ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | å¿…å¡« |说明 | +| ------------ | ------ | --- |------------ | +| latitude | number | 是 |纬度(度)。 | +| longitude | number | 是 |ç»åº¦(度)。 | +| altitude | number | 是 |æµ·æ‹”(ç±³)。 | + +## QualityLevel + +枚举,图片质é‡ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| -------------------- | ---- | ------------ | +| QUALITY_LEVEL_HIGH | 0 | 图片质é‡é«˜ã€‚ | +| QUALITY_LEVEL_MEDIUM | 1 | 图片质é‡ä¸ç‰ã€‚ | +| QUALITY_LEVEL_LOW | 2 | 图片质é‡å·®ã€‚ | + + +## PhotoCaptureSetting + +æ‹æ‘„照片的设置。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | å¿…å¡« | 默认值 | 说明 | +| -------- | ------------------------------- | ---- | ----------------- | -----------------| +| quality | [QualityLevel](#qualitylevel) | å¦ | QUALITY_LEVEL_HIGH| 图片质é‡ã€‚ | +| rotation | [ImageRotation](#imagerotation) | å¦ | ROTATION_0 | 图片旋转角度。 | +| location | [Location](#location) | å¦ | (0,0,0) | 图片地ç†ä½ç½®ä¿¡æ¯ã€‚ | +| mirror | boolean | å¦ | false |é•œåƒä½¿èƒ½å¼€å…³(默认关)。 | + +## PhotoOutput + +æ‹ç…§ä¼šè¯ä¸ä½¿ç”¨çš„输出信æ¯ã€‚ + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(callback: AsyncCallback<PhotoCaptureSetting\>): void + +获å–默认æ‹ç…§å‚数,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[PhotoCaptureSetting](#photocapturesetting)\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +photoOutput.getDefaultCaptureSetting((err, photocapturesetting) => { + if (err) { + console.error('Failed to get the defaultCaptureSetting. ${err.message}'); + return; + } + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(): Promise<PhotoCaptureSetting\> + +获å–默认æ‹ç…§å‚数,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------- | ----------------------- | +| Promise<[PhotoCaptureSetting](#photocapturesetting)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +photoOutput.getDefaultCaptureSetting().then((photocapturesetting) => { + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### capture + +capture(callback: AsyncCallback<void\>): void + +以默认设置触å‘一次æ‹ç…§ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +photoOutput.capture((err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture + +capture(setting: PhotoCaptureSetting, callback: AsyncCallback<void\>): void + +以指定å‚数触å‘一次æ‹ç…§ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------- | ---- | -------------------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | æ‹ç…§è®¾ç½®ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +let settings:PhotoCaptureSetting = { + quality = 1, + rotation = 0 +} +photoOutput.capture(settings, (err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture + +capture(setting?: PhotoCaptureSetting): Promise<void\> + +以指定å‚数触å‘一次æ‹ç…§ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------------------- | ---- | -------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | å¦ | æ‹ç…§è®¾ç½®ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------ | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + + +**示例:** + +```js +photoOutput.capture().then(() => { + console.log('Promise returned to indicate that photo capture request success.'); +}) +``` + +### isMirrorSupported + +isMirrorSupported(callback: AsyncCallback<boolean\>): void + +查询是å¦æ”¯æŒé•œåƒæ‹ç…§ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------- | ---- | -------------------------- | +| callback | AsyncCallback<boolean\> | 是 | 回调函数,返回是å¦æ”¯æŒé•œåƒæ‹ç…§ã€‚ | + +**示例:** + +```js +captureSession.isMirrorSupported((err, isSupported) => { + if (err) { + console.error('Failed to check mirror is supported ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of isMirrorSupported.'); +}) +``` + +### isMirrorSupported + +isMirrorSupported(): Promise<boolean\> + +查询是å¦æ”¯æŒé•œåƒæ‹ç…§ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------- | +| Promise<boolean\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果,返回是å¦æ”¯æŒè‡ªæ‹ç»“果。 | + +**示例:** + +```js +captureSession.isMirrorSupported().then((isSupported) => { + console.log('Promise returned with mirror supported: ' + isSupported); +}) +``` + +### on('captureStart') + +on(type: 'captureStart', callback: AsyncCallback<number\>): void + +监å¬æ‹ç…§å¼€å§‹ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–Capture ID。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'captureStart',å³æ‹ç…§å¯åŠ¨äº‹ä»¶ã€‚ | +| callback | AsyncCallback<number\> | 是 | 使用callbackçš„æ–¹å¼èŽ·å–Capture ID。 | + +**示例:** + +```js +photoOutput.on('captureStart', (err, captureId) => { + console.log('photo capture stated, captureId : ' + captureId); +}) +``` + +### on('frameShutter') + +on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void + +监å¬æ‹ç…§å¸§è¾“出æ•èŽ·ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------- | --- | ------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameShutter',å³å¸§åˆ·æ–°äº‹ä»¶ã€‚ | +| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | 是 | 回调函数,用于获å–相关信æ¯ã€‚ | + +**示例:** + +```js +photoOutput.on('frameShutter', (err, frameShutterInfo) => { + console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); + console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +}) +``` + +### on('captureEnd') + +on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void + +监å¬æ‹ç…§ç»“æŸï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'captureEnd',å³æ‹ç…§åœæ¢äº‹ä»¶ã€‚ | +| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | 是 | 回调函数,用于获å–相关信æ¯ã€‚ | + +**示例:** + +```js +photoOutput.on('captureEnd', (err, captureEndInfo) => { + console.log('photo capture end, captureId : ' + captureEndInfo.captureId); + console.log('frameCount : ' + captureEndInfo.frameCount); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback<PhotoOutputError\>): void + +监å¬æ‹ç…§è¾“出å‘生错误,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------- | ---- | ----------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³æ‹ç…§é”™è¯¯äº‹ä»¶ã€‚ | +| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +photoOutput.on('error', (err, photoOutputError) => { + console.log('Photo output error code: ' + photoOutputError.code); +}) +``` + +## FrameShutterInfo + +æ‹ç…§å¸§è¾“出信æ¯ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | å¿…å¡« | 说明 | +| --------- | ------ | ---- | ---------- | +| captureId | number | 是 | æ‹ç…§çš„ID。 | +| timestamp | number | 是 | 快门时间戳。 | + +## CaptureEndInfo + +æ‹ç…§åœæ¢ä¿¡æ¯ã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | å¿…å¡« | 说明 | +| ---------- | ------ | ---- | ---------| +| captureId | number | 是 | æ‹ç…§çš„ID。 | +| frameCount | number | 是 | 帧数。 | + +## PhotoOutputErrorCode + +枚举,æ‹ç…§è¾“出错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ----------------------------- | ---- | --------------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 1 | 资æºä¸è¶³ã€‚ | +| ERROR_TIMEOUT | 2 | 超时。 | + +## PhotoOutputError + +æ‹ç…§è¾“出错误ç 。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | 说明 | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | PhotoOutputä¸çš„错误ç 。 | + +## VideoOutput + +录åƒä¼šè¯ä¸ä½¿ç”¨çš„输出信æ¯ã€‚ + +### start + +start(callback: AsyncCallback<void\>): void + +å¯åŠ¨å½•åˆ¶ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +videoOutput.start((err) => { + if (err) { + console.error('Failed to start the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output start success.'); +}); +``` + +### start + +start(): Promise<void\> + +å¯åŠ¨å½•åˆ¶ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + + +**示例:** + +```js +videoOutput.start().then(() => { + console.log('Promise returned to indicate that start method execution success.'); +}) +``` + +### stop + +stop(callback: AsyncCallback<void\>): void + +结æŸå½•åˆ¶ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +videoOutput.stop((err) => { + if (err) { + console.error('Failed to stop the video output ${err.message}'); + return; + } + console.log('Callback invoked to indicate the video output stop success.'); +}); +``` + +### stop + +stop(): Promise<void\> + +结æŸå½•åˆ¶ï¼Œé€šè¿‡Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +videoOutput.stop().then(() => { + console.log('Promise returned to indicate that stop method execution success.'); +}) +``` + +### on('frameStart') + +on(type: 'frameStart', callback: AsyncCallback<void\>): void + +监å¬å½•åƒå¼€å§‹ï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ----------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameStart',å³è§†é¢‘帧开å¯äº‹ä»¶ã€‚ | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +videoOutput.on('frameStart', () => { + console.log('Video frame started'); +}) +``` + +### on('frameEnd') + +on(type: 'frameEnd', callback: AsyncCallback<void\>): void + +监å¬å½•åƒç»“æŸï¼Œé€šè¿‡æ³¨å†Œå›žè°ƒå‡½æ•°èŽ·å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'frameEnd',å³è§†é¢‘帧结æŸäº‹ä»¶ 。 | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +videoOutput.on('frameEnd', () => { + console.log('Video frame ended'); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback<VideoOutputError\>): void + +监å¬å½•åƒè¾“出å‘生错误,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ---- | -------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³è§†é¢‘输出错误事件。 | +| callback | Callback<[VideoOutputError](#videooutputerror)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +videoOutput.on('error', (VideoOutputError) => { + console.log('Video output error code: ' + VideoOutputError.code); +}) +``` + ## VideoOutputErrorCode -枚举,视频输出的错误ç 。 +枚举,录åƒè¾“出错误类型。 **系统能力:** SystemCapability.Multimedia.Camera.Core -| å称 | 值 | 说明 | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | 未知错误。 | +| å称 | 值 | 说明 | +| --------------------- | ---- | ------------ | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_DRIVER_ERROR | 0 | 驱动或者硬件错误。| + +## VideoOutputError + +录åƒè¾“出错误ç 。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | 说明 | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | VideoOutputä¸çš„错误ç 。 | + +## MetadataObjectType + +枚举,metadataæµã€‚ + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ------------------------- | ---- | ----------------- | +| FACE_DETECTION | 0 | metadata对象类型。 | + +## Rect + +矩形定义。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 类型 | 说明 | +| -------- | ------ | -------------------- | +| topLeftX | number | 矩形区域左上角xåæ ‡ã€‚ | +| topLeftY | number | 矩形区域左上角yåæ ‡ã€‚ | +| width | number | 矩形宽。 | +| height | number | 矩形高。 | + +## MetadataObject + +相机元能力信æ¯ï¼Œ[CameraInput](#camerainput)相机信æ¯ä¸çš„æ•°æ®æ¥æºã€‚ + +### getType + +getType(callback: AsyncCallback<MetadataObjectType\>): void + +查询metadata对象类型,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------------------------- | --- | -------------------- | +| callback | AsyncCallback<[MetadataObjectType](#metadataObjectType)\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +metadataObject.getType((err, metadataObjectType) => { + if (err) { + console.error('Failed to get type. ${err.message}'); + return; + } + console.log('Callback returned with an array of metadataObjectType.'); +}) +``` + +### getType + +getType(): Promise<MetadataObjectType\> + +查询metadata对象类型,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------------- | --------------------------- | +| Promise<[MetadataObjectType](#metadataObjectType)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +metadataObject.getType().then((metadataObjectType) => { + console.log('Callback returned with an array of metadataObjectType.'); +}) +``` + +### getTimestamp + +getTimestamp(callback: AsyncCallback<number\>): void + +查询metadata时间戳,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<number\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +metadataObject.getTimestamp((err) => { + if (err) { + console.error('Failed to get timestamp. ${err.message}'); + return; + } + console.log('Callback returned with timestamp getted.'); +}) +``` + +### getTimestamp + +getTimestamp(): Promise<number\> + +查询metadata时间戳,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise<number)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +metadataObject.getTimestamp().then(() => { + console.log('Callback returned with timestamp getted.'); +}) +``` + +### getBoundingBox + +getBoundingBox(callback: AsyncCallback<Rect\>): void + +查询metadata的边界框,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[Rect](#rect)\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +metadataObject.getBoundingBox((err, rect) => { + if (err) { + console.error('Failed to get boundingBox. ${err.message}'); + return; + } + console.log('Callback returned with boundingBox getted.'); +}) +``` + +### getBoundingBox + +getBoundingBox(): Promise<Rect\> + +查询metadata的边界框,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<[Rect](#rect)\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +metadataObject.getBoundingBox().then((rect) => { + console.log('Callback returned with boundingBox getted.'); +}) +``` + +## MetadataFaceObject + +metadata的人脸对象。继承[MetadataObject](#metadataObject) + +## MetadataOutput + +metadataæµã€‚继承[CameraOutput](#cameraoutput) + +### start + +start(callback: AsyncCallback<void\>): void + +开始输出metadata,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +metadataOutput.start((err) => { + if (err) { + console.error('Failed to start metadataOutput. ${err.message}'); + return; + } + console.log('Callback returned with metadataOutput started.'); +}) +``` + +### start + +start(): Promise<void\> + +开始输出metadata,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ------------------------ | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +metadataOutput.start().then(() => { + console.log('Callback returned with metadataOutput started.'); +}) +``` + +### stop + +stop(callback: AsyncCallback<void\>): void + +åœæ¢è¾“出metadata,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| callback | AsyncCallback<void\> | 是 | 回调函数,用于获å–结果。 | + +**示例:** + +```js +metadataOutput.stop((err) => { + if (err) { + console.error('Failed to stop the metadataOutput. ${err.message}'); + return; + } + console.log('Callback returned with metadataOutput stoped.'); +}) +``` + +### stop + +stop(): Promise<void\> + +åœæ¢è¾“出metadata,通过Promise获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | --------------------------- | +| Promise<void\> | 使用Promiseçš„æ–¹å¼èŽ·å–结果。 | + +**示例:** + +```js +metadataOutput.stop().then(() => { + console.log('Callback returned with metadataOutput stoped.'); +}) +``` + +### on('metadataObjectsAvailable') + +on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObject\>\>): void + +监å¬æ£€æµ‹åˆ°çš„metadata对象,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- - | ---- | ------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'metadataObjectsAvailable',å³metadata对象。 | +| callback | Callback<Array<[MetadataObject](#metadataObject)\>\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +metadataOutput.on('metadataObjectsAvailable', (metadataObject) => { + console.log('metadata output error code: ' + metadataObject.code); +}) +``` + +### on('error') + +on(tuype: 'error', callback: ErrorCallback<MetadataOutputError\>): void + +监å¬metadataæµçš„错误,通过注册回调函数获å–结果。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ---- | --------------------------------------- | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'error',å³metadataæµçš„错误。 | +| callback | Callback<[MetadataOutputError](#metadataOutputError)\> | 是 | 回调函数,用于获å–错误信æ¯ã€‚ | + +**示例:** + +```js +metadataOutput.on('error', (metadataOutputError) => { + console.log('Metadata output error code: ' + metadataOutputError.code); +}) +``` + +## MetadataOutputErrorCode + +枚举,metadata输出错误类型。 + +**系统能力:** SystemCapability.Multimedia.Camera.Core + +| å称 | 值 | 说明 | +| ------------------------------- | ---- | -------- | +| ERROR_UNKNOWN | -1 | 未知错误。 | +| ERROR_INSUFFICIENT_RESOURCES | 0 | 资æºä¸è¶³ã€‚ | -## VideoOutputError +## MetadataOutputError -视频输出错误对象。 +metadata输出错误ç 。 **系统能力:** SystemCapability.Multimedia.Camera.Core | å称 | 类型 | 说明 | | ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | VideoOutputä¸çš„错误ç 。 | \ No newline at end of file +| code | [MetadataOutputErrorCode](#MetadataOutputErrorCode) | MetadataOutputä¸çš„错误ç 。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md index 26d43c37158ab489ad43a28c73d359d923e18dff..96d1d56624bb13cb4d835f0ad54399b0181874b5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @@ -3,7 +3,7 @@ 本模å—主è¦ç”¨äºŽæ“作åŠç®¡ç†NFCå¡æ¨¡æ‹Ÿã€‚ >  **说明:** -> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -19,7 +19,7 @@ isSupported(feature: number): boolean 是å¦æ”¯æŒæŸç§ç±»åž‹çš„å¡æ¨¡æ‹Ÿ -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -27,11 +27,11 @@ isSupported(feature: number): boolean | -------- | -------- | | boolean | true:支æŒè¯¥ç±»åž‹å¡æ¨¡æ‹Ÿï¼Œ false:ä¸æ”¯æŒè¯¥ç±»åž‹å¡æ¨¡æ‹Ÿã€‚ | -## HceService +## HceService<sup>8+</sup> 管ç†HCEå¡æ¨¡æ‹Ÿã€‚在调用HceService的接å£å‰ï¼Œéœ€è¦å…ˆé€šè¿‡new cardEmulation.HceService()创建实例。 -### startHCE +### startHCE<sup>8+</sup> startHCE(aidList: string[]): boolean @@ -39,7 +39,7 @@ startHCE(aidList: string[]): boolean **需è¦æƒé™**:ohos.permission.NFC_CARD_EMULATION -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **å‚数:** @@ -47,7 +47,7 @@ startHCE(aidList: string[]): boolean | ------- | -------- | ---- | ----------------------- | | aidList | string[] | 是 | 注册进行å¡æ¨¡æ‹Ÿçš„aid列表 | -### stopHCE +### stopHCE<sup>8+</sup> stopHCE(): boolean @@ -55,9 +55,9 @@ stopHCE(): boolean **需è¦æƒé™**:ohos.permission.NFC_CARD_EMULATION -**系统能力:** SystemCapability.Communication.NFC +**系统能力:** SystemCapability.Communication.NFC.Core -### on +### on<sup>8+</sup> on(type: "hceCmd", callback: AsyncCallback<number[]>): void; @@ -65,7 +65,7 @@ on(type: "hceCmd", callback: AsyncCallback<number[]>): void; **需è¦æƒé™**:ohos.permission.NFC_CARD_EMULATION -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **å‚数:** @@ -74,7 +74,7 @@ on(type: "hceCmd", callback: AsyncCallback<number[]>): void; | type | string | 是 | 固定填"hceCmd"å—符串 | | callback | AsyncCallback<number[]> | 是 | 订阅的事件回调,入å‚是符åˆAPDUå议的数æ®æ•°ç»„ | -### sendResponse +### sendResponse<sup>8+</sup> sendResponse(responseApdu: number[]): void; @@ -82,7 +82,7 @@ sendResponse(responseApdu: number[]): void; **需è¦æƒé™**:ohos.permission.NFC_CARD_EMULATION -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **å‚数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index f95af7bd892338a983429ae8ae1db23a9dd75c0d..df66790171ff88b2d42ee9dd784cf8eddd857ccf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -170,6 +170,8 @@ CommonEvent模å—支æŒçš„事件类型。å称指的是系统公共事件å®ï¼› | COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | 表示foundation已准备好的公共事件的动作。 | | COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | æ— | 表示设备飞行模å¼å·²æ›´æ”¹çš„公共事件的动作。 | | COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN | 表示分å±çš„公共事件的动作。 | +| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | 表示通知通é“更新的动作。 | +| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | æ— | 表示spn显示信æ¯å·²æ›´æ–°çš„公共事件的动作。 | ## CommonEvent.publish diff --git a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md index d79d5fdba78a9ea51a50f876b45e73cd160db4fa..d8531e35a584b9ba62f2b43e46ffb4b1ea9f5698 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-config-policy.md +++ b/zh-cn/application-dev/reference/apis/js-apis-config-policy.md @@ -6,7 +6,7 @@ > > 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > -> 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +> 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— diff --git a/zh-cn/application-dev/reference/apis/js-apis-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-configuration.md index 1889e753e1a868c5730c9f29e500b812fb11f64a..0f82948b512e9bd6b497befe3953562bcdb69c63 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configuration.md @@ -23,3 +23,5 @@ import Configuration from '@ohos.application.Configuration'; | direction<sup>9+</sup> | Direction | 是 | å¦ | 表示å±å¹•æ–¹å‘,å–值范围:水平方å‘(DIRECTION_HORIZONTAL),垂直方å‘(DIRECTION_VERTICAL)。 | | screenDensity<sup>9+</sup> | ScreenDensity | 是 | å¦ | 表示å±å¹•åˆ†è¾¨çŽ‡ï¼Œå–值范围:SCREEN_DENSITY_SDPI(120)ã€SCREEN_DENSITY_MDPI(160)ã€SCREEN_DENSITY_LDPI(240)ã€SCREEN_DENSITY_XLDPI(320)ã€SCREEN_DENSITY_XXLDPI(480)ã€SCREEN_DENSITY_XXXLDPI(640)。 | | displayId<sup>9+</sup> | number | 是 | å¦ | 表示应用所在的displayId。 | +| hasPointerDevice<sup>9+</sup> | boolean | 是 | å¦ | 指示指针类型设备是å¦å·²è¿žæŽ¥ã€‚ | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md b/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md index 6f62b388faf8642a95796829f7f39147e03db897..412d965ba806772193c751ebf212f67321e0fe14 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-connectedTag.md @@ -129,7 +129,7 @@ writeNdefTag(data: string): Promise<void> ## connectedTag.writeNdefTag -writeNdefTag(data: string, callback: AsyncCallback<string>): void +writeNdefTag(data: string, callback: AsyncCallback<void>): void 写入内容到有æºæ ‡ç¾ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ @@ -219,6 +219,8 @@ off(type: "notify", callback?: Callback<number>): void 表示NFC场强状æ€çš„枚举。 +**系统能力**:SystemCapability.Communication.ConnectedTag + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | NFC_RF_LEAVE | 0 | NFC离场事件 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md index 8270193601115937abe402bb26eb67e11f907411..bc7145c55e268f1da2a710f6d0f239132cb33ef8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md +++ b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationExtraParams.md @@ -1,19 +1,14 @@ # ContinuationExtraParams -本模å—æä¾›æµè½¬ç®¡ç†å…¥å£ä¸äº’è”é¢æ¿æ‰€éœ€çš„过滤å‚数。 +本模å—æä¾›æµè½¬ç®¡ç†å…¥å£ä¸è®¾å¤‡é€‰æ‹©æ¨¡å—所需的过滤å‚数。 ->  **说明:** +> **说明:** +> > 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 -## å¯¼å…¥æ¨¡å— - -```js -import continuationManager from "@ohos.continuation.continuationManager" -``` - ## ContinuationExtraParams -表示æµè½¬ç®¡ç†å…¥å£ä¸äº’è”é¢æ¿æ‰€éœ€çš„过滤å‚数。 +表示æµè½¬ç®¡ç†å…¥å£ä¸è®¾å¤‡é€‰æ‹©æ¨¡å—所需的过滤å‚数。 **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.DistributedAbilityManager diff --git a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md index 5153a98a31ae33a6ee20d9e321de71bf181518c4..6f8c8b23efd22a2dd9d3e287a7029a9037429af6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -1,10 +1,12 @@ # continuationManager +continuationManager模å—æ供了æµè½¬/ååŒå…¥å£ç®¡ç†æœåŠ¡èƒ½åŠ›ï¼ŒåŒ…括连接/å–消æµè½¬ç®¡ç†æœåŠ¡ï¼Œæ³¨å†Œ/解注册设备连接å˜åŒ–监å¬ï¼Œæ‹‰èµ·è®¾å¤‡é€‰æ‹©æ¨¡å—,更新连接状æ€ã€‚ ->  **说明:** -> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +本模å—接å£ç”¨äºŽæ‹‰èµ·ç³»ç»Ÿä¸çš„设备选择模å—,由于该模å—功能暂ä¸å®Œå¤‡ï¼Œå› æ¤**æµè½¬èƒ½åŠ›æ•´ä½“æš‚ä¸æ”¯æŒç”¨äºŽåº”用开å‘**。 -continuationManager模å—æ供了æµè½¬/ååŒå…¥å£ç®¡ç†æœåŠ¡èƒ½åŠ›ï¼ŒåŒ…括连接/å–消æµè½¬ç®¡ç†æœåŠ¡ï¼Œæ³¨å†Œ/解注册设备连接å˜åŒ–监å¬ï¼Œæ‹‰èµ·äº’è”é¢æ¿ï¼Œæ›´æ–°è¿žæŽ¥çŠ¶æ€ã€‚ +> **说明:** +> +> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -86,9 +88,16 @@ register(options?: ContinuationExtraParams): Promise\<number>; | -------- | -------- | -------- | -------- | | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | å¦ | 过滤å¯é€‰æ‹©è®¾å¤‡åˆ—表的é¢å¤–å‚数,该å‚æ•°å¯ç¼ºçœ| +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\<number> | Promiseå½¢å¼è¿”回æµè½¬ç®¡ç†æœåŠ¡è¿žæŽ¥åŽç”Ÿæˆçš„token。 | + **示例:** ```js + let token = -1; let continuationExtraParams = { deviceType: ["00E"] }; @@ -130,7 +139,7 @@ off(type: "deviceDisconnect", callback?: Callback\<string>): void; 异æ¥æ–¹æ³•ï¼Œå–消监å¬è®¾å¤‡æ–开状æ€ï¼Œä½¿ç”¨Callbackå½¢å¼è¿”回连接的设备信æ¯ã€‚ -## continuationManager.on("deviceConnect") +## continuationManager.on("deviceConnect")<sup>9+</sup> on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void; @@ -144,11 +153,12 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation | -------- | -------- | -------- | -------- | | type | string | 是 | 监å¬çš„事件类型,固定值"deviceConnect"。 | | token | number | 是 | 注册åŽçš„token。 | - | callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | 是 | 当用户从互è”é¢æ¿ä¸é€‰æ‹©è®¾å¤‡æ—¶è°ƒç”¨ï¼Œè¿”回设备IDã€è®¾å¤‡ç±»åž‹å’Œè®¾å¤‡å称供开å‘者使用。 | + | callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | 是 | 当用户从设备选择模å—ä¸é€‰æ‹©è®¾å¤‡æ—¶è°ƒç”¨ï¼Œè¿”回设备IDã€è®¾å¤‡ç±»åž‹å’Œè®¾å¤‡å称供开å‘者使用。 | **示例:** ```js + let token = 1; continuationManager.on("deviceConnect", token, (data) => { console.info('onDeviceConnect len: ' + data.length); for (let i = 0; i < data.length; i++) { @@ -159,7 +169,7 @@ on(type: "deviceConnect", token: number, callback: Callback\<Array\<Continuation }); ``` -## continuationManager.on("deviceDisconnect") +## continuationManager.on("deviceDisconnect")<sup>9+</sup> on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void; @@ -173,11 +183,12 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>) | -------- | -------- | -------- | -------- | | type | string | 是 | 监å¬çš„事件类型,固定值"deviceDisconnect"。 | | token | number | 是 | 注册åŽçš„token。 | - | callback | Callback\<Array\<string>> | 是 | 当用户从互è”é¢æ¿ä¸æ–开设备时调用,返回设备ID供开å‘者使用。 | + | callback | Callback\<Array\<string>> | 是 | 当用户从设备选择模å—ä¸æ–开设备时调用,返回设备ID供开å‘者使用。 | **示例:** ```js + let token = 1; continuationManager.on("deviceDisconnect", token, (data) => { console.info('onDeviceDisconnect len: ' + data.length); for (let i = 0; i < data.length; i++) { @@ -187,7 +198,7 @@ on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>) }); ``` -## continuationManager.off("deviceConnect") +## continuationManager.off("deviceConnect")<sup>9+</sup> off(type: "deviceConnect", token: number): void; @@ -205,10 +216,11 @@ off(type: "deviceConnect", token: number): void; **示例:** ```js + let token = 1; continuationManager.off("deviceConnect", token); ``` -## continuationManager.off("deviceDisconnect") +## continuationManager.off("deviceDisconnect")<sup>9+</sup> off(type: "deviceDisconnect", token: number): void; @@ -226,6 +238,7 @@ off(type: "deviceDisconnect", token: number): void; **示例:** ```js + let token = 1; continuationManager.off("deviceDisconnect", token); ``` @@ -233,7 +246,7 @@ off(type: "deviceDisconnect", token: number): void; startDeviceManager(token: number, callback: AsyncCallback\<void>): void; -拉起互è”é¢æ¿ï¼Œå¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œæ— 过滤æ¡ä»¶ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +拉起设备选择模å—,å¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œæ— 过滤æ¡ä»¶ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -247,6 +260,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void; **示例:** ```js + let token = 1; continuationManager.startDeviceManager(token, (err, data) => { if (err.code != 0) { console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); @@ -260,7 +274,7 @@ startDeviceManager(token: number, callback: AsyncCallback\<void>): void; startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void; -拉起互è”é¢æ¿ï¼Œå¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +拉起设备选择模å—,å¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -275,6 +289,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As **示例:** ```js + let token = 1; let continuationExtraParams = { deviceType: ["00E"] }; @@ -291,7 +306,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>; -拉起互è”é¢æ¿ï¼Œå¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +拉起设备选择模å—,å¯æ˜¾ç¤ºç»„网内å¯é€‰æ‹©è®¾å¤‡åˆ—表信æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -302,9 +317,16 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v | token | number | 是 | 注册åŽçš„token。 | | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | å¦ | 过滤å¯é€‰æ‹©è®¾å¤‡åˆ—表的é¢å¤–å‚数,该å‚æ•°å¯ç¼ºçœ| +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\<void> | Promiseå½¢å¼è¿”回接å£è°ƒç”¨ç»“果。 | + **示例:** ```js + let token = 1; let continuationExtraParams = { deviceType: ["00E"] }; @@ -321,7 +343,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<v updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void; -通知互è”é¢æ¿ï¼Œæ›´æ–°å½“å‰çš„连接状æ€ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +通知设备选择模å—,更新当å‰çš„连接状æ€ï¼Œä½¿ç”¨AsyncCallbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -337,6 +359,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, **示例:** ```js + let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { if (err.code != 0) { @@ -351,7 +374,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>; -通知互è”é¢æ¿ï¼Œæ›´æ–°å½“å‰çš„连接状æ€ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +通知设备选择模å—,更新当å‰çš„连接状æ€ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -363,9 +386,16 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) | deviceId | string | 是 | 设备ID。 | | status | [DeviceConnectState](#deviceconnectstate) | 是 | 设备连接状æ€ã€‚ | +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\<void> | Promiseå½¢å¼è¿”回接å£è°ƒç”¨ç»“果。 | + **示例:** ```js + let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) .then((data) => { @@ -394,6 +424,7 @@ unregister(token: number, callback: AsyncCallback\<void>): void; **示例:** ```js + let token = 1; continuationManager.unregister(token, (err, data) => { if (err.code != 0) { console.error('unregister failed, cause: ' + JSON.stringify(err)); @@ -417,9 +448,16 @@ unregister(token: number): Promise\<void>; | -------- | -------- | -------- | -------- | | token | number | 是 | 注册åŽçš„token。 | +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------ | +| Promise\<void> | Promiseå½¢å¼è¿”回接å£è°ƒç”¨ç»“果。 | + **示例:** ```js + let token = 1; continuationManager.unregister(token) .then((data) => { console.info('unregister finished, ' + JSON.stringify(data)); @@ -446,7 +484,7 @@ unregister(token: number): Promise\<void>; ## ContinuationMode -互è”é¢æ¿è¿žæŽ¥æ¨¡å¼ã€‚ +设备选择模å—连接模å¼ã€‚ **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -454,5 +492,5 @@ unregister(token: number): Promise\<void>; | å‚æ•°å | 类型 | 值 | 说明 | | -------- | -------- | -------- | -------- | - | COLLABORATION_SINGLE | number | 0 | 互è”é¢æ¿å•é€‰æ¨¡å¼ã€‚ | - | COLLABORATION_MULTIPLE | number | 1 | 互è”é¢æ¿å¤šé€‰æ¨¡å¼ã€‚ | \ No newline at end of file + | COLLABORATION_SINGLE | number | 0 | 设备选择模å—å•é€‰æ¨¡å¼ã€‚ | + | COLLABORATION_MULTIPLE | number | 1 | 设备选择模å—多选模å¼ã€‚ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md index b5bad4a12fb5be6631b00662311387e9f217dd18..cbb605b604614e67100be55225ba64230b8f4206 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md @@ -49,10 +49,10 @@ let xml = '</note>'; let conv = new convertxml.ConvertXML(); let options = {trim : false, declarationKey:"_declaration", - instructionKey : "_instruction", attributesKey : "_attributes", - textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", - commentKey : "_comment", parentKey : "_parent", typeKey : "_type", - nameKey : "_name", elementsKey : "_elements"} + instructionKey : "_instruction", attributesKey : "_attributes", + textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", + commentKey : "_comment", parentKey : "_parent", typeKey : "_type", + nameKey : "_name", elementsKey : "_elements"} let result = JSON.stringify(conv.convert(xml, options)); console.log(result) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md index 8f6a8e74a15d7acd70863f92abd8c1adc122b956..c48c588a1110c8085feee3a9f88ec5167a7b1f32 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md @@ -44,7 +44,10 @@ dataShareHelper.query(uri, da, columns).then((data) => { }); ``` -## 属性 +## DataShareResultSet +æ供通过查询数æ®åº“生æˆçš„结果集的相关访问方法。 + +### 属性 **系统能力:** SystemCapability.DistributedDataManager.DataShare.Core @@ -55,7 +58,7 @@ dataShareHelper.query(uri, da, columns).then((data) => { | rowCount | number | 是 | 结果集ä¸çš„行数。 | | isClosed | boolean | 是 | æ ‡è¯†å½“å‰ç»“果集是å¦å…³é—。 | -## goToFirstRow +### goToFirstRow goToFirstRow(): boolean @@ -76,7 +79,7 @@ let isGoTOFirstRow = resultSet.goToFirstRow(); console.info('resultSet.goToFirstRow: ' + isGoTOFirstRow); ``` -## goToLastRow +### goToLastRow goToLastRow(): boolean @@ -97,7 +100,7 @@ let isGoToLastRow = resultSet.goToLastRow(); console.info('resultSet.goToLastRow: ' + isGoToLastRow); ``` -## goToNextRow +### goToNextRow goToNextRow(): boolean @@ -118,7 +121,7 @@ let isGoToNextRow = resultSet.goToNextRow(); console.info('resultSet.goToNextRow: ' + isGoToNextRow); ``` -## goToPreviousRow +### goToPreviousRow goToPreviousRow(): boolean @@ -139,7 +142,7 @@ let isGoToPreviousRow = resultSet.goToPreviousRow(); console.info('resultSet.goToPreviousRow: ' + isGoToPreviousRow); ``` -## goTo +### goTo goTo(offset:number): boolean @@ -167,7 +170,7 @@ let isGoTo = resultSet.goTo(goToNum); console.info('resultSet.goTo: ' + isGoTo); ``` -## goToRow +### goToRow goToRow(position: number): boolean @@ -195,7 +198,7 @@ let isGoToRow = resultSet.goToRow(goToRowNum); console.info('resultSet.goToRow: ' + isGoToRow); ``` -## getBlob +### getBlob getBlob(columnIndex: number): Uint8Array @@ -224,7 +227,7 @@ let getBlob = resultSet.getBlob(columnIndex); console.info('resultSet.getBlob: ' + getBlob); ``` -## getString +### getString getString(columnIndex: number): *string* @@ -253,7 +256,7 @@ let getString = resultSet.getString(columnIndex); console.info('resultSet.getString: ' + getString); ``` -## getLong +### getLong getLong(columnIndex: number): number @@ -282,7 +285,7 @@ let getLong = resultSet.getLong(columnIndex); console.info('resultSet.getLong: ' + getLong); ``` -## getDouble +### getDouble getDouble(columnIndex: number): number @@ -311,7 +314,7 @@ let getDouble = resultSet.getDouble(columnIndex); console.info('resultSet.getDouble: ' + getDouble); ``` -## close +### close close(): void @@ -325,7 +328,7 @@ close(): void resultSet.close(); ``` -## getColumnIndex +### getColumnIndex getColumnIndex(columnName: string): number @@ -353,7 +356,7 @@ let getColumnIndex = resultSet.getColumnIndex(ColumnName) console.info('resultSet.getColumnIndex: ' + getColumnIndex); ``` -## getColumnName +### getColumnName getColumnName(columnIndex: number): *string* @@ -381,7 +384,7 @@ let getColumnName = resultSet.getColumnName(columnIndex) console.info('resultSet.getColumnName: ' + getColumnName); ``` -## getDataType +### getDataType getDataType(columnIndex: number): DataType diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-ValuesBucket.md b/zh-cn/application-dev/reference/apis/js-apis-data-ValuesBucket.md index 7190b74c45174c90482e16bc6dc3fe90514628b9..a533ef34ce47b3fa69235a680b92a2c1ae3ca915 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-ValuesBucket.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-ValuesBucket.md @@ -20,7 +20,7 @@ import { ValuesBucket } from '@ohos.data.ValuesBucket'; **系统能力:** SystemCapability.DistributedDataManager.DataShare.Core -| å称 | 说明 | +| 类型 | 说明 | | ------- | -------------------- | | number | 表示å—段类型为数å—。 | | string | 表示å—段类型为å—符串。 | @@ -28,11 +28,10 @@ import { ValuesBucket } from '@ohos.data.ValuesBucket'; ## ValuesBucket -该类型用于å˜å‚¨ä¸€ç³»åˆ—键值对。 +用于å˜å‚¨é”®å€¼å¯¹çš„类型。 **系统能力:** SystemCapability.DistributedDataManager.DataShare.Core -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| [key: string] | [ValueType](#valuetype)\| Uint8Array \| null | 是 | 键的类型为å—符串型;值的类型å¯ä»¥ä¸ºæ•°å—ã€å—符串ã€å¸ƒå°”值ã€æ— 符å·æ•´åž‹8ä½æ•°ç»„ã€ç©ºå€¼ã€‚ | - +| 键类型 | 值类型 | +| ------------- | --------------------------------------------- | +| string | [ValueType](#valuetype)\| Uint8Array \| null | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md index aa8b98db48cf52c477131f2cea304462f2271634..4f8e0a3e017f84fc0e4091881a9a4e756d0ba136 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md @@ -789,7 +789,7 @@ notIn(field: string, value: Array<ValueType>): DataAbilityPredicates **系统能力:** SystemCapability.DistributedDataManager.DataShare.Core。 -| å称 | 说明 | +| 类型 | 说明 | | ------- | -------------------- | | number | 表示值类型为数å—。 | | string | 表示值类型为å—符。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md index a7d360e03bb5ce1e94fea59f9025ae9759af612d..993919600938aba0e516b8d9e65f2fdd5b668663 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @@ -10,7 +10,6 @@ ## å¯¼å…¥æ¨¡å— ```ts -import Ability from '@ohos.application.Ability' import dataShare from '@ohos.data.dataShare' ``` @@ -34,7 +33,7 @@ createDataShareHelper(context: Context, uri: string, callback: AsyncCallback< **示例:** ```ts -import dataShare from '@ohos.data.dataShare' +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let dataShareHelper; @@ -72,7 +71,7 @@ createDataShareHelper(context: Context, uri: string): Promise<DataShareHelper **示例:** ```ts -import dataShare from '@ohos.data.dataShare' +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let dataShareHelper; @@ -88,6 +87,8 @@ dataShare.createDataShareHelper(this.context, uri).then((data) => { DataShare管ç†å·¥å…·å®žä¾‹ï¼Œå¯ä½¿ç”¨æ¤å®žä¾‹è®¿é—®æˆ–管ç†æœåŠ¡ç«¯çš„æ•°æ®ã€‚在调用DataShareHelperæ供的方法å‰ï¼Œéœ€è¦å…ˆé€šè¿‡[createDataShareHelper](#datasharecreatedatasharehelper)构建一个实例。 +æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 + ### openFile openFile(uri: string, mode: string, callback: AsyncCallback<number>): void @@ -109,6 +110,7 @@ openFile(uri: string, mode: string, callback: AsyncCallback<number>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.openFile(uri, "rwt", (err, data) => { if (err != undefined) { @@ -146,6 +148,7 @@ openFile(uri: string, mode: string): Promise<number> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.openFile(uri, "rwt").then((data) => { console.info("openFile succeed, data : " + data); @@ -176,6 +179,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' function onCallback() { console.info("**** Observer on callback ****"); } @@ -204,6 +208,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' function offCallback() { console.info("**** Observer off callback ****"); } @@ -232,6 +237,7 @@ insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); const valueBucket = { "name": "rose", @@ -273,6 +279,7 @@ insert(uri: string, value: ValuesBucket): Promise<number> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); const valueBucket = { "name": "rose1", @@ -301,12 +308,13 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callbac | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦åˆ 除的数æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />delete接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBçš„åˆ é™¤ç›®å‰ä»…支æŒinKeysè°“è¯ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />delete接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBçš„åˆ é™¤ç›®å‰ä»…支æŒinKeysè°“è¯ã€‚ | | callback | AsyncCallback<number> | 是 | 回调函数。当从数æ®åº“ä¸åˆ 除一æ¡æˆ–多æ¡æ•°æ®è®°å½•æˆåŠŸï¼Œerr为undefined,data为获å–åˆ°çš„å·²åˆ é™¤çš„æ•°æ®è®°å½•æ•°ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚<br />å› éƒ¨åˆ†æ•°æ®åº“(如KVDB)的相应接å£å¹¶ä¸æ供相应支æŒï¼Œæ•…è‹¥æœåŠ¡ç«¯ä½¿ç”¨æ¤æ•°æ®åº“,则æ¤callbackä¹Ÿæ— æ³•è¿”å›žåˆ é™¤çš„æ•°æ®è®°å½•æ•°ã€‚ | **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -336,7 +344,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promis | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦åˆ 除的数æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />delete接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBçš„åˆ é™¤ç›®å‰ä»…支æŒinKeysè°“è¯ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />delete接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBçš„åˆ é™¤ç›®å‰ä»…支æŒinKeysè°“è¯ã€‚ | **返回值:** @@ -347,6 +355,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promis **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -374,13 +383,14 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦æŸ¥è¯¢çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />query接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰ä»…支æŒinKeyså’ŒprefixKey。 | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />query接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰ä»…支æŒinKeyså’ŒprefixKey。 | | columns | Array<string> | 是 | 指示è¦æŸ¥è¯¢çš„列。如果æ¤å‚数为空,则查询所有列。 | | callback | AsyncCallback<[DataShareResultSet](js-apis-data-DataShareResultSet.md#datashareresultset)> | 是 | 回调函数。当查询数æ®åº“ä¸çš„æ•°æ®æˆåŠŸï¼Œerr为undefined,data为获å–到的查询到的结果集;å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -411,7 +421,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦æŸ¥è¯¢çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />query接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰ä»…支æŒinKeyså’ŒprefixKey。 | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />query接å£æ‰€æ”¯æŒçš„è°“è¯æ–¹æ³•å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰ä»…支æŒinKeyså’ŒprefixKey。 | | columns | Array<string> | 是 | 指示è¦æŸ¥è¯¢çš„列。如果æ¤å‚数为空,则查询所有列。 | **返回值:** @@ -423,6 +433,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -451,13 +462,14 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦æ›´æ–°çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />update接å£æ˜¯å¦æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰å¹¶ä¸æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶ï¼Œä»…RDB支æŒã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />update接å£æ˜¯å¦æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰å¹¶ä¸æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶ï¼Œä»…RDB支æŒã€‚ | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示è¦æ›´æ–°çš„æ•°æ®ã€‚ | | callback | AsyncCallback<number> | 是 | 回调函数。当更新数æ®åº“ä¸çš„æ•°æ®è®°å½•æˆåŠŸï¼Œerr为undefined,data为获å–到的更新的数æ®è®°å½•æ•°ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚<br />å› éƒ¨åˆ†æ•°æ®åº“(如KVDB)的相应接å£å¹¶ä¸æ供相应支æŒï¼Œæ•…è‹¥æœåŠ¡ç«¯ä½¿ç”¨æ¤æ•°æ®åº“,则æ¤callbackä¹Ÿæ— æ³•è¿”å›žæ›´æ–°çš„æ•°æ®è®°å½•æ•°ã€‚ | **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -493,7 +505,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: | å称 | 类型 | å¿…å¡« | æè¿° | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦æ›´æ–°çš„æ•°æ®çš„路径。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />update接å£æ˜¯å¦æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰å¹¶ä¸æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶ï¼Œä»…RDB支æŒã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示ç›é€‰æ¡ä»¶ã€‚<br />update接å£æ˜¯å¦æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶å–决于æœåŠ¡ç«¯æ‰€é€‰ç”¨çš„æ•°æ®åº“,如KVDBç›®å‰å¹¶ä¸æ”¯æŒè°“è¯ç›é€‰æ¡ä»¶ï¼Œä»…RDB支æŒã€‚ | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示è¦æ›´æ–°çš„æ•°æ®ã€‚ | **返回值:** @@ -505,6 +517,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: **示例:** ```ts +import Ability from '@ohos.application.Ability' import dataSharePredicates from '@ohos.data.dataSharePredicates' let uri = ("datashare:///com.samples.datasharetest.DataShare"); @@ -544,6 +557,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallb **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, {"name": "roe12", "age": 21, "salary": 20.5,}, @@ -583,6 +597,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number&g **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let vbs = new Array({"name": "roe11", "age": 21, "salary": 20.5,}, {"name": "roe12", "age": 21, "salary": 20.5,}, @@ -614,6 +629,7 @@ getType(uri: string, callback: AsyncCallback<string>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.getType(uri, (err, data)=>{ if (err != undefined) { @@ -650,6 +666,7 @@ getType(uri: string): Promise<string> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.getType(uri).then((data) => { console.log("getType succeed, data : " + data); @@ -674,11 +691,12 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Arr | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示è¦èŽ·å–的文件的路径。 | | mimeTypeFilter | string | 是 | 指示è¦ç›é€‰çš„MIME类型。例如:<br />“\*/\*â€ï¼šèŽ·å–支æŒçš„所有类型。<br/>“image/\*â€ï¼šèŽ·å–主类型image,å类型为任何类型的MIME。<br />â€\*/jpgâ€ï¼šèŽ·å–å类型为jpg,主类型为任何类型的MIME。 | -| callback | openFile(uri: string, mode: string, callback: AsyncCallback<number>) {   let err = {"code":0};   let fd = 0;   callback(err,fd);}ts | 是 | 回调函数。当获å–支æŒçš„文件的MIME类型æˆåŠŸï¼Œerr为undefined,data为获å–到的匹é…çš„MIME类型数组;å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| callback | AsyncCallback<Array\<string>> | 是 | 回调函数。当获å–支æŒçš„文件的MIME类型æˆåŠŸï¼Œerr为undefined,data为获å–到的匹é…çš„MIME类型数组;å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let mimeTypeFilter = "image/*"; dataShareHelper.getFileTypes(uri, mimeTypeFilter, (err,data) => { @@ -716,6 +734,7 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise<Array<string> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); let mimeTypeFilter = "image/*"; dataShareHelper.getFileTypes(uri, mimeTypeFilter).then((data) => { @@ -745,6 +764,7 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri, (err, data) => { if (err != undefined) { @@ -780,6 +800,7 @@ normalizeUri(uri: string): Promise<string> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.normalizeUri(uri).then((data) => { console.log("normalizeUri = " + data); @@ -808,6 +829,7 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri, (err, data) => { if (err != undefined) { @@ -843,6 +865,7 @@ denormalizeUri(uri: string): Promise<string> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.denormalizeUri(uri).then((data) => { console.log("denormalizeUri = " + data); @@ -871,6 +894,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.notifyChange(uri, () => { console.log("***** notifyChange *****"); @@ -902,6 +926,7 @@ notifyChange(uri: string): Promise<void> **示例:** ```ts +import Ability from '@ohos.application.Ability' let uri = ("datashare:///com.samples.datasharetest.DataShare"); dataShareHelper.notifyChange(uri); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md index 7838b092adfab89d49626d67e093d056233841e0..91fcd5fa3bcd519cef639c39bdadfeac7b5b11b8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataSharePredicates.md @@ -13,7 +13,10 @@ import dataSharePredicates from '@ohos.data.dataSharePredicates'; ``` -## equalTo +## DataSharePredicates +æ供用于ä¸åŒå®žçŽ°ä¸åŒæŸ¥è¯¢æ–¹æ³•çš„æ•°æ®å…±äº«è°“è¯ã€‚ + +### equalTo equalTo(field: string, value: ValueType): DataSharePredicates @@ -43,7 +46,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Rose") ``` -## notEqualTo +### notEqualTo notEqualTo(field: string, value: ValueType): DataSharePredicates @@ -73,7 +76,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.notEqualTo("NAME", "Rose") ``` -## beginWrap +### beginWrap beginWrap(): DataSharePredicates @@ -99,7 +102,7 @@ predicates.equalTo("NAME", "lisi") .endWrap() ``` -## endWrap +### endWrap endWrap(): DataSharePredicates @@ -125,7 +128,7 @@ predicates.equalTo("NAME", "lisi") .endWrap() ``` -## or +### or or(): DataSharePredicates @@ -150,7 +153,7 @@ predicates.equalTo("NAME", "lisi") .equalTo("NAME", "Rose") ``` -## and +### and and(): DataSharePredicates @@ -175,7 +178,7 @@ predicates.equalTo("NAME", "lisi") .equalTo("SALARY", 200.5) ``` -## contains +### contains contains(field: string, value: string): DataSharePredicates @@ -203,7 +206,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.contains("NAME", "os") ``` -## beginsWith +### beginsWith beginsWith(field: string, value: string): DataSharePredicates @@ -231,7 +234,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.beginsWith("NAME", "os") ``` -## endsWith +### endsWith endsWith(field: string, value: string): DataSharePredicates @@ -259,7 +262,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.endsWith("NAME", "os") ``` -## isNull +### isNull isNull(field: string): DataSharePredicates @@ -288,7 +291,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.isNull("NAME") ``` -## isNotNull +### isNotNull isNotNull(field: string): DataSharePredicates @@ -317,7 +320,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.isNotNull("NAME") ``` -## like +### like like(field: string, value: string): DataSharePredicates @@ -347,7 +350,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.like("NAME", "%os%") ``` -## unlike +### unlike unlike(field: string, value: string): DataSharePredicates @@ -377,7 +380,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.unlike("NAME", "%os%") ``` -## glob +### glob glob(field: string, value: string): DataSharePredicates @@ -405,7 +408,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.glob("NAME", "?h*g") ``` -## between +### between between(field: string, low: ValueType, high: ValueType): DataSharePredicates @@ -434,7 +437,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.between("AGE", 10, 50) ``` -## notBetween +### notBetween notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates @@ -463,7 +466,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.notBetween("AGE", 10, 50) ``` -## greaterThan +### greaterThan greaterThan(field: string, value: ValueType): DataSharePredicates @@ -493,7 +496,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.greaterThan("AGE", 10) ``` -## lessThan +### lessThan lessThan(field: string, value: ValueType): DataSharePredicates @@ -523,7 +526,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.lessThan("AGE", 50) ``` -## greaterThanOrEqualTo +### greaterThanOrEqualTo greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates @@ -553,7 +556,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.greaterThanOrEqualTo("AGE", 10) ``` -## lessThanOrEqualTo +### lessThanOrEqualTo lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates @@ -583,7 +586,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.lessThanOrEqualTo("AGE", 50) ``` -## orderByAsc +### orderByAsc orderByAsc(field: string): DataSharePredicates @@ -612,7 +615,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.orderByAsc("AGE") ``` -## orderByDesc +### orderByDesc orderByDesc(field: string): DataSharePredicates @@ -641,7 +644,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.orderByDesc("AGE") ``` -## distinct +### distinct distinct(): DataSharePredicates @@ -662,7 +665,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Rose").distinct() ``` -## limit +### limit limit(total: number, offset: number): DataSharePredicates @@ -692,7 +695,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.equalTo("NAME", "Rose").limit(10, 3) ``` -## groupBy +### groupBy groupBy(fields: Array<string>): DataSharePredicates @@ -719,7 +722,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.groupBy(["AGE", "NAME"]) ``` -## indexedBy +### indexedBy indexedBy(field: string): DataSharePredicates @@ -746,7 +749,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.indexedBy("SALARY_INDEX") ``` -## in +### in in(field: string, value: Array<ValueType>): DataSharePredicates @@ -776,7 +779,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.in("AGE", [18, 20]) ``` -## notIn +### notIn notIn(field: string, value: Array<ValueType>): DataSharePredicates @@ -806,7 +809,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.notIn("NAME", ["Lisa", "Rose"]) ``` -## prefixKey +### prefixKey prefixKey(prefix: string): DataSharePredicates @@ -833,7 +836,7 @@ let predicates = new dataSharePredicates.DataSharePredicates() predicates.prefixKey("NAME") ``` -## inKeys +### inKeys inKeys(keys: Array<string>): DataSharePredicates diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md index 99bd4b7ea270c1afb786f1e284507b1d726fe868..c58b2ad12209b1fabfd32d7c7e83fa38eec097a3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -307,7 +307,7 @@ g_object.save("local").then((result)=>{ ### revokeSave<sup>9+</sup> -revokeSave(callback: AsyncCallback<SaveSuccessResponse>): void +revokeSave(callback: AsyncCallback<RevokeSaveSuccessResponse>): void 撤回ä¿å˜çš„分布å¼æ•°æ®å¯¹è±¡ã€‚使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ @@ -334,7 +334,7 @@ g_object.revokeSave((result, data) =>{ ### revokeSave<sup>9+</sup> -revokeSave(): Promise<SaveSuccessResponse> +revokeSave(): Promise<RevokeSaveSuccessResponse> 撤回ä¿å˜çš„分布å¼æ•°æ®å¯¹è±¡ã€‚使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 8ed0dd29dfb55764bece703a3d3ef21ba2ed2f8d..827571daedecf93ec7ba80b78565b3a12fa46f28 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -681,7 +681,7 @@ data_preferences.getPreferences(this.context, 'mystore', function (err, preferen **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core -| å称 | 说明 | +| 类型 | 说明 | | -------------- | ------------------------------ | | number | 表示值类型为数å—。 | | string | 表示值类型为å—符串。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md index d66146a2651c473b10eb82089cddd59c0122a32f..ac3e4d5e4c5da4f553e8979f5c972e7338a60308 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md @@ -21,7 +21,7 @@ import data_rdb from '@ohos.data.rdb'; getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void -获得一个相关的RdbStore,æ“作关系型数æ®åº“,用户å¯ä»¥æ ¹æ®è‡ªå·±çš„需求é…ç½®RdbStoreçš„å‚数,然åŽé€šè¿‡RdbStore调用相关接å£å¯ä»¥æ‰§è¡Œç›¸å…³çš„æ•°æ®æ“作,结果以callbackå½¢å¼è¿”回。 +获得一个相关的RdbStore,æ“作关系型数æ®åº“,用户å¯ä»¥æ ¹æ®è‡ªå·±çš„需求é…ç½®RdbStoreçš„å‚数,然åŽé€šè¿‡RdbStore调用相关接å£å¯ä»¥æ‰§è¡Œç›¸å…³çš„æ•°æ®æ“作,使用callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -51,7 +51,7 @@ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore> -获得一个相关的RdbStore,æ“作关系型数æ®åº“,用户å¯ä»¥æ ¹æ®è‡ªå·±çš„需求é…ç½®RdbStoreçš„å‚数,然åŽé€šè¿‡RdbStore调用相关接å£å¯ä»¥æ‰§è¡Œç›¸å…³çš„æ•°æ®æ“作,结果以Promiseå½¢å¼è¿”回。 +获得一个相关的RdbStore,æ“作关系型数æ®åº“,用户å¯ä»¥æ ¹æ®è‡ªå·±çš„需求é…ç½®RdbStoreçš„å‚数,然åŽé€šè¿‡RdbStore调用相关接å£å¯ä»¥æ‰§è¡Œç›¸å…³çš„æ•°æ®æ“作,使用Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -85,7 +85,7 @@ promise.then(async (rdbStore) => { deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void -åˆ é™¤æ•°æ®åº“,结果以callbackå½¢å¼è¿”回。 +åˆ é™¤æ•°æ®åº“,使用callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -111,7 +111,7 @@ data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) { deleteRdbStore(context: Context, name: string): Promise<void> -使用指定的数æ®åº“文件é…ç½®åˆ é™¤æ•°æ®åº“,结果以Promiseå½¢å¼è¿”回。 +使用指定的数æ®åº“文件é…ç½®åˆ é™¤æ•°æ®åº“,使用Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -953,7 +953,7 @@ predicates.notIn("NAME", ["Lisa", "Rose"]) insert(table: string, values: ValuesBucket, callback: AsyncCallback<number>):void -å‘ç›®æ ‡è¡¨ä¸æ’入一行数æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +å‘ç›®æ ‡è¡¨ä¸æ’入一行数æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -972,12 +972,12 @@ const valueBucket = { "SALARY": 100.5, "CODES": new Uint8Array([1, 2, 3, 4, 5]), } -rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { - if (err) { - console.info("Insert failed, err: " + err) - return +rdbStore.insert("EMPLOYEE", valueBucket, function (status, rowId) { + if (status) { + console.log("Insert is failed"); + return; } - console.log("Insert first done: " + ret) + console.log("Insert is successful, rowId = " + rowId); }) ``` @@ -986,7 +986,7 @@ rdbStore.insert("EMPLOYEE", valueBucket, function (err, ret) { insert(table: string, values: ValuesBucket):Promise<number> -å‘ç›®æ ‡è¡¨ä¸æ’入一行数æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +å‘ç›®æ ‡è¡¨ä¸æ’入一行数æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1010,19 +1010,113 @@ const valueBucket = { "CODES": new Uint8Array([1, 2, 3, 4, 5]), } let promise = rdbStore.insert("EMPLOYEE", valueBucket) -promise.then(async (ret) => { - console.log("Insert first done: " + ret) -}).catch((err) => { - console.log("Insert failed, err: " + err) +promise.then((rowId) => { + console.log("Insert is successful, rowId = " + rowId); +}).catch((status) => { + console.log("Insert is failed"); +}) +``` + +### batchInsert<sup>9+</sup> + +batchInsert(table: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>):void + +å‘ç›®æ ‡è¡¨ä¸æ’入一组数æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | +| values | Array<[ValuesBucket](#valuesbucket)> | 是 | 表示è¦æ’入到表ä¸çš„一组数æ®ã€‚ | +| callback | AsyncCallback<number> | 是 | 指定callback回调函数。如果æ“作æˆåŠŸï¼Œè¿”回æ’入的数æ®ä¸ªæ•°ï¼Œå¦åˆ™è¿”回-1。 | + +**示例:** +```js +const valueBucket1 = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]) +} +const valueBucket2 = { + "NAME": "Jack", + "AGE": 19, + "SALARY": 101.5, + "CODES": new Uint8Array([6, 7, 8, 9, 10]) +} +const valueBucket3 = { + "NAME": "Tom", + "AGE": 20, + "SALARY": 102.5, + "CODES": new Uint8Array([11, 12, 13, 14, 15]) +} + +var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); +rdbStore.batchInsert("EMPLOYEE", valueBuckets, function(status, insertNum) { + if (status) { + console.log("bathInsert is failed, status = " + status); + return; + } + console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); }) ``` +### batchInsert<sup>9+</sup> + +batchInsert(table: string, values: Array<ValuesBucket>):Promise<number> + +å‘ç›®æ ‡è¡¨ä¸æ’入一组数æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | +| values | Array<[ValuesBucket](#valuesbucket)> | 是 | 表示è¦æ’入到表ä¸çš„一组数æ®ã€‚ | + +**返回值**: +| 类型 | 说明 | +| -------- | -------- | +| Promise<number> | 指定Promise回调函数。如果æ“作æˆåŠŸï¼Œè¿”回æ’入的数æ®ä¸ªæ•°ï¼Œå¦åˆ™è¿”回-1。 | + +**示例:** +```js +const valueBucket1 = { + "NAME": "Lisa", + "AGE": 18, + "SALARY": 100.5, + "CODES": new Uint8Array([1, 2, 3, 4, 5]) +} +const valueBucket2 = { + "NAME": "Jack", + "AGE": 19, + "SALARY": 101.5, + "CODES": new Uint8Array([6, 7, 8, 9, 10]) +} +const valueBucket3 = { + "NAME": "Tom", + "AGE": 20, + "SALARY": 102.5, + "CODES": new Uint8Array([11, 12, 13, 14, 15]) +} + +var valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); +let promise = rdbStore.batchInsert("EMPLOYEE", valueBuckets); +promise.then((insertNum) => { + console.log("bathInsert is successful, the number of values that were inserted = " + insertNum); +}).catch((status) => { + console.log("bathInsert is failed, status = " + status); +}) +``` ### update update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback<number>):void -æ ¹æ®RdbPredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®RdbPredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1057,7 +1151,7 @@ rdbStore.update(valueBucket, predicates, function (err, ret) { update(values: ValuesBucket, predicates: RdbPredicates):Promise<number> -æ ¹æ®RdbPredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®RdbPredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1093,7 +1187,7 @@ promise.then(async (ret) => { ### update<sup>9+</sup> update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void -æ ¹æ®DataSharePredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®DataSharePredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1102,7 +1196,7 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data | -------- | -------- | -------- | -------- | | table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | | values | [ValuesBucket](#valuesbucket) | 是 | values指示数æ®åº“ä¸è¦æ›´æ–°çš„æ•°æ®è¡Œã€‚键值对与数æ®åº“表的列å相关è”。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates)| 是 | DataSharePredicates的实例对象指定的更新æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates)| 是 | DataSharePredicates的实例对象指定的更新æ¡ä»¶ã€‚ | | callback | AsyncCallback<number> | 是 | 指定的callback回调方法。返回å—å½±å“的行数。 | **示例:** @@ -1128,7 +1222,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise<number> -æ ¹æ®DataSharePredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®DataSharePredicates的指定实例对象更新数æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1137,7 +1231,7 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data | -------- | -------- | -------- | -------- | | table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | | values | [ValuesBucket](#valuesbucket) | 是 | values指示数æ®åº“ä¸è¦æ›´æ–°çš„æ•°æ®è¡Œã€‚键值对与数æ®åº“表的列å相关è”。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的更新æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的更新æ¡ä»¶ã€‚ | **返回值**: | 类型 | 说明 | @@ -1168,7 +1262,7 @@ promise.then(async (ret) => { delete(predicates: RdbPredicates, callback: AsyncCallback<number>):void -æ ¹æ®RdbPredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®RdbPredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1196,7 +1290,7 @@ rdbStore.delete(predicates, function (err, rows) { delete(predicates: RdbPredicates):Promise<number> -æ ¹æ®RdbPredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®RdbPredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1227,7 +1321,7 @@ promise.then((rows) => { delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>):void -æ ¹æ®DataSharePredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®DataSharePredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1235,7 +1329,7 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callb | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicatesçš„å®žä¾‹å¯¹è±¡æŒ‡å®šçš„åˆ é™¤æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicatesçš„å®žä¾‹å¯¹è±¡æŒ‡å®šçš„åˆ é™¤æ¡ä»¶ã€‚ | | callback | AsyncCallback<number> | 是 | 指定callback回调函数。返回å—å½±å“的行数。 | **示例:** @@ -1255,7 +1349,7 @@ rdbStore.delete("EMPLOYEE", predicates, function (err, rows) { delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise<number> -æ ¹æ®DataSharePredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®DataSharePredicates的指定实例对象从数æ®åº“ä¸åˆ 除数æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1263,7 +1357,7 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promi | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicatesçš„å®žä¾‹å¯¹è±¡æŒ‡å®šçš„åˆ é™¤æ¡ä»¶ã€‚ | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicatesçš„å®žä¾‹å¯¹è±¡æŒ‡å®šçš„åˆ é™¤æ¡ä»¶ã€‚ | **返回值**: | 类型 | 说明 | @@ -1287,7 +1381,7 @@ promise.then((rows) => { query(predicates: RdbPredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void -æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1317,7 +1411,7 @@ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (e query(predicates: RdbPredicates, columns?: Array<string>):Promise<ResultSet> -æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1347,16 +1441,17 @@ query(predicates: RdbPredicates, columns?: Array<string>):Promise<Resul ### query<sup>9+</sup> -query(predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void +query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array<string>, callback: AsyncCallback<ResultSet>):void -æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的查询æ¡ä»¶ã€‚ | +| table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的查询æ¡ä»¶ã€‚ | | columns | Array<string> | 是 | 表示è¦æŸ¥è¯¢çš„列。如果值为空,则查询应用于所有列。 | | callback | AsyncCallback<[ResultSet](js-apis-data-resultset.md)> | 是 | 指定callback回调函数。如果æ“作æˆåŠŸï¼Œåˆ™è¿”回ResultSet对象。 | @@ -1377,16 +1472,17 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], ### query<sup>9+</sup> -query(predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> +query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array<string>):Promise<ResultSet> -æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šæ¡ä»¶æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的查询æ¡ä»¶ã€‚ | +| table | string | 是 | æŒ‡å®šçš„ç›®æ ‡è¡¨å。 | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | DataSharePredicates的实例对象指定的查询æ¡ä»¶ã€‚ | | columns | Array<string> | å¦ | 表示è¦æŸ¥è¯¢çš„列。如果值为空,则查询应用于所有列。 | **返回值**: @@ -1412,7 +1508,7 @@ promise.then((resultSet) => { querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void -æ ¹æ®æŒ‡å®šSQLè¯å¥æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以callbackå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šSQLè¯å¥æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1440,7 +1536,7 @@ rdbStore.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> -æ ¹æ®æŒ‡å®šSQLè¯å¥æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +æ ¹æ®æŒ‡å®šSQLè¯å¥æŸ¥è¯¢æ•°æ®åº“ä¸çš„æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1471,7 +1567,7 @@ promise.then((resultSet) => { executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<void>):void -执行包å«æŒ‡å®šå‚数但ä¸è¿”回值的SQLè¯å¥ï¼Œç»“果以callbackå½¢å¼è¿”回。 +执行包å«æŒ‡å®šå‚数但ä¸è¿”回值的SQLè¯å¥ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1499,7 +1595,7 @@ rdbStore.executeSql(SQL_CREATE_TABLE, null, function(err) { executeSql(sql: string, bindArgs?: Array<ValueType>):Promise<void> -执行包å«æŒ‡å®šå‚数但ä¸è¿”回值的SQLè¯å¥ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +执行包å«æŒ‡å®šå‚数但ä¸è¿”回值的SQLè¯å¥ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1584,7 +1680,7 @@ rdbStore.commit() ### rollBack<sup>8+</sup> -rollBack():void; +rollBack():void 回滚已ç»æ‰§è¡Œçš„SQLè¯å¥ã€‚ @@ -1618,7 +1714,7 @@ try { backup(destName:string, callback: AsyncCallback<void>):void -以指定å称备份数æ®åº“,结果以callbackå½¢å¼è¿”回。 +以指定å称备份数æ®åº“,使用callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1643,7 +1739,7 @@ rdbStore.backup("dbBackup.db", function(err) { backup(destName:string): Promise<void> -以指定å称备份数æ®åº“,结果以promiseå½¢å¼è¿”回。 +以指定å称备份数æ®åº“,使用Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1671,7 +1767,7 @@ promiseBackup.then(()=>{ restore(srcName:string, callback: AsyncCallback<void>):void -从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,结果以callbackå½¢å¼è¿”回。 +从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,使用callback异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1696,7 +1792,7 @@ rdbStore.restore("dbBackup.db", function(err) { restore(srcName:string): Promise<void> -从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,结果以promiseå½¢å¼è¿”回。 +从指定的数æ®åº“备份文件æ¢å¤æ•°æ®åº“,使用Promise异æ¥å›žè°ƒã€‚ **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core。 @@ -1724,7 +1820,7 @@ promiseRestore.then(()=>{ setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void -设置分布å¼åˆ—表,结果以callbackå½¢å¼è¿”回。 +设置分布å¼åˆ—表,使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1752,7 +1848,7 @@ rdbStore.setDistributedTables(["EMPLOYEE"], function (err) { setDistributedTables(tables: Array<string>): Promise<void> -设置分布å¼åˆ—表,结果以Promiseå½¢å¼è¿”回。 +设置分布å¼åˆ—表,使用Promise异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1782,7 +1878,7 @@ promise.then(() => { obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void -æ ¹æ®æœ¬åœ°è¡¨å获å–指定远程设备的分布å¼è¡¨å。在查询远程设备数æ®åº“时,需è¦ä½¿ç”¨åˆ†å¸ƒå¼è¡¨å, 结果以callbackå½¢å¼è¿”回。 +æ ¹æ®æœ¬åœ°è¡¨å获å–指定远程设备的分布å¼è¡¨å。在查询远程设备数æ®åº“时,需è¦ä½¿ç”¨åˆ†å¸ƒå¼è¡¨å, 使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1811,7 +1907,7 @@ rdbStore.obtainDistributedTableName("12345678abcde", "EMPLOYEE", function (err, obtainDistributedTableName(device: string, table: string): Promise<string> -æ ¹æ®æœ¬åœ°è¡¨å获å–指定远程设备的分布å¼è¡¨å。在查询远程设备数æ®åº“时,需è¦ä½¿ç”¨åˆ†å¸ƒå¼è¡¨å,结果以Promiseå½¢å¼è¿”回。 +æ ¹æ®æœ¬åœ°è¡¨å获å–指定远程设备的分布å¼è¡¨å。在查询远程设备数æ®åº“时,需è¦ä½¿ç”¨åˆ†å¸ƒå¼è¡¨å,使用Promise异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1842,7 +1938,7 @@ promise.then((tableName) => { sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void -在设备之间åŒæ¥æ•°æ®, 结果以callbackå½¢å¼è¿”回。 +在设备之间åŒæ¥æ•°æ®, 使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1876,7 +1972,7 @@ rdbStore.sync(data_rdb.SyncMode.SYNC_MODE_PUSH, predicates, function (err, resul sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>> -在设备之间åŒæ¥æ•°æ®ï¼Œç»“果以Promiseå½¢å¼è¿”回。 +在设备之间åŒæ¥æ•°æ®ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1945,7 +2041,7 @@ try { off(event:'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void -从数æ®åº“ä¸åˆ 除指定类型的指定观察者, 结果以callbackå½¢å¼è¿”回。 +从数æ®åº“ä¸åˆ 除指定类型的指定观察者, 使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.DISTRIBUTED_DATASYNC @@ -1990,7 +2086,7 @@ try { **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedDataManager.RelationalStore.Core。 -| å称 | 说明 | +| 类型 | 说明 | | -------- | -------- | | number | 表示值类型为数å—。 | | string | 表示值类型为å—符。 | @@ -1999,14 +2095,13 @@ try { ## ValuesBucket -用于å˜å‚¨é”®å€¼å¯¹ã€‚ +用于å˜å‚¨é”®å€¼å¯¹çš„类型。 **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedDataManager.RelationalStore.Core。 -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| [key: string] | [ValueType](#valuetype)\| Uint8Array \| null | 是 | 用于å˜å‚¨é”®å€¼å¯¹ã€‚ | - +| 键类型 | 值类型 | +| -------- | -------- | +| string | [ValueType](#valuetype)\| Uint8Array \| null | ## SyncMode<sup>8+</sup> diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index e0e2307ced5b2ace2a6699cd070f0fc37f6938c9..bf111b8806a4bce5cf224b160ea3746e2b688913 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -793,7 +793,7 @@ off(type: 'change', callback: Callback<StorageObserver>): void **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core -| å称 | 说明 | +| 类型 | 说明 | | ------- | -------------------- | | number | 表示值类型为数å—。 | | string | 表示值类型为å—符。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 3810f7281a58ec11c0dbf0b7e6e376be05fd66fe..be98b82dab1e822070f37cf16c69135b7f2ffba7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -662,7 +662,7 @@ DAHelper.delete( ## DataAbilityHelper.delete -delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\<number> +delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\<number>; 从数æ®åº“ä¸åˆ 除一个或多个数æ®è®°å½•ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -685,7 +685,7 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\<num ```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.dataAbility' +import ohos_data_ability from '@ohos.data.dataAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -741,7 +741,7 @@ DAHelper.update( ## DataAbilityHelper.update -update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\<number> +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.DataAbilityPredicates): Promise\<number>; æ›´æ–°æ•°æ®åº“ä¸çš„æ•°æ®è®°å½•ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -825,7 +825,7 @@ DAHelper.query( ## DataAbilityHelper.query -query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates): Promise\<ResultSet> +query(uri: string, columns?: Array\<string>, predicates?: dataAbility.DataAbilityPredicates): Promise\<ResultSet>; 查询数æ®åº“ä¸çš„æ•°æ®ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -932,8 +932,107 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", " console.info('Operation succeeded: ' + data); }); ``` + +## DataAbilityHelper.executeBatch + +executeBatch(uri: string, operations: Array\<DataAbilityOperation>, callback: AsyncCallback\<Array\<DataAbilityResult>>): void; + +查询数æ®åº“ä¸çš„æ•°æ®ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指定待处ç†çš„DataAbility。例:"dataability:///com.example.xxx.xxxx"。| +| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | 是 | 指示数æ®æ“作列表,其ä¸å¯ä»¥åŒ…å«å¯¹æ•°æ®åº“的多个æ“作。 | +| callback | AsyncCallback\<Array\<[DataAbilityResult](#dataabilityresult)>> | 是 |在数组 DataAbilityResultä¸è¿”回æ¯ä¸ªæ“作的结果。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility'; + +// æ ¹æ®DataAbilityOperation列表选择è¦å¯¹æ•°æ®åº“åšçš„æ“作 +let op=new Array(); +let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility"); +dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility", op, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + err); + return; + } + console.info('Operation succeeded: ' + data); +}); +``` + +## DataAbilityHelper.executeBatch + +executeBatch(uri: string, operations: Array\<DataAbilityOperation>): Promise\<Array\<DataAbilityResult>>; + +查询数æ®åº“ä¸çš„æ•°æ®ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel + +**å‚数:** + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------- | -------------------------------| ---- | ------------------------------------------------ | +| uri | string | 是 | 指定待处ç†çš„DataAbility。例:"dataability:///com.example.xxx.xxxx"。| +| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | 是 | 指示数æ®æ“作列表,其ä¸å¯ä»¥åŒ…å«å¯¹æ•°æ®åº“的多个æ“作。 | + +**返回值:** + +| 类型 | 说明 | +|------ | ------- | +|Promise\<Array\<[DataAbilityResult](#dataabilityresult)>> | 在数组 DataAbilityResultä¸è¿”回æ¯ä¸ªæ“作的结果。 | + +**示例:** + +```js +import featureAbility from '@ohos.ability.featureAbility'; + +// æ ¹æ®DataAbilityOperation列表选择è¦å¯¹æ•°æ®åº“åšçš„æ“作 +let op=new Array(); +let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility"); +dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility",op ).then((data) => { + console.info('Operation succeeded: ' + data); +}).catch((error) => { + console.error('Operation failed. Cause: ' + error); +}); + +``` + ## PacMap +[key: string]: number | string | boolean | Array\<string | number | boolean> | null; + +**系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel + | å称 | å‚数类型 | å¿…å¡« | 说明 | | ------ | ------ | ------ | ------ | -| [key: string] | number \| string \| boolean \| Array\<string \| number \| boolean\> \| null | 是 | æ•°æ®å˜å‚¨åœ¨é”®å€¼å¯¹ä¸ã€‚ | \ No newline at end of file +| [key: string] | number \| string \| boolean \| Array\<string \| number \| boolean\> \| null | Yes| æ•°æ®å˜å‚¨åœ¨é”®å€¼å¯¹ä¸ã€‚| + +## DataAbilityOperation + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.FAModel + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | å¿…å¡«| 说明 | +| -------- | -------- | -------- | -------- | --------| -------- | +| uri | string | 是 | å¦ | 是 | 指定待处ç†çš„DataAbility。例:"dataability:///com.example.xxx.xxxx"。 | +| type | featureAbility.DataAbilityOperationType | 是 | å¦ | 是 | 指示æ“作类型。 | +| valuesBucket? | rdb.ValuesBucket | 是 | å¦ | å¦ | 指示è¦è®¾ç½®çš„æ•°æ®å€¼ã€‚ | +| valueBackReferences? | rdb.ValuesBucket | 是 | å¦ | å¦ | 指示包å«ä¸€ç»„键值对的valuesBucket对象。 | +| predicates? | dataAbility.DataAbilityPredicates | 是 | å¦ | å¦ | 指示è¦è®¾ç½®çš„ç›é€‰æ¡ä»¶ã€‚如果æ¤å‚数为空,则所有数æ®è®°å½•ã€‚ | +| predicatesBackReferences? | Map\<number, number> | 是 | å¦ | å¦ | 指示用作谓è¯ä¸ç›é€‰æ¡ä»¶çš„åå‘引用。 | +| interrupted? | boolean | 是 | å¦ | å¦ | 指定是å¦å¯ä»¥ä¸æ–批处ç†æ“作。 | +| expectedCount? | number | 是 | å¦ | å¦ | 指示è¦æ›´æ–°æˆ–åˆ é™¤çš„é¢„æœŸè¡Œæ•°ã€‚ | + +## DataAbilityResult + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.FAModel + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| uri? | string | 是 | å¦ | å¦ | 指定待处ç†çš„DataAbility。例:"dataability:///com.example.xxx.xxxx"。 | +| count? | number | 是 | å¦ | å¦ | 指示å—æ“作影å“的行数。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md index d37d15441adf61ff9df73d4728ac94ce973432b0..21a164bd5006b04eb34b932d543a8deed0419420 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-device-manager.md @@ -9,7 +9,7 @@ - 认è¯å’Œå–消认è¯è®¾å¤‡ - 查询å¯ä¿¡è®¾å¤‡åˆ—表 - 查询本地设备信æ¯ï¼ŒåŒ…括设备åç§°ï¼Œè®¾å¤‡ç±»åž‹å’Œè®¾å¤‡æ ‡è¯† - +- å‘布设备å‘现 > **说明:** > > - 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 @@ -32,10 +32,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | bundleName | string | 是 | 指示应用程åºçš„包å。 | - | callback | AsyncCallback<[DeviceManager](#devicemanager)> | 是 | DeviceManager实例创建时调用的回调,返回设备管ç†å™¨å¯¹è±¡å®žä¾‹ã€‚ | + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | ---------- | ---------------------------------------- | ---- | ------------------------------------ | + | bundleName | string | 是 | 指示应用程åºçš„包å。 | + | callback | AsyncCallback<[DeviceManager](#devicemanager)> | 是 | DeviceManager实例创建时调用的回调,返回设备管ç†å™¨å¯¹è±¡å®žä¾‹ã€‚ | - 示例: ``` @@ -45,7 +45,7 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager return; } console.info("createDeviceManager success"); - this.dmInstance = data; + let dmInstance = data; }); ``` @@ -55,13 +55,13 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -| deviceId | string | 是 | è®¾å¤‡çš„å”¯ä¸€æ ‡è¯†ã€‚ | -| deviceName | string | 是 | 设备å称。 | -| deviceType | [DeviceType](#deviceType) | 是 | 设备类型。 | -| networkId<sup>8+</sup> | string | 是 | è®¾å¤‡ç½‘ç»œæ ‡è¯†ã€‚ | - +| å称 | 类型 | å¿…å¡« | æè¿° | +| ---------------------- | ------------------------- | ---- | -------- | +| deviceId | string | 是 | è®¾å¤‡çš„å”¯ä¸€æ ‡è¯†ã€‚ | +| deviceName | string | 是 | 设备å称。 | +| deviceType | [DeviceType](#devicetype) | 是 | 设备类型。 | +| networkId<sup>8+</sup> | string | 是 | è®¾å¤‡ç½‘ç»œæ ‡è¯†ã€‚ | +| range<sup>9+</sup> | number | 是 | å‘现设备的è·ç¦»ã€‚ | ## DeviceType @@ -69,15 +69,15 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| SPEAKER | 0x0A | 智能音箱 | -| PHONE | 0x0E | 手机 | -| TABLET | 0x11 | å¹³æ¿ | -| WEARABLE | 0x6D | 智能穿戴 | -| TV | 0x9C | æ™ºæ…§å± | -| CAR | 0x83 | 车 | -| UNKNOWN_TYPE | 0 | 未知设备 | +| å称 | 默认值 | 说明 | +| ------------ | ---- | ---- | +| SPEAKER | 0x0A | 智能音箱 | +| PHONE | 0x0E | 手机 | +| TABLET | 0x11 | å¹³æ¿ | +| WEARABLE | 0x6D | 智能穿戴 | +| TV | 0x9C | æ™ºæ…§å± | +| CAR | 0x83 | 车 | +| UNKNOWN_TYPE | 0 | 未知设备 | ## DeviceStateChangeAction @@ -86,12 +86,12 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| ONLINE | 0 | 设备上线。 | -| READY | 1 | 设备就绪,设备信æ¯åŒæ¥å·²å®Œæˆã€‚ | -| OFFLINE | 2 | 设备下线。 | -| CHANGE | 3 | 设备信æ¯æ›´æ”¹ã€‚ | +| å称 | 默认值 | 说明 | +| ------- | ---- | --------------- | +| ONLINE | 0 | 设备上线。 | +| READY | 1 | 设备就绪,设备信æ¯åŒæ¥å·²å®Œæˆã€‚ | +| OFFLINE | 2 | 设备下线。 | +| CHANGE | 3 | 设备信æ¯æ›´æ”¹ã€‚ | ## SubscribeInfo @@ -99,15 +99,15 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -| subscribeId | number | 是 | å‘çŽ°æ ‡è¯†ï¼Œç”¨äºŽæ ‡è¯†ä¸åŒçš„å‘现周期。 | -| mode | [DiscoverMode ](#discoverMode) | å¦ | å‘现模å¼ã€‚ | -| medium | [ExchangeMedium](#exchangeMedium) | å¦ | å‘现类型。 | -| freq | [ExchangeFreq](#exchangeFreq) | å¦ | å‘现频率。 | -| isSameAccount | boolean | å¦ | 是å¦åŒè´¦å·ã€‚ | -| isWakeRemote | boolean | å¦ | 是å¦å”¤é†’设备。 | -| capability | [SubscribeCap](#subscribeCap) | å¦ | å‘现能力。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------------- | --------------------------------- | ---- | ----------------- | +| subscribeId | number | 是 | å‘çŽ°æ ‡è¯†ï¼Œç”¨äºŽæ ‡è¯†ä¸åŒçš„å‘现周期。 | +| mode | [DiscoverMode ](#discovermode) | å¦ | å‘现模å¼ã€‚ | +| medium | [ExchangeMedium](#exchangemedium) | å¦ | å‘现类型。 | +| freq | [ExchangeFreq](#exchangefreq) | å¦ | å‘现频率。 | +| isSameAccount | boolean | å¦ | 是å¦åŒè´¦å·ã€‚ | +| isWakeRemote | boolean | å¦ | 是å¦å”¤é†’设备。 | +| capability | [SubscribeCap](#subscribecap) | å¦ | å‘现能力。 | ## DiscoverMode @@ -116,10 +116,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | +| å称 | 默认值 | 说明 | +| --------------------- | ---- | ----- | | DISCOVER_MODE_PASSIVE | 0x55 | 被动模å¼ã€‚ | -| DISCOVER_MODE_ACTIVE | 0xAA | 主动模å¼ã€‚ | +| DISCOVER_MODE_ACTIVE | 0xAA | 主动模å¼ã€‚ | ## ExchangeMedium @@ -128,12 +128,12 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| AUTO | 0 | 自动å‘现类型。 | -| BLE | 1 | è“牙å‘现类型。 | -| COAP | 2 | WiFiå‘现类型。 | -| USB | 3 | USBå‘现类型。 | +| å称 | 默认值 | 说明 | +| ---- | ---- | --------- | +| AUTO | 0 | 自动å‘现类型。 | +| BLE | 1 | è“牙å‘现类型。 | +| COAP | 2 | WiFiå‘现类型。 | +| USB | 3 | USBå‘现类型。 | ## ExchangeFreq @@ -141,12 +141,12 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| LOW | 0 | 低频率。 | -| MID | 1 | ä¸é¢‘率。 | -| HIGH | 2 | 高频率。 | -| SUPER_HIGH | 3 | 超高频率。 | +| å称 | 默认值 | 说明 | +| ---------- | ---- | ----- | +| LOW | 0 | 低频率。 | +| MID | 1 | ä¸é¢‘率。 | +| HIGH | 2 | 高频率。 | +| SUPER_HIGH | 3 | 超高频率。 | ## SubscribeCap @@ -155,10 +155,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,åŽç»ä¼šè¢«åºŸå¼ƒã€‚ | -| SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 | +| å称 | 默认值 | 说明 | +| ------------------------- | ---- | -------------- | +| SUBSCRIBE_CAPABILITY_DDMP | 0 | DDMP能力,åŽç»ä¼šè¢«åºŸå¼ƒã€‚ | +| SUBSCRIBE_CAPABILITY_OSD | 1 | OSD能力。 | ## AuthParam @@ -167,10 +167,10 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -| authType | number | 是 | 认è¯ç±»åž‹ã€‚ | -| extraInfo | {[key:string] : any} | å¦ | 认è¯å‚æ•°å¯æ‰©å±•å—段。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| --------- | -------------------- | ---- | ---------- | +| authType | number | 是 | 认è¯ç±»åž‹ã€‚ | +| extraInfo | {[key:string] : any} | å¦ | 认è¯å‚æ•°å¯æ‰©å±•å—段。 | ## AuthInfo @@ -178,12 +178,24 @@ createDeviceManager(bundleName: string, callback: AsyncCallback<DeviceManager **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager -| å称 | 类型 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -| authType | number | 是 | 认è¯ç±»åž‹ã€‚ | -| token | number | 是 | 认è¯Token。 | -| extraInfo | {[key:string] : any} | å¦ | 认è¯ä¿¡æ¯å¯æ‰©å±•å—段。 | +| å称 | 类型 | å¿…å¡« | æè¿° | +| --------- | -------------------- | ---- | ---------- | +| authType | number | 是 | 认è¯ç±»åž‹ã€‚ | +| token | number | 是 | 认è¯Token。 | +| extraInfo | {[key:string] : any} | å¦ | 认è¯ä¿¡æ¯å¯æ‰©å±•å—段。 | +## PublishInfo + +å‘布设备å‚æ•° + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.DistributedHardware.DeviceManager + +| å称 | 类型 | å¿…å¡« | æè¿° | +| ------------- | --------------------------------- | ---- | ----------------- | +| publishId | number | 是 | å‘å¸ƒè®¾å¤‡æ ‡è¯†ï¼Œç”¨äºŽæ ‡è¯†ä¸åŒçš„å‘布周期。 | +| mode | [DiscoverMode ](#discovermode) | 是 | å‘现模å¼ã€‚ | +| freq | [ExchangeFreq](#exchangefreq) | 是 | å‘现频率。 | +| ranging | boolean | 是 | å‘布的设备是å¦æ”¯æŒæµ‹è·èƒ½åŠ›ã€‚ | ## DeviceManager @@ -213,8 +225,8 @@ getTrustedDeviceListSync(): Array<DeviceInfo> **系统能力**:SystemCapability.DistributedHardware.DeviceManager - 返回值: - | å称 | 说明 | - | -------- | -------- | + | å称 | 说明 | + | -------------------------------------- | --------- | | Array<[DeviceInfo](#deviceinfo)> | 返回å¯ä¿¡è®¾å¤‡åˆ—表。 | - 示例: @@ -232,9 +244,9 @@ getTrustedDeviceList(callback:AsyncCallback<Array<DeviceInfo>>): voi **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | 是 | 获å–所有å¯ä¿¡è®¾å¤‡åˆ—表的回调,返回设备信æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | --------------------- | + | callback | AsyncCallback<Array<[DeviceInfo](#deviceinfo)>> | 是 | 获å–所有å¯ä¿¡è®¾å¤‡åˆ—表的回调,返回设备信æ¯ã€‚ | - 示例: ```js @@ -254,8 +266,8 @@ getTrustedDeviceList(): Promise<Array<DeviceInfo>> **系统能力**:SystemCapability.DistributedHardware.DeviceManager - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------------------- | --------------------- | | Promise<Array<[DeviceInfo](#deviceinfo)>> | Promise实例,用于获å–异æ¥è¿”回结果。 | - 示例: @@ -276,8 +288,8 @@ getLocalDeviceInfoSync(): [DeviceInfo](#deviceinfo) **系统能力**:SystemCapability.DistributedHardware.DeviceManager - 返回值: - | å称 | 说明 | - | -------- | -------- | + | å称 | 说明 | + | -------------------------------------- | --------- | | Array<[DeviceInfo](#deviceinfo)> | 返回本地设备列表。 | - 示例: @@ -295,9 +307,9 @@ getLocalDeviceInfo(callback:AsyncCallback<DeviceInfo>): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | 是 | 获å–本地设备信æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | --------- | + | callback | AsyncCallback<[DeviceInfo](#deviceinfo)> | 是 | 获å–本地设备信æ¯ã€‚ | - 示例: ```js @@ -317,8 +329,8 @@ getLocalDeviceInfo(): Promise<DeviceInfo> **系统能力**:SystemCapability.DistributedHardware.DeviceManager - 返回值: - | 类型 | 说明 | - | -------- | -------- | + | 类型 | 说明 | + | ---------------------------------------- | --------------------- | | Promise<[DeviceInfo](#deviceinfo)> | Promise实例,用于获å–异æ¥è¿”回结果。 | - 示例: @@ -339,9 +351,9 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | subscribeInfo | [SubscribeInfo](#subscribeInfo) | 是 | å‘现信æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ------------- | ------------------------------- | ---- | ----- | + | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | å‘现信æ¯ã€‚ | - 示例: ```js @@ -359,6 +371,45 @@ startDeviceDiscovery(subscribeInfo: SubscribeInfo): void dmInstance.startDeviceDiscovery(subscribeInfo); //当有设备å‘现时,通过deviceFoundå›žè°ƒé€šçŸ¥ç»™åº”ç”¨ç¨‹åº ``` +### startDeviceDiscovery9+</sup> + +startDeviceDiscovery(subscribeInfo: SubscribeInfo, filterOptions: string): void + +å‘现周边设备。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ------------- | ------------------------------- | ---- | ----- | + | subscribeInfo | [SubscribeInfo](#subscribeinfo) | 是 | å‘现信æ¯ã€‚ | + | filterOptions | [string](#filteroptions) | å¦ | å‘现设备过滤信æ¯ã€‚| + +- 示例: + ```js + //生æˆå‘çŽ°æ ‡è¯†ï¼Œéšæœºæ•°ç¡®ä¿æ¯æ¬¡è°ƒç”¨å‘现接å£çš„æ ‡è¯†ä¸ä¸€è‡´ + var subscribeId = Math.floor(Math.random() * 10000 + 1000); + var subscribeInfo = { + "subscribeId": subscribeId, + "mode": 0xAA, //ä¸»åŠ¨æ¨¡å¼ + "medium": 0, //自动å‘现类型,åŒæ—¶æ”¯æŒå¤šç§å‘现类型 + "freq": 2, //高频率 + "isSameAccount": false, + "isWakeRemote": false, + "capability": 1 + }; + var filterOptions = { + "filter_op": "OR", // å¯é€‰, 默认"OR" + "filters": [ + { + "type": "range", + "value": 50 // 需过滤å‘现设备的è·ç¦»ï¼Œå•ä½(cm) + } + ] +}; + dmInstance.startDeviceDiscovery(subscribeInfo, JSON.stringify(filterOptions)); //当有设备å‘现时,通过deviceFoundå›žè°ƒé€šçŸ¥ç»™åº”ç”¨ç¨‹åº + ``` + ### stopDeviceDiscovery stopDeviceDiscovery(subscribeId: number): void @@ -368,9 +419,9 @@ stopDeviceDiscovery(subscribeId: number): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | subscribeId | number | 是 | å‘çŽ°æ ‡è¯†ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ----------- | ------ | ---- | ----- | + | subscribeId | number | 是 | å‘çŽ°æ ‡è¯†ã€‚ | - 示例: ```js @@ -378,6 +429,51 @@ stopDeviceDiscovery(subscribeId: number): void dmInstance.stopDeviceDiscovery(subscribeId); ``` +### publishDeviceDiscovery9+</sup> + +publishDeviceDiscovery(publishInfo: PublishInfo): void + +å‘现设备å‘现。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ------------- | ------------------------------- | ---- | ----- | + | publishInfo | [PublishInfo](#publishinfo) | 是 | å‘布设备å‘现信æ¯ã€‚ | + +- 示例: + ```js + //生æˆå‘å¸ƒæ ‡è¯†ï¼Œéšæœºæ•°ç¡®ä¿æ¯æ¬¡è°ƒç”¨å‘现接å£çš„æ ‡è¯†ä¸ä¸€è‡´ + var publishId = Math.floor(Math.random() * 10000 + 1000); + var publishInfo = { + "publishId": publishId, + "mode": 0xAA, //ä¸»åŠ¨æ¨¡å¼ + "freq": 2, //高频率 + "ranging": 1 //支æŒå‘çŽ°æ—¶æµ‹è· + }; + dmInstance.publishDeviceDiscovery(publishInfo); //当有å‘å¸ƒç»“æžœæ—¶ï¼Œé€šè¿‡å›žè°ƒé€šçŸ¥ç»™åº”ç”¨ç¨‹åº + ``` + +### unPublishDeviceDiscovery + +unPublishDeviceDiscovery(publishId: number): void + +åœæ¢å‘布设备å‘现。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ----------- | -------- | ---- | ----- | + | publishId | number | 是 | å‘å¸ƒæ ‡è¯†ã€‚ | + +- 示例: + ```js + //å…¥å‚需è¦å’ŒpublishDeviceDiscovery接å£ä¼ 入的publishIdé…对使用 + dmInstance.unPublishDeviceDiscovery(publishId); + ``` + ### authenticateDevice authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinToken ?: number}>): void @@ -387,11 +483,11 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | deviceInfo | [DeviceInfo](#deviceInfo) | 是 | 设备信æ¯ã€‚ | - | authParam | [AuthParam](#authParam) | 是 | 认è¯å‚数。 | - | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | 是 | 认è¯ç»“果回调。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ---------- | ---------------------------------------- | ---- | ------- | + | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信æ¯ã€‚ | + | authParam | [AuthParam](#authparam) | 是 | 认è¯å‚数。 | + | callback | AsyncCallback<{ deviceId: string, pinToken ?: number }> | 是 | 认è¯ç»“果回调。 | - 示例: ```js @@ -424,9 +520,9 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | deviceInfo | [DeviceInfo](#deviceInfo) | 是 | 设备信æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | ---------- | ------------------------- | ---- | ----- | + | deviceInfo | [DeviceInfo](#deviceinfo) | 是 | 设备信æ¯ã€‚ | - 示例: ```js @@ -443,10 +539,10 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, le **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | authInfo | [AuthInfo](#authInfo) | 是 | 认è¯ä¿¡æ¯ã€‚ | - | authInfo | AsyncCallback<{ deviceId: string, level: number }> | 是 | 验è¯ç»“果回调。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | ------- | + | authInfo | [AuthInfo](#authinfo) | 是 | 认è¯ä¿¡æ¯ã€‚ | + | authInfo | AsyncCallback<{ deviceId: string, level: number }> | 是 | 验è¯ç»“果回调。 | - 示例: ```js @@ -474,10 +570,10 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 注册设备状æ€å›žè°ƒï¼Œå›ºå®šä¸ºdeviceStateChange。 | - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示è¦æ³¨å†Œçš„设备状æ€å›žè°ƒï¼Œè¿”回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 注册设备状æ€å›žè°ƒï¼Œå›ºå®šä¸ºdeviceStateChange。 | + | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示è¦æ³¨å†Œçš„设备状æ€å›žè°ƒï¼Œè¿”回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | - 示例: ```js @@ -497,10 +593,10 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | æ ¹æ®åº”用程åºçš„包åå–消注册设备状æ€å›žè°ƒã€‚ | - | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示è¦å–消注册的设备状æ€å›žè°ƒï¼Œè¿”回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | 是 | æ ¹æ®åº”用程åºçš„包åå–消注册设备状æ€å›žè°ƒã€‚ | + | callback | Callback<{ action: [DeviceStateChangeAction](#devicestatechangeaction), device: [DeviceInfo](#deviceinfo) }> | 是 | 指示è¦å–消注册的设备状æ€å›žè°ƒï¼Œè¿”回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | - 示例: ```js @@ -520,10 +616,10 @@ on(type: 'deviceFound', callback: Callback<{ subscribeId: number, device: Dev **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 注册设备å‘现回调,以便在å‘现周边设备时通知应用程åºã€‚ | - | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 注册设备å‘现的回调方法。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | -------------------------- | + | type | string | 是 | 注册设备å‘现回调,以便在å‘现周边设备时通知应用程åºã€‚ | + | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 注册设备å‘现的回调方法。 | - 示例: ```js @@ -542,10 +638,10 @@ off(type: 'deviceFound', callback?: Callback<{ subscribeId: number, device: D **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | å–消注册设备å‘现回调。 | - | callback | Callback<{ subscribeId: number, device: DeviceInfo }> | 是 | 指示è¦å–消注册的设备å‘现回调,返回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | 是 | å–消注册设备å‘现回调。 | + | callback | Callback<{ subscribeId: number, device: [DeviceInfo](#deviceinfo) }> | 是 | 指示è¦å–消注册的设备å‘现回调,返回设备状æ€å’Œè®¾å¤‡ä¿¡æ¯ã€‚ | - 示例: ```js @@ -564,10 +660,10 @@ on(type: 'discoverFail', callback: Callback<{ subscribeId: number, reason: nu **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 注册设备å‘现失败回调,以便在å‘现周边设备失败时通知应用程åºã€‚ | - | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 注册设备å‘现失败的回调方法。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 注册设备å‘现失败回调,以便在å‘现周边设备失败时通知应用程åºã€‚ | + | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 注册设备å‘现失败的回调方法。 | - 示例: ```js @@ -586,10 +682,10 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | å–消注册设备å‘现失败回调。 | - | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 指示è¦å–消注册的设备å‘现失败回调。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | ----------------- | + | type | string | 是 | å–消注册设备å‘现失败回调。 | + | callback | Callback<{ subscribeId: number, reason: number }> | 是 | 指示è¦å–消注册的设备å‘现失败回调。 | - 示例: ```js @@ -599,6 +695,93 @@ off(type: 'discoverFail', callback?: Callback<{ subscribeId: number, reason: ); ``` +### on('publishSuccess') + +on(type: 'publishSuccess', callback: Callback<{ publishId: number }>): void + +注册å‘布设备å‘现回调监å¬ã€‚ + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | -------------------------- | + | type | string | 是 | 注册å‘布设备å‘现回调,以便将å‘布结果时通知应用程åºã€‚ | + | callback | Callback<{ publishId: number }> | 是 | 注册设备å‘布的回调方法。 | + +- 示例: + ```js + dmInstance.on('publishSuccess', (data) => { + console.info("publishSuccess:" + JSON.stringify(data)); + } + ); + ``` + +### off('publishSuccess') + +off(type: 'publishSuccess', callback?: Callback<{ publishId: number }>): void + +å–消注册设备å‘现回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ---------------------------------------- | ---- | --------------------------- | + | type | string | 是 | å–消注册设备å‘现回调。 | + | callback | Callback<{ publishId: number }> | 是 | 指示è¦å–消注册的设备å‘布回调。 | + +- 示例: + ```js + dmInstance.off('publishSuccess', (data) => { + console.info('publishSuccess' + JSON.stringify(data)); + } + ); + ``` + +### on('publishFail') + +on(type: 'publishFail', callback: Callback<{ publishId: number, reason: number }>): void + +注册设备å‘布失败回调监å¬ã€‚ + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ----------------------------------------------------- | ---- | ------------------------------ | + | type | string | 是 | 注册设备å‘布失败回调,以便在å‘布设备失败时通知应用程åºã€‚ | + | callback | Callback<{ publishId: number, reason: number }> | 是 | 注册设备å‘布失败的回调方法。 | + +- 示例: + ```js + dmInstance.on('publishFail', (data) => { + this.log("publishFail on:" + JSON.stringify(data)); + } + ); + ``` + +### off('publishFail') + +off(type: 'publishFail', callback?: Callback<{ publishId: number, reason: number }>): void + +å–消注册设备å‘现失败回调。 + +**系统能力**:SystemCapability.DistributedHardware.DeviceManager + +- å‚数: + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ----------------------------------------------------- | ---- | ----------------- | + | type | string | 是 | å–消注册设备å‘布失败回调。 | + | callback | Callback<{ publishId: number, reason: number }> | 是 | 指示è¦å–消注册的设备å‘布失败回调。 | + +- 示例: + ```js + dmInstance.off('publishFail', (data) => { + console.info('publishFail' + JSON.stringify(data)); + } + ); + ``` ### on('serviceDie') @@ -609,10 +792,10 @@ on(type: 'serviceDie', callback: () => void): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | 注册serviceDie回调,以便在devicemanageræœåŠ¡å¼‚常终æ¢æ—¶é€šçŸ¥åº”用程åºã€‚ | - | callback | () => void | 是 | 注册serviceDie的回调方法。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ----------------------- | ---- | ---------------------------------------- | + | type | string | 是 | 注册serviceDie回调,以便在devicemanageræœåŠ¡å¼‚常终æ¢æ—¶é€šçŸ¥åº”用程åºã€‚ | + | callback | () => void | 是 | 注册serviceDie的回调方法。 | - 示例: ```js @@ -632,10 +815,10 @@ off(type: 'serviceDie', callback?: () => void): void **系统能力**:SystemCapability.DistributedHardware.DeviceManager - å‚数: - | å称 | å‚数类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | type | string | 是 | å–消注册serviceDie回调,以便在devicemanageræœåŠ¡å¼‚常终æ¢æ—¶é€šçŸ¥åº”用程åºã€‚ | - | callback | () => void | å¦ | å–消注册serviceDie的回调方法。 | + | å称 | å‚数类型 | å¿…å¡« | 说明 | + | -------- | ----------------------- | ---- | ---------------------------------------- | + | type | string | 是 | å–消注册serviceDie回调,以便在devicemanageræœåŠ¡å¼‚常终æ¢æ—¶é€šçŸ¥åº”用程åºã€‚ | + | callback | () => void | å¦ | å–消注册serviceDie的回调方法。 | - 示例: ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..2ea328f8452288a0bf4461c6704217f5323cb971 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md @@ -0,0 +1,20 @@ +# DispatchInfo + + + +>  **说明:** +> 本模å—首批接å£ä»ŽAPI version 9 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + + + +调度信æ¯ç±» + +## DispatchInfo + +**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.BundleManager.BundleFramework + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------- | ------ | ---- | ---- | ------------------------ | +| verison | string | 是 | å¦ | 包å«dispatchInfoç‰ˆæœ¬ä¿¡æ¯ | +| dispatchAPI | string | 是 | å¦ | 包å«å…安装接å£ç‰ˆæœ¬å· | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index a0512d075e978281605477d13f402967fcb043b3..22e041d0a45217c562d4c421d82b9a721f0cfcce 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -174,6 +174,42 @@ getAllDisplay(): Promise<Array<Display>> }); ``` +## display.hasPrivateWindow<sup>9+</sup> + +hasPrivateWindow(displayId: number): boolean + +查询指定display对象上是å¦æœ‰å¯è§çš„éšç§çª—å£ã€‚å¯é€šè¿‡[setPrivacyMode](js-apis-window.md#setprivacymode7)接å£è®¾ç½®éšç§çª—å£ã€‚éšç§çª—å£å†…å®¹å°†æ— æ³•è¢«æˆªå±æˆ–录å±ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------------------------- | ---- |----------| +| id | number | 是 | 显示设备的id。 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- |-----------------------------------------------------------------------| +|boolean | 查询的display对象上是å¦æœ‰å¯è§çš„éšç§çª—å£ã€‚<br>true表示æ¤display对象上有å¯è§çš„éšç§çª—å£ï¼Œfalse表示æ¤display对象上没有å¯è§çš„éšç§çª—å£ã€‚</br> | + +**示例:** + + ```js + var ret = display.hasPrivateWindow(displayClass.id); + if (ret == undefined) { + console.log("HasPrivateWindow undefined."); + } + if (ret) { + console.log("HasPrivateWindow."); + } else if (!ret) { + console.log("Don't HasPrivateWindow."); + } + ``` + ## display.on('add'|'remove'|'change') on(type: 'add'|'remove'|'change', callback: Callback<number>): void @@ -215,3 +251,4 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void ```js display.off("remove"); ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md index f6e715f41a98d066a88c4dc58c2064ee63dba262..626629182d7da7c388a03a3c4b0aa37168458d71 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @@ -43,7 +43,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): v **系统能力:** SystemCapability.Account.OsAccount -**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC,该æƒé™ä»…供系统应用使用。 +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC。 - å‚数: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -68,7 +68,7 @@ queryOsAccountDistributedInfo(): Promise<DistributedInfo> **系统能力:** SystemCapability.Account.OsAccount -**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC,该æƒé™ä»…供系统应用使用。 +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS 或 ohos.permission.DISTRIBUTED_DATASYNC。 - 返回值: | 类型 | 说明 | @@ -94,7 +94,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall **系统能力:** SystemCapability.Account.OsAccount -**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该æƒé™ä»…供系统应用使用。 +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS。 - å‚数: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -119,7 +119,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> **系统能力:** SystemCapability.Account.OsAccount -**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该æƒé™ä»…供系统应用使用。 +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_LOCAL_ACCOUNTS。 - å‚数: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index f043079681dfc50caa3c56b86b6c7ee615bfda6a..42fee9042b090961be2e5b9e877b1fde48180745 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -182,7 +182,7 @@ export default class MyAbilityStage extends AbilityStage { | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ------ | ------ | -| context | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。| +| context<sup>9+<sup> | Context | 是 | 应用的上下文。 <br>FA模型的应用Context定义è§[Context](js-apis-Context.md)。<br>Stage模型的应用Context定义è§[Context](js-apis-ability-context.md)。| | userInfo | [UserInfo](#userinfo) | 是 | 调用方的用户信æ¯ã€‚ | | bundleName | string | 是 | 调用方的包å。 | @@ -558,7 +558,7 @@ getAllKVStoreId(appId: string): Promise<string[]> let kvManager; try { console.log('GetAllKVStoreId'); - kvManager.getAllKVStoreId('apppId').then((data) => { + kvManager.getAllKVStoreId('appId').then((data) => { console.log('getAllKVStoreId success'); console.log('size = ' + data.length); }).catch((err) => { @@ -844,7 +844,7 @@ let kvStore; try { let resultSet; kvStore.getResultSet('batch_test_string_key').then((result) => { - console.log('getResultSet succeeed.'); + console.log('getResultSet succeeded.'); resultSet = result; }).catch((err) => { console.log('getResultSet failed: ' + err); @@ -2301,7 +2301,7 @@ try { ### delete<sup>9+</sup> -delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<void>): void +delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<void>) 从数æ®åº“ä¸åˆ 除符åˆpredicatesæ¡ä»¶çš„键值对,并通过callbackæ–¹å¼è¿”回,æ¤æ–¹æ³•ä¸ºå¼‚æ¥æ–¹æ³•ã€‚ @@ -2311,7 +2311,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallb | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。| | callback | AsyncCallback<void> | 是 |回调函数。 | **示例:** @@ -2345,7 +2345,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates): Promise<void> | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。| +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。| **返回值:** @@ -2381,7 +2381,7 @@ try { ### on('dataChange') -on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void +on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotification>): void 订阅指定类型的数æ®å˜æ›´é€šçŸ¥ã€‚ @@ -2393,7 +2393,7 @@ on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotific | ----- | ------ | ---- | ----------------------- | | event |string | 是 |订阅的事件å,固定为'dataChange',表示数æ®å˜æ›´äº‹ä»¶ã€‚ | | type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 | -| observer |Callback<[ChangeNotification](#changenotification)> | 是 |回调函数。 | +| listener |Callback<[ChangeNotification](#changenotification)> | 是 |回调函数。 | **示例:** @@ -2431,7 +2431,7 @@ kvStore.on('syncComplete', function (data) { ### off('dataChange')<sup>8+</sup> -off(event:'dataChange', observer?: Callback<ChangeNotification>): void +off(event:'dataChange', listener?: Callback<ChangeNotification>): void å–消订阅数æ®å˜æ›´é€šçŸ¥ã€‚ @@ -2442,7 +2442,7 @@ off(event:'dataChange', observer?: Callback<ChangeNotification>): void | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |å–消订阅的事件å,固定为'dataChange',表示数æ®å˜æ›´äº‹ä»¶ã€‚ | -| observer |Callback<[ChangeNotification](#changenotification)> |å¦ |回调函数。 | +| listener |Callback<[ChangeNotification](#changenotification)> |å¦ |回调函数。 | **示例:** @@ -2522,10 +2522,10 @@ try { console.log('entries: ' + JSON.stringify(entries)); kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key', function (err,entrys) { + kvStore.getEntries('batch_test_string_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -2574,7 +2574,7 @@ try { console.log('entries: ' + JSON.stringify(entries)); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key').then((entrys) => { + kvStore.getEntries('batch_test_string_key').then((entries) => { console.log('getEntries success'); console.log('PutBatch ' + JSON.stringify(entries)); }).catch((err) => { @@ -3313,10 +3313,10 @@ try { } kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('batch_test_number_key', function (err,entrys) { + kvStore.getEntries('batch_test_number_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -3365,12 +3365,12 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('batch_test_string_key').then((entrys) => { + kvStore.getEntries('batch_test_string_key').then((entries) => { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); }); @@ -3421,10 +3421,10 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query, function (err,entrys) { + kvStore.getEntries(query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); console.log('GetEntries success'); @@ -3477,7 +3477,7 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query).then((entrys) => { + kvStore.getEntries(query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); @@ -3717,8 +3717,8 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: Asyn | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| predicates | [DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。 | -| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)> | 是 |回调函数,获å–与指定Predicates对象匹é…çš„KvStoreResultSet对象。 | +| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。 | +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获å–与指定Predicates对象匹é…çš„KvStoreResultSet对象。 | **示例:** @@ -3752,7 +3752,7 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<Kv | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| predicates |[DataSharePredicates](js-apis-data-DataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。 | +| predicates |[DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 |指示ç›é€‰æ¡ä»¶,当æ¤å‚数为null时,应定义处ç†é€»è¾‘。 | **返回值:** @@ -4164,7 +4164,7 @@ kvStore.off('dataChange', function (data) { ### sync<sup>7+</sup> -sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void +sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 在手动åŒæ¥æ–¹å¼ä¸‹ï¼Œè§¦å‘æ•°æ®åº“åŒæ¥ã€‚关于分布å¼æ•°æ®æœåŠ¡çš„åŒæ¥æ–¹å¼è¯´æ˜Žï¼Œè¯·è§[分布å¼æ•°æ®æœåŠ¡æ¦‚è¿°](../../database/database-mdds-overview.md)。 @@ -4176,9 +4176,9 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| deviceIdList |string[] | 是 |åŒä¸€ç»„网环境下,需è¦åŒæ¥çš„设备的deviceId列表。 | +| deviceIds |string[] | 是 |åŒä¸€ç»„网环境下,需è¦åŒæ¥çš„设备的deviceId列表。 | | mode |[SyncMode](#syncmode) | 是 |åŒæ¥æ¨¡å¼ã€‚ | -| allowedDelayMs |number | å¦ |å¯é€‰å‚数,å…许延时时间,å•ä½ï¼šms(毫秒)。 | +| delayMs |number | å¦ |å¯é€‰å‚数,å…许延时时间,å•ä½ï¼šms(毫秒)。 | **示例:** @@ -4202,7 +4202,7 @@ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void | ----- | ------ | ---- | ----------------------- | | deviceIds |string[] | 是 |åŒä¸€ç»„网环境下,需è¦åŒæ¥çš„设备的deviceId列表。 | | mode |[SyncMode](#syncmode) | 是 |åŒæ¥æ¨¡å¼ã€‚ | -| query |[Query](#querysup8sup) | 是 |表示数æ®åº“的查询谓è¯æ¡ä»¶ | +| query |[Query](#query8) | 是 |表示数æ®åº“的查询谓è¯æ¡ä»¶ | | delayMs |number | å¦ |å¯é€‰å‚数,å…许延时时间,å•ä½ï¼šms(毫秒)。 | **示例:** @@ -4320,7 +4320,7 @@ try { console.log('getSecurityLevel success'); }); }catch(e) { - console.log('GetSecurityLeve e ' + e); + console.log('GetSecurityLevel e ' + e); } ``` @@ -4350,7 +4350,7 @@ try { console.log('getSecurityLevel fail ' + JSON.stringify(err)); }); }catch(e) { - console.log('GetSecurityLeve e ' + e); + console.log('GetSecurityLevel e ' + e); } ``` @@ -4480,10 +4480,10 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries, async function (err,data) { console.log('putBatch success'); - kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entrys) { + kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); }catch(e) { @@ -4533,12 +4533,12 @@ try { console.log('entries: ' + entries); kvStore.putBatch(entries).then(async (err) => { console.log('putBatch success'); - kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entrys) => { + kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entries) => { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); - console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); - console.log('entrys[0].value.value: ' + entrys[0].value.value); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); + console.log('entries[0].value: ' + JSON.stringify(entries[0].value)); + console.log('entries[0].value.value: ' + entries[0].value.value); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); }); @@ -4590,10 +4590,10 @@ try { const query = new distributedData.Query(); query.prefixKey("batch_test"); query.deviceId('localDeviceId'); - kvStore.getEntries(query, function (err,entrys) { + kvStore.getEntries(query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }); }); console.log('GetEntries success'); @@ -4646,7 +4646,7 @@ try { console.log('putBatch success'); const query = new distributedData.Query(); query.prefixKey("batch_test"); - kvStore.getEntries(query).then((entrys) => { + kvStore.getEntries(query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); @@ -4701,10 +4701,10 @@ try { var query = new distributedData.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); - kvStore.getEntries('localDeviceId', query, function (err,entrys) { + kvStore.getEntries('localDeviceId', query, function (err,entries) { console.log('getEntries success'); - console.log('entrys.length: ' + entrys.length); - console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entries.length: ' + entries.length); + console.log('entries[0]: ' + JSON.stringify(entries[0])); }) }); console.log('GetEntries success'); @@ -4759,7 +4759,7 @@ try { var query = new distributedData.Query(); query.deviceId('localDeviceId'); query.prefixKey("batch_test"); - kvStore.getEntries('localDeviceId', query).then((entrys) => { + kvStore.getEntries('localDeviceId', query).then((entries) => { console.log('getEntries success'); }).catch((err) => { console.log('getEntries fail ' + JSON.stringify(err)); @@ -5459,7 +5459,7 @@ try { ### sync<sup>8+</sup> ### -sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void +sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void 在手动åŒæ¥æ–¹å¼ä¸‹ï¼Œè§¦å‘æ•°æ®åº“åŒæ¥ã€‚关于分布å¼æ•°æ®æœåŠ¡çš„åŒæ¥æ–¹å¼è¯´æ˜Žï¼Œè¯·è§[分布å¼æ•°æ®æœåŠ¡æ¦‚è¿°](../../database/database-mdds-overview.md)。 @@ -5471,9 +5471,9 @@ sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ----------------------- | -| deviceIdList |string[] | 是 |需è¦åŒæ¥DeviceKvStoreæ•°æ®åº“的设备ID列表。 | +| deviceIds |string[] | 是 |需è¦åŒæ¥DeviceKvStoreæ•°æ®åº“的设备ID列表。 | | mode |[SyncMode](#syncmode) | 是 |åŒæ¥æ¨¡å¼ã€‚ | -| allowedDelayMs |number | å¦ |å¯é€‰å‚数,å…许延时时间,å•ä½ï¼šms(毫秒)。 | +| delayMs |number | å¦ |å¯é€‰å‚数,å…许延时时间,å•ä½ï¼šms(毫秒)。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md b/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md index c231350a73495a1ac47f649f3171fafbee290044..a4eb7176cbbcd12ee85096a69f6e7542a12df77b 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedMissionManager.md @@ -1,20 +1,19 @@ -# distributedMissionManager +# 分布å¼ä»»åŠ¡ç®¡ç† -distributedMissionManager模å—æ供跨设备系统任务管ç†èƒ½åŠ›ï¼ŒåŒ…括注册系统任务状æ€ç›‘å¬ã€å–消系统任务状æ€ç›‘å¬ã€å¼€å§‹åŒæ¥è¿œç«¯ä»»åŠ¡åˆ—表ã€åœæ¢åŒæ¥è¿œç«¯ä»»åŠ¡åˆ—表æ“作。 +分布å¼ä»»åŠ¡ç®¡ç†æ¨¡å—æ供跨设备系统任务管ç†èƒ½åŠ›ï¼ŒåŒ…括注册系统任务状æ€ç›‘å¬ã€å–消系统任务状æ€ç›‘å¬ã€å¼€å§‹åŒæ¥è¿œç«¯ä»»åŠ¡åˆ—表ã€åœæ¢åŒæ¥è¿œç«¯ä»»åŠ¡åˆ—表æ“作。 > **说明:** -> +> > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> +> 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— -``` +```js import distributedMissionManager from '@ohos.distributedMissionManager' ``` -## æƒé™åˆ—表 - -ohos.permission.MANAGE_MISSIONS ## distributedMissionManager.registerMissionListener @@ -26,15 +25,13 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | 注册监å¬è®¾å¤‡ä¿¡æ¯ã€‚ | - | options | <a href="#missioncallback">MissionCallback</a> | 是 | 注册的回调方法。 | - | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | 注册监å¬è®¾å¤‡ä¿¡æ¯ã€‚ | +| options | [MissionCallback](#missioncallback) | 是 | 注册的回调方法。 | +| callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | **示例:** @@ -72,20 +69,18 @@ registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | 设备信æ¯ã€‚ | - | options | <a href="#missioncallback">MissionCallback</a> | 是 | 注册的回调方法。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ---------------------------------------- | ---- | -------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | 设备信æ¯ã€‚ | +| options | <a href="#missioncallback">MissionCallback</a> | 是 | 注册的回调方法。 | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | +| 类型 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | **示例:** @@ -128,15 +123,12 @@ unregisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback& **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | listenerId | number | 是 | 系统任务状æ€ç›‘å¬æ–¹æ³•çš„index值,和监å¬æ–¹æ³•ä¸€ä¸€å¯¹åº”,由registerMissionListener方法返回。 | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | 设备信æ¯ã€‚ | - | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | 设备信æ¯ã€‚ | +| callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | **示例:** @@ -160,19 +152,17 @@ unregisterMissionListener(parameter: MissionDeviceInfo): Promise<void> **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | 设备信æ¯ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | 设备信æ¯ã€‚ | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | +| 类型 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | **示例:** @@ -198,15 +188,12 @@ startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback< **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | listenerId | number | 是 | 系统任务状æ€ç›‘å¬æ–¹æ³•çš„index值,和监å¬æ–¹æ³•ä¸€ä¸€å¯¹åº”,由registerMissionListener方法返回。 | - | parameter | <a href="#missionparameter">MissionParameter</a> | 是 | åŒæ¥ä¿¡æ¯ã€‚ | - | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------------------------------------- | ---- | --------- | +| parameter | [MissionParameter](#missionparameter) | 是 | åŒæ¥ä¿¡æ¯ã€‚ | +| callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | **示例:** @@ -231,19 +218,17 @@ startSyncRemoteMissions(parameter: MissionParameter): Promise<void> **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | <a href="#missionparameter">MissionParameter</a> | 是 | åŒæ¥ä¿¡æ¯ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------------------------------------- | ---- | ----- | +| parameter | [MissionParameter](#missionparameter) | 是 | åŒæ¥ä¿¡æ¯ã€‚ | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | +| 类型 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | **示例:** @@ -271,15 +256,12 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback< **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | listenerId | number | 是 | 系统任务状æ€ç›‘å¬æ–¹æ³•çš„index值,和监å¬æ–¹æ³•ä¸€ä¸€å¯¹åº”,由registerMissionListener方法返回。 | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | åŒæ¥ä¿¡æ¯ã€‚ | - | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | --------- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | åŒæ¥ä¿¡æ¯ã€‚ | +| callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | **示例:** @@ -302,19 +284,17 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> **系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ - **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | parameter | <a href="#missiondeviceinfo">MissionDeviceInfo</a> | 是 | åŒæ¥ä¿¡æ¯ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是 | åŒæ¥ä¿¡æ¯ã€‚ | **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | +| 类型 | 说明 | +| ------------------- | ---------------- | +| Promise<void> | promiseæ–¹å¼è¿”回执行结果。 | **示例:** @@ -330,42 +310,36 @@ stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> }) ``` -## <a id ="missioncallback">MissionCallback</a> +## MissionCallback 表示开始åŒæ¥åŽï¼Œå»ºç«‹çš„回调函数。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Mission - -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| notifyMissionsChanged | function | 是 | å¦ | 通知任务å˜åŒ–,返回设备ID。| -| notifySnapshot | function | 是 | å¦ | 通知快照å˜åŒ–,返回设备ID,任务ID | -| notifyNetDisconnect | function | 是 | å¦ | 通知æ–开连接,返回设备IDï¼Œç½‘ç»œçŠ¶æ€ | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| --------------------- | -------- | ---- | ---- | ------------------ | +| notifyMissionsChanged | function | 是 | å¦ | 通知任务å˜åŒ–,返回设备ID。 | +| notifySnapshot | function | 是 | å¦ | 通知快照å˜åŒ–,返回设备ID,任务ID | +| notifyNetDisconnect | function | 是 | å¦ | 通知æ–开连接,返回设备IDï¼Œç½‘ç»œçŠ¶æ€ | -## <a id ="missionparameter">MissionParameter</a> +## MissionParameter 表示åŒæ¥æ—¶æ‰€éœ€å‚数的枚举。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Mission - -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| deviceId | string | 是 | 是 | 表示设备ID。| -| fixConflict | boolean | 是 | 是 | 表示是å¦å˜åœ¨ç‰ˆæœ¬å†²çªã€‚ | -| tag | number | 是 | 是 | è¡¨ç¤ºç‰¹å®šçš„æ ‡ç¾ã€‚ | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------- | ------- | ---- | ---- | ----------- | +| deviceId | string | 是 | 是 | 表示设备ID。 | +| fixConflict | boolean | 是 | 是 | 表示是å¦å˜åœ¨ç‰ˆæœ¬å†²çªã€‚ | +| tag | number | 是 | 是 | è¡¨ç¤ºç‰¹å®šçš„æ ‡ç¾ã€‚ | -## <a id ="missiondeviceinfo">MissionDeviceInfo</a> +## MissionDeviceInfo 表示注册监å¬æ—¶æ‰€éœ€å‚数的枚举。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityRuntime.Mission - -**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| deviceId | string | 是 | 是 | 表示设备ID。| \ No newline at end of file +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | +| -------- | ------ | ---- | ---- | ------- | +| deviceId | string | 是 | 是 | 表示设备ID。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md index b9524a5c74feb553d0cee49a6c549973388b0d65..cfa707255ee96189c9e872c52167da6691c7048d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -42,10 +42,10 @@ createEffect(source: image.PixelMap): Filter ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; image.createPixelMap(color, opts) - .then((pixelmap) => { - let headFilter = effectKit.createEffect(pixelmap) + .then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap) }) ``` @@ -74,13 +74,12 @@ createColorPicker(source: image.PixelMap): Promise\<ColorPicker> ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } -image.createPixelMap(color, opts, (pixelmap) => { +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts, (pixelMap) => { effectKit.createColorPicker(pixelMap).then(colorPicker => { console.info("color picker=" + colorPicker); - }) - .catch(ex => console.error(".error=" + ex.toString())) }) + .catch(ex => console.error(".error=" + ex.toString())) }) ``` @@ -104,15 +103,15 @@ createColorPicker(source: image.PixelMap, callback: AsyncCallback\<ColorPicker>) ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } -image.createPixelMap(color, opts, (pixelmap) => { - effectKit.createColorPicker(pixelMap, (error, colorPicker) ) { +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; +image.createPixelMap(color, opts, (pixelMap) => { + effectKit.createColorPicker(pixelMap, (error, colorPicker) => { if(error) { console.log('Failed to create color picker.'); } else { console.log('Succeeded in creating color picker.'); } - }) + }) }) ``` @@ -152,7 +151,7 @@ getMainColor(): Promise\<Color> ```js colorPicker.getMainColor().then(color => { console.log('Succeeded in getting main color.') - console.info("color[ARGB]=" + color.alpha "," + color.red + "," + color.green + "," + color.blue); + console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue); }).catch(error => { console.log('Failed to get main color.'); }) @@ -175,8 +174,8 @@ getMainColorSync(): Color **示例:** ```js -let color = colorPicker.getMainColorSync() -console.log('get main color =' + color) +let color = colorPicker.getMainColorSync(); +console.log('get main color =' + color); ``` ## Filter @@ -208,11 +207,11 @@ blur(radius: number): Filter ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; image.createPixelMap(color, opts) - .then((pixelmap) => { + .then((pixelMap) => { let radius = 5; - let headFilter = effectKit.createEffect(pixelmap) + let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) { headFilter.blur(radius) } @@ -244,11 +243,11 @@ brightness(bright: number): Filter ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; image.createPixelMap(color, opts) - .then((pixelmap) => { + .then((pixelMap) => { let bright = 0.5; - let headFilter = effectKit.createEffect(pixelmap) + let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) { headFilter.brightness(bright) } @@ -274,10 +273,10 @@ grayscale(): Filter ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; image.createPixelMap(color, opts) - .then((pixelmap) => { - let headFilter = effectKit.createEffect(pixelmap) + .then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) { headFilter.grayscale() } @@ -303,9 +302,9 @@ getPixelMap(): image.PixelMap ```js import image from "@ohos.multimedia.image" const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; image.createPixelMap(color, opts) - .then((pixelmap) => { - let pixel = effectKit.createEffect(pixelmap).grayscale().getPixelMap() + .then((pixelMap) => { + let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap() }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 970361fa37e59657f127bed9640d07a20ab35f6b..8f2b64adf74e242fc3b3686ca4d99e6bb492e345 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -3,7 +3,7 @@ 本模å—æä¾›ä¼ä¸šè®¾å¤‡ç®¡ç†èƒ½åŠ›ï¼Œä½¿è®¾å¤‡å…·å¤‡ä¼ä¸šåœºæ™¯ä¸‹æ‰€éœ€çš„定制能力。 > **说明:** -> +> > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -18,20 +18,18 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å激活设备管ç†å‘˜åº”用,使用Callbackå½¢å¼è¿”回是å¦æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** -ohos.permission.MANAGE_ADMIN +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------------- | ----------------------------------- | --- | ------------------ | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | -| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦æ¿€æ´»æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ----------------------------------- | ---- | ------------------ | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦æ¿€æ´»æˆåŠŸ | **示例**: @@ -59,23 +57,19 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å激活设备管ç†å‘˜åº”用,使用Callbackå½¢å¼è¿”回是å¦æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -ohos.permission.MANAGE_ADMIN - -**系统能力:** - - SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------------- | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | -| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | -| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦æ¿€æ´»æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦æ¿€æ´»æˆåŠŸ | **示例**: @@ -103,20 +97,18 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å激活设备管ç†å‘˜åº”用,使用Promiseå½¢å¼è¿”回是å¦æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** -ohos.permission.MANAGE_ADMIN +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------------- | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | -| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | -| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| type | [AdminType](#AdminType) | 是 | 激活的设备管ç†å‘˜ç±»åž‹ | +| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | **返回值:** @@ -149,18 +141,16 @@ disableAdmin(admin: Want, callback: AsyncCallback\<boolean>): void 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å将设备普通管ç†å‘˜åº”用去激活,使用Callbackå½¢å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** -ohos.permission.MANAGE_ADMIN +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------- | --- | ------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | ------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | **示例**: @@ -184,21 +174,17 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<boolean>): vo 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å将设备普通管ç†å‘˜åº”用去激活,使用Callbackå½¢å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** - -ohos.permission.MANAGE_ADMIN - -**系统能力:** +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | -| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | **示例**: @@ -222,18 +208,16 @@ disableAdmin(admin: Want, userId?: number): Promise\<boolean> 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å将设备普通管ç†å‘˜åº”用去激活,使用Promiseå½¢å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸã€‚ -**需è¦æƒé™ï¼š** -ohos.permission.MANAGE_ADMIN +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_ADMIN -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | -| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 普通设备管ç†å‘˜åº”用 | +| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | **返回值:** @@ -261,15 +245,14 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å将设备超级管ç†å‘˜åº”用去激活,使用Callbackå½¢å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------- | --- | ------------------- | -| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用的包å | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ----------------------- | ---- | ------------------- | +| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用的包å | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸ | **示例**: @@ -290,14 +273,13 @@ disableSuperAdmin(bundleName: String): Promise\<boolean> 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å将设备超级管ç†å‘˜åº”用去激活,使用Promiseå½¢å¼è¿”回是å¦åŽ»æ¿€æ´»æˆåŠŸã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ------ | --- | ------------ | -| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用的包å | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ------ | ---- | ------------ | +| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用的包å | **返回值:** @@ -322,15 +304,14 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å判æ–设备管ç†å‘˜åº”用是å¦è¢«æ¿€æ´»ï¼Œä½¿ç”¨Callbackå½¢å¼è¿”回是å¦å¤„于激活状æ€ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------- | --- | -------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | -------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | **示例**: @@ -354,17 +335,15 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å判æ–设备管ç†å‘˜åº”用是å¦è¢«æ¿€æ´»ï¼Œä½¿ç”¨Callbackå½¢å¼è¿”回是å¦å¤„于激活状æ€ã€‚ -**系统能力:** - -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| userId | number | 是 | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | **示例**: @@ -388,15 +367,14 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å和类å判æ–设备管ç†å‘˜åº”用是å¦è¢«æ¿€æ´»ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回是å¦å¤„于激活状æ€ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------------------- | --- | ---------------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------------- | ---- | ---------------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| userId | number | å¦ | 用户ID。默认值:调用方所在用户,å–值范围:大于ç‰äºŽ0。 | **返回值:** @@ -424,15 +402,14 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å判æ–设备超级管ç†å‘˜åº”用是å¦è¢«æ¿€æ´»ï¼Œä½¿ç”¨Callbackå½¢å¼è¿”回是å¦å¤„于激活状æ€ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------- | --- | -------------------- | -| bundleName | String | 是 | 设备管ç†å‘˜åº”用 | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ----------------------- | ---- | -------------------- | +| bundleName | String | 是 | 设备管ç†å‘˜åº”用 | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | **示例**: @@ -453,14 +430,13 @@ isSuperAdmin(bundleName: String): Promise\<boolean> 以异æ¥æ–¹æ³•æ ¹æ®ç»™å®šçš„包å判æ–设备超级管ç†å‘˜åº”用是å¦è¢«æ¿€æ´»ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回是å¦å¤„于激活状æ€ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚æ•°**: -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ------ | --- | --------- | -| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ------ | ---- | --------- | +| bundleName | String | 是 | 超级设备管ç†å‘˜åº”用 | **返回值:** @@ -485,14 +461,13 @@ getDeviceSettingsManager(callback: AsyncCallback<DeviceSettingsManager>): 获å–DeviceSettingsManager对象,使用callbackå½¢å¼è¿”回DeviceSettingsManager对象。 -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------------------- | --- | ----------------------------------- | -| callback | AsyncCallback<DeviceSettingsManager> | 是 | callbackæ–¹å¼è¿”回DeviceSettingsManager对象 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | ----------------------------------- | +| callback | AsyncCallback<DeviceSettingsManager> | 是 | callbackæ–¹å¼è¿”回DeviceSettingsManager对象 | **示例:** @@ -522,8 +497,7 @@ getDeviceSettingsManager(): Promise<DeviceSettingsManager> 获å–DeviceSettingsManager对象,使用Promiseå½¢å¼è¿”回DeviceSettingsManager对象。 -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **返回值:** @@ -555,16 +529,15 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa 设置设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回是å¦è®¾ç½®æˆåŠŸã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------------- | ----------------------------------- | --- | ---------------------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | -| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦è®¾ç½®ä¼ä¸šä¿¡æ¯æˆåŠŸ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ----------------------------------- | ---- | ---------------------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| callback | AsyncCallback\<boolean> | 是 | callbackæ–¹å¼è¿”回是å¦è®¾ç½®ä¼ä¸šä¿¡æ¯æˆåŠŸ | **示例:** @@ -591,21 +564,20 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise<boole 设置设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回是å¦è®¾ç½®æˆåŠŸã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------------- | ----------------------------------- | --- | ------------ | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ----------------------------------- | ---- | ------------ | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| enterpriseInfo | [EnterpriseInfo](#EnterpriseInfo) | 是 | 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| ------------------ | --------------------- | -| Promise\<boolean>; | Promiseæ–¹å¼è¿”回是å¦è®¾ç½®ä¼ä¸šä¿¡æ¯æˆåŠŸ | +| 类型 | 说明 | +| ----------------- | --------------------- | +| Promise\<boolean> | Promiseæ–¹å¼è¿”回是å¦è®¾ç½®ä¼ä¸šä¿¡æ¯æˆåŠŸ | **示例:** @@ -632,15 +604,14 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): v 获å–设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ------------------------------------------------------ | --- | ------------------------ | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | -| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | 是 | callbackæ–¹å¼è¿”回设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------ | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| callback | AsyncCallback<[EnterpriseInfo](#EnterpriseInfo)> | 是 | callbackæ–¹å¼è¿”回设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ | **示例:** @@ -665,19 +636,18 @@ getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> 获å–设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ï¼Œä½¿ç”¨Promiseå½¢å¼è¿”回设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ã€‚ -**系统能力:** -SystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ----------------------------------- | --- | ------- | -| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-application-Want.md) | 是 | 设备管ç†å‘˜åº”用 | **返回值:** -| 类型 | 说明 | -| ------------------------------------------------ | ------------------------- | +| 类型 | 说明 | +| ---------------------------------------- | ------------------------- | | Promise<[EnterpriseInfo](#EnterpriseInfo)> | Promiseæ–¹å¼è¿”回设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯å¯¹è±¡ | **示例:** @@ -699,8 +669,8 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { 设备管ç†å‘˜åº”用的ä¼ä¸šä¿¡æ¯ -**系统能力:** -以下å„项对应系统能力å‡ä¸ºSystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + | å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | | ----------- | ---- | ------ | ---- | ----------------- | | name | åªè¯» | string | 是 | 表示设备管ç†å‘˜åº”用所属ä¼ä¸šçš„å称。 | @@ -710,8 +680,8 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => { 设备管ç†å‘˜åº”用的管ç†å‘˜ç±»åž‹ã€‚ -**系统能力:** -以下å„项对应系统能力å‡ä¸ºSystemCapability.Customation.EnterpriseDeviceManager +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + | å称 | 默认值 | 说明 | | ----------------- | ---- | ----- | | ADMIN_TYPE_NORMAL | 0x00 | 普通管ç†å‘˜ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-errorManager.md b/zh-cn/application-dev/reference/apis/js-apis-errorManager.md new file mode 100644 index 0000000000000000000000000000000000000000..4dfec1a0ff6f60c8fd02852f301cfe066402a606 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-errorManager.md @@ -0,0 +1,139 @@ +# ErrorManager + +ErrorManager模å—æ供对错误观察器的注册和注销的能力。 + +> **说明:** +> +> 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 + +## å¯¼å…¥æ¨¡å— +``` +import errorManager from '@ohos.application.errorManager' +``` + +## ErrorManager.registerErrorObserver + +registerErrorObserver(observer: ErrorObserver): number; + +注册错误观测器。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| observer | [ErrorObserver](#errorobserver) | å¦ | 返回观察者的数å—代ç 。 | + +**示例:** + +```js +var observer = { + onUnhandledException(errorMsg) { + console.log('onUnhandledException, errorMsg: ', errorMsg) + } +} +errorManager.registerErrorObserver(observer) + .then((data) => { + console.log('----------- registerErrorObserver success ----------', data); + }) + .catch((err) => { + console.log('----------- registerErrorObserver fail ----------', err); + }) + +``` + +## ErrorManager.unregisterErrorObserver + +unregisterErrorObserver(observerId: number, callback: AsyncCallback\<void>): void; + +注销错误观测器。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| observerId | number | å¦ | 返回观察者的数å—代ç 。 | +| callback | AsyncCallback\<void> | å¦ | 表示指定的回调方法。 | + +**示例:** + +```js +var observerId = 100; + +function unregisterErrorObserverCallback(err) { + if (err) { + console.log('------------ unregisterErrorObserverCallback ------------', err); + } +} +errorManager.unregisterErrorObserver(observerId, unregisterErrorObserverCallback); + +``` + +## ErrorManager.unregisterErrorObserver + +unregisterErrorObserver(observerId: number): Promise\<void>; + +注销错误观测器。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| observerId | number | å¦ | 返回观察者的数å—代ç 。 | + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| Promise\<void> | 返回执行结果。 | + +**示例:** + +```js +var observerId = 100; +errorManager.unregisterErrorObserver(observerId) +.then((data) => { + console.log('----------- unregisterErrorObserver success ----------', data); +}) +.catch((err) => { + console.log('----------- unregisterErrorObserver fail ----------', err); +}) + +``` + +## ErrorObserver + +onUnhandledException(errMsg: string): void; + +将在jsè¿è¡Œæ—¶å¼•å‘用户未æ•èŽ·çš„异常时调用。 + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| errMsg | string | å¦ | 有关异常的消æ¯å’Œé”™è¯¯å †æ ˆè·Ÿè¸ªã€‚ | + +**示例:** + +```js +var observer = { + onUnhandledException(errorMsg) { + console.log('onUnhandledException, errorMsg: ', errorMsg) + } +} +errorManager.registerErrorObserver(observer) + .then((data) => { + console.log('----------- registerErrorObserver success ----------', data); + }) + .catch((err) => { + console.log('----------- registerErrorObserver fail ----------', err); + }) + +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md index 9add67e43afa65b78f549df61a81eb3548f4883f..4be9d179fcea470a893c93043075a138a8760193 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md @@ -17,3 +17,6 @@ ExtensionContext模å—æ供扩展的上下文的能力,包括å…许访问特 | -------- | -------- | -------- | -------- | -------- | | currentHapModuleInfo | HapModuleInfo | 是 | å¦ | 当å‰Hap包的信æ¯ã€‚ | | config | Configuration | 是 | å¦ | 模å—çš„é…置信æ¯ã€‚ | +| extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | 是 | å¦ | æœåŠ¡æ‰©å±•ä¿¡æ¯ã€‚ | + + diff --git a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md index a20771dcdaae6d4071658b2a2f683582280349a5..5d131e1dfcab25145571f4b9b41e615965c969d2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @@ -327,8 +327,6 @@ featureAbility.terminateSelfWithResult( }); ``` - - ## featureAbility.hasWindowFocus<sup>7+<sup> hasWindowFocus(callback: AsyncCallback\<boolean>): void @@ -350,8 +348,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus() ``` - - ## featureAbility.hasWindowFocus<sup>7+<sup> hasWindowFocus(): Promise\<boolean> @@ -375,8 +371,6 @@ featureAbility.hasWindowFocus().then((data) => { }); ``` - - ## featureAbility.getWant getWant(callback: AsyncCallback\<Want>): void @@ -398,8 +392,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant() ``` - - ## featureAbility.getWant getWant(): Promise\<Want> @@ -445,8 +437,6 @@ var context = featureAbility.getContext() context.getBundleName() ``` - - ## featureAbility.terminateSelf<sup>7+</sup> terminateSelf(callback: AsyncCallback\<void>): void @@ -468,8 +458,6 @@ import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf() ``` - - ## featureAbility.terminateSelf<sup>7+</sup> terminateSelf(): Promise\<void> @@ -508,18 +496,6 @@ connectAbility(request: Want, options:ConnectOptions): number | request | [Want](js-apis-application-Want.md) | 是 | 表示被连接的ServiceAbility。 | | options | [ConnectOptions](#connectoptions) | 是 | 被指定的回调方法。 | -## Want - -want类型说明 - -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Ability.AbilityBase - -| å称 | 读写属性 | 类型 | å¿…å¡« | æè¿° | -| ----------- | ---- | ------ | ---- | ---------------------------------------- | -| deviceId | åªè¯» | string | å¦ | 表示被连接的ServiceAbility的设备id,缺çœè¡¨ç¤ºè¿žæŽ¥æœ¬åœ°çš„ServiceAbility。 | -| bundleName | åªè¯» | string | 是 | 表示被连接的ServiceAbility的包å。 | -| abilityName | åªè¯» | string | 是 | 表示被连接的ServiceAbilityçš„ç±»å。 | - ## ConnectOptions ConnectOptions类型说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index ebdc2315773a1166ee57e10a6750860225a89aa0..7393edf78b0726c0c7e057e83e04c2815f1ea0b6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -17,15 +17,31 @@ import fileio from '@ohos.fileio'; 使用该功能模å—对文件/目录进行æ“作å‰ï¼Œéœ€è¦å…ˆèŽ·å–其应用沙箱路径,获å–æ–¹å¼åŠå…¶æŽ¥å£ç”¨æ³•è¯·å‚考: +**Stage模型** + + ```js +import Ability from '@ohos.application.Ability'; +class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + let context = this.context; + let path = context.filesDir; + } +} + ``` + + Stage模型context的具体获å–方法å‚è§[Stage模型](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-ability-context.md#abilitycontext)。 + +**FA模型** + ```js import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); - let path = ''; context.getFilesDir().then((data) => { - path = data; + let path = data; }) ``` - + + FA模型context的具体获å–方法å‚è§[FA模型](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md#context%E6%A8%A1%E5%9D%97)。 ## fileio.stat @@ -2159,7 +2175,7 @@ createStream(path: string, mode: string): Promise<Stream> | 类型 | 说明 | | --------------------------------- | --------- | - | Promise<[Stream](#stream7)> | Promise对象。返回文件æµçš„结果。 | + | Promise<[Stream](#stream)> | Promise对象。返回文件æµçš„结果。 | **示例:** @@ -2186,7 +2202,7 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>): | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | 是 | 待打开文件的应用沙箱路径。 | | mode | string | 是 | - r:打开åªè¯»æ–‡ä»¶ï¼Œè¯¥æ–‡ä»¶å¿…é¡»å˜åœ¨ã€‚<br/>- r+:打开å¯è¯»å†™çš„文件,该文件必须å˜åœ¨ã€‚<br/>- w:打开åªå†™æ–‡ä»¶ï¼Œè‹¥æ–‡ä»¶å˜åœ¨åˆ™æ–‡ä»¶é•¿åº¦æ¸…0,å³è¯¥æ–‡ä»¶å†…容会消失。若文件ä¸å˜åœ¨åˆ™å»ºç«‹è¯¥æ–‡ä»¶ã€‚<br/>- w+:打开å¯è¯»å†™æ–‡ä»¶ï¼Œè‹¥æ–‡ä»¶å˜åœ¨åˆ™æ–‡ä»¶é•¿åº¦æ¸…0,å³è¯¥æ–‡ä»¶å†…容会消失。若文件ä¸å˜åœ¨åˆ™å»ºç«‹è¯¥æ–‡ä»¶ã€‚<br/>- aï¼šä»¥é™„åŠ çš„æ–¹å¼æ‰“å¼€åªå†™æ–‡ä»¶ã€‚若文件ä¸å˜åœ¨ï¼Œåˆ™ä¼šå»ºç«‹è¯¥æ–‡ä»¶ï¼Œå¦‚果文件å˜åœ¨ï¼Œå†™å…¥çš„æ•°æ®ä¼šè¢«åŠ 到文件尾,å³æ–‡ä»¶åŽŸå…ˆçš„内容会被ä¿ç•™ã€‚<br/>- a+ï¼šä»¥é™„åŠ æ–¹å¼æ‰“å¼€å¯è¯»å†™çš„文件。若文件ä¸å˜åœ¨ï¼Œåˆ™ä¼šå»ºç«‹è¯¥æ–‡ä»¶ï¼Œå¦‚果文件å˜åœ¨ï¼Œå†™å…¥çš„æ•°æ®ä¼šè¢«åŠ 到文件尾åŽï¼Œå³æ–‡ä»¶åŽŸå…ˆçš„内容会被ä¿ç•™ã€‚ | -| callback | AsyncCallback<[Stream](#stream7)> | 是 | 异æ¥æ‰“开文件æµä¹‹åŽçš„回调。 | +| callback | AsyncCallback<[Stream](#stream)> | 是 | 异æ¥æ‰“开文件æµä¹‹åŽçš„回调。 | **示例:** @@ -2216,7 +2232,7 @@ createStreamSync(path: string, mode: string): Stream | 类型 | 说明 | | ------------------ | --------- | - | [Stream](#stream7) | 返回文件æµçš„结果。 | + | [Stream](#stream) | 返回文件æµçš„结果。 | **示例:** @@ -2244,7 +2260,7 @@ fdopenStream(fd: number, mode: string): Promise<Stream> | 类型 | 说明 | | --------------------------------- | --------- | - | Promise<[Stream](#stream7)> | Promise对象。返回文件æµçš„结果。 | + | Promise<[Stream](#stream)> | Promise对象。返回文件æµçš„结果。 | **示例:** @@ -2272,7 +2288,7 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待打开文件的文件æ述符。 | | mode | string | 是 | - r:打开åªè¯»æ–‡ä»¶ï¼Œè¯¥æ–‡ä»¶å¿…é¡»å˜åœ¨ã€‚<br/>- r+:打开å¯è¯»å†™çš„文件,该文件必须å˜åœ¨ã€‚<br/>- w:打开åªå†™æ–‡ä»¶ï¼Œè‹¥æ–‡ä»¶å˜åœ¨åˆ™æ–‡ä»¶é•¿åº¦æ¸…0,å³è¯¥æ–‡ä»¶å†…容会消失。若文件ä¸å˜åœ¨åˆ™å»ºç«‹è¯¥æ–‡ä»¶ã€‚<br/>- w+:打开å¯è¯»å†™æ–‡ä»¶ï¼Œè‹¥æ–‡ä»¶å˜åœ¨åˆ™æ–‡ä»¶é•¿åº¦æ¸…0,å³è¯¥æ–‡ä»¶å†…容会消失。若文件ä¸å˜åœ¨åˆ™å»ºç«‹è¯¥æ–‡ä»¶ã€‚<br/>- aï¼šä»¥é™„åŠ çš„æ–¹å¼æ‰“å¼€åªå†™æ–‡ä»¶ã€‚若文件ä¸å˜åœ¨ï¼Œåˆ™ä¼šå»ºç«‹è¯¥æ–‡ä»¶ï¼Œå¦‚果文件å˜åœ¨ï¼Œå†™å…¥çš„æ•°æ®ä¼šè¢«åŠ 到文件尾,å³æ–‡ä»¶åŽŸå…ˆçš„内容会被ä¿ç•™ã€‚<br/>- a+ï¼šä»¥é™„åŠ æ–¹å¼æ‰“å¼€å¯è¯»å†™çš„文件。若文件ä¸å˜åœ¨ï¼Œåˆ™ä¼šå»ºç«‹è¯¥æ–‡ä»¶ï¼Œå¦‚果文件å˜åœ¨ï¼Œå†™å…¥çš„æ•°æ®ä¼šè¢«åŠ 到文件尾åŽï¼Œå³æ–‡ä»¶åŽŸå…ˆçš„内容会被ä¿ç•™ã€‚ | - | callback | AsyncCallback <[Stream](#stream7)> | 是 | 异æ¥æ‰“开文件æµä¹‹åŽçš„回调。 | + | callback | AsyncCallback <[Stream](#stream)> | 是 | 异æ¥æ‰“开文件æµä¹‹åŽçš„回调。 | **示例:** @@ -2303,7 +2319,7 @@ fdopenStreamSync(fd: number, mode: string): Stream | 类型 | 说明 | | ------------------ | --------- | - | [Stream](#stream7) | 返回文件æµçš„结果。 | + | [Stream](#stream) | 返回文件æµçš„结果。 | **示例:** @@ -2720,7 +2736,7 @@ stop(): Promise<void> ```js let filename = path +"/test.txt"; - let watcher = await fileio.createWatcher(filename, 1, function(number){ + let watcher = fileio.createWatcher(filename, 1, function(number){ console.info("Monitoring times: "+number); }); watcher.stop().then(function(){ @@ -2747,7 +2763,7 @@ stop(callback: AsyncCallback<void>): void ```js let filename = path +"/test.txt"; - let watcher = await fileio.createWatcher(filename, 1, function(number){ + let watcher = fileio.createWatcher(filename, 1, function(number){ console.info("Monitoring times: "+number); }); watcher.stop(function(){ @@ -3125,7 +3141,6 @@ read(): Promise<Dirent> **示例:** ```js - let dir = fileio.opendirSync(path); dir.read().then(function (dirent){ console.log("read succeed:"+JSON.stringify(dirent)); }).catch(function(err){ @@ -3151,7 +3166,6 @@ read(callback: AsyncCallback<Dirent>): void **示例:** ```js - let dir = fileio.opendirSync(path); dir.read(function (err, dirent) { if (dirent) { // do something @@ -3178,7 +3192,6 @@ readSync(): Dirent **示例:** ```js - let dir = fileio.opendirSync(path); let dirent = dir.readSync(); ``` @@ -3194,7 +3207,6 @@ close(): Promise<void> **示例:** ```js - let dir = fileio.opendirSync(path); dir.close().then(function(err){ console.info("close dir successfully"); }); @@ -3212,7 +3224,6 @@ close(callback: AsyncCallback<void>): void **示例:** ```js - let dir = fileio.opendirSync(path); dir.close(function(err){ console.info("close dir successfully"); }); @@ -3230,7 +3241,6 @@ closeSync(): void **示例:** ```js - let dir = fileio.opendirSync(path); dir.closeSync(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index 802d3d71d66bb58f8cf9e49f85d4d2f336453140..ab92b4087e433f5409a19602b1028e3ee406c7cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -35,12 +35,10 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]> **示例:** ```js - filemanager.getRoot().then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log("file:"+JSON.stringify(fileInfo)); - } - } + filemanager.getRoot().then((fileInfos) => { + for (var i = 0; i < fileInfos.length; i++) { + console.log("files:"+JSON.stringify(fileInfos)); + } }).catch((err) => { console.log(err) }); @@ -69,14 +67,11 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>) "name":"local" } }; - filemanager.getRoot(options, (err, fileInfo)=>{ - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log("file:"+JSON.stringify(fileInfo)); - } - } + filemanager.getRoot(options, (err, fileInfos)=>{ + for (var i = 0; i < fileInfos.length; i++) { + console.log("files:"+JSON.stringify(fileInfos)); + } }); - ``` ## filemanager.listFile @@ -111,18 +106,17 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num **示例:** ```js - // 获å–目录下所有文件 - // 通过listFileã€getRoot获å–的文件uri - let media_path = "" - filemanager.listFile(media_path, "file") - .then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log("file:"+JSON.stringify(fileInfo)); - } - } + // 获å–目录下所有文件,通过getRoot获å–的目录uri + filemanager.getRoot().then((fileInfos) => { + let file = fileInfos.find(item => item.name == "file_folder"); + let path = file.path; + filemanager.listFile(path, "file").then((files) => { + console.log("files:" + JSON.stringify(files)); + }).catch((err) => { + console.log("failed to get files" + err); + }); }).catch((err) => { - console.log("failed to get file"+err); + console.log("failed to get root" + err); }); ``` @@ -153,33 +147,18 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num **示例:** - ```js - // 通过listFileã€getRoot获å–的文件path - let fileInfos = filemanager.getRoot(); - let media_path = ""; - for (let i = 0; i < fileInfos.length; i++) { - if (fileInfos[i].name == "image_album") { - media_path = fileInfos[i].path; - } else if (fileInfos[i].name == "audio_album") { - media_path = fileInfos[i].path; - } else if (fileInfos[i].name == "video_album") { - media_path = fileInfos[i].path; - } else if (fileInfos[i].name == "file_folder") { - media_path = fileInfos[i].path; - } - } - - filemanager.listFile(media_path, "file") - .then((fileInfo) => { - if(Array.isArray(fileInfo)) { - for (var i = 0; i < fileInfo.length; i++) { - console.log("file:"+JSON.stringify(fileInfo)); - } - } - }).catch((err) => { - console.log("failed to get file"+err); - }); - ``` +```js +// 获å–目录下所有文件,通过getRoot获å–的目录uri +filemanager.getRoot().then((fileInfos) => { + let file = fileInfos.find(item => item.name == "image_album"); + let path = file.path; + filemanager.listFile(path, "image",function(err, files){ + console.log("files:" + JSON.stringify(files)); + }) +}).catch((err) => { + console.log("failed to get root" + err); +}); +``` ## filemanager.createFile diff --git a/zh-cn/application-dev/reference/apis/js-apis-formInfo.md b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md index e8d857b2e2df72995164f0b47593c03e5c2c9700..119d7675b9a78fd454bfb52db57fd91e5bb9f353 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formInfo.md @@ -22,8 +22,6 @@ import formInfo from '@ohos.application.formInfo'; **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 读写属性 | 类型 | æè¿° | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | | bundleName | åªè¯» | string | 表示å¡ç‰‡æ‰€å±žåŒ…的包å。 | @@ -51,8 +49,6 @@ SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 值 | 说明 | | ----------- | ---- | ------------ | | JS | 1 | å¡ç‰‡ç±»åž‹ä¸ºJS。 | @@ -63,8 +59,6 @@ SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 值 | 说明 | | ----------- | ---- | ------------ | | MODE_AUTO | -1 | 自动模å¼ã€‚ | @@ -77,8 +71,6 @@ SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 读写属性 | 类型 | æè¿° | | ----------- | -------- | -------------------- | ------------------------------------------------------------ | | formState | åªè¯» | [FormState](#formstate) | 表示å¡ç‰‡çŠ¶æ€ã€‚ | @@ -90,8 +82,6 @@ SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 值 | 说明 | | ----------- | ---- | ------------ | | UNKNOWN | -1 | 未知状æ€ã€‚ | @@ -104,8 +94,6 @@ SystemCapability.Ability.Form **系统能力**:SystemCapability.Ability.Form -SystemCapability.Ability.Form - | å称 | 值 | 说明 | | ----------- | ---- | ------------ | | IDENTITY_KEY | "ohos.extra.param.key.form_identity" | å¡ç‰‡æ ‡è¯†ã€‚<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextension.md b/zh-cn/application-dev/reference/apis/js-apis-formextension.md index f014698cb88b80a3b5976a7da03f762ae708d89e..4c0c8a855454c9861d1d2ec95fc639445870bcb0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextension.md @@ -225,7 +225,7 @@ onConfigurationUpdated(config: Configuration): void; } ``` - ## FormExtension.onAcquireFormState +## FormExtension.onAcquireFormState onAcquireFormState?(want: Want): formInfo.FormState; diff --git a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md index 841b484a23b78ad1ebb5152311d2963edf4b35a4..6a87544db5dc4e834e36b7e2d4b57298784aea74 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -11,81 +11,22 @@ FormExtensionContext模å—æä¾›FormExtension具有的接å£å’Œèƒ½åŠ›ã€‚ ## 使用说明 -FormExtensionContext模å—是FormExtension的上下文环境,继承自ExtensionContext。 - -## FormExtensionContext.updateForm - -updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void - -主动更新å¡ç‰‡ã€‚ - -**系统能力**:SystemCapability.Ability.Form - -**å‚数:** - - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- | - | formId | string | 是 | 请求更新的å¡ç‰‡ID。 | - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | å¡ç‰‡æ–°çš„æ•°æ®ã€‚ | - | callback | AsyncCallback\<void> | 是 | 回调函数,返回接å£è°ƒç”¨æ˜¯å¦æˆåŠŸçš„结果。 | - -**示例:** - - ```js - import formBindingData from '@ohos.application.formBindingData' - import FormExtension from '@ohos.application.FormExtension' - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2, (data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }); - } - } - - - ``` - -## FormExtensionContext.updateForm - -updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void> - -æ›´æ–°å¡ç‰‡ã€‚ - -**系统能力**:SystemCapability.Ability.Form - -**å‚数:** - - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | --------------- | ------------------------------------------------------------ | ---- | ------------------ | - | formId | string | 是 | 请求更新的å¡ç‰‡ID。 | - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | å¡ç‰‡æ–°çš„æ•°æ®ã€‚ | - -**返回值:** - - | 类型 | 说明 | - | -------------- | --------------------------------- | - | Promise\<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | - -**示例:** +在使用FormExtensionContext的功能å‰ï¼Œéœ€è¦é€šè¿‡FormExtension获å–。 +```js +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData' +export default class MyFormExtension extends FormExtension { + onCreate() { + let dataObj1 = { + temperature:"11c", + "time":"11:00" + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; + } +} - ```js - import formBindingData from '@ohos.application.formBindingData' - import FormExtension from '@ohos.application.FormExtension' - export default class MyFormExtension extends FormExtension { - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); - } - } - - ``` +``` ## FormExtensionContext.startAbility @@ -95,6 +36,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -124,8 +67,12 @@ this.context.startAbility(want, function(err) { startAbility(want: Want): Promise<void> +拉起一个å¡ç‰‡æ‰€å±žåº”用的Ability。 + **系统能力**:SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md index 9e7e8e0c5a2ae8b8cc3fd611d7e0230b3febc9d7..3d81a064465c818b2612eaf17563f65bcf738ffa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md @@ -238,13 +238,13 @@ formProvider.getFormsInfo(filter).then((data) => { ## requestPublishForm<sup>9+</sup> -requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<string>): <void>; +requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void; 请求å‘å¸ƒä¸€å¼ å¡ç‰‡åˆ°ä½¿ç”¨æ–¹ã€‚ -**系统能力:** +**系统能力:** SystemCapability.Ability.Form -SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ **å‚数:** @@ -278,13 +278,13 @@ SystemCapability.Ability.Form ## requestPublishForm<sup>9+</sup> -requestPublishForm(want: Want, callback: AsyncCallback<string>): <void>; +requestPublishForm(want: Want, callback: AsyncCallback<string>): void; 请求å‘å¸ƒä¸€å¼ å¡ç‰‡åˆ°ä½¿ç”¨æ–¹ã€‚ -**系统能力:** +**系统能力:** SystemCapability.Ability.Form -SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ **å‚数:** @@ -319,9 +319,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData 请求å‘å¸ƒä¸€å¼ å¡ç‰‡åˆ°ä½¿ç”¨æ–¹ã€‚ -**系统能力:** +**系统能力:** SystemCapability.Ability.Form -SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ **å‚数:** @@ -362,6 +362,8 @@ isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void; **系统能力:** SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -404,6 +406,8 @@ isRequestPublishFormSupported(): Promise<boolean>; **系统能力:** SystemCapability.Ability.Form +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **返回值:** | 类型 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index 77ef5727a7148b5bcb46644f777524cc85862bb7..3cd5bb1b94919b8e48c4b2c8b215254963bd05aa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -8,8 +8,7 @@ ## å¯¼å…¥æ¨¡å— - -``` +```js import geolocation from '@ohos.geolocation'; ``` @@ -23,17 +22,19 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationChangeâ€ï¼Œè¡¨ç¤ºä½ç½®å˜åŒ–。 | | request | LocationRequest | 是 | 设置ä½ç½®è¯·æ±‚å‚数。 | | callback | Callback<[Location](#location)> | 是 | 接收ä½ç½®å˜åŒ–状æ€å˜åŒ–监å¬ã€‚ | + -- 示例: +**示例** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); @@ -52,16 +53,17 @@ off(type: 'locationChange', callback?: Callback<Location>) : void **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationChangeâ€ï¼Œè¡¨ç¤ºä½ç½®å˜åŒ–。 | | callback | Callback<[Location](#location)> | å¦ | 接收ä½ç½®å˜åŒ–状æ€å˜åŒ–监å¬ã€‚ | -- 示例: +**示例** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { console.log('locationChanger: data: ' + JSON.stringify(location)); @@ -81,18 +83,19 @@ on(type: 'locationServiceState', callback: Callback<boolean>) : void **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationServiceStateâ€ï¼Œè¡¨ç¤ºä½ç½®æœåŠ¡çŠ¶æ€ã€‚ | | callback | Callback<boolean> | 是 | 接收ä½ç½®æœåŠ¡çŠ¶æ€å˜åŒ–监å¬ã€‚ | -- 示例: +**示例** - ``` + ```js var locationServiceState = (state) => { - console.log('locationServiceState: ' + state); + console.log('locationServiceState: ' + JSON.stringify(state)); } geolocation.on('locationServiceState', locationServiceState); ``` @@ -108,18 +111,19 @@ off(type: 'locationServiceState', callback?: Callback<boolean>) : void; **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationServiceStateâ€ï¼Œè¡¨ç¤ºä½ç½®æœåŠ¡çŠ¶æ€ã€‚ | | callback | Callback<boolean> | å¦ | 接收ä½ç½®æœåŠ¡çŠ¶æ€å˜åŒ–监å¬ã€‚ | -- 示例: +**示例** - ``` + ```js var locationServiceState = (state) => { - console.log('locationServiceState: state: ' + state); + console.log('locationServiceState: state: ' + JSON.stringify(state)); } geolocation.on('locationServiceState', locationServiceState); geolocation.off('locationServiceState', locationServiceState); @@ -136,19 +140,20 @@ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, ca **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsReportingâ€ï¼Œè¡¨ç¤ºGNSS缓å˜å®šä½ç»“果上报。 | | request | CachedGnssLocationsRequest | 是 | GNSS缓å˜åŠŸèƒ½é…ç½®å‚æ•° | | callback | Callback<boolean> | 是 | 接收GNSS缓å˜ä½ç½®ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsReporting: locations: ' + locations); + console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); } var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); @@ -165,18 +170,19 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsReportingâ€ï¼Œè¡¨ç¤ºGNSS缓å˜å®šä½ç»“果上报。 | | callback | Callback<boolean> | å¦ | 接收GNSS缓å˜ä½ç½®ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var cachedLocationsCb = (locations) => { - console.log('cachedGnssLocationsReporting: locations: ' + locations); + console.log('cachedGnssLocationsReporting: locations: ' + JSON.stringify(locations)); } var requestInfo = {'reportingPeriodSec': 10, 'wakeUpCacheQueueFull': true}; geolocation.on('cachedGnssLocationsReporting', requestInfo, cachedLocationsCb); @@ -194,18 +200,19 @@ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : vo **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“gnssStatusChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…GNSSå«æ˜ŸçŠ¶æ€ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | | callback | Callback<SatelliteStatusInfo> | 是 | 接收GNSSå«æ˜ŸçŠ¶æ€ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var gnssStatusCb = (satelliteStatusInfo) => { - console.log('gnssStatusChange: ' + satelliteStatusInfo); + console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); } geolocation.on('gnssStatusChange', gnssStatusCb); ``` @@ -221,17 +228,18 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“gnssStatusChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…GNSSå«æ˜ŸçŠ¶æ€ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | | callback | Callback<SatelliteStatusInfo> | å¦ | 接收GNSSå«æ˜ŸçŠ¶æ€ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var gnssStatusCb = (satelliteStatusInfo) => { - console.log('gnssStatusChange: ' + satelliteStatusInfo); + console.log('gnssStatusChange: ' + JSON.stringify(satelliteStatusInfo)); } geolocation.on('gnssStatusChange', gnssStatusCb); geolocation.off('gnssStatusChange', gnssStatusCb); @@ -248,18 +256,19 @@ on(type: 'nmeaMessageChange', callback: Callback<string>) : void; **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“nmeaMessageChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…GNSS NMEAä¿¡æ¯ä¸ŠæŠ¥ã€‚ | | callback | Callback<string> | 是 | 接收GNSS NMEAä¿¡æ¯ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var nmeaCb = (str) => { - console.log('nmeaMessageChange: ' + str); + console.log('nmeaMessageChange: ' + JSON.stringify(str)); } geolocation.on('nmeaMessageChange', nmeaCb ); ``` @@ -275,18 +284,19 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“nmeaMessageChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…GNSS NMEAä¿¡æ¯ä¸ŠæŠ¥ã€‚ | | callback | Callback<string> | å¦ | 接收GNSS NMEAä¿¡æ¯ä¸ŠæŠ¥ã€‚ | -- 示例: +**示例** - ``` + ```js var nmeaCb = (str) => { - console.log('nmeaMessageChange: ' + str); + console.log('nmeaMessageChange: ' + JSON.stringify(str)); } geolocation.on('nmeaMessageChange', nmeaCb); geolocation.off('nmeaMessageChange', nmeaCb); @@ -303,60 +313,38 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; **系统能力**:SystemCapability.Location.Location.Geofence -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“fenceStatusChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…å›´æ 事件上报。 | | request | GeofenceRequest | 是 | å›´æ çš„é…ç½®å‚数。 | | want | WantAgent | 是 | 用于接收地ç†å›´æ 事件上报(进出围æ )。 | -- 示例: +**示例** - ``` - import WantAgent from '@ohos.wantAgent'; - import { OperationType, WantAgentFlags } from '@ohos.wantagent'; - //wantAgent对象 - var wantAgent; - //getWantAgent回调 - function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); - if (err.code == 0) { - wantAgent = data; - } else { - console.info('----getWantAgent failed!----'); - } - } - //WantAgentInfo对象 - var wantAgentInfo = { + ```js + import geolocation from '@ohos.geolocation'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } } ], - operationType: OperationType.START_ABILITIES, + operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - } - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - geolocation.on('fenceStatusChange', requestInfo, wantAgent); + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; + geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); + }); ``` @@ -370,60 +358,91 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void **系统能力**:SystemCapability.Location.Location.Geofence -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“fenceStatusChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…å›´æ 事件上报。 | | request | GeofenceRequest | 是 | å›´æ çš„é…ç½®å‚数。 | | want | WantAgent | 是 | 用于接收地ç†å›´æ 事件上报(进出围æ )。 | -- 示例: +**示例** - ``` - import WantAgent from '@ohos.wantAgent'; - import { OperationType, WantAgentFlags } from '@ohos.wantagent'; - //wantAgent对象 - var wantAgent; - //getWantAgent回调 - function getWantAgentCallback(err, data) { - console.info("==========================>getWantAgentCallback=======================>"); - if (err.code == 0) { - wantAgent = data; - } else { - console.info('----getWantAgent failed!----'); - } - } - //WantAgentInfo对象 - var wantAgentInfo = { + ```js + import geolocation from '@ohos.geolocation'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { wants: [ { - deviceId: "deviceId", - bundleName: "com.neu.setResultOnAbilityResultTest1", - abilityName: "com.example.test.MainAbility", + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } } ], - operationType: OperationType.START_ABILITIES, + operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; + geolocation.on('fenceStatusChange', requestInfo, wantAgentObj); + geolocation.off('fenceStatusChange', requestInfo, wantAgentObj); + }); + ``` + + +## geolocation.on('countryCodeChange')<sup>9+</sup> + +on(type: 'countryCodeChange', callback: Callback<CountryCode>) : void; + +订阅国家ç ä¿¡æ¯ä¸ŠæŠ¥äº‹ä»¶ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 设置事件类型。type为“countryCodeChangeâ€ï¼Œè¡¨ç¤ºè®¢é˜…国家ç ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | + | callback | Callback<CountryCode> | 是 | 接收国家ç ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | + + +**示例** + + ```js + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); } - WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) - var requestInfo = {'priority': 0x201, 'scenario': 0x301, "geofence": {"latitude": 121, "longitude": 26, "radius": 100, "expiration": 10000}}; - geolocation.on('fenceStatusChange', requestInfo, wantAgent); - geolocation.off('fenceStatusChange', requestInfo, wantAgent); + geolocation.on('countryCodeChange', callback); + ``` + + +## geolocation.off('countryCodeChange')<sup>9+</sup> + +off(type: 'countryCodeChange', callback?: Callback<CountryCode>) : void; + +å–消订阅国家ç 上报事件。 + +**系统能力**:SystemCapability.Location.Location.Core + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 设置事件类型。type为“countryCodeChangeâ€ï¼Œè¡¨ç¤ºå–消订阅国家ç ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | + | callback | Callback<CountryCode> | 是 | 接收国家ç ä¿¡æ¯ä¸ŠæŠ¥ã€‚ | + + +**示例** + + ```js + var callback = (code) => { + console.log('countryCodeChange: ' + JSON.stringify(code)); + } + geolocation.on('countryCodeChange', callback); + geolocation.off('countryCodeChange', callback); ``` @@ -438,18 +457,24 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | å¦ | 设置ä½ç½®è¯·æ±‚å‚数。 | | callback | AsyncCallback<[Location](#location)> | 是 | 用æ¥æŽ¥æ”¶ä½ç½®ä¿¡æ¯çš„回调。 | -- 示例: +**示例** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; var locationChange = (err, location) => { - console.log('locationChanger: ' + err + 'data: ' + location); + if (err) { + console.log('locationChanger: err=' + JSON.stringify(err)); + } + if (location) { + console.log('locationChanger: location=' + JSON.stringify(location)); + } }; geolocation.getCurrentLocation(requestInfo, locationChange); geolocation.getCurrentLocation(locationChange); @@ -467,22 +492,24 @@ getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [CurrentLocationRequest](#currentlocationrequest) | å¦ | 设置ä½ç½®è¯·æ±‚å‚数。 | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<[Location](#location)> | 返回ä½ç½®ä¿¡æ¯ã€‚ | -- 示例: +**示例** - ``` + ```js var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; - locationEventListener.getCurrentLocation(requestInfo).then((result) => { + geolocation.getCurrentLocation(requestInfo).then((result) => { console.log('current location: ' + JSON.stringify(result)); }); ``` @@ -498,17 +525,23 @@ getLastLocation(callback: AsyncCallback<Location>) : void **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<[Location](#location)> | 是 | 用æ¥æŽ¥æ”¶ä¸Šæ¬¡ä½ç½®çš„回调。 | -- 示例: +**示例** - ``` + ```js geolocation.getLastLocation((err, data) => { - console.log('getLastLocation: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getLastLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getLastLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -523,15 +556,16 @@ getLastLocation() : Promise<Location> **系统能力**:SystemCapability.Location.Location.Core -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<[Location](#location)> | 返回上次ä½ç½®ä¿¡æ¯ã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.getLastLocation().then((result) => { console.log('getLastLocation: result: ' + JSON.stringify(result)); }); @@ -549,17 +583,22 @@ isLocationEnabled(callback: AsyncCallback<boolean>) : void **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶ä½ç½®æœåŠ¡çŠ¶æ€çš„回调。 | - -- 示例: +**示例** - ``` + ```js geolocation.isLocationEnabled((err, data) => { - console.log('isLocationEnabled: ' + err + " data: " + data); + if (err) { + console.log('isLocationEnabled: err=' + JSON.stringify(err)); + } + if (data) { + console.log('isLocationEnabled: data=' + JSON.stringify(data)); + } }); ``` @@ -574,16 +613,17 @@ isLocationEnabled() : Promise<boolean> **系统能力**:SystemCapability.Location.Location.Core -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 返回ä½ç½®æœåŠ¡æ˜¯å¦å¯ç”¨çš„状æ€ã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.isLocationEnabled().then((result) => { - console.log('promise, isLocationEnabled: ' + result); + console.log('promise, isLocationEnabled: ' + JSON.stringify(result)); }); ``` @@ -599,17 +639,22 @@ requestEnableLocation(callback: AsyncCallback<boolean>) : void **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶ä½ç½®æœåŠ¡çŠ¶æ€çš„回调。 | - -- 示例: +**示例** - ``` + ```js geolocation.requestEnableLocation((err, data) => { - console.log('requestEnableLocation: ' + err + " data: " + data); + if (err) { + console.log('requestEnableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('requestEnableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -624,17 +669,17 @@ requestEnableLocation() : Promise<boolean> **系统能力**:SystemCapability.Location.Location.Core -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 返回ä½ç½®æœåŠ¡æ˜¯å¦å¯ç”¨ã€‚ | - -- 示例: +**示例** - ``` + ```js geolocation.requestEnableLocation().then((result) => { - console.log('promise, requestEnableLocation: ' + result); + console.log('promise, requestEnableLocation: ' + JSON.stringify(result)); }); ``` @@ -647,21 +692,26 @@ enableLocation(callback: AsyncCallback<boolean>) : void; **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ -**需è¦æƒé™**:ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶ä½ç½®æœåŠ¡çŠ¶æ€çš„回调。 | - -- 示例: +**示例** - ``` + ```js geolocation.enableLocation((err, data) => { - console.log('enableLocation: ' + err + " data: " + data); + if (err) { + console.log('enableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('enableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -674,21 +724,21 @@ enableLocation() : Promise<boolean> **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ -**需è¦æƒé™**:ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS **系统能力**:SystemCapability.Location.Location.Core -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 返回ä½ç½®æœåŠ¡æ˜¯å¦å¯ç”¨ã€‚ | - -- 示例: +**示例** - ``` + ```js geolocation.enableLocation().then((result) => { - console.log('promise, enableLocation: ' + result); + console.log('promise, enableLocation: ' + JSON.stringify(result)); }); ``` @@ -700,21 +750,26 @@ disableLocation(callback: AsyncCallback<boolean>) : void; **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ -**需è¦æƒé™**:ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶ä½ç½®æœåŠ¡çŠ¶æ€çš„回调。 | - -- 示例: +**示例** - ``` + ```js geolocation.disableLocation((err, data) => { - console.log('disableLocation: ' + err + " data: " + data); + if (err) { + console.log('disableLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('disableLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -727,21 +782,21 @@ disableLocation() : Promise<boolean> **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ -**需è¦æƒé™**:ohos.permission.LOCATION +**需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS **系统能力**:SystemCapability.Location.Location.Core -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 返回ä½ç½®æœåŠ¡æ˜¯å¦å¯ç”¨ã€‚ | - -- 示例: +**示例** - ``` + ```js geolocation.disableLocation().then((result) => { - console.log('promise, disableLocation: ' + result); + console.log('promise, disableLocation: ' + JSON.stringify(result)); }); ``` @@ -755,17 +810,22 @@ isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void **系统能力**:SystemCapability.Location.Location.Geocoder -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶åœ°ç†ç¼–ç æœåŠ¡çŠ¶æ€çš„回调。 | - -- 示例: +**示例** - ``` + ```js geolocation.isGeoServiceAvailable((err, data) => { - console.log('isGeoServiceAvailable: ' + err + " data: " + data); + if (err) { + console.log('isGeoServiceAvailable: err=' + JSON.stringify(err)); + } + if (data) { + console.log('isGeoServiceAvailable: data=' + JSON.stringify(data)); + } }); ``` @@ -780,22 +840,21 @@ isGeoServiceAvailable() : Promise<boolean> **系统能力**:SystemCapability.Location.Location.Geocoder -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 返回地ç†ç¼–ç æœåŠ¡æ˜¯å¦å¯ç”¨çš„状æ€ã€‚ | - -- 示例: +**示例** - ``` + ```js geolocation.isGeoServiceAvailable().then((result) => { - console.log('promise, isGeoServiceAvailable: ' + result); + console.log('promise, isGeoServiceAvailable: ' + JSON.stringify(result)); }); ``` - ## geolocation.getAddressesFromLocation getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback<Array<GeoAddress>>) : void @@ -806,18 +865,24 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback **系统能力**:SystemCapability.Location.Location.Geocoder -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地ç†ç¼–ç 请求的相关å‚数。 | | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收逆地ç†ç¼–ç 请求的回调å‚数。 | -- 示例: +**示例** - ``` + ```js var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { - console.log('getAddressesFromLocation: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getAddressesFromLocation: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getAddressesFromLocation: data=' + JSON.stringify(data)); + } }); ``` @@ -832,19 +897,21 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<G **系统能力**:SystemCapability.Location.Location.Geocoder -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [ReverseGeoCodeRequest](#reversegeocoderequest) | 是 | 设置逆地ç†ç¼–ç 请求的相关å‚数。 | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | 返回地ç†æè¿°ä¿¡æ¯ã€‚ | -- 示例: +**示例** - ``` + ```js var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { console.log('getAddressesFromLocation: ' + JSON.stringify(data)); @@ -862,19 +929,24 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< **系统能力**:SystemCapability.Location.Location.Geocoder -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地ç†ç¼–ç 请求的相关å‚数。 | | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收地ç†ç¼–ç 请求的回调å‚数。 | - -- 示例: +**示例** - ``` + ```js var geocodeRequest = {"description": "上海市浦东新区xxè·¯xxå·", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { - console.log('getAddressesFromLocationName: ' + err + " data: " + JSON.stringify(data)); + if (err) { + console.log('getAddressesFromLocationName: err=' + JSON.stringify(err)); + } + if (data) { + console.log('getAddressesFromLocationName: data=' + JSON.stringify(data)); + } }); ``` @@ -889,19 +961,21 @@ getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoA **系统能力**:SystemCapability.Location.Location.Geocoder -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | request | [GeoCodeRequest](#geocoderequest) | 是 | 设置地ç†ç¼–ç 请求的相关å‚数。 | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<Array<[GeoAddress](#geoaddress)>> | 设置接收地ç†ç¼–ç 请求的回调å‚数。 | -- 示例: +**示例** - ``` + ```js var geocodeRequest = {"description": "上海市浦东新区xxè·¯xxå·", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { console.log('getAddressesFromLocationName: ' + JSON.stringify(result)); @@ -909,7 +983,6 @@ getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoA ``` - ## geolocation.getCachedGnssLocationsSize<sup>8+</sup> getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; @@ -920,16 +993,22 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<number> | 是 | 用æ¥æŽ¥æ”¶GNSS芯片缓å˜ä½ç½®ä¸ªæ•°çš„回调。 | -- 示例: +**示例** - ``` + ```js geolocation.getCachedGnssLocationsSize((err, size) => { - console.log('getCachedGnssLocationsSize: err:' + err + " size: " + size); + if (err) { + console.log('getCachedGnssLocationsSize: err=' + JSON.stringify(err)); + } + if (size) { + console.log('getCachedGnssLocationsSize: size=' + JSON.stringify(size)); + } }); ``` @@ -944,16 +1023,17 @@ getCachedGnssLocationsSize() : Promise<number>; **系统能力**:SystemCapability.Location.Location.Gnss -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<number> | 返回GNSS缓å˜ä½ç½®çš„个数。 | -- 示例: +**示例** - ``` + ```js geolocation.getCachedGnssLocationsSize().then((result) => { - console.log('promise, getCachedGnssLocationsSize: ' + result); + console.log('promise, getCachedGnssLocationsSize: ' + JSON.stringify(result)); }); ``` @@ -968,16 +1048,22 @@ flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; **系统能力**:SystemCapability.Location.Location.Gnss -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶æ¸…空GNSS芯片缓å˜ä½ç½®æ“作的结果。 | -- 示例: +**示例** - ``` + ```js geolocation.flushCachedGnssLocations((err, result) => { - console.log('flushCachedGnssLocations: err:' + err + " result: " + result); + if (err) { + console.log('flushCachedGnssLocations: err=' + JSON.stringify(err)); + } + if (result) { + console.log('flushCachedGnssLocations: result=' + JSON.stringify(result)); + } }); ``` @@ -992,16 +1078,17 @@ flushCachedGnssLocations() : Promise<boolean>; **系统能力**:SystemCapability.Location.Location.Gnss -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 清空所有GNSS缓å˜ä½ç½®æ˜¯å¦æˆåŠŸã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.flushCachedGnssLocations().then((result) => { - console.log('promise, flushCachedGnssLocations: ' + result); + console.log('promise, flushCachedGnssLocations: ' + JSON.stringify(result)); }); ``` @@ -1016,18 +1103,24 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | command | LocationCommand | 是 | æŒ‡å®šç›®æ ‡åœºæ™¯ï¼Œå’Œå°†è¦å‘é€çš„命令(å—符串)。 | | callback | AsyncCallback<boolean> | 是 | 用æ¥æŽ¥æ”¶å‘½ä»¤å‘é€çš„结果。 | -- 示例: +**示例** - ``` + ```js var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo, (err, result) => { - console.log('sendCommand: err:' + err + " result: " + result); + if (err) { + console.log('sendCommand: err=' + JSON.stringify(err)); + } + if (result) { + console.log('sendCommand: result=' + JSON.stringify(result)); + } }); ``` @@ -1042,22 +1135,24 @@ sendCommand(command: LocationCommand) : Promise<boolean>; **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | command | LocationCommand | 是 | æŒ‡å®šç›®æ ‡åœºæ™¯ï¼Œå’Œå°†è¦å‘é€çš„命令(å—符串)。 | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 表示命令å‘é€æˆåŠŸæˆ–失败。 | -- 示例: +**示例** - ``` + ```js var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo).then((result) => { - console.log('promise, sendCommand: ' + result); + console.log('promise, sendCommand: ' + JSON.stringify(result)); }); ``` @@ -1074,17 +1169,23 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&l **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定éšç§ç”³æ˜Žåœºæ™¯ï¼Œä¾‹å¦‚开机å‘导ä¸çš„éšç§ç”³æ˜Žã€å¼€å¯ç½‘络定ä½åŠŸèƒ½æ—¶å¼¹å‡ºçš„éšç§ç”³æ˜Žç‰ã€‚ | | callback | AsyncCallback<boolean> | 是 | 表示用户是å¦åŒæ„定ä½æœåŠ¡éšç§ç”³æ˜Žã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.isLocationPrivacyConfirmed(1, (err, result) => { - console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); + if (err) { + console.log('isLocationPrivacyConfirmed: err=' + JSON.stringify(err)); + } + if (result) { + console.log('isLocationPrivacyConfirmed: result=' + JSON.stringify(result)); + } }); ``` @@ -1101,21 +1202,23 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean> **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定éšç§ç”³æ˜Žåœºæ™¯ï¼Œä¾‹å¦‚开机å‘导ä¸çš„éšç§ç”³æ˜Žã€å¼€å¯ç½‘络定ä½åŠŸèƒ½æ—¶å¼¹å‡ºçš„éšç§ç”³æ˜Žç‰ã€‚ | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 表示用户是å¦åŒæ„定ä½æœåŠ¡éšç§ç”³æ˜Žã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.isLocationPrivacyConfirmed(1).then((result) => { - console.log('promise, isLocationPrivacyConfirmed: ' + result); + console.log('promise, isLocationPrivacyConfirmed: ' + JSON.stringify(result)); }); ``` @@ -1132,18 +1235,24 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定éšç§ç”³æ˜Žåœºæ™¯ï¼Œä¾‹å¦‚开机å‘导ä¸çš„éšç§ç”³æ˜Žã€å¼€å¯ç½‘络定ä½åŠŸèƒ½æ—¶å¼¹å‡ºçš„éšç§ç”³æ˜Žç‰ã€‚ | | isConfirmed | boolean | 是 | 表示用户是å¦åŒæ„定ä½æœåŠ¡éšç§ç”³æ˜Žã€‚ | | callback | AsyncCallback<boolean> | 是 | 表示æ“作是å¦æˆåŠŸã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.setLocationPrivacyConfirmStatus(1, true, (err, result) => { - console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); + if (err) { + console.log('setLocationPrivacyConfirmStatus: err=' + JSON.stringify(err)); + } + if (result) { + console.log('setLocationPrivacyConfirmStatus: result=' + JSON.stringify(result)); + } }); ``` @@ -1160,26 +1269,534 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea **系统能力**:SystemCapability.Location.Location.Core -- å‚数: - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | type | LocationPrivacyType | 是 | 指定éšç§ç”³æ˜Žåœºæ™¯ï¼Œä¾‹å¦‚开机å‘导ä¸çš„éšç§ç”³æ˜Žã€å¼€å¯ç½‘络定ä½åŠŸèƒ½æ—¶å¼¹å‡ºçš„éšç§ç”³æ˜Žç‰ã€‚ | | isConfirmed | boolean | 是 | 表示用户是å¦åŒæ„定ä½æœåŠ¡éšç§ç”³æ˜Žã€‚ | -- 返回值: - | å‚æ•°å | 说明 | +**返回值**: + + | å‚æ•°å | 说明 | | -------- | -------- | | Promise<boolean> | 表示æ“作是å¦æˆåŠŸã€‚ | -- 示例: +**示例** - ``` + ```js geolocation.setLocationPrivacyConfirmStatus(1, true).then((result) => { - console.log('promise, setLocationPrivacyConfirmStatus: ' + result); + console.log('promise, setLocationPrivacyConfirmStatus: ' + JSON.stringify(result)); }); ``` +## geolocation.getCountryCode<sup>9+</sup> + +getCountryCode(callback: AsyncCallback<CountryCode>) : void; + +查询当å‰çš„国家ç 。 + +**系统能力**:SystemCapability.Location.Location.Core + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<CountryCode> | 是 | 用æ¥æŽ¥æ”¶å›½å®¶ç 。 | + +**示例** + + ```js + geolocation.getCountryCode((err, result) => { + if (err) { + console.log('getCountryCode: err=' + JSON.stringify(err)); + } + if (result) { + console.log('getCountryCode: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.getCountryCode<sup>9+</sup> + +getCountryCode() : Promise<CountryCode>; + +查询当å‰çš„国家ç 。 + +**系统能力**:SystemCapability.Location.Location.Core + +**å‚æ•°**: + +æ— + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<CountryCode> | 返回国家ç 。 | + +**示例** + + ```js + geolocation.getCountryCode() + .then((result) => { + console.log('promise, getCountryCode: result=' + JSON.stringify(result)); + }) + .catch((error) => { + console.log('promise, getCountryCode: error=' + JSON.stringify(error)); + }); + ``` + + +## geolocation.enableLocationMock<sup>9+</sup> + +enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback<void>) : void; + +使能æŸä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ï¼ŒåŒä¸€æ—¶é—´åªèƒ½ä½¿èƒ½ä¸€ä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | å¦ | 指示在什么场景下使能ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var request = {"scenario": 0x0301}; + geolocation.enableLocationMock(request, (err, result) => { + if (err) { + console.log('enableLocationMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('enableLocationMock: result=' + JSON.stringify(result)); + } + }); + ``` + +## geolocation.enableLocationMock<sup>9+</sup> + +enableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; + +使能æŸä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ï¼ŒåŒä¸€æ—¶é—´åªèƒ½ä½¿èƒ½ä¸€ä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | å¦ | 指示使能什么场景的ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚如果ä¸æºå¸¦è¯¥å‚数则表示使能所有场景的ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | + + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var request = {"scenario": 0x0301}; + geolocation.enableLocationMock(request) + .then((result) => { + if (result) { + console.log('promise, enableLocationMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, enableLocationMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.disableLocationMock<sup>9+</sup> + +disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback<void>) : void; + +去使能ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | å¦ | 指示去使能æŸä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚如果ä¸æºå¸¦è¯¥å‚数则表示去使能所有场景的ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var request = {"scenario": 0x0301}; + geolocation.disableLocationMock(request, (err, result) => { + if (err) { + console.log('disableLocationMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('disableLocationMock: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.disableLocationMock<sup>9+</sup> + +disableLocationMock(scenario?: LocationRequestScenario) : Promise<void>; + +去使能ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | scenario | LocationRequestScenario | å¦ | 指示去使能æŸä¸ªåœºæ™¯çš„ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚如果ä¸æºå¸¦è¯¥å‚数则表示去使能所有场景的ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var request = {"scenario": 0x0301}; + geolocation.disableLocationMock(request) + .then((result) => { + if (result) { + console.log('promise, disableLocationMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, disableLocationMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.setMockedLocations<sup>9+</sup> + +setMockedLocations(config: LocationMockConfig, callback: AsyncCallback<void>) : void; + +设置模拟的ä½ç½®ä¿¡æ¯ï¼ŒåŽé¢ä¼šä»¥è¯¥æŽ¥å£ä¸æºå¸¦çš„时间间隔上报模拟ä½ç½®ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | config | LocationMockConfig | 是 | 指示ä½ç½®æ¨¡æ‹Ÿçš„é…ç½®å‚数,包å«æ¨¡æ‹Ÿä½ç½®ä¸ŠæŠ¥çš„时间间隔和模拟ä½ç½®æ•°ç»„。 | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations": locations}; + geolocation.setMockedLocations(config, (err, data) => { + if (err) { + console.log('setMockedLocations: err=' + JSON.stringify(err)); + } + if (data) { + console.log('setMockedLocations: data=' + JSON.stringify(data)); + } + }); + ``` + +## geolocation.setMockedLocations<sup>9+</sup> + +setMockedLocations(config: LocationMockConfig) : Promise<void>; + +设置模拟的ä½ç½®ä¿¡æ¯ï¼ŒåŽé¢ä¼šä»¥è¯¥æŽ¥å£ä¸æºå¸¦çš„时间间隔上报模拟ä½ç½®ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | config | LocationMockConfig | 是 | 指示ä½ç½®æ¨¡æ‹Ÿçš„é…ç½®å‚数,包å«æ¨¡æ‹Ÿä½ç½®ä¸ŠæŠ¥çš„时间间隔和模拟ä½ç½®æ•°ç»„。 | + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var locations = [ + {"latitude": 30.12, "longitude": 120.11, "altitude": 123, "accuracy": 1, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 1000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 31.13, "longitude": 121.11, "altitude": 123, "accuracy": 2, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 2000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 32.14, "longitude": 122.11, "altitude": 123, "accuracy": 3, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 3000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 33.15, "longitude": 123.11, "altitude": 123, "accuracy": 4, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 4000000000, "additionSize": 0, "isFromMock": true}, + {"latitude": 34.16, "longitude": 124.11, "altitude": 123, "accuracy": 5, "speed": 5.2, "timeStamp": 16594326109, "direction": 123.11, "timeSinceBoot": 5000000000, "additionSize": 0, "isFromMock": true} + ]; + var config = {"timeInterval": 5, "locations":locations}; + geolocation.setMockedLocations(config) + .then((result) => { + if (result) { + console.log('promise, setMockedLocations: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, setMockedLocations: error=' + JSON.stringify(error)); + } + }); + ``` + + + +## geolocation.enableReverseGeocodingMock<sup>9+</sup> + +enableReverseGeocodingMock(callback: AsyncCallback<void>) : void; + +使能逆地ç†ç¼–ç 模拟功能。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + geolocation.enableReverseGeocodingMock((err, data) => { + if (err) { + console.log('enableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + if (data) { + console.log('enableReverseGeocodingMock: data=' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.enableReverseGeocodingMock<sup>9+</sup> + +enableReverseGeocodingMock() : Promise<void>; + +使能逆地ç†ç¼–ç 模拟功能。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + +æ— + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + geolocation.enableReverseGeocodingMock() + .then((result) => { + if (result) { + console.log('promise, enableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, enableReverseGeocodingMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.disableReverseGeocodingMock<sup>9+</sup> + +disableReverseGeocodingMock(callback: AsyncCallback<void>) : void; + +去使能逆地ç†ç¼–ç 模拟功能。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + geolocation.disableReverseGeocodingMock((err, result) => { + if (err) { + console.log('disableReverseGeocodingMock: err=' + JSON.stringify(err)); + } + if (result) { + console.log('disableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }); + ``` + + +## geolocation.disableReverseGeocodingMock<sup>9+</sup> + +disableReverseGeocodingMock() : Promise<void>; + +去使能逆地ç†ç¼–ç 模拟功能。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + +æ— + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + geolocation.disableReverseGeocodingMock() + .then((result) => { + if (result) { + console.log('promise, disableReverseGeocodingMock: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, disableReverseGeocodingMock: error=' + JSON.stringify(error)); + } + }); + ``` + + +## geolocation.setReverseGeocodingMockInfo<sup>9+</sup> + +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>, callback: AsyncCallback<void>) : void; + +设置逆地ç†ç¼–ç 模拟功能的é…置信æ¯ï¼ŒåŒ…å«äº†ä½ç½®å’Œåœ°å的对应关系,åŽç»è¿›è¡Œé€†åœ°ç†ç¼–ç 查询时如果ä½ç½®ä¿¡æ¯ä½äºŽé…置信æ¯ä¸ï¼Œå°±è¿”回对应的地å。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | mockInfos | Array<ReverseGeocodingMockInfo> | 是 | 指示逆地ç†ç¼–ç 模拟功能的é…ç½®å‚数数组。逆地ç†ç¼–ç 模拟功能的é…ç½®å‚数包å«äº†ä¸€ä¸ªä½ç½®å’Œä¸€ä¸ªåœ°å。 | + | callback | AsyncCallback<void> | 是 | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geolocation.setReverseGeocodingMockInfo(mockInfos, (err, data) => { + if (err) { + console.log('promise, setReverseGeocodingMockInfo, err:' + JSON.stringify(err)); + } + if (data) { + console.log('promise, setReverseGeocodingMockInfo, data:' + JSON.stringify(data)); + } + }); + ``` + + +## geolocation.setReverseGeocodingMockInfo<sup>9+</sup> + +setReverseGeocodingMockInfo(mockInfos: Array<ReverseGeocodingMockInfo>) : Promise<void>; + +设置逆地ç†ç¼–ç 模拟功能的é…置信æ¯ï¼ŒåŒ…å«äº†ä½ç½®å’Œåœ°å的对应关系,åŽç»è¿›è¡Œé€†åœ°ç†ç¼–ç 查询时如果ä½ç½®ä¿¡æ¯ä½äºŽé…置信æ¯ä¸ï¼Œå°±è¿”回对应的地å。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚æ•°**: + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | mockInfos | Array<ReverseGeocodingMockInfo> | 是 | 指示逆地ç†ç¼–ç 模拟功能的é…置信æ¯æ•°ç»„。逆地ç†ç¼–ç 模拟功能的é…置信æ¯åŒ…å«äº†ä¸€ä¸ªä½ç½®å’Œä¸€ä¸ªåœ°å。 | + +**返回值**: + + | å‚æ•°å | 说明 | + | -------- | -------- | + | Promise<void> | 用æ¥æŽ¥æ”¶æ‰§è¡Œç»“果,如果执行æˆåŠŸå°±è¿”回nullptr,å¦åˆ™å°±è¿”回错误信æ¯ã€‚ | + +**示例** + + ```js + var mockInfos = [ + {"location": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 30.12, "longitude": 120.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 31.12, "longitude": 121.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 32.12, "longitude": 122.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 33.12, "longitude": 123.11, "maxItems": 1, "isFromMock": true}}, + {"location": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1}, "geoAddress": {"locale": "zh", "latitude": 34.12, "longitude": 124.11, "maxItems": 1, "isFromMock": true}}, + ]; + geolocation.setReverseGeocodingMockInfo(mockInfos) + .then((result) => { + if (result) { + console.log('promise, setReverseGeocodingMockInfo: result=' + JSON.stringify(result)); + } + }) + .catch((error) => { + if (error) { + console.log('promise, setReverseGeocodingMockInfo: error=' + JSON.stringify(error)); + } + }); + ``` + ## LocationRequestPriority @@ -1225,13 +1842,15 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea | å称 | 默认值 | 说明 | | -------- | -------- | -------- | -| INPUT_PARAMS_ERROR | 101 | 表示输入å‚数错误。 | -| REVERSE_GEOCODE_ERROR | 102 | 表示逆地ç†ç¼–ç 接å£è°ƒç”¨å¤±è´¥ã€‚ | -| GEOCODE_ERROR | 103 | 表示地ç†ç¼–ç 接å£è°ƒç”¨å¤±è´¥ã€‚ | -| LOCATOR_ERROR | 104 | 表示定ä½å¤±è´¥ã€‚ | -| LOCATION_SWITCH_ERROR | 105 | 表示定ä½å¼€å…³ã€‚ | -| LAST_KNOWN_LOCATION_ERROR | 106 | 表示获å–上次ä½ç½®å¤±è´¥ã€‚ | -| LOCATION_REQUEST_TIMEOUT_ERROR | 107 | 表示å•æ¬¡å®šä½ï¼Œæ²¡æœ‰åœ¨æŒ‡å®šæ—¶é—´å†…返回ä½ç½®ã€‚ | +| NOT_SUPPORTED<sup>9+</sup> | 100 | 表示该接å£åŠŸèƒ½ä¸æ”¯æŒã€‚ | +| INPUT_PARAMS_ERROR<sup>7+</sup> | 101 | 表示输入å‚数错误。 | +| REVERSE_GEOCODE_ERROR<sup>7+</sup> | 102 | 表示逆地ç†ç¼–ç 接å£è°ƒç”¨å¤±è´¥ã€‚ | +| GEOCODE_ERROR<sup>7+</sup> | 103 | 表示地ç†ç¼–ç 接å£è°ƒç”¨å¤±è´¥ã€‚ | +| LOCATOR_ERROR<sup>7+</sup> | 104 | 表示定ä½å¤±è´¥ã€‚ | +| LOCATION_SWITCH_ERROR<sup>7+</sup> | 105 | 表示定ä½å¼€å…³ã€‚ | +| LAST_KNOWN_LOCATION_ERROR<sup>7+</sup> | 106 | 表示获å–上次ä½ç½®å¤±è´¥ã€‚ | +| LOCATION_REQUEST_TIMEOUT_ERROR<sup>7+</sup> | 107 | 表示å•æ¬¡å®šä½ï¼Œæ²¡æœ‰åœ¨æŒ‡å®šæ—¶é—´å†…返回ä½ç½®ã€‚ | +| QUERY_COUNTRY_CODE_ERROR<sup>9+</sup> | 108 | 表示国家ç 查询失败。 | ## ReverseGeoCodeRequest @@ -1279,24 +1898,25 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea | å称 | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| latitude | number | å¦ | 表示纬度信æ¯ï¼Œæ£å€¼è¡¨ç¤ºåŒ—纬,负值表示å—纬。 | -| longitude | number | å¦ | 表示ç»åº¦ä¿¡æ¯ï¼Œæ£å€¼è¡¨ç¤ºä¸œç»ï¼Œè´Ÿå€¼è¡¨æ˜¯è¥¿ç»ã€‚ | -| locale | string | å¦ | 表示ä½ç½®æè¿°ä¿¡æ¯çš„è¯è¨€ï¼Œâ€œzhâ€ä»£è¡¨ä¸æ–‡ï¼Œâ€œenâ€ä»£è¡¨è‹±æ–‡ã€‚ | -| placeName | string | å¦ | 表示地区信æ¯ã€‚ | -| countryCode | string | å¦ | 表示国家ç ä¿¡æ¯ã€‚ | -| countryName | string | å¦ | 表示国家信æ¯ã€‚ | -| administrativeArea | string | å¦ | 表示çœä»½åŒºåŸŸä¿¡æ¯ã€‚ | -| subAdministrativeArea | string | å¦ | 表示表示å区域信æ¯ã€‚ | -| locality | string | å¦ | 表示城市信æ¯ã€‚ | -| subLocality | string | å¦ | 表示å城市信æ¯ã€‚ | -| roadName | string | å¦ | 表示路åä¿¡æ¯ã€‚ | -| subRoadName | string | å¦ | 表示åè·¯åä¿¡æ¯ã€‚ | -| premises | string | å¦ | 表示门牌å·ä¿¡æ¯ã€‚ | -| postalCode | string | å¦ | 表示邮政编ç ä¿¡æ¯ã€‚ | -| phoneNumber | string | å¦ | 表示è”系方å¼ä¿¡æ¯ã€‚ | -| addressUrl | string | å¦ | 表示ä½ç½®ä¿¡æ¯é™„件的网å€ä¿¡æ¯ã€‚ | -| descriptions | Array<string> | å¦ | è¡¨ç¤ºé™„åŠ çš„æè¿°ä¿¡æ¯ã€‚ | -| descriptionsSize | number | å¦ | è¡¨ç¤ºé™„åŠ çš„æè¿°ä¿¡æ¯æ•°é‡ã€‚ | +| latitude<sup>7+</sup> | number | å¦ | 表示纬度信æ¯ï¼Œæ£å€¼è¡¨ç¤ºåŒ—纬,负值表示å—纬。 | +| longitude<sup>7+</sup> | number | å¦ | 表示ç»åº¦ä¿¡æ¯ï¼Œæ£å€¼è¡¨ç¤ºä¸œç»ï¼Œè´Ÿå€¼è¡¨æ˜¯è¥¿ç»ã€‚ | +| locale<sup>7+</sup> | string | å¦ | 表示ä½ç½®æè¿°ä¿¡æ¯çš„è¯è¨€ï¼Œâ€œzhâ€ä»£è¡¨ä¸æ–‡ï¼Œâ€œenâ€ä»£è¡¨è‹±æ–‡ã€‚ | +| placeName<sup>7+</sup> | string | å¦ | 表示地区信æ¯ã€‚ | +| countryCode<sup>7+</sup> | string | å¦ | 表示国家ç ä¿¡æ¯ã€‚ | +| countryName<sup>7+</sup> | string | å¦ | 表示国家信æ¯ã€‚ | +| administrativeArea<sup>7+</sup> | string | å¦ | 表示çœä»½åŒºåŸŸä¿¡æ¯ã€‚ | +| subAdministrativeArea<sup>7+</sup> | string | å¦ | 表示表示å区域信æ¯ã€‚ | +| locality<sup>7+</sup> | string | å¦ | 表示城市信æ¯ã€‚ | +| subLocality<sup>7+</sup> | string | å¦ | 表示å城市信æ¯ã€‚ | +| roadName<sup>7+</sup> | string | å¦ | 表示路åä¿¡æ¯ã€‚ | +| subRoadName<sup>7+</sup> | string | å¦ | 表示åè·¯åä¿¡æ¯ã€‚ | +| premises<sup>7+</sup> | string | å¦ | 表示门牌å·ä¿¡æ¯ã€‚ | +| postalCode<sup>7+</sup> | string | å¦ | 表示邮政编ç ä¿¡æ¯ã€‚ | +| phoneNumber<sup>7+</sup> | string | å¦ | 表示è”系方å¼ä¿¡æ¯ã€‚ | +| addressUrl<sup>7+</sup> | string | å¦ | 表示ä½ç½®ä¿¡æ¯é™„件的网å€ä¿¡æ¯ã€‚ | +| descriptions<sup>7+</sup> | Array<string> | å¦ | è¡¨ç¤ºé™„åŠ çš„æè¿°ä¿¡æ¯ã€‚ | +| descriptionsSize<sup>7+</sup> | number | å¦ | è¡¨ç¤ºé™„åŠ çš„æè¿°ä¿¡æ¯æ•°é‡ã€‚ | +| isFromMock<sup>9+</sup> | Boolean | å¦ | 表示地åä¿¡æ¯æ˜¯å¦æ¥è‡ªäºŽé€†åœ°ç†ç¼–ç 模拟功能。 | ## LocationRequest @@ -1434,13 +2054,68 @@ GNSSå›´æ çš„é…ç½®å‚数。目å‰åªæ”¯æŒåœ†å½¢å›´æ 。 | å称 | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| latitude | number | 是 | 表示纬度信æ¯ï¼Œæ£å€¼è¡¨ç¤ºåŒ—纬,负值表示å—纬。 | -| longitude | number | 是 | 表示ç»åº¦ä¿¡æ¯ï¼Œæ£å€¼è¡¨ç¤ºä¸œç»ï¼Œè´Ÿå€¼è¡¨æ˜¯è¥¿ç»ã€‚ | -| altitude | number | 是 | 表示高度信æ¯ï¼Œå•ä½ç±³ã€‚ | -| accuracy | number | 是 | 表示精度信æ¯ï¼Œå•ä½ç±³ã€‚ | -| speed | number | 是 | 表示速度信æ¯ï¼Œå•ä½ç±³æ¯ç§’。 | -| timeStamp | number | 是 | 表示ä½ç½®æ—¶é—´æˆ³ï¼ŒUTCæ ¼å¼ã€‚ | -| direction | number | 是 | 表示航å‘ä¿¡æ¯ã€‚ | -| timeSinceBoot | number | 是 | 表示ä½ç½®æ—¶é—´æˆ³ï¼Œå¼€æœºæ—¶é—´æ ¼å¼ã€‚ | -| additions | Array<string> | å¦ | é™„åŠ ä¿¡æ¯ã€‚ | -| additionSize | number | å¦ | é™„åŠ ä¿¡æ¯æ•°é‡ã€‚ | +| latitude<sup>7+</sup> | number | 是 | 表示纬度信æ¯ï¼Œæ£å€¼è¡¨ç¤ºåŒ—纬,负值表示å—纬。 | +| longitude<sup>7+</sup> | number | 是 | 表示ç»åº¦ä¿¡æ¯ï¼Œæ£å€¼è¡¨ç¤ºä¸œç»ï¼Œè´Ÿå€¼è¡¨æ˜¯è¥¿ç»ã€‚ | +| altitude<sup>7+</sup> | number | 是 | 表示高度信æ¯ï¼Œå•ä½ç±³ã€‚ | +| accuracy<sup>7+</sup> | number | 是 | 表示精度信æ¯ï¼Œå•ä½ç±³ã€‚ | +| speed<sup>7+</sup> | number | 是 | 表示速度信æ¯ï¼Œå•ä½ç±³æ¯ç§’。 | +| timeStamp<sup>7+</sup> | number | 是 | 表示ä½ç½®æ—¶é—´æˆ³ï¼ŒUTCæ ¼å¼ã€‚ | +| direction<sup>7+</sup> | number | 是 | 表示航å‘ä¿¡æ¯ã€‚ | +| timeSinceBoot<sup>7+</sup> | number | 是 | 表示ä½ç½®æ—¶é—´æˆ³ï¼Œå¼€æœºæ—¶é—´æ ¼å¼ã€‚ | +| additions<sup>7+</sup> | Array<string> | å¦ | é™„åŠ ä¿¡æ¯ã€‚ | +| additionSize<sup>7+</sup> | number | å¦ | é™„åŠ ä¿¡æ¯æ•°é‡ã€‚ | +| isFromMock<sup>9+</sup> | Boolean | å¦ | 表示ä½ç½®ä¿¡æ¯æ˜¯å¦æ¥è‡ªäºŽä½ç½®æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | + + +## ReverseGeocodingMockInfo<sup>9+</sup> + +逆地ç†ç¼–ç 模拟功能的é…置信æ¯ï¼ŒåŒ…å«ä¸€ä¸ªä½ç½®ä¿¡æ¯å’Œä¸€ä¸ªåœ°åä¿¡æ¯ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| location | ReverseGeoCodeRequest | 是 | 表示ç»çº¬åº¦ä¿¡æ¯ã€‚ | +| geoAddress | GeoAddress | 是 | 表示地åä¿¡æ¯ã€‚ | + + +## LocationMockConfig<sup>9+</sup> + +ä½ç½®æ¨¡æ‹ŸåŠŸèƒ½çš„é…ç½®å‚数,包å«äº†æ¨¡æ‹Ÿä½ç½®ä¸ŠæŠ¥çš„时间间隔和模拟ä½ç½®æ•°ç»„。 + +**系统能力**:SystemCapability.Location.Location.Core + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| timeInterval | number | 是 | 表示模拟ä½ç½®ä¸ŠæŠ¥çš„时间间隔,å•ä½æ˜¯ç§’。 | +| locations | Array<Location> | 是 | 表示模拟ä½ç½®æ•°ç»„。 | + + +## CountryCode<sup>9+</sup> + +国家ç ä¿¡æ¯ç»“构体,包å«å›½å®¶ç å—符串和国家ç çš„æ¥æºä¿¡æ¯ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| country | string | 是 | 表示国家ç å—符串。 | +| type | CountryCodeType | 是 | 表示国家ç ä¿¡æ¯æ¥æºã€‚ | + + +## CountryCodeType<sup>9+</sup> + +国家ç æ¥æºç±»åž‹ã€‚ + +**系统能力**:SystemCapability.Location.Location.Core + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| COUNTRY_CODE_FROM_LOCALE | 1 | 从全çƒåŒ–模å—çš„è¯è¨€é…置信æ¯ä¸èŽ·å–到的国家ç 。 | +| COUNTRY_CODE_FROM_SIM | 2 | 从SIMå¡ä¸èŽ·å–到的国家ç 。 | +| COUNTRY_CODE_FROM_LOCATION | 3 | 基于用户的ä½ç½®ä¿¡æ¯ï¼Œé€šè¿‡é€†åœ°ç†ç¼–ç 查询到的国家ç 。 | +| COUNTRY_CODE_FROM_NETWORK | 4 | 从蜂çªç½‘络注册信æ¯ä¸èŽ·å–到的国家ç 。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md index 58da6c591b600ee7063a9fe2e00d642f50139888..26a7adcbafda064eedff82290d791b3e9016f40f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md @@ -26,7 +26,7 @@ getNativeHeapSize(): bigint | 类型 | 说明 | | ------ | --------------------------- | -| bigint | 返回native heap内å˜æ€»å¤§å°ã€‚ | +| bigint | 返回native heap内å˜æ€»å¤§å°ï¼Œå•ä½ä¸ºkB。 | **示例:** @@ -49,7 +49,7 @@ getNativeHeapAllocatedSize(): bigint **返回值:** | 类型 | 说明 | | ------ | --------------------------------- | -| bigint | 返回native heap内å˜çš„已分é…内å˜ã€‚ | +| bigint | 返回native heap内å˜çš„已分é…内å˜ï¼Œå•ä½ä¸ºkB。 | **示例:** @@ -72,7 +72,7 @@ getNativeHeapFreeSize(): bigint **返回值:** | 类型 | 说明 | | ------ | ------------------------------- | -| bigint | 返回native heap内å˜çš„空闲内å˜ã€‚ | +| bigint | 返回native heap内å˜çš„空闲内å˜ï¼Œå•ä½ä¸ºkB。 | **示例:** @@ -93,7 +93,7 @@ getPss(): bigint **返回值:** | 类型 | 说明 | | ------ | ------------------------- | -| bigint | 返回应用进程PSS内å˜å¤§å°ã€‚ | +| bigint | 返回应用进程PSS内å˜å¤§å°ï¼Œå•ä½ä¸ºkB。 | **示例:** @@ -114,7 +114,7 @@ getSharedDirty(): bigint **返回值:** | 类型 | 说明 | | ------ | -------------------------- | -| bigint | 返回进程的共享è„内å˜å¤§å°ã€‚ | +| bigint | 返回进程的共享è„内å˜å¤§å°ï¼Œå•ä½ä¸ºkB。 | **示例:** @@ -134,7 +134,7 @@ getPrivateDirty(): bigint **返回值:** | 类型 | 说明 | | ------ | -------------------------- | -| bigint | 返回进程的ç§æœ‰è„内å˜å¤§å°ã€‚ | +| bigint | 返回进程的ç§æœ‰è„内å˜å¤§å°ï¼Œå•ä½ä¸ºkB。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md index 6cc5ea38e9bc6c15dfa73a02957d999c3406c5a0..c811da3849cdd8b77c0be23b5dd84ca15c123acb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hisysevent.md @@ -4,7 +4,7 @@ >  **说明:** > - 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 -> - 本模å—的接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +> - 本模å—的接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— diff --git a/zh-cn/application-dev/reference/apis/js-apis-http.md b/zh-cn/application-dev/reference/apis/js-apis-http.md index 33f83d33ea014f99f8d0e484b7d3a9cba2204dd3..54875254f16c162376e44e39b0239173193afd5e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-http.md +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -1,6 +1,6 @@ # æ•°æ®è¯·æ±‚ -本模å—æä¾›httpæ•°æ®è¯·æ±‚能力。应用å¯ä»¥é€šè¿‡HTTPå‘起一个数æ®è¯·æ±‚,支æŒå¸¸è§çš„GETã€POSTã€OPTIONSã€HEADã€PUTã€DELETEã€TRACEã€CONNECT方法。 +本模å—æä¾›HTTPæ•°æ®è¯·æ±‚能力。应用å¯ä»¥é€šè¿‡HTTPå‘起一个数æ®è¯·æ±‚,支æŒå¸¸è§çš„GETã€POSTã€OPTIONSã€HEADã€PUTã€DELETEã€TRACEã€CONNECT方法。 >**说明:** > @@ -18,15 +18,15 @@ import http from '@ohos.net.http'; ```js import http from '@ohos.net.http'; -// æ¯ä¸€ä¸ªhttpRequest对应一个http请求任务,ä¸å¯å¤ç”¨ +// æ¯ä¸€ä¸ªhttpRequest对应一个HTTP请求任务,ä¸å¯å¤ç”¨ let httpRequest = http.createHttp(); -// 用于订阅httpå“应头,æ¤æŽ¥å£ä¼šæ¯”request请求先返回。å¯ä»¥æ ¹æ®ä¸šåŠ¡éœ€è¦è®¢é˜…æ¤æ¶ˆæ¯ +// 用于订阅HTTPå“应头,æ¤æŽ¥å£ä¼šæ¯”request请求先返回。å¯ä»¥æ ¹æ®ä¸šåŠ¡éœ€è¦è®¢é˜…æ¤æ¶ˆæ¯ // 从API 8开始,使用on('headersReceive', Callback)替代on('headerReceive', AsyncCallback)。 8+ httpRequest.on('headersReceive', (header) => { console.info('header: ' + JSON.stringify(header)); }); httpRequest.request( - // 填写http请求的url地å€ï¼Œå¯ä»¥å¸¦å‚数也å¯ä»¥ä¸å¸¦å‚数。URL地å€éœ€è¦å¼€å‘者自定义。请求的å‚æ•°å¯ä»¥åœ¨extraDataä¸æŒ‡å®š + // 填写HTTP请求的URL地å€ï¼Œå¯ä»¥å¸¦å‚数也å¯ä»¥ä¸å¸¦å‚数。URL地å€éœ€è¦å¼€å‘者自定义。请求的å‚æ•°å¯ä»¥åœ¨extraDataä¸æŒ‡å®š "EXAMPLE_URL", { method: http.RequestMethod.POST, // å¯é€‰ï¼Œé»˜è®¤ä¸ºhttp.RequestMethod.GET @@ -38,14 +38,14 @@ httpRequest.request( extraData: { "data": "data to send", }, - connectTimeout: 60000, // å¯é€‰ï¼Œé»˜è®¤ä¸º60s - readTimeout: 60000, // å¯é€‰ï¼Œé»˜è®¤ä¸º60s + connectTimeout: 60000, // å¯é€‰ï¼Œé»˜è®¤ä¸º60000ms + readTimeout: 60000, // å¯é€‰ï¼Œé»˜è®¤ä¸º60000ms }, (err, data) => { if (!err) { - // data.result为httpå“应内容,å¯æ ¹æ®ä¸šåŠ¡éœ€è¦è¿›è¡Œè§£æž + // data.result为HTTPå“应内容,å¯æ ¹æ®ä¸šåŠ¡éœ€è¦è¿›è¡Œè§£æž console.info('Result:' + data.result); console.info('code:' + data.responseCode); - // data.header为httpå“应头,å¯æ ¹æ®ä¸šåŠ¡éœ€è¦è¿›è¡Œè§£æž + // data.header为HTTPå“应头,å¯æ ¹æ®ä¸šåŠ¡éœ€è¦è¿›è¡Œè§£æž console.info('header:' + JSON.stringify(data.header)); console.info('cookies:' + data.cookies); // 8+ } else { @@ -61,7 +61,7 @@ httpRequest.request( createHttp\(\): HttpRequest -创建一个http,里é¢åŒ…括å‘起请求ã€ä¸æ–请求ã€è®¢é˜…/å–消订阅HTTP Response Header 事件。æ¯ä¸€ä¸ªHttpRequest对象对应一个Http请求。如需å‘起多个Http请求,须为æ¯ä¸ªHttp请求创建对应HttpRequest对象。 +创建一个HTTP请求,里é¢åŒ…括å‘起请求ã€ä¸æ–请求ã€è®¢é˜…/å–消订阅HTTP Response Header事件。æ¯ä¸€ä¸ªHttpRequest对象对应一个HTTP请求。如需å‘起多个HTTP请求,须为æ¯ä¸ªHTTP请求创建对应HttpRequest对象。 **系统能力**:SystemCapability.Communication.NetStack @@ -81,7 +81,7 @@ let httpRequest = http.createHttp(); ## HttpRequest -http请求任务。在调用HttpRequest的方法å‰ï¼Œéœ€è¦å…ˆé€šè¿‡[createHttp\(\)](#httpcreatehttp)创建一个任务。 +HTTP请求任务。在调用HttpRequest的方法å‰ï¼Œéœ€è¦å…ˆé€šè¿‡[createHttp\(\)](#httpcreatehttp)创建一个任务。 ### request @@ -432,9 +432,9 @@ request方法回调函数的返回值类型。 | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | -| result | string \| Object \| ArrayBuffer<sup>8+</sup> | 是 | Httpè¯·æ±‚æ ¹æ®å“应头ä¸Content-type类型返回对应的å“åº”æ ¼å¼å†…容:<br />- application/json:返回JSONæ ¼å¼çš„å—符串,如需Httpå“应具体内容,需开å‘者自行解æž<br />- application/octet-stream:ArrayBuffer<br />- 其他:string | +| result | string \| Object \| ArrayBuffer<sup>8+</sup> | 是 | HTTPè¯·æ±‚æ ¹æ®å“应头ä¸Content-type类型返回对应的å“åº”æ ¼å¼å†…容:<br />- application/json:返回JSONæ ¼å¼çš„å—符串,如需HTTPå“应具体内容,需开å‘者自行解æž<br />- application/octet-stream:ArrayBuffer<br />- 其他:string | | responseCode | [ResponseCode](#responsecode) \| number | 是 | 回调函数执行æˆåŠŸæ—¶ï¼Œæ¤å—段为[ResponseCode](#responsecode)。若执行失败,错误ç 将会从AsyncCallbackä¸çš„errå—段返回。错误ç å‚考[Response错误ç ](#response常用错误ç )。 | -| header | Object | 是 | å‘èµ·http请求返回æ¥çš„å“应头。当å‰è¿”回的是JSONæ ¼å¼å—符串,如需具体å—段内容,需开å‘者自行解æžã€‚常è§å—段åŠè§£æžæ–¹å¼å¦‚下:<br/>- Content-Type:header['Content-Type']ï¼›<br />- Status-Line:header['Status-Line']ï¼›<br />- Date:header.Date/header['Date']ï¼›<br />- Server:header.Server/header['Server']ï¼› | +| header | Object | 是 | å‘èµ·HTTP请求返回æ¥çš„å“应头。当å‰è¿”回的是JSONæ ¼å¼å—符串,如需具体å—段内容,需开å‘者自行解æžã€‚常è§å—段åŠè§£æžæ–¹å¼å¦‚下:<br/>- Content-Type:header['Content-Type']ï¼›<br />- Status-Line:header['Status-Line']ï¼›<br />- Date:header.Date/header['Date']ï¼›<br />- Server:header.Server/header['Server']ï¼› | | cookies<sup>8+</sup> | Array\<string\> | 是 | æœåŠ¡å™¨è¿”回的 cookies。 | ## Response常用错误ç diff --git a/zh-cn/application-dev/reference/apis/js-apis-huks.md b/zh-cn/application-dev/reference/apis/js-apis-huks.md index e6ab60f61b19eebe48128c5dd85eef3f7de5586d..0f4c594431e26d488432f9fd63f1022d6713dcdb 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-huks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-huks.md @@ -16,7 +16,7 @@ import huks from '@ohos.security.huks' 表示错误ç 的枚举。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | -------------------------- | ----- | ---- | @@ -59,6 +59,11 @@ import huks from '@ohos.security.huks' | HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |表示å˜åœ¨æ–°çš„æ ¹å¯†é’¥æ料。| | HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |è¡¨ç¤ºæ›´æ–°æ ¹å¯†é’¥æ料失败。| | HUKS_ERROR_VERIFICATION_FAILED | -38 |表示验è¯è¯ä¹¦é“¾å¤±è´¥ã€‚| +| HUKS_ERROR_GET_USERIAM_SECINFO_FAILED<sup>9+</sup> | -40 |表示获å–当å‰ç”¨æˆ·å®‰å…¨å±žæ€§ä¿¡æ¯å¤±è´¥ã€‚| +| HUKS_ERROR_GET_USERIAM_AUTHINFO_FAILED<sup>9+</sup> | -41 |表示获å–当å‰ç”¨æˆ·è®¤è¯ä¿¡æ¯å¤±è´¥ã€‚| +| HUKS_ERROR_USER_AUTH_TYPE_NOT_SUPPORT<sup>9+</sup> | -42 |表示ä¸æ”¯æŒå½“å‰ç”¨æˆ·è®¤è¯ç±»åž‹çš„访问控制。| +| HUKS_ERROR_KEY_AUTH_FAILED<sup>9+</sup> | -43 |表示安全访问控制认è¯å¤±è´¥ã€‚| +| HUKS_ERROR_DEVICE_NO_CREDENTIAL<sup>9+</sup> | -44 |表示设备当å‰æœªå½•å…¥å‡æ®ã€‚| | HUKS_ERROR_CHECK_GET_ALG_FAIL | -100 |è¡¨ç¤ºæ£€æŸ¥èŽ·å– ALG 失败。| | HUKS_ERROR_CHECK_GET_KEY_SIZE_FAIL | -101 |表示检查获å–密钥大å°å¤±è´¥ã€‚| | HUKS_ERROR_CHECK_GET_PADDING_FAIL | -102 |表示检查获å–填充失败。| @@ -95,7 +100,7 @@ import huks from '@ohos.security.huks' 表示密钥用途。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ------------------------ | ---- | -------------------------------- | @@ -113,7 +118,7 @@ import huks from '@ohos.security.huks' 表示摘è¦ç®—法。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ---------------------- | ---- | ---------------------------------------- | @@ -130,7 +135,7 @@ import huks from '@ohos.security.huks' 表示补é½ç®—法。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ---------------------- | ---- | ---------------------------------------- | @@ -145,7 +150,7 @@ import huks from '@ohos.security.huks' è¡¨ç¤ºåŠ å¯†æ¨¡å¼ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ------------- | ---- | --------------------- | @@ -160,7 +165,7 @@ import huks from '@ohos.security.huks' 表示密钥长度。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ---------------------------------- | ---- | ------------------------------------------ | @@ -189,7 +194,7 @@ import huks from '@ohos.security.huks' 表示密钥使用的算法。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ------------------------- | ---- | --------------------- | @@ -212,7 +217,7 @@ import huks from '@ohos.security.huks' 表示生æˆå¯†é’¥çš„类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ------------------------------ | ---- | ---------------- | @@ -224,7 +229,7 @@ import huks from '@ohos.security.huks' 表示密钥的产生方å¼ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | -------------------------- | ---- | ------------------------------------ | @@ -237,7 +242,7 @@ import huks from '@ohos.security.huks' 表示密钥å˜å‚¨æ–¹å¼ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ----------------------- | ---- | ------------------------------ | @@ -248,7 +253,7 @@ import huks from '@ohos.security.huks' 表示å‘é€Tagçš„æ–¹å¼ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | -------------------- | ---- | ----------------- | @@ -259,7 +264,7 @@ import huks from '@ohos.security.huks' è¡¨ç¤ºå¯¼å…¥åŠ å¯†å¯†é’¥çš„ç®—æ³•å¥—ä»¶ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ---------------------------------------------- | ---- | ----------------------------------------------------- | @@ -270,7 +275,7 @@ import huks from '@ohos.security.huks' 表示导入密钥的密钥类型,默认为导入公钥,导入对称密钥时ä¸éœ€è¦è¯¥å—段。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | ------------------------- | ---- | ------------------------------ | @@ -278,11 +283,69 @@ import huks from '@ohos.security.huks' | HUKS_KEY_TYPE_PRIVATE_KEY | 1 | 表示导入的密钥类型为ç§é’¥ã€‚ | | HUKS_KEY_TYPE_KEY_PAIR | 2 | 表示导入的密钥类型为公ç§é’¥å¯¹ã€‚ | +## HuksUserAuthType<sup>9+</sup> + +表示用户认è¯ç±»åž‹ã€‚ + +**系统能力**:SystemCapability.Security.Huks + +| å称 | 值 | 说明 | +| ------------------------------- | ---- | ------------------------- | +| HUKS_USER_AUTH_TYPE_FINGERPRINT | 1 | 表示用户认è¯ç±»åž‹ä¸ºæŒ‡çº¹ã€‚ | +| HUKS_USER_AUTH_TYPE_FACE | 2 | 表示用户认è¯ç±»åž‹ä¸ºäººè„¸ 。 | +| HUKS_USER_AUTH_TYPE_PIN | 4 | 表示用户认è¯ç±»åž‹ä¸ºPINç 。 | + +## HuksAuthAccessType<sup>9+</sup> + +表示安全访问控制类型。 + +**系统能力**:SystemCapability.Security.Huks + +| å称 | 值 | 说明 | +| --------------------------------------- | ---- | ------------------------------------------------ | +| HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD | 1 | 表示安全访问控制类型为清除密ç åŽå¯†é’¥æ— 效。 | +| HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL | 2 | 表示安全访问控制类型为新录入生物特å¾åŽå¯†é’¥æ— 效。 | + +## HuksChallengeType<sup>9+</sup> + +表示密钥使用时生æˆchallenge的类型。 + +**系统能力**:SystemCapability.Security.Huks + +| å称 | 值 | 说明 | +| ------------------------------- | ---- | ------------------------------ | +| HUKS_CHALLENGE_TYPE_NORMAL | 0 | 表示challenge为普通类型,默认32å—节。 | +| HUKS_CHALLENGE_TYPE_CUSTOM | 1 | 表示challenge为用户自定义类型。支æŒä½¿ç”¨å¤šä¸ªå¯†é’¥ä»…一次认è¯ã€‚ | +| HUKS_CHALLENGE_TYPE_NONE | 2 | 表示å…challenge类型。 | + +## HuksChallengePosition<sup>9+</sup> + +表示challenge类型为用户自定义类型时,生æˆçš„challenge有效长度仅为8å—节连ç»çš„æ•°æ®ï¼Œä¸”仅支æŒ4ç§ä½ç½® 。 + +**系统能力**:SystemCapability.Security.Huks + +| å称 | 值 | 说明 | +| ------------------------------- | ---- | ------------------------------ | +| HUKS_CHALLENGE_POS_0 | 0 | 表示0~7å—节为当å‰å¯†é’¥çš„有效challenge。 | +| HUKS_CHALLENGE_POS_1 | 1 | 表示8~15å—节为当å‰å¯†é’¥çš„有效challenge。 | +| HUKS_CHALLENGE_POS_2 | 2 | 表示16~23å—节为当å‰å¯†é’¥çš„有效challenge。 | +| HUKS_CHALLENGE_POS_3 | 3 | 表示24~31å—节为当å‰å¯†é’¥çš„有效challenge。 | + +## HuksSecureSignType<sup>9+</sup> + +表示生æˆæˆ–导入密钥时,指定该密钥的ç¾å类型。 + +**系统能力**:SystemCapability.Security.Huks + +| å称 | 值 | 说明 | +| ------------------------------ | ---- | ------------------------------------------------------------ | +| HUKS_SECURE_SIGN_WITH_AUTHINFO | 1 | 表示ç¾å类型为æºå¸¦è®¤è¯ä¿¡æ¯ã€‚生æˆæˆ–导入密钥时指定该å—段,则在使用密钥进行ç¾å时,对待ç¾åçš„æ•°æ®æ·»åŠ 认è¯ä¿¡æ¯åŽè¿›è¡Œç¾å。 | + ## HuksTagType 表示Tagçš„æ•°æ®ç±»åž‹ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | @@ -298,7 +361,7 @@ import huks from '@ohos.security.huks' 表示调用å‚æ•°çš„Tag。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å称 | 值 | 说明 | | -------------------------------------------- | ---------------------------------------- | -------------------------------------- | @@ -336,9 +399,13 @@ import huks from '@ohos.security.huks' | HUKS_TAG_ALL_USERS | ksTagType.HUKS_TAG_TYPE_BOOL \| 301 | 预留。 | | HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | 预留。 | | HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | 预留。 | -| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | 预留。 | +| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | 表示用户认è¯ç±»åž‹ã€‚从[HuksUserAuthType](#huksuserauthtype9)ä¸é€‰æ‹©ï¼Œéœ€è¦ä¸Žå®‰å…¨è®¿é—®æŽ§åˆ¶ç±»åž‹åŒæ—¶è®¾ç½®ã€‚支æŒåŒæ—¶æŒ‡å®šä¸¤ç§ç”¨æˆ·è®¤è¯ç±»åž‹ï¼Œå¦‚:安全访问控制类型指定为HKS_SECURE_ACCESS_INVALID_NEW_BIO_ENROLL时,密钥访问认è¯ç±»åž‹å¯ä»¥æŒ‡å®šä»¥ä¸‹ä¸‰ç§ï¼š HKS_USER_AUTH_TYPE_FACE ã€HKS_USER_AUTH_TYPE_FINGERPRINTã€HKS_USER_AUTH_TYPE_FACE \| HKS_USER_AUTH_TYPE_FINGERPRINT | | HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | 预留。 | | HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | 预留。 | +| HUKS_TAG_KEY_AUTH_ACCESS_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 307 | 表示安全访问控制类型。从[HuksAuthAccessType](#huksauthaccesstype9)ä¸é€‰æ‹©ï¼Œéœ€è¦å’Œç”¨æˆ·è®¤è¯ç±»åž‹åŒæ—¶è®¾ç½®ã€‚ | +| HUKS_TAG_KEY_SECURE_SIGN_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 308 | 表示生æˆæˆ–导入密钥时,指定该密钥的ç¾å类型。 | +| HUKS_TAG_CHALLENGE_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 309 | 表示密钥使用时生æˆçš„challenge类型。从[HuksChallengeType](#hukschallengetype9)ä¸é€‰æ‹© | +| HUKS_TAG_CHALLENGE_POS<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 310 | 表示challenge类型为用户自定义类型时,huks产生的challenge有效长度仅为8å—节连ç»çš„æ•°æ®ã€‚从[HuksChallengePosition](#hukschallengeposition9)ä¸é€‰æ‹©ã€‚ | | HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | 表示attestation时的挑战值。 | | HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | 表示attestation时拥有该密钥的applicationçš„Id。 | | HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | 表示设备的å“牌。 | @@ -387,7 +454,7 @@ generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<Huk 生æˆå¯†é’¥ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -437,7 +504,7 @@ generateKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult> 生æˆå¯†é’¥ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -488,7 +555,7 @@ deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR åˆ é™¤å¯†é’¥ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -515,7 +582,7 @@ deleteKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult> åˆ é™¤å¯†é’¥ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -547,7 +614,7 @@ getSdkVersion(options: HuksOptions) : string 获å–当å‰ç³»ç»Ÿsdk版本。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -577,7 +644,7 @@ importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR 导入明文密钥,使用Callbackæ–¹å¼å›žè°ƒå¼‚æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -635,7 +702,7 @@ importKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult> 导入明文密钥,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -700,7 +767,7 @@ importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOption å¯¼å…¥åŠ å¯†å¯†é’¥ï¼Œä½¿ç”¨Callbackæ–¹å¼å›žè°ƒå¼‚æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -804,8 +871,8 @@ async function TestImportWrappedKeyFunc( * å‡è®¾å¾…导入的密钥为keyA * 1.生æˆECCå…¬ç§é’¥keyB,公钥为keyB_pub, ç§é’¥ä¸ºkeyB_pri * 2.使用keyB_priå’ŒwrappingAlias密钥ä¸èŽ·å–的公钥进行密钥å商,å商出共享密钥share_key - * 3.éšæœºç”Ÿæˆå¯†é’¥kekï¼Œç”¨äºŽåŠ å¯†keyA,采用AES-GCMåŠ å¯†ï¼ŒåŠ å¯†è¿‡ç¨‹ä¸éœ€è¦è®°å½•ï¼šnonce1/aad1/åŠ å¯†åŽçš„密文keyA_enc/åŠ å¯†åŽçš„tag1。 - * 4.使用share_keyåŠ å¯†kek,采用AES-GCMåŠ å¯†ï¼ŒåŠ å¯†è¿‡ç¨‹ä¸éœ€è¦è®°å½•ï¼šnonce2/aad2/åŠ å¯†åŽçš„密文kek_enc/åŠ å¯†åŽçš„tag2。 + * 3.éšæœºç”Ÿæˆå¯†é’¥kekï¼Œç”¨äºŽåŠ å¯†keyA,采用AES-GCMåŠ å¯†ï¼ŒåŠ å¯†è¿‡ç¨‹ä¸éœ€è¦è®°å½•ï¼šnonce1ã€aad1ã€åŠ 密åŽçš„密文keyA_encã€åŠ 密åŽçš„tag1。 + * 4.使用share_keyåŠ å¯†kek,采用AES-GCMåŠ å¯†ï¼ŒåŠ å¯†è¿‡ç¨‹ä¸éœ€è¦è®°å½•ï¼šnonce2ã€aad2ã€åŠ 密åŽçš„密文kek_encã€åŠ 密åŽçš„tag2。 * 5.拼接importOptions.inDataå—æ®µï¼Œæ»¡è¶³ä»¥ä¸‹æ ¼å¼: * keyB_pub的长度(4å—节) + keyB_pubçš„æ•°æ® + aad2的长度(4å—节) + aad2çš„æ•°æ® + * nonce2的长度(4å—节) + nonce2çš„æ•°æ® + tag2的长度(4å—节) + tag2çš„æ•°æ® + @@ -888,7 +955,7 @@ importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOption å¯¼å…¥åŠ å¯†å¯†é’¥ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -924,7 +991,7 @@ exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR 导出密钥,使用Callbackæ–¹å¼å›žè°ƒå¼‚æ¥è¿”回的结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -951,7 +1018,7 @@ exportKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult> 导出密钥,使用Promiseæ–¹å¼å›žè°ƒå¼‚æ¥è¿”回的结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -983,7 +1050,7 @@ getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback 获å–密钥属性,使用Callback回调异æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1010,7 +1077,7 @@ getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksResult> 获å–密钥属性,使用Promise回调异æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1042,7 +1109,7 @@ isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<bool 判æ–密钥是å¦å˜åœ¨ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1069,7 +1136,7 @@ isKeyExist(keyAlias: string, options: HuksOptions) : Promise\<boolean> 判æ–密钥是å¦å˜åœ¨ï¼Œä½¿ç”¨Promise回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1103,7 +1170,7 @@ init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksHandle initæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1120,7 +1187,7 @@ init(keyAlias: string, options: HuksOptions) : Promise\<HuksHandle> initæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1131,41 +1198,94 @@ initæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 | promise | Promise\<[HuksHandle](#hukshandle)> | 是 | å°†Initæ“作返回的handleæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | -## huks.update +## huks.update<sup>(deprecated)</sup> update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void updateæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.update<sup>9+</sup>](#huksupdate9)替代。 -**å‚数:** +**系统能力**: SystemCapability.Security.Huks -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | 是 | Updateæ“作的handle。 | -| token | Uint8Array | å¦ | Updateæ“作的token。 | -| options | [HuksOptions](#huksoptions) | 是 | Updateçš„å‚数集åˆã€‚ | -| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Updateæ“作的handle。 | +| token | Uint8Array | å¦ | Updateæ“作的token。 | +| options | [HuksOptions](#huksoptions) | 是 | Updateæ“作的å‚数集åˆã€‚ | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | -## huks.update +## huks.update<sup>(deprecated)</sup> update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\<HuksResult> updateæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +> **说明:** 从API Version 9开始废弃,建议使用[huks.update<sup>9+</sup>](#huksupdate9)替代。 + +**系统能力**: SystemCapability.Security.Huks **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------- | ---- | ------------------------------------- | -| handle | number | 是 | Updateæ“作的handle。 | -| token | Uint8Array | å¦ | Updateæ“作的token。 | -| options | [HuksOptions](#huksoptions) | 是 | Updateæ“作的å‚数集åˆã€‚ | -| promise | Promise\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Updateæ“作的handle。 | +| token | Uint8Array | å¦ | Updateæ“作的token。 | +| options | [HuksOptions](#huksoptions) | 是 | Updateæ“作的å‚数集åˆã€‚ | +| promise | Promise\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | + +## huks.update<sup>9+</sup> + +update(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void + +updateæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Updateæ“作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Updateçš„å‚数集åˆã€‚ | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | + + +## huks.update<sup>9+</sup> + +update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\<HuksResult>) : void + +updateæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Updateæ“作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Updateæ“作的å‚数集åˆã€‚ | +| token | Uint8Array | 是 | Updateæ“作的token。 | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | + +## huks.update<sup>9+</sup> + +update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksResult> + +updateæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Updateæ“作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Updateæ“作的å‚数集åˆã€‚ | +| token | Uint8Array | å¦ | Updateæ“作的token。 | +| promise | Promise\<[HuksResult](#huksresult)> | 是 | å°†Updateæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | ## huks.finish @@ -1173,7 +1293,7 @@ finish(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksResult finishæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1190,7 +1310,7 @@ finish(handle: number, options: HuksOptions) : Promise\<HuksResult> finishæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1198,8 +1318,42 @@ finishæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 | -------- | ---------------------- | ---- | ------------------------------------- | | handle | number | 是 | Finishæ“作的handle。 | | options | [HuksOptions](#huksoptions) | 是 | Finishæ“作的å‚数集åˆã€‚ | -| promise | Promise\<[HuksResult](#HuksResult)> | 是 | promise实例,用于获å–异æ¥è¿”回结果。 | +| promise | Promise\<[HuksResult](#huksresult)> | 是 | promise实例,用于获å–异æ¥è¿”回结果。 | + +## huks.finish<sup>9+</sup> + +finish(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\<HuksResult>) : void + +finishæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 + +**系统能力**:SystemCapability.Security.Huks + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------- | ---- | -------------------------------------------- | +| handle | number | 是 | Finishæ“作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Finishçš„å‚数集åˆã€‚ | +| token | Uint8Array | 是 | Finishæ“作的token。 | +| callback | AsyncCallback\<[HuksResult](#huksresult)> | 是 | å°†Finishæ“ä½œçš„ç»“æžœæ·»åŠ åˆ°å¯†é’¥ç®¡ç†ç³»ç»Ÿçš„回调。 | + + +## huks.finish<sup>9+</sup> + +finish(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksResult> + +finishæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +**系统能力**:SystemCapability.Security.Huks + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | ----------------------------------- | +| handle | number | 是 | Finishæ“作的handle。 | +| options | [HuksOptions](#huksoptions) | 是 | Finishæ“作的å‚数集åˆã€‚ | +| token | Uint8Array | å¦ | Finishæ“作的token。 | +| promise | Promise\<[HuksResult](#Huksresult)> | 是 | promise实例,用于获å–异æ¥è¿”回结果。 | ## huks.abort @@ -1207,7 +1361,7 @@ abort(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksResult> abortæ“作密钥接å£ï¼Œä½¿ç”¨Callback回调异æ¥è¿”回结果 。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1427,7 +1581,7 @@ abort(handle: number, options: HuksOptions) : Promise\<HuksResult>; abortæ“作密钥接å£ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks **å‚数:** @@ -1651,49 +1805,49 @@ struct Index { 调用接å£ä½¿ç”¨çš„optionsä¸çš„properties数组ä¸çš„param。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------------------- | ---- | ---------- | -| tag | HuksTag | 是 | æ ‡ç¾ | -| value | boolean\|number\|bigint\|Uint8Array | 是 | æ ‡ç¾å¯¹åº”值 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------------- | ---- | ------------ | +| tag | [HuksTag](#hukstag) | 是 | æ ‡ç¾ã€‚ | +| value | boolean\|number\|bigint\|Uint8Array | 是 | æ ‡ç¾å¯¹åº”值。 | ## HuksOptions 调用接å£ä½¿ç”¨çš„options。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ---------- | ----------------- | ---- | ------------------------ | -| properties | Array\<HuksParam> | å¦ | 属性,å˜HuksParam的数组。 | +| properties | Array\<[HuksParam](#huksparam)> | å¦ | 属性,用于å˜HuksParam的数组。 | | inData | Uint8Array | å¦ | 输入数æ®ã€‚ | ## HuksHandle huks Handle结构体。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ---------- | ---------------- | ---- | -------- | -| errorCode | number | 是 | 错误ç | -| handle | number | 是 | handle值 | -| token | Uint8Array | å¦ | 预留å—段 | +| errorCode | number | 是 | 表示错误ç 。 | +| handle | number | 是 | 表示handle值。 | +| token | Uint8Array | å¦ | 表示[init](#huksinit)æ“作之åŽèŽ·å–到的challengeä¿¡æ¯ã€‚ | ## HuksResult 调用接å£è¿”回的result。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Security.Huks。 +**系统能力**:SystemCapability.Security.Huks -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------- | ---- | -------- | -| errorCode | number | 是 | 错误ç | -| outData | Uint8Array | å¦ | è¾“å‡ºæ•°æ® | -| properties | Array\<HuksParam> | å¦ | 属性 | -| certChains | Array\<string> | å¦ | è¯ä¹¦é“¾ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ------------------------------- | ---- | ---------------- | +| errorCode | number | 是 | 表示错误ç 。 | +| outData | Uint8Array | å¦ | 表示输出数æ®ã€‚ | +| properties | Array\<[HuksParam](#huksparam)> | å¦ | 表示属性信æ¯ã€‚ | +| certChains | Array\<string> | å¦ | 表示è¯ä¹¦é“¾æ•°æ®ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 8d824eed79e430d8704481ca37a8243011ba834c..ba30c0778a1c0a056e16da4c7ac08605853c5ab5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -3,15 +3,15 @@ 本模å—æ供系统相关的或者增强的国际化能力,包括区域管ç†ã€ç”µè¯å·ç 处ç†ã€æ—¥åŽ†ç‰ï¼Œç›¸å…³æŽ¥å£ä¸ºECMA 402æ ‡å‡†ä¸æœªå®šä¹‰çš„补充接å£ã€‚ [Intl模å—](js-apis-intl.md)æ供了ECMA 402æ ‡å‡†å®šä¹‰çš„åŸºç¡€å›½é™…åŒ–æŽ¥å£ï¼Œä¸Žæœ¬æ¨¡å—å…±åŒä½¿ç”¨å¯æ供完整地国际化支æŒèƒ½åŠ›ã€‚ ->  **说明:** -> - 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> **说明:** +> - 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > -> - I18N模å—包å«å›½é™…化能力增强接å£ï¼ˆæœªåœ¨ECMA 402ä¸å®šä¹‰ï¼‰ï¼ŒåŒ…括区域管ç†ã€ç”µè¯å·ç 处ç†ã€æ—¥åŽ†ç‰ï¼Œå›½é™…化基础能力请å‚考[Intl模å—](js-apis-intl.md)。 +> - I18N模å—包å«å›½é™…化能力增强接å£ï¼ˆæœªåœ¨ECMA 402ä¸å®šä¹‰ï¼‰ï¼ŒåŒ…括区域管ç†ã€ç”µè¯å·ç 处ç†ã€æ—¥åŽ†ç‰ï¼Œå›½é™…化基础能力请å‚考[Intl模å—](js-apis-intl.md)。 ## å¯¼å…¥æ¨¡å— -``` +```js import i18n from '@ohos.i18n'; ``` @@ -37,7 +37,7 @@ getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): st | string | 指定è¯è¨€çš„本地化显示文本。 | **示例:** - ``` + ```js i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB"); ``` @@ -64,7 +64,7 @@ getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): stri | string | 指定国家的本地化显示文本。 | **示例:** - ``` + ```js i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB"); ``` @@ -89,7 +89,7 @@ isRTL(locale: string): boolean | boolean | true表示该locale从å³è‡³å·¦æ˜¾ç¤ºè¯è¨€ï¼›false表示该locale从左至å³æ˜¾ç¤ºè¯è¨€ã€‚ | **示例:** - ``` + ```js i18n.isRTL("zh-CN");// ä¸æ–‡ä¸æ˜¯RTLè¯è¨€ï¼Œè¿”回false i18n.isRTL("ar-EG");// 阿è¯æ˜¯RTLè¯è¨€ï¼Œè¿”回true ``` @@ -109,7 +109,7 @@ getSystemLanguage(): string | string | 系统è¯è¨€ID。 | **示例:** - ``` + ```js i18n.getSystemLanguage(); ``` @@ -118,8 +118,9 @@ getSystemLanguage(): string setSystemLanguage(language: string): boolean -设置系统è¯è¨€ã€‚<br> -该接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +设置系统è¯è¨€ã€‚当å‰è°ƒç”¨è¯¥æŽ¥å£ä¸æ”¯æŒç³»ç»Ÿç•Œé¢è¯è¨€çš„实时刷新。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™**:ohos.permission.UPDATE_CONFIGURATION @@ -136,7 +137,7 @@ setSystemLanguage(language: string): boolean | boolean | 返回true,表示系统è¯è¨€è®¾ç½®æˆåŠŸï¼›è¿”回false,表示系统è¯è¨€è®¾ç½®å¤±è´¥ã€‚ | **示例:** - ``` + ```js i18n.setSystemLanguage('zh'); ``` @@ -147,9 +148,9 @@ getSystemLanguages(): Array<string> 获å–系统支æŒçš„è¯è¨€åˆ—表。 -**系统能力**:SystemCapability.Global.I18n +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统API**: 该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Global.I18n **返回值:** | 类型 | 说明 | @@ -157,7 +158,7 @@ getSystemLanguages(): Array<string> | Array<string> | 系统支æŒçš„è¯è¨€ID列表。 | **示例:** - ``` + ```js i18n.getSystemLanguages(); ``` @@ -168,9 +169,9 @@ getSystemCountries(language: string): Array<string> 获å–针对输入è¯è¨€ç³»ç»Ÿæ”¯æŒçš„区域列表。 -**系统能力**:SystemCapability.Global.I18n +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统API**: 该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Global.I18n **å‚数:** | å‚æ•°å | 类型 | 说明 | @@ -183,7 +184,7 @@ getSystemCountries(language: string): Array<string> | Array<string> | 系统支æŒçš„区域ID列表。 | **示例:** - ``` + ```js i18n.getSystemCountries('zh'); ``` @@ -202,7 +203,7 @@ getSystemRegion(): string | string | 系统地区ID。 | **示例:** - ``` + ```js i18n.getSystemRegion(); ``` @@ -211,8 +212,9 @@ getSystemRegion(): string setSystemRegion(region: string): boolean -设置系统区域。<br> -该接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +设置系统区域。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™**:ohos.permission.UPDATE_CONFIGURATION @@ -229,7 +231,7 @@ setSystemRegion(region: string): boolean | boolean | 返回true,表示系统区域设置æˆåŠŸï¼›è¿”回false,表示系统区域设置失败。 | **示例:** - ``` + ```js i18n.setSystemRegion('CN'); ``` @@ -248,7 +250,7 @@ getSystemLocale(): string | string | 系统区域ID。 | **示例:** - ``` + ```js i18n.getSystemLocale(); ``` @@ -257,8 +259,9 @@ getSystemLocale(): string setSystemLocale(locale: string): boolean -设置系统Locale。<br> -该接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +设置系统Locale。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™**:ohos.permission.UPDATE_CONFIGURATION @@ -275,7 +278,7 @@ setSystemLocale(locale: string): boolean | boolean | 返回true,表示系统Locale设置æˆåŠŸï¼›è¿”回false,表示系统Locale设置失败。 | **示例:** - ``` + ```js i18n.setSystemLocale('zh-CN'); ``` @@ -286,9 +289,9 @@ isSuggested(language: string, region?: string): boolean 判æ–当å‰è¯è¨€å’ŒåŒºåŸŸæ˜¯å¦åŒ¹é…。 -**系统能力**:SystemCapability.Global.I18n +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统API**: 该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**系统能力**:SystemCapability.Global.I18n **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -302,7 +305,7 @@ isSuggested(language: string, region?: string): boolean | boolean | 返回true,表示当å‰è¯è¨€å’Œåœ°åŒºåŒ¹é…;返回false,表示当å‰è¯è¨€å’Œåœ°åŒºä¸åŒ¹é…。 | **示例:** - ``` + ```js i18n.isSuggested('zh', 'CN'); ``` @@ -327,7 +330,7 @@ getCalendar(locale: string, type? : string): Calendar | [Calendar](#calendar8) | 日历对象。 | **示例:** - ``` + ```js i18n.getCalendar("zh-Hans", "gregory"); ``` @@ -349,7 +352,7 @@ setTime(date: Date): void | date | Date | 是 | å°†è¦è®¾ç½®çš„日历对象的内部时间日期。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); var date = new Date(2021, 10, 7, 8, 0, 0, 0); calendar.setTime(date); @@ -370,7 +373,7 @@ setTime(time: number): void | time | number | 是 | time为从1970.1.1 00:00:00 GMTé€åŽ»çš„毫秒数。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); calendar.setTime(10540800000); ``` @@ -395,7 +398,7 @@ set(year: number, month: number, date:number, hour?: number, minute?: number, se | second | number | å¦ | 设置的秒。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 ``` @@ -415,7 +418,7 @@ setTimeZone(timezone: string): void | timezone | string | 是 | 设置的时区id,如“Asia/Shanghaiâ€ã€‚ | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); ``` @@ -435,7 +438,7 @@ getTimeZone(): string | string | 日历对象的时区id。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setTimeZone("Asia/Shanghai"); calendar.getTimeZone(); // Asia/Shanghai" @@ -456,7 +459,7 @@ getFirstDayOfWeek(): number | number | 获å–一周的起始日,1代表周日,7代表周å…。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("en-US", "gregory"); calendar.getFirstDayOfWeek(); ``` @@ -476,7 +479,7 @@ setFirstDayOfWeek(value: number): void | value | number | å¦ | 设置一周的起始日,1代表周日,7代表周å…。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setFirstDayOfWeek(0); ``` @@ -496,7 +499,7 @@ getMinimalDaysInFirstWeek(): number | number | 一年ä¸ç¬¬ä¸€å‘¨çš„最å°å¤©æ•°ã€‚ | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.getMinimalDaysInFirstWeek(); ``` @@ -516,7 +519,7 @@ setMinimalDaysInFirstWeek(value: number): void | value | number | å¦ | 一年ä¸ç¬¬ä¸€å‘¨çš„最å°å¤©æ•°ã€‚ | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.setMinimalDaysInFirstWeek(3); ``` @@ -541,7 +544,7 @@ get(field: string): number | number | 与field相关è”的值,如当å‰Calendar对象的内部日期的年份为1990,get("year")返回1990。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.get("hour_of_day"); // 8 @@ -567,7 +570,7 @@ getDisplayName(locale: string): string | string | 日历在locale所指示的区域的åå—。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("en-US", "buddhist"); calendar.getDisplayName("zh"); // 佛历 ``` @@ -592,7 +595,7 @@ isWeekend(date?: Date): boolean | boolean | 当所判æ–的日期为周末时,返回 true,å¦åˆ™è¿”回false。 | **示例:** - ``` + ```js var calendar = i18n.getCalendar("zh-Hans"); calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 calendar.isWeekend(); // false @@ -619,7 +622,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions) | options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | å¦ | 电è¯å·ç æ ¼å¼åŒ–对象的相关选项。 | **示例:** - ``` + ```js var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); ``` @@ -643,7 +646,7 @@ isValidNumber(number: string): boolean | boolean | 返回true表示电è¯å·ç çš„æ ¼å¼æ£ç¡®ï¼Œè¿”回false表示电è¯å·ç çš„æ ¼å¼é”™è¯¯ã€‚ | **示例:** - ``` + ```js var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); phonenumberfmt.isValidNumber("15812312312"); ``` @@ -668,13 +671,13 @@ format(number: string): string | string | æ ¼å¼åŒ–åŽçš„电è¯å·ç 。 | **示例:** - ``` + ```js var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); phonenumberfmt.format("15812312312"); ``` -### getLocationName<sup>8+</sup> +### getLocationName<sup>9+</sup> static getLocationName(number: string, locale: string): string @@ -683,19 +686,20 @@ static getLocationName(number: string, locale: string): string **系统能力**:SystemCapability.Global.I18n **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ------ | ---- | ---------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---- | | number | string | 是 | 电è¯å·ç | | locale | string | 是 | 区域ID | **返回值:** -| 类型 | 说明 | -| ------ | ---------- | +| 类型 | 说明 | +| ------ | -------- | | string | 电è¯å·ç 归属地。 | **示例:** - ``` - var location = i18n.PhoneNumberFormat.getLocationName('15812312345', 'zh-CN'); + ```js + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.getLocationName("15812312345", "zh-CN"); ``` @@ -703,7 +707,7 @@ static getLocationName(number: string, locale: string): string 表示电è¯å·ç æ ¼å¼åŒ–对象å¯è®¾ç½®çš„属性。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ---- | ------ | ---- | ---- | ---------------------------------------- | @@ -714,7 +718,7 @@ static getLocationName(number: string, locale: string): string 度é‡è¡¡å•ä½ä¿¡æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ------------- | ------ | ---- | ---- | ---------------------------------------- | @@ -748,11 +752,35 @@ static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: | string | 按照toUnitçš„å•ä½æ ¼å¼åŒ–åŽï¼Œå¾—到的å—符串。 | **示例:** - ``` + ```js i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); ``` +### getDateOrder<sup>9+</sup> + +static getDateOrder(locale: string): string + +获å–æŸä¸€åŒºåŸŸçš„日期的年ã€æœˆã€æ—¥æŽ’列顺åºã€‚ + +**系统能力**:SystemCapability.Global.I18n + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------- | +| locale | string | 是 | æ ¼å¼åŒ–时使用的区域å‚数,如:zh-Hans-CN。 | + +**返回值:** +| 类型 | 说明 | +| ------ | ------------------- | +| string | 返回æŸä¸€åŒºåŸŸçš„日期的年ã€æœˆã€æ—¥æŽ’åˆ—é¡ºåº | + +**示例:** + ```js + i18n.Util.getDateOrder("zh-CN"); + ``` + + ## getInstance<sup>8+</sup> getInstance(locale?:string): IndexUtil @@ -772,7 +800,7 @@ getInstance(locale?:string): IndexUtil | [IndexUtil](#indexutil8) | locale对应的IndexUtil对象。 | **示例:** - ``` + ```js var indexUtil= i18n.getInstance("zh-CN"); ``` @@ -794,7 +822,7 @@ getIndexList(): Array<string> | Array<string> | 返回当å‰locale对应的索引列表。 | **示例:** - ``` + ```js var indexUtil = i18n.getInstance("zh-CN"); var indexList = indexUtil.getIndexList(); ``` @@ -814,7 +842,7 @@ addLocale(locale: string): void | locale | string | 是 | 包å«åŒºåŸŸè®¾ç½®ä¿¡æ¯çš„å—符串,包括è¯è¨€ä»¥åŠå¯é€‰çš„脚本和区域。 | **示例:** - ``` + ```js var indexUtil = i18n.getInstance("zh-CN"); indexUtil.addLocale("en-US"); ``` @@ -839,9 +867,9 @@ getIndex(text: string): string | string | 输入文本对应的索引值。 | **示例:** - ``` + ```js var indexUtil= i18n.getInstance("zh-CN"); - indexUtil.getIndex("hi"); // 返回h + indexUtil.getIndex("hi"); // 返回hi ``` @@ -867,7 +895,7 @@ static isDigit(char: string): boolean | boolean | 返回true表示输入的å—符是数å—,返回false表示输入的å—符ä¸æ˜¯æ•°å—。 | **示例:** - ``` + ```js var isdigit = i18n.Character.isDigit("1"); // 返回true ``` @@ -891,7 +919,7 @@ static isSpaceChar(char: string): boolean | boolean | 返回true表示输入的å—ç¬¦æ˜¯ç©ºæ ¼ç¬¦ï¼Œè¿”å›žfalse表示输入的å—符ä¸æ˜¯ç©ºæ ¼ç¬¦ã€‚ | **示例:** - ``` + ```js var isspacechar = i18n.Character.isSpaceChar("a"); // 返回false ``` @@ -915,7 +943,7 @@ static isWhitespace(char: string): boolean | boolean | 返回true表示输入的å—符是空白符,返回false表示输入的å—符ä¸æ˜¯ç©ºç™½ç¬¦ã€‚ | **示例:** - ``` + ```js var iswhitespace = i18n.Character.isWhitespace("a"); // 返回false ``` @@ -939,7 +967,7 @@ static isRTL(char: string): boolean | boolean | 返回true表示输入的å—符是从å³åˆ°å·¦è¯è¨€çš„å—符,返回false表示输入的å—符ä¸æ˜¯ä»Žå³åˆ°å·¦è¯è¨€çš„å—符。 | **示例:** - ``` + ```js var isrtl = i18n.Character.isRTL("a"); // 返回false ``` @@ -963,7 +991,7 @@ static isIdeograph(char: string): boolean | boolean | 返回true表示输入的å—符是表æ„æ–‡å—,返回false表示输入的å—符ä¸æ˜¯è¡¨æ„æ–‡å—。 | **示例:** - ``` + ```js var isideograph = i18n.Character.isIdeograph("a"); // 返回false ``` @@ -987,7 +1015,7 @@ static isLetter(char: string): boolean | boolean | 返回true表示输入的å—符是å—æ¯ï¼Œè¿”回false表示输入的å—符ä¸æ˜¯å—æ¯ã€‚ | **示例:** - ``` + ```js var isletter = i18n.Character.isLetter("a"); // 返回true ``` @@ -1011,7 +1039,7 @@ static isLowerCase(char: string): boolean | boolean | 返回true表示输入的å—符是å°å†™å—æ¯ï¼Œè¿”回false表示输入的å—符ä¸æ˜¯å°å†™å—æ¯ã€‚ | **示例:** - ``` + ```js var islowercase = i18n.Character.isLowerCase("a"); // 返回true ``` @@ -1035,7 +1063,7 @@ static isUpperCase(char: string): boolean | boolean | 返回true表示输入的å—符是大写å—æ¯ï¼Œè¿”回false表示输入的å—符ä¸æ˜¯å¤§å†™å—æ¯ã€‚ | **示例:** - ``` + ```js var isuppercase = i18n.Character.isUpperCase("a"); // 返回false ``` @@ -1059,7 +1087,7 @@ static getType(char: string): string | string | 输入å—符的一般类别值。 | **示例:** - ``` + ```js var type = i18n.Character.getType("a"); ``` @@ -1083,7 +1111,7 @@ getLineInstance(locale: string): BreakIterator | [BreakIterator](#breakiterator8) | 用于进行æ–å¥çš„处ç†å™¨ã€‚ | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); ``` @@ -1105,7 +1133,7 @@ setLineBreakText(text: string): void | text | string | 是 | 指定BreakIterator进行æ–å¥çš„文本。 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); ``` @@ -1125,7 +1153,7 @@ getLineBreakText(): string | string | BreakIterator对象æ£åœ¨å¤„ç†çš„文本 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.getLineBreakText(); // Apple is my favorite fruit. @@ -1146,7 +1174,7 @@ current(): number | number | BreakIterator在当å‰æ‰€å¤„ç†çš„文本ä¸çš„ä½ç½®ã€‚ | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.current(); // 0 @@ -1167,7 +1195,7 @@ first(): number | number | 被处ç†æ–‡æœ¬çš„第一个分割点的å移é‡ã€‚ | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1188,7 +1216,7 @@ last(): number | number | 被处ç†çš„文本的最åŽä¸€ä¸ªåˆ†å‰²ç‚¹çš„åç§»é‡ | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.last(); // 27 @@ -1214,7 +1242,7 @@ next(index?: number): number | number | 返回移动了index个分割点åŽï¼Œå½“å‰[BreakIterator](#breakiterator8)在文本ä¸çš„ä½ç½®ã€‚若移动index个分割点åŽè¶…出了所处ç†çš„文本的长度范围,返回-1。 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1237,7 +1265,7 @@ previous(): number | number | 返回移动到å‰ä¸€ä¸ªåˆ†å‰²ç‚¹åŽï¼Œå½“å‰[BreakIterator](#breakiterator8)在文本ä¸çš„ä½ç½®ã€‚若移动index个分割点åŽè¶…出了所处ç†çš„文本的长度范围,返回-1。 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.first(); // 0 @@ -1265,7 +1293,7 @@ following(offset: number): number | number | 返回[BreakIterator](#breakiterator8)移动åŽçš„ä½ç½®ï¼Œå¦‚果由offset所指定的ä½ç½®çš„下一个分割点超出了文本的范围则返回-1。 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.following(0); // 6 @@ -1293,7 +1321,7 @@ isBoundary(offset: number): boolean | boolean | 如果是一个分割点返回true, å¦åˆ™è¿”回false。 | **示例:** - ``` + ```js var iterator = i18n.getLineInstance("en"); iterator.setLineBreakText("Apple is my favorite fruit."); iterator.isBoundary(0); // true; @@ -1315,7 +1343,7 @@ is24HourClock(): boolean | boolean | 返回true,表示系统24å°æ—¶å¼€å…³å¼€å¯ï¼›è¿”回false,表示系统24å°æ—¶å¼€å…³å…³é—。 | **示例:** - ``` + ```js var is24HourClock = i18n.is24HourClock(); ``` @@ -1341,7 +1369,7 @@ set24HourClock(option: boolean): boolean | boolean | 返回true,表示修改æˆåŠŸï¼›è¿”回false,表示修改失败。 | **示例:** - ``` + ```js // 将系统时间设置为24å°æ—¶åˆ¶ var success = i18n.set24HourClock(true); ``` @@ -1369,7 +1397,7 @@ addPreferredLanguage(language: string, index?: number): boolean | boolean | 返回trueï¼Œè¡¨ç¤ºæ·»åŠ æˆåŠŸï¼›è¿”回falseï¼Œè¡¨ç¤ºæ·»åŠ å¤±è´¥ã€‚ | **示例:** - ``` + ```js // å°†è¯è¨€zh-CNæ·»åŠ åˆ°ç³»ç»Ÿå好è¯è¨€åˆ—è¡¨ä¸ var language = 'zh-CN'; var index = 0; @@ -1398,7 +1426,7 @@ removePreferredLanguage(index: number): boolean | boolean | 返回trueï¼Œè¡¨ç¤ºåˆ é™¤æˆåŠŸï¼›è¿”回falseï¼Œè¡¨ç¤ºåˆ é™¤å¤±è´¥ã€‚ | **示例:** - ``` + ```js // åˆ é™¤ç³»ç»Ÿå好è¯è¨€åˆ—表ä¸çš„第一个å好è¯è¨€ var index = 0; var success = i18n.removePreferredLanguage(index); @@ -1419,7 +1447,7 @@ getPreferredLanguageList(): Array<string> | Array<string> | 系统å好è¯è¨€åˆ—表。 | **示例:** - ``` + ```js var preferredLanguageList = i18n.getPreferredLanguageList(); ``` @@ -1438,7 +1466,7 @@ getFirstPreferredLanguage(): string | string | å好è¯è¨€åˆ—表ä¸çš„第一个è¯è¨€ã€‚ | **示例:** - ``` + ```js var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); ``` @@ -1452,12 +1480,12 @@ getAppPreferredLanguage(): string **系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| ------ | -------------- | +| 类型 | 说明 | +| ------ | -------- | | string | 应用的å好è¯è¨€ã€‚ | **示例:** - ``` + ```js var appPreferredLanguage = i18n.getAppPreferredLanguage(); ``` @@ -1481,15 +1509,15 @@ getTimeZone(zoneID?: string): TimeZone | TimeZone | 时区ID对应的时区对象。 | **示例:** - ``` + ```js var timezone = i18n.getTimeZone(); ``` -## TimeZone<sup>8+</sup> +## TimeZone -### getID<sup>8+</sup> +### getID getID(): string @@ -1503,13 +1531,13 @@ getID(): string | string | 时区对象对应的时区ID。 | **示例:** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getID(); ``` -### getDisplayName<sup>8+</sup> +### getDisplayName getDisplayName(locale?: string, isDST?: boolean): string @@ -1529,13 +1557,13 @@ getDisplayName(locale?: string, isDST?: boolean): string | string | 时区对象在指定区域的表示。 | **示例:** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getDisplayName("zh-CN", false); ``` -### getRawOffset<sup>8+</sup> +### getRawOffset getRawOffset(): number @@ -1549,13 +1577,13 @@ getRawOffset(): number | number | 时区对象表示的时区与UTC时区的å差。 | **示例:** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getRawOffset(); ``` -### getOffset<sup>8+</sup> +### getOffset getOffset(date?: number): number @@ -1569,7 +1597,7 @@ getOffset(date?: number): number | number | æŸä¸€æ—¶åˆ»æ—¶åŒºå¯¹è±¡è¡¨ç¤ºçš„时区与UTC时区的å差。 | **示例:** - ``` + ```js var timezone = i18n.getTimeZone(); timezone.getOffset(1234567890); ``` @@ -1584,12 +1612,12 @@ static getAvailableIDs(): Array<string> **系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| ------ | ----------------------- | +| 类型 | 说明 | +| ------------------- | ----------- | | Array<string> | 系统支æŒçš„时区ID列表 | **示例:** - ``` + ```ts var ids = i18n.TimeZone.getAvailableIDs(); ``` @@ -1603,12 +1631,12 @@ static getAvailableZoneCityIDs(): Array<string> **系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| ------ | ----------------------- | +| 类型 | 说明 | +| ------------------- | ------------- | | Array<string> | 系统支æŒçš„时区城市ID列表 | **示例:** - ``` + ```ts var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs(); ``` @@ -1622,18 +1650,18 @@ static getCityDisplayName(cityID: string, locale: string): string **系统能力**:SystemCapability.Global.I18n **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------ | | cityID | string | 是 | 时区城市ID | -| locale | string | 是 | 区域ID | +| locale | string | 是 | 区域ID | **返回值:** -| 类型 | 说明 | -| ------ | ----------------------- | +| 类型 | 说明 | +| ------ | ------------------ | | string | 时区城市在locale下的本地化显示 | **示例:** - ``` + ```ts var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); ``` @@ -1647,17 +1675,17 @@ static getTimezoneFromCity(cityID: string): TimeZone **系统能力**:SystemCapability.Global.I18n **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------ | | cityID | string | 是 | 时区城市ID | **返回值:** -| 类型 | 说明 | -| ------ | ----------------------- | +| 类型 | 说明 | +| -------- | ----------- | | TimeZone | 时区城市对应的时区对象 | **示例:** - ``` + ```ts var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai"); ``` @@ -1666,25 +1694,26 @@ static getTimezoneFromCity(cityID: string): TimeZone setUsingLocalDigit(flag: boolean): boolean -设置是å¦æ‰“开本地数å—开关。<br> -该接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +设置是å¦æ‰“开本地数å—开关。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™**:ohos.permission.UPDATE_CONFIGURATION **系统能力**:SystemCapability.Global.I18n **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---- | ------- | ---- | ------------------------------- | | flag | boolean | 是 | true表示打开本地数å—开关,false表示关é—本地数å—开关。 | **返回值:** -| 类型 | 说明 | -| -------- | ------------ | +| 类型 | 说明 | +| ------- | ----------------------------------- | | boolean | true表示本地数å—开关设置æˆåŠŸï¼Œfalse表示本地数å—开关设置失败。 | **示例:** - ``` + ```ts var status = i18n.setUsingLocalDigit(true); ``` @@ -1698,11 +1727,82 @@ getUsingLocalDigit(): boolean **系统能力**:SystemCapability.Global.I18n **返回值:** -| 类型 | 说明 | -| -------- | ------------ | +| 类型 | 说明 | +| ------- | ---------------------------------------- | | boolean | true表示系统当å‰å·²æ‰“开本地数å—开关,false表示系统当å‰æœªæ‰“开本地数å—开关。 | **示例:** - ``` + ```ts var status = i18n.getUsingLocalDigit(); + ``` + + +## Transliterator<sup>9+</sup> + + +### getAvailableIDs<sup>9+</sup> + +static getAvailableIDs(): string[] + +获å–音译支æŒçš„ID列表。 + +**系统能力**:SystemCapability.Global.I18n + +**返回值:** +| 类型 | 说明 | +| -------- | ---------- | +| string[] | 音译支æŒçš„ID列表。 | + +**示例:** + ```ts + i18n.Transliterator.getAvailableIDs(); + ``` + + +### getInstance<sup>9+</sup> + +static getInstance(id: string): Transliterator + +创建音译对象。 + +**系统能力**:SystemCapability.Global.I18n + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---- | ------ | ---- | -------- | +| id | string | 是 | 音译支æŒçš„ID。 | + +**返回值:** +| 类型 | 说明 | +| ---------------------------------- | ----- | +| [Transliterator](#transliterator9) | 音译对象。 | + +**示例:** + ```ts + var transliterator = i18n.Transliterator.getInstance("Any-Latn"); + ``` + + +### transform<sup>9+</sup> + +transform(text: string): string + +将输入å—符串从æºæ ¼å¼è½¬æ¢ä¸ºç›®æ ‡æ ¼å¼ã€‚ + +**系统能力**:SystemCapability.Global.I18n + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---- | ------ | ---- | ------ | +| text | string | 是 | 输入å—符串。 | + +**返回值:** +| 类型 | 说明 | +| ------ | -------- | +| string | 转æ¢åŽçš„å—符串。 | + +**示例:** + ```ts + var transliterator = i18n.Transliterator.getInstance("Any-Latn"); + transliterator.transform("ä¸å›½"); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 6720c5cbcdd506327ca1bd9fd5e5b9af698563fe..f4aeef3b877acfc2634927e33743d707f60a7c07 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -82,9 +82,9 @@ image.createPixelMap(color, opts, (error, pixelmap) => { **系统能力:** SystemCapability.Multimedia.Image.Core -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ----------------------- | ------- | ---- | ---- | -------------------------- | -| isEditable<sup>7+</sup> | boolean | 是 | å¦ | 设定是å¦å›¾åƒåƒç´ å¯è¢«ç¼–辑。 | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ---------- | ------- | ---- | ---- | -------------------------- | +| isEditable | boolean | 是 | å¦ | 设定是å¦å›¾åƒåƒç´ å¯è¢«ç¼–辑。 | ### readPixelsToBuffer<sup>7+</sup> @@ -96,20 +96,20 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void> **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ----------- | ---- | ------------------------------------------------------------ | -| dst | ArrayBuffer | 是 | 缓冲区,函数执行结æŸåŽèŽ·å–的图åƒåƒç´ æ•°æ®å†™å…¥åˆ°è¯¥å†…å˜åŒºåŸŸå†…。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- | +| dst | ArrayBuffer | 是 | 缓冲区,函数执行结æŸåŽèŽ·å–的图åƒåƒç´ æ•°æ®å†™å…¥åˆ°è¯¥å†…å˜åŒºåŸŸå†…。缓冲区大å°ç”±getPixelBytesNumber接å£èŽ·å–。 | **返回值:** | 类型 | 说明 | -| :------------- | :---------------------------------------------- | +| -------------- | ----------------------------------------------- | | Promise\<void> | Promise实例,用于获å–结果,失败时返回错误信æ¯ã€‚ | **示例:** ```js -const readBuffer = new ArrayBuffer(400); +const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer).then(() => { console.log('Succeeded in reading image pixel data.'); //符åˆæ¡ä»¶åˆ™è¿›å…¥ }).catch(error => { @@ -127,15 +127,15 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------- | ---- | ------------------------------------------------------------ | -| dst | ArrayBuffer | 是 | 缓冲区,函数执行结æŸåŽèŽ·å–的图åƒåƒç´ æ•°æ®å†™å…¥åˆ°è¯¥å†…å˜åŒºåŸŸå†…。 | -| callback | AsyncCallback\<void> | 是 | 获å–回调,失败时返回错误信æ¯ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- | +| dst | ArrayBuffer | 是 | 缓冲区,函数执行结æŸåŽèŽ·å–的图åƒåƒç´ æ•°æ®å†™å…¥åˆ°è¯¥å†…å˜åŒºåŸŸå†…。缓冲区大å°ç”±getPixelBytesNumber接å£èŽ·å–。 | +| callback | AsyncCallback\<void> | 是 | 获å–回调,失败时返回错误信æ¯ã€‚ | **示例:** ```js -const readBuffer = new ArrayBuffer(400); +const readBuffer = new ArrayBuffer(96); pixelmap.readPixelsToBuffer(readBuffer, (err, res) => { if(err) { console.log('Failed to read image pixel data.'); //ä¸ç¬¦åˆæ¡ä»¶åˆ™è¿›å…¥ @@ -279,7 +279,7 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | --------- | ------------------------------ | ---- | ------------------------------ | | area | [PositionArea](#positionarea7) | 是 | åŒºåŸŸï¼Œæ ¹æ®åŒºåŸŸå†™å…¥ã€‚ | -| callback: | AsyncCallback\<void> | 是 | 获å–回调,失败时返回错误信æ¯ã€‚ | +| callback | AsyncCallback\<void> | 是 | 获å–回调,失败时返回错误信æ¯ã€‚ | **示例:** @@ -892,8 +892,6 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (pixelmap) => { pixelmap.release().then(() => { console.log('Succeeded in releasing pixelmap object.'); - }).catch(error => { - console.log('Failed to release pixelmap object.'); }) }) ``` @@ -925,6 +923,33 @@ let path = this.context.getApplicationContext().fileDirs + "test.jpg"; const imageSourceApi = image.createImageSource(path); ``` +## image.createImageSource<sup>9+</sup> + +createImageSource(uri: string, options: SourceOptions): ImageSource + +é€šè¿‡ä¼ å…¥çš„uri创建图片æºå®žä¾‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------- | ---- | ----------------------------------- | +| uri | string | 是 | 图片路径,当å‰ä»…支æŒåº”用沙箱路径。 | +| options | [SourceOptions](#sourceoptions9) | 是 | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚| + +**返回值:** + +| 类型 | 说明 | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | 返回ImageSource类实例,失败时返回undefined。 | + +**示例:** + +```js +const imageSourceApi = image.createImageSource('/sdcard/test.jpg'); +``` + ## image.createImageSource<sup>7+</sup> createImageSource(fd: number): ImageSource @@ -948,7 +973,34 @@ createImageSource(fd: number): ImageSource **示例:** ```js -const imageSourceApi = image.createImageSource(0) +const imageSourceApi = image.createImageSource(0); +``` + +## image.createImageSource<sup>9+</sup> + +createImageSource(fd: number, options: SourceOptions): ImageSource + +é€šè¿‡ä¼ å…¥æ–‡ä»¶æ述符æ¥åˆ›å»ºå›¾ç‰‡æºå®žä¾‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------- | ---- | ----------------------------------- | +| fd | number | 是 | 文件æ述符fd。 | +| options | [SourceOptions](#sourceoptions9) | 是 | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚| + +**返回值:** + +| 类型 | 说明 | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | 返回ImageSource类实例,失败时返回undefined。 | + +**示例:** + +```js +const imageSourceApi = image.createImageSource(fd); ``` ## image.createImageSource<sup>9+</sup> @@ -972,9 +1024,64 @@ const buf = new ArrayBuffer(96); const imageSourceApi = image.createImageSource(buf); ``` +## image.createImageSource<sup>9+</sup> + +createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource + +通过缓冲区创建图片æºå®žä¾‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | -------------------------------- | ---- | ------------------------------------ | +| buf | ArrayBuffer | 是 | 图åƒç¼“冲区数组。 | +| options | [SourceOptions](#sourceoptions9) | 是 | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| --------------------------- | -------------------------------------------- | +| [ImageSource](#imagesource) | 返回ImageSource类实例,失败时返回undefined。 | + +**示例:** + +```js +const data = new ArrayBuffer(112); +const imageSourceApi = image.createImageSource(data); +``` + +## image.CreateIncrementalSource<sup>9+</sup> + +CreateIncrementalSource(buf: ArrayBuffer): ImageSource + +通过缓冲区以增é‡çš„æ–¹å¼åˆ›å»ºå›¾ç‰‡æºå®žä¾‹ã€‚ + +**系统能力:** SystemCapability.Multimedia.Image.ImageSource + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------| ---- | ----------| +| buf | ArrayBuffer | 是 | 增é‡æ•°æ®ã€‚| + +**返回值:** + +| 类型 | 说明 | +| --------------------------- | --------------------------------- | +| [ImageSource](#imagesource) | 返回图片æºï¼Œå¤±è´¥æ—¶è¿”回undefined。 | + +**示例:** + +```js +const buf = new ArrayBuffer(96); +const imageSourceApi = image.CreateIncrementalSource(buf); +``` + ## image.CreateIncrementalSource<sup>9+</sup> -function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource +CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource 通过缓冲区以增é‡çš„æ–¹å¼åˆ›å»ºå›¾ç‰‡æºå®žä¾‹ã€‚ @@ -985,7 +1092,7 @@ function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): Ima | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------- | ------------------------------- | ---- | ------------------------------------ | | buf | ArrayBuffer | 是 | 增é‡æ•°æ®ã€‚ | -| options | [SourceOptions](#SourceOptions) | å¦ | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚ | +| options | [SourceOptions](#sourceoptions9) | å¦ | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚ | **返回值:** @@ -1109,8 +1216,8 @@ getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string **返回值:** -| 类型 | 说明 | -| ---------------- | ------------------------------------------------------------ | +| 类型 | 说明 | +| ---------------- | ----------------------------------------------------------------- | | Promise\<string> | Promise实例,用于异æ¥èŽ·å–图片属性值,如获å–失败则返回属性默认值。 | **示例:** @@ -1159,11 +1266,11 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | -| key | string | 是 | 图片属性å。 | -| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | 是 | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚ | -| callback | AsyncCallback\<string> | 是 | 获å–图片属性回调,返回图片属性值,如获å–失败则返回属性默认值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------- | +| key | string | 是 | 图片属性å。 | +| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | 是 | 图片属性,包括图片åºå·ä¸Žé»˜è®¤å±žæ€§å€¼ã€‚ | +| callback | AsyncCallback\<string> | 是 | 获å–图片属性回调,返回图片属性值,如获å–失败则返回属性默认值。| **示例:** @@ -1202,7 +1309,7 @@ modifyImageProperty(key: string, value: string): Promise\<void> **示例:** ```js -imageSourceApi.modifyImageProperty("ImageWidth", "abc") +imageSourceApi.modifyImageProperty("ImageWidth", "120") .then(() => { const w = imageSourceApi.getImageProperty("ImageWidth") console.info('w', w); @@ -1211,7 +1318,7 @@ imageSourceApi.modifyImageProperty("ImageWidth", "abc") ### modifyImageProperty<sup>9+</sup> -modifyImageProperty(key: string, value: string, callback: AsyncCallback<void>): void +modifyImageProperty(key: string, value: string, callback: AsyncCallback\<void>): void 通过指定的键修改图片属性的值,callbackå½¢å¼è¿”回结果。 @@ -1223,12 +1330,12 @@ modifyImageProperty(key: string, value: string, callback: AsyncCallback<void>): | -------- | ------------------- | ---- | ------------------------------ | | key | string | 是 | 图片属性å。 | | value | string | 是 | 属性值。 | -| callback | AsyncCallback<void> | 是 | 修改属性值,callback返回结果。 | +| callback | AsyncCallback\<void> | 是 | 修改属性值,callback返回结果。 | **示例:** ```js -imageSourceApi.modifyImageProperty("ImageWidth", "abc",() => {}) +imageSourceApi.modifyImageProperty("ImageWidth", "120",() => {}) ``` ### updateData<sup>9+</sup> @@ -1266,7 +1373,7 @@ imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => { ### updateData<sup>9+</sup> -updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback<void>): void +updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback\<void>): void 更新增é‡æ•°æ®ï¼Œcallbackå½¢å¼è¿”回结果。 @@ -1280,7 +1387,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, | isFinished | boolean | 是 | 是å¦æ›´æ–°å®Œã€‚ | | value | number | å¦ | å移é‡ã€‚ | | length | number | å¦ | 数组长。 | -| callback | AsyncCallback<void> | 是 | 回调表示æˆåŠŸæˆ–失败。 | +| callback | AsyncCallback\<void> | 是 | 回调表示æˆåŠŸæˆ–失败。 | **示例:** @@ -1340,11 +1447,9 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void **示例:** ```js -imageSourceApi.createPixelMap(pixelmap => { - console.log('Succeeded in creating pixelmap object.'); -}).catch(error => { - console.log('Failed to create pixelmap object.'); -}) +imageSourceApi.createPixelMap((err, pixelmap) => { + console.info('Succeeded in creating pixelmap object.')ï¼› + }) ``` ### createPixelMap<sup>7+</sup> @@ -1423,7 +1528,7 @@ createImagePacker(): ImagePacker 创建ImagePacker实例。 -**系统能力:** SystemCapability.Multimedia.Image.ImageReceiver +**系统能力:** SystemCapability.Multimedia.Image.ImagePacker **返回值:** @@ -1491,8 +1596,8 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer> **返回值:** | 类型 | 说明 | -| :--------------------------- | :-------------------------------------------- | -| Promise\<ArrayBuffer> | Promise实例,用于异æ¥èŽ·å–压缩或打包åŽçš„æ•°æ®ã€‚ | +| ---------------------------- | --------------------------------------------- | +| Promise\<ArrayBuffer> | Promise实例,用于异æ¥èŽ·å–压缩或打包åŽçš„æ•°æ®ã€‚ | **示例:** @@ -1530,8 +1635,6 @@ let packOpts = { format:"image/jpeg", quality:98 } const pixelMapApi = new ArrayBuffer(400); imagePackerApi.packing(pixelMapApi, packOpts, data => { console.log('Succeeded in packing the image.'); -}).catch(error => { - console.log('Failed to pack the image.'); }) ``` @@ -1552,9 +1655,9 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer> **返回值:** -| 类型 | 说明 | -| :--------------------------- | :-------------------------------------------- | -| Promise\<ArrayBuffer> | Promise实例,用于异æ¥èŽ·å–压缩或打包åŽçš„æ•°æ®ã€‚ | +| 类型 | 说明 | +| --------------------- | -------------------------------------------- | +| Promise\<ArrayBuffer> | Promise实例,用于异æ¥èŽ·å–压缩或打包åŽçš„æ•°æ®ã€‚| **示例:** @@ -1601,9 +1704,9 @@ release(): Promise\<void> **返回值:** -| 类型 | 说明 | -| :------------- | :------------------------------------------------------ | -| Promise\<void> | Promise实例,用于异æ¥èŽ·å–释放结果,失败时返回错误信æ¯ã€‚ | +| 类型 | 说明 | +| -------------- | ------------------------------------------------------ | +| Promise\<void> | Promise实例,用于异æ¥èŽ·å–释放结果,失败时返回错误信æ¯ã€‚| **示例:** @@ -1654,11 +1757,11 @@ var receiver = image.createImageReceiver(8192, 8, 4, 8); **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.ImageReceiver -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| --------------------- | ---------------------------- | ---- | ---- | ------------------ | -| size<sup>9+</sup> | [Size](#size) | 是 | å¦ | 图片大å°ã€‚ | -| capacity<sup>9+</sup> | number | 是 | å¦ | åŒæ—¶è®¿é—®çš„图åƒæ•°ã€‚ | -| format<sup>9+</sup> | [ImageFormat](#imageformat9) | 是 | å¦ | 图åƒæ ¼å¼ã€‚ | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------- | ---------------------------- | ---- | ---- | ------------------ | +| size | [Size](#size) | 是 | å¦ | 图片大å°ã€‚ | +| capacity | number | 是 | å¦ | åŒæ—¶è®¿é—®çš„图åƒæ•°ã€‚ | +| format | [ImageFormat](#imageformat9) | 是 | å¦ | 图åƒæ ¼å¼ã€‚ | ### getReceivingSurfaceId<sup>9+</sup> @@ -1748,7 +1851,7 @@ readLatestImage(): Promise\<Image> | 类型 | 说明 | | ------------------------- | ------------------ | -| Promise<[Image](#image8)> | 异æ¥è¿”回最新图片。 | +| Promise<[Image](#image9)> | 异æ¥è¿”回最新图片。 | **示例:** @@ -1883,11 +1986,11 @@ receiver.release().then(() => { **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.Core -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| --------------------- | ------------------ | ---- | ---- | -------------------------------------------------- | -| clipRect<sup>9+</sup> | [Region](#region7) | 是 | 是 | è¦è£å‰ªçš„图åƒåŒºåŸŸã€‚ | -| size<sup>9+</sup> | [Size](#size) | 是 | å¦ | 图åƒå¤§å°ã€‚ | -| format<sup>9+</sup> | number | 是 | å¦ | 图åƒæ ¼å¼ï¼Œå‚考[PixelMapFormat](#pixelmapformat7)。 | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| -------- | ------------------ | ---- | ---- | -------------------------------------------------- | +| clipRect | [Region](#region7) | 是 | 是 | è¦è£å‰ªçš„图åƒåŒºåŸŸã€‚ | +| size | [Size](#size) | 是 | å¦ | 图åƒå¤§å°ã€‚ | +| format | number | 是 | å¦ | 图åƒæ ¼å¼ï¼Œå‚考[PixelMapFormat](#pixelmapformat7)。 | ### getComponent<sup>9+</sup> @@ -1963,8 +2066,6 @@ release(callback: AsyncCallback\<void>): void ```js img.release(() =>{ console.log('release succeeded.'); -}).catch(error => { - console.log('release failed.'); }) ``` @@ -2034,11 +2135,12 @@ img.release().then(() =>{ **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.Core -| å称 | 默认值 | æè¿° | -| --------- | ------ | ---------------- | -| UNKNOWN | 0 | æœªçŸ¥æ ¼å¼ã€‚ | -| RGB_565 | 2 | æ ¼å¼ä¸ºRGB_565。 | -| RGBA_8888 | 3 | æ ¼å¼ä¸ºRGBA_8888。 | +| å称 | 默认值 | æè¿° | +| ---------------------- | ------ | ----------------- | +| UNKNOWN | 0 | æœªçŸ¥æ ¼å¼ã€‚ | +| RGB_565 | 2 | æ ¼å¼ä¸ºRGB_565 | +| RGBA_8888 | 3 | æ ¼å¼ä¸ºRGBA_8888。 | +| BGRA_8888<sup>9+</sup> | 4 | æ ¼å¼ä¸ºBGRA_8888。 | ## AlphaType<sup>9+</sup> @@ -2064,19 +2166,32 @@ img.release().then(() =>{ | CENTER_CROP | 1 | 缩放图åƒä»¥å¡«å……ç›®æ ‡å›¾åƒåŒºåŸŸå¹¶å±…ä¸è£å‰ªåŒºåŸŸå¤–的效果。 | | FIT_TARGET_SIZE | 2 | 图åƒé€‚åˆç›®æ ‡å°ºå¯¸çš„效果。 | +## SourceOptions<sup>9+</sup> + +ImageSourceçš„åˆå§‹åŒ–选项。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.Core + +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ----------------- | ---------------------------------- | ---- | ---- | ------------------ | +| sourceDensity | number | 是 | 是 | ImageSource的密度。| +| sourcePixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | 图片åƒç´ æ ¼å¼ã€‚ | +| sourceSize | [Size](#size) | 是 | 是 | 图åƒåƒç´ 大å°ã€‚ | + + ## InitializationOptions<sup>8+</sup> PixelMapçš„åˆå§‹åŒ–选项。 -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.Code +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.Core -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ---------------------- | ---------------------------------- | ---- | ---- | -------------- | -| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | 是 | 是 | é€æ˜Žåº¦ã€‚ | -| editable | boolean | 是 | 是 | 是å¦å¯ç¼–辑。 | -| pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | åƒç´ æ ¼å¼ã€‚ | -| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | 是 | 是 | 缩略值。 | -| size | [Size](#size) | 是 | 是 | 创建图片大å°ã€‚ | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------------------------ | ---------------------------------- | ---- | ---- | -------------- | +| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | 是 | 是 | é€æ˜Žåº¦ã€‚ | +| editable | boolean | 是 | 是 | 是å¦å¯ç¼–辑。 | +| pixelFormat | [PixelMapFormat](#pixelmapformat7) | 是 | 是 | åƒç´ æ ¼å¼ã€‚ | +| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | 是 | 是 | 缩略值。 | +| size | [Size](#size) | 是 | 是 | 创建图片大å°ã€‚ | ## DecodingOptions<sup>7+</sup> @@ -2112,9 +2227,9 @@ PixelMapçš„åˆå§‹åŒ–选项。 **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.Image.ImagePacker -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ------- | ------ | ---- | ---- | -------------- | -| format | string | 是 | 是 | ç›®æ ‡æ ¼å¼ã€‚ | +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------- | ------ | ---- | ---- | --------------------------------------------------- | +| format | string | 是 | 是 | ç›®æ ‡æ ¼å¼ã€‚ | | quality | number | 是 | 是 | JPEGç¼–ç ä¸è®¾å®šè¾“出图片质é‡çš„å‚数,å–值范围为1-100。 | ## GetImagePropertyOptions<sup>7+</sup> diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index 0a34cefa86bb57dfcac8a65484982ca413899405..d47a7f5604c3609161e6da3faeee04697685b811 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -2,17 +2,17 @@ InputConsumer模å—æ供对按键事件的监å¬ã€‚ ->  **说明:** +> **说明:** > > - 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > -> - 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +> - 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— -``` +```js import inputConsumer from '@ohos.multimodalInput.inputConsumer'; ``` @@ -23,19 +23,19 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v 开始监å¬ç»„åˆæŒ‰é”®äº‹ä»¶, 当满足æ¡ä»¶çš„组åˆæŒ‰é”®è¾“入事件å‘生时,将keyOptions回调到入å‚callback表示的回调函数上。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监å¬è¾“入事件类型,åªæ”¯æŒâ€œkeyâ€ã€‚ | -| keyOptions | [keyOptions](#keyOptions) | 是 | 组åˆé”®é€‰é¡¹ï¼Œç”¨æ¥æŒ‡å®šç»„åˆé”®è¾“入时应该符åˆçš„æ¡ä»¶ã€‚ | -| callback | Callback<KeyOptions> | 是 | 回调函数。当满足æ¡ä»¶çš„按键输入产生时,回调到æ¤å‡½æ•°ï¼Œä»¥ä¼ 入的KeyOptions为入å‚。 | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| ---------- | -------------------------- | ---- | ---------------------------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,åªæ”¯æŒâ€œkeyâ€ã€‚ | +| keyOptions | [keyOptions](#keyoptions) | 是 | 组åˆé”®é€‰é¡¹ï¼Œç”¨æ¥æŒ‡å®šç»„åˆé”®è¾“入时应该符åˆçš„æ¡ä»¶ã€‚ | +| callback | Callback<KeyOptions> | 是 | 回调函数。当满足æ¡ä»¶çš„按键输入产生时,回调到æ¤å‡½æ•°ï¼Œä»¥ä¼ 入的KeyOptions为入å‚。 | **示例:** -``` +```js let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} let callback = function(keyOptions) { console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, @@ -51,21 +51,19 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): åœæ¢ç›‘å¬ç»„åˆæŒ‰é”®äº‹ä»¶ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - **系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| type | string | 是 | 监å¬è¾“入事件类型,åªæ”¯æŒâ€œkeyâ€ã€‚ | -| keyOptions | [keyOptions](#keyOptions) | 是 | 开始监å¬æ—¶ä¼ 入的keyOptions。 | -| callback | Callback<KeyOptions> | 是 | 开始监å¬æ—¶ä¸ŽKeyOption一åŒä¼ 入的回调函数 。 | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| ---------- | -------------------------- | ---- | ------------------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,åªæ”¯æŒâ€œkeyâ€ã€‚ | +| keyOptions | [keyOptions](#keyoptions) | 是 | 开始监å¬æ—¶ä¼ 入的keyOptions。 | +| callback | Callback<KeyOptions> | 是 | 开始监å¬æ—¶ä¸ŽKeyOption一åŒä¼ 入的回调函数 。 | **示例:** -``` +```js let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} let callback = function(keyOptions) { console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, @@ -75,17 +73,15 @@ inputConsumer.off('key', keyOptions, callback); ``` -## KeyOption +## KeyOptions 组åˆé”®è¾“入事件å‘生时,组åˆé”®æ»¡è¶³çš„选项。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - -**系统能力:**SystemCapability.MultimodalInput.Input.InputConsumer +**系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer - | å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| preKeys | Array | 是 | 组åˆé”®å‰ç½®æŒ‰é”®é›†åˆï¼Œå¯ä¸ºç©ºï¼Œå‰ç½®æŒ‰é”®æ— 顺åºè¦æ±‚。 | -| finalKey | Number | 是 | 组åˆé”®æœ€åŽæŒ‰é”®ï¼Œä¸èƒ½ä¸ºç©ºã€‚ | -| isFinalKeyDown | boolean | 是 | 组åˆé”®æœ€åŽæŒ‰é”®æ˜¯æŒ‰ä¸‹è¿˜æ˜¯æŠ¬èµ·ï¼Œé»˜è®¤æ˜¯æŒ‰ä¸‹ã€‚ | -| finalKeyDownDuration | Number | 是 | 组åˆé”®æœ€åŽæŒ‰é”®æŒ‰ä¸‹æŒç»æ—¶é•¿ï¼Œé»˜è®¤æ— 时长è¦æ±‚。 | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------- | ---- | ------------------------ | +| preKeys | Array | 是 | 组åˆé”®å‰ç½®æŒ‰é”®é›†åˆï¼Œå¯ä¸ºç©ºï¼Œå‰ç½®æŒ‰é”®æ— 顺åºè¦æ±‚。 | +| finalKey | Number | 是 | 组åˆé”®æœ€åŽæŒ‰é”®ï¼Œä¸èƒ½ä¸ºç©ºã€‚ | +| isFinalKeyDown | boolean | 是 | 组åˆé”®æœ€åŽæŒ‰é”®æ˜¯æŒ‰ä¸‹è¿˜æ˜¯æŠ¬èµ·ï¼Œé»˜è®¤æ˜¯æŒ‰ä¸‹ã€‚ | +| finalKeyDownDuration | Number | 是 | 组åˆé”®æœ€åŽæŒ‰é”®æŒ‰ä¸‹æŒç»æ—¶é•¿ï¼Œé»˜è®¤æ— 时长è¦æ±‚。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index 74d20ddb543e4ec64160ae3f22be1f5010fdaecf..902b060a0fe746ce5b2fa529e62a088d25d2190d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -4,7 +4,8 @@ 输入设备管ç†æ¨¡å—,用于监å¬è¾“入设备连接ã€æ–开和å˜åŒ–,并查看输入设备相关信æ¯ã€‚比如监å¬é¼ æ ‡æ’拔,并获å–é¼ æ ‡çš„idã€name和指针移动速度ç‰ä¿¡æ¯ã€‚ -> **说明**:<br> +> **说明**: +> > 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 @@ -28,7 +29,7 @@ on(type: “changeâ€, listener: Callback<DeviceListener>): void | å‚æ•° | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | 是 | 输入设备的事件类型。 | -| listener | Callback<[DeviceListener](#devicelistener<sup>9+</sup>)> | 是 | å¯ä¸ŠæŠ¥çš„输入设备事件。 | +| listener | Callback<[DeviceListener](#devicelistener9)> | 是 | å¯ä¸ŠæŠ¥çš„输入设备事件。 | **示例**: @@ -63,7 +64,7 @@ off(type: “changeâ€, listener?: Callback<DeviceListener>): void | å‚æ•° | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | 是 | 输入设备的事件类型。 | -| listener | Callback<[DeviceListener](#devicelistener<sup>9+</sup>)> | å¦ | å¯ä¸ŠæŠ¥çš„输入设备事件。 | +| listener | Callback<[DeviceListener](#devicelistener9)> | å¦ | å¯ä¸ŠæŠ¥çš„输入设备事件。 | **示例**: @@ -245,7 +246,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): | å‚æ•° | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------------------------- | ---- | --------------------------------- | | deviceId | number | 是 | è¾“å…¥è®¾å¤‡çš„å”¯ä¸€æ ‡è¯†ï¼ŒåŒä¸€ä¸ªç‰©ç†è®¾å¤‡åå¤æ’拔,其设备id会å‘生å˜åŒ–。 | -| callback | AsyncCallback<[KeyboardType](#keyboardtype)> | 是 | 回调函数,异æ¥è¿”回查询结果。 | +| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | 是 | 回调函数,异æ¥è¿”回查询结果。 | **示例**: @@ -268,7 +269,7 @@ getKeyboardType(deviceId: number): Promise<KeyboardType> | å‚æ•° | 说明 | | ---------------------------------------- | ------------------- | -| Promise<[KeyboardType](#keyboardtype)> | Promise实例,用于异æ¥èŽ·å–结果。 | +| Promise<[KeyboardType](#keyboardtype9)> | Promise实例,用于异æ¥èŽ·å–结果。 | **示例**: @@ -283,7 +284,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的æè¿°ä¿¡æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | -------- | --------------------------- | --------------------------------- | @@ -294,7 +295,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的æè¿°ä¿¡æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | -------------------- | -------------------------------------- | ---------------------------------------- | @@ -313,7 +314,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的轴类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | ----------- | ------ | --------------- | @@ -331,12 +332,12 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 输入设备的轴信æ¯ã€‚ -**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**: SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | ----------------------- | ------------------------- | -------- | | source | [SourceType](#sourcetype) | 轴的输入æºç±»åž‹ã€‚ | -| axis | [AxisType](#axistype) | 轴的类型。 | +| axis | [AxisType](#axistype9) | 轴的类型。 | | max | number | 轴的最大值。 | | min | number | 轴的最å°å€¼ã€‚ | | fuzz<sup>9+</sup> | number | 轴的模糊值。 | @@ -347,7 +348,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 定义这个轴的输入æºç±»åž‹ã€‚æ¯”å¦‚é¼ æ ‡è®¾å¤‡å¯ä¸ŠæŠ¥x轴事件,则xè½´çš„æºå°±æ˜¯é¼ æ ‡ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | ----------- | ------ | ----------- | @@ -358,11 +359,11 @@ inputDevice.getKeyboardType(1).then((ret)=>{ | touchpad | string | 表示输入设备是触摸æ¿ã€‚ | | joystick | string | 表示输入设备是æ“纵æ†ã€‚ | -## ChangeType +## ChangedType 定义监å¬è®¾å¤‡çƒæ’拔事件。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 说明 | | ------ | ------ | --------- | @@ -373,7 +374,7 @@ inputDevice.getKeyboardType(1).then((ret)=>{ 定义键盘输入设备的类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputDevice +**系统能力**:SystemCapability.MultimodalInput.Input.InputDevice | å称 | å‚数类型 | 值 | 说明 | | ------------------- | ------ | ---- | --------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md index 01aaa9b2ba3954da6e5836be22729fb6d8a066f2..df973465e5b7341c60de3740e757d320dc3feed7 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md @@ -2,7 +2,7 @@ InputEvent模å—æ述了设备上报的基本事件。 ->  **说明:** +> **说明:** > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -13,12 +13,12 @@ import InputEvent from '@ohos.multimodalInput.inputEvent'; ## InputEvent -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| id | number | 是 | å¦ | ç”±æœåŠ¡ç«¯ç”Ÿæˆå…¨å±€å”¯ä¸€äº‹ä»¶id | -| deviceId | number | 是 | å¦ | 上报输入事件的设备id | -| actionTime | number | 是 | å¦ | 输入事件的上报时间 | -| screenId | number | 是 | å¦ | ç›®æ ‡å±å¹•id | -| windowId | number | 是 | å¦ | ç›®æ ‡çª—å£id | \ No newline at end of file +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ---------- | ------ | ---- | ---- | -------------- | +| id | number | 是 | å¦ | ç”±æœåŠ¡ç«¯ç”Ÿæˆå…¨å±€å”¯ä¸€äº‹ä»¶id | +| deviceId | number | 是 | å¦ | 上报输入事件的设备id | +| actionTime | number | 是 | å¦ | 输入事件的上报时间 | +| screenId | number | 是 | å¦ | ç›®æ ‡å±å¹•id | +| windowId | number | 是 | å¦ | ç›®æ ‡çª—å£id | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md index d199635658c38b565315bc9b0e760b8e67ba0cee..82c05b94b72c330b921d6d868768d19268fcc023 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -6,7 +6,7 @@ InputEventClient模å—æ供了注入按键能力。 > > - 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > -> - 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +> - 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— @@ -23,8 +23,6 @@ injectEvent({KeyEvent: KeyEvent}): void 注入按键,KeyEvent为注入按键的æè¿°ä¿¡æ¯ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - **系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator **å‚数:** @@ -48,15 +46,13 @@ let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ## KeyEvent -注入按键的æè¿°ä¿¡æ¯ - -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +注入按键的æè¿°ä¿¡æ¯ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.InputSimulator +**系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator | å‚æ•° | 类型 | å¿…å¡« | 说明 | | --------------- | ------- | ---- | --------- | | isPressed | boolean | 是 | 按键是å¦æŒ‰ä¸‹ | | keyCode | number | 是 | 按键键值 | -| keyDownDuration | number | 是 | 按键按下æŒç»æ—¶é—´ | -| isIntercepted | boolean | 是 | 按键是å¦å¯ä»¥è¢«æ‹¦æˆª | +| keyDownDuration | number | 是 | 按键按下æŒç»æ—¶é—´ | +| isIntercepted | boolean | 是 | 按键是å¦å¯ä»¥è¢«æ‹¦æˆª | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index 09f90747863be35c6e4f32e971fbce67f03f6c09..a11614d149bfd2db3c3b8370aeba57ea906f880d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -2,14 +2,15 @@ 本模å—æ供对输入法框架的管ç†ï¼ŒåŒ…括éšè—输入法ã€æŸ¥è¯¢å·²å®‰è£…的输入法列表和显示输入法选择对è¯æ¡†ã€‚ ->  **说明:** +> **说明:** +> > 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— ``` -import inputMethod from '@ohos.inputMethod'; +import inputMethod from '@ohos.inputmethod'; ``` ## inputMethod<sup>8+</sup> @@ -38,7 +39,7 @@ import inputMethod from '@ohos.inputMethod'; getInputMethodController(): InputMethodController -获å–客户端实例[InputMethodController](#InputMethodController)。 +获å–客户端实例[InputMethodController](#inputmethodcontroller)。 **系统能力**:SystemCapability.MiscServices.InputMethodFramework @@ -46,7 +47,7 @@ getInputMethodController(): InputMethodController | 类型 | 说明 | | -------- | -------- | - | [InputMethodController](#InputMethodController) | 回调返回当å‰å®¢æˆ·ç«¯å®žä¾‹ã€‚ | + | [InputMethodController](#inputmethodcontroller) | 回调返回当å‰å®¢æˆ·ç«¯å®žä¾‹ã€‚ | **示例:** @@ -58,7 +59,7 @@ getInputMethodController(): InputMethodController getInputMethodSetting(): InputMethodSetting -获å–客户端设置实例[InputMethodSetting](#InputMethodSetting)。 +获å–客户端设置实例[InputMethodSetting](#inputmethodsetting8)。 **系统能力**: SystemCapability.MiscServices.InputMethodFramework @@ -66,7 +67,7 @@ getInputMethodSetting(): InputMethodSetting | 类型 | 说明 | | ----------------------------------------- | ---------------------------- | -| [InputMethodSetting](#InputMethodSetting) | 回调返回当å‰å®¢æˆ·ç«¯è®¾ç½®å®žä¾‹ã€‚ | +| [InputMethodSetting](#inputmethodsetting8) | 回调返回当å‰å®¢æˆ·ç«¯è®¾ç½®å®žä¾‹ã€‚ | **示例:** @@ -78,6 +79,8 @@ getInputMethodSetting(): InputMethodSetting switchInputMethod(target: InputmethodProperty, callback: AsyncCallback<boolean>): void; +切æ¢è¾“入法。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 + **系统能力**:SystemCapability.Miscservices.InputMethodFramework @@ -99,6 +102,7 @@ switchInputMethod(target: InputmethodProperty, callback: AsyncCallback<boolea ## inputMethod.switchInputMethod<sup>9+</sup> switchInputMethod(target: InputmethodProperty): Promise<boolean> +切æ¢è¾“入法。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 **系统能力**: SystemCapability.Miscservices.InputMethodFramework @@ -111,7 +115,7 @@ switchInputMethod(target: InputmethodProperty): Promise<boolean> **返回值:** | 类型 | 说明 | | ----------------------------------------- | ---------------------------- | - | [Promise](#Promise) | 回调返回切æ¢åŽçš„输入法。 | + | Promise\<boolean> | 回调返回切æ¢åŽçš„输入法。 | **示例:** @@ -123,7 +127,7 @@ switchInputMethod(target: InputmethodProperty): Promise<boolean> ``` ## InputMethodController -下列API示例ä¸éƒ½éœ€ä½¿ç”¨[getInputMethodController](#getInputMethodController)回调获å–到InputMethodController实例,å†é€šè¿‡æ¤å®žä¾‹è°ƒç”¨å¯¹åº”方法。 +下列API示例ä¸éƒ½éœ€ä½¿ç”¨[getInputMethodController](#inputmethodgetinputmethodcontroller)回调获å–到InputMethodController实例,å†é€šè¿‡æ¤å®žä¾‹è°ƒç”¨å¯¹åº”方法。 ### stopInput @@ -171,7 +175,7 @@ stopInput(): Promise<boolean> ## InputMethodSetting<sup>8+</sup> -下列API示例ä¸éƒ½éœ€ä½¿ç”¨[getInputMethodSetting](#getInputMethodSetting)回调获å–到InputMethodSetting实例,å†é€šè¿‡æ¤å®žä¾‹è°ƒç”¨å¯¹åº”方法。 +下列API示例ä¸éƒ½éœ€ä½¿ç”¨[getInputMethodSetting](#inputmethodgetinputmethodcontroller)回调获å–到InputMethodSetting实例,å†é€šè¿‡æ¤å®žä¾‹è°ƒç”¨å¯¹åº”方法。 ### listInputMethod @@ -184,7 +188,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | -| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | +| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是 | 返回已安装输入法列表。 | **示例:** @@ -208,7 +212,7 @@ listInputMethod(): Array<InputMethodProperty> **返回值:** | 类型 | 说明 | | ----------------------------------------------------------- | ---------------------- | -| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 | +| Promise<Array<[InputMethodProperty](#inputmethodproperty8)>> | 返回已安装输入法列表。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index 438362623786e279ffe399efd31c88358fa41b62..3a9f870ae16920a3c5c4a1c9bf6c4f0ad5b347a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -8,7 +8,7 @@ ## å¯¼å…¥æ¨¡å— ``` -import inputMethodEngine from '@ohos.inputMethodEngine'; +import inputMethodEngine from '@ohos.inputmethodengine'; ``` ## inputMethodEngine diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index be52e915593fe57342e8e74ca2d5ac4a2a73f0de..6659984f7fa36cafaaae252913f4c84e5f3e6d1a 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -2,10 +2,10 @@ InputMonitor模å—æ供了监å¬å…¨å±€è§¦æ‘¸äº‹ä»¶çš„功能。 ->  **说明:** +> **说明:** > - 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > -> - 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +> - 本模å—接å£å‡ä¸ºç³»ç»ŸæŽ¥å£ã€‚ ## å¯¼å…¥æ¨¡å— @@ -16,28 +16,21 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor'; ``` -## æƒé™ - -ohos.permission.INPUT_MONITORING - - ## inputMonitor.on on(type: "touch", receiver: TouchEventReceiver): void 开始监å¬å…¨å±€è§¦å±äº‹ä»¶ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - -**需è¦æƒé™ï¼š**ohos.permission.INPUT_MONITORING +**需è¦æƒé™ï¼š** ohos.permission.INPUT_MONITORING -**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------------- | ---- | ------------------------------- | -| type | string | 是 | 监å¬è¾“入事件类型,å–值“touchâ€ã€‚ | -| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,å–值“touchâ€ã€‚ | +| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 | **示例:** @@ -53,18 +46,16 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void 开始监å¬å…¨å±€é¼ æ ‡äº‹ä»¶ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - **需è¦æƒé™ï¼š** ohos.permission.INPUT_MONITORING **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------------- | ---- | ------------------------------- | -| type | string | 是 | 监å¬è¾“入事件类型,å–值“mouseâ€ã€‚ | -| receiver | Callback<MouseEvent> | 是 | é¼ æ ‡è¾“å…¥äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚ | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,å–值“mouseâ€ã€‚ | +| receiver | Callback<MouseEvent> | 是 | é¼ æ ‡è¾“å…¥äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚ | **示例:** @@ -82,17 +73,15 @@ off(type: "touch", receiver?: TouchEventReceiver): void åœæ¢ç›‘å¬å…¨å±€è§¦å±äº‹ä»¶ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - -**需è¦æƒé™ï¼š**ohos.permission.INPUT_MONITORING +**需è¦æƒé™ï¼š** ohos.permission.INPUT_MONITORING -**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | ----------------------------------------- | ---- | ------------------------------- | -| type | string | 是 | 监å¬è¾“入事件类型,å–值“touchâ€ã€‚ | -| receiver | [TouchEventReceiver](#toucheventreceiver) | å¦ | 触摸输入事件回调函数。 | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,å–值“touchâ€ã€‚ | +| receiver | [TouchEventReceiver](#toucheventreceiver) | å¦ | 触摸输入事件回调函数。 | **示例:** @@ -104,18 +93,16 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void åœæ¢ç›‘å¬å…¨å±€é¼ æ ‡äº‹ä»¶ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ - -**需è¦æƒé™ï¼š**ohos.permission.INPUT_MONITORING +**需è¦æƒé™ï¼š** ohos.permission.INPUT_MONITORING -**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **å‚数:** -| å‚æ•° | 类型 | å¿…å¡« | 说明 | -| -------- | -------------------------- | ---- | ------------------------------- | -| type | string | 是 | 监å¬è¾“入事件类型,å–值“mouseâ€ã€‚ | -| receiver | Callback<MouseEvent> | å¦ | é¼ æ ‡è¾“å…¥äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚ | +| å‚æ•° | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------- | ---- | ------------------- | +| type | string | 是 | 监å¬è¾“入事件类型,å–值“mouseâ€ã€‚ | +| receiver | Callback<MouseEvent> | å¦ | é¼ æ ‡è¾“å…¥äº‹ä»¶å›žè°ƒå‡½æ•°ã€‚ | **示例:** @@ -129,9 +116,9 @@ inputMonitor.off("mouse"); 触摸输入事件的回调函数。如果返回true,则触摸输入被监å¬å™¨æ¶ˆè€—,系统将执行关é—动作。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.INPUT_MONITORING -**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor +**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor **å‚数:** | å‚æ•° | 类型 | å¿…å¡« | 说明 | @@ -139,8 +126,8 @@ inputMonitor.off("mouse"); | touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | 是 | 触摸输入事件回调函数,返回true表示输触事件被监å¬å™¨æ¶ˆè´¹ï¼Œfalse表示输触事件未被监å¬å™¨æ¶ˆè´¹ã€‚ | **返回值:** -| 类型 | 说明 | -| ------- | -------------------------------------- | +| 类型 | 说明 | +| ------- | ---------------------------------------- | | Boolean | 返回true表示触摸输入事件被监å¬å™¨æ¶ˆè´¹ï¼Œfalse表示触摸输入事件未被监å¬å™¨æ¶ˆè´¹ã€‚ | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index f3c4df4e1deee00198bb19f0a79f16c0760af3ff..9157c68e4501463b98633d1c86451b6e455c0f44 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -3,7 +3,7 @@ 本模å—æä¾›æä¾›åŸºç¡€çš„åº”ç”¨å›½é™…åŒ–èƒ½åŠ›ï¼ŒåŒ…æ‹¬æ—¶é—´æ—¥æœŸæ ¼å¼åŒ–ã€æ•°å—æ ¼å¼åŒ–ã€æŽ’åºç‰ï¼Œç›¸å…³æŽ¥å£åœ¨ECMA 402æ ‡å‡†ä¸å®šä¹‰ã€‚ [I18N模å—](js-apis-i18n.md)æ供其他éžECMA 402定义的国际化接å£ï¼Œä¸Žæœ¬æ¨¡å—å…±åŒä½¿ç”¨å¯æ供完整地国际化支æŒèƒ½åŠ›ã€‚ ->  **说明:** +> **说明:** > - 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > > - Intl模å—包å«å›½é™…化能力基础接å£ï¼ˆåœ¨ECMA 402ä¸å®šä¹‰ï¼‰ï¼ŒåŒ…æ‹¬æ—¶é—´æ—¥æœŸæ ¼å¼åŒ–ã€æ•°å—æ ¼å¼åŒ–ã€æŽ’åºç‰ï¼Œå›½é™…化增强能力请å‚考[I18N模å—](js-apis-i18n.md)。 @@ -11,7 +11,7 @@ ## å¯¼å…¥æ¨¡å— -``` +```js import Intl from '@ohos.intl'; ``` @@ -46,7 +46,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var locale = new Intl.Locale(); ``` @@ -66,7 +66,7 @@ constructor(locale: string, options?: LocaleOptions) | options | LocaleOptions | å¦ | 用于创建区域对象的选项。 | **示例:** - ``` + ```js var locale = new Intl.Locale("zh-CN"); ``` @@ -85,7 +85,7 @@ toString(): string | string | å—符串形å¼çš„区域信æ¯ã€‚ | **示例:** - ``` + ```js var locale = new Intl.Locale("zh-CN"); locale.toString(); ``` @@ -105,7 +105,7 @@ maximize(): Locale | [Locale](#locale) | 最大化åŽçš„区域对象。 | **示例:** - ``` + ```js var locale = new Intl.Locale("zh-CN"); locale.maximize(); ``` @@ -125,7 +125,7 @@ minimize(): Locale | [Locale](#locale) | 最å°åŒ–åŽçš„区域对象。 | **示例:** - ``` + ```js var locale = new Intl.Locale("zh-CN"); locale.minimize(); ``` @@ -135,7 +135,7 @@ minimize(): Locale 表示区域åˆå§‹åŒ–选项。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | --------------- | ------- | ---- | ---- | ---------------------------------------- | @@ -159,7 +159,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var datefmt= new Intl.DateTimeFormat(); ``` @@ -179,13 +179,13 @@ constructor(locale: string | Array<string>, options?: DateTimeOptions) | options | [DateTimeOptions](#datetimeoptions) | å¦ | ç”¨äºŽåˆ›å»ºæ—¶é—´æ—¥æœŸæ ¼å¼åŒ–的选项。 | **示例:** - ``` + ```js var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); ``` **示例:** - ``` + ```js var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); ``` @@ -209,7 +209,7 @@ format(date: Date): string | string | æ ¼å¼åŒ–åŽçš„时间日期å—符串 | **示例:** - ``` + ```js var date = new Date(2021, 11, 17, 3, 24, 0); var datefmt = new Intl.DateTimeFormat("en-GB"); datefmt.format(date); @@ -236,7 +236,7 @@ formatRange(startDate: Date, endDate: Date): string | string | æ ¼å¼åŒ–åŽçš„时间日期段å—符串。 | **示例:** - ``` + ```js var startDate = new Date(2021, 11, 17, 3, 24, 0); var endDate = new Date(2021, 11, 18, 3, 24, 0); var datefmt = new Intl.DateTimeFormat("en-GB"); @@ -258,7 +258,7 @@ resolvedOptions(): DateTimeOptions | [DateTimeOptions](#datetimeoptions) | DateTimeFormat å¯¹è±¡çš„æ ¼å¼åŒ–选项。 | **示例:** - ``` + ```js var datefmt = new Intl.DateTimeFormat("en-GB"); datefmt.resolvedOptions(); ``` @@ -268,7 +268,7 @@ resolvedOptions(): DateTimeOptions è¡¨ç¤ºæ—¶é—´æ—¥æœŸæ ¼å¼åŒ–选项。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | --------------- | ------- | ---- | ---- | ---------------------------------------- | @@ -305,7 +305,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var numfmt = new Intl.NumberFormat(); ``` @@ -325,7 +325,7 @@ constructor(locale: string | Array<string>, options?: NumberOptions) | options | [NumberOptions](#numberoptions) | å¦ | 用于创建数å—æ ¼å¼åŒ–的选项。 | **示例:** - ``` + ```js var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); ``` @@ -350,7 +350,7 @@ format(number: number): string; **示例:** - ``` + ```js var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); numfmt.format(1223); ``` @@ -371,7 +371,7 @@ resolvedOptions(): NumberOptions **示例:** - ``` + ```js var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); numfmt.resolvedOptions(); ``` @@ -391,7 +391,7 @@ resolvedOptions(): NumberOptions | currencyDisplay | string | 是 | 是 | è´§å¸çš„显示方å¼ï¼Œå–值包括:"symbol", "narrowSymbol", "code", "name"。 | | unit | string | 是 | 是 | å•ä½å称,如:"meter","inch",“hectareâ€ç‰ã€‚ | | unitDisplay | string | 是 | 是 | å•ä½çš„æ˜¾ç¤ºæ ¼å¼ï¼Œå–值包括:"long", "short", "narrow"。 | -| unitUsage<sup>8+</sup> | string | 是 | 是 | å•ä½çš„使用场景,å–值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | +| unitUsage<sup>8+</sup> | string | 是 | 是 | å•ä½çš„使用场景,å–值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | | signDisplay | string | 是 | 是 | æ•°å—符å·çš„æ˜¾ç¤ºæ ¼å¼ï¼Œå–值包括:"auto", "never", "always", "expectZero"。 | | compactDisplay | string | 是 | 是 | ç´§å‡‘åž‹çš„æ˜¾ç¤ºæ ¼å¼ï¼Œå–值包括:"long", "short"。 | | notation | string | 是 | 是 | æ•°å—çš„æ ¼å¼åŒ–è§„æ ¼ï¼Œå–值包括:"standard", "scientific", "engineering", "compact"。 | @@ -418,7 +418,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var collator = new Intl.Collator(); ``` @@ -439,7 +439,7 @@ constructor(locale: string | Array<string>, options?: CollatorOptions) | options | [CollatorOptions](#collatoroptions) | å¦ | 用于创建排åºå¯¹è±¡çš„选项。 | **示例:** - ``` + ```js var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"}); ``` @@ -464,7 +464,7 @@ compare(first: string, second: string): number | number | 比较结果。当number为负数,表示first排åºåœ¨second之å‰ï¼›å½“number为0,表示first与second排åºç›¸åŒï¼›å½“number为æ£æ•°ï¼Œè¡¨ç¤ºfirst排åºåœ¨second之åŽã€‚ | **示例:** - ``` + ```js var collator = new Intl.Collator("zh-Hans"); collator.compare("first", "second"); ``` @@ -484,17 +484,17 @@ resolvedOptions(): CollatorOptions | [CollatorOptions](#collatoroptions) | 返回的Collator对象的属性。 | **示例:** - ``` + ```js var collator = new Intl.Collator("zh-Hans"); var options = collator.resolvedOptions(); ``` -## CollatorOptions<sup>8+</sup><a name=collatoroptions></a> +## CollatorOptions<sup>8+</sup> 表示Collatorå¯è®¾ç½®çš„属性。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ----------------- | ------- | ---- | ---- | ---------------------------------------- | @@ -519,7 +519,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var pluralRules = new Intl.PluralRules(); ``` @@ -539,8 +539,8 @@ constructor(locale: string | Array<string>, options?: PluralRulesOptions) | options | [PluralRulesOptions](#pluralrulesoptions) | å¦ | 用于创建å•å¤æ•°å¯¹è±¡çš„选项。 | **示例:** - ``` - var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); + ```js + var pluralRules= new Intl.PluralRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); ``` @@ -563,17 +563,17 @@ select(n: number): string | string | å•å¤æ•°ç±»åˆ«ï¼Œå–值包括:"zero","one","two", "few", "many", "others"。 | **示例:** - ``` + ```js var pluralRules = new Intl.PluralRules("zh-Hans"); pluralRules.select(1); ``` -## PluralRulesOptions<sup>8+</sup><a name=pluralrulesoptions></a> +## PluralRulesOptions<sup>8+</sup> 表示PluralRules对象å¯è®¾ç½®çš„属性。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ------------------------ | ------ | ---- | ---- | ---------------------------------------- | @@ -598,7 +598,7 @@ constructor() **系统能力**:SystemCapability.Global.I18n **示例:** - ``` + ```js var relativetimefmt = new Intl.RelativeTimeFormat(); ``` @@ -618,7 +618,7 @@ constructor(locale: string | Array<string>, options?: RelativeTimeFormatIn | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | å¦ | ç”¨äºŽåˆ›å»ºç›¸å¯¹æ—¶é—´æ ¼å¼åŒ–对象的选项。 | **示例:** - ``` + ```js var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); ``` @@ -643,7 +643,7 @@ format(value: number, unit: string): string | string | æ ¼å¼åŒ–åŽçš„相对时间。 | **示例:** - ``` + ```js var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); relativetimefmt.format(3, "quarter") ``` @@ -669,7 +669,7 @@ formatToParts(value: number, unit: string): Array<object> | Array<object> | 返回å¯ç”¨äºŽè‡ªå®šä¹‰åŒºåŸŸè®¾ç½®æ ¼å¼çš„ç›¸å¯¹æ—¶é—´æ ¼å¼çš„对象数组。 | **示例:** - ``` + ```js var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); var parts = relativetimefmt.format(10, "seconds"); ``` @@ -689,17 +689,17 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | RelativeTimeFormat å¯¹è±¡çš„æ ¼å¼åŒ–选项。 | **示例:** - ``` + ```js var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); relativetimefmt.resolvedOptions(); ``` -## RelativeTimeFormatInputOptions<sup>8+</sup><a name=relativetimeformatinputoptions></a> +## RelativeTimeFormatInputOptions<sup>8+</sup> 表示RelativeTimeFormat对象å¯è®¾ç½®çš„属性。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | ------------- | ------ | ---- | ---- | ---------------------------------------- | @@ -708,11 +708,11 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions | style | string | 是 | 是 | 国际化消æ¯çš„长度,å–值包括:"long", "short", "narrow"。 | -## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a> +## RelativeTimeFormatResolvedOptions<sup>8+</sup> 表示RelativeTimeFormat对象å¯è®¾ç½®çš„属性。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.I18n +**系统能力**:SystemCapability.Global.I18n | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | | --------------- | ------ | ---- | ---- | ---------------------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keycode.md b/zh-cn/application-dev/reference/apis/js-apis-keycode.md index 2559bcf9dc665a91d8f79a60006e9a04cc1fcf10..ae30bf1186b06d7a034f219c5407f30becbcc01c 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keycode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keycode.md @@ -2,7 +2,7 @@ KeyCode模å—æ供了按键类设备的键值。 ->  **说明:** +> **说明:** > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -13,337 +13,337 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode' ## KeyCode -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| KEYCODE_FN | number | 是 | å¦ | 功能(Fn)键 | -| KEYCODE_UNKNOWN | number | 是 | å¦ | 未知按键 | -| KEYCODE_HOME | number | 是 | å¦ | 按键Home | -| KEYCODE_BACK | number | 是 | å¦ | 返回键 | -| KEYCODE_MEDIA_PLAY_PAUSE | number | 是 | å¦ | 多媒体键 æ’放/æš‚åœ | -| KEYCODE_MEDIA_STOP | number | 是 | å¦ | 多媒体键 åœæ¢ | -| KEYCODE_MEDIA_NEXT | number | 是 | å¦ | 多媒体键 下一首 | -| KEYCODE_MEDIA_PREVIOUS | number | 是 | å¦ | 多媒体键 上一首 | -| KEYCODE_MEDIA_REWIND | number | 是 | å¦ | 多媒体键 快退 | -| KEYCODE_MEDIA_FAST_FORWARD | number | 是 | å¦ | 多媒体键 å¿«è¿› | -| KEYCODE_VOLUME_UP | number | 是 | å¦ | 音é‡å¢žåŠ é”® | -| KEYCODE_VOLUME_DOWN | number | 是 | å¦ | 音é‡å‡å°é”® | -| KEYCODE_POWER | number | 是 | å¦ | 电æºé”® | -| KEYCODE_CAMERA | number | 是 | å¦ | æ‹ç…§é”® | -| KEYCODE_VOLUME_MUTE | number | 是 | å¦ | 扬声器é™éŸ³é”® | -| KEYCODE_MUTE | number | 是 | å¦ | è¯ç’é™éŸ³é”® | -| KEYCODE_BRIGHTNESS_UP | number | 是 | å¦ | 亮度调节按键 调亮 | -| KEYCODE_BRIGHTNESS_DOWN | number | 是 | å¦ | 亮度调节按键 调暗 | -| KEYCODE_0 | number | 是 | å¦ | 按键'0' | -| KEYCODE_1 | number | 是 | å¦ | 按键'1' | -| KEYCODE_2 | number | 是 | å¦ | 按键'2' | -| KEYCODE_3 | number | 是 | å¦ | 按键'3' | -| KEYCODE_4 | number | 是 | å¦ | 按键'4' | -| KEYCODE_5 | number | 是 | å¦ | 按键'5' | -| KEYCODE_6 | number | 是 | å¦ | 按键'6' | -| KEYCODE_7 | number | 是 | å¦ | 按键'7' | -| KEYCODE_8 | number | 是 | å¦ | 按键'8' | -| KEYCODE_9 | number | 是 | å¦ | 按键'9' | -| KEYCODE_STAR | number | 是 | å¦ | 按键'*' | -| KEYCODE_POUND | number | 是 | å¦ | 按键'#' | -| KEYCODE_DPAD_UP | number | 是 | å¦ | 导航键 å‘上 | -| KEYCODE_DPAD_DOWN | number | 是 | å¦ | 导航键 å‘下 | -| KEYCODE_DPAD_LEFT | number | 是 | å¦ | 导航键 å‘å·¦ | -| KEYCODE_DPAD_RIGHT | number | 是 | å¦ | 导航键 å‘å³ | -| KEYCODE_DPAD_CENTER | number | 是 | å¦ | 导航键 确定键 | -| KEYCODE_A | number | 是 | å¦ | 按键'A' | -| KEYCODE_B | number | 是 | å¦ | 按键'B' | -| KEYCODE_C | number | 是 | å¦ | 按键'C' | -| KEYCODE_D | number | 是 | å¦ | 按键'D' | -| KEYCODE_E | number | 是 | å¦ | 按键'E' | -| KEYCODE_F | number | 是 | å¦ | 按键'F' | -| KEYCODE_G | number | 是 | å¦ | 按键'G' | -| KEYCODE_H | number | 是 | å¦ | 按键'H' | -| KEYCODE_I | number | 是 | å¦ | 按键'I' | -| KEYCODE_J | number | 是 | å¦ | 按键'J' | -| KEYCODE_K | number | 是 | å¦ | 按键'K' | -| KEYCODE_L | number | 是 | å¦ | 按键'L' | -| KEYCODE_M | number | 是 | å¦ | 按键'M' | -| KEYCODE_N | number | 是 | å¦ | 按键'N' | -| KEYCODE_O | number | 是 | å¦ | 按键'O' | -| KEYCODE_P | number | 是 | å¦ | 按键'P' | -| KEYCODE_Q | number | 是 | å¦ | 按键'Q' | -| KEYCODE_R | number | 是 | å¦ | 按键'R' | -| KEYCODE_S | number | 是 | å¦ | 按键'S' | -| KEYCODE_T | number | 是 | å¦ | 按键'T' | -| KEYCODE_U | number | 是 | å¦ | 按键'U' | -| KEYCODE_V | number | 是 | å¦ | 按键'V' | -| KEYCODE_W | number | 是 | å¦ | 按键'W' | -| KEYCODE_X | number | 是 | å¦ | 按键'X' | -| KEYCODE_Y | number | 是 | å¦ | 按键'Y' | -| KEYCODE_Z | number | 是 | å¦ | 按键'Z' | -| KEYCODE_COMMA | number | 是 | å¦ | 按键',' | -| KEYCODE_PERIOD | number | 是 | å¦ | 按键'.' | -| KEYCODE_ALT_LEFT | number | 是 | å¦ | Alt+Left | -| KEYCODE_ALT_RIGHT | number | 是 | å¦ | Alt+Right | -| KEYCODE_SHIFT_LEFT | number | 是 | å¦ | Shift+Left | -| KEYCODE_SHIFT_RIGHT | number | 是 | å¦ | Shift+Right | -| KEYCODE_TAB | number | 是 | å¦ | Tabé”® | -| KEYCODE_SPACE | number | 是 | å¦ | ç©ºæ ¼é”® | -| KEYCODE_SYM | number | 是 | å¦ | 符å·ä¿®æ”¹å™¨æŒ‰é”® | -| KEYCODE_EXPLORER | number | 是 | å¦ | æµè§ˆå™¨åŠŸèƒ½é”®ï¼Œæ¤é”®ç”¨äºŽå¯åŠ¨æµè§ˆå™¨åº”用程åºã€‚ | -| KEYCODE_ENVELOPE | number | 是 | å¦ | 电å邮件功能键,æ¤é”®ç”¨äºŽå¯åŠ¨ç”µå邮件应用程åºã€‚| -| KEYCODE_ENTER | number | 是 | å¦ | 回车键 | -| KEYCODE_DEL | number | 是 | å¦ | é€€æ ¼é”® | -| KEYCODE_GRAVE | number | 是 | å¦ | 按键'`' | -| KEYCODE_MINUS | number | 是 | å¦ | 按键'-' | -| KEYCODE_EQUALS | number | 是 | å¦ | 按键'=' | -| KEYCODE_LEFT_BRACKET | number | 是 | å¦ | 按键'[' | -| KEYCODE_RIGHT_BRACKET | number | 是 | å¦ | 按键']' | -| KEYCODE_BACKSLASH | number | 是 | å¦ | 按键'\' | -| KEYCODE_SEMICOLON | number | 是 | å¦ | 按键';' | -| KEYCODE_APOSTROPHE | number | 是 | å¦ | 按键''' (å•å¼•å·) | -| KEYCODE_SLASH | number | 是 | å¦ | 按键'/' | -| KEYCODE_AT | number | 是 | å¦ | 按键'@' | -| KEYCODE_PLUS | number | 是 | å¦ | 按键'+' | -| KEYCODE_MENU | number | 是 | å¦ | èœå•é”® | -| KEYCODE_PAGE_UP | number | 是 | å¦ | å‘上翻页键 | -| KEYCODE_PAGE_DOWN | number | 是 | å¦ | å‘下翻页键 | -| KEYCODE_ESCAPE | number | 是 | å¦ | ESCé”® | -| KEYCODE_FORWARD_DEL | number | 是 | å¦ | åˆ é™¤é”® | -| KEYCODE_CTRL_LEFT | number | 是 | å¦ | Control+Left | -| KEYCODE_CTRL_RIGHT | number | 是 | å¦ | Control+Right | -| KEYCODE_CAPS_LOCK | number | 是 | å¦ | 大写é”定键 | -| KEYCODE_SCROLL_LOCK | number | 是 | å¦ | 滚动é”定键 | -| KEYCODE_META_LEFT | number | 是 | å¦ | 左元修改器键 | -| KEYCODE_META_RIGHT | number | 是 | å¦ | å³å…ƒä¿®æ”¹å™¨é”® | -| KEYCODE_FUNCTION | number | 是 | å¦ | 函数修改器键 | -| KEYCODE_SYSRQ | number | 是 | å¦ | 系统请求/打å°å±å¹•é”® | -| KEYCODE_BREAK | number | 是 | å¦ | Break/Pauseé”® | -| KEYCODE_MOVE_HOME | number | 是 | å¦ | å…‰æ ‡ç§»åŠ¨åˆ°å¼€å§‹é”® | -| KEYCODE_MOVE_END | number | 是 | å¦ | å…‰æ ‡ç§»åŠ¨åˆ°æœ«å°¾é”® | -| KEYCODE_INSERT | number | 是 | å¦ | æ’入键 | -| KEYCODE_FORWARD | number | 是 | å¦ | åˆ é™¤é”® | -| KEYCODE_MEDIA_PLAY | number | 是 | å¦ | 多媒体键 æ’放 | -| KEYCODE_MEDIA_PAUSE | number | 是 | å¦ | 多媒体键 æš‚åœ | -| KEYCODE_MEDIA_CLOSE | number | 是 | å¦ | 多媒体键 å…³é— | -| KEYCODE_MEDIA_EJECT | number | 是 | å¦ | 多媒体键 弹出 | -| KEYCODE_MEDIA_RECORD | number | 是 | å¦ | 多媒体键 录音 | -| KEYCODE_F1 | number | 是 | å¦ | 按键'F1' | -| KEYCODE_F2 | number | 是 | å¦ | 按键'F2' | -| KEYCODE_F3 | number | 是 | å¦ | 按键'F3' | -| KEYCODE_F4 | number | 是 | å¦ | 按键'F4' | -| KEYCODE_F5 | number | 是 | å¦ | 按键'F5' | -| KEYCODE_F6 | number | 是 | å¦ | 按键'F6' | -| KEYCODE_F7 | number | 是 | å¦ | 按键'F7' | -| KEYCODE_F8 | number | 是 | å¦ | 按键'F8' | -| KEYCODE_F9 | number | 是 | å¦ | 按键'F9' | -| KEYCODE_F10 | number | 是 | å¦ | 按键'F10' | -| KEYCODE_F11 | number | 是 | å¦ | 按键'F11' | -| KEYCODE_F12 | number | 是 | å¦ | 按键'F12' | -| KEYCODE_NUM_LOCK | number | 是 | å¦ | å°é”®ç›˜é” | -| KEYCODE_NUMPAD_0 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'0' | -| KEYCODE_NUMPAD_1 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'1' | -| KEYCODE_NUMPAD_2 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'2' | -| KEYCODE_NUMPAD_3 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'3' | -| KEYCODE_NUMPAD_4 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'4' | -| KEYCODE_NUMPAD_5 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'5' | -| KEYCODE_NUMPAD_6 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'6' | -| KEYCODE_NUMPAD_7 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'7' | -| KEYCODE_NUMPAD_8 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'8' | -| KEYCODE_NUMPAD_9 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'9' | -| KEYCODE_NUMPAD_DIVIDE | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'/' | -| KEYCODE_NUMPAD_MULTIPLY | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'*' | -| KEYCODE_NUMPAD_SUBTRACT | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'-' | -| KEYCODE_NUMPAD_ADD | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'+' | -| KEYCODE_NUMPAD_DOT | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'.' | -| KEYCODE_NUMPAD_COMMA | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®',' | -| KEYCODE_NUMPAD_ENTER | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®å›žè½¦ | -| KEYCODE_NUMPAD_EQUALS | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'=' | -| KEYCODE_NUMPAD_LEFT_PAREN | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'(' | -| KEYCODE_NUMPAD_RIGHT_PAREN | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®')' | -| KEYCODE_VIRTUAL_MULTITASK | number | 是 | å¦ | 虚拟多任务键 | -| KEYCODE_SLEEP | number | 是 | å¦ | ç¡çœ é”® | -| KEYCODE_ZENKAKU_HANKAKU | number | 是 | å¦ | 日文全宽/åŠå®½é”® | -| KEYCODE_102ND | number | 是 | å¦ | 102nd按键 | -| KEYCODE_RO | number | 是 | å¦ | 日文Roé”® | -| KEYCODE_KATAKANA | number | 是 | å¦ | 日文片å‡åé”® | -| KEYCODE_HIRAGANA | number | 是 | å¦ | 日文平å‡åé”® | -| KEYCODE_HENKAN | number | 是 | å¦ | 日文转æ¢é”® | -| KEYCODE_KATAKANA_HIRAGANA | number | 是 | å¦ | æ—¥è¯ç‰‡å‡å/å¹³å‡åé”® | -| KEYCODE_MUHENKAN | number | 是 | å¦ | 日文éžè½¬æ¢é”® | -| KEYCODE_LINEFEED | number | 是 | å¦ | æ¢è¡Œé”® | -| KEYCODE_MACRO | number | 是 | å¦ | å®é”® | -| KEYCODE_NUMPAD_PLUSMINUS | number | 是 | å¦ | æ•°å—é”®ç›˜ä¸Šçš„åŠ å·/å‡å·é”® | -| KEYCODE_SCALE | number | 是 | å¦ | 扩展键 | -| KEYCODE_HANGUEL | number | 是 | å¦ | 日文韩è¯é”® | -| KEYCODE_HANJA | number | 是 | å¦ | 日文汉è¯é”® | -| KEYCODE_YEN | number | 是 | å¦ | 日元键 | -| KEYCODE_STOP | number | 是 | å¦ | åœæ¢é”® | -| KEYCODE_AGAIN | number | 是 | å¦ | é‡å¤é”® | -| KEYCODE_PROPS | number | 是 | å¦ | é“å…·é”® | -| KEYCODE_UNDO | number | 是 | å¦ | 撤消键 | -| KEYCODE_COPY | number | 是 | å¦ | å¤åˆ¶é”® | -| KEYCODE_OPEN | number | 是 | å¦ | 打开键 | -| KEYCODE_PASTE | number | 是 | å¦ | 粘贴键 | -| KEYCODE_FIND | number | 是 | å¦ | 查找键 | -| KEYCODE_CUT | number | 是 | å¦ | 剪切键 | -| KEYCODE_HELP | number | 是 | å¦ | 帮助键 | -| KEYCODE_CALC | number | 是 | å¦ | 计算器特殊功能键,用于å¯åŠ¨è®¡ç®—å™¨åº”ç”¨ç¨‹åº | -| KEYCODE_FILE | number | 是 | å¦ | 文件按键 | -| KEYCODE_BOOKMARKS | number | 是 | å¦ | 书ç¾é”® | -| KEYCODE_NEXT | number | 是 | å¦ | 下一个按键 | -| KEYCODE_PLAYPAUSE | number | 是 | å¦ | æ’放/æš‚åœé”® | -| KEYCODE_PREVIOUS | number | 是 | å¦ | 上一个按键 | -| KEYCODE_STOPCD | number | 是 | å¦ | CDåœæ¢é”® | -| KEYCODE_CONFIG | number | 是 | å¦ | é…置键 | -| KEYCODE_REFRESH | number | 是 | å¦ | 刷新键 | -| KEYCODE_EXIT | number | 是 | å¦ | 退出键 | -| KEYCODE_EDIT | number | 是 | å¦ | 编辑键 | -| KEYCODE_SCROLLUP | number | 是 | å¦ | å‘上滚动键 | -| KEYCODE_SCROLLDOWN | number | 是 | å¦ | å‘下滚动键 | -| KEYCODE_NEW | number | 是 | å¦ | 新建键 | -| KEYCODE_REDO | number | 是 | å¦ | æ¢å¤é”® | -| KEYCODE_CLOSE | number | 是 | å¦ | å…³é—é”® | -| KEYCODE_PLAY | number | 是 | å¦ | æ’放键 | -| KEYCODE_BASSBOOST | number | 是 | å¦ | 低音增强键 | -| KEYCODE_PRINT | number | 是 | å¦ | 打å°é”® | -| KEYCODE_CHAT | number | 是 | å¦ | èŠå¤©é”® | -| KEYCODE_FINANCE | number | 是 | å¦ | 金èžé”® | -| KEYCODE_CANCEL | number | 是 | å¦ | å–消键 | -| KEYCODE_KBDILLUM_TOGGLE | number | 是 | å¦ | 键盘ç¯å…‰åˆ‡æ¢é”® | -| KEYCODE_KBDILLUM_DOWN | number | 是 | å¦ | 键盘ç¯å…‰è°ƒäº®é”® | -| KEYCODE_KBDILLUM_UP | number | 是 | å¦ | 键盘ç¯å…‰è°ƒæš—é”® | -| KEYCODE_SEND | number | 是 | å¦ | å‘é€é”® | -| KEYCODE_REPLY | number | 是 | å¦ | ç”å¤é”® | -| KEYCODE_FORWARDMAIL | number | 是 | å¦ | 邮件转å‘é”® | -| KEYCODE_SAVE | number | 是 | å¦ | ä¿å˜é”® | -| KEYCODE_DOCUMENTS | number | 是 | å¦ | 文件键 | -| KEYCODE_VIDEO_NEXT | number | 是 | å¦ | 下一个视频键 | -| KEYCODE_VIDEO_PREV | number | 是 | å¦ | 上一个视频键 | -| KEYCODE_BRIGHTNESS_CYCLE | number | 是 | å¦ | 背光æ¸å˜é”® | -| KEYCODE_BRIGHTNESS_ZERO | number | 是 | å¦ | 亮度调节为0é”® | -| KEYCODE_DISPLAY_OFF | number | 是 | å¦ | 显示关é—é”® | -| KEYCODE_BTN_MISC | number | 是 | å¦ | 游æˆæ‰‹æŸ„上的å„ç§æŒ‰é”® | -| KEYCODE_GOTO | number | 是 | å¦ | 进入键 | -| KEYCODE_INFO | number | 是 | å¦ | ä¿¡æ¯æŸ¥çœ‹é”® | -| KEYCODE_PROGRAM | number | 是 | å¦ | 程åºé”® | -| KEYCODE_PVR | number | 是 | å¦ | 个人录åƒæœº(PVR)é”® | -| KEYCODE_SUBTITLE | number | 是 | å¦ | å—幕键 | -| KEYCODE_FULL_SCREEN | number | 是 | å¦ | å…¨å±é”® | -| KEYCODE_KEYBOARD | number | 是 | å¦ | 键盘 | -| KEYCODE_ASPECT_RATIO | number | 是 | å¦ | å±å¹•çºµæ¨ªæ¯”调节键 | -| KEYCODE_PC | number | 是 | å¦ | 端å£æŽ§åˆ¶é”® | -| KEYCODE_TV | number | 是 | å¦ | TVé”® | -| KEYCODE_TV2 | number | 是 | å¦ | TVé”®2 | -| KEYCODE_VCR | number | 是 | å¦ | 录åƒæœºå¼€å¯é”® | -| KEYCODE_VCR2 | number | 是 | å¦ | 录åƒæœºå¼€å¯é”®2 | -| KEYCODE_SAT | number | 是 | å¦ | SIMå¡åº”用工具包(SAT)键 | -| KEYCODE_CD | number | 是 | å¦ | CDé”® | -| KEYCODE_TAPE | number | 是 | å¦ | ç£å¸¦é”® | -| KEYCODE_TUNER | number | 是 | å¦ | è°ƒè°å™¨é”® | -| KEYCODE_PLAYER | number | 是 | å¦ | æ’放器键 | -| KEYCODE_DVD | number | 是 | å¦ | DVDé”® | -| KEYCODE_AUDIO | number | 是 | å¦ | 音频键 | -| KEYCODE_VIDEO | number | 是 | å¦ | 视频键 | -| KEYCODE_MEMO | number | 是 | å¦ | 备忘录键 | -| KEYCODE_CALENDAR | number | 是 | å¦ | 日历键 | -| KEYCODE_RED | number | 是 | å¦ | 红色指示器 | -| KEYCODE_GREEN | number | 是 | å¦ | 绿色指示器 | -| KEYCODE_YELLOW | number | 是 | å¦ | 黄色指示器 | -| KEYCODE_BLUE | number | 是 | å¦ | è“色指示器 | -| KEYCODE_CHANNELUP | number | 是 | å¦ | 频é“å‘上键 | -| KEYCODE_CHANNELDOWN | number | 是 | å¦ | 频é“å‘下键 | -| KEYCODE_LAST | number | 是 | å¦ | 末尾键 | -| KEYCODE_RESTART | number | 是 | å¦ | é‡å¯é”® | -| KEYCODE_SLOW | number | 是 | å¦ | 慢速键 | -| KEYCODE_SHUFFLE | number | 是 | å¦ | éšæœºæ’放键 | -| KEYCODE_VIDEOPHONE | number | 是 | å¦ | å¯è§†ç”µè¯é”® | -| KEYCODE_GAMES | number | 是 | å¦ | 游æˆé”® | -| KEYCODE_ZOOMIN | number | 是 | å¦ | 放大键 | -| KEYCODE_ZOOMOUT | number | 是 | å¦ | 缩å°é”® | -| KEYCODE_ZOOMRESET | number | 是 | å¦ | 缩放é‡ç½®é”® | -| KEYCODE_WORDPROCESSOR | number | 是 | å¦ | æ–‡å—处ç†é”® | -| KEYCODE_EDITOR | number | 是 | å¦ | 编辑器键 | -| KEYCODE_SPREADSHEET | number | 是 | å¦ | 电åè¡¨æ ¼é”® | -| KEYCODE_GRAPHICSEDITOR | number | 是 | å¦ | 图形编辑器键 | -| KEYCODE_PRESENTATION | number | 是 | å¦ | 演示文稿键 | -| KEYCODE_DATABASE | number | 是 | å¦ | æ•°æ®åº“é”®æ ‡ | -| KEYCODE_NEWS | number | 是 | å¦ | 新闻键 | -| KEYCODE_VOICEMAIL | number | 是 | å¦ | è¯éŸ³ä¿¡ç®± | -| KEYCODE_ADDRESSBOOK | number | 是 | å¦ | 通讯簿 | -| KEYCODE_MESSENGER | number | 是 | å¦ | 通信键 | -| KEYCODE_BRIGHTNESS_TOGGLE | number | 是 | å¦ | 亮度切æ¢é”® | -| KEYCODE_SPELLCHECK | number | 是 | å¦ | AL拼写检查 | -| KEYCODE_COFFEE | number | 是 | å¦ | 终端é”/å±å¹•ä¿æŠ¤ç¨‹åº | -| KEYCODE_MEDIA_REPEAT | number | 是 | å¦ | 媒体循环键 | -| KEYCODE_IMAGES | number | 是 | å¦ | 图åƒé”® | -| KEYCODE_BUTTONCONFIG | number | 是 | å¦ | 按键é…置键 | -| KEYCODE_TASKMANAGER | number | 是 | å¦ | 任务管ç†å™¨ | -| KEYCODE_JOURNAL | number | 是 | å¦ | 日志按键 | -| KEYCODE_CONTROLPANEL | number | 是 | å¦ | 控制é¢æ¿é”® | -| KEYCODE_APPSELECT | number | 是 | å¦ | 应用程åºé€‰æ‹©é”® | -| KEYCODE_SCREENSAVER | number | 是 | å¦ | å±å¹•ä¿æŠ¤ç¨‹åºé”® | -| KEYCODE_ASSISTANT | number | 是 | å¦ | 辅助键 | -| KEYCODE_KBD_LAYOUT_NEXT | number | 是 | å¦ | 下一个键盘布局键 | -| KEYCODE_BRIGHTNESS_MIN | number | 是 | å¦ | 最å°äº®åº¦é”® | -| KEYCODE_BRIGHTNESS_MAX | number | 是 | å¦ | 最大亮度键 | -| KEYCODE_KBDINPUTASSIST_PREV | number | 是 | å¦ | 键盘输入Assist_Previous | -| KEYCODE_KBDINPUTASSIST_NEXT | number | 是 | å¦ | 键盘输入Assist_Next | -| KEYCODE_KBDINPUTASSIST_PREVGROUP | number | 是 | å¦ | 键盘输入Assist_Previous | -| KEYCODE_KBDINPUTASSIST_NEXTGROUP | number | 是 | å¦ | 键盘输入Assist_Next | -| KEYCODE_KBDINPUTASSIST_ACCEPT | number | 是 | å¦ | 键盘输入Assist_Accept | -| KEYCODE_KBDINPUTASSIST_CANCEL | number | 是 | å¦ | 键盘输入Assist_Cancel | -| KEYCODE_FRONT | number | 是 | å¦ | 挡风玻璃除雾器开关 | -| KEYCODE_SETUP | number | 是 | å¦ | 设置键 | -| KEYCODE_WAKEUP | number | 是 | å¦ | 唤醒键 | -| KEYCODE_SENDFILE | number | 是 | å¦ | å‘é€æ–‡ä»¶æŒ‰é”® | -| KEYCODE_DELETEFILE | number | 是 | å¦ | åˆ é™¤æ–‡ä»¶æŒ‰é”® | -| KEYCODE_XFER | number | 是 | å¦ | æ–‡ä»¶ä¼ è¾“(XFER)按键 | -| KEYCODE_PROG1 | number | 是 | å¦ | 程åºé”®1 | -| KEYCODE_PROG2 | number | 是 | å¦ | 程åºé”®2 | -| KEYCODE_MSDOS | number | 是 | å¦ | MS-DOS键(微软ç£ç›˜æ“作系统 | -| KEYCODE_SCREENLOCK | number | 是 | å¦ | å±å¹•é”定键 | -| KEYCODE_DIRECTION_ROTATE_DISPLAY | number | 是 | å¦ | æ–¹å‘旋转显示键 | -| KEYCODE_CYCLEWINDOWS | number | 是 | å¦ | Windows循环键 | -| KEYCODE_COMPUTER | number | 是 | å¦ | 计算机按键 | -| KEYCODE_EJECTCLOSECD | number | 是 | å¦ | 弹出CDé”® | -| KEYCODE_ISO | number | 是 | å¦ | ISOé”® | -| KEYCODE_MOVE | number | 是 | å¦ | 移动键 | -| KEYCODE_F13 | number | 是 | å¦ | 按键'F13' | -| KEYCODE_F14 | number | 是 | å¦ | 按键'F14' | -| KEYCODE_F15 | number | 是 | å¦ | 按键'F15' | -| KEYCODE_F16 | number | 是 | å¦ | 按键'F16' | -| KEYCODE_F17 | number | 是 | å¦ | 按键'F17' | -| KEYCODE_F18 | number | 是 | å¦ | 按键'F18' | -| KEYCODE_F19 | number | 是 | å¦ | 按键'F19' | -| KEYCODE_F20 | number | 是 | å¦ | 按键'F20' | -| KEYCODE_F21 | number | 是 | å¦ | 按键'F21' | -| KEYCODE_F22 | number | 是 | å¦ | 按键'F22' | -| KEYCODE_F23 | number | 是 | å¦ | 按键'F23' | -| KEYCODE_F24 | number | 是 | å¦ | 按键'F24' | -| KEYCODE_PROG3 | number | 是 | å¦ | 程åºé”®3 | -| KEYCODE_PROG4 | number | 是 | å¦ | 程åºé”®4 | -| KEYCODE_DASHBOARD | number | 是 | å¦ | ä»ªè¡¨æ¿ | -| KEYCODE_SUSPEND | number | 是 | å¦ | 挂起键 | -| KEYCODE_HP | number | 是 | å¦ | 高阶路径键 | -| KEYCODE_SOUND | number | 是 | å¦ | 音é‡é”® | -| KEYCODE_QUESTION | number | 是 | å¦ | 疑问按键 | -| KEYCODE_CONNECT | number | 是 | å¦ | 连接键 | -| KEYCODE_SPORT | number | 是 | å¦ | è¿åŠ¨æŒ‰é”® | -| KEYCODE_SHOP | number | 是 | å¦ | 商城键 | -| KEYCODE_ALTERASE | number | 是 | å¦ | 交替键 | -| KEYCODE_SWITCHVIDEOMODE | number | 是 | å¦ | 在å¯ç”¨è§†é¢‘之间循环输出(监视器/LCD/TV输出/ç‰ï¼‰| -| KEYCODE_BATTERY | number | 是 | å¦ | ç”µæ± æŒ‰é”® | -| KEYCODE_BLUETOOTH | number | 是 | å¦ | è“牙按键 | -| KEYCODE_WLAN | number | 是 | å¦ | æ— çº¿å±€åŸŸç½‘ | -| KEYCODE_UWB | number | 是 | å¦ | 超宽带(UWB)| -| KEYCODE_WWAN_WIMAX | number | 是 | å¦ | WWAN WiMAX按键 | -| KEYCODE_RFKILL | number | 是 | å¦ | 控制所有收音机的键 | -| KEYCODE_CHANNEL | number | 是 | å¦ | å‘上频é“é”® | -| KEYCODE_BTN_0 | number | 是 | å¦ | 按键0 | -| KEYCODE_BTN_1 | number | 是 | å¦ | 按键1 | -| KEYCODE_BTN_2 | number | 是 | å¦ | 按键2 | -| KEYCODE_BTN_3 | number | 是 | å¦ | 按键3 | -| KEYCODE_BTN_4 | number | 是 | å¦ | 按键4 | -| KEYCODE_BTN_5 | number | 是 | å¦ | 按键5 | -| KEYCODE_BTN_6 | number | 是 | å¦ | 按键6 | -| KEYCODE_BTN_7 | number | 是 | å¦ | 按键7 | -| KEYCODE_BTN_8 | number | 是 | å¦ | 按键8 | -| KEYCODE_BTN_9 | number | 是 | å¦ | 按键9 | \ No newline at end of file +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| -------------------------------- | ------ | ---- | ---- | --------------------------- | +| KEYCODE_FN | number | 是 | å¦ | 功能(Fn)键 | +| KEYCODE_UNKNOWN | number | 是 | å¦ | 未知按键 | +| KEYCODE_HOME | number | 是 | å¦ | 按键Home | +| KEYCODE_BACK | number | 是 | å¦ | 返回键 | +| KEYCODE_MEDIA_PLAY_PAUSE | number | 是 | å¦ | 多媒体键 æ’放/æš‚åœ | +| KEYCODE_MEDIA_STOP | number | 是 | å¦ | 多媒体键 åœæ¢ | +| KEYCODE_MEDIA_NEXT | number | 是 | å¦ | 多媒体键 下一首 | +| KEYCODE_MEDIA_PREVIOUS | number | 是 | å¦ | 多媒体键 上一首 | +| KEYCODE_MEDIA_REWIND | number | 是 | å¦ | 多媒体键 快退 | +| KEYCODE_MEDIA_FAST_FORWARD | number | 是 | å¦ | 多媒体键 å¿«è¿› | +| KEYCODE_VOLUME_UP | number | 是 | å¦ | 音é‡å¢žåŠ é”® | +| KEYCODE_VOLUME_DOWN | number | 是 | å¦ | 音é‡å‡å°é”® | +| KEYCODE_POWER | number | 是 | å¦ | 电æºé”® | +| KEYCODE_CAMERA | number | 是 | å¦ | æ‹ç…§é”® | +| KEYCODE_VOLUME_MUTE | number | 是 | å¦ | 扬声器é™éŸ³é”® | +| KEYCODE_MUTE | number | 是 | å¦ | è¯ç’é™éŸ³é”® | +| KEYCODE_BRIGHTNESS_UP | number | 是 | å¦ | 亮度调节按键 调亮 | +| KEYCODE_BRIGHTNESS_DOWN | number | 是 | å¦ | 亮度调节按键 调暗 | +| KEYCODE_0 | number | 是 | å¦ | 按键'0' | +| KEYCODE_1 | number | 是 | å¦ | 按键'1' | +| KEYCODE_2 | number | 是 | å¦ | 按键'2' | +| KEYCODE_3 | number | 是 | å¦ | 按键'3' | +| KEYCODE_4 | number | 是 | å¦ | 按键'4' | +| KEYCODE_5 | number | 是 | å¦ | 按键'5' | +| KEYCODE_6 | number | 是 | å¦ | 按键'6' | +| KEYCODE_7 | number | 是 | å¦ | 按键'7' | +| KEYCODE_8 | number | 是 | å¦ | 按键'8' | +| KEYCODE_9 | number | 是 | å¦ | 按键'9' | +| KEYCODE_STAR | number | 是 | å¦ | 按键'*' | +| KEYCODE_POUND | number | 是 | å¦ | 按键'#' | +| KEYCODE_DPAD_UP | number | 是 | å¦ | 导航键 å‘上 | +| KEYCODE_DPAD_DOWN | number | 是 | å¦ | 导航键 å‘下 | +| KEYCODE_DPAD_LEFT | number | 是 | å¦ | 导航键 å‘å·¦ | +| KEYCODE_DPAD_RIGHT | number | 是 | å¦ | 导航键 å‘å³ | +| KEYCODE_DPAD_CENTER | number | 是 | å¦ | 导航键 确定键 | +| KEYCODE_A | number | 是 | å¦ | 按键'A' | +| KEYCODE_B | number | 是 | å¦ | 按键'B' | +| KEYCODE_C | number | 是 | å¦ | 按键'C' | +| KEYCODE_D | number | 是 | å¦ | 按键'D' | +| KEYCODE_E | number | 是 | å¦ | 按键'E' | +| KEYCODE_F | number | 是 | å¦ | 按键'F' | +| KEYCODE_G | number | 是 | å¦ | 按键'G' | +| KEYCODE_H | number | 是 | å¦ | 按键'H' | +| KEYCODE_I | number | 是 | å¦ | 按键'I' | +| KEYCODE_J | number | 是 | å¦ | 按键'J' | +| KEYCODE_K | number | 是 | å¦ | 按键'K' | +| KEYCODE_L | number | 是 | å¦ | 按键'L' | +| KEYCODE_M | number | 是 | å¦ | 按键'M' | +| KEYCODE_N | number | 是 | å¦ | 按键'N' | +| KEYCODE_O | number | 是 | å¦ | 按键'O' | +| KEYCODE_P | number | 是 | å¦ | 按键'P' | +| KEYCODE_Q | number | 是 | å¦ | 按键'Q' | +| KEYCODE_R | number | 是 | å¦ | 按键'R' | +| KEYCODE_S | number | 是 | å¦ | 按键'S' | +| KEYCODE_T | number | 是 | å¦ | 按键'T' | +| KEYCODE_U | number | 是 | å¦ | 按键'U' | +| KEYCODE_V | number | 是 | å¦ | 按键'V' | +| KEYCODE_W | number | 是 | å¦ | 按键'W' | +| KEYCODE_X | number | 是 | å¦ | 按键'X' | +| KEYCODE_Y | number | 是 | å¦ | 按键'Y' | +| KEYCODE_Z | number | 是 | å¦ | 按键'Z' | +| KEYCODE_COMMA | number | 是 | å¦ | 按键',' | +| KEYCODE_PERIOD | number | 是 | å¦ | 按键'.' | +| KEYCODE_ALT_LEFT | number | 是 | å¦ | Alt+Left | +| KEYCODE_ALT_RIGHT | number | 是 | å¦ | Alt+Right | +| KEYCODE_SHIFT_LEFT | number | 是 | å¦ | Shift+Left | +| KEYCODE_SHIFT_RIGHT | number | 是 | å¦ | Shift+Right | +| KEYCODE_TAB | number | 是 | å¦ | Tabé”® | +| KEYCODE_SPACE | number | 是 | å¦ | ç©ºæ ¼é”® | +| KEYCODE_SYM | number | 是 | å¦ | 符å·ä¿®æ”¹å™¨æŒ‰é”® | +| KEYCODE_EXPLORER | number | 是 | å¦ | æµè§ˆå™¨åŠŸèƒ½é”®ï¼Œæ¤é”®ç”¨äºŽå¯åŠ¨æµè§ˆå™¨åº”用程åºã€‚ | +| KEYCODE_ENVELOPE | number | 是 | å¦ | 电å邮件功能键,æ¤é”®ç”¨äºŽå¯åŠ¨ç”µå邮件应用程åºã€‚ | +| KEYCODE_ENTER | number | 是 | å¦ | 回车键 | +| KEYCODE_DEL | number | 是 | å¦ | é€€æ ¼é”® | +| KEYCODE_GRAVE | number | 是 | å¦ | 按键'`' | +| KEYCODE_MINUS | number | 是 | å¦ | 按键'-' | +| KEYCODE_EQUALS | number | 是 | å¦ | 按键'=' | +| KEYCODE_LEFT_BRACKET | number | 是 | å¦ | 按键'[' | +| KEYCODE_RIGHT_BRACKET | number | 是 | å¦ | 按键']' | +| KEYCODE_BACKSLASH | number | 是 | å¦ | 按键'\' | +| KEYCODE_SEMICOLON | number | 是 | å¦ | 按键';' | +| KEYCODE_APOSTROPHE | number | 是 | å¦ | 按键''' (å•å¼•å·) | +| KEYCODE_SLASH | number | 是 | å¦ | 按键'/' | +| KEYCODE_AT | number | 是 | å¦ | 按键'@' | +| KEYCODE_PLUS | number | 是 | å¦ | 按键'+' | +| KEYCODE_MENU | number | 是 | å¦ | èœå•é”® | +| KEYCODE_PAGE_UP | number | 是 | å¦ | å‘上翻页键 | +| KEYCODE_PAGE_DOWN | number | 是 | å¦ | å‘下翻页键 | +| KEYCODE_ESCAPE | number | 是 | å¦ | ESCé”® | +| KEYCODE_FORWARD_DEL | number | 是 | å¦ | åˆ é™¤é”® | +| KEYCODE_CTRL_LEFT | number | 是 | å¦ | Control+Left | +| KEYCODE_CTRL_RIGHT | number | 是 | å¦ | Control+Right | +| KEYCODE_CAPS_LOCK | number | 是 | å¦ | 大写é”定键 | +| KEYCODE_SCROLL_LOCK | number | 是 | å¦ | 滚动é”定键 | +| KEYCODE_META_LEFT | number | 是 | å¦ | 左元修改器键 | +| KEYCODE_META_RIGHT | number | 是 | å¦ | å³å…ƒä¿®æ”¹å™¨é”® | +| KEYCODE_FUNCTION | number | 是 | å¦ | 函数修改器键 | +| KEYCODE_SYSRQ | number | 是 | å¦ | 系统请求/打å°å±å¹•é”® | +| KEYCODE_BREAK | number | 是 | å¦ | Break/Pauseé”® | +| KEYCODE_MOVE_HOME | number | 是 | å¦ | å…‰æ ‡ç§»åŠ¨åˆ°å¼€å§‹é”® | +| KEYCODE_MOVE_END | number | 是 | å¦ | å…‰æ ‡ç§»åŠ¨åˆ°æœ«å°¾é”® | +| KEYCODE_INSERT | number | 是 | å¦ | æ’入键 | +| KEYCODE_FORWARD | number | 是 | å¦ | åˆ é™¤é”® | +| KEYCODE_MEDIA_PLAY | number | 是 | å¦ | 多媒体键 æ’放 | +| KEYCODE_MEDIA_PAUSE | number | 是 | å¦ | 多媒体键 æš‚åœ | +| KEYCODE_MEDIA_CLOSE | number | 是 | å¦ | 多媒体键 å…³é— | +| KEYCODE_MEDIA_EJECT | number | 是 | å¦ | 多媒体键 弹出 | +| KEYCODE_MEDIA_RECORD | number | 是 | å¦ | 多媒体键 录音 | +| KEYCODE_F1 | number | 是 | å¦ | 按键'F1' | +| KEYCODE_F2 | number | 是 | å¦ | 按键'F2' | +| KEYCODE_F3 | number | 是 | å¦ | 按键'F3' | +| KEYCODE_F4 | number | 是 | å¦ | 按键'F4' | +| KEYCODE_F5 | number | 是 | å¦ | 按键'F5' | +| KEYCODE_F6 | number | 是 | å¦ | 按键'F6' | +| KEYCODE_F7 | number | 是 | å¦ | 按键'F7' | +| KEYCODE_F8 | number | 是 | å¦ | 按键'F8' | +| KEYCODE_F9 | number | 是 | å¦ | 按键'F9' | +| KEYCODE_F10 | number | 是 | å¦ | 按键'F10' | +| KEYCODE_F11 | number | 是 | å¦ | 按键'F11' | +| KEYCODE_F12 | number | 是 | å¦ | 按键'F12' | +| KEYCODE_NUM_LOCK | number | 是 | å¦ | å°é”®ç›˜é” | +| KEYCODE_NUMPAD_0 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'0' | +| KEYCODE_NUMPAD_1 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'1' | +| KEYCODE_NUMPAD_2 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'2' | +| KEYCODE_NUMPAD_3 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'3' | +| KEYCODE_NUMPAD_4 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'4' | +| KEYCODE_NUMPAD_5 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'5' | +| KEYCODE_NUMPAD_6 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'6' | +| KEYCODE_NUMPAD_7 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'7' | +| KEYCODE_NUMPAD_8 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'8' | +| KEYCODE_NUMPAD_9 | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'9' | +| KEYCODE_NUMPAD_DIVIDE | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'/' | +| KEYCODE_NUMPAD_MULTIPLY | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'*' | +| KEYCODE_NUMPAD_SUBTRACT | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'-' | +| KEYCODE_NUMPAD_ADD | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'+' | +| KEYCODE_NUMPAD_DOT | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'.' | +| KEYCODE_NUMPAD_COMMA | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®',' | +| KEYCODE_NUMPAD_ENTER | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®å›žè½¦ | +| KEYCODE_NUMPAD_EQUALS | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'=' | +| KEYCODE_NUMPAD_LEFT_PAREN | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®'(' | +| KEYCODE_NUMPAD_RIGHT_PAREN | number | 是 | å¦ | å°é”®ç›˜æŒ‰é”®')' | +| KEYCODE_VIRTUAL_MULTITASK | number | 是 | å¦ | 虚拟多任务键 | +| KEYCODE_SLEEP | number | 是 | å¦ | ç¡çœ é”® | +| KEYCODE_ZENKAKU_HANKAKU | number | 是 | å¦ | 日文全宽/åŠå®½é”® | +| KEYCODE_102ND | number | 是 | å¦ | 102nd按键 | +| KEYCODE_RO | number | 是 | å¦ | 日文Roé”® | +| KEYCODE_KATAKANA | number | 是 | å¦ | 日文片å‡åé”® | +| KEYCODE_HIRAGANA | number | 是 | å¦ | 日文平å‡åé”® | +| KEYCODE_HENKAN | number | 是 | å¦ | 日文转æ¢é”® | +| KEYCODE_KATAKANA_HIRAGANA | number | 是 | å¦ | æ—¥è¯ç‰‡å‡å/å¹³å‡åé”® | +| KEYCODE_MUHENKAN | number | 是 | å¦ | 日文éžè½¬æ¢é”® | +| KEYCODE_LINEFEED | number | 是 | å¦ | æ¢è¡Œé”® | +| KEYCODE_MACRO | number | 是 | å¦ | å®é”® | +| KEYCODE_NUMPAD_PLUSMINUS | number | 是 | å¦ | æ•°å—é”®ç›˜ä¸Šçš„åŠ å·/å‡å·é”® | +| KEYCODE_SCALE | number | 是 | å¦ | 扩展键 | +| KEYCODE_HANGUEL | number | 是 | å¦ | 日文韩è¯é”® | +| KEYCODE_HANJA | number | 是 | å¦ | 日文汉è¯é”® | +| KEYCODE_YEN | number | 是 | å¦ | 日元键 | +| KEYCODE_STOP | number | 是 | å¦ | åœæ¢é”® | +| KEYCODE_AGAIN | number | 是 | å¦ | é‡å¤é”® | +| KEYCODE_PROPS | number | 是 | å¦ | é“å…·é”® | +| KEYCODE_UNDO | number | 是 | å¦ | 撤消键 | +| KEYCODE_COPY | number | 是 | å¦ | å¤åˆ¶é”® | +| KEYCODE_OPEN | number | 是 | å¦ | 打开键 | +| KEYCODE_PASTE | number | 是 | å¦ | 粘贴键 | +| KEYCODE_FIND | number | 是 | å¦ | 查找键 | +| KEYCODE_CUT | number | 是 | å¦ | 剪切键 | +| KEYCODE_HELP | number | 是 | å¦ | 帮助键 | +| KEYCODE_CALC | number | 是 | å¦ | 计算器特殊功能键,用于å¯åŠ¨è®¡ç®—å™¨åº”ç”¨ç¨‹åº | +| KEYCODE_FILE | number | 是 | å¦ | 文件按键 | +| KEYCODE_BOOKMARKS | number | 是 | å¦ | 书ç¾é”® | +| KEYCODE_NEXT | number | 是 | å¦ | 下一个按键 | +| KEYCODE_PLAYPAUSE | number | 是 | å¦ | æ’放/æš‚åœé”® | +| KEYCODE_PREVIOUS | number | 是 | å¦ | 上一个按键 | +| KEYCODE_STOPCD | number | 是 | å¦ | CDåœæ¢é”® | +| KEYCODE_CONFIG | number | 是 | å¦ | é…置键 | +| KEYCODE_REFRESH | number | 是 | å¦ | 刷新键 | +| KEYCODE_EXIT | number | 是 | å¦ | 退出键 | +| KEYCODE_EDIT | number | 是 | å¦ | 编辑键 | +| KEYCODE_SCROLLUP | number | 是 | å¦ | å‘上滚动键 | +| KEYCODE_SCROLLDOWN | number | 是 | å¦ | å‘下滚动键 | +| KEYCODE_NEW | number | 是 | å¦ | 新建键 | +| KEYCODE_REDO | number | 是 | å¦ | æ¢å¤é”® | +| KEYCODE_CLOSE | number | 是 | å¦ | å…³é—é”® | +| KEYCODE_PLAY | number | 是 | å¦ | æ’放键 | +| KEYCODE_BASSBOOST | number | 是 | å¦ | 低音增强键 | +| KEYCODE_PRINT | number | 是 | å¦ | 打å°é”® | +| KEYCODE_CHAT | number | 是 | å¦ | èŠå¤©é”® | +| KEYCODE_FINANCE | number | 是 | å¦ | 金èžé”® | +| KEYCODE_CANCEL | number | 是 | å¦ | å–消键 | +| KEYCODE_KBDILLUM_TOGGLE | number | 是 | å¦ | 键盘ç¯å…‰åˆ‡æ¢é”® | +| KEYCODE_KBDILLUM_DOWN | number | 是 | å¦ | 键盘ç¯å…‰è°ƒäº®é”® | +| KEYCODE_KBDILLUM_UP | number | 是 | å¦ | 键盘ç¯å…‰è°ƒæš—é”® | +| KEYCODE_SEND | number | 是 | å¦ | å‘é€é”® | +| KEYCODE_REPLY | number | 是 | å¦ | ç”å¤é”® | +| KEYCODE_FORWARDMAIL | number | 是 | å¦ | 邮件转å‘é”® | +| KEYCODE_SAVE | number | 是 | å¦ | ä¿å˜é”® | +| KEYCODE_DOCUMENTS | number | 是 | å¦ | 文件键 | +| KEYCODE_VIDEO_NEXT | number | 是 | å¦ | 下一个视频键 | +| KEYCODE_VIDEO_PREV | number | 是 | å¦ | 上一个视频键 | +| KEYCODE_BRIGHTNESS_CYCLE | number | 是 | å¦ | 背光æ¸å˜é”® | +| KEYCODE_BRIGHTNESS_ZERO | number | 是 | å¦ | 亮度调节为0é”® | +| KEYCODE_DISPLAY_OFF | number | 是 | å¦ | 显示关é—é”® | +| KEYCODE_BTN_MISC | number | 是 | å¦ | 游æˆæ‰‹æŸ„上的å„ç§æŒ‰é”® | +| KEYCODE_GOTO | number | 是 | å¦ | 进入键 | +| KEYCODE_INFO | number | 是 | å¦ | ä¿¡æ¯æŸ¥çœ‹é”® | +| KEYCODE_PROGRAM | number | 是 | å¦ | 程åºé”® | +| KEYCODE_PVR | number | 是 | å¦ | 个人录åƒæœº(PVR)é”® | +| KEYCODE_SUBTITLE | number | 是 | å¦ | å—幕键 | +| KEYCODE_FULL_SCREEN | number | 是 | å¦ | å…¨å±é”® | +| KEYCODE_KEYBOARD | number | 是 | å¦ | 键盘 | +| KEYCODE_ASPECT_RATIO | number | 是 | å¦ | å±å¹•çºµæ¨ªæ¯”调节键 | +| KEYCODE_PC | number | 是 | å¦ | 端å£æŽ§åˆ¶é”® | +| KEYCODE_TV | number | 是 | å¦ | TVé”® | +| KEYCODE_TV2 | number | 是 | å¦ | TVé”®2 | +| KEYCODE_VCR | number | 是 | å¦ | 录åƒæœºå¼€å¯é”® | +| KEYCODE_VCR2 | number | 是 | å¦ | 录åƒæœºå¼€å¯é”®2 | +| KEYCODE_SAT | number | 是 | å¦ | SIMå¡åº”用工具包(SAT)键 | +| KEYCODE_CD | number | 是 | å¦ | CDé”® | +| KEYCODE_TAPE | number | 是 | å¦ | ç£å¸¦é”® | +| KEYCODE_TUNER | number | 是 | å¦ | è°ƒè°å™¨é”® | +| KEYCODE_PLAYER | number | 是 | å¦ | æ’放器键 | +| KEYCODE_DVD | number | 是 | å¦ | DVDé”® | +| KEYCODE_AUDIO | number | 是 | å¦ | 音频键 | +| KEYCODE_VIDEO | number | 是 | å¦ | 视频键 | +| KEYCODE_MEMO | number | 是 | å¦ | 备忘录键 | +| KEYCODE_CALENDAR | number | 是 | å¦ | 日历键 | +| KEYCODE_RED | number | 是 | å¦ | 红色指示器 | +| KEYCODE_GREEN | number | 是 | å¦ | 绿色指示器 | +| KEYCODE_YELLOW | number | 是 | å¦ | 黄色指示器 | +| KEYCODE_BLUE | number | 是 | å¦ | è“色指示器 | +| KEYCODE_CHANNELUP | number | 是 | å¦ | 频é“å‘上键 | +| KEYCODE_CHANNELDOWN | number | 是 | å¦ | 频é“å‘下键 | +| KEYCODE_LAST | number | 是 | å¦ | 末尾键 | +| KEYCODE_RESTART | number | 是 | å¦ | é‡å¯é”® | +| KEYCODE_SLOW | number | 是 | å¦ | 慢速键 | +| KEYCODE_SHUFFLE | number | 是 | å¦ | éšæœºæ’放键 | +| KEYCODE_VIDEOPHONE | number | 是 | å¦ | å¯è§†ç”µè¯é”® | +| KEYCODE_GAMES | number | 是 | å¦ | 游æˆé”® | +| KEYCODE_ZOOMIN | number | 是 | å¦ | 放大键 | +| KEYCODE_ZOOMOUT | number | 是 | å¦ | 缩å°é”® | +| KEYCODE_ZOOMRESET | number | 是 | å¦ | 缩放é‡ç½®é”® | +| KEYCODE_WORDPROCESSOR | number | 是 | å¦ | æ–‡å—处ç†é”® | +| KEYCODE_EDITOR | number | 是 | å¦ | 编辑器键 | +| KEYCODE_SPREADSHEET | number | 是 | å¦ | 电åè¡¨æ ¼é”® | +| KEYCODE_GRAPHICSEDITOR | number | 是 | å¦ | 图形编辑器键 | +| KEYCODE_PRESENTATION | number | 是 | å¦ | 演示文稿键 | +| KEYCODE_DATABASE | number | 是 | å¦ | æ•°æ®åº“é”®æ ‡ | +| KEYCODE_NEWS | number | 是 | å¦ | 新闻键 | +| KEYCODE_VOICEMAIL | number | 是 | å¦ | è¯éŸ³ä¿¡ç®± | +| KEYCODE_ADDRESSBOOK | number | 是 | å¦ | 通讯簿 | +| KEYCODE_MESSENGER | number | 是 | å¦ | 通信键 | +| KEYCODE_BRIGHTNESS_TOGGLE | number | 是 | å¦ | 亮度切æ¢é”® | +| KEYCODE_SPELLCHECK | number | 是 | å¦ | AL拼写检查 | +| KEYCODE_COFFEE | number | 是 | å¦ | 终端é”/å±å¹•ä¿æŠ¤ç¨‹åº | +| KEYCODE_MEDIA_REPEAT | number | 是 | å¦ | 媒体循环键 | +| KEYCODE_IMAGES | number | 是 | å¦ | 图åƒé”® | +| KEYCODE_BUTTONCONFIG | number | 是 | å¦ | 按键é…置键 | +| KEYCODE_TASKMANAGER | number | 是 | å¦ | 任务管ç†å™¨ | +| KEYCODE_JOURNAL | number | 是 | å¦ | 日志按键 | +| KEYCODE_CONTROLPANEL | number | 是 | å¦ | 控制é¢æ¿é”® | +| KEYCODE_APPSELECT | number | 是 | å¦ | 应用程åºé€‰æ‹©é”® | +| KEYCODE_SCREENSAVER | number | 是 | å¦ | å±å¹•ä¿æŠ¤ç¨‹åºé”® | +| KEYCODE_ASSISTANT | number | 是 | å¦ | 辅助键 | +| KEYCODE_KBD_LAYOUT_NEXT | number | 是 | å¦ | 下一个键盘布局键 | +| KEYCODE_BRIGHTNESS_MIN | number | 是 | å¦ | 最å°äº®åº¦é”® | +| KEYCODE_BRIGHTNESS_MAX | number | 是 | å¦ | 最大亮度键 | +| KEYCODE_KBDINPUTASSIST_PREV | number | 是 | å¦ | 键盘输入Assist_Previous | +| KEYCODE_KBDINPUTASSIST_NEXT | number | 是 | å¦ | 键盘输入Assist_Next | +| KEYCODE_KBDINPUTASSIST_PREVGROUP | number | 是 | å¦ | 键盘输入Assist_Previous | +| KEYCODE_KBDINPUTASSIST_NEXTGROUP | number | 是 | å¦ | 键盘输入Assist_Next | +| KEYCODE_KBDINPUTASSIST_ACCEPT | number | 是 | å¦ | 键盘输入Assist_Accept | +| KEYCODE_KBDINPUTASSIST_CANCEL | number | 是 | å¦ | 键盘输入Assist_Cancel | +| KEYCODE_FRONT | number | 是 | å¦ | 挡风玻璃除雾器开关 | +| KEYCODE_SETUP | number | 是 | å¦ | 设置键 | +| KEYCODE_WAKEUP | number | 是 | å¦ | 唤醒键 | +| KEYCODE_SENDFILE | number | 是 | å¦ | å‘é€æ–‡ä»¶æŒ‰é”® | +| KEYCODE_DELETEFILE | number | 是 | å¦ | åˆ é™¤æ–‡ä»¶æŒ‰é”® | +| KEYCODE_XFER | number | 是 | å¦ | æ–‡ä»¶ä¼ è¾“(XFER)按键 | +| KEYCODE_PROG1 | number | 是 | å¦ | 程åºé”®1 | +| KEYCODE_PROG2 | number | 是 | å¦ | 程åºé”®2 | +| KEYCODE_MSDOS | number | 是 | å¦ | MS-DOS键(微软ç£ç›˜æ“作系统 | +| KEYCODE_SCREENLOCK | number | 是 | å¦ | å±å¹•é”定键 | +| KEYCODE_DIRECTION_ROTATE_DISPLAY | number | 是 | å¦ | æ–¹å‘旋转显示键 | +| KEYCODE_CYCLEWINDOWS | number | 是 | å¦ | Windows循环键 | +| KEYCODE_COMPUTER | number | 是 | å¦ | 按键 | +| KEYCODE_EJECTCLOSECD | number | 是 | å¦ | 弹出CDé”® | +| KEYCODE_ISO | number | 是 | å¦ | ISOé”® | +| KEYCODE_MOVE | number | 是 | å¦ | 移动键 | +| KEYCODE_F13 | number | 是 | å¦ | 按键'F13' | +| KEYCODE_F14 | number | 是 | å¦ | 按键'F14' | +| KEYCODE_F15 | number | 是 | å¦ | 按键'F15' | +| KEYCODE_F16 | number | 是 | å¦ | 按键'F16' | +| KEYCODE_F17 | number | 是 | å¦ | 按键'F17' | +| KEYCODE_F18 | number | 是 | å¦ | 按键'F18' | +| KEYCODE_F19 | number | 是 | å¦ | 按键'F19' | +| KEYCODE_F20 | number | 是 | å¦ | 按键'F20' | +| KEYCODE_F21 | number | 是 | å¦ | 按键'F21' | +| KEYCODE_F22 | number | 是 | å¦ | 按键'F22' | +| KEYCODE_F23 | number | 是 | å¦ | 按键'F23' | +| KEYCODE_F24 | number | 是 | å¦ | 按键'F24' | +| KEYCODE_PROG3 | number | 是 | å¦ | 程åºé”®3 | +| KEYCODE_PROG4 | number | 是 | å¦ | 程åºé”®4 | +| KEYCODE_DASHBOARD | number | 是 | å¦ | ä»ªè¡¨æ¿ | +| KEYCODE_SUSPEND | number | 是 | å¦ | 挂起键 | +| KEYCODE_HP | number | 是 | å¦ | 高阶路径键 | +| KEYCODE_SOUND | number | 是 | å¦ | 音é‡é”® | +| KEYCODE_QUESTION | number | 是 | å¦ | 疑问按键 | +| KEYCODE_CONNECT | number | 是 | å¦ | 连接键 | +| KEYCODE_SPORT | number | 是 | å¦ | è¿åŠ¨æŒ‰é”® | +| KEYCODE_SHOP | number | 是 | å¦ | 商城键 | +| KEYCODE_ALTERASE | number | 是 | å¦ | 交替键 | +| KEYCODE_SWITCHVIDEOMODE | number | 是 | å¦ | 在å¯ç”¨è§†é¢‘之间循环输出(监视器/LCD/TV输出/ç‰ï¼‰ | +| KEYCODE_BATTERY | number | 是 | å¦ | ç”µæ± æŒ‰é”® | +| KEYCODE_BLUETOOTH | number | 是 | å¦ | è“牙按键 | +| KEYCODE_WLAN | number | 是 | å¦ | æ— çº¿å±€åŸŸç½‘ | +| KEYCODE_UWB | number | 是 | å¦ | 超宽带(UWB) | +| KEYCODE_WWAN_WIMAX | number | 是 | å¦ | WWAN WiMAX按键 | +| KEYCODE_RFKILL | number | 是 | å¦ | 控制所有收音机的键 | +| KEYCODE_CHANNEL | number | 是 | å¦ | å‘上频é“é”® | +| KEYCODE_BTN_0 | number | 是 | å¦ | 按键0 | +| KEYCODE_BTN_1 | number | 是 | å¦ | 按键1 | +| KEYCODE_BTN_2 | number | 是 | å¦ | 按键2 | +| KEYCODE_BTN_3 | number | 是 | å¦ | 按键3 | +| KEYCODE_BTN_4 | number | 是 | å¦ | 按键4 | +| KEYCODE_BTN_5 | number | 是 | å¦ | 按键5 | +| KEYCODE_BTN_6 | number | 是 | å¦ | 按键6 | +| KEYCODE_BTN_7 | number | 是 | å¦ | 按键7 | +| KEYCODE_BTN_8 | number | 是 | å¦ | 按键8 | +| KEYCODE_BTN_9 | number | 是 | å¦ | 按键9 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md index a2d63e44c662562c36e169786426ab8f0cecce2e..2dcf562d995aa43115528998f8fb14e625ab884d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md @@ -2,7 +2,8 @@ KeyEvent模å—æ供了设备å¯ä»¥ä¸ŠæŠ¥çš„按键事件。 ->  **说明:** +> **说明:** +> > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -13,39 +14,39 @@ import {Action,Key,KeyEvent} from '@ohos.multimodalInput.keyEvent'; ## Action -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| CANCEL | number | 是 | å¦ | å–消 | -| DOWN | number | 是 | å¦ | 按下按钮 | -| UP | number | 是 | å¦ | 抬起按钮 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ------ | ------ | ---- | ---- | ---- | +| CANCEL | number | 是 | å¦ | å–消 | +| DOWN | number | 是 | å¦ | 按下按钮 | +| UP | number | 是 | å¦ | 抬起按钮 | ## Key -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| code | KeyCode | 是 | å¦ | 按键ç | -| pressedTime | number | 是 | å¦ | 按下时间 | -| deviceId | number | 是 | å¦ | 按键所属设备 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----------- | ------- | ---- | ---- | ------ | +| code | KeyCode | 是 | å¦ | 按键ç | +| pressedTime | number | 是 | å¦ | 按下时间 | +| deviceId | number | 是 | å¦ | 按键所属设备 | ## KeyEvent -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core - -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| action | Action | 是 | å¦ | 按键动作 | -| key | Key | 是 | å¦ | 当å‰å‘生å˜åŒ–的按键 | -| unicodeChar | number | 是 | å¦ | 按键对应的uniCodeå—符 | -| keys | Key[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按键列表 | -| ctrlKey | boolean | 是 | å¦ | 当å‰ctrlKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| altKey | boolean | 是 | å¦ | 当å‰altKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| shiftKey | boolean | 是 | å¦ | 当å‰shiftKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| logoKey | boolean | 是 | å¦ | 当å‰logoKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| fnKey | boolean | 是 | å¦ | 当å‰fnKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| capsLock | boolean | 是 | å¦ | 当å‰capsLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | -| numLock | boolean | 是 | å¦ | 当å‰numLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | -| scrollLock | boolean | 是 | å¦ | 当å‰scrollLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | \ No newline at end of file +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----------- | ------- | ---- | ---- | -------------------- | +| action | Action | 是 | å¦ | 按键动作 | +| key | Key | 是 | å¦ | 当å‰å‘生å˜åŒ–的按键 | +| unicodeChar | number | 是 | å¦ | 按键对应的uniCodeå—符 | +| keys | Key[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按键列表 | +| ctrlKey | boolean | 是 | å¦ | 当å‰ctrlKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| altKey | boolean | 是 | å¦ | 当å‰altKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| shiftKey | boolean | 是 | å¦ | 当å‰shiftKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| logoKey | boolean | 是 | å¦ | 当å‰logoKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| fnKey | boolean | 是 | å¦ | 当å‰fnKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| capsLock | boolean | 是 | å¦ | 当å‰capsLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| numLock | boolean | 是 | å¦ | 当å‰numLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| scrollLock | boolean | 是 | å¦ | 当å‰scrollLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index d3bcdb125e4fb4321580a5ed9a2644ae1ec87a06..4c0a3d2cac9d0341f4edc8d77bc0a3cdd9fc1627 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -105,6 +105,7 @@ media.createVideoPlayer().then((video) => { createAudioRecorder(): AudioRecorder 创建音频录制的实例æ¥æŽ§åˆ¶éŸ³é¢‘的录制。 +一å°è®¾å¤‡åªå…许创建一个录制实例。 **系统能力:** SystemCapability.Multimedia.Media.AudioRecorder @@ -125,6 +126,7 @@ let audioRecorder = media.createAudioRecorder(); createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder9)>): void 异æ¥æ–¹å¼åˆ›å»ºè§†é¢‘录制实例。通过注册回调函数获å–返回值。 +一å°è®¾å¤‡åªå…许创建一个录制实例。 **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -154,6 +156,7 @@ media.createVideoRecorder((error, video) => { createVideoRecorder(): Promise<[VideoRecorder](#videorecorder9)> 异æ¥æ–¹å¼åˆ›å»ºè§†é¢‘录制实例。通过Promise获å–返回值。 +一å°è®¾å¤‡åªå…许创建一个录制实例。 **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -271,14 +274,15 @@ Codec MIME类型枚举。 **系统能力:** 以下å„项对应的系统能力å‡ä¸º SystemCapability.Multimedia.Media.AudioPlayer。 -| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | -| ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | 是 | 是 | 音频媒体URI,支æŒå½“å‰ä¸»æµçš„è§†é¢‘æ ¼å¼(mp4ã€mpeg-tsã€webmã€mkv)。<br>**支æŒè·¯å¾„示例**:<br>1. fd类型æ’放:fd://xx<br><br>2. http网络æ’放: http://xx<br/>3. https网络æ’放: https://xx<br/>4. hls网络æ’放路径:http://xx或者https://xx<br/>**注æ„事项**:<br>ä½¿ç”¨åª’ä½“ç´ æ需è¦èŽ·å–读æƒé™ï¼Œå¦åˆ™æ— 法æ£å¸¸æ’放。 | -| loop | boolean | 是 | 是 | 音频循环æ’放属性,设置为'true'表示循环æ’放。 | -| currentTime | number | 是 | å¦ | 音频的当å‰æ’放ä½ç½®ã€‚ | -| duration | number | 是 | å¦ | 音频时长。 | -| state | [AudioState](#audiostate) | 是 | å¦ | 音频æ’放的状æ€ã€‚ | - +| å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | +| ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| src | string | 是 | 是 | 音频媒体URI,支æŒå½“å‰ä¸»æµçš„éŸ³é¢‘æ ¼å¼(m4aã€aacã€mp3ã€oggã€wav)。<br>**支æŒè·¯å¾„示例**:<br>1. fd类型æ’放:fd://xx<br><br>2. http网络æ’放: http://xx<br/>3. https网络æ’放: https://xx<br/>4. hls网络æ’放路径:http://xx或者https://xx<br/>**需è¦æƒé™ï¼š** ohos.permission.READ_MEDIA;如果需è¦ä½¿ç”¨ç½‘ç»œç´ æ,还需è¦ç”³è¯·ohos.permission.INTERNET。 | +| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 音频媒体文件æ述,使用场景:应用ä¸çš„音频资æºè¢«è¿žç»å˜å‚¨åœ¨åŒä¸€ä¸ªæ–‡ä»¶ä¸ã€‚<br/>**使用示例**:<br/>å‡è®¾ä¸€ä¸ªè¿žç»å˜å‚¨çš„音ä¹æ–‡ä»¶: <br/>音ä¹1(地å€å移:0,å—节长度:100)<br/>音ä¹2(地å€å移:101,å—节长度:50)<br/>音ä¹3(地å€å移:151,å—节长度:150)<br/>1. æ’放音ä¹1:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 0; lengt = 100; }<br/>2. æ’放音ä¹2:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 101; length = 50; }<br/>3. æ’放音ä¹3:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 151; length = 150; }<br/>å‡è®¾æ˜¯ä¸€ä¸ªç‹¬ç«‹çš„音ä¹æ–‡ä»¶: 请使用src=fd://xx <br/>**注æ„事项**:<br/>**需è¦æƒé™ï¼š** ohos.permission.READ_MEDIA | +| loop | boolean | 是 | 是 | 音频循环æ’放属性,设置为'true'表示循环æ’放。 | +| audioInterruptMode<sup>9+</sup> | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | +| currentTime | number | 是 | å¦ | 音频的当å‰æ’放ä½ç½®ï¼Œå•ä½ä¸ºæ¯«ç§’(ms)。 | +| duration | number | 是 | å¦ | 音频时长,å•ä½ä¸ºæ¯«ç§’(ms)。 | +| state | [AudioState](#audiostate) | 是 | å¦ | å¯ä»¥æŸ¥è¯¢éŸ³é¢‘æ’放的状æ€ï¼Œè¯¥çŠ¶æ€ä¸å¯ä½œä¸ºè°ƒç”¨play/pause/stopç‰çŠ¶æ€åˆ‡æ¢çš„触å‘æ¡ä»¶ã€‚ | ### play<a name=audioplayer_play></a> play(): void @@ -617,7 +621,7 @@ audioPlayer.seek(30000); //seek到30000msçš„ä½ç½® on(type: 'error', callback: ErrorCallback): void -开始订阅音频æ’放错误事件。 +开始订阅音频æ’放错误事件,当上报error错误事件åŽï¼Œç”¨æˆ·éœ€å¤„ç†error事件,退出æ’放æ“作。 **系统能力:** SystemCapability.Multimedia.Media.AudioPlayer @@ -645,13 +649,38 @@ audioPlayer.setVolume(3); //设置volumeä¸ºæ— æ•ˆå€¼ï¼Œè§¦å‘'error'事件 **系统能力:** 以下å„项对应的系统能力å‡ä¸º SystemCapability.Multimedia.Media.AudioPlayer。 -| å称 | 类型 | æè¿° | -| ------------------ | ------ | -------------- | -| idle | string | 音频æ’放空闲。 | -| playing | string | 音频æ£åœ¨æ’放。 | -| paused | string | 音频暂åœæ’放。 | -| stopped | string | 音频æ’放åœæ¢ã€‚ | -| error<sup>8+</sup> | string | 错误状æ€ã€‚ | +| å称 | 类型 | æè¿° | +| ------------------ | ------ | ---------------------------------------------- | +| idle | string | 音频æ’放空闲,dataload/resetæˆåŠŸåŽå¤„于æ¤çŠ¶æ€ã€‚ | +| playing | string | 音频æ£åœ¨æ’放,playæˆåŠŸåŽå¤„于æ¤çŠ¶æ€ã€‚ | +| paused | string | 音频暂åœæ’放,pauseæˆåŠŸåŽå¤„于æ¤çŠ¶æ€ã€‚ | +| stopped | string | 音频æ’放åœæ¢ï¼Œstop/æ’放结æŸåŽå¤„于æ¤çŠ¶æ€ã€‚ | +| error<sup>8+</sup> | string | 错误状æ€ã€‚ | + +## AVFileDescriptor<sup>9+</sup> + +音视频文件资æºæ述,一ç§ç‰¹æ®Šèµ„æºçš„æ’放方å¼ï¼Œä½¿ç”¨åœºæ™¯ï¼šåº”用ä¸çš„音频资æºè¢«è¿žç»å˜å‚¨åœ¨åŒä¸€ä¸ªæ–‡ä»¶ä¸ï¼Œéœ€è¦æ ¹æ®å移é‡å’Œé•¿åº¦è¿›è¡Œæ’放。 + +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| fd | number | 是 | 资æºå¥æŸ„,通过resourceManager.getRawFileDescriptorèŽ·å– | +| offset | number | 是 | 资æºå移é‡ï¼Œéœ€è¦åŸºäºŽé¢„置资æºçš„ä¿¡æ¯è¾“入,éžæ³•å€¼ä¼šé€ æˆéŸ³è§†é¢‘资æºè§£æžé”™è¯¯ | +| length | number | 是 | 资æºé•¿åº¦ï¼Œéœ€è¦åŸºäºŽé¢„置资æºçš„ä¿¡æ¯è¾“入,éžæ³•å€¼ä¼šé€ æˆéŸ³è§†é¢‘资æºè§£æžé”™è¯¯ | + +## InterruptMode<sup>9+</sup> + +音频焦点模å¼ã€‚ + +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + +| å称 | 默认值 | æè¿° | +| ---------------------------- | ------ | ---------- | +| SHARE_MODE | 0 | 共享焦点模å¼ã€‚ | +| INDEPENDENT_MODE| 1 | 独立焦点模å¼ã€‚ | ## VideoPlayer<sup>8+</sup> @@ -665,13 +694,16 @@ audioPlayer.setVolume(3); //设置volumeä¸ºæ— æ•ˆå€¼ï¼Œè§¦å‘'error'事件 | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url<sup>8+</sup> | string | 是 | 是 | 视频媒体URL,支æŒå½“å‰ä¸»æµçš„è§†é¢‘æ ¼å¼(mp4ã€mpeg-tsã€webmã€mkv)。<br>**支æŒè·¯å¾„示例**:<br>1. fd类型æ’放:fd://xx<br><br>2. http网络æ’放: http://xx<br/>3. https网络æ’放: https://xx<br/>4. hls网络æ’放路径:http://xx或者https://xx<br/>**注æ„事项**:<br>ä½¿ç”¨åª’ä½“ç´ æ需è¦èŽ·å–读æƒé™ï¼Œå¦åˆ™æ— 法æ£å¸¸æ’放。 | +| url<sup>8+</sup> | string | 是 | 是 | 视频媒体URL,支æŒå½“å‰ä¸»æµçš„è§†é¢‘æ ¼å¼(mp4ã€mpeg-tsã€webmã€mkv)。<br>**支æŒè·¯å¾„示例**:<br>1. fd类型æ’放:fd://xx<br><br>2. http网络æ’放: http://xx<br/>3. https网络æ’放: https://xx<br/>4. hls网络æ’放路径:http://xx或者https://xx<br/>**需è¦æƒé™ï¼š** ohos.permission.READ_MEDIA;如果需è¦ä½¿ç”¨ç½‘ç»œç´ æ,还需è¦ç”³è¯·ohos.permission.INTERNET。 | +| fdSrc<sup>9+</sup> | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 视频媒体文件æ述,使用场景:应用ä¸çš„视频资æºè¢«è¿žç»å˜å‚¨åœ¨åŒä¸€ä¸ªæ–‡ä»¶ä¸ã€‚<br/>**使用示例**:<br/>å‡è®¾ä¸€ä¸ªè¿žç»å˜å‚¨çš„音ä¹æ–‡ä»¶: <br/>视频1(地å€å移:0,å—节长度:100)<br/>视频2(地å€å移:101,å—节长度:50)<br/>视频3(地å€å移:151,å—节长度:150)<br/>1. æ’放视频1:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 0; lengt = 100; }<br/>2. æ’放视频2:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 101; length = 50; }<br/>3. æ’放视频3:AVFileDescriptor { fd = 资æºå¥æŸ„; offset = 151; length = 150; }<br/>å‡è®¾æ˜¯ä¸€ä¸ªç‹¬ç«‹çš„视频文件: 请使用src=fd://xx <br/>**注æ„事项**:<br/>**需è¦æƒé™ï¼š** ohos.permission.READ_MEDIA | | loop<sup>8+</sup> | boolean | 是 | 是 | 视频循环æ’放属性,设置为'true'表示循环æ’放。 | -| currentTime<sup>8+</sup> | number | 是 | å¦ | 视频的当å‰æ’放ä½ç½®ã€‚ | -| duration<sup>8+</sup> | number | 是 | å¦ | 视频时长,返回-1表示直æ’模å¼ã€‚ | +| videoScaleType<sup>9+</sup> | [VideoScaleType](#videoscaletype9) | 是 | 是 | 视频缩放模å¼ã€‚ | +| audioInterruptMode<sup>9+</sup> | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | +| currentTime<sup>8+</sup> | number | 是 | å¦ | 视频的当å‰æ’放ä½ç½®ï¼Œå•ä½ä¸ºæ¯«ç§’(ms)。 | +| duration<sup>8+</sup> | number | 是 | å¦ | 视频时长,å•ä½ä¸ºæ¯«ç§’(ms),返回-1表示直æ’模å¼ã€‚ | | state<sup>8+</sup> | [VideoPlayState](#videoplaystate8) | 是 | å¦ | 视频æ’放的状æ€ã€‚ | -| width<sup>8+</sup> | number | 是 | å¦ | 视频宽。 | -| height<sup>8+</sup> | number | 是 | å¦ | 视频高。 | +| width<sup>8+</sup> | number | 是 | å¦ | 视频宽,å•ä½ä¸ºåƒç´ (px)。 | +| height<sup>8+</sup> | number | 是 | å¦ | 视频高,å•ä½ä¸ºåƒç´ (px)。 | ### setDisplaySurface<sup>8+</sup> @@ -1333,7 +1365,7 @@ videoPlayer.setSpeed(speed).then() => { selectBitrate(bitrate:number, callback: AsyncCallback\<number>): void -通过回调方å¼è®¾ç½®ç 率,通过[availableBitrateCollected](#on('availableBitrateCollected')<sup>9+</sup>)获å–当å‰ç æµæ”¯æŒçš„Bitrate。 +通过回调方å¼è®¾ç½®ç 率,通过[availableBitratesCollect](#onavailablebitratescollect9)获å–当å‰ç æµæ”¯æŒçš„Bitrate。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer @@ -1361,7 +1393,7 @@ videoPlayer.selectBitrate(bitrate, (err, result) => { selectBitrate(bitrate:number): Promise\<number> -通过Promiseæ–¹å¼è®¾ç½®ç 率,通过[availableBitrateCollected](#on('availableBitrateCollected')<sup>9+</sup>)获å–当å‰ç æµæ”¯æŒçš„Bitrate。 +通过Promiseæ–¹å¼è®¾ç½®ç 率,通过[availableBitratesCollect](#onavailablebitratescollect9)获å–当å‰ç æµæ”¯æŒçš„Bitrate。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer @@ -1486,7 +1518,7 @@ videoPlayer.on('videoSizeChanged', (width, height) => { on(type: 'error', callback: ErrorCallback): void -开始监å¬è§†é¢‘æ’放错误事件。 +开始监å¬è§†é¢‘æ’放错误事件,当上报error错误事件åŽï¼Œç”¨æˆ·éœ€å¤„ç†error事件,退出æ’放æ“作。 **系统能力:** SystemCapability.Multimedia.Media.VideoPlayer @@ -1505,12 +1537,12 @@ videoPlayer.on('error', (error) => { // 设置'error'事件回调 console.info(`video error called, errCode is ${error.code}`); // 打å°é”™è¯¯ç console.info(`video error called, errMessage is ${error.message}`);// 打å°é”™è¯¯ç±»åž‹è¯¦ç»†æè¿° }); -videoPlayer.setVolume(3); //设置volumeä¸ºæ— æ•ˆå€¼ï¼Œè§¦å‘'error'事件 +videoPlayer.url = 'fd://error'; //设置错误的æ’放地å€ï¼Œè§¦å‘'error'事件 ``` -### on('availableBitrateCollected')<sup>9+</sup> +### on('availableBitratesCollect')<sup>9+</sup> -on(type: 'availableBitrateCollected', callback: (bitrates: Array<number>) => void): void +on(type: 'availableBitratesCollect', callback: (bitrates: Array\<number>) => void): void 开始监å¬è§†é¢‘æ’放ç 率上报事件。 @@ -1520,15 +1552,15 @@ on(type: 'availableBitrateCollected', callback: (bitrates: Array<number>) => voi | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | ---- | ------------------------------------------------------------ | -| type | string | 是 | 视频æ’放ç 率上报事件回调类型,支æŒçš„事件:'availableBitrateCollected',åªåœ¨å¼€å§‹æ’放时候上报一次 | -| callback | function | 是 | 视频æ’放ç 率事件回调方法,使用数组å˜æ”¾æ”¯æŒçš„ç 率。 | +| type | string | 是 | 视频æ’放ç 率上报事件回调类型,支æŒçš„事件:'availableBitratesCollect',åªåœ¨å¼€å§‹æ’放时候上报一次 | +| callback | function | 是 | 视频æ’放ç 率事件回调方法,使用数组å˜æ”¾æ”¯æŒçš„ç 率。 | **示例:** ```js -videoPlayer.on('availableBitrateCollected', (bitrates) => { +videoPlayer.on('availableBitratesCollect', (bitrates) => { for (let i = 0; i < bitrates.length; i++) { - console.info('case availableBitrateCollected bitrates: ' + bitrates[i]); //打å°æ”¯æŒçš„ç 率 + console.info('case availableBitratesCollect bitrates: ' + bitrates[i]); //打å°æ”¯æŒçš„ç 率 } }); ``` @@ -1573,6 +1605,17 @@ videoPlayer.on('availableBitrateCollected', (bitrates) => { | SPEED_FORWARD_1_75_X | 3 | 表示视频æ’放æ£å¸¸æ’速的1.75å€ã€‚ | | SPEED_FORWARD_2_00_X | 4 | 表示视频æ’放æ£å¸¸æ’速的2.00å€ã€‚ | +## VideoScaleType<sup>9+</sup> + +枚举,视频缩放模å¼ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸º SystemCapability.Multimedia.Media.VideoPlayer。 + +| å称 | 默认值 | æè¿° | +| ---------------------------- | ------ | ---------- | +| VIDEO_SCALE_TYPE_FIT | 0 | 视频拉伸至与窗å£ç‰å¤§ã€‚ | +| VIDEO_SCALE_TYPE_FIT_CROP| 1 | ä¿æŒè§†é¢‘宽高比拉伸至填满窗å£ï¼Œå†…容å¯èƒ½ä¼šæœ‰è£å‰ªã€‚ | + ## MediaDescription<sup>8+</sup> ### [key : string] : Object @@ -1814,7 +1857,7 @@ audioRecorder.prepare(audioRecorderConfig) on(type: 'error', callback: ErrorCallback): void -开始订阅音频录制错误事件。 +开始订阅音频录制错误事件,当上报error错误事件åŽï¼Œç”¨æˆ·éœ€å¤„ç†error事件,退出录制æ“作。 **系统能力:** SystemCapability.Multimedia.Media.AudioRecorder @@ -1977,7 +2020,7 @@ prepare(config: VideoRecorderConfig): Promise\<void>; 异æ¥æ–¹å¼è¿›è¡Œè§†é¢‘录制的å‚数设置。通过Promise获å–返回值。 -**需è¦æƒé™ï¼š** ohos.permission.MICROPHONE,ohos.permission.CAMERA +**需è¦æƒé™ï¼š** ohos.permission.MICROPHONE **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2108,7 +2151,7 @@ start(callback: AsyncCallback\<void>): void; 异æ¥æ–¹å¼å¼€å§‹è§†é¢‘录制。通过注册回调函数获å–返回值。 -在[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)åŽè°ƒç”¨ï¼Œéœ€è¦ä¾èµ–æ•°æ®æºå…ˆç»™surfaceä¼ é€’æ•°æ®ã€‚ +在[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)åŽè°ƒç”¨ï¼Œéœ€è¦ä¾èµ–æ•°æ®æºå…ˆç»™surfaceä¼ é€’æ•°æ®ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2137,7 +2180,7 @@ start(): Promise\<void>; 异æ¥æ–¹å¼å¼€å§‹è§†é¢‘录制。通过Promise获å–返回值。 -在[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)åŽè°ƒç”¨ï¼Œéœ€è¦ä¾èµ–æ•°æ®æºå…ˆç»™surfaceä¼ é€’æ•°æ®ã€‚ +在[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)åŽè°ƒç”¨ï¼Œéœ€è¦ä¾èµ–æ•°æ®æºå…ˆç»™surfaceä¼ é€’æ•°æ®ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2272,7 +2315,7 @@ stop(callback: AsyncCallback\<void>): void; 异æ¥æ–¹å¼åœæ¢è§†é¢‘录制。通过注册回调函数获å–返回值。 -需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ +需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2301,7 +2344,7 @@ stop(): Promise\<void>; 异æ¥æ–¹å¼åœæ¢è§†é¢‘录制。通过Promise获å–返回值。 -需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ +需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2380,7 +2423,7 @@ reset(callback: AsyncCallback\<void>): void; 异æ¥æ–¹å¼é‡ç½®è§†é¢‘录制。通过注册回调函数获å–返回值。 -需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ +需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2409,7 +2452,7 @@ reset(): Promise\<void>; 异æ¥æ–¹å¼é‡ç½®è§†é¢‘录制。通过Promise获å–返回值。 -需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface8)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ +需è¦é‡æ–°è°ƒç”¨[prepare()](#videorecorder_prepare1)å’Œ[getInputSurface()](#getinputsurface9)接å£æ‰èƒ½é‡æ–°å½•åˆ¶ã€‚ **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2434,7 +2477,7 @@ videoRecorder.reset().then(() => { on(type: 'error', callback: ErrorCallback): void -开始订阅视频录制错误事件。 +开始订阅视频录制错误事件,当上报error错误事件åŽï¼Œç”¨æˆ·éœ€å¤„ç†error事件,退出录制æ“作。 **系统能力:** SystemCapability.Multimedia.Media.VideoRecorder @@ -2484,7 +2527,7 @@ videoRecorder.on('error', (error) => { // 设 | profile | [VideoRecorderProfile](#videorecorderprofile9) | 是 | 视频录制的profile。 | | rotation | number | å¦ | 录制视频的旋转角度。 | | location | [Location](#location) | å¦ | 录制视频的地ç†ä½ç½®ã€‚ | -| url | string | 是 | 视频输出URL:fd://xx (fd number)<br/> <br/>文件需è¦ç”±è°ƒç”¨è€…创建,并赋予适当的æƒé™ã€‚ | +| url | string | 是 | 视频输出URL:fd://xx (fd number)<br/> <br/>**需è¦æƒé™ï¼š** ohos.permission.READ_MEDIAï¼› | ## AudioSourceType<sup>9+</sup> diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index 3b407a460442bb4efb95fc1ff80e45d0a2e30cac..79e539d30e5f18e0a468e6e05cc000ba66115c20 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -14,6 +14,8 @@ getMediaLibrary(context: Context): MediaLibrary 获å–媒体库的实例,用于访问和修改用户ç‰ä¸ªäººåª’体数æ®ä¿¡æ¯ï¼ˆå¦‚音频ã€è§†é¢‘ã€å›¾ç‰‡ã€æ–‡æ¡£ç‰ï¼‰ã€‚ +æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 + **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core **å‚数:** @@ -48,6 +50,8 @@ getMediaLibrary(): MediaLibrary 获å–媒体库的实例,用于访问和修改用户ç‰ä¸ªäººåª’体数æ®ä¿¡æ¯ï¼ˆå¦‚音频ã€è§†é¢‘ã€å›¾ç‰‡ã€æ–‡æ¡£ç‰ï¼‰ã€‚ +æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用。 + > **说明**: 从API Version 8开始,该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用新接å£[mediaLibrary.getMediaLibrary<sup>8+</sup>](#medialibrarygetmedialibrary8)。 **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core @@ -98,7 +102,9 @@ media.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); fetchFileResult.getAllObject((err, fileAssetList) => { if (fileAssetList != undefined) { - fileAssetList.forEach(getAllObjectInfo); + fileAssetList.forEach(function(getAllObjectInfo){ + console.info("getAllObjectInfo.displayName :" + getAllObjectInfo.displayName); + }); } }); } @@ -136,7 +142,7 @@ let imagesfetchOp = { selectionArgs: [imageType.toString()], }; media.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ - console.info("getFileAssets successfully:"+ JSON.stringify(dir)); + console.info("getFileAssets successfully: image number is "+ fetchFileResult.getCount()); }).catch(function(err){ console.info("getFileAssets failed with error:"+ err); }); @@ -160,7 +166,7 @@ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'| **示例:** ``` -mediaLibrary.on('imageChange', () => { +media.on('imageChange', () => { // image file had changed, do something }) ``` @@ -251,17 +257,12 @@ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Pr **示例:** ``` -async function example() { - // 使用Promiseæ–¹å¼åˆ›å»ºImage类型文件 - let mediaType = mediaLibrary.MediaType.IMAGE; - let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; - const path = await media.getPublicDirectory(DIR_IMAGE); - media.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { - console.info("createAsset successfully:"+ JSON.stringify(asset)); - }).catch(function(err){ - console.info("createAsset failed with error:"+ err); - }); -} +let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; +media.getPublicDirectory(DIR_CAMERA).then(function(dicResult){ + console.info("getPublicDirectory successfully:"+ JSON.stringify(dicResult)); +}).catch(function(err){ + console.info("getPublicDirectory failed with error:"+ err); +}); ``` ### getPublicDirectory<sup>8+</sup> @@ -665,7 +666,7 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback<Array< ``` let option = { - type : "image", + type : "media", count : 2 }; mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { @@ -705,7 +706,7 @@ startMediaSelect(option: MediaSelectOption): Promise<Array<string>> ``` let option = { - type : "image", + type : "media", count : 2 }; mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { @@ -770,6 +771,7 @@ isDirectory(callback: AsyncCallback<boolean>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -805,6 +807,7 @@ isDirectory():Promise<boolean> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -842,6 +845,7 @@ commitModify(callback: AsyncCallback<void>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -878,6 +882,7 @@ commitModify(): Promise<void> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -900,7 +905,7 @@ open(mode: string, callback: AsyncCallback<number>): void **注æ„**:当å‰å†™æ“作是互斥的æ“作,写æ“作完æˆåŽéœ€è¦è°ƒç”¨close进行释放 -**需è¦æƒé™**:ohos.permission.READ_MEDIA('r'模å¼æ‰“开),ohos.permission.WRITE_MEDIA('w'模å¼æ‰“开) +**需è¦æƒé™**:ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core @@ -918,7 +923,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - asset = await media.createAsset(mediaType, "image00003.jpg", path); + const asset = await media.createAsset(mediaType, "image00003.jpg", path); asset.open('rw', (openError, fd) => { if(fd > 0){ asset.close(fd); @@ -937,7 +942,7 @@ open(mode: string): Promise<number> **注æ„**:当å‰å†™æ“作是互斥的æ“作,写æ“作完æˆåŽéœ€è¦è°ƒç”¨close进行释放 -**需è¦æƒé™**:ohos.permission.READ_MEDIA('r'模å¼æ‰“开),ohos.permission.WRITE_MEDIA('w'模å¼æ‰“开) +**需è¦æƒé™**:ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core @@ -960,7 +965,7 @@ async function example() { let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await media.getPublicDirectory(DIR_IMAGE); - asset = await media.createAsset(mediaType, "image00003.jpg", path); + const asset = await media.createAsset(mediaType, "image00003.jpg", path); asset.open('rw') .then((fd) => { console.info('File fd!' + fd); @@ -977,7 +982,7 @@ close(fd: number, callback: AsyncCallback<void>): void å…³é—当å‰æ–‡ä»¶ï¼Œä½¿ç”¨callbackæ–¹å¼è¿”回异æ¥ç»“果。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA('r'模å¼æ‰“开),ohos.permission.WRITE_MEDIA('w'模å¼æ‰“开) +**需è¦æƒé™**:ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core @@ -992,6 +997,7 @@ close(fd: number, callback: AsyncCallback<void>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1001,13 +1007,19 @@ async function example() { }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.close(fd, (closeErr) => { - if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); - } else { - console.info("=======asset.close success====>"); - } + asset.open('rw').then((fd) => { + console.info('File fd!' + fd); + asset.close(fd, (closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + } else { + console.info("=======asset.close success====>"); + } + }); + }) + .catch((err) => { + console.info('File err!' + err); }); } ``` @@ -1018,7 +1030,7 @@ close(fd: number): Promise<void> å…³é—当å‰æ–‡ä»¶ï¼Œä½¿ç”¨promiseæ–¹å¼è¿”回异æ¥ç»“果。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA('r'模å¼æ‰“开),ohos.permission.WRITE_MEDIA('w'模å¼æ‰“开) +**需è¦æƒé™**:ohos.permission.READ_MEDIA or ohos.permission.WRITE_MEDIA **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core @@ -1038,6 +1050,7 @@ close(fd: number): Promise<void> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1047,14 +1060,20 @@ async function example() { }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.close(fd).then((closeErr) => { - if (closeErr != undefined) { - console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + asset.open('rw').then((fd) => { + console.info('File fd!' + fd); + asset.close(fd).then((closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); - } else { - console.info("=======asset.close success====>"); - } + } else { + console.info("=======asset.close success====>"); + } + }); + }) + .catch((err) => { + console.info('File err!' + err); }); } ``` @@ -1079,6 +1098,7 @@ getThumbnail(callback: AsyncCallback<image.PixelMap>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1115,6 +1135,7 @@ getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1122,6 +1143,7 @@ async function example() { order: fileKeyObj.DATE_ADDED + " DESC", extendArgs: "", }; + let size = { width: 720, height: 720 }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size, (err, pixelmap) => { @@ -1156,6 +1178,7 @@ getThumbnail(size?: Size): Promise<image.PixelMap> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1163,6 +1186,7 @@ async function example() { order: fileKeyObj.DATE_ADDED + " DESC", extendArgs: "", }; + let size = { width: 720, height: 720 }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.getThumbnail(size) @@ -1196,6 +1220,7 @@ favorite(isFavorite: boolean, callback: AsyncCallback<void>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1237,6 +1262,7 @@ favorite(isFavorite: boolean): Promise<void> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1274,6 +1300,7 @@ isFavorite(callback: AsyncCallback<boolean>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1313,6 +1340,7 @@ isFavorite():Promise<boolean> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1353,6 +1381,7 @@ trash(isTrash: boolean, callback: AsyncCallback<void>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1397,6 +1426,7 @@ trash(isTrash: boolean): Promise<void> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1434,6 +1464,7 @@ isTrash(callback: AsyncCallback<boolean>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1447,7 +1478,7 @@ async function example() { function isTrashCallBack(err, isTrash) { if (isTrash == true) { console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); - asset.trash(true, trashCallBack); + asset.trash(true, istrashCallBack); } else { console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); @@ -1478,6 +1509,7 @@ isTrash():Promise<boolean> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1517,6 +1549,8 @@ getCount(): number ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey + let fileType = mediaLibrary.MediaType.FILE; let getFileCountOneOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [fileType.toString()], @@ -1546,6 +1580,7 @@ isAfterLast(): boolean ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1583,6 +1618,7 @@ close(): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1613,6 +1649,7 @@ getFirstObject(callback: AsyncCallback<FileAsset>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1621,12 +1658,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getFirstObject((err, value) => { + fetchFileResult.getFirstObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1649,6 +1686,7 @@ getFirstObject(): Promise<FileAsset> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1671,8 +1709,6 @@ async function example() { 获å–文件检索结果ä¸çš„下一个文件资产。æ¤æ–¹æ³•ä½¿ç”¨callbackå½¢å¼è¿”回结果。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA - **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core **å‚æ•°**: @@ -1685,6 +1721,7 @@ async function example() { ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1693,12 +1730,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getNextObject((err, value) => { + fetchFileResult.getNextObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1709,8 +1746,6 @@ async function example() { 获å–文件检索结果ä¸çš„下一个文件资产。æ¤æ–¹æ³•ä½¿ç”¨promiseæ–¹å¼æ¥å¼‚æ¥è¿”回FileAsset。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA - **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core **返回值**: @@ -1723,6 +1758,7 @@ async function example() { ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1733,7 +1769,7 @@ async function example() { let fetchFileResult = await media.getFileAssets(getImageOp); const fetchCount = fetchFileResult.getCount(); console.info('mediaLibraryTest : count:' + fetchCount); - fileAsset = await fetchFileResult.getNextObject(); + let fileAsset = await fetchFileResult.getNextObject(); } ``` @@ -1755,6 +1791,7 @@ getLastObject(callback: AsyncCallback<FileAsset>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1763,12 +1800,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getLastObject((err, value) => { + fetchFileResult.getLastObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1791,6 +1828,7 @@ getLastObject(): Promise<FileAsset> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1822,6 +1860,7 @@ getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1830,12 +1869,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getPositionObject(0, (err, value) => { + fetchFileResult.getPositionObject(0, (err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1846,8 +1885,6 @@ getPositionObject(index: number): Promise<FileAsset> 获å–文件检索结果ä¸å…·æœ‰æŒ‡å®šç´¢å¼•çš„文件资产。æ¤æ–¹æ³•ä½¿ç”¨Promiseå½¢å¼è¿”回文件Asset。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA - **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core **å‚æ•°**: @@ -1866,6 +1903,7 @@ getPositionObject(index: number): Promise<FileAsset> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1874,13 +1912,11 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getPositionObject(1, (err, value) => { - if (err) { - console.error('Failed '); - return; - } - console.log(value); - }) + fetchFileResult.getPositionObject(1) .then(function (fileAsset){ + console.log('[Demo] fileAsset.displayName : ' + fileAsset.displayName); + }).catch(function (err) { + console.info("[Demo] getFileAssets failed with error:" + err); + }); } ``` @@ -1890,8 +1926,6 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void 获å–文件检索结果ä¸çš„所有文件资产。æ¤æ–¹æ³•ä½¿ç”¨Callback回调æ¥è¿”回FileAsset结果集。 -**需è¦æƒé™**:ohos.permission.READ_MEDIA - **系统能力**:SystemCapability.Multimedia.MediaLibrary.Core **å‚æ•°**: @@ -1904,6 +1938,7 @@ getAllObject(callback: AsyncCallback<Array<FileAsset>>): void ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -1912,12 +1947,12 @@ async function example() { extendArgs: "", }; let fetchFileResult = await media.getFileAssets(getImageOp); - fetchFileResult.getAllObject((err, value) => { + fetchFileResult.getAllObject((err, fileAsset) => { if (err) { console.error('Failed '); return; } - console.log(value); + console.log('fileAsset.displayName : ' + fileAsset.displayName); }) } ``` @@ -1940,6 +1975,7 @@ getAllObject(): Promise<Array<FileAsset>> ``` async function example() { + let fileKeyObj = mediaLibrary.FileKey let imageType = mediaLibrary.MediaType.IMAGE; let getImageOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', @@ -2067,6 +2103,10 @@ async function example() { selections: '', selectionArgs: [], }; + let fileNoArgsfetchOp = { + selections: '', + selectionArgs: [], + } const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const album = albumList[0]; album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); @@ -2106,6 +2146,10 @@ async function example() { selections: '', selectionArgs: [], }; + let fileNoArgsfetchOp = { + selections: '', + selectionArgs: [], + } const albumList = await media.getAlbums(AlbumNoArgsfetchOp); const album = albumList[0]; album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){ @@ -2119,8 +2163,9 @@ async function example() { ## PeerInfo<sup>8+</sup> 注册设备的信æ¯ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.MediaLibrary.Core +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.MediaLibrary.DistributedCore | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ---------- | -------------------------- | ---- | ---- | ---------------- | @@ -2165,7 +2210,7 @@ async function example() { | TITLE | title | æ–‡ä»¶æ ‡é¢˜ | | ARTIST | artist | 作者 | | AUDIOALBUM | audio_album | 专辑 | -| DURATION | duration | æŒç»æ—¶é—´ï¼ˆå•ä½ï¼šç§’) | +| DURATION | duration | æŒç»æ—¶é—´ï¼ˆå•ä½ï¼šæ¯«ç§’) | | WIDTH | width | 图片宽度(å•ä½ï¼šåƒç´ ) | | HEIGHT | height | 图片高度(å•ä½ï¼šåƒç´ ) | | ORIENTATION | orientation | 图片显示方å‘,å³é¡ºæ—¶é’ˆæ—‹è½¬è§’度,如0,90,180。(å•ä½ï¼šåº¦ï¼‰ | @@ -2190,8 +2235,9 @@ async function example() { ## DeviceType<sup>8+</sup> 枚举,设备类型。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.MediaLibrary.Core +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.MediaLibrary.DistributedCore | å称 | 说明 | | ------------ | ---------- | @@ -2221,6 +2267,7 @@ async function example() { ## Size<sup>8+</sup> 图片尺寸。 +系统能力: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Multimedia.MediaLibrary.Core | å称 | 类型 | å¯è¯» | å¯å†™ | 说明 | | ------ | ------ | ---- | ---- | -------- | @@ -2253,4 +2300,5 @@ async function example() { | å称 | 类型 | å¿…å¡« | æè¿° | | ----- | ------ | ---- | -------------------- | | type | string | 是 | 媒体类型,包括:image, video, media,当å‰ä»…支æŒmedia类型 | -| count | number | 是 | 媒体选择,count = 1表示å•é€‰ï¼Œcount大于1表示多选。 | \ No newline at end of file +| count | number | 是 | 媒体选择,count = 1表示å•é€‰ï¼Œcount大于1表示多选。 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md index 0b6e423c1731de71958ee1a18e21db2da46c09f9..aef2af9a2b4a2f402df7673594865bb815990582 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md @@ -3,6 +3,7 @@ æä¾›æ ¹æ®ä¸åŒåª’体类型定义ä¸åŒçš„æ ·å¼ã€‚ > **说明:** +> > 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 @@ -118,7 +119,7 @@ off(type: 'change', callback?: Callback<MediaQueryResult>): void ### 示例 -```js +```ts import mediaquery from '@ohos.mediaquery' let portraitFunc = null diff --git a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md index af0eb8d91ab0f4e8e42a3021a95edac2f3c8d34d..bb2deac5e536bae5841fd28fd6fe1c112df1b801 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-missionManager.md @@ -362,6 +362,88 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps }); ``` +## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup> + +getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void; + +使用给定的任务ID获å–任务低分辨率快照。 + +**需è¦æƒé™**:ohos.permission.MANAGE_MISSIONS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | deviceId | string | 是 | 设备ID,本机默认为空å—符串。 | + | missionId | number | 是 | 任务ID。 | + | callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | 是 | 执行结果回调函数,返回任务快照信æ¯ã€‚ | + +**示例:** + + ```js + import missionManager from '@ohos.application.missionManager' + + missionManager.getMissionInfos("", 10, (error, missions) => { + console.log("getMissionInfos is called, error.code = " + error.code); + console.log("size = " + missions.length); + console.log("missions = " + JSON.stringify(missions)); + var id = missions[0].missionId; + + missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => { + console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code); + console.log("bundleName = " + snapshot.ability.bundleName); + }) + }) + ``` + + +## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup> + +getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>; + +使用给定的任务ID获å–任务低分辨率快照。 + +**需è¦æƒé™**:ohos.permission.MANAGE_MISSIONS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | deviceId | string | 是 | 设备ID,本机默认为空å—符串。 | + | missionId | number | 是 | 任务ID。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | 任务快照信æ¯ã€‚ | + +**示例:** + + ```js + import missionManager from '@ohos.application.missionManager' + + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + var snapshot = missionManager.getLowResolutionMissionSnapShot("", id).catch(function (err){ + console.log(err); + }); + ``` + ## missionManager.lockMission diff --git a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md index 1262a33512efbf4c1678cac176733b27611fe8a1..b47a5d9bd5dcfaaae274b736ec7cf3052eb22703 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md @@ -2,7 +2,7 @@ è®¾å¤‡ä¸ŠæŠ¥çš„é¼ æ ‡äº‹ä»¶ã€‚ ->  **说明:** +> **说明:** > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -13,77 +13,77 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou ## Action -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| CANCEL | number | 是 | å¦ | å–消 | -| MOVE | number | 是 | å¦ | é¼ æ ‡ç§»åŠ¨ | -| BUTTON_DOWN | number | 是 | å¦ | é¼ æ ‡æŒ‰é’®æŒ‰ä¸‹ | -| BUTTON_UP | number | 是 | å¦ | é¼ æ ‡æŒ‰é’®æŠ¬èµ· | -| AXIS_BEGIN | number | 是 | å¦ | é¼ æ ‡å…³è”的轴事件开始 | -| AXIS_UPDATE | number | 是 | å¦ | é¼ æ ‡å…³è”的轴事件更新 | -| AXIS_END | number | 是 | å¦ | é¼ æ ‡å…³è”çš„è½´äº‹ä»¶ç»“æŸ | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----------- | ------ | ---- | ---- | ---------- | +| CANCEL | number | 是 | å¦ | å–消 | +| MOVE | number | 是 | å¦ | é¼ æ ‡ç§»åŠ¨ | +| BUTTON_DOWN | number | 是 | å¦ | é¼ æ ‡æŒ‰é’®æŒ‰ä¸‹ | +| BUTTON_UP | number | 是 | å¦ | é¼ æ ‡æŒ‰é’®æŠ¬èµ· | +| AXIS_BEGIN | number | 是 | å¦ | é¼ æ ‡å…³è”的轴事件开始 | +| AXIS_UPDATE | number | 是 | å¦ | é¼ æ ‡å…³è”的轴事件更新 | +| AXIS_END | number | 是 | å¦ | é¼ æ ‡å…³è”çš„è½´äº‹ä»¶ç»“æŸ | ## Button -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| LEFT | number | 是 | å¦ | é¼ æ ‡å·¦é”® | -| MIDDLE | number | 是 | å¦ | é¼ æ ‡ä¸é”® | -| RIGHT | number | 是 | å¦ | é¼ æ ‡å³é”® | -| SIDE | number | 是 | å¦ | é¼ æ ‡ä¾§è¾¹é”® | -| EXTRA | number | 是 | å¦ | é¼ æ ‡æ‰©å±•é”® | -| FORWARD | number | 是 | å¦ | é¼ æ ‡å‰è¿›é”® | -| BACK | number | 是 | å¦ | é¼ æ ‡åŽé€€é”® | -| TASK | number | 是 | å¦ | é¼ æ ‡ä»»åŠ¡é”® | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ------- | ------ | ---- | ---- | ----- | +| LEFT | number | 是 | å¦ | é¼ æ ‡å·¦é”® | +| MIDDLE | number | 是 | å¦ | é¼ æ ‡ä¸é”® | +| RIGHT | number | 是 | å¦ | é¼ æ ‡å³é”® | +| SIDE | number | 是 | å¦ | é¼ æ ‡ä¾§è¾¹é”® | +| EXTRA | number | 是 | å¦ | é¼ æ ‡æ‰©å±•é”® | +| FORWARD | number | 是 | å¦ | é¼ æ ‡å‰è¿›é”® | +| BACK | number | 是 | å¦ | é¼ æ ‡åŽé€€é”® | +| TASK | number | 是 | å¦ | é¼ æ ‡ä»»åŠ¡é”® | ## Axis -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| SCROLL_VERTICAL | number | 是 | å¦ | 垂直滚动轴 | -| SCROLL_HORIZONTAL | number | 是 | å¦ | 水平滚动轴 | -| PINCH | number | 是 | å¦ | æåˆè½´ | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----------------- | ------ | ---- | ---- | ----- | +| SCROLL_VERTICAL | number | 是 | å¦ | 垂直滚动轴 | +| SCROLL_HORIZONTAL | number | 是 | å¦ | 水平滚动轴 | +| PINCH | number | 是 | å¦ | æåˆè½´ | ## AxisValue -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| axis | Axis | 是 | å¦ | 轴类型 | -| value | number | 是 | å¦ | 轴的值 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----- | ------ | ---- | ---- | ---- | +| axis | Axis | 是 | å¦ | 轴类型 | +| value | number | 是 | å¦ | 轴的值 | ## MouseEvent -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core - -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| action | Action | 是 | å¦ | é¼ æ ‡äº‹ä»¶åŠ¨ä½œ | -| screenX | number | 是 | å¦ | é¼ æ ‡å…‰æ ‡åœ¨å±å¹•ä¸çš„xåæ ‡ | -| screenY | number | 是 | å¦ | é¼ æ ‡å…‰æ ‡åœ¨å±å¹•ä¸çš„yåæ ‡ | -| windowX | number | 是 | å¦ | é¼ æ ‡å½’å±žçª—å£çš„xåæ ‡ | -| windowY | number | 是 | å¦ | é¼ æ ‡å½’å±žçª—å£çš„yåæ ‡ | -| rawDeltaX | number | 是 | å¦ | Xè½´ç›¸å¯¹ä¸Šæ¬¡ä¸ŠæŠ¥é¼ æ ‡ä½ç½®çš„å移,在å±å¹•è¾¹ç¼˜ä½ç½®æ—¶ï¼Œè¯¥å€¼å¯èƒ½å°äºŽä¸¤æ¬¡é¼ æ ‡ä¸ŠæŠ¥çš„åæ ‡å·® | -| rawDeltaY | number | 是 | å¦ | Yè½´ç›¸å¯¹ä¸Šæ¬¡ä¸ŠæŠ¥é¼ æ ‡ä½ç½®çš„å移 | -| button | Button | 是 | å¦ | 当å‰æŒ‰ä¸‹/抬起的按钮 | -| pressedButtons | Button[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按钮 | -| axes | AxisValue[] | 是 | å¦ | 事件包å«çš„æ‰€æœ‰è½´æ•°æ® | -| pressedKeys | KeyCode[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按键列表 | -| ctrlKey | boolean | 是 | å¦ | 当å‰ctrlKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| altKey | boolean | 是 | å¦ | 当å‰altKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| shiftKey | boolean | 是 | å¦ | 当å‰shiftKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| logoKey | boolean | 是 | å¦ | 当å‰logoKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| fnKey | boolean | 是 | å¦ | 当å‰fnKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | -| capsLock | boolean | 是 | å¦ | 当å‰capsLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | -| numLock | boolean | 是 | å¦ | 当å‰numLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | -| scrollLock | boolean | 是 | å¦ | 当å‰scrollLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| -------------- | ----------- | ---- | ---- | ---------------------------------------- | +| action | Action | 是 | å¦ | é¼ æ ‡äº‹ä»¶åŠ¨ä½œ | +| screenX | number | 是 | å¦ | é¼ æ ‡å…‰æ ‡åœ¨å±å¹•ä¸çš„xåæ ‡ | +| screenY | number | 是 | å¦ | é¼ æ ‡å…‰æ ‡åœ¨å±å¹•ä¸çš„yåæ ‡ | +| windowX | number | 是 | å¦ | é¼ æ ‡å½’å±žçª—å£çš„xåæ ‡ | +| windowY | number | 是 | å¦ | é¼ æ ‡å½’å±žçª—å£çš„yåæ ‡ | +| rawDeltaX | number | 是 | å¦ | Xè½´ç›¸å¯¹ä¸Šæ¬¡ä¸ŠæŠ¥é¼ æ ‡ä½ç½®çš„å移,在å±å¹•è¾¹ç¼˜ä½ç½®æ—¶ï¼Œè¯¥å€¼å¯èƒ½å°äºŽä¸¤æ¬¡é¼ æ ‡ä¸ŠæŠ¥çš„åæ ‡å·® | +| rawDeltaY | number | 是 | å¦ | Yè½´ç›¸å¯¹ä¸Šæ¬¡ä¸ŠæŠ¥é¼ æ ‡ä½ç½®çš„å移 | +| button | Button | 是 | å¦ | 当å‰æŒ‰ä¸‹/抬起的按钮 | +| pressedButtons | Button[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按钮 | +| axes | AxisValue[] | 是 | å¦ | 事件包å«çš„æ‰€æœ‰è½´æ•°æ® | +| pressedKeys | KeyCode[] | 是 | å¦ | 当å‰å¤„于按下状æ€çš„按键列表 | +| ctrlKey | boolean | 是 | å¦ | 当å‰ctrlKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| altKey | boolean | 是 | å¦ | 当å‰altKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| shiftKey | boolean | 是 | å¦ | 当å‰shiftKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| logoKey | boolean | 是 | å¦ | 当å‰logoKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| fnKey | boolean | 是 | å¦ | 当å‰fnKey是å¦å¤„äºŽæŒ‰ä¸‹çŠ¶æ€ | +| capsLock | boolean | 是 | å¦ | 当å‰capsLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| numLock | boolean | 是 | å¦ | 当å‰numLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | +| scrollLock | boolean | 是 | å¦ | 当å‰scrollLock是å¦å¤„äºŽæ¿€æ´»çŠ¶æ€ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md index 4f07a3ff32c1bf2873b4ba4415d852ecd5be6f69..2e77f939b7aecb764479e398adec859ce0b0cc04 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcController.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcController.md @@ -3,7 +3,7 @@ 本模å—主è¦ç”¨äºŽæ“作åŠç®¡ç†NFC。 >  **说明:** -> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## **导入模å—** @@ -19,6 +19,8 @@ isNfcAvailable(): boolean 查询是å¦æœ‰NFC功能 +**系统能力**:SystemCapability.Communication.NFC.Core + **返回值:** | **类型** | **说明** | @@ -34,7 +36,7 @@ openNfc(): boolean **需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -50,7 +52,7 @@ closeNfc(): boolean **需è¦æƒé™**:ohos.permission.MANAGE_SECURE_SETTINGS -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -64,7 +66,7 @@ isNfcOpen(): boolean 查询NFC是å¦æ‰“开。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -78,7 +80,7 @@ getNfcState(): NfcState 查询NFC状æ€ã€‚ -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -92,7 +94,7 @@ on(type: "nfcStateChange", callback: Callback<NfcState>): void 注册NFC开关状æ€äº‹ä»¶ã€‚ -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **å‚æ•°** @@ -109,7 +111,7 @@ off(type: "nfcStateChange", callback?: Callback<NfcState>): void å–消NFC开关状æ€äº‹ä»¶çš„注册。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **å‚æ•°** @@ -140,6 +142,8 @@ off(type: "nfcStateChange", callback?: Callback<NfcState>): void 表示NFC状æ€çš„枚举。 +**系统能力**:SystemCapability.Communication.NFC.Core + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | STATE_OFF | 1 | NFCå…³é—çŠ¶æ€ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index 87fc40e6959e3da7907f5f70ab18f26893e13854..94550568a43da3bf71c1313b18d8a6a6cd1eafbd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -3,7 +3,7 @@ 本模å—主è¦ç”¨äºŽæ“作åŠç®¡ç†NFC Tag。 >  **说明:** -> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## **导入模å—** @@ -21,7 +21,7 @@ getNfcATag(tagInfo: TagInfo): NfcATag **需è¦æƒé™**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -37,7 +37,7 @@ getNfcBTag(tagInfo: TagInfo): NfcBTag **需è¦æƒé™**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -53,7 +53,7 @@ getNfcFTag(tagInfo: TagInfo): NfcFTag **需è¦æƒé™**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -69,10 +69,10 @@ getNfcVTag(tagInfo: TagInfo): NfcVTag **需è¦æƒé™**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | | -------- | ---------------- | -| NfcVTag | NFC V类型Tag对象 | \ No newline at end of file +| NfcVTag | NFC V类型Tag对象 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index 3684393fab272c6769669dd027498494fcd601cf..2288f0e23c7256f13c7a8daabd37d033ed1c9fd7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -2571,7 +2571,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle ## Notification.enableDistributedByBundle<sup>8+</sup> -bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void> +enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\<void> æ ¹æ®åº”用的包设置应用程åºæ˜¯å¦æ”¯æŒåˆ†å¸ƒå¼é€šçŸ¥ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -2897,7 +2897,7 @@ Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { ## Notification.enableNotificationSlot <sup>9+</sup> -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void +enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void è®¾å®šæŒ‡å®šç±»åž‹çš„æ¸ é“使能状æ€ï¼ˆCallbackå½¢å¼ï¼‰ã€‚ @@ -2905,6 +2905,8 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, ca **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -2924,14 +2926,14 @@ function enableSlotCallback(err) { Notification.enableNotificationSlot( { bundle: "ohos.samples.notification", }, - notify.SlotType.SOCIAL_COMMUNICATION, + Notification.SlotType.SOCIAL_COMMUNICATION, true, enableSlotCallback); ``` ## Notification.enableNotificationSlot <sup>9+</sup> -enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void> +enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> è®¾å®šæŒ‡å®šç±»åž‹çš„æ¸ é“使能状æ€ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -2939,6 +2941,8 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): P **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -2953,7 +2957,7 @@ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): P //enableNotificationSlot Notification.enableNotificationSlot( { bundle: "ohos.samples.notification", }, - notify.SlotType.SOCIAL_COMMUNICATION, + Notification.SlotType.SOCIAL_COMMUNICATION, true).then(() => { console.log('====================>enableNotificationSlot====================>'); }); @@ -2961,7 +2965,7 @@ Notification.enableNotificationSlot( ## Notification.isNotificationSlotEnabled <sup>9+</sup> -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback<boolean>): void +isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void 获å–æŒ‡å®šç±»åž‹çš„æ¸ é“使能状æ€ï¼ˆCallbackå½¢å¼ï¼‰ã€‚ @@ -2969,13 +2973,15 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------- | ---- | ---------------------- | | bundle | [BundleOption](#bundleoption) | 是 | 指定包信æ¯ã€‚ | | type | [SlotType](#slottype) | 是 | æŒ‡å®šæ¸ é“类型。 | -| callback | AsyncCallback\<void\> | 是 | è®¾å®šæ¸ é“使能回调函数。 | +| callback | AsyncCallback\<boolean\> | 是 | è®¾å®šæ¸ é“使能回调函数。 | **示例:** @@ -2987,13 +2993,13 @@ function getEnableSlotCallback(err, data) { Notification.isNotificationSlotEnabled( { bundle: "ohos.samples.notification", }, - notify.SlotType.SOCIAL_COMMUNICATION, + Notification.SlotType.SOCIAL_COMMUNICATION, getEnableSlotCallback); ``` ## Notification.isNotificationSlotEnabled <sup>9+</sup> -isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean> +isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\> 获å–æŒ‡å®šç±»åž‹çš„æ¸ é“使能状æ€ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ @@ -3001,6 +3007,8 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -3008,18 +3016,166 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise<boolean | bundle | [BundleOption](#bundleoption) | 是 | 指定包信æ¯ã€‚ | | type | [SlotType](#slottype) | 是 | æŒ‡å®šæ¸ é“类型。 | +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\<boolean\> | 以Promiseå½¢å¼è¿”å›žæŒ‡å®šç±»åž‹çš„æ¸ é“使能状æ€ã€‚ | + **示例:** ```js //isNotificationSlotEnabled Notification.isNotificationSlotEnabled( { bundle: "ohos.samples.notification", }, - notify.SlotType.SOCIAL_COMMUNICATION, - true).then((data) => { + Notification.SlotType.SOCIAL_COMMUNICATION + ).then((data) => { console.log('====================>isNotificationSlotEnabled====================>'); }); ``` + +## Notification.setSyncNotificationEnabledForUninstallApp<sup>9+</sup> + +setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void + +设置是å¦å°†é€šçŸ¥åŒæ¥åˆ°æœªå®‰è£…应用程åºçš„设备(callbackå½¢å¼)。 + +**系统能力**:SystemCapability.Notification.Notification + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| userId | number | 是 | 用户Id。 | +| enable | boolean | 是 | 是å¦å°†é€šçŸ¥åŒæ¥åˆ°æœªå®‰è£…应用程åºçš„设备。true:是。false:å¦ã€‚ | +| callback | AsyncCallback\<void\> | 是 | 设置是å¦å°†é€šçŸ¥åŒæ¥åˆ°æœªå®‰è£…应用程åºçš„设备的回调函数。 | + +**示例:** + +```js +let userId = 100; +let enable = true; + +function setSyncNotificationEnabledForUninstallAppCallback(err) { + console.log('setSyncNotificationEnabledForUninstallAppCallback'); +} + +Notification.setSyncNotificationEnabledForUninstallApp(userId, enable, setSyncNotificationEnabledForUninstallAppCallback); +``` + + +## Notification.setSyncNotificationEnabledForUninstallApp<sup>9+</sup> + +setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean): Promise\<void> + +设置是å¦å°†é€šçŸ¥åŒæ¥åˆ°æœªå®‰è£…应用程åºçš„设备(Promiseå½¢å¼)。 + +**系统能力**:SystemCapability.Notification.Notification + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| userId | number | 是 | 用户Id。 | +| enable | boolean | 是 | 是å¦å°†é€šçŸ¥åŒæ¥åˆ°æœªå®‰è£…应用程åºçš„设备。true:是。false:å¦ã€‚ | + +**示例:** + +```js +let userId = 100; +let enable = true; + +Notification.setSyncNotificationEnabledForUninstallApp(userId, enable) + .then((data) => { + console.log('setSyncNotificationEnabledForUninstallApp, data:', data); + }) + .catch((err) => { + console.log('setSyncNotificationEnabledForUninstallApp, err:', err); + }); +``` + + +## Notification.getSyncNotificationEnabledForUninstallApp<sup>9+</sup> + +getSyncNotificationEnabledForUninstallApp(userId: number, callback: AsyncCallback\<boolean>): void + +获å–是å¦åŒæ¥é€šçŸ¥åˆ°æœªå®‰è£…应用程åºçš„设备的结果(callbackå½¢å¼)。 + +**系统能力**:SystemCapability.Notification.Notification + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| userId | number | 是 | 用户Id。 | +| callback | AsyncCallback\<boolean\> | 是 | 获å–是å¦åŒæ¥é€šçŸ¥åˆ°æœªå®‰è£…应用程åºçš„设备的结果的回调函数。true:是。false:å¦ã€‚ | + +**示例:** + +```js +let userId = 100; + +function getSyncNotificationEnabledForUninstallAppCallback(err, data) { + console.log('getSyncNotificationEnabledForUninstallAppCallback, data: ', data); +} + +Notification.getSyncNotificationEnabledForUninstallApp(userId, getSyncNotificationEnabledForUninstallAppCallback); +``` + + +## Notification.getSyncNotificationEnabledForUninstallApp<sup>9+</sup> + +getSyncNotificationEnabledForUninstallApp(userId: number): Promise\<boolean> + +获å–是å¦åŒæ¥é€šçŸ¥åˆ°æœªå®‰è£…应用程åºçš„设备的结果(Promiseå½¢å¼)。 + +**系统能力**:SystemCapability.Notification.Notification + +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**需è¦æƒé™**:ohos.permission.NOTIFICATION_CONTROLLER + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| userId | number | 是 | 用户Id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\<boolean\> | 以Promiseå½¢å¼è¿”回获å–是å¦åŒæ¥é€šçŸ¥åˆ°æœªå®‰è£…应用程åºçš„设备的结果。true:是。false:å¦ã€‚ | + +**示例:** + +```js +let userId = 100; + +Notification.getSyncNotificationEnabledForUninstallApp(userId) + .then((data) => { + console.log('getSyncNotificationEnabledForUninstallApp, data: ', data); + }) + .catch((err) => { + console.log('getSyncNotificationEnabledForUninstallApp, err: ', err); + }); +``` + + + ## NotificationSubscriber **系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ @@ -3582,6 +3738,8 @@ Notification.subscribe(subscriber, subscribeCallback); | distributedOption<sup>8+</sup> | 是 | 是 | [DistributedOptions](#distributedoptions8) | å¦ | 分布å¼é€šçŸ¥çš„选项。 | | deviceId<sup>8+</sup> | 是 | å¦ | string | å¦ | 通知æºçš„deviceId。<br>**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | | notificationFlags<sup>8+</sup> | 是 | å¦ | [NotificationFlags](#notificationflags8) | å¦ | 获å–NotificationFlags。 | +| removalWantAgent<sup>9+</sup> | 是 | 是 | WantAgent | å¦ | 当移除通知时,通知将被é‡å®šå‘到的WantAgent实例。 | +| badgeNumber<sup>9+</sup> | 是 | 是 | number | å¦ | 应用程åºå›¾æ ‡ä¸Šæ˜¾ç¤ºçš„通知数。 | ## DistributedOptions<sup>8+</sup> diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 9582d405e98c3e59c78cc3da3feb1dcdcdd54751..ae0ade3187e9075470956d16854e688dadd0e1d7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -801,7 +801,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ---------- | --------------------------------------- | ---- | -------------------------------------------- | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | | callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域å¸å·å…³è”的系统å¸å·ID。 | **示例:** @@ -829,7 +829,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number& | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ---------- | --------------------------------------- | ---- | ------------ | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | **返回值:** @@ -1156,7 +1156,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ | | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统å¸å·çš„类型。 | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统å¸å·çš„ä¿¡æ¯ã€‚ | **示例:** @@ -1187,7 +1187,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ---------- | --------------------------------------- | ---- | ---------------------- | | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统å¸å·çš„类型。 | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是 | 域å¸å·ä¿¡æ¯ã€‚ | **返回值:** @@ -1912,6 +1912,1289 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis console.info("queryOsAccountConstraintSourceType sourceTypeInfos:" + JSON.stringify(sourceTypeInfos)); ``` +## UserAuth<sup>8+</sup> + +用户认è¯ç±»ã€‚ + +### constructor<sup>8+</sup> + +constructor() + +创建用户认è¯çš„实例。 + +**系统能力**:SystemCapability.Account.OsAccount + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + console.info('====>test for examples constructor success'); + ``` + + +### getVersion<sup>8+</sup> + +getVersion(): number; + +返回版本信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** + +| 类型 | 说明 | +| :----- | :----------- | +| number | 返回版本信æ¯ã€‚| + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + console.info('====>test for examples constructor success'); + var version = userAuth.getVersion(); + console.info('====>test for examples version is : ' + JSON.stringify(version)); + ``` + +### getAvailableStatus<sup>8+</sup> + +getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number; + +检查身份认è¯åŠŸèƒ½æ˜¯å¦å¯ç”¨ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -----------------------------------------------| ---- | ------------------------- | +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 指示用于认è¯çš„å‡æ®ç±»åž‹ã€‚ | +| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | 是 | 表示身份验è¯ç»“果的信任级别。 | + +**返回值:** + +| 类型 | 说明 | +| :----- | :---------------------------------------- | +| number | 返回验è¯[结果](#ResultCode<sup>8+</sup>)。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let authTrustLevel = osAccount.AuthTrustLevel.ATL1; + console.info('====>test for examples constructor success'); + let availableStatus = userAuth.getAvailableStatus(authType, authTrustLevel); + console.info('====>test for examples AvailabeStatus is : ' + JSON.stringify(availableStatus)); + ``` + +### getProperty<sup>8+</sup> + +getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProperty>): void; + +基于指定的请求信æ¯èŽ·å–属性,使用callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------------------- | ---- | ---------------------------------- | +| request | [GetPropertyRequest](#GetPropertyRequest<sup>8+</sup>) | 是 | 请求信æ¯ï¼ŒåŒ…括认è¯ç±»åž‹å’Œå±žæ€§ç±»åž‹åˆ—表。 | +| callback | AsyncCallback<[ExecutorProperty](#ExecutorProperty<sup>8+</sup>)> | 是 | 回调结果,返回的是调用者属性。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let keys = new Array(); + keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE; + keys[1] = osAccount.GetPropertyType.REMAIN_TIMES; + keys[2] = osAccount.GetPropertyType.FREEZING_TIME; + let getPropertyRequest = {authType, keys}; + userAuth.getProperty(getPropertyRequest,function (propReq) { + console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq)); + }) + ``` + +### getProperty<sup>8+</sup> + +getProperty(request: GetPropertyRequest): Promise<ExecutorProperty>; + +基于指定的请求信æ¯èŽ·å–属性,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------ | ---- | ---------------------------------- | +| request | [GetPropertyRequest](#GetPropertyRequest<sup>8+</sup>) | 是 | 请求信æ¯ï¼ŒåŒ…括认è¯ç±»åž‹å’Œå±žæ€§ç±»åž‹åˆ—表。 | + +**返回值:** + +| 类型 | 说明 | +| :---------------------------------------------------------------- | :-------------------------------------------------- | +| Promise<[ExecutorProperty](#ExecutorProperty<sup>8+</sup>)> | Promise实例,用于获å–异æ¥è¿”回结果,返回的是调用者属性。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let keys = new Array(); + keys[0] = osAccount.GetPropertyType.AUTH_SUB_TYPE; + keys[1] = osAccount.GetPropertyType.REMAIN_TIMES; + keys[2] = osAccount.GetPropertyType.FREEZING_TIME; + let getPropertyRequest = {authType, keys}; + userAuth.getProperty(getPropertyRequest).then((propReq) => { + console.log("====>test for examples getallAuthInfo AsyncCallback = " + JSON.stringify(propReq)); + }); + ``` + +### setProperty<sup>8+</sup> + +setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void; + +设置å¯ç”¨äºŽåˆå§‹åŒ–算法的属性,使用callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- | +| request | [SetPropertyRequest](#SetPropertyRequest<sup>8+</sup>)| 是 | 请求信æ¯ï¼ŒåŒ…括认è¯ç±»åž‹å’Œè¦è®¾ç½®çš„密钥值。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回一个[数值](#ResultCode<sup>8+</sup>),指示属性设置是å¦æˆåŠŸã€‚ | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let key = osAccount.SetPropertyType.INIT_ALGORITHM; + let setInfo = new Uint8Array(); + let setPropertyRequest = {authType, key, setInfo}; + userAuth.setProperty(setPropertyRequest,function (setProp) { + console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp)); + }); + ``` + +### setProperty<sup>8+</sup> + +setProperty(request: SetPropertyRequest): Promise<number>; + +设置å¯ç”¨äºŽåˆå§‹åŒ–算法的属性,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------ | ---- | ---------------------------------------- | +| request | [SetPropertyRequest](#SetPropertyRequest<sup>8+</sup>) | 是 | 请求信æ¯ï¼ŒåŒ…括身份验è¯ç±»åž‹å’Œè¦è®¾ç½®çš„密钥值。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------------------------------------------------------------------------------- | +| Promise<number> | Promise实例,用于获å–异æ¥è¿”回结果,返回一个[数值](#ResultCode<sup>8+</sup>),指示属性设置是å¦æˆåŠŸã€‚ | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let key = osAccount.SetPropertyType.INIT_ALGORITHM; + let setInfo = new Uint8Array(); + let setPropertyRequest = {authType, key, setInfo}; + userAuth.setProperty(setPropertyRequest).then((setProp) => { + console.log("====>test for examples setProperty AsyncCallback = " + JSON.stringify(setProp)); + }); + ``` + +### auth<sup>8+</sup> + +auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; + +执行认è¯ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ---------------------------------------------------- | --- | ------------------------------------ | +| challenge | Uint8Array | 是 | 指示挑战值,挑战值为一个éšæœºæ•°ï¼Œç”¨äºŽæå‡å®‰å…¨æ€§ã€‚| +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 指示认è¯ç±»åž‹ã€‚ | +| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | 是 | 指示认è¯ç»“果的信任级别。 | +| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | 是 | 回调结果,返回的是结果和所获å–çš„ä¿¡æ¯ã€‚ | + + +**返回值:** + +| 类型 | 说明 | +| :--------- | :----------------- | +| Uint8Array | 返回å–消的上下文ID。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let challenge = 1; + let authTrustLevel = osAccount.AuthTrustLevel.ATL1; + let onresult = { + authresult: null, + authextr: null, + } + userAuth.auth(challenge, authType,authTrustLevel,{ + onResult: function(result,extraInfo){ + console.log("====>test for examples auth result = " + result); + onresult.authresult = result; + console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo)); + onresult.authextr = extraInfo; + console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult)); + } + }); + ``` + +### authUser<sup>8+</sup> + +authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array; + +执行用户认è¯ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ---------------------------------------------------- | --- | ------------------------------------ | +| userId | number | 是 | 指示用户身份。 | +| challenge | Uint8Array | 是 | 指示挑战值,挑战值为一个éšæœºæ•°ï¼Œç”¨äºŽæå‡å®‰å…¨æ€§ã€‚ | +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 指示认è¯ç±»åž‹ã€‚ | +| authTrustLevel | [AuthTrustLevel](#AuthTrustLevel<sup>8+</sup>) | 是 | 指示认è¯ç»“果的信任级别。 | +| callback | [IUserAuthCallback](#IUserAuthCallback<sup>8+</sup>) | 是 | 回调结果,返回的是结果和所获å–çš„ä¿¡æ¯ã€‚ | + + +**返回值:** + +| 类型 | 说明 | +| :--------- | :----------------- | +| Uint8Array | 返回å–消的上下文ID。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let challenge = 1; + let authTrustLevel = osAccount.AuthTrustLevel.ATL1; + let userID = 100; + let onresult = { + authresult: null, + authextr: null, + } + userAuth.authUser(userID, challenge, authType, authTrustLevel, { + onResult: function(result,extraInfo){ + console.log("====>test for examples authUser result = " + result); + onresult.authresult = result; + console.log("====>test for examples authUser extraInfo = " + JSON.stringify(extraInfo)); + onresult.authextr = extraInfo; + console.info('====>test for examples authUser onResult = ' + JSON.stringify(onresult)); + } + }); + ``` + +### cancelAuth<sup>8+</sup> + +cancelAuth(contextID: Uint8Array): number; + +å–消特定的认è¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_USER_AUTH_INTERNAL + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------| ---------- | ---- | ------------------------------------------ | +| contextID | Uint8Array | 是 | 指示身份验è¯ä¸Šä¸‹æ–‡ID,æ¤ID动æ€ç”Ÿæˆæ²¡æœ‰å…·ä½“值。 | + +**返回值:** + +| 类型 | 说明 | +| :----- | :-------------------------------------------------------- | +| number | 返回一个[æ•°å—](#ResultCode<sup>8+</sup>),指示å–消是å¦æˆåŠŸã€‚ | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let contextID = null; + let cancelAuthresult = null; + cancelAuthresult = userAuth.cancelAuth(contextID); + console.log("====>test for examples cancelAuthresult result = " + JSON.stringify(cancelAuthresult)); + ``` + +## PINAuth<sup>8+</sup> + +Pinç 认è¯åŠŸèƒ½åŸºç±»ã€‚ + +### constructor<sup>8+</sup> + +constructor() + +创建Pinç 认è¯çš„实例。 + +**系统能力**:SystemCapability.Account.OsAccount + +**示例:** + ```js + var pinAuth = new osAccount.PINAuth(); + console.info('====>test for examples constructor success'); + ``` + +### registerInputer + +registerInputer(inputer: IInputer): boolean; + +注册输入器。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_PIN_AUTH + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------| ----------------------------------- | --- | ------------------ | +| inputer | [IInputer](#IInputer<sup>8+</sup>) | 是 | 指示密ç 输入框回调。 | + +**返回值:** + +| 类型 | 说明 | +| :------ | :-------------------------------------------- | +| boolean | 返回布尔值,true表示注册æˆåŠŸï¼Œfalse表示注册失败。 | + +**示例:** + ```js + var pinAuth = new osAccount.PINAuth(); + var GetAuthSubType = 0; + var AuthSubType = osAccount.AuthSubType.PIN_SIX; + var Inputerdata = [0,1,3]; + var registerresult = pinAuth.registerInputer({ + onGetData: (GetAuthSubType, IInputData) => { + if (GetAuthSubType == 0) { + IInputData.onSetData(AuthSubType, Inputerdata) + } else { + IInputData.onSetData(GetAuthSubType, Inputerdata); + } + } + }) + console.log("====>test for examples RegisterInputer result is: " + registerresult); + ``` + +### unregisterInputer + +unregisterInputer(): void; + +å¸è½½è¾“入器。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.ACCESS_PIN_AUTH + +**示例:** + ```js + var pinAuth = new osAccount.PinAuth(); + pinAuth.unregisterInputer(); + ``` + +## UserIdentityManager<sup>8+</sup> + +获å–用户身份管ç†ç±»ã€‚ + +### constructor<sup>8+</sup> + +constructor() + +创建用户认è¯çš„实例。 + +**系统能力**:SystemCapability.Account.OsAccount + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + console.info('====>test for examples constructor success'); + ``` + +### openSession<sup>8+</sup> + +openSession(callback: AsyncCallback<Uint8Array>): void; + +打开会è¯ï¼Œå¯åŠ¨IDMæ“作以获å–挑战值,使用callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<Uint8Array> | 是 | 回调结果,返回的是挑战值,éž0å³æˆåŠŸï¼Œä¸º0则失败。| + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + var challenge; + userIDM.openSession(function(err, data){ + try{ + console.log("====>test for examples before get challenge"); + console.log("====>test for examples + " + data); + challenge = data; + console.log("====>test for examples end "); + console.log("====>test for examples after get challenge"); + } + catch(e) { + console.info('====>test for examples openSession error = ' + JSON.stringify(e)); + } + }); + ``` + +### openSession<sup>8+</sup> + +openSession(): Promise<Uint8Array>; + +打开会è¯ï¼Œå¯åŠ¨IDMæ“作以获å–挑战值,使用Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**返回值:** + +| 类型 | 说明 | +| :------------------------ | :------------------------------------------------------- | +| Promise<Uint8Array> | Promise实例,用于获å–异æ¥è¿”回结果,返回的是挑战值,éž0å³æˆåŠŸï¼Œä¸º0则失败。| + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + var challenge; + userIDM.openSession().then((data) => { + try{ + console.log("====>test for examples before get challenge"); + console.log("====>test for examples + " + data); + challenge = data; + console.log("====>test for examples end "); + console.log("====>test for examples after get challenge"); + } + catch(err) { + console.info('====>test for examples faceDemo openSession error1 = ' + JSON.stringify(err)); + } + }) + .catch((err) => { + console.info('====>test for examples faceDemo openSession error2 = ' + JSON.stringify(err)); + }) + ``` + +### addCredential<sup>8+</sup> + +addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; + +æ·»åŠ å‡æ®ï¼Œæ·»åŠ 用户å‡æ®ä¿¡æ¯ï¼Œä¼ å…¥å‡æ®æ·»åŠ 方法和å‡æ®ä¿¡æ¯ï¼ˆå‡æ®ç±»åž‹ï¼Œåç±»ï¼Œå¦‚æžœæ·»åŠ ç”¨æˆ·çš„éžå¯†ç å‡æ®ï¼Œåˆ™ä¼ 入密ç 身份验è¯ä»¤ç‰Œï¼‰ï¼Œå¹¶èŽ·å–结果/获å–ä¿¡æ¯ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ------------------------------------------------ | --- | -------------------------------- | +| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | 是 | 指示å‡æ®ä¿¡æ¯ã€‚ | +| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | 是 | 回调结果,返回的是结果和获å–ä¿¡æ¯ã€‚ | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let CredentialInfo = null; + let onresult = { + addCredresult: null, + credentialId: null, + } + userIDM.addCredential(CredentialInfo, { + onResult: function(result,extraInfo){ + console.info('====>test for examples aaaaaaaaaaaaa'); + console.info("====>test for examples addCredential result = " + result); + console.info("====>test for examples addCredential extraInfo = " + JSON.stringify(extraInfo)); + console.log(result) + onresult.addCredresult= result; + if(extraInfo != undefined) { + onresult.credentialId = extraInfo.credentialId + } else { + onresult.credentialId = null; + } + } + }) + ``` + +### updateCredential<sup>8+</sup> + +updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void; + +æ›´æ–°å‡æ®ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ------------------------------------------------- | --- | -------------------------------- | +| credentialInfo | [CredentialInfo](#CredentialInfo<sup>8+</sup>) | 是 | 指示å‡æ®ä¿¡æ¯ã€‚ | +| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | 是 | 回调结果,返回的是结果和获å–ä¿¡æ¯ã€‚ | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let CredentialInfo = null; + let onresult = { + addCredresult: null, + credentialId: null, + } + userIDM.updateCredential(CredentialInfo, { + onResult: function(result,extraInfo){ + console.log("====>test for examples faceDemo updateCredential result = " + result) + onresult.updateCredresult = result + console.log("====>test for examples faceDemo updateCredential credentialId = " + extraInfo.credentialId) + if(extraInfo != undefined) { + onresult.CredentialId = extraInfo.credentialId + } else { + onresult.CredentialId = null; + } + console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult)); + } + }) + ``` + +### closeSession<sup>8+</sup> + +closeSession(): void; + +å…³é—会è¯ï¼Œç»“æŸIDMæ“作 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + userIDM.closeSession(); + ``` + +### cancel<sup>8+</sup> + +cancel(challenge: Uint8Array): number; + +æ ¹æ®æŒ‘战值å–消æ¡ç›®ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------- | ---- | ----- | +| challenge | Uint8Array | 是 | 挑战值。 | + +**返回值:** + +| 类型 | 说明 | +| :----- | :-------------------------------------------------------- | +| number | 返回一个[æ•°å—](#ResultCode<sup>8+</sup>),指示å–消是å¦æˆåŠŸã€‚ | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let challenge = 1; + let cancelresult = userIDM.cancel(challenge); + ``` + +### delUser<sup>8+</sup> + +delUser(token: Uint8Array, callback: IIdmCallback): void; + +åˆ é™¤å…·æœ‰èº«ä»½éªŒè¯ä»¤ç‰Œçš„用户,使用callbackæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------ | --- | ------------------------- | +| token | Uint8Array | 是 | 身份验è¯ä»¤ç‰Œã€‚ | +| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | 是 | å›žè°ƒç»“æžœï¼Œè¿”å›žçš„æ˜¯åˆ é™¤ç»“æžœã€‚| + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let onresult = { + delUserresult: null, + CredentialId: null, + } + let token = null; + userIDM.delUser(token, { + onResult: function(result,extraInfo){ + console.log("====>test for examples delUser result = " + result) + onresult.delUserresult = result + if(extraInfo != undefined) { + onresult.CredentialId = extraInfo.credentialId + } else { + onresult.CredentialId = null; + } + console.info('====>test for examples publicdelUser delUser = ' + JSON.stringify(onresult)); + } + }) + ``` + +### delCred<sup>8+</sup> + +delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void; + +åˆ é™¤ç”¨æˆ·å‡æ®ä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ----------------------------------------------- | --- | ---------------------------| +| credentialId | Uint8Array | 是 | å‡è¯ç´¢å¼•ã€‚ | +| token | Uint8Array | 是 | 身份验è¯ä»¤ç‰Œã€‚ | +| callback | [IIdmCallback](#IIdmCallback<sup>8+</sup>) | 是 | å›žè°ƒç»“æžœï¼Œè¿”å›žçš„æ˜¯åˆ é™¤ç»“æžœã€‚ | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let onresult = { + delUserresult: null, + CredentialId: null, + } + let credentialId = 1; + let token = null; + userIDM.delCred(credentialId, token,{ + onResult: function(result,extraInfo){ + console.log("====>test for examples delCred result = " + result) + onresult.delCredresult = result + console.log("====>test for examples delCred extraInfo = " + extraInfo) + if(extraInfo != undefined) { + onresult.CredentialId = extraInfo.credentialId + } else { + onresult.CredentialId = null; + } + console.log("====>test for examples delCred onresult = " + JSON.stringify(onresult)); + } + }) + ``` + +### getAuthInfo<sup>8+</sup> + +getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>, authType?: AuthType): void; + +获å–认è¯ä¿¡æ¯ï¼Œä½¿ç”¨callback回调异æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- | +| callback | AsyncCallback<Array<[EnrolledCredInfo](#EnrolledCredInfo<sup>8+</sup>)>> | 是 | 回调结果,返回的是当å‰ç”¨æˆ·æŒ‡å®šç±»åž‹çš„所有已注册å‡æ®ä¿¡æ¯ã€‚| +| authType | [AuthType](#AuthType<sup>8+</sup>) | å¦ | 认è¯ç±»åž‹ã€‚ | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + var authType = osAccount.AuthType.PIN; + userIDM.getAuthInfo(authType, function (authInfo) { + console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo)) + }) + ``` + +### getAuthInfo<sup>8+</sup> + +getAuthInfo(authType?: AuthType): Promise<Array<EnrolledCredInfo>>; + +获å–认è¯ä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼å¼‚æ¥è¿”回结果。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_USER_IDM + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | -------- | +| authType | [AuthType](#AuthType<sup>8+</sup>) | å¦ | 认è¯ç±»åž‹ã€‚| + +**返回值:** + +| 类型 | 说明 | +| :------------------------------------------- | :------------------------------------------------------------------------ | +| Promise<Array<[EnrolledCredInfo](#EnrolledCredInfo<sup>8+</sup>)>> | Promise实例,用于获å–异æ¥è¿”回结果,返回的是当å‰ç”¨æˆ·æŒ‡å®šç±»åž‹çš„所有已注册å‡æ®ä¿¡æ¯ã€‚| + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + var authType = osAccount.AuthType.PIN; + userIDM.getAuthInfo(authType).then((authInfo) => { + console.log("====>test for examples getAuthInfo AsyncCallback = " + JSON.stringify(authInfo)) + }) + ``` + +## IInputData<sup>8+</sup> + +密ç æ•°æ®å›žè°ƒã€‚ + +### onSetData<sup>8+</sup> + +onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void; + +通知设置数æ®ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- | +| pinSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | 是 | 用于认è¯çš„å‡æ®å类型。 | +| data | Uint8Array | 是 | è¦è®¾ç½®çš„æ•°æ®æ˜¯å‡æ®ï¼Œç”¨æ¥åœ¨è®¤è¯ã€æ·»åŠ ã€ä¿®æ”¹å‡æ®æ“作。 | + +**示例:** + ```js + console.log("====>test for examples onCreate start "); + var pinAuth = new osAccount.PINAuth(); + var GetAuthSubType = 0; + var AuthSubType = osAccount.AuthSubType.PIN_SIX; + console.log("====>test for examples GetAuthSubType " + GetAuthSubType); + console.log("====>test for examples AuthSubType " + AuthSubType); + var Inputerdata = [0,1,3]; + var registerresult = pinAuth.registerInputer({ + onGetData: (GetAuthSubType, IInputData) => { + console.log("====>test for examples by GetAuthSubType " +GetAuthSubType ); + if (GetAuthSubType == 0) { + console.log("====>test for examples GetAuthSubType == 0 "); + IInputData.onSetData(AuthSubType, Inputerdata) + } else { + console.log("====>test for examples GetAuthSubType == 1 "); + IInputData.onSetData(GetAuthSubType, Inputerdata); + } + } + }) + console.log("====>test for examples RegisterInputer result is: " + registerresult); + ``` + +## IInputer<sup>8+</sup> + +密ç 输入框回调。 + +### onGetData<sup>8+</sup> + +onGetData: (callback: IInputData) => void; + +通知获å–æ•°æ®ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | --------------------------------------- | ---- | --------------- | +| callback | [IInputData](#IInputData<sup>8+</sup>) | 是 | 指示密ç æ•°æ®å›žè°ƒã€‚| + +**示例:** + ```js + console.log("====>test for examples onCreate start "); + var pinAuth = new osAccount.PINAuth(); + var GetAuthSubType = 0; + var AuthSubType = osAccount.AuthSubType.PIN_SIX; + console.log("====>test for examples GetAuthSubType " + GetAuthSubType); + console.log("====>test for examples AuthSubType " + AuthSubType); + var Inputerdata = [0,1,3]; + var registerresult = pinAuth.registerInputer({ + onGetData: (GetAuthSubType, IInputData) => { + console.log("====>test for examples by GetAuthSubType " +GetAuthSubType ); + if (GetAuthSubType == 0) { + console.log("====>test for examples GetAuthSubType == 0 "); + IInputData.onSetData(AuthSubType, Inputerdata) + } else { + console.log("====>test for examples GetAuthSubType == 1 "); + IInputData.onSetData(GetAuthSubType, Inputerdata); + } + } + }) + console.log("====>test for examples RegisterInputer result is: " + registerresult); + ``` + +## IUserAuthCallback<sup>8+</sup> + +用户认è¯å›žè°ƒã€‚ + +### onResult<sup>8+</sup> + +onResult: (result: number, extraInfo: AuthResult) => void; + +身份认è¯ç»“果代ç 通过回调返回。 + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | ------------------- | +| result | number | 是 | 表示身份认è¯ç»“果代ç 。| +| extraInfo | [AuthResult](#AuthResult<sup>8+</sup>) | 是 | 表示ä¸åŒæƒ…况下的具体信æ¯ï¼Œå¦‚果认è¯é€šè¿‡ï¼Œåˆ™åœ¨extrainfoä¸è¿”回认è¯ä»¤ç‰Œï¼Œå¦‚果身份验è¯å¤±è´¥ï¼Œåˆ™åœ¨extrainfoä¸è¿”回剩余的身份验è¯æ—¶é—´ï¼Œå¦‚果身份验è¯æ‰§è¡Œå™¨è¢«é”定,冻结时间将在extrainfoä¸è¿”回。| + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let challenge = 1; + let authTrustLevel = osAccount.AuthTrustLevel.ATL1; + let onresult = { + authresult: null, + authextr: null, + } + userAuth.auth(challenge, authType,authTrustLevel,{ + onResult: function(result,extraInfo){ + console.log("====>test for examples auth result = " + result); + onresult.authresult = result; + console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo)); + onresult.authextr = extraInfo; + console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult)); + } + }); + ``` + +### onAcquireInfo?<sup>8+</sup> + +onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; + +在身份验è¯æœŸé—´ï¼ŒTipsCode通过回调返回。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------- | ---- | ----------------------------- | +| module | number | 是 | 指示用于身份验è¯çš„执行器类型。 | +| acquire | number | 是 | 指示ä¸åŒèº«ä»½éªŒè¯æ‰§è¡Œå™¨çš„tip代ç 。| +| extraInfo | any | 是 | ä¿ç•™å‚数。 | + +**示例:** + ```js + let userAuth = new osAccount.UserAuth(); + let authType = osAccount.AuthType.PIN; + let challenge = 1; + let authTrustLevel = osAccount.AuthTrustLevel.ATL1; + let onresult = { + authresult: null, + authextr: null, + } + let onacquireinfo = { + authmodule : null, + authacquire : null, + authextr : null + } + userAuth.auth(challenge, authType,authTrustLevel,{ + onResult: function(result,extraInfo){ + console.log("====>test for examples auth result = " + result) + onresult.authresult = result + console.log("====>test for examples auth extraInfo = " + JSON.stringify(extraInfo)); + onresult.authextr = extraInfo; + console.info('====>test for examples auth onResult = ' + JSON.stringify(onresult)); + }, + onAcquireInfo:function (modulea,acquire,extr){ + console.info('====>test for examples publicauth auth onAcquireInfo in'); + onacquireinfo.authmodule = modulea; + onacquireinfo.authacquire = acquire; + onacquireinfo.authextr = extr; + console.log("====>test for examples auth module = " + JSON.stringify(modulea)); + console.info('====>test for examples publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo)); + } + }); + ``` + +## IIdmCallback<sup>8+</sup> + +身份管ç†å›žè°ƒã€‚ + +### onResult<sup>8+</sup> + +onResult: (result: number, extraInfo: AuthResult) => void; + +身份认è¯ç»“果代ç 通过回调返回。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------------------------------------- | ---- | ----------------------- | +| result | number | 是 | 表示身份认è¯ç»“果代ç 。 | +| extraInfo | [AuthResult](#AuthResult<sup>8+</sup>) | 是 | 针对ä¸åŒæƒ…å†µä¼ é€’å…·ä½“ä¿¡æ¯ã€‚| + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let CredentialInfo = null; + let onresult = { + addCredresult: null, + credentialId: null, + } + userIDM.updateCredential(CredentialInfo, { + onResult: function(result,extraInfo){ + console.log("====>test for examples updateCredential result = " + result) + onresult.updateCredresult = result + console.log("====>test for examples updateCredential credentialId = " + extraInfo.credentialId) + if(extraInfo != undefined) { + onresult.CredentialId = extraInfo.credentialId + } else { + onresult.CredentialId = null; + } + console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult)); + } + }) + ``` + +### onAcquireInfo?<sup>8+</sup> + +onAcquireInfo?: (module: number, acquire: number, extraInfo: any) => void; + +在身份验è¯æœŸé—´ï¼ŒTipsCode通过回调返回。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.Account.OsAccount + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------- | ---- | ----------------------------- | +| module | number | 是 | 指示用于身份验è¯çš„执行器类型。 | +| acquire | number | 是 | 指示ä¸åŒèº«ä»½éªŒè¯æ‰§è¡Œå™¨çš„tip代ç 。| +| extraInfo | any | 是 | ä¿ç•™å‚数。 | + +**示例:** + ```js + var userIDM = new osAccount.UserIdentityManager(); + let CredentialInfo = null; + let onresult = { + addCredresult: null, + credentialId: null, + } + let onacquireinfo = { + updateCredmodule : null, + updateCredacquire : null, + updateCredextr : null + } + userIDM.updateCredential(CredentialInfo, { + onResult: function(result,extraInfo){ + console.log("====>test for examples updateCredential result = " + result) + onresult.updateCredresult = result + console.log("====>test for examples updateCredential credentialId = " + extraInfo.credentialId) + if(extraInfo != undefined) { + onresult.CredentialId = extraInfo.credentialId + } else { + onresult.CredentialId = null; + } + console.info('====>test for examples publicupdateCred updateCredential onResult = ' + JSON.stringify(onresult)); + }, + onAcquireInfo:function (modulea,acquire,extr){ + console.info('====>test for examples publicupdateCred updateCredential onAcquireInfo in '); + onacquireinfo.updateCredmodule = modulea + onacquireinfo.updateCredacquire = acquire + onacquireinfo.updateCredextr = extr + console.info('====>test for examples updateCredential onacquireinfo = ' + JSON.stringify(onacquireinfo)); + console.log("====>test for examples updateCredential module = " + modulea) + } + }) + ``` + +## GetPropertyRequest<sup>8+</sup> + +æ供获å–属性请求的信æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------- | ----- | ----------------------- | +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 身份验è¯å‡æ®ç±»åž‹ã€‚ | +| keys | Array<[GetPropertyType](#GetPropertyType<sup>8+</sup>)> | 是 | 指示è¦èŽ·å–的属性类型数组。 | + +## SetPropertyRequest<sup>8+</sup> + +æ供设置属性请求的信æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------ | ----- | -------------------- | +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 身份验è¯å‡æ®ç±»åž‹ã€‚ | +| keys | [SetPropertyType](#SetPropertyType<sup>8+</sup>) | 是 | 指示è¦è®¾ç½®çš„属性类型。 | +| setInfo | Uint8Array | 是 | 指示è¦è®¾ç½®çš„ä¿¡æ¯ã€‚ | + +## ExecutorProperty<sup>8+</sup> + +æ供执行器的属性。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------ | ---------------------------------------- | ----- | ----------------- | +| result | number | 是 | 指示结果。 | +| authSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | 是 | 指示认è¯å‡æ®å类型。| +| remainTimes | number | å¦ | 指示剩余时间。 | +| freezingTime | number | å¦ | 指示冻结时间。 | + +## AuthResult<sup>8+</sup> + +指示认è¯ç»“果的信æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------ | ----------- | ----- | ----------------- | +| token | Uint8Array | å¦ | 指示认è¯ä»¤ç‰Œã€‚ | +| remainTimes | number | å¦ | 指示剩余时间。 | +| freezingTime | number | å¦ | 指示冻结时间。 | + +## CredentialInfo<sup>8+</sup> + +指示å‡è¯ä¿¡æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------ | ---------------------------------------- | ----- | ----------------- | +| credType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 指示å‡æ®ç±»åž‹ã€‚ | +| credSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | 是 | 指示å‡æ®å类型。 | +| token | Uint8Array | 是 | 指示认è¯ä»¤ç‰Œã€‚ | + +## RequestResult<sup>8+</sup> + +指示请求结果的信æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------ | ----------- | ----- | ----------------- | +| credentialId | Uint8Array | å¦ | 指示å‡æ®ç´¢å¼•ã€‚ | + +## EnrolledCredInfo<sup>8+</sup> + +指示已注册å‡æ®çš„ä¿¡æ¯ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------ | ---------------------------------------- | ----- | ------------------- | +| credentialId | Uint8Array | 是 | 指示å‡æ®ç´¢å¼•ã€‚ | +| authType | [AuthType](#AuthType<sup>8+</sup>) | 是 | 指示认è¯å‡æ®ç±»åž‹ã€‚ | +| authSubType | [AuthSubType](#AuthSubType<sup>8+</sup>) | 是 | 指示认è¯å‡æ®å类型。 | +| templateId | Uint8Array | 是 | 指示å‡æ®æ¨¡æ¿ID。 | + +## GetPropertyType<sup>8+</sup> + +枚举,指示è¦èŽ·å–的属性类型。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ------------- | ------ | --------- | +| AUTH_SUB_TYPE | 1 | 认è¯å类型。 | +| REMAIN_TIMES | 2 | 剩余时间。 | +| FREEZING_TIME | 3 | 冻结时间。 | + +## SetPropertyType<sup>8+</sup> + +枚举,指示è¦è®¾ç½®çš„属性类型。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| -------------- | ----- | ----------- | +| INIT_ALGORITHM | 1 | åˆå§‹åŒ–算法。 | + +## AuthType<sup>8+</sup> + +枚举,指示身份验è¯çš„å‡æ®ç±»åž‹ã€‚ + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ----- | ----- | ---------------- | +| PIN | 1 | 指示PIN认è¯ç±»åž‹ã€‚ | +| FACE | 2 | 指示脸部认è¯ç±»åž‹ã€‚| + +## AuthSubType<sup>8+</sup> + +枚举,指示用于认è¯çš„å‡æ®å类型。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ---------- | ----- | ------------------ | +| PIN_SIX | 10000 | 表示6ä½å‡è¯ã€‚ | +| PIN_NUMBER | 10001 | 表示自定义数å—å‡è¯ã€‚ | +| PIN_MIXED | 10002 | 表示自定义混åˆå‡æ®ã€‚ | +| FACE_2D | 20000 | 指示2D 人脸å‡è¯ã€‚ | +| FACE_3D | 20001 | 指示3D 人脸å‡è¯ã€‚ | + +## AuthTrustLevel<sup>8+</sup> + +枚举,指示认è¯ç»“果的å—信任级别。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ---- | ------ | ----------- | +| ATL1 | 10000 | 信任级别 1。 | +| ATL2 | 20000 | 信任级别 2。 | +| ATL3 | 30000 | 信任级别 3。 | +| ATL4 | 40000 | 信任级别 4。 | + +## Module<sup>8+</sup> + +枚举,表示获å–ä¿¡æ¯çš„模å—。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| --------- | ------ | ------------------------ | +| FACE_AUTH | 1 | 表示从人脸认è¯èŽ·å–çš„ä¿¡æ¯ã€‚ | + +## ResultCode<sup>8+</sup> + +枚举,指示身份验è¯ç»“果代ç 。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ----------------------- | ----- | ---------------------------------------- | +| SUCCESS | 0 | 表示身份验è¯æˆåŠŸæˆ–支æŒæ¤åŠŸèƒ½ã€‚ | +| FAIL | 1 | 表示验è¯å™¨æ— 法识别用户。 | +| GENERAL_ERROR | 2 | 表示其他错误。 | +| CANCELED | 3 | 表示身份验è¯å·²å–消。 | +| TIMEOUT | 4 | 表示身份验è¯å·²è¶…时。 | +| TYPE_NOT_SUPPORT | 5 | 表示ä¸æ”¯æŒæ¤èº«ä»½éªŒè¯ç±»åž‹ã€‚ | +| TRUST_LEVEL_NOT_SUPPORT | 6 | 表示ä¸æ”¯æŒèº«ä»½éªŒè¯ä¿¡ä»»çº§åˆ«ã€‚ | +| BUSY | 7 | 表示身份验è¯ä»»åŠ¡æ£å¿™ã€‚ç‰å¾…å‡ ç§’é’Ÿï¼Œç„¶åŽé‡è¯•ã€‚ | +| INVALID_PARAMETERS | 8 | 表示å‚æ•°ä¸æ£ç¡®ã€‚ | +| LOCKED | 9 | 指示身份验è¯å™¨å·²é”定。 | +| NOT_ENROLLED | 10 | 表示用户尚未注册验è¯å™¨ã€‚ | + +## FaceTipsCode<sup>8+</sup> + +枚举,指示人脸验è¯è¿‡ç¨‹ä¸æ示代ç 。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ----------------------------- | ----- | ---------------------------------------- | +| FACE_AUTH_TIP_TOO_BRIGHT | 1 | 表示由于高照明,获得的é¢éƒ¨å›¾åƒå¤ªäº®ã€‚ | +| FACE_AUTH_TIP_TOO_DARK | 2 | 表示由于照明度低,获得的é¢éƒ¨å›¾åƒå¤ªæš—。 | +| FACE_AUTH_TIP_TOO_CLOSE | 3 | 表示é¢éƒ¨ç¦»è®¾å¤‡å¤ªè¿‘。 | +| FACE_AUTH_TIP_TOO_FAR | 4 | 表示é¢éƒ¨ç¦»è®¾å¤‡å¤ªè¿œã€‚ | +| FACE_AUTH_TIP_TOO_HIGH | 5 | 表示设备太高,仅æ•æ‰é¢éƒ¨ä¸Šéƒ¨ã€‚ | +| FACE_AUTH_TIP_TOO_LOW | 6 | 表示设备太低,仅æ•æ‰é¢éƒ¨ä¸‹éƒ¨ã€‚ | +| FACE_AUTH_TIP_TOO_RIGHT | 7 | 指示设备å‘å³å移,并且仅æ•æ‰é¢éƒ¨çš„å³ä¾§éƒ¨åˆ†ã€‚ | +| FACE_AUTH_TIP_TOO_LEFT | 8 | 指示设备å‘å·¦å移,并且仅æ•æ‰é¢éƒ¨çš„左侧部分。 | +| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9 | 表示é¢éƒ¨ä¿¡æ¯æ”¶é›†è¿‡ç¨‹ä¸é¢éƒ¨ç§»åŠ¨è¿‡å¿«ã€‚ | +| FACE_AUTH_TIP_POOR_GAZE | 10 | 表示é¢æœªæœå‘设备。 | +| FACE_AUTH_TIP_NOT_DETECTED | 11 | 表示未检测到人脸。 | + +## ingerprintTips<sup>8+</sup> + +枚举,指示指纹身份验è¯è¿‡ç¨‹ä¸æ示代ç 。 + +**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount + +| å‚æ•° | 默认值 | 说明 | +| ----------------------------- | ----- | ----------------------------------------------- | +| FINGERPRINT_TIP_GOOD | 0 | 表明采集的图åƒè‰¯å¥½ã€‚ | +| FINGERPRINT_TIP_IMAGER_DIRTY | 1 | è¡¨ç¤ºç”±äºŽä¼ æ„Ÿå™¨ä¸Šå¯ç–‘或检测到污垢,指纹图åƒå™ªå£°è¿‡å¤§ã€‚ | +| FINGERPRINT_TIP_INSUFFICIENT | 2 | 表示由于检测到的情况,指纹图åƒå™ªå£°å¤ªå¤§ï¼Œæ— 法处ç†ã€‚ | +| FINGERPRINT_TIP_PARTIAL | 3 | 指示仅检测到部分指纹图åƒã€‚ | +| FINGERPRINT_TIP_TOO_FAST | 4 | 表示指纹图åƒç”±äºŽå¿«é€Ÿè¿åŠ¨è€Œä¸å®Œæ•´ã€‚ | +| FINGERPRINT_TIP_TOO_SLOW | 5 | 表示由于缺少è¿åŠ¨ï¼ŒæŒ‡çº¹å›¾åƒæ— 法读å–。 | + ## OsAccountInfo 系统å¸å·ä¿¡æ¯ã€‚ @@ -1932,7 +3215,7 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis | isActived<sup>8+</sup> | boolean | 是 | 系统å¸å·æ¿€æ´»çŠ¶æ€ | | isCreateCompleted<sup>8+</sup> | boolean | 是 | 系统å¸å·åˆ›å»ºæ˜¯å¦å®Œæ•´ | | distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | å¦ | 分布å¼å¸å·ä¿¡æ¯ | -| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo) | å¦ | 域å¸å·ä¿¡æ¯ | +| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | å¦ | 域å¸å·ä¿¡æ¯ | ## DomainAccountInfo<sup>8+</sup> @@ -2017,6 +3300,8 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis 约æŸæ¥æºç±»åž‹ä¿¡æ¯ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount。 | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -2028,6 +3313,8 @@ queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promis 枚举,约æŸæ¥æºç±»åž‹ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Account.OsAccount。 | å‚æ•° | 默认值 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index f3f3ba733bc56301ba22021a4fbd3edfaa1c92e2..e41944c75170b6c9d36d451a2500dcb77c7586e7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -1,5 +1,6 @@ # å‰ªè´´æ¿ + 剪贴æ¿æœåŠ¡ä¸»è¦ç»„件包括剪贴æ¿ç®¡ç†å®¢æˆ·ç«¯å’Œå‰ªè´´æ¿æœåŠ¡ã€‚剪贴æ¿ç®¡ç†å®¢æˆ·ç«¯è´Ÿè´£å‰ªè´´æ¿æŽ¥å£ç®¡ç†ï¼Œæ供剪贴æ¿åŒ—å‘JS API给应用;在应用框架侧创建剪贴æ¿æ•°æ®ã€è¯·æ±‚剪贴æ¿SA执行剪贴æ¿çš„新建ã€åˆ 除ã€æŸ¥è¯¢ã€è½¬æ¢æ–‡æœ¬ã€é…ç½®ç‰ã€‚剪贴æ¿æœåŠ¡è´Ÿè´£å‰ªè´´æ¿äº‹ä»¶ç®¡ç†ï¼Œç®¡ç†å‰ªè´´æ¿SA的生命周期,为系统å¤åˆ¶ã€ç²˜è´´åŠŸèƒ½æ供支æŒã€‚ >  **说明:** > 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md index 38c1f1c7be9d1814ef5990dc61516e93975d04de..cadfc12098a6e85805136f8bf78d76705179f657 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-privacyManager.md @@ -191,7 +191,7 @@ privacyManager.getPermissionUsedRecords(request, (err, data) => { | -------- | -------------- | ---- | ---------------------------------------- | | beginTime | number | å¦ | 查询记录的起始时间,å•ä½ï¼šms。 | | endTime | number | å¦ | 查询记录的终æ¢æ—¶é—´ï¼Œå•ä½ï¼šms。 | -| bundleRecords | Array<[BundleUsedRecord](#BundleUsedRecord)> | å¦ | 应用的æƒé™ä½¿ç”¨è®°å½•é›†åˆã€‚ | +| bundleRecords | Array<[BundleUsedRecord](#bundleusedrecord)> | å¦ | 应用的æƒé™ä½¿ç”¨è®°å½•é›†åˆã€‚ | ## BundleUsedRecord @@ -205,7 +205,7 @@ privacyManager.getPermissionUsedRecords(request, (err, data) => { | isRemote | boolean | å¦ | 默认值false。 | | deviceId | string | å¦ | ç›®æ ‡åº”ç”¨æ‰€åœ¨è®¾å¤‡çš„ID。 | | bundleName | string | å¦ | ç›®æ ‡åº”ç”¨çš„åŒ…å。 | -| permissionRecords | Array<[PermissionUsedRecord](#PermissionUsedRecord)> | å¦ | æ¯ä¸ªåº”用的æƒé™ä½¿ç”¨è®°å½•é›†åˆã€‚ | +| permissionRecords | Array<[PermissionUsedRecord](#permissionusedrecord)> | å¦ | æ¯ä¸ªåº”用的æƒé™ä½¿ç”¨è®°å½•é›†åˆã€‚ | ## PermissionUsedRecord diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md index 248789076260954647828c891e77e8aa5bba5b28..7484c7b566df6b9ba6b2b0118c348ddc65546865 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-process.md +++ b/zh-cn/application-dev/reference/apis/js-apis-process.md @@ -232,7 +232,7 @@ is64Bit(): boolean **示例:** ```js -var ressult = process.is64Bit(); +var result = process.is64Bit(); ``` @@ -409,7 +409,7 @@ runCmd(command: string, options?: { timeout : number, killSignal : number | stri | å称 | å‚数类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | timeout | number | å¦ | å进程è¿è¡Œçš„ms数,当å进程è¿è¡Œæ—¶é—´è¶…出æ¤æ—¶é—´ï¼Œåˆ™çˆ¶è¿›ç¨‹å‘é€killSignalä¿¡å·ç»™å进程。timeout默认为0。 | -| killSignal | number \| string | å¦ | å进程è¿è¡Œæ—¶é—´è¶…出timeout时,父进程å‘é€killSignal ä¿¡å·ç»™å进程。killSignal 默认为'SIGTERM'。 | +| killSignal | number \| string | å¦ | å进程è¿è¡Œæ—¶é—´è¶…出timeout时,父进程å‘é€killSignal ä¿¡å·ç»™å进程。killSignal 默认为'SIGTERM'。 | | maxBuffer | number | å¦ | åè¿›ç¨‹æ ‡å‡†è¾“å…¥è¾“å‡ºçš„æœ€å¤§ç¼“å†²åŒºå¤§å°ï¼Œå½“超出æ¤å¤§å°æ—¶åˆ™ç»ˆæ¢å进程。maxBuffer默认1024\*1024。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md index 0d5ceb5c8c30bb70fb506922a60613cf48e16475..ba97f38ccc7bc002fa643490d0652d1b4fab8e0a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -4,7 +4,7 @@ ProcessRunningInfo模å—æ供对进程è¿è¡Œä¿¡æ¯è¿›è¡Œè®¾ç½®å’ŒæŸ¥è¯¢çš„能 > **说明:** > -> 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## 使用说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-prompt.md index 774278b087ee2bf412e00548a84842bcb6df9c53..b2cd8bebcb6622fcabe249fa29ea1f7f0e0aed7d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-prompt.md +++ b/zh-cn/application-dev/reference/apis/js-apis-prompt.md @@ -8,7 +8,7 @@ ## å¯¼å…¥æ¨¡å— -``` +```js import prompt from '@ohos.prompt' ``` @@ -26,15 +26,11 @@ showToast(options: ShowToastOptions): void | options | [ShowToastOptions](#showtoastoptions) | 是 | 文本弹窗选项。 | **示例:** - ``` - export default { - showToast() { - prompt.showToast({ - message: 'Message Info', - duration: 2000, - }); - } - } + ```js +prompt.showToast({ + message: 'Message Info', + duration: 2000, +}); ``` ## ShowToastOptions @@ -42,11 +38,11 @@ showToast(options: ShowToastOptions): void **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------------- | ---- | ---------------------------------------- | -| message | string | 是 | 显示的文本信æ¯ã€‚ | -| duration | number | å¦ | 默认值1500ms,建议区间:1500ms-10000ms,若å°äºŽ1500ms则å–默认值。 | -| bottom | string | number | å¦ | 设置弹窗边框è·ç¦»å±å¹•åº•éƒ¨çš„ä½ç½®ã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ------ | ---------------------------------------- | +| message | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | 是 | 显示的文本信æ¯ã€‚ | +| duration | number | å¦ | 默认值1500ms,建议区间:1500ms-10000ms,若å°äºŽ1500ms则å–默认值。 | +| bottom | string | number | å¦ | ## prompt.showDialog @@ -69,31 +65,27 @@ showDialog(options: ShowDialogOptions): Promise<ShowDialogSuccessResponse> **示例:** - ``` - export default { - showDialog() { - prompt.showDialog({ - title: 'Title Info', - message: 'Message Info', - buttons: [ - { - text: 'button1', - color: '#000000', - }, - { - text: 'button2', - color: '#000000', - } - ], - }) - .then(data => { - console.info('showDialog success, click button: ' + data.index); - }) - .catch(err => { - console.info('showDialog error: ' + err); - }) + ```js +prompt.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', + }, + { + text: 'button2', + color: '#000000', } - } + ], +}) + .then(data => { + console.info('showDialog success, click button: ' + data.index); + }) + .catch(err => { + console.info('showDialog error: ' + err); + }) ``` ## prompt.showDialog @@ -112,32 +104,27 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc | callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | 是 | 对è¯æ¡†å“应结果回调。 | **示例:** - ``` - export default { - callback(err, data) { - if(err) { - console.info('showDialog err: ' + err); - return; - } - console.info('showDialog success callback, click button: ' + data.index); + ```js +prompt.showDialog({ + title: 'showDialog Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button1', + color: '#000000', }, - showDialog() { - prompt.showDialog({ - title: 'showDialog Title Info', - message: 'Message Info', - buttons: [ - { - text: 'button1', - color: '#000000', - }, - { - text: 'button2', - color: '#000000', - } - ] - }, this.callback); + { + text: 'button2', + color: '#000000', } + ] +}, (err, data) => { + if (err) { + console.info('showDialog err: ' + err); + return; } + console.info('showDialog success callback, click button: ' + data.index); +}); ``` ## ShowDialogOptions @@ -146,11 +133,11 @@ showDialog(options: ShowDialogOptions, callback: AsyncCallback<ShowDialogSucc **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 -| å称 | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ---------------------------------------- | -| title | string | å¦ | æ ‡é¢˜æ–‡æœ¬ã€‚ | -| message | string | å¦ | 内容文本。 | -| buttons | Array | å¦ | 对è¯æ¡†ä¸æŒ‰é’®çš„数组,结构为:{text:'button', color: '\#666666'},支æŒ1-3个按钮。其ä¸ç¬¬ä¸€ä¸ªä¸ºpositiveButton;第二个为negativeButton;第三个为neutralButton。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | å¦ | æ ‡é¢˜æ–‡æœ¬ã€‚ | +| message | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | å¦ | 内容文本。 | +| buttons | Array | å¦ | 对è¯æ¡†ä¸æŒ‰é’®çš„数组,结构为:{text:'button', color: '\#666666'},支æŒ1-3个按钮。其ä¸ç¬¬ä¸€ä¸ªä¸ºpositiveButton;第二个为negativeButton;第三个为neutralButton。 | ## ShowDialogSuccessResponse @@ -179,31 +166,26 @@ showActionMenu(options: ActionMenuOptions, callback: AsyncCallback<ActionMenu **示例:** - ``` - export default { - callback(err, data) { - if(err) { - console.info('showActionMenu err: ' + err); - return; - } - console.info('showActionMenu success callback, click button: ' + data.index); + ```js +prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', }, - showActionMenu() { - prompt.showActionMenu({ - title: 'Title Info', - buttons: [ - { - text: 'item1', - color: '#666666', - }, - { - text: 'item2', - color: '#000000', - }, - ] - }, this.callback) - } + { + text: 'item2', + color: '#000000', + }, + ] +}, (err, data) => { + if (err) { + console.info('showActionMenu err: ' + err); + return; } + console.info('showActionMenu success callback, click button: ' + data.index); +}) ``` ## prompt.showActionMenu @@ -225,47 +207,43 @@ showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse | Promise<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | èœå•å“应结果。 | **示例:** - ``` - export default { - showActionMenu() { - prompt.showActionMenu({ - title: 'showActionMenu Title Info', - buttons: [ - { - text: 'item1', - color: '#666666', - }, - { - text: 'item2', - color: '#000000', - }, - ] - }) - .then(data => { - console.info('showActionMenu success, click button: ' + data.index); - }) - .catch(err => { - console.info('showActionMenu error: ' + err); - }) - } - } + ```js +prompt.showActionMenu({ + title: 'showActionMenu Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ] +}) + .then(data => { + console.info('showActionMenu success, click button: ' + data.index); + }) + .catch(err => { + console.info('showActionMenu error: ' + err); + }) ``` ## ActionMenuOptions æ“作èœå•çš„选项。 -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 -| å称 | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ---------------------------------------- | -| title | string | å¦ | æ ‡é¢˜æ–‡æœ¬ã€‚ | -| buttons | Array<[Button](#button)> | 是 | èœå•ä¸èœå•é¡¹æŒ‰é’®çš„数组,结构为:{text:'button', color: '\#666666'},支æŒ1-6个按钮。大于6个按钮时弹窗ä¸æ˜¾ç¤ºã€‚ | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------------------- | ---- | ---------------------------------------- | +| title | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | å¦ | æ ‡é¢˜æ–‡æœ¬ã€‚ | +| buttons | Array<[Button](#button)> | 是 | èœå•ä¸èœå•é¡¹æŒ‰é’®çš„数组,结构为:{text:'button', color: '\#666666'},支æŒ1-6个按钮。大于6个按钮时弹窗ä¸æ˜¾ç¤ºã€‚ | ## ActionMenuSuccessResponse æ“作èœå•çš„å“应结果。 -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full | å称 | 类型 | å¿…å¡« | 说明 | | ----- | ------ | ---- | ------------------------ | @@ -275,10 +253,10 @@ showActionMenu(options: ActionMenuOptions): Promise<ActionMenuSuccessResponse èœå•ä¸çš„èœå•é¡¹æŒ‰é’®ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full -| å称 | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ------------------------ | -| text | string | 是 | 按钮文本内容。 | -| color | string | 是 | 按钮文本颜色。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ----- | ---------------------------------------- | ---- | ------- | +| text | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | 是 | 按钮文本内容。 | +| color | string\| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | 是 | 按钮文本颜色。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-radio.md b/zh-cn/application-dev/reference/apis/js-apis-radio.md index 5b6297b3f53f72eac45e6843652eddbea2af7676..90f0cbfd4f73a19d94b7d277ae8d875e47819372 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-radio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-radio.md @@ -701,7 +701,7 @@ getIMEI(slotId?: number): Promise<string\> | 类型 | 说明 | | ----------------- | ------------------------------------------ | -| Promise\<string\> | 返回IMEI;如果IMEIä¸å˜åœ¨ï¼Œåˆ™è¿”回空å—符串。 | +| Promise\<string\> | 以Promiseå½¢å¼å¼‚æ¥è¿”回IMEI;如果IMEIä¸å˜åœ¨ï¼Œåˆ™è¿”回空å—符串。 | **示例:** @@ -899,6 +899,693 @@ promise.then(data => { }); ``` +## radio.sendUpdateCellLocationRequest<sup>8+</sup> + +sendUpdateCellLocationRequest\(callback: AsyncCallback<void\>\): void + +å‘é€æ›´æ–°å°åŒºä½ç½®è¯·æ±‚,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.sendUpdateCellLocationRequest((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.sendUpdateCellLocationRequest<sup>8+</sup> + +sendUpdateCellLocationRequest\(\): Promise<void\> + +å‘é€æ›´æ–°å°åŒºä½ç½®è¯·æ±‚,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = radio.sendUpdateCellLocationRequest(); +promise.then(data => { + console.log(`sendUpdateCellLocationRequest success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`sendUpdateCellLocationRequest fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.getCellInformation<sup>8+</sup> + +getCellInformation(callback: AsyncCallback<Array<CellInformation\>>): void + +获å–å°åŒºä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.LOCATION + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------ | +| callback | AsyncCallback\<Array<[CellInformation](#cellinformation8)\>\> | 是 | 回调函数,返回å°åŒºä¿¡æ¯ã€‚ | + +**示例:** + +```js +radio.getCellInformation((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getCellInformation<sup>8+</sup> + +getCellInformation(slotId: number, callback: AsyncCallback<Array<CellInformation\>\>): void + +获å–å°åŒºä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.LOCATION + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<Array<[CellInformation](#cellinformation8)\>\> | 是 | 回调函数,返回å°åŒºä¿¡æ¯ã€‚ | + +**示例:** + +```js +let slotId = 0; +radio.getCellInformation(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getCellInformation<sup>8+</sup> + +getCellInformation(slotId?: number): Promise<Array<CellInformation\>\> + +获å–å°åŒºä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.LOCATION + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | å¦ | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | ----------------------- | +| Promise\<Array<[CellInformation](#cellinformation8)\>\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let slotId = 0; +let promise = radio.getCellInformation(slotId); +promise.then(data => { + console.log(`getCellInformation success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCellInformation fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.setNetworkSelectionMode + +setNetworkSelectionMode\(options: NetworkSelectionModeOptions, callback: AsyncCallback<void\>\): void + +设置网络选择模å¼ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------ | +| options | [NetworkSelectionModeOptions](#networkselectionmodeoptions) | 是 | 网络选择模å¼é€‰é¡¹ã€‚ | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +let networkInformation={ + operatorName: "ä¸å›½ç§»åŠ¨", + operatorNumeric: "898600", + state: 1, + radioTech: "CS" +} +let networkSelectionModeOptions={ + slotid: 0, + selectMode: 1, + networkInformation: networkInformation, + resumeSelection: true +} +radio.setNetworkSelectionMode(networkSelectionModeOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.setNetworkSelectionMode + +setNetworkSelectionMode\(options: NetworkSelectionModeOptions\): Promise<void\> + +设置网络选择模å¼ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------------------------------- | ---- | ------------------ | +| options | [NetworkSelectionModeOptions](#networkselectionmodeoptions) | 是 | 网络选择模å¼é€‰é¡¹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let networkInformation={ + operatorName: "ä¸å›½ç§»åŠ¨", + operatorNumeric: "898600", + state: 1, + radioTech: "CS" +} +let networkSelectionModeOptions={ + slotid: 0, + selectMode: 1, + networkInformation: networkInformation, + resumeSelection: true +} +let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions); +promise.then(data => { + console.log(`setNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.getNetworkSearchInformation + +getNetworkSearchInformation\(slotId: number, callback: AsyncCallback<NetworkSearchResult\>\): void + +获å–网络æœç´¢ä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<[NetworkSearchResult](#networksearchresult)\> | 是 | 回调函数。返回网络æœç´¢ä¿¡æ¯ã€‚ | + +**示例:** + +```js +radio.getNetworkSearchInformation(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.getNetworkSearchInformation + +getNetworkSearchInformation\(slotId: number\): Promise<void\> + +获å–网络æœç´¢ä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------ | ----------------------- | +| Promise\<[NetworkSearchResult](#networksearchresult)\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = radio.getNetworkSearchInformation(0); +promise.then(data => { + console.log(`getNetworkSearchInformation success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getNetworkSearchInformation fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.getNrOptionMode<sup>8+</sup> + +getNrOptionMode(callback: AsyncCallback<NrOptionMode\>): void + +获å–Nré€‰é¡¹æ¨¡å¼ ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[NrOptionMode](#nroptionmode8)\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.getNrOptionMode((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getNrOptionMode<sup>8+</sup> + +getNrOptionMode(slotId: number, callback: AsyncCallback<NrOptionMode\>): void + +获å–Nré€‰é¡¹æ¨¡å¼ ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<[NrOptionMode](#nroptionmode8)\> | 是 | 回调函数。 | + +**示例:** + +```js +let slotId = 0; +radio.getNrOptionMode(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getNrOptionMode<sup>8+</sup> + +getNrOptionMode(slotId?: number): Promise<NrOptionMode\> + +获å–Nré€‰é¡¹æ¨¡å¼ ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | å¦ | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------- | ----------------------- | +| Promise\<[NrOptionMode](#nroptionmode8)\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let slotId = 0; +let promise = radio.getNrOptionMode(slotId); +promise.then(data => { + console.log(`getNrOptionMode success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getNrOptionMode fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.turnOnRadio<sup>7+</sup> + +turnOnRadio(callback: AsyncCallback<void\>): void + +打开Radio,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.turnOnRadio((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.turnOnRadio<sup>7+</sup> + +turnOnRadio(slotId: number, callback: AsyncCallback<void\>): void + +打开Radio,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +let slotId = 0; +radio.turnOnRadio(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.turnOnRadio<sup>7+</sup> + +turnOnRadio(slotId?: number): Promise<void\> + +打开Radio,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | å¦ | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let slotId = 0; +let promise = radio.turnOnRadio(slotId); +promise.then(data => { + console.log(`turnOnRadio success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`turnOnRadio fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.turnOffRadio<sup>7+</sup> + +turnOffRadio(callback: AsyncCallback<void\>): void + +å…³é—Radio,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.turnOffRadio((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.turnOffRadio<sup>7+</sup> + +turnOffRadio(slotId: number, callback: AsyncCallback<void\>): void + +å…³é—Radio,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +let slotId = 0; +radio.turnOffRadio(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.turnOffRadio<sup>7+</sup> + +turnOffRadio(slotId?: number): Promise<void\> + +å…³é—Radio,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | å¦ | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let slotId = 0; +let promise = radio.turnOffRadio(slotId); +promise.then(data => { + console.log(`turnOffRadio success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`turnOffRadio fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.setPreferredNetwork<sup>8+</sup> + +setPreferredNetwork\(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback<void\>\): void + +设置首选网络,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ---------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| networkMode | [PreferredNetworkMode](#preferrednetworkmode8) | 是 | è®¾ç½®é¦–é€‰ç½‘ç»œæ¨¡å¼ | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.setPreferredNetwork(0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.setPreferredNetwork<sup>8+</sup> + +setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise<void\> + +设置首选网络,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ---------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| networkMode | [PreferredNetworkMode](#preferrednetworkmode8) | 是 | è®¾ç½®é¦–é€‰ç½‘ç»œæ¨¡å¼ | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = radio.setPreferredNetwork(0, 1); +promise.then(data => { + console.log(`setPreferredNetwork success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setPreferredNetwork fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## radio.getPreferredNetwork<sup>8+</sup> + +getPreferredNetwork\(slotId: number, callback: AsyncCallback<PreferredNetworkMode\>\): void + +获å–首选网络,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<[PreferredNetworkMode](#preferrednetworkmode8)\> | 是 | 回调函数。 | + +**示例:** + +```js +radio.getPreferredNetwork(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## radio.getPreferredNetwork<sup>8+</sup> + +getPreferredNetwork(slotId: number): Promise<void\> + +设置首选网络,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = radio.getPreferredNetwork(0); +promise.then(data => { + console.log(`getPreferredNetwork success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getPreferredNetwork fail, promise: err->${JSON.stringify(err)}`); +}); +``` + ## RadioTechnology æ— çº¿æŽ¥å…¥æŠ€æœ¯ã€‚ @@ -1011,3 +1698,238 @@ promise.then(data => { | NETWORK_SELECTION_AUTOMATIC | 1 | 自动选网模å¼ã€‚ | | NETWORK_SELECTION_MANUAL | 2 | 手动选网模å¼ã€‚ | +## PreferredNetworkMode<sup>8+</sup> + +首选网络模å¼ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| --------------------------------------------------------- | ---- | --------------------------------------------- | +| PREFERRED_NETWORK_MODE_GSM | 1 | 首选GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_WCDMA | 2 | 首选WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE | 3 | 首选LTE网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_WCDMA | 4 | 首选LTE WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM | 5 | 首选LTE WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_WCDMA_GSM | 6 | 首选WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_CDMA | 7 | 首选CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_EVDO | 8 | 首选EVDO网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_EVDO_CDMA | 9 | 首选EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA | 10 | 首选WCDMA GSM EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA | 11 | 首选LTE EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA | 12 | 首选LTE WCDMA GSM EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_TDSCDMA | 13 | 首选TDSCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_TDSCDMA_GSM | 14 | 首选TDSCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA | 15 | 首选TDSCDMA_WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM | 16 | 首选TDSCDMA_WCDMA_GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_TDSCDMA | 17 | 首选LTE TDSCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM | 18 | 首选LTE TDSCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA | 19 | 首选LTE TDSCDMA WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM | 20 | 首选LTE TDSCDMA WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 21 | 首选TDSCDMA WCDMA GSM EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 22 | 首选LTE TDSCDMA WCDMA GSM EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR | 31 | 首选NR网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE | 32 | 首选NR LTE网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA | 33 | 首选NR LTE WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM | 34 | 首选NR LTE WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA | 35 | 首选NR LTE EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA | 36 | 首选NR LTE WCDMA GSM EVDO CDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA | 37 | 首选NR LTE TDSCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM | 38 | 首选NR LTE TDSCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA | 39 | 首选NR LTE TDSCDMA WCDMA网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM | 40 | 首选NR LTE TDSCDMA WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 41 | 首选NR LTE TDSCDMA WCDMA GSM网络模å¼ã€‚ | +| PREFERRED_NETWORK_MODE_MAX_VALUE | 99 | 首选网络模å¼æœ€å¤§å€¼ã€‚ | + +## CellInformation<sup>8+</sup> + +å°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| networkType | [NetworkType](#networktype) | 获å–æœåŠ¡å•å…ƒçš„网络类型。 | +| isCamped | boolean | 获å–æœåŠ¡å•å…ƒçš„状æ€ã€‚ | +| timeStamp | number | 获å–å•å…ƒæ ¼ä¿¡æ¯æ—¶èŽ·å–时间戳。 | +| signalInformation | [SignalInformation](#signalinformation) | ä¿¡å·ä¿¡æ¯ã€‚ | +| data | [CdmaCellInformation](#cdmacellinformation) \| [GsmCellInformation](#gsmcellinformation) \| [LteCellInformation](#ltecellinformation) \| [NrCellInformation](#nrcellinformation) \| [TdscdmaCellInformation](#tdscdmacellinformation) | Cdmaå°åŒºä¿¡æ¯ \|Gsmå°åŒºä¿¡æ¯\|Lteå°åŒºä¿¡æ¯\|Nrå°åŒºä¿¡æ¯\|Tdscdmaå°åŒºä¿¡æ¯ | + +## CdmaCellInformation<sup>8+</sup> + +Cdmaå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| --------- | ------ | ------------ | +| baseId | number | 基站Id。 | +| latitude | number | ç»åº¦ã€‚ | +| longitude | number | 纬度。 | +| nid | number | 网络识别ç 。 | +| sid | number | 系统识别ç 。 | + +## GsmCellInformation<sup>8+</sup> + +Gsmå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------ | ------ | -------------------- | +| lac | number | ä½ç½®åŒºç¼–å·ã€‚ | +| cellId | number | å°åŒºå·ã€‚ | +| arfcn | number | ç»å¯¹æ— 线频率信é“å·ã€‚ | +| bsic | number | 基站识别å·ã€‚ | +| mcc | string | 移动国家ç 。 | +| mnc | string | 移动网å·ã€‚ | + +## LteCellInformation<sup>8+</sup> + +Lteå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------------- | ------- | ----------------------- | +| cgi | number | å°åŒºå…¨çƒæ ‡è¯†ã€‚ | +| pci | number | 物ç†å°åŒºè¯†åˆ«ã€‚ | +| tac | number | 跟踪区域代ç 。 | +| earfcn | number | ç»å¯¹æ— 线频率信é“å·ã€‚ | +| bandwidth | number | 带宽。 | +| mcc | string | 移动国家ç 。 | +| mnc | string | 移动网å·ã€‚ | +| isSupportEndc | boolean | 是å¦æ”¯æŒæ–°æ— 线电_åŒè¿žæŽ¥ | + +## NrCellInformation<sup>8+</sup> + +Nrå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------- | ------ | ---------------- | +| nrArfcn | number | 5G频点å·ã€‚ | +| pci | number | 物ç†å°åŒºè¯†åˆ«ã€‚ | +| tac | number | 跟踪区域代ç 。 | +| nci | number | 5G网络å°åŒºæ ‡è¯†ã€‚ | +| mcc | string | 移动国家ç 。 | +| mnc | string | 移动网å·ã€‚ | + +## TdscdmaCellInformation<sup>8+</sup> + +Tdscdmaå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------ | ------ | ------------ | +| lac | number | ä½ç½®åŒºç¼–å·ã€‚ | +| cellId | number | å°åŒºå·ã€‚ | +| cpid | number | å°åŒºå‚æ•°Id。 | +| uarfcn | number | ç»å¯¹å°„频å·ã€‚ | +| mcc | string | 移动国家ç 。 | +| mnc | string | 移动网å·ã€‚ | + +## WcdmaCellInformation<sup>8+</sup> + +Wcdmaå°åŒºä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------ | ------ | ------------ | +| lac | number | ä½ç½®åŒºç¼–å·ã€‚ | +| cellId | number | å°åŒºå·ã€‚ | +| psc | number | 主扰ç 。 | +| uarfcn | number | ç»å¯¹å°„频å·ã€‚ | +| mcc | string | 移动国家ç 。 | +| mnc | string | 移动网å·ã€‚ | + +## NrOptionMode<sup>8+</sup> + +Nr的选择模å¼ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| -------------------- | ---- | ---------------------------------- | +| NR_OPTION_UNKNOWN | 0 | 未知的Nr选择模å¼ã€‚ | +| NR_OPTION_NSA_ONLY | 1 | ä»…éžç‹¬ç«‹ç»„网的Nr选择模å¼ã€‚ | +| NR_OPTION_SA_ONLY | 2 | 仅独立组网的Nr选择模å¼ã€‚ | +| NR_OPTION_NSA_AND_SA | 3 | éžç‹¬ç«‹ç»„网和独立组网的Nr选择模å¼ã€‚ | + +## NetworkSearchResult + +网络æœç´¢ç»“果。 + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ---------------------- | ------------------------------------------------- | -------------- | +| isNetworkSearchSuccess | boolean | 网络æœç´¢æˆåŠŸã€‚ | +| networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | 网络æœç´¢ç»“果。 | + +## NetworkInformation + +网络信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| --------------- | ----------------------------------------- | -------------- | +| operatorName | string | è¿è¥å•†çš„å称。 | +| operatorNumeric | string | è¿è¥å•†æ•°å—。 | +| state | [NetworkInformationState](#networkinformationstate) | 网络信æ¯çŠ¶æ€ã€‚ | +| radioTech | string | æ— çº¿ç”µæŠ€æœ¯ã€‚ | + +## NetworkInformationState + +网络信æ¯çŠ¶æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| ----------------- | ---- | ---------------- | +| NETWORK_UNKNOWN | 0 | 网络状æ€æœªçŸ¥ã€‚ | +| NETWORK_AVAILABLE | 1 | 网络å¯ç”¨äºŽæ³¨å†Œã€‚ | +| NETWORK_CURRENT | 2 | 已在网络ä¸æ³¨å†Œã€‚ | +| NETWORK_FORBIDDEN | 3 | ç½‘ç»œæ— æ³•æ³¨å†Œã€‚ | + +## NetworkSelectionModeOptions + +网络选择模å¼é€‰é¡¹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------------------ | --------------------------------------------- | -------------------------------------- | +| slotId | number | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| selectMode | [NetworkSelectionMode](#networkselectionmode) | 网络选择模å¼ã€‚ | +| networkInformation | [NetworkInformation](#networkinformation) | 网络信æ¯ã€‚ | +| resumeSelection | boolean | 继ç»é€‰æ‹©ã€‚ | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 75d6b4faa5586f948c01259d0d39fb90f7523f2f..b0e42ef70ce809931acd3248d1b99bb6d7b0cd6f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -16,9 +16,9 @@ import request from '@ohos.request'; ## é™åˆ¶ä¸Žçº¦æŸ -默认支æŒhttps,如果è¦æ”¯æŒhttp,需è¦åœ¨config.jsoné‡Œå¢žåŠ networkæ ‡ç¾ï¼Œå±žæ€§æ ‡è¯† "cleartextTraffic": true。å³ï¼š +在开å‘FA模型下的应用程åºæ—¶, 默认支æŒhttps,如果è¦æ”¯æŒhttp,需è¦åœ¨config.jsoné‡Œå¢žåŠ networkæ ‡ç¾ï¼Œå±žæ€§æ ‡è¯† "cleartextTraffic": true。å³ï¼š -``` +```js var config = { "deviceConfig": { "default": { @@ -31,6 +31,9 @@ var config = { } ``` +在开å‘stage模型下的应用程åºæ—¶ï¼Œä¸æ¶‰åŠå±žæ€§æ ‡è¯† "cleartextTraffic"。 + + ## å¸¸é‡ @@ -68,6 +71,8 @@ upload(config: UploadConfig): Promise<UploadTask> ä¸Šä¼ ï¼Œå¼‚æ¥æ–¹æ³•ï¼Œä½¿ç”¨promiseå½¢å¼è¿”回结果。 +æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用 + **需è¦æƒé™**:ohos.permission.INTERNET **系统能力**: SystemCapability.MiscServices.Upload @@ -87,11 +92,15 @@ upload(config: UploadConfig): Promise<UploadTask> **示例:** ```js - let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }; - let data = { name: "name123", value: "123" }; - let header = { key1: "value1", key2: "value2" }; let uploadTask; - request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }).then((data) => { + let uploadConfig = { + url: 'https://patch', + header: { key1: "value1", key2: "value2" }, + method: "POST", + files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], + data: [{ name: "name123", value: "123" }], + }; + request.upload(uploadConfig).then((data) => { uploadTask = data; }).catch((err) => { console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); @@ -105,6 +114,8 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void ä¸Šä¼ ï¼Œå¼‚æ¥æ–¹æ³•ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 +æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用 + **需è¦æƒé™**:ohos.permission.INTERNET **系统能力**: SystemCapability.MiscServices.Upload @@ -119,11 +130,15 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void **示例:** ```js - let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }; - let data = { name: "name123", value: "123" }; - let header = { key1: "value1", key2: "value2" }; let uploadTask; - request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }, (err, data) => { + let uploadConfig = { + url: 'https://patch', + header: { key1: "value1", key2: "value2" }, + method: "POST", + files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], + data: [{ name: "name123", value: "123" }], + }; + request.upload(uploadConfig, (err, data) => { if (err) { console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); return; @@ -131,7 +146,86 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void uploadTask = data; }); ``` +## request.upload<sup>9+</sup> + +upload(context: BaseContext, config: UploadConfig): Promise<UploadTask> + +ä¸Šä¼ ï¼Œå¼‚æ¥æ–¹æ³•ï¼Œä½¿ç”¨promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™**:ohos.permission.INTERNET + +**系统能力**: SystemCapability.MiscServices.Upload + +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | context | BaseContext | 是 | 基于应用程åºçš„上下文。 | + | config | [UploadConfig](#uploadconfig) | 是 | ä¸Šä¼ çš„é…置信æ¯ã€‚ | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<[UploadTask](#uploadtask)> | è¿”å›žä¸Šä¼ ä»»åŠ¡ã€‚ | + +**示例:** + + ```js + let uploadTask; + let uploadConfig = { + url: 'https://patch', + header: { key1: "value1", key2: "value2" }, + method: "POST", + files: { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }, + data: { name: "name123", value: "123" }, + }; + request.upload(globalThis.abilityContext, uploadConfig).then((data) => { + uploadTask = data; + }).catch((err) => { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + }); + ``` + + +## request.upload<sup>9+</sup> + +upload(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void + +ä¸Šä¼ ï¼Œå¼‚æ¥æ–¹æ³•ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™**:ohos.permission.INTERNET + +**系统能力**: SystemCapability.MiscServices.Upload + +**å‚数:** + + | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | context | BaseContext | 是 | 基于应用程åºçš„上下文。 | + | config | [UploadConfig](#uploadconfig) | 是 | ä¸Šä¼ çš„é…置信æ¯ã€‚ | + | callback | AsyncCallback<[UploadTask](#uploadtask)> | å¦ | 回调函数,异æ¥è¿”回UploadTask对象。 | + +**示例:** + + ```js + let uploadTask; + let uploadConfig = { + url: 'https://patch', + header: { key1: "value1", key2: "value2" }, + method: "POST", + files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], + data: [{ name: "name123", value: "123" }], + }; + request.upload(globalThis.abilityContext, uploadConfig, (err, data) => { + if (err) { + console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); + return; + } + uploadTask = data; + }); + ``` ## UploadTask @@ -338,6 +432,8 @@ remove(callback: AsyncCallback<boolean>): void ## UploadConfig +**需è¦æƒé™**:ohos.permission.INTERNET + **系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MiscServices.Upload。 | å称 | 类型 | å¿…å¡« | 说明 | @@ -351,7 +447,9 @@ remove(callback: AsyncCallback<boolean>): void ## File -**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MiscServices.Upload。 +**需è¦æƒé™**:ohos.permission.INTERNET + +**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MiscServices.Download | å称 | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -363,8 +461,9 @@ remove(callback: AsyncCallback<boolean>): void ## RequestData -**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MiscServices.Upload。 +**需è¦æƒé™**:ohos.permission.INTERNET +**系统能力**: 以下å„项对应的系统能力å‡ä¸ºSystemCapability.MiscServices.Download | å称 | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 表示表å•å…ƒç´ çš„å称。 | @@ -377,6 +476,8 @@ download(config: DownloadConfig): Promise<DownloadTask> 下载,异æ¥æ–¹æ³•ï¼Œä½¿ç”¨promiseå½¢å¼è¿”回结果。 +æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用 + **需è¦æƒé™**:ohos.permission.INTERNET **系统能力**: SystemCapability.MiscServices.Download @@ -411,6 +512,8 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v 下载,异æ¥æ–¹æ³•ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 +æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用 + **需è¦æƒé™**:ohos.permission.INTERNET **系统能力**: SystemCapability.MiscServices.Download @@ -436,7 +539,72 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v }); ``` +## request.download<sup>9+</sup> + +download(context: BaseContext, config: DownloadConfig): Promise<DownloadTask> + +下载,异æ¥æ–¹æ³•ï¼Œä½¿ç”¨promiseå½¢å¼è¿”回结果。 + +**需è¦æƒé™**:ohos.permission.INTERNET + +**系统能力**: SystemCapability.MiscServices.Download + +**å‚数:** + + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | context | BaseContext | 是 | 基于应用程åºçš„上下文。 | + | config | [DownloadConfig](#downloadconfig) | 是 | 下载的é…置信æ¯ã€‚ | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<[DownloadTask](#downloadtask)> | 返回下载任务。 | + +**示例:** + + ```js + let downloadTask; + request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxx.hap' }).then((data) => { + downloadTask = data; + }).catch((err) => { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + }) + ``` + + +## request.download<sup>9+</sup> + +download(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; + +下载,异æ¥æ–¹æ³•ï¼Œä½¿ç”¨callbackå½¢å¼è¿”回结果。 + +**需è¦æƒé™**:ohos.permission.INTERNET + +**系统能力**: SystemCapability.MiscServices.Download + +**å‚数:** + + | å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | context | BaseContext | 是 | 基于应用程åºçš„上下文。 | + | config | [DownloadConfig](#downloadconfig) | 是 | 下载的é…置信æ¯ã€‚ | + | callback | AsyncCallback<[DownloadTask](#downloadtask)> | å¦ | 下载接å£çš„回调函数。 | +**示例:** + + ```js + let downloadTask; + request.download(globalThis.abilityContext, { url: 'https://xxxx/xxxxx.hap', + filePath: 'xxx/xxxxx.hap'}, (err, data) => { + if (err) { + console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); + return; + } + downloadTask = data; + }); + ``` ## DownloadTask 下载任务。 @@ -936,6 +1104,8 @@ resume(callback: AsyncCallback<void>): void ## DownloadConfig +**需è¦æƒé™**:ohos.permission.INTERNET + **系统能力**: SystemCapability.MiscServices.Download | å称 | 类型 | å¿…å¡« | 说明 | @@ -948,10 +1118,13 @@ resume(callback: AsyncCallback<void>): void | filePath<sup>7+</sup> | string | å¦ | 设置下载路径(默认在'internal://cache/'路径下)。<br/>- filePath:'workspace/test.txt':默认路径下创建workspace路径,并将文件å˜å‚¨åœ¨workspace路径下。<br/>- filePath:'test.txt':将文件å˜å‚¨åœ¨é»˜è®¤è·¯å¾„下。<br/>- filePath:'workspace/':默认路径下创建workspace路径,并将文件å˜å‚¨åœ¨workspace路径下。 | | networkType | number | å¦ | 设置å…许下载的网络类型。 | | title | string | å¦ | 设置下载会è¯æ ‡é¢˜ã€‚ | +| background | boolean | å¦ | åŽå°ä»»åŠ¡é€šçŸ¥å¼€å…³ï¼Œå¼€å¯åŽå¯åœ¨é€šçŸ¥ä¸æ˜¾ç¤ºä¸‹è½½çŠ¶æ€ã€‚ | ## DownloadInfo<sup>7+</sup> +**需è¦æƒé™**:ohos.permission.INTERNET + **系统能力**: SystemCapability.MiscServices.Download | å称 | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index 14d19f464809e47dbd75d91af9eaf83143ec29c2..c187b3366cd892a42d791471a64fbf7d6ff23c9e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -9,7 +9,7 @@ ## å¯¼å…¥æ¨¡å— -``` +```js import resourceManager from '@ohos.resourceManager'; ``` @@ -17,7 +17,7 @@ import resourceManager from '@ohos.resourceManager'; 从API Version9开始,Stage模型支æŒäº†é€šè¿‡context获å–resourceManager对象的方å¼ï¼Œå†è°ƒç”¨å…¶å†…部获å–资æºçš„接å£ï¼Œæ— 需å†å¯¼å…¥åŒ…,æ¤æ–¹å¼FA模型ä¸é€‚用。 -``` +```ts this.context.resourceManager; ``` @@ -37,7 +37,7 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callbackæ–¹å¼è¿”回ResourceManager对象 | **示例:** - ``` + ```js resourceManager.getResourceManager((error, mgr) => { if (error != null) { console.log("error is " + error); @@ -71,7 +71,7 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callbackæ–¹å¼è¿”回ResourceManager对象 | **示例:** - ``` + ```js resourceManager.getResourceManager("com.example.myapplication", (error, mgr) => { }); ``` @@ -93,7 +93,7 @@ getResourceManager(): Promise<ResourceManager> | Promise<[ResourceManager](#resourcemanager)> | Promiseæ–¹å¼è¿”回资æºç®¡ç†å¯¹è±¡ | **示例:** - ``` + ```js resourceManager.getResourceManager().then(mgr => { mgr.getString(0x1000000, (error, value) => { if (error != null) { @@ -129,11 +129,9 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | Promise<[ResourceManager](#resourcemanager)> | Promiseæ–¹å¼è¿”回的资æºç®¡ç†å¯¹è±¡ | **示例:** - ``` + ```js resourceManager.getResourceManager("com.example.myapplication").then(mgr => { - }).catch(error => { - }); ``` @@ -142,7 +140,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 用于表示设备å±å¹•æ–¹å‘。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +**系统能力**:SystemCapability.Global.ResourceManager | å称 | 默认值 | 说明 | | -------------------- | ---- | ---- | @@ -154,7 +152,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 用于表示当å‰è®¾å¤‡ç±»åž‹ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +**系统能力**:SystemCapability.Global.ResourceManager | å称 | 默认值 | 说明 | | -------------------- | ---- | ---- | @@ -170,7 +168,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 用于表示当å‰è®¾å¤‡å±å¹•å¯†åº¦ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +**系统能力**:SystemCapability.Global.ResourceManager | å称 | 默认值 | 说明 | | -------------- | ---- | ---------- | @@ -186,7 +184,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 表示当å‰è®¾å¤‡çš„状æ€ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +**系统能力**:SystemCapability.Global.ResourceManager | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | @@ -196,7 +194,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **示例:** - ``` + ```js resourceManager.getResourceManager((error, mgr) => { mgr.getConfiguration((error, value) => { let direction = value.direction; @@ -209,7 +207,7 @@ resourceManager.getResourceManager((error, mgr) => { 表示设备支æŒçš„能力。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +**系统能力**:SystemCapability.Global.ResourceManager | å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | @@ -219,7 +217,7 @@ resourceManager.getResourceManager((error, mgr) => { **示例:** - ``` + ```js resourceManager.getResourceManager((error, mgr) => { mgr.getDeviceCapability((error, value) => { let screenDensity = value.screenDensity; @@ -230,8 +228,9 @@ resourceManager.getResourceManager((error, mgr) => { ## RawFileDescriptor<sup>8+</sup> -表示rawfileçš„descriptorä¿¡æ¯ã€‚<br> -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager +表示rawfileçš„descriptorä¿¡æ¯ã€‚ + +**系统能力:** SystemCapability.Global.ResourceManager | å称 | 类型 | 说明 | | ------ | ------ | ------------------ | @@ -245,11 +244,11 @@ resourceManager.getResourceManager((error, mgr) => { **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.Global.ResourceManager -| å称 | 类型 | 说明 | -| ------ | ------ | ------------------ | +| å称 | 类型 | 说明 | +| ---------- | ------ | ----------- | | bundleName | string | 应用的bundleå称 | -| moduleName | string | 应用的moduleå称 | -| id | number | 资æºçš„id值 | +| moduleName | string | 应用的moduleå称 | +| id | number | 资æºçš„id值 | ## ResourceManager @@ -278,7 +277,7 @@ getString(resId: number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getString($r('app.string.test').id, (error, value) => { if (error != null) { @@ -310,7 +309,7 @@ getString(resId: number): Promise<string> | Promise<string> | 资æºID值对应的å—符串 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getString($r('app.string.test').id).then(value => { let str = value; @@ -332,11 +331,11 @@ getString(resource: Resource, callback: AsyncCallback<string>): void **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------- | ---- | --------------- | -| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | +| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -360,17 +359,17 @@ getString(resource: Resource): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| --------------------- | ---------------- | | Promise<string> | resource对象对应的å—符串 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -398,7 +397,7 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>> | callback | AsyncCallback<Array<string>> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串数组 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getStringArray($r('app.strarray.test').id, (error, value) => { if (error != null) { @@ -430,7 +429,7 @@ getStringArray(resId: number): Promise<Array<string>> | Promise<Array<string>> | 资æºID值对应的å—符串数组 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getStringArray($r('app.strarray.test').id).then(value => { let strArray = value; @@ -449,13 +448,13 @@ getStringArray(resource: Resource, callback: AsyncCallback<Array<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------- | ---- | --------------- | -| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------- | +| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | | callback | AsyncCallback<Array<string>> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串数组 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -479,17 +478,17 @@ getStringArray(resource: Resource): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ---------------------------------- | ------------------ | | Promise<Array<string>> | resource对象对应的å—符串数组 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -517,7 +516,7 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void | callback | AsyncCallback<Uint8Array> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的媒体文件内容 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getMedia($r('app.media.test').id, (error, value) => { if (error != null) { @@ -549,7 +548,7 @@ getMedia(resId: number): Promise<Uint8Array> | Promise<Uint8Array> | 资æºID值对应的媒体文件内容 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getMedia($r('app.media.test').id).then(value => { let media = value; @@ -568,13 +567,13 @@ getMedia(resource: Resource, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------- | ---- | --------------- | -| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------- | ---- | ------------------ | +| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | | callback | AsyncCallback<Uint8Array> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的媒体文件内容 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -598,17 +597,17 @@ getMedia(resource: Resource): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------------------------- | ------------------- | | Promise<Uint8Array> | resource对象对应的媒体文件内容 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -636,7 +635,7 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getMediaBase64($r('app.media.test').id, (error, value) => { if (error != null) { @@ -668,7 +667,7 @@ getMediaBase64(resId: number): Promise<string> | Promise<string> | 资æºID值对应的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getMediaBase64($r('app.media.test').id).then(value => { let media = value; @@ -689,11 +688,11 @@ getMediaBase64(resource: Resource, callback: AsyncCallback<string>): void **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------- | ---- | ------------------------ | -| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | +| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -717,17 +716,17 @@ getMediaBase64(resource: Resource): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | -------------------- | +| 类型 | 说明 | +| --------------------- | ------------------------- | | Promise<string> | resource对象对应的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -755,7 +754,7 @@ getConfiguration(callback: AsyncCallback<Configuration>): void | callback | AsyncCallback<[Configuration](#configuration)> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回设备的Configuration | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getConfiguration((error, value) => { if (error != null) { @@ -783,7 +782,7 @@ getConfiguration(): Promise<Configuration> | Promise<[Configuration](#configuration)> | 设备的Configuration | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getConfiguration().then(value => { let direction = value.direction; @@ -809,7 +808,7 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void | callback | AsyncCallback<[DeviceCapability](#devicecapability)> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回设备的DeviceCapability | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getDeviceCapability((error, value) => { if (error != null) { @@ -837,7 +836,7 @@ getDeviceCapability(): Promise<DeviceCapability> | Promise<[DeviceCapability](#devicecapability)> | 设备的DeviceCapability | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getDeviceCapability().then(value => { let screenDensity = value.screenDensity; @@ -865,7 +864,7 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string> | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œè¿”å›žæ ¹æ®æŒ‡å®šæ•°é‡èŽ·å–指定IDå—符串表示的å•å¤æ•°å—符串 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getPluralString($r("app.plural.test").id, 1, (error, value) => { if (error != null) { @@ -898,7 +897,7 @@ getPluralString(resId: number, num: number): Promise<string> | Promise<string> | æ ¹æ®æ供的数é‡èŽ·å–对应IDå—符串表示的å•å¤æ•°å—符串 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getPluralString($r("app.plural.test").id, 1).then(value => { let str = value; @@ -917,14 +916,14 @@ getPluralString(resource: Resource, num: number, callback: AsyncCallback<stri **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------- | ---- | ------------------------------- | -| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | -| num | number | 是 | æ•°é‡å€¼ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------ | +| resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | +| num | number | 是 | æ•°é‡å€¼ | | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œè¿”å›žæ ¹æ®æŒ‡å®šæ•°é‡èŽ·å–指定resource对象表示的å•å¤æ•°å—符串 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -948,18 +947,18 @@ getPluralString(resource: Resource, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | -| num | number | 是 | æ•°é‡å€¼ | +| num | number | 是 | æ•°é‡å€¼ | **返回值:** -| 类型 | 说明 | -| --------------------- | ------------------------- | +| 类型 | 说明 | +| --------------------- | ------------------------------ | | Promise<string> | æ ¹æ®æ供的数é‡èŽ·å–对应resource对象表示的å•å¤æ•°å—符串 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -987,7 +986,7 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void | callback | AsyncCallback<Uint8Array> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„rawfile文件内容 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getRawFile("test.xml", (error, value) => { if (error != null) { @@ -1018,7 +1017,7 @@ getRawFile(path: string): Promise<Uint8Array> | Promise<Uint8Array> | rawfile文件内容 | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getRawFile("test.xml").then(value => { let rawFile = value; @@ -1043,7 +1042,7 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor& | callback | AsyncCallback<[RawFileDescriptor](#rawfiledescriptor8)> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„rawfile文件的descriptor | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getRawFileDescriptor("test.xml", (error, value) => { if (error != null) { @@ -1076,7 +1075,7 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor> | Promise<[RawFileDescriptor](#rawfiledescriptor8)> | rawfile文件descriptor | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.getRawFileDescriptor("test.xml").then(value => { let fd = value.fd; @@ -1103,7 +1102,7 @@ closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 异æ¥å›žè°ƒ | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.closeRawFileDescriptor("test.xml", (error, value) => { if (error != null) { @@ -1132,7 +1131,7 @@ closeRawFileDescriptor(path: string): Promise<void> | Promise<void> | æ— è¿”å›žå€¼ | **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.closeRawFileDescriptor("test.xml").then(value => { let result = value; @@ -1151,7 +1150,7 @@ release() **系统能力**:SystemCapability.Global.ResourceManager **示例:** - ``` + ```ts resourceManager.getResourceManager((error, mgr) => { mgr.release(); }); @@ -1168,11 +1167,11 @@ getStringByName(resName: string, callback: AsyncCallback<string>): void **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------- | ---- | --------------- | -| resName | string | 是 | 资æºå称 | -| callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串 | +| resName | string | 是 | 资æºå称 | +| callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串 | **示例:** - ``` + ```ts this.context.resourceManager.getStringByName("test", (error, value) => { if (error != null) { console.log("error is " + error); @@ -1191,17 +1190,17 @@ getStringByName(resName: string): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------- | ------ | ---- | ---- | -| resName | string | 是 | 资æºå称 | +| resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| --------------------- | ---------- | | Promise<string> | 资æºå称对应的å—符串 | **示例:** - ``` + ```ts this.context.resourceManager.getStringByName("test").then(value => { let string = value; }).catch(error => { @@ -1220,11 +1219,11 @@ getStringArrayByName(resName: string, callback: AsyncCallback<Array<string **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | -| resName | string | 是 | 资æºå称 | +| resName | string | 是 | 资æºå称 | | callback | AsyncCallback<Array<string>> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–çš„å—符串数组 | **示例:** - ``` + ```ts this.context.resourceManager.getStringArrayByName("test", (error, value) => { if (error != null) { console.log("error is " + error); @@ -1243,17 +1242,17 @@ getStringArrayByName(resName: string): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ----- | -| resName | string | 是 | 资æºå称 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | +| resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| ---------------------------------- | ------------- | +| 类型 | 说明 | +| ---------------------------------- | ------------ | | Promise<Array<string>> | 资æºå称对应的å—符串数组 | **示例:** - ``` + ```ts this.context.resourceManager.getStringArrayByName("test").then(value => { let strArray = value; }).catch(error => { @@ -1272,11 +1271,11 @@ getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ------------------------------- | ---- | ------------------ | -| resName | string | 是 | 资æºå称 | +| resName | string | 是 | 资æºå称 | | callback | AsyncCallback<Uint8Array> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的媒体文件内容 | **示例:** - ``` + ```ts this.context.resourceManager.getMediaByName("test", (error, value) => { if (error != null) { console.log("error is " + error); @@ -1295,17 +1294,17 @@ getMediaByName(resName: string): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | | resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| ------------------------- | -------------- | +| 类型 | 说明 | +| ------------------------- | ------------- | | Promise<Uint8Array> | 资æºå称对应的媒体文件内容 | **示例:** - ``` + ```ts this.context.resourceManager.getMediaByName("test").then(value => { let media = value; }).catch(error => { @@ -1324,11 +1323,11 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): vo **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------- | ---- | ------------------------ | -| resName | string | 是 | 资æºå称 | +| resName | string | 是 | 资æºå称 | | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œç”¨äºŽè¿”回获å–的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts this.context.resourceManager.getMediaBase64ByName("test", (error, value) => { if (error != null) { console.log("error is " + error); @@ -1347,17 +1346,17 @@ getMediaBase64ByName(resName: string): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ----- | -| resName | string | 是 | 资æºå称 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | +| resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| --------------------- | -------------------- | +| 类型 | 说明 | +| --------------------- | ------------------- | | Promise<string> | 资æºå称对应的图片资æºBase64ç¼–ç | **示例:** - ``` + ```ts this.context.resourceManager.getMediaBase64ByName("test").then(value => { let media = value; }).catch(error => { @@ -1374,14 +1373,14 @@ getPluralStringByName(resName: string, num: number, callback: AsyncCallback<s **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | --------------------------- | ---- | ------------------------------- | -| resName | string | 是 | 资æºå称 | -| num | number | 是 | æ•°é‡å€¼ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ----------------------------- | +| resName | string | 是 | 资æºå称 | +| num | number | 是 | æ•°é‡å€¼ | | callback | AsyncCallback<string> | 是 | 异æ¥å›žè°ƒï¼Œè¿”å›žæ ¹æ®ä¼ 入的数é‡å€¼èŽ·å–资æºå称对应的å—ç¬¦ä¸²èµ„æº | **示例:** - ``` + ```ts this.context.resourceManager.getPluralStringByName("test", 1, (error, value) => { if (error != null) { console.log("error is " + error); @@ -1400,18 +1399,18 @@ getPluralStringByName(resName: string, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | | resName | string | 是 | 资æºå称 | -| num | number | 是 | æ•°é‡å€¼ | +| num | number | 是 | æ•°é‡å€¼ | **返回值:** -| 类型 | 说明 | -| --------------------- | ------------------------- | +| 类型 | 说明 | +| --------------------- | ---------------------- | | Promise<string> | æ ¹æ®ä¼ 入的数é‡å€¼èŽ·å–资æºå称对应的å—ç¬¦ä¸²èµ„æº | **示例:** - ``` + ```ts this.context.resourceManager.getPluralStringByName("test", 1).then(value => { let str = value; }).catch(error => { @@ -1433,12 +1432,12 @@ getStringSync(resId: number): string | resId | number | 是 | 资æºID值 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | ----------- | | string | 资æºID值对应的å—符串 | **示例:** - ``` + ```ts this.context.resourceManager.getStringSync($r('app.string.test').id); ``` @@ -1451,17 +1450,17 @@ getStringSync(resource: Resource): string **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | ---------------- | | string | resource对象对应的å—符串 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -1479,17 +1478,17 @@ getStringByNameSync(resName: string): string **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | | resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | ---------- | | string | 资æºå称对应的å—符串 | **示例:** - ``` + ```ts this.context.resourceManager.getStringByNameSync("test"); ``` @@ -1507,12 +1506,12 @@ getBoolean(resId: number): boolean | resId | number | 是 | 资æºID值 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------- | ------------ | | boolean | 资æºID值对应的布尔结果 | **示例:** - ``` + ```ts this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id); ``` ### getBoolean<sup>9+</sup> @@ -1524,17 +1523,17 @@ getBoolean(resource: Resource): boolean **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------- | ----------------- | | boolean | resource对象对应的布尔结果 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -1552,17 +1551,17 @@ getBooleanByName(resName: string): boolean **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------- | ------ | ---- | ----- | -| resName | string | 是 | 资æºå称 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | +| resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------- | ----------- | | boolean | 资æºå称对应的布尔结果 | **示例:** - ``` + ```ts this.context.resourceManager.getBooleanByName("boolean_test"); ``` @@ -1580,12 +1579,12 @@ getNumber(resId: number): number | resId | number | 是 | 资æºID值 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | ---------- | | number | 资æºID值对应的数值 | **示例:** - ``` + ```ts this.context.resourceManager.getNumber($r('app.integer.integer_test').id); this.context.resourceManager.getNumber($r('app.float.float_test').id); ``` @@ -1599,17 +1598,17 @@ getNumber(resource: Resource): number **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资æºä¿¡æ¯ | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | --------------- | | number | resource对象对应的数值 | **示例:** - ``` + ```ts let resource = { bundleName: "com.example.myapplication", moduleName: "entry", @@ -1627,17 +1626,17 @@ getNumberByName(resName: string): number **系统能力**:SystemCapability.Global.ResourceManager **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----- | ------ | ---- | ----- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---- | | resName | string | 是 | 资æºå称 | **返回值:** -| 类型 | 说明 | -| --------------------- | ----------- | +| 类型 | 说明 | +| ------ | --------- | | number | 资æºå称对应的数值 | **示例:** - ``` + ```ts this.context.resourceManager.getNumberByName("integer_test"); this.context.resourceManager.getNumberByName("float_test"); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index 51f8738c2fdf55c470c2d5e4d4159e459974912b..2b6cf2dcb4dd56d65dc34cb7d3e7ef7c841833f6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -2,9 +2,10 @@ 本模å—æ供通过ä¸åŒçš„url访问ä¸åŒçš„页é¢ï¼ŒåŒ…括跳转到应用内的指定页é¢ã€ç”¨åº”用内的æŸä¸ªé¡µé¢æ›¿æ¢å½“å‰é¡µé¢ã€è¿”回上一页é¢æˆ–指定的页é¢ç‰ã€‚ ->  **说明** +> **说明** > > - 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> > - 页é¢è·¯ç”±éœ€è¦åœ¨é¡µé¢æ¸²æŸ“完æˆä¹‹åŽæ‰èƒ½è°ƒç”¨ï¼Œåœ¨onInitå’ŒonReady生命周期ä¸é¡µé¢è¿˜å¤„于渲染阶段,ç¦æ¢è°ƒç”¨é¡µé¢è·¯ç”±æ–¹æ³•ã€‚ ## å¯¼å…¥æ¨¡å— @@ -13,100 +14,108 @@ import router from '@ohos.router' ``` -## æƒé™åˆ—表 - -æ— - ## router.push -push(options: RouterOptions, mode?: RouterMode): void +push(options: RouterOptions): void 跳转到应用内的指定页é¢ã€‚ **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | 是 | 跳转页é¢æè¿°ä¿¡æ¯ã€‚ | -| mode<sup>9+</sup> | [RouterMode](#routermode9) | å¦ | 跳转页é¢ä½¿ç”¨çš„模å¼ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页é¢æè¿°ä¿¡æ¯ã€‚ | **示例:** - ```js - // 在当å‰é¡µé¢ä¸ - export default { - pushPage() { - router.push({ - url: 'pages/routerpage2/routerpage2', - params: { - data1: 'message', - data2: { - data3: [123, 456, 789] - }, - }, - }); - } - } - ``` - ```js - // 在routerpage2页é¢ä¸ - export default { - data: { - data1: 'default', - data2: { - data3: [1, 2, 3] - } +```js +router.push({ + url: 'pages/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] }, - onInit() { - console.info('showData1:' + this.data1); - console.info('showData3:' + this.data2.data3); - } - } - ``` + }, +}); +``` +## router.push<sup>9+</sup> + +push(options: RouterOptions, mode: RouterMode): void +跳转到应用内的指定页é¢ã€‚ + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ------------------------------- | ---- | -------------------- | +| options | [RouterOptions](#routeroptions) | 是 | 跳转页é¢æè¿°ä¿¡æ¯ã€‚ | +| mode<sup>9+</sup> | [RouterMode](#routermode9) | 是 | 跳转页é¢ä½¿ç”¨çš„模å¼ã€‚ | + + +**示例:** +```js +router.push({ + url: 'pages/routerpage2/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, +},router.RouterMode.Standard); +``` ## router.replace -replace(options: RouterOptions, mode?: RouterMode): void +replace(options: RouterOptions): void 用应用内的æŸä¸ªé¡µé¢æ›¿æ¢å½“å‰é¡µé¢ï¼Œå¹¶é”€æ¯è¢«æ›¿æ¢çš„页é¢ã€‚ **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | 是 | 替æ¢é¡µé¢æè¿°ä¿¡æ¯ã€‚ | -| mode<sup>9+</sup> | [RouterMode](#routermode9) | å¦ | 跳转页é¢ä½¿ç”¨çš„模å¼ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------- | ---- | ------------------ | +| options | [RouterOptions](#routeroptions) | 是 | 替æ¢é¡µé¢æè¿°ä¿¡æ¯ã€‚ | **示例:** - ```js - // 在当å‰é¡µé¢ä¸ - export default { - replacePage() { - router.replace({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, - }, router.RouterMode.Standard); - } - } - ``` +```js +router.replace({ + url: 'pages/detail', + params: { + data1: 'message', + }, +}); +``` - ```js - // 在detail页é¢ä¸ - export default { - data: { - data1: 'default' - }, - onInit() { - console.info('showData1:' + this.data1) - } - } - ``` + ## router.replace<sup>9+</sup> + +replace(options: RouterOptions, mode: RouterMode): void + +用应用内的æŸä¸ªé¡µé¢æ›¿æ¢å½“å‰é¡µé¢ï¼Œå¹¶é”€æ¯è¢«æ›¿æ¢çš„页é¢ã€‚ + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ------------------------------- | ---- | -------------------- | +| options | [RouterOptions](#routeroptions) | 是 | 替æ¢é¡µé¢æè¿°ä¿¡æ¯ã€‚ | +| mode<sup>9+</sup> | [RouterMode](#routermode9) | 是 | 跳转页é¢ä½¿ç”¨çš„模å¼ã€‚ | + +**示例:** + +```js +router.replace({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, +}, router.RouterMode.Standard); +``` ## router.back @@ -117,59 +126,15 @@ back(options?: RouterOptions ): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [RouterOptions](#routeroptions) | 是 | 返回页é¢æè¿°ä¿¡æ¯ï¼Œå…¶ä¸å‚æ•°url指路由跳转时会返回到指定urlçš„ç•Œé¢ï¼Œå¦‚果页é¢æ ˆä¸Šæ²¡æœ‰url页é¢ï¼Œåˆ™ä¸å“应该情况。如果url未设置,则返回上一页。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------- | ---- | ------------------------------------------------------------ | +| options | [RouterOptions](#routeroptions) | å¦ | 返回页é¢æè¿°ä¿¡æ¯ï¼Œå…¶ä¸å‚æ•°url指路由跳转时会返回到指定urlçš„ç•Œé¢ï¼Œå¦‚果页é¢æ ˆä¸Šæ²¡æœ‰url页é¢ï¼Œåˆ™ä¸å“应该情况。如果url未设置,则返回上一页。 | **示例:** - ```js - // indexé¡µé¢ - export default { - indexPushPage() { - router.push({ - url: 'pages/detail/detail', - }); - } - } - ``` - ```js - // detailé¡µé¢ - export default { - detailPushPage() { - router.push({ - url: 'pages/mall/mall', - }); - } - } - ``` - - ```js - // mall页é¢é€šè¿‡back,将返回detailé¡µé¢ - export default { - mallBackPage() { - router.back(); - } - } - ``` - - ```js - // detail页é¢é€šè¿‡back,将返回indexé¡µé¢ - export default { - defaultBack() { - router.back(); - } - } - ``` - - ```js - // 通过back,返回到detailé¡µé¢ - export default { - backToDetail() { - router.back({uri:'pages/detail/detail'}); - } - } - ``` +```js +router.back({url:'pages/detail'}); +``` ## router.clear @@ -180,13 +145,10 @@ clear(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** - ```js - export default { - clearPage() { - router.clear(); - } - }js - ``` + +```js +router.clear(); +``` ## router.getLength @@ -197,19 +159,15 @@ getLength(): string **系统能力:** SystemCapability.ArkUI.ArkUI.Full **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | ---------------------------------- | | string | 页é¢æ•°é‡ï¼Œé¡µé¢æ ˆæ”¯æŒæœ€å¤§æ•°å€¼æ˜¯32。 | **示例:** - ```js - export default { - getLength() { - var size = router.getLength(); - console.log('pages stack size = ' + size); - } - } - ``` +```js +var size = router.getLength(); +console.log('pages stack size = ' + size); +``` ## router.getState @@ -224,28 +182,26 @@ getState(): RouterState | 类型 | 说明 | | --------------------------- | -------------- | | [RouterState](#routerstate) | 页é¢çŠ¶æ€ä¿¡æ¯ã€‚ | +**示例:** + +```js +var page = router.getState(); +console.log('current index = ' + page.index); +console.log('current name = ' + page.name); +console.log('current path = ' + page.path); +``` + ## RouterState -页é¢çŠ¶æ€ä¿¡æ¯ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 +页é¢çŠ¶æ€ä¿¡æ¯ã€‚ -| å称 | 类型 | 说明 | -| -------- | -------- | -------- | -| index | number | 表示当å‰é¡µé¢åœ¨é¡µé¢æ ˆä¸çš„索引。<br/>>  **说明:**<br/>> ä»Žæ ˆåº•åˆ°æ ˆé¡¶ï¼Œindex从1开始递增。 | -| name | string | 表示当å‰é¡µé¢çš„å称,å³å¯¹åº”文件å。 | -| path | string | 表示当å‰é¡µé¢çš„路径。 | +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 -**示例:** - ```js - export default { - getState() { - var page = router.getState(); - console.log('current index = ' + page.index); - console.log('current name = ' + page.name); - console.log('current path = ' + page.path); - } - } - ``` +| å称 | 类型 | 说明 | +| ----- | ------ | ------------------------------------------------------------ | +| index | number | 表示当å‰é¡µé¢åœ¨é¡µé¢æ ˆä¸çš„ç´¢å¼•ã€‚ä»Žæ ˆåº•åˆ°æ ˆé¡¶ï¼Œindex从1开始递增。 | +| name | string | 表示当å‰é¡µé¢çš„å称,å³å¯¹åº”文件å。 | +| path | string | 表示当å‰é¡µé¢çš„路径。 | ## router.enableAlertBeforeBackPage @@ -256,26 +212,16 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信æ¯æ述。 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------------- | ---- | ------------------ | +| options | [EnableAlertOptions](#enablealertoptions) | 是 | 文本弹窗信æ¯æ述。 | **示例:** - ```js - export default { - enableAlertBeforeBackPage() { - router.enableAlertBeforeBackPage({ - message: 'Message Info', - success: function() { - console.log('success'); - }, - fail: function() { - console.log('fail'); - }, - }); - } - } + ```js + router.enableAlertBeforeBackPage({ + message: 'Message Info' + }); ``` ## EnableAlertOptions @@ -283,9 +229,9 @@ enableAlertBeforeBackPage(options: EnableAlertOptions): void **系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Full。 -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| message | string | 是 | 询问对è¯æ¡†å†…容。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---------------- | +| message | string | 是 | 询问对è¯æ¡†å†…容。 | ## router.disableAlertBeforeBackPage @@ -296,13 +242,9 @@ disableAlertBeforeBackPage(): void **系统能力:** SystemCapability.ArkUI.ArkUI.Full **示例:** - ```js - export default { - disableAlertBeforeBackPage() { - router.disableAlertBeforeBackPage(); - } - } - ``` +```js +router.disableAlertBeforeBackPage(); +``` ## router.getParams @@ -320,133 +262,140 @@ getParams(): Object **示例:** -- ç±»Web范示例 - ```js - // 在当å‰é¡µé¢ä¸ - export default { - pushPage() { - router.push({ - url: 'pages/detail/detail', - params: { - data1: 'message', - }, - }); - } - } - ``` - ```js - // 在detail页é¢ä¸ - export default { - onInit() { - console.info('showData1:' + router.getParams().data1); - } - } - ``` - -- 声明å¼ç¤ºä¾‹ - - ```ts - //通过router.pushè·³è½¬è‡³ç›®æ ‡é¡µæºå¸¦paramså‚æ•° - import router from '@ohos.router' - - @Entry - @Component - struct Index { - async routePage() { - let options = { - url: 'pages/second', - params: { - text: '这是第一页的值', - data: { - array: [12, 45, 78] - }, - } - } - try { - await router.push(options) - } catch (err) { - console.info(` fail callback, code: ${err.code}, msg: ${err.msg}`) - } - } - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('这是第一页') - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(25) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ top: 20 }) - .backgroundColor('#ccc') - .onClick(() => { - this.routePage() - }) - } - .width('100%') - .height('100%') - } - } - ``` - - ```ts - //在second页é¢ä¸æŽ¥æ”¶ä¼ 递过æ¥çš„å‚æ•° - import router from '@ohos.router' - - @Entry - @Component - struct Second { - private content: string = "这是第二页" - @State text: string = router.getParams()['text'] - @State data: any = router.getParams()['data'] - @State secondData : string = '' - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text(`${this.content}`) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Text(this.text) - .fontSize(30) - .onClick(()=>{ - this.secondData = (this.data.array[1]).toString() - }) - .margin({top:20}) - Text('ç¬¬ä¸€é¡µä¼ æ¥çš„数值' + ' ' + this.secondData) - .fontSize(20) - .margin({top:20}) - .backgroundColor('red') - } - .width('100%') - .height('100%') - } - } - ``` +``` +router.getParams(); +``` ## RouterOptions 路由跳转选项。 -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Lite。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite。 -| å称 | 类型 | å¿…å¡« | 说明 | -| -------- | -------- | -------- | -------- | -| url | string | 是 | è¡¨ç¤ºç›®æ ‡é¡µé¢çš„uri,å¯ä»¥ç”¨ä»¥ä¸‹ä¸¤ç§æ ¼å¼ï¼š<br/>- 页é¢ç»å¯¹è·¯å¾„,由é…置文件ä¸pages列表æ供,例如:<br/> - pages/index/index<br/> - pages/detail/detail<br/>- 特殊值,如果uri的值是"/",则跳转到首页。 | -| params | Object | å¦ | 跳转时è¦åŒæ—¶ä¼ é€’åˆ°ç›®æ ‡é¡µé¢çš„æ•°æ®ï¼Œè·³è½¬åˆ°ç›®æ ‡é¡µé¢åŽï¼Œå‚æ•°å¯ä»¥åœ¨é¡µé¢ä¸ç›´æŽ¥ä½¿ç”¨ï¼Œå¦‚this.data1(data1为跳转时paramså‚æ•°ä¸çš„key值)ã€‚å¦‚æžœç›®æ ‡é¡µé¢ä¸å·²æœ‰è¯¥å—æ®µï¼Œåˆ™å…¶å€¼ä¼šè¢«ä¼ å…¥çš„å—段值覆盖。 | +| å称 | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| url | string | 是 | è¡¨ç¤ºç›®æ ‡é¡µé¢çš„uri,å¯ä»¥ç”¨ä»¥ä¸‹ä¸¤ç§æ ¼å¼ï¼š<br/>- 页é¢ç»å¯¹è·¯å¾„,由é…置文件ä¸pages列表æ供,例如:<br/> - pages/index/index<br/> - pages/detail/detail<br/>- 特殊值,如果uri的值是"/",则跳转到首页。 | +| params | Object | å¦ | 跳转时è¦åŒæ—¶ä¼ é€’åˆ°ç›®æ ‡é¡µé¢çš„æ•°æ®ï¼Œè·³è½¬åˆ°ç›®æ ‡é¡µé¢åŽï¼Œå‚æ•°å¯ä»¥åœ¨é¡µé¢ä¸ç›´æŽ¥ä½¿ç”¨ï¼Œå¦‚this.data1(data1为跳转时paramså‚æ•°ä¸çš„key值)ã€‚å¦‚æžœç›®æ ‡é¡µé¢ä¸å·²æœ‰è¯¥å—æ®µï¼Œåˆ™å…¶å€¼ä¼šè¢«ä¼ å…¥çš„å—段值覆盖。 | - >  **说明:** + > **说明:** > 页é¢è·¯ç”±æ ˆæ”¯æŒçš„最大Pageæ•°é‡ä¸º32。 ## RouterMode<sup>9+</sup> 路由跳转模å¼ã€‚ -**系统能力:** 以下å„项对应的系统能力å‡ä¸ºSystemCapability.ArkUI.ArkUI.Lite。 +**系统能力:** SystemCapability.ArkUI.ArkUI.Full。 + +| å称 | æè¿° | +| -------- | ------------------------------------------------------------ | +| Standard | æ ‡å‡†æ¨¡å¼ã€‚ | +| Single | å•å®žä¾‹æ¨¡å¼ã€‚<br/>å¦‚æžœç›®æ ‡é¡µé¢çš„url在页é¢æ ˆä¸å·²ç»å˜åœ¨åŒurl页é¢ï¼Œç¦»æ ˆé¡¶æœ€è¿‘的页é¢ä¼šè¢«ç§»åŠ¨åˆ°æ ˆé¡¶ï¼Œç§»åŠ¨åŽçš„页é¢ä¸ºæ–°å»ºé¡µã€‚<br/>å¦‚ç›®æ ‡é¡µé¢çš„url在页é¢æ ˆä¸ä¸å˜åœ¨åŒurl页é¢ï¼ŒæŒ‰æ ‡å‡†æ¨¡å¼è·³è½¬ã€‚ | + +## 完整示例 -| å称 | æè¿° | -| -------- | -------- | -| Standard | æ ‡å‡†æ¨¡å¼ã€‚ | -| Single | å•å®žä¾‹æ¨¡å¼ã€‚<br/>å¦‚æžœç›®æ ‡é¡µé¢çš„url在页é¢æ ˆä¸å·²ç»å˜åœ¨åŒurl页é¢ï¼Œç¦»æ ˆé¡¶æœ€è¿‘的页é¢ä¼šè¢«ç§»åŠ¨åˆ°æ ˆé¡¶ï¼Œç§»åŠ¨åŽçš„页é¢ä¸ºæ–°å»ºé¡µã€‚<br/>å¦‚ç›®æ ‡é¡µé¢çš„url在页é¢æ ˆä¸ä¸å˜åœ¨åŒurl页é¢ï¼ŒæŒ‰æ ‡å‡†æ¨¡å¼è·³è½¬ã€‚ | +### 基于JS扩展的类Webå¼€å‘èŒƒå¼ + +```js +// 在当å‰é¡µé¢ä¸ +export default { + pushPage() { + router.push({ + url: 'pages/detail/detail', + params: { + data1: 'message', + }, + }); + } +} +``` +```js +// 在detail页é¢ä¸ +export default { + onInit() { + console.info('showData1:' + router.getParams()[data1]); + } +} +``` + +### 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ + +```ts +//通过router.pushè·³è½¬è‡³ç›®æ ‡é¡µæºå¸¦paramså‚æ•° +import router from '@ohos.router' + +@Entry +@Component +struct Index { + async routePage() { + let options = { + url: 'pages/second', + params: { + text: '这是第一页的值', + data: { + array: [12, 45, 78] + }, + } + } + try { + await router.push(options) + } catch (err) { + console.info(` fail callback, code: ${err.code}, msg: ${err.msg}`) + } + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('这是第一页') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ top: 20 }) + .backgroundColor('#ccc') + .onClick(() => { + this.routePage() + }) + } + .width('100%') + .height('100%') + } +} +``` + +```ts +//在second页é¢ä¸æŽ¥æ”¶ä¼ 递过æ¥çš„å‚æ•° +import router from '@ohos.router' + +@Entry +@Component +struct Second { + private content: string = "这是第二页" + @State text: string = router.getParams()['text'] + @State data: any = router.getParams()['data'] + @State secondData : string = '' + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text(this.text) + .fontSize(30) + .onClick(()=>{ + this.secondData = (this.data.array[1]).toString() + }) + .margin({top:20}) + Text('ç¬¬ä¸€é¡µä¼ æ¥çš„数值' + ' ' + this.secondData) + .fontSize(20) + .margin({top:20}) + .backgroundColor('red') + } + .width('100%') + .height('100%') + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index 2456ffa333aecefb4ef88ae0862ee8206325aeda..d45b3934bcdf596a5736864c81a19ef5fa7d5c94 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -1322,7 +1322,7 @@ writeFloatArray(floatArray: number[]): boolean **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | floatArray | number[] | 是 | è¦å†™å…¥çš„浮点数组。 | + | floatArray | number[] | 是 | è¦å†™å…¥çš„浮点数组。由于系统内部对float类型的数æ®æ˜¯æŒ‰ç…§double处ç†çš„,使用时对于数组所å 的总å—节数应按照double类型æ¥è®¡ç®—。 | **返回值:** | 类型 | 说明 | @@ -1349,7 +1349,7 @@ readFloatArray(dataIn: number[]) : void **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | dataIn | number[] | 是 | è¦è¯»å–的浮点数组。 | + | dataIn | number[] | 是 | è¦è¯»å–的浮点数组。由于系统内部对float类型的数æ®æ˜¯æŒ‰ç…§double处ç†çš„,使用时对于数组所å 的总å—节数应按照double类型æ¥è®¡ç®—。 | **示例:** @@ -1764,20 +1764,20 @@ readException(): void let reply = rpc.MessageParcel.create(); data.writeInt(1); data.writeString("hello"); - proxy.sendRequest(1, data, reply, option) + proxy.sendRequestAsync(1, data, reply, option) .then(function(errCode) { if (errCode === 0) { - console.log("sendRequest got result"); + console.log("sendRequestAsync got result"); reply.readException(); let msg = reply.readString(); console.log("RPCTest: reply msg: " + msg); } else { - console.log("RPCTest: sendRequest failed, errCode: " + errCode); + console.log("RPCTest: sendRequestAsync failed, errCode: " + errCode); } }).catch(function(e) { - console.log("RPCTest: sendRequest got exception: " + e.message); + console.log("RPCTest: sendRequestAsync got exception: " + e.message); }).finally (() => { - console.log("RPCTest: sendRequest ends, reclaim parcel"); + console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); data.reclaim(); reply.reclaim(); }); @@ -2504,7 +2504,7 @@ queryLocalInterface(descriptor: string): IRemoteBroker ### sendRequest<sup>(deprecated)</sup> > **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequest<sup>8+</sup>](#sendrequest8)替代。 +> 从 API Version 8 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean @@ -2526,7 +2526,10 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options | boolean | 返回一个布尔值,true表示æˆåŠŸï¼Œfalse表示失败。| -### sendRequest<sup>8+</sup> +### sendRequest<sup>8+(deprecated)</sup> + +> **说明:** +> 从 API Version 9 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> @@ -2534,6 +2537,27 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options **系统能力**:SystemCapability.Communication.IPC.Core +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | code | number | 是 | 本次请求调用的消æ¯ç ,由通信åŒæ–¹ç¡®å®šã€‚如果接å£ç”±IDL工具生æˆï¼Œåˆ™æ¶ˆæ¯ä»£ç ç”±IDL自动生æˆã€‚ | + | data | [MessageParcel](#messageparcel) | 是 | ä¿å˜å¾…å‘é€æ•°æ®çš„ MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应ç”æ•°æ®çš„MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的åŒå¼‚æ¥æ¨¡å¼ï¼Œé»˜è®¤åŒæ¥è°ƒç”¨ã€‚ | + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + +### sendRequestAsync<sup>9+</sup> + +sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> + +以åŒæ¥æˆ–异æ¥æ–¹å¼å‘对端进程å‘é€MessageParcel消æ¯ã€‚如果为选项设置了异æ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦ç«‹å³å…‘现,reply报文里没有内容。如果为选项设置了åŒæ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦å°†åœ¨sendRequestAsync返回时兑现,回å¤å†…容在reply报文里。 + +**系统能力**:SystemCapability.Communication.IPC.Core + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -2653,7 +2677,7 @@ isObjectDead(): boolean ### sendRequest<sup>(deprecated)</sup> > **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequest<sup>8+</sup>](#sendrequest8-2)替代。 +> 从 API Version 8 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9-1)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean @@ -2715,7 +2739,10 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options reply.reclaim(); ``` -### sendRequest<sup>8+</sup> +### sendRequest<sup>8+(deprecated)</sup> + +> **说明:** +> 从 API Version 9 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9-1)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> @@ -2782,6 +2809,72 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options }); ``` +### sendRequestAsync<sup>9+</sup> + +sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> + +以åŒæ¥æˆ–异æ¥æ–¹å¼å‘对端进程å‘é€MessageParcel消æ¯ã€‚如果为选项设置了异æ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦ç«‹å³å…‘现,reply报文里没有内容。如果为选项设置了åŒæ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦å°†åœ¨sendRequestAsync返回时兑现,回å¤å†…容在reply报文里。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | code | number | 是 | 本次请求调用的消æ¯ç ,由通信åŒæ–¹ç¡®å®šã€‚如果接å£ç”±IDL工具生æˆï¼Œåˆ™æ¶ˆæ¯ä»£ç ç”±IDL自动生æˆã€‚ | + | data | [MessageParcel](#messageparcel) | 是 | ä¿å˜å¾…å‘é€æ•°æ®çš„ MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应ç”æ•°æ®çš„MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的åŒå¼‚æ¥æ¨¡å¼ï¼Œé»˜è®¤åŒæ¥è°ƒç”¨ã€‚ | + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + +**示例:** + + ``` + import FA from "@ohos.ability.featureAbility"; + let proxy; + let connect = { + onConnect: function(elementName, remoteProxy) { + console.log("RpcClient: js onConnect called."); + proxy = remoteProxy; + }, + onDisconnect: function(elementName) { + console.log("RpcClient: onDisconnect"); + }, + onFailed: function() { + console.log("RpcClient: onFailed"); + } + }; + let want = { + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.MainAbility", + }; + FA.connectAbility(want, connect); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + proxy.sendRequestAsync(1, data, reply, option) + .then(function(result) { + if (result.errCode === 0) { + console.log("sendRequestAsync got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequestAsync failed, errCode: " + result.errCode); + } + }).catch(function(e) { + console.log("RPCTest: sendRequestAsync got exception: " + e.message); + }).finally (() => { + console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + }); + ``` ### sendRequest<sup>8+</sup> @@ -3082,7 +3175,7 @@ isObjectDead(): boolean | -------- | -------- | -------- | | TF_SYNC | 0 | åŒæ¥è°ƒç”¨ã€‚ | | TF_ASYNC | 1 | 异æ¥è°ƒç”¨ã€‚ | -| TF_ACCEPT_FDS | 0x10 | 指示[sendRequest](#sendrequest8)接å£å¯ä»¥è¿”回文件æ述符。 | +| TF_ACCEPT_FDS | 0x10 | 指示[sendRequestAsync](#sendrequestasync9)接å£å¯ä»¥è¿”回文件æ述符。 | | TF_WAIT_TIME | 8 | ç‰å¾…时间。å•ä½ç§’。 | @@ -3471,7 +3564,7 @@ RemoteObjectæž„é€ å‡½æ•°ã€‚ ### sendRequest<sup>(deprecated)</sup> > **说明:** -> 从 API Version 8 开始废弃,建议使用[sendRequest<sup>8+</sup>](#sendrequest8-4)替代。 +> 从 API Version 8 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9-2)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean @@ -3535,7 +3628,10 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options ``` -### sendRequest<sup>8+</sup> +### sendRequest<sup>8+(deprecated)</sup> + +> **说明:** +> 从 API Version 9 开始废弃,建议使用[sendRequestAsync<sup>9+</sup>](#sendrequestasync9-2)替代。 sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> @@ -3604,6 +3700,73 @@ sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options }); ``` +### sendRequestAsync<sup>9+</sup> + +sendRequestAsync(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise<SendRequestResult> + +以åŒæ¥æˆ–异æ¥æ–¹å¼å‘对端进程å‘é€MessageParcel消æ¯ã€‚如果为选项设置了异æ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦ç«‹å³å…‘现,reply报文里没有内容。如果为选项设置了åŒæ¥æ¨¡å¼ï¼Œåˆ™æœŸçº¦å°†åœ¨sendRequestAsync返回时兑现,回å¤å†…容在reply报文里。 + +**系统能力**:SystemCapability.Communication.IPC.Core + +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | code | number | 是 | 本次请求调用的消æ¯ç ,由通信åŒæ–¹ç¡®å®šã€‚如果接å£ç”±IDL工具生æˆï¼Œåˆ™æ¶ˆæ¯ä»£ç ç”±IDL自动生æˆã€‚ | + | data | [MessageParcel](#messageparcel) | 是 | ä¿å˜å¾…å‘é€æ•°æ®çš„ MessageParcel对象。 | + | reply | [MessageParcel](#messageparcel) | 是 | 接收应ç”æ•°æ®çš„MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的åŒå¼‚æ¥æ¨¡å¼ï¼Œé»˜è®¤åŒæ¥è°ƒç”¨ã€‚ | + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<SendRequestResult> | 返回一个期约,兑现值是sendRequestResult实例。| + +**示例:** + + ``` + class MyDeathRecipient { + onRemoteDied() { + console.log("server died"); + } + } + class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } + } + let testRemoteObject = new TestRemoteObject("testObject"); + let option = new rpc.MessageOption(); + let data = rpc.MessageParcel.create(); + let reply = rpc.MessageParcel.create(); + data.writeInt(1); + data.writeString("hello"); + testRemoteObject.sendRequestAsync(1, data, reply, option) + .then(function(result) { + if (result.errCode === 0) { + console.log("sendRequestAsync got result"); + result.reply.readException(); + let msg = result.reply.readString(); + console.log("RPCTest: reply msg: " + msg); + } else { + console.log("RPCTest: sendRequestAsync failed, errCode: " + result.errCode); + } + }).catch(function(e) { + console.log("RPCTest: sendRequestAsync got exception: " + e.message); + }).finally (() => { + console.log("RPCTest: sendRequestAsync ends, reclaim parcel"); + data.reclaim(); + reply.reclaim(); + }); + ``` ### sendRequest<sup>8+</sup> @@ -3672,7 +3835,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean -sendRequest请求的å“应处ç†å‡½æ•°ï¼ŒæœåŠ¡ç«¯åœ¨è¯¥å‡½æ•°é‡Œå¤„ç†è¯·æ±‚,回å¤ç»“果。 +sendRequestAsync请求的å“应处ç†å‡½æ•°ï¼ŒæœåŠ¡ç«¯åœ¨è¯¥å‡½æ•°é‡Œå¤„ç†è¯·æ±‚,回å¤ç»“果。 **系统能力**:SystemCapability.Communication.IPC.Core diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md index 7581861012f98b643114b083430ce37cf1ae0734..1f3b7ed1329150c973496061d0a4bd780cf08616 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @@ -177,6 +177,8 @@ on(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'beginS **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -199,6 +201,8 @@ on(type: 'beginSleep' | 'endSleep' | 'changeUser', callback: Callback\<number\>) **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -220,6 +224,8 @@ on(type: 'screenlockEnabled', callback: Callback\<boolean\>): void **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -243,6 +249,8 @@ off(type: 'beginWakeUp' | 'endWakeUp' | 'beginScreenOn' | 'endScreenOn' | 'begin **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -265,6 +273,8 @@ sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\<b **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | @@ -282,12 +292,14 @@ sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\<b ## screenlock.sendScreenLockEvent<sup>9+</sup> -sendScreenLockEvent(event: String, parameter: number): Promise<boolean> +sendScreenLockEvent(event: String, parameter: number): Promise\<boolean\> 应用å‘é€äº‹ä»¶åˆ°é”å±æœåŠ¡ï¼Œå¼‚æ¥æ–¹æ³•ã€‚ **系统能力**: SystemCapability.MiscServices.ScreenLock +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚æ•°**: | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen.md b/zh-cn/application-dev/reference/apis/js-apis-screen.md index d8725959e19a165c4db8560cee69e95e33cadc55..9472f9f6d445586231e7bbb44ec1c87b1cc1dc52 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen.md @@ -32,7 +32,7 @@ getAllScreens(callback: AsyncCallback<Array<Screen>>): void var screenClass = null; screen.getAllScreens((err, data) => { if (err.code) { - console.error('Failed to get all screens . Cuase: ' + JSON.stringify(err)); + console.error('Failed to get all screens . Cause: ' + JSON.stringify(err)); return; } console.info('Succeeded in getting all screens . Data:' + JSON.stringify(data)); @@ -223,6 +223,8 @@ createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Scre **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需è¦æƒé™**:ohos.permission.CAPTURE_SCREEN,如果VirtualScreenOption.surfaceId有效,æ¤æƒé™æ˜¯å¿…需的。仅系统应用å¯ç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -256,6 +258,8 @@ createVirtualScreen(options:VirtualScreenOption): Promise<Screen> **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需è¦æƒé™**:ohos.permission.CAPTURE_SCREEN,如果VirtualScreenOption.surfaceId有效,æ¤æƒé™æ˜¯å¿…需的。仅系统应用å¯ç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------- | ------------------------------------------- | ---- | ------------------------ | @@ -343,6 +347,8 @@ setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallb **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需è¦æƒé™**:ohos.permission.CAPTURE_SCREEN,仅系统应用å¯ç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -372,6 +378,8 @@ setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void> **系统能力:** SystemCapability.WindowManager.WindowManager.Core +**需è¦æƒé™**:ohos.permission.CAPTURE_SCREEN,仅系统应用å¯ç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | --------- | ------ | ---- | ------------- | @@ -531,7 +539,7 @@ screen.setScreenRotationLocked(isLocked, (err, data) => { | parent | number | 是 | å¦ | å±å¹•æ‰€å±žç¾¤ç»„çš„id。 | | supportedModeInfo | Array<[ScreenModeInfo](#screenmodeinfo)> | 是 | å¦ | å±å¹•æ”¯æŒçš„模å¼é›†åˆã€‚ | | activeModeIndex | number | 是 | å¦ | 当å‰å±å¹•æ‰€å¤„模å¼ç´¢å¼•ã€‚ | -| orientation | [Orientation](#rientation) | 是 | å¦ | å±å¹•æ–¹å‘。 | +| orientation | [Orientation](#orientation) | 是 | å¦ | å±å¹•æ–¹å‘。 | ### setOrientation setOrientation(orientation: Orientation, callback: AsyncCallback<void>): void @@ -696,9 +704,6 @@ promise.then((data) => { | HORIZONTAL | 2 | 表示指定å±å¹•ä¸ºæ°´å¹³æ–¹å‘。 | | REVERSE_VERTICAL | 3 | 表示指定å±å¹•ä¸ºåå‘åž‚ç›´æ–¹å‘。 | | REVERSE_HORIZONTAL | 4 | 表示指定å±å¹•ä¸ºåå‘水平方å‘。 | -| SENSOR | 5 | 表示å±å¹•æ–¹å‘è·Ÿéšä¼ 感器方å‘。 | -| SENSOR_VERTICAL | 6 | 表示å±å¹•æ–¹å‘åž‚ç›´è·Ÿéšä¼ 感器方å‘。 | -| SENSOR_HORIZONTAL | 7 | 表示å±å¹•æ–¹å‘水平跟éšä¼ 感器方å‘。 | ## ScreenModeInfo å±å¹•æ˜¾ç¤ºæ¨¡å¼ä¿¡æ¯ã€‚ diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index 6871f0ce050609b9871ab727c4fae0a9e910494c..c0126a92a3da3dd958331483243e69f3a46b12f2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -68,29 +68,30 @@ save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>) | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | options | [ScreenshotOptions](#screenshotoptions) | å¦ | 该类型的å‚数包å«screenRect,imageSize,rotation, displayId四个å‚数,å¯ä»¥åˆ†åˆ«è®¾ç½®è¿™å››ä¸ªå‚数。 | -| callback | AsyncCallback<image.PixelMap> | 是 | 回调函数。返回一个PixelMap对象。 | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。返回一个PixelMap对象。 | **示例:** ```js - var ScreenshotOptions = { - "screenRect": { - "left": 200, - "top": 100, - "width": 200, - "height": 200}, - "imageSize": { - "width": 300, - "height": 300}, - "rotation": 0, - "displayId": 0 + var screenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0, + "displayId": 0 }; - screenshot.save(ScreenshotOptions, (err, data) => { - if (err) { - console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err)); - return; - } - console.info('Screenshot saved. Data: ' + JSON.stringify(data)); + screenshot.save(screenshotOptions, (err, pixelMap) => { + if (err) { + console.log('Failed to save screenshot: ' + JSON.stringify(err)); + return; + } + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完åŽåŠæ—¶é‡Šæ”¾å†…å˜ }); ``` @@ -114,12 +115,12 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> | 类型 | 说明 | | ----------------------------- | ----------------------------------------------- | -| Promise<image.PixelMap> | Promise对象。返回一个PixelMap对象。 | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回一个PixelMap对象。 | **示例:** ```js - var ScreenshotOptions = { + var screenshotOptions = { "screenRect": { "left": 200, "top": 100, @@ -131,10 +132,11 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap> "rotation": 0, "displayId": 0 }; - let promise = screenshot.save(ScreenshotOptions); - promise.then(() => { - console.log('screenshot save success'); + let promise = screenshot.save(screenshotOptions); + promise.then((pixelMap) => { + console.log('Succeeded in saving sreenshot. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完åŽåŠæ—¶é‡Šæ”¾å†…å˜ }).catch((err) => { - console.log('screenshot save fail: ' + JSON.stringify(err)); + console.log('Failed to save screenshot: ' + JSON.stringify(err)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md index 5dedb55f06c6e564743cda51a39057625791a518..85ecc774d519951c987c22e7cd9b1c40b3de19cd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md +++ b/zh-cn/application-dev/reference/apis/js-apis-securityLabel.md @@ -48,8 +48,7 @@ setSecurityLabel(path:string, type:dataLevel):Promise<void> **示例:** ```js - let type = "s4"; - securityLabel.setSecurityLabel(path, type).then(function(){ + securityLabel.setSecurityLabel(path, "s0").then(function(){ console.info("setSecurityLabel successfully"); }).catch(function(error){ console.info("setSecurityLabel failed with error:" + error); @@ -75,8 +74,7 @@ setSecurityLabel(path:string, type:dataLevel, callback: AsyncCallback<void> **示例:** ```js - let type = "s4"; - securityLabel.setSecurityLabel(path, type, function(error){ + securityLabel.setSecurityLabel(path, "s0", function(error){ console.info("setSecurityLabel:" + JSON.stringify(error)); }); ``` @@ -98,8 +96,7 @@ setSecurityLabelSync(path:string, type:dataLevel):void **示例:** ```js -let type = "s4"; -securityLabel.setSecurityLabelSync(path, type); +securityLabel.setSecurityLabelSync(path, "s0"); ``` ## securityLabel.getSecurityLabel @@ -125,11 +122,10 @@ getSecurityLabel(path:string):Promise<string> **示例:** ```js - let type = "s4"; securityLabel.getSecurityLabel(path).then(function(type){ console.log("getSecurityLabel successfully:" + type); - }).catch(function(error){ - console.log("getSecurityLabel failed with error:" + error); + }).catch(function(err){ + console.log("getSecurityLabel failed with error:" + err); }); ``` @@ -151,8 +147,7 @@ getSecurityLabel(path:string, callback:AsyncCallback<string>): void **示例:** ```js - let type = "s4"; - securityLabel.getSecurityLabel(path,function(error, type){ + securityLabel.getSecurityLabel(path, function(err, type){ console.log("getSecurityLabel successfully:" + type); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index 9a6f1207744a901dac3d9bdc718d83eead38c923..51b33a58ec38d345f1d351d17606228ce7d04eb6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -1,7 +1,5 @@ # ä¼ æ„Ÿå™¨ -## 模å—说明 - sensor模å—æä¾›è®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®åŸºæœ¬èƒ½åŠ›ï¼ŒåŒ…括订阅ã€å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ï¼ŒèŽ·å–ä¼ æ„Ÿå™¨åˆ—è¡¨ï¼Œä»¥åŠé€šç”¨çš„ä¼ æ„Ÿå™¨ç®—æ³•æŽ¥å£å¦‚通过气压值计算海拔高度ã€é€šè¿‡æ—‹è½¬çŸ©é˜µè®¡ç®—设备方å‘ç‰ã€‚ ä¼ æ„Ÿå™¨æ˜¯æŒ‡ç”¨äºŽä¾¦æµ‹çŽ¯å¢ƒä¸æ‰€å‘生事件或å˜åŒ–,并将æ¤æ¶ˆæ¯å‘é€è‡³å…¶ä»–电å设备(如ä¸å¤®å¤„ç†å™¨ï¼‰çš„设备,通常由æ•æ„Ÿç»„件和转æ¢ç»„件组æˆã€‚ä¼ æ„Ÿå™¨æ˜¯å®žçŽ°ç‰©è”网智能化的é‡è¦åŸºçŸ³ï¼Œä¸ºå®žçŽ°å…¨åœºæ™¯æ™ºæ…§åŒ–战略,支撑“1+8+Nâ€äº§å“需求,需è¦æž„ç‘ç»Ÿä¸€çš„ä¼ æ„Ÿå™¨ç®¡ç†æ¡†æž¶ï¼Œè¾¾åˆ°ä¸ºå„产å“/业务æ供低时延ã€ä½ŽåŠŸè€—的感知数æ®çš„ç›®çš„ã€‚æ ¹æ®ç”¨é€”å¯åˆ†ä¸ºä»¥ä¸‹å…大类: @@ -54,12 +52,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Acceler ); ``` -### LINEAR_ACCELERATION +### LINEAR_ACCELERATION<sup>deprecated</sup> on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, options?: Options): void 监å¬çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨çš„æ•°æ®å˜åŒ–。如果多次调用该接å£ï¼Œä»…最åŽä¸€æ¬¡è°ƒç”¨ç”Ÿæ•ˆã€‚ +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.on.LINEAR_ACCELEROMETER<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.ACCELEROMETER ,该æƒé™ä¸ºç³»ç»Ÿæƒé™ **系统能力**:SystemCapability.Sensors.Sensor @@ -82,6 +82,35 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Line ); ``` +### LINEAR_ACCELEROMETER<sup>9+</sup> + +on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>, options?: Options): void + +监å¬çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨çš„æ•°æ®å˜åŒ–。如果多次调用该接å£ï¼Œä»…最åŽä¸€æ¬¡è°ƒç”¨ç”Ÿæ•ˆã€‚ + + +**需è¦æƒé™**:ohos.permission.ACCELEROMETER,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | è¦è®¢é˜…çš„çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | æ³¨å†Œçº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºLinearAccelerometerResponse。 | +| options | [Options](#options) | å¦ | å¯é€‰å‚数列表,设置上报频率,默认值为200000000ns。 | + +**示例:** + ```js + sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,function(data){ + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + }, + {interval: 10000000} + ); + ``` + ### ACCELEROMETER_UNCALIBRATED on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>, options?: Options): void @@ -499,12 +528,14 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<Orientatio ); ``` -### HEART_RATE +### HEART_RATE<sup>deprecated</sup> on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, options?: Options): void 监å¬å¿ƒçŽ‡ä¼ 感器数æ®å˜åŒ–一次。 +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.on.HEART_BEAT_RATE<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor @@ -526,6 +557,33 @@ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ ); ``` +### HEART_BEAT_RATE<sup>9+</sup> + +on(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback<HeartRateResponse>, options?: Options): void + +监å¬å¿ƒçŽ‡ä¼ 感器数æ®å˜åŒ–一次。 + +**需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | è¦è®¢é˜…çš„å¿ƒçŽ‡ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | æ³¨å†Œä¸€æ¬¡å¿ƒçŽ‡ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºHeartRateResponse。 | + +**示例:** + +```js +sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE,function(data){ + console.info("Heart rate: " + data.heartRate); +}, + {interval: 10000000} +); +``` + ### ROTATION_VECTOR on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<RotationVectorResponse>,options?: Options): void @@ -605,12 +663,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Accele ); ``` -### LINEAR_ACCELERATION +### LINEAR_ACCELERATION<sup>deprecated</sup> once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void 监å¬çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨æ•°æ®å˜åŒ–一次。 +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.once.LINEAR_ACCELEROMETER<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.ACCELEROMETER ,该æƒé™ä¸ºç³»ç»Ÿæƒé™ **系统能力**:SystemCapability.Sensors.Sensor @@ -631,6 +691,32 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Li ); ``` +### LINEAR_ACCELEROMETER<sup>9+</sup> + +once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>): void + +è®¢é˜…ä¸€æ¬¡çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨æ•°æ®ã€‚ + +**需è¦æƒé™**:ohos.permission.ACCELEROMETER ,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | æ³¨å†Œä¸€æ¬¡çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºLinearAccelerometerResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, function(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); + } + ); + ``` + ### ACCELEROMETER_UNCALIBRATED once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>): void @@ -1041,12 +1127,14 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<Rota ); ``` -### HEART_RATE +### HEART_RATE<sup>deprecated</sup> once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void 监å¬å¿ƒçŽ‡ä¼ 感器数æ®å˜åŒ–一次。 +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.once.HEART_BEAT_RATE<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor @@ -1065,6 +1153,30 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRate ); ``` +### HEART_BEAT_RATE<sup>9+</sup> + +once(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback<HeartRateResponse>): void + +è®¢é˜…ä¸€æ¬¡å¿ƒçŽ‡ä¼ æ„Ÿå™¨æ•°æ®ã€‚ + +**需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | æ³¨å†Œä¸€æ¬¡å¿ƒçŽ‡ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºHeartRateResponse。 | + +**示例:** + ```js + sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, function(data) { + console.info("Heart rate: " + data.heartRate); + } + ); + ``` + ### WEAR_DETECTION once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void @@ -1326,12 +1438,14 @@ function callback(data) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback); ``` -### HEART_RATE +### HEART_RATE<sup>deprecated</sup> off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€‚ +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.off.HEART_BEAT_RATE<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor @@ -1352,6 +1466,32 @@ function callback(data) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback); ``` +### HEART_BEAT_RATE<sup>9+</sup> + +off(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback?: Callback<HeartRateResponse>): void + +å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€‚ + +**需è¦æƒé™**:ohos.permission.READ_HEALTH_DATA + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | è¦å–æ¶ˆè®¢é˜…çš„å¿ƒçŽ‡ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_HEART_BEAT_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | å–æ¶ˆæ³¨å†Œä¸€æ¬¡å¿ƒçŽ‡ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºHeartRateResponse。 | + +**示例:** + +```js +function callback(data) { + console.info("Heart rate: " + data.heartRate); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback); +``` + ### HUMIDITY off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityResponse>): void @@ -1376,12 +1516,14 @@ function callback(data) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback); ``` -### LINEAR_ACCELERATION +### LINEAR_ACCELERATION<sup>deprecated</sup> off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback<LinearAccelerometerResponse>): void å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€‚ +从API Version9开始该接å£ä¸å†ç»´æŠ¤ï¼ŒæŽ¨è使用sensor.off.LINEAR_ACCELEROMETER<sup>9+</sup> + **需è¦æƒé™**:ohos.permission.ACCELEROMETER,该æƒé™ä¸ºç³»ç»Ÿæƒé™ **系统能力**:SystemCapability.Sensors.Sensor @@ -1404,6 +1546,34 @@ function callback(data) { sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); ``` +### LINEAR_ACCELEROMETER<sup>9+</sup> + +off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback?: Callback<LinearAccelerometerResponse>): void + +å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€‚ + +**需è¦æƒé™**:ohos.permission.ACCELEROMETER,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**系统能力**:SystemCapability.Sensors.Sensor + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| type | [SensorType](#sensortype) | 是 | è¦å–æ¶ˆè®¢é˜…çš„çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ç±»åž‹ä¸ºSENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | å–æ¶ˆæ³¨å†Œæ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨çš„å›žè°ƒå‡½æ•°ï¼Œä¸ŠæŠ¥çš„æ•°æ®ç±»åž‹ä¸ºLinearAccelerometerResponse。 | + +**示例:** + +```js +function callback(data) { + console.info('X-coordinate component: ' + data.x); + console.info('Y-coordinate component: ' + data.y); + console.info('Z-coordinate component: ' + data.z); +} +sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback); +``` + ### MAGNETIC_FIELD off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void @@ -1972,7 +2142,7 @@ createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallbac err.message); return; } - for (var i=0; i < data.rotation.length; i++) { + for (var i=0; i < data.length; i++) { console.info("data[" + i + "]: " + data[i]); } }) @@ -2005,7 +2175,7 @@ createRotationMatrix(rotationVector: Array<number>): Promise<Array<n const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); promise.then((data) => { console.info('createRotationMatrix_promise success'); - for (var i=0; i < data.rotation.length; i++) { + for (var i=0; i < data.length; i++) { console.info("data[" + i + "]: " + data[i]); } }).catch((reason) => { @@ -2172,7 +2342,7 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& err.message); return; } - for (var i=0; i < data.length; i++) { + for (var i=0; i < data.rotation.length; i++) { console.info("data[" + i + "]: " + data[i]) } }) @@ -2206,7 +2376,7 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); promise.then((data) => { console.info('createRotationMatrix_promise successed'); - for (var i=0; i < data.length; i++) { + for (var i=0; i < data.rotation.length; i++) { console.info("data[" + i + "]: " + data[i]); } }).catch((err) => { @@ -2234,7 +2404,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& | SENSOR_TYPE_ID_HUMIDITY | 13 | æ¹¿åº¦ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_ORIENTATION | 256 | æ–¹å‘ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_GRAVITY | 257 | é‡åŠ›ä¼ 感器。 | -| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ID_LINEAR_ACCELERATION<sup>deprecated</sup> | 258 | çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ID_LINEAR_ACCELEROMETER | 258 | çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢é‡ä¼ 感器。 | | SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | çŽ¯å¢ƒæ¸©åº¦ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | æœªæ ¡å‡†ç£åœºä¼ 感器。 | @@ -2242,7 +2413,8 @@ createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number& | SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效è¿åŠ¨ä¼ 感器。 | | SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计æ¥æ£€æµ‹ä¼ 感器。 | | SENSOR_TYPE_ID_PEDOMETER | 266 | 计æ¥ä¼ 感器。 | -| SENSOR_TYPE_ID_HEART_RATE | 278 | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ID_HEART_RATE<sup>deprecated</sup> | 278 | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ID_HEART_BEAT_RATE | 278 | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_WEAR_DETECTION | 280 | ä½©æˆ´æ£€æµ‹ä¼ æ„Ÿå™¨ã€‚ | | SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | æœªæ ¡å‡†åŠ é€Ÿåº¦è®¡ä¼ æ„Ÿå™¨ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md index 1a99c38a34b9863c991e63ba097c5c0e70c07cad..f3a72caed5eddbb876cadf1308be11c30cc481d9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-ability.md @@ -230,7 +230,7 @@ dump(params: Array\<string>): Array\<string>; 转储客户端信æ¯æ—¶è°ƒç”¨ã€‚ -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core +**系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore **系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md index b92fbe05c23d531c26aa788ea1685e0884862763..a6730e833657cbb840b7f34d41401697c5a27acb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @@ -1,8 +1,8 @@ # ServiceExtensionContext -ServiceExtensionContext模å—是ServiceExtension的上下文环境,继承自ExtensionContext。 +ServiceExtensionContext模å—是ServiceExtensionAbility的上下文环境,继承自ExtensionContext。 -ServiceExtensionContext模å—æä¾›ServiceExtension具有的能力和接å£ï¼ŒåŒ…括å¯åŠ¨ã€åœæ¢ã€ç»‘定ã€è§£ç»‘Ability。 +ServiceExtensionContext模å—æä¾›ServiceExtensionAbility具有的能力和接å£ï¼ŒåŒ…括å¯åŠ¨ã€åœæ¢ã€ç»‘定ã€è§£ç»‘Ability。 > **说明:** > @@ -11,15 +11,16 @@ ServiceExtensionContext模å—æä¾›ServiceExtension具有的能力和接å£ï¼Œ ## 使用说明 -ServiceExtensionContext模å—是ServiceExtension的上下文环境,继承自ExtensionContext。 +在使用ServiceExtensionContext的功能å‰ï¼Œéœ€è¦é€šè¿‡ServiceExtensionAbilityå类实例获å–。 -## 属性 - -**系统能力**:SystemCapability.Ability.AbilityRuntime.Core - -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | 是 | å¦ | æœåŠ¡æ‰©å±•ä¿¡æ¯ã€‚ | +```js + import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ServiceExtensionAbility { + onCreate() { + let context = this.context; + } + } +``` ## startAbility @@ -41,18 +42,12 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility"}; - this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringify(err)); - }); - } - } - + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility"}; + this.context.startAbility(want, (err) => { + console.log('startAbility result:' + JSON.stringify(err)); + }); ``` ## startAbility @@ -81,20 +76,16 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility" - }; - this.context.startAbility(want).then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - } - } + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility" + }; + this.context.startAbility(want).then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + ``` ## startAbility @@ -127,13 +118,13 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& windowMode: 0, }; this.context.startAbility(want, options, (error) => { - console.log("error.code = " + error.code) + console.log("error.code = " + error.code) }) ``` ## ServiceExtensionContext.startAbilityWithAccount -startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void\>): void; +startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; æ ¹æ®accountå¯åŠ¨Ability(callbackå½¢å¼ï¼‰ã€‚ @@ -146,7 +137,7 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | **示例:** @@ -179,7 +170,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | [StartOptions](js-apis-application-StartOptions.md) | å¦ | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | | callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | @@ -203,7 +194,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca ## ServiceExtensionContext.startAbilityWithAccount -startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void\>; +startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void>; æ ¹æ®accountå¯åŠ¨Ability(Promiseå½¢å¼ï¼‰ã€‚ @@ -216,9 +207,15 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。。 | | options | [StartOptions](js-apis-application-StartOptions.md) | å¦ | å¯åŠ¨Ability所æºå¸¦çš„å‚数。 | +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | + **示例:** ```js @@ -240,6 +237,297 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): }) ``` +## ServiceExtensionContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(callbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want, (err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.startServiceExtensionAbility + +startServiceExtensionAbility(want: Want): Promise\<void>; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(Promiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.startServiceExtensionAbility(want) + .then((data) => { + console.log('---------- startServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(callbackå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | +| callback | AsyncCallback\<void\> | 是 | å¯åŠ¨Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.startServiceExtensionAbilityWithAccount + +startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +å¯åŠ¨ä¸€ä¸ªæ–°çš„ServiceExtensionAbility(Promiseå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.startServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; + +åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | åœæ¢Abilityçš„wantä¿¡æ¯ã€‚ | +| callback | AsyncCallback\<void\> | 是 | åœæ¢Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want, (err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.stopServiceExtensionAbility + +stopServiceExtensionAbility(want: Want): Promise\<void>; + +åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | åœæ¢Abilityçš„wantä¿¡æ¯ã€‚ | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + this.context.stopServiceExtensionAbility(want) + .then((data) => { + console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); + }) + ``` + +## ServiceExtensionContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void; + +使用å¸æˆ·åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆcallbackå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | åœæ¢Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 需è¦åœæ¢çš„系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | +| callback | AsyncCallback\<void\> | 是 | åœæ¢Ability的回调函数。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId, (err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }); + ``` + +## ServiceExtensionContext.stopServiceExtensionAbilityWithAccount + +stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; + +使用å¸æˆ·åœæ¢åŒä¸€åº”用程åºå†…çš„æœåŠ¡ï¼ˆPromiseå½¢å¼ï¼‰ã€‚ + +**需è¦æƒé™**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力**:SystemCapability.Ability.AbilityRuntime.Core + +**系统API**: æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | 是 | åœæ¢Abilityçš„wantä¿¡æ¯ã€‚ | +| accountId | number | 是 | 需è¦åœæ¢çš„系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 返回一个Promise,包å«æŽ¥å£çš„结果。 | + +**示例:** + + ```js + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "MainAbility" + }; + var accountId = 100; + this.context.stopServiceExtensionAbilityWithAccount(want,accountId) + .then((data) => { + console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + }) + .catch((err) => { + console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); + }) + ``` ## ServiceExtensionContext.terminateSelf @@ -260,19 +548,11 @@ terminateSelf(callback: AsyncCallback<void>): void; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringify(err)); - }); - } - } - - + this.context.terminateSelf((err) => { + console.log('terminateSelf result:' + JSON.stringify(err)); + }); ``` - ## ServiceExtensionContext.terminateSelf terminateSelf(): Promise<void>; @@ -292,17 +572,11 @@ terminateSelf(): Promise<void>; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - this.context.terminateSelf().then((data) => { - console.log('success:' + JSON.stringify(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringify(error)); - }); - } -} - + this.context.terminateSelf().then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); ``` ## ServiceExtensionContext.connectAbility @@ -332,13 +606,13 @@ connectAbility(want: Want, options: ConnectOptions): number; ```js let want = { - "bundleName": "com.example.myapp", - "abilityName": "MyAbility" + "bundleName": "com.example.myapp", + "abilityName": "MyAbility" }; let options = { - onConnect: function(elementName, proxy) {}, - onDisConnect: function(elementName) {}, - onFailed: function(code) {} + onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, + onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, + onFailed(code) { console.log('----------- onFailed -----------') } } let connection = this.context.connectAbility(want,options); ``` @@ -358,7 +632,7 @@ connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | want | [Want](js-apis-application-Want.md) | 是 | å¯åŠ¨Abilityçš„wantä¿¡æ¯ã€‚ | -| accountId | number | 是 | 需è¦å¯åŠ¨çš„accountId。 | +| accountId | number | 是 | 系统å¸å·çš„å¸å·ID,详情å‚考[getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess)。 | | options | ConnectOptions | å¦ | 远端对象实例。 | **返回值:** @@ -405,17 +679,11 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let connection=1 - this.context.disconnectAbility(connection, (err) => { + let connection=1 + this.context.disconnectAbility(connection, (err) => { // connection为connectAbilityä¸çš„返回值 console.log('terminateSelf result:' + JSON.stringify(err)); - }); - } - } - + }); ``` ## ServiceExtensionContext.disconnectAbility @@ -443,16 +711,11 @@ disconnectAbility(connection: number): Promise<void>; **示例:** ```js - import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; - class MainAbility extends ExtensionContext { - onWindowStageCreate(windowStage) { - let connection=1 - this.context.disconnectAbility(connection).then((data) => { // connection为connectAbilityä¸çš„返回值 + let connection=1 + this.context.disconnectAbility(connection).then((data) => { + // connection为connectAbilityä¸çš„返回值 console.log('success:' + JSON.stringify(data)); - }).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringify(error)); - }); - } - } - + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-sim.md b/zh-cn/application-dev/reference/apis/js-apis-sim.md index 1bc5bd4ae94bfdb0d1136ebf50a394d17cb2fc39..d49729103b2fcfc971ad369ea2de3bc682df3f6c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -467,7 +467,7 @@ hasSimCard\(slotId: number, callback: AsyncCallback<boolean\>\): void **示例:** -```jsjs +```js sim.hasSimCard(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -522,7 +522,7 @@ getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo\>): voi | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------------------------------- | ---- | -------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| callback | AsyncCallback\<[IccAccountInfo](#IccAccountInfo7)\> | 是 | 回调函数。 | +| callback | AsyncCallback\<[IccAccountInfo](#iccaccountinfo7)\> | 是 | 回调函数。 | **示例:** @@ -555,7 +555,7 @@ getSimAccountInfo(slotId: number): Promise<IccAccountInfo\> | 类型 | 说明 | | -------------------------------------------- | ------------------------------------------ | -| Promise<[IccAccountInfo](#IccAccountInfo7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„账户信æ¯ã€‚ | +| Promise<[IccAccountInfo](#iccaccountinfo7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„账户信æ¯ã€‚ | **示例:** @@ -584,7 +584,7 @@ getActiveSimAccountInfoList(callback: AsyncCallback<Array<IccAccountInfo\>>): vo | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------------------------- | ---- | ---------- | -| callback | AsyncCallback\<Array<[IccAccountInfo](#IccAccountInfo7)\>\> | 是 | 回调函数。 | +| callback | AsyncCallback\<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | 是 | 回调函数。 | **示例:** @@ -611,7 +611,7 @@ getActiveSimAccountInfoList(): Promise<Array<IccAccountInfo\>>; | 类型 | 说明 | | ---------------------------------------------------- | ---------------------------------------------- | -| Promise<Array<[IccAccountInfo](#IccAccountInfo7)\>\> | 以Promiseå½¢å¼è¿”回活跃å¡æ§½SIMå¡çš„账户信æ¯åˆ—表。 | +| Promise<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | 以Promiseå½¢å¼è¿”回活跃å¡æ§½SIMå¡çš„账户信æ¯åˆ—表。 | **示例:** @@ -646,7 +646,7 @@ setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void\>): void **示例:** ```js -sim.setDefaultVoiceSlotId(0,(err, data) => { +sim.setDefaultVoiceSlotId(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -710,8 +710,8 @@ setShowName\(slotId: number, name: string,callback: AsyncCallback<void\>\): void **示例:** ```js -const name='ä¸å›½ç§»åŠ¨'; -sim.setShowName(0, name,(err, data) => { +const name = 'ä¸å›½ç§»åŠ¨'; +sim.setShowName(0, name, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -744,8 +744,8 @@ setShowName\(slotId: number, name: string\): Promise\<void\> **示例:** ```js -const name='ä¸å›½ç§»åŠ¨'; -let promise = sim.setShowName(0,name); +const name = 'ä¸å›½ç§»åŠ¨'; +let promise = sim.setShowName(0, name); promise.then(data => { console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -839,8 +839,8 @@ setShowNumber\(slotId: number, number: string,callback: AsyncCallback<void\>\): **示例:** ```js -let number='+861xxxxxxxxxx'; -sim.setShowNumber(0, number,(err, data) => { +let number = '+861xxxxxxxxxx'; +sim.setShowNumber(0, number, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -874,8 +874,8 @@ setShowNumber\(slotId: number,number: string\): Promise\<void\> **示例:** ```js -let number='+861xxxxxxxxxx'; -let promise = sim.setShowNumber(0,number); +let number = '+861xxxxxxxxxx'; +let promise = sim.setShowNumber(0, number); promise.then(data => { console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1089,16 +1089,18 @@ setLockState(slotId: number, options: LockInfo, callback: AsyncCallback<LockStat | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | 是 | 回调函数。 | -| options | [LockInfo](#LockInfo8) | 是 | é”ä¿¡æ¯ã€‚<br/>lockType: [LockType](#LockType8)<br/>password: string<br/>state: [LockState](#LockState8) | +| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | +| options | [LockInfo](#lockinfo8) | 是 | é”ä¿¡æ¯ã€‚<br/>lockType: [LockType](#locktype8)<br/>password: string<br/>state: [LockState](#lockstate8) | **示例:** ```js -LockInfo.lockType = 1; -LockInfo.password = "1234"; -LockInfo.state = 0; -sim.setLockState(0, LockInfo, (err, data) => { +let lockInfo = { + lockType = 1, + password = "1234", + state = 0 +}; +sim.setLockState(0, lockInfo, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1121,21 +1123,23 @@ setLockState(slotId: number, options: LockInfo): Promise<LockStatusResponse\> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------- | ---------------------- | ---- | ------------------------------------------------------------ | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| options | [LockInfo](#LockInfo8) | 是 | é”ä¿¡æ¯ã€‚<br/>lockType: [LockType](#LockType8)<br/>password: string<br/>state: [LockState](#LockState8) | +| options | [LockInfo](#lockinfo8) | 是 | é”ä¿¡æ¯ã€‚<br/>lockType: [LockType](#locktype8)<br/>password: string<br/>state: [LockState](#lockstate8) | **返回值:** | 类型 | 说明 | | ---------------------------------------------------- | -------------------------------------------- | -| Promise<[LockStatusResponse](#LockStatusResponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„é”状æ€ã€‚ | +| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„é”状æ€ã€‚ | **示例:** ```js -LockInfo.lockType = 1; -LockInfo.password = "1234"; -LockInfo.state = 0; -let promise = sim.setLockState(0, LockInfo); +let lockInfo = { + lockType = 1, + password = "1234", + state = 0 +}; +let promise = sim.setLockState(0, lockInfo); promise.then(data => { console.log(`setLockState success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1158,8 +1162,8 @@ getLockState(slotId: number, lockType: LockType, callback: AsyncCallback<LockSta | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------- | ---- | --------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| callback | AsyncCallback\<[LockState](#LockState8)\> | 是 | 回调函数。 | -| options | [LockType](#LockType8) | 是 | é”类型。<br/>- 1: PINé”<br/>- 2: PIN2é” | +| callback | AsyncCallback\<[LockState](#lockstate8)\> | 是 | 回调函数。 | +| options | [LockType](#locktype8) | 是 | é”类型。<br/>- 1: PINé”<br/>- 2: PIN2é” | **示例:** @@ -1185,13 +1189,13 @@ getLockState(slotId: number, lockType: LockType): Promise<LockState\> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ------- | ---------------------- | ---- | --------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| options | [LockType](#LockType8) | 是 | é”类型。<br/>- 1: PINé”<br/>- 2: PIN2é” | +| options | [LockType](#locktype8) | 是 | é”类型。<br/>- 1: PINé”<br/>- 2: PIN2é” | **返回值:** | 类型 | 说明 | | ---------------------------------- | -------------------------------------------- | -| Promise<[LockState](#LockState8)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„é”状æ€ã€‚ | +| Promise<[LockState](#lockstate8)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„é”状æ€ã€‚ | **示例:** @@ -1221,14 +1225,14 @@ alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | 是 | 回调函数。 | +| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | | newPin | string | 是 | 新密ç 。 | | oldPin | string | 是 | 旧密ç 。 | **示例:** ```js -sim.alterPin(0, "1234", "0000"(err, data) => { +sim.alterPin(0, "1234", "0000", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1258,7 +1262,7 @@ alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResp | 类型 | 说明 | | ---------------------------------------------------- | --------------------------------------------- | -| Promise<[LockStatusResponse](#LockStatusResponse7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„Pin是å¦æˆåŠŸã€‚ | +| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„Pin是å¦æˆåŠŸã€‚ | **示例:** @@ -1288,7 +1292,7 @@ alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallb | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | -| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | 是 | 回调函数。 | +| callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数。 | | newPin2 | string | 是 | 新密ç 。 | | oldPin2 | string | 是 | 旧密ç 。 | @@ -1325,12 +1329,12 @@ alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise<LockStatusR | 类型 | 说明 | | ---------------------------------------------------- | --------------------------------------------- | -| Promise<[LockStatusResponse](#LockStatusResponse7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„Pin是å¦æˆåŠŸã€‚ | +| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½SIMå¡çš„Pin是å¦æˆåŠŸã€‚ | **示例:** ```js -let promise = sim.alterPin2(0, "1234","0000"); +let promise = sim.alterPin2(0, "1234", "0000"); promise.then(data => { console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1356,13 +1360,13 @@ unlockPin(slotId: number,pin: string ,callback: AsyncCallback<LockStatusResponse | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | | pin | string | 是 | SIMå¡çš„密ç | -| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | 是 | 回调函数。 | +| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | **示例:** ```js -let pin='1234'; -sim.unlockPin(0, pin,(err, data) => { +let pin = '1234'; +sim.unlockPin(0, pin, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1391,13 +1395,13 @@ unlockPin(slotId: number,pin: string): Promise<LockStatusResponse\> | 类型 | 说明 | | ---------------------------------------------------- | -------------------------------------------------- | -| Promise\<[LockStatusResponse](#LockStatusResponse)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | +| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | **示例:** ```js -let pin='1234'; -let promise = sim.unlockPin(0,pin); +let pin = '1234'; +let promise = sim.unlockPin(0, pin); promise.then(data => { console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1424,14 +1428,14 @@ unlockPuk(slotId: number,newPin: string,puk: string ,callback: AsyncCallback<Loc | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | | newPin | string | 是 | é‡ç½®SIMå¡çš„密ç | | puk | string | 是 | SIMå¡å¯†ç 的解é”密ç | -| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | 是 | 回调函数。 | +| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | **示例:** ```js -let puk='1xxxxxxx'; -let newPin='1235'; -sim.unlockPuk(0, newPin,puk,(err, data) => { +let puk = '1xxxxxxx'; +let newPin = '1235'; +sim.unlockPuk(0, newPin, puk, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1461,14 +1465,14 @@ unlockPuk(slotId: number,newPin: string,puk: string): Promise<LockStatusRespo | 类型 | 说明 | | ---------------------------------------------------- | -------------------------------------------------- | -| Promise\<[LockStatusResponse](#LockStatusResponse)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | +| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | **示例:** ```js -let puk='1xxxxxxx'; -let newPin='1235'; -let promise = sim.unlockPuk(0,newPin,puk); +let puk = '1xxxxxxx'; +let newPin = '1235'; +let promise = sim.unlockPuk(0, newPin, puk); promise.then(data => { console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1494,13 +1498,13 @@ promise.then(data => { | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | | pin2 | string | 是 | SIMå¡çš„密ç | -| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | 是 | 回调函数。 | +| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | **示例:** ```js -let pin2='1234'; -sim.unlockPin2(0, pin2,(err, data) => { +let pin2 = '1234'; +sim.unlockPin2(0, pin2, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1529,7 +1533,7 @@ unlockPin2(slotId: number,pin2: string): Promise<LockStatusResponse\> | 类型 | 说明 | | ----------------------------------------------------- | -------------------------------------------------- | -| Promise\<[LockStatusResponse](#LockStatusResponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | +| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | **示例:** @@ -1562,14 +1566,14 @@ unlockPuk2(slotId: number,newPin2: string,puk2: string ,callback: AsyncCallback< | slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | | newPin2 | string | 是 | é‡ç½®SIMå¡çš„密ç | | puk2 | string | 是 | SIMå¡å¯†ç 的解é”密ç | -| callback | AsyncCallback<[LockStatusResponse](#LockStatusResponse7)> | 是 | 回调函数。 | +| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)> | 是 | 回调函数。 | **示例:** ```js -let puk2='1xxxxxxx'; -let newPin2='1235'; -sim.unlockPuk2(0, newPin2,puk2,(err, data) => { +let puk2 = '1xxxxxxx'; +let newPin2 = '1235'; +sim.unlockPuk2(0, newPin2, puk2, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1599,14 +1603,14 @@ unlockPuk2slotId: number,newPin2: string,puk2: string): Promise<LockStatusRes | 类型 | 说明 | | ---------------------------------------------------- | -------------------------------------------------- | -| Promise\<[LockStatusResponse](#LockStatusResponse)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | +| Promise\<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½çš„SIMå¡é”状æ€çš„å“应。 | **示例:** ```js -let puk2='1xxxxxxx'; -let newPin2='1235'; -let promise = sim.unlockPuk2(0,newPin2,puk2); +let puk2 = '1xxxxxxx'; +let newPin2 = '1235'; +let promise = sim.unlockPuk2(0, newPin2, puk2); promise.then(data => { console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1634,143 +1638,1313 @@ getMaxSimCount\(\): number console.log("Result: "+ sim.getMaxSimCount()) ``` +## sim.getSimIccId<sup>7+</sup> -## SimState +getSimIccId(slotId: number, callback: AsyncCallback<string\>): void -SIMå¡çŠ¶æ€ã€‚ +获å–指定å¡æ§½SIMå¡çš„ICCID,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -| å称 | 值 | 说明 | -| --------------------- | ---- | ---------------------------------------------------------- | -| SIM_STATE_UNKNOWN | 0 | SIMå¡çŠ¶æ€æœªçŸ¥ï¼Œå³æ— 法获å–准确的状æ€ã€‚ | -| SIM_STATE_NOT_PRESENT | 1 | 表示SIMå¡å¤„于not present状æ€ï¼Œå³å¡æ§½ä¸æ²¡æœ‰æ’å…¥SIMå¡ã€‚ | -| SIM_STATE_LOCKED | 2 | 表示SIMå¡å¤„于locked状æ€ï¼Œå³SIMå¡è¢«PINã€PUK或网络é”é”定。 | -| SIM_STATE_NOT_READY | 3 | 表示SIMå¡å¤„于not ready状æ€ï¼Œå³SIMå¡åœ¨ä½ä½†æ— 法æ£å¸¸å·¥ä½œã€‚ | -| SIM_STATE_READY | 4 | 表示SIMå¡å¤„于ready状æ€ï¼Œå³SIMå¡åœ¨ä½ä¸”工作æ£å¸¸ã€‚ | -| SIM_STATE_LOADED | 5 | 表示SIMå¡å¤„于loaded状æ€ï¼Œå³SIMå¡åœ¨ä½ä¸”所有å¡æ–‡ä»¶åŠ 载完毕。 | +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -## CardType<sup>7+</sup> +**系统能力**:SystemCapability.Telephony.CoreService -å¡ç±»åž‹ã€‚ +**å‚数:** -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<string\> | 是 | 回调函数。 | -| å称 | 值 | 说明 | -| ----- | ----- | ----- | -|UNKNOWN_CARD | -1 | 未知类型 | -|SINGLE_MODE_SIM_CARD | 10 | å•SIMå¡ | -|SINGLE_MODE_USIM_CARD | 20 | å•USIMå¡ | -|SINGLE_MODE_RUIM_CARD | 30 | å•RUIMå¡ | -|DUAL_MODE_CG_CARD | 40 | åŒå¡æ¨¡å¼C+G | -|CT_NATIONAL_ROAMING_CARD | 41 | ä¸å›½ç”µä¿¡å†…éƒ¨æ¼«æ¸¸å¡ | -|CU_DUAL_MODE_CARD | 42 | ä¸å›½è”通åŒæ¨¡å¡ | -|DUAL_MODE_TELECOM_LTE_CARD | 43 | åŒæ¨¡å¼ç”µä¿¡LTEå¡ | -|DUAL_MODE_UG_CARD | 50 | åŒæ¨¡å¼UGå¡ | -|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | å•ä¸€ISIMå¡ç±»åž‹ | +**示例:** -## LockType<sup>8+</sup> +```js +sim.getSimIccId(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` -é”类型。 + +## sim.getSimIccId<sup>7+</sup> + +getSimIccId(slotId: number): Promise<string\> + +获å–指定å¡æ§½SIMå¡çš„ICCID,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -| å称 | 值 | 说明 | -| -------- | ---- | ----------- | -| PIN_LOCK | 1 | SIMå¡å¯†ç é” | -| FDN_LOCK | 2 | 固定拨å·é” | +**系统能力**:SystemCapability.Telephony.CoreService -## LockState<sup>8+</sup> +**å‚数:** -é”状æ€ã€‚ +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------- | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„ICCID。 | + +**示例:** + +```js +let promise = sim.getSimIccId(0); +promise.then(data => { + console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimIccId fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getVoiceMailIdentifier<sup>8+</sup> + +getVoiceMailIdentifier(slotId: number, callback: AsyncCallback<string\>): void + +获å–指定å¡æ§½ä¸SIMå¡è¯éŸ³ä¿¡ç®±çš„alphaæ ‡è¯†ç¬¦ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -| å称 | 值 | 说明 | -| -------- | ---- | ---------- | -| LOCK_OFF | 0 | é”å…³é—çŠ¶æ€ | -| LOCK_ON | 1 | é”å¼€å¯çŠ¶æ€ | +**系统能力**:SystemCapability.Telephony.CoreService -## **PersoLockType**<sup>8+</sup> +**å‚数:** -定制é”类型。 +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<string\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getVoiceMailIdentifier(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getVoiceMailIdentifier<sup>8+</sup> + +getVoiceMailIdentifier(slotId: number): Promise<string\> + +获å–指定å¡æ§½ä¸SIMå¡è¯éŸ³ä¿¡ç®±çš„alphaæ ‡è¯†ç¬¦ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -| å称 | 值 | 说明 | -| ------------ | ---- | ----------------------------------------------- | -| PN_PIN_LOCK | 0 | 定制网络PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | -| PN_PUK_LOCK | 1 | 定制网络PUké” | -| PU_PIN_LOCK | 2 | 定制网络å集PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | -| PU_PUK_LOCK | 3 | 定制网络å集PUKé” | -| PP_PIN_LOCK | 4 | 定制æœåŠ¡æ供者PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | -| PP_PUK_LOCK | 5 | 定制æœåŠ¡æ供者PUKé” | -| PC_PIN_LOCK | 6 | 定制ä¼ä¸šPINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | -| PC_PUK_LOCK | 7 | 定制ä¼ä¸šPuké” | -| SIM_PIN_LOCK | 8 | 定制SIMçš„PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | -| SIM_PUK_LOCK | 9 | 定制SIMçš„PUKé” | +**系统能力**:SystemCapability.Telephony.CoreService -## **LockStatusResponse**<sup>7+</sup> +**å‚数:** -é”状æ€å“应。 +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------- | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„alphaæ ‡è¯†ç¬¦ã€‚ | + +**示例:** + +```js +let promise = sim.getVoiceMailIdentifier(0); +promise.then(data => { + console.log(`getVoiceMailIdentifier success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getVoiceMailIdentifier fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getVoiceMailNumber<sup>8+</sup> + +getVoiceMailNumber(slotId: number, callback: AsyncCallback<string\>): void + +获å–指定å¡æ§½ä¸SIMå¡çš„è¯éŸ³ä¿¡ç®±å·ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -| å称 | 类型 | 说明 | -| --------------- | ------ | ------------------ | -| result | number | 当å‰æ“作的结果 | -| remain?: number | number | 剩余次数(å¯ä»¥ä¸ºç©º) | +**系统能力**:SystemCapability.Telephony.CoreService -## **LockInfo**<sup>8+</sup> +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<string\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getVoiceMailNumber(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` -é”状æ€å“应。 + +## sim.getVoiceMailNumber<sup>8+</sup> + +getVoiceMailNumber(slotId: number): Promise<string\> + +获å–指定å¡æ§½ä¸SIMå¡çš„è¯éŸ³ä¿¡ç®±å·ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE -| å称 | 类型 | 说明 | -| -------- | --------- | ------ | -| lockType | LockType | é”类型 | -| password | string | 密ç | -| state | LockState | é”çŠ¶æ€ | +**系统能力**:SystemCapability.Telephony.CoreService -## **PersoLockInfo**<sup>8+</sup> +**å‚数:** -é”状æ€å“应。 +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------ | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„è¯éŸ³ä¿¡ç®±å·ã€‚ | + +**示例:** + +```js +let promise = sim.getVoiceMailNumber(0); +promise.then(data => { + console.log(`getVoiceMailNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getVoiceMailNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.setVoiceMailInfo<sup>8+</sup> + +setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback<void\>): void + +设置è¯éŸ³é‚®ä»¶ä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService -| å称 | 类型 | 说明 | -| -------- | ------------- | ------------ | -| lockType | PersoLockType | 定制é”的类型 | -| password | string | 密ç | +**å‚数:** -## **IccAccountInfo**<sup>7+</sup> +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | -------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| mailName | string | 是 | 邮件åå— | +| mailNumber | string | 是 | 邮件å·ç | +| callback | AsyncCallback<void\> | 是 | 回调函数。 | -Icc账户信æ¯ã€‚ +**示例:** + +```js +sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com" , (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.setVoiceMailInfo<sup>8+</sup> + +setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise<void\> + +设置è¯éŸ³é‚®ä»¶ä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE -| å称 | 类型 | 说明 | -| ---------- | ------- | ---------------- | -| simId | number | SIMå¡ID | -| slotIndex | number | å¡æ§½ID | -| isEsim | boolean | æ ‡è®°å¡æ˜¯å¦æ˜¯eSim | -| isActive | boolean | å¡æ˜¯å¦è¢«æ¿€æ´» | -| iccId | string | ICCIDå·ç | -| showName | string | SIMå¡æ˜¾ç¤ºå称 | -| showNumber | string | SIMå¡æ˜¾ç¤ºå·ç | +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| mailName | string | 是 | 邮件åå— | +| mailNumber | string | 是 | 邮件å·ç | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com"); +promise.then(data => { + console.log(`setVoiceMailInfo success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`setVoiceMailInfo fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getSimTelephoneNumber<sup>8+</sup> + +getSimTelephoneNumber(slotId: number, callback: AsyncCallback<string\>): void + +获å–指定å¡æ§½ä¸SIMå¡çš„MSISDN,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<string\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getSimTelephoneNumber(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getSimTelephoneNumber<sup>8+</sup> + +getSimTelephoneNumber(slotId: number): Promise<string\> + +获å–指定å¡æ§½ä¸SIMå¡çš„MSISDN,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | -------------------------------------------- | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„MSISDN。 | + +**示例:** + +```js +let promise = sim.getSimTelephoneNumber(0); +promise.then(data => { + console.log(`getSimTelephoneNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimTelephoneNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getSimGid1<sup>7+</sup> + +getSimGid1(slotId: number, callback: AsyncCallback<string\>): void + +获å–指定å¡æ§½ä¸SIMå¡çš„ç»„æ ‡è¯†ç¬¦çº§åˆ«1(GID1),使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<string\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getSimGid1(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getSimGid1<sup>7+</sup> + +getSimGid1(slotId: number): Promise<string\> + +获å–指定å¡æ§½ä¸SIMå¡çš„ç»„æ ‡è¯†ç¬¦çº§åˆ«1(GID1),使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------- | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–指定å¡æ§½SIMå¡çš„æ ‡è¯†ç¬¦çº§åˆ«1。 | + +**示例:** + +```js +let promise = sim.getSimGid1(0); +promise.then(data => { + console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimGid1 fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getIMSI + +getIMSI(slotId: number, callback: AsyncCallback<string\>): void + +获å–国际移动用户识别ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback\<string\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getIMSI(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getIMSI + +getIMSI(slotId: number): Promise<string\> + +获å–国际移动用户识别ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------- | +| Promise<string\> | 以Promiseå½¢å¼è¿”回获å–的国际移动用户识别ç 。 | + +**示例:** + +```js +let promise = sim.getIMSI(0); +promise.then(data => { + console.log(`getIMSI success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getIMSI fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getOperatorConfigs<sup>8+</sup> + +getOperatorConfigs(slotId: number, callback: AsyncCallback<Array<OperatorConfig\>>): void + +获å–è¿è¥å•†é…置,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | 是 | 回调函数。 | + +**示例:** + +```js +sim.getOperatorConfigs(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getOperatorConfigs<sup>8+</sup> + +getOperatorConfigs(slotId: number): Promise<Array<OperatorConfig\>> + +获å–è¿è¥å•†é…置,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.GET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------------- | ----------------------------- | +| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | 以Promiseå½¢å¼è¿”回è¿è¥å•†é…置。 | + +**示例:** + +```js +let promise = sim.getOperatorConfigs(0); +promise.then(data => { + console.log(`getOperatorConfigs success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getOperatorConfigs fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.queryIccDiallingNumbers<sup>8+</sup> + +queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallback<Array<DiallingNumbersInfo\>>): void + +查询SIMå¡è”系人å·ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.READ_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 是 | 回调函数。 | + +**示例:** + +```js +sim.queryIccDiallingNumbers(0, 1, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.queryIccDiallingNumbers<sup>8+</sup> + +queryIccDiallingNumbers(slotId: number, type: ContactType): Promise<Array<DiallingNumbersInfo\>> + +查询SIMå¡è”系人å·ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.READ_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ----------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------------ | +| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | 以Promiseå½¢å¼è¿”回Icc拨å·å·ç 。 | + +**示例:** + +```js +let promise = sim.queryIccDiallingNumbers(0, 1); +promise.then(data => { + console.log(`queryIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`queryIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.addIccDiallingNumbers<sup>8+</sup> + +addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void + +æ·»åŠ SIMå¡è”系人å·ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | +| callback | AsyncCallback<void\> | 是 | 回调函数 | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +sim.addIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.addIccDiallingNumbers<sup>8+</sup> + +addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\> + +æ·»åŠ SIMå¡è”系人å·ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”å›žæ·»åŠ ç»“æžœã€‚ | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +let promise = sim.addIccDiallingNumbers(0, 1, diallingNumbersInof); +promise.then(data => { + console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`addIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.delIccDiallingNumbers<sup>8+</sup> + +delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void + +åˆ é™¤SIMå¡è”系人å·ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | +| callback | AsyncCallback<void\> | 是 | 回调函数 | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +sim.delIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.delIccDiallingNumbers<sup>8+</sup> + +delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\> + +åˆ é™¤SIMå¡è”系人å·ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”å›žåˆ é™¤ç»“æžœã€‚ | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +let promise = sim.delIccDiallingNumbers(0, 1, diallingNumbersInof); +promise.then(data => { + console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`delIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.updateIccDiallingNumbers<sup>8+</sup> + +updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void + +æ›´æ–°SIMå¡è”系人å·ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | +| callback | AsyncCallback<void\> | 是 | 回调函数 | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.updateIccDiallingNumbers<sup>8+</sup> + +updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\> + +æ›´æ–°SIMå¡è”系人å·ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.WRITE_CONTACTS + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| type | [ContactType](#contacttype8) | 是 | è”系人类型。<br/>1 : GENERAL_CONTACT<br/>2 : FIXED_DIALING | +| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | 是 | 拨å·å·ç ä¿¡æ¯ | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ----------------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”回更新的结果。 | + +**示例:** + +```js +let diallingNumbersInof = { + alphaTag = "alpha", + number = "138xxxxxxxx", + recordNumber = 123, + pin2 = "1234" +}; +let promise = sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof); +promise.then(data => { + console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`updateIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.sendEnvelopeCmd<sup>8+</sup> + +sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void + +å‘é€ä¿¡å°å‘½ä»¤ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| cmd | string | 是 | 命令 | +| callback | AsyncCallback<void\> | 是 | 是 | + +**示例:** + +```js +sim.sendEnvelopeCmd(0, "ls", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.sendEnvelopeCmd<sup>8+</sup> + +sendEnvelopeCmd(slotId: number, cmd: string): Promise<void\> + +å‘é€ä¿¡å°å‘½ä»¤ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| cmd | string | 是 | 命令 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”回å‘é€ç»“果。 | + +**示例:** + +```js +let promise = sim.sendEnvelopeCmd(0, "ls"); +promise.then(data => { + console.log(`sendEnvelopeCmd success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`sendEnvelopeCmd fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.sendTerminalResponseCmd<sup>8+</sup> + +sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void + +å‘é€ç»ˆç«¯å“应命令,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| cmd | string | 是 | 命令 | +| callback | AsyncCallback<void\> | 是 | 回调函数。 | + +**示例:** + +```js +sim.sendTerminalResponseCmd(0, "ls", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.sendTerminalResponseCmd<sup>8+</sup> + +sendTerminalResponseCmd(slotId: number, cmd: string): Promise<void\> + +å‘é€ç»ˆç«¯å“应命令,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| cmd | string | 是 | 命令 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise<void\> | 以Promiseå½¢å¼è¿”回å‘é€ç»“果。 | + +**示例:** + +```js +let promise = sim.sendTerminalResponseCmd(0, "ls"); +promise.then(data => { + console.log(`sendTerminalResponseCmd success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`sendTerminalResponseCmd fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.unlockSimLock<sup>8+</sup> + +unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback<LockStatusResponse\>): void + +解é”SIMå¡é”,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| lockInfo | [PersoLockInfo](#persolockinfo8) | 是 | 定制é”ç±»åž‹ä¿¡æ¯ | +| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | 是 | 回调函数 | + +**示例:** + +```js +let persoLockInfo = { + lockType = 0, + password = "1234" +}; +sim.unlockSimLock(0, persoLockInfo, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.unlockSimLock<sup>8+</sup> + +unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise<LockStatusResponse\> + +解é”SIMå¡é”,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| lockInfo | [PersoLockInfo](#persolockinfo8) | 是 | 定制é”ç±»åž‹ä¿¡æ¯ | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------------------- | ------------------------- | +| Promise<[LockStatusResponse](#lockstatusresponse7)\> | 以Promiseå½¢å¼è¿”回é”状æ€ã€‚ | + +**示例:** + +```js +let persoLockInfo = { + lockType = 0, + password = "1234" +}; +let promise = sim.unlockSimLock(0, persoLockInfo); +promise.then(data => { + console.log(`unlockSimLock success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`unlockSimLock fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getOpKey<sup>9+</sup> + +getOpKey(slotId: number, callback: AsyncCallback<number\>): void + +获å–指定å¡æ§½ä¸SIMå¡çš„opkey,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<number\> | 是 | 回调函数 | + +**示例:** + +```js +sim.getOpKey(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getOpKey<sup>9+</sup> + +getOpKey(slotId: number): Promise<number\> + +获å–指定å¡æ§½ä¸SIMå¡çš„opkey,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ----------------------------------------- | +| Promise<number\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½ä¸SIMå¡çš„opkey。 | + +**示例:** + +```js +let promise = sim.getOpKey(0); +promise.then(data => { + console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getOpKey fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sim.getOpName<sup>9+</sup> + +getOpName(slotId: number, callback: AsyncCallback<string\>): void + +获å–指定å¡æ§½ä¸SIMå¡çš„OpName,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<string\> | 是 | 回调函数 | + +**示例:** + +```js +sim.getOpName(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.getOpName<sup>9+</sup> + +getOpName(slotId: number): Promise<string\> + +获å–指定å¡æ§½ä¸SIMå¡çš„OpName,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.CoreService + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------ | +| Promise<string\> | 以Promiseå½¢å¼è¿”回指定å¡æ§½ä¸SIMå¡çš„OpName。 | + +**示例:** + +```js +let promise = sim.getOpName(0); +promise.then(data => { + console.log(`getOpName success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getOpName fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## SimState + +SIMå¡çŠ¶æ€ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| --------------------- | ---- | ---------------------------------------------------------- | +| SIM_STATE_UNKNOWN | 0 | SIMå¡çŠ¶æ€æœªçŸ¥ï¼Œå³æ— 法获å–准确的状æ€ã€‚ | +| SIM_STATE_NOT_PRESENT | 1 | 表示SIMå¡å¤„于not present状æ€ï¼Œå³å¡æ§½ä¸æ²¡æœ‰æ’å…¥SIMå¡ã€‚ | +| SIM_STATE_LOCKED | 2 | 表示SIMå¡å¤„于locked状æ€ï¼Œå³SIMå¡è¢«PINã€PUK或网络é”é”定。 | +| SIM_STATE_NOT_READY | 3 | 表示SIMå¡å¤„于not ready状æ€ï¼Œå³SIMå¡åœ¨ä½ä½†æ— 法æ£å¸¸å·¥ä½œã€‚ | +| SIM_STATE_READY | 4 | 表示SIMå¡å¤„于ready状æ€ï¼Œå³SIMå¡åœ¨ä½ä¸”工作æ£å¸¸ã€‚ | +| SIM_STATE_LOADED | 5 | 表示SIMå¡å¤„于loaded状æ€ï¼Œå³SIMå¡åœ¨ä½ä¸”所有å¡æ–‡ä»¶åŠ 载完毕。 | + +## CardType<sup>7+</sup> + +å¡ç±»åž‹ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| ----- | ----- | ----- | +|UNKNOWN_CARD | -1 | 未知类型 | +|SINGLE_MODE_SIM_CARD | 10 | å•SIMå¡ | +|SINGLE_MODE_USIM_CARD | 20 | å•USIMå¡ | +|SINGLE_MODE_RUIM_CARD | 30 | å•RUIMå¡ | +|DUAL_MODE_CG_CARD | 40 | åŒå¡æ¨¡å¼C+G | +|CT_NATIONAL_ROAMING_CARD | 41 | ä¸å›½ç”µä¿¡å†…éƒ¨æ¼«æ¸¸å¡ | +|CU_DUAL_MODE_CARD | 42 | ä¸å›½è”通åŒæ¨¡å¡ | +|DUAL_MODE_TELECOM_LTE_CARD | 43 | åŒæ¨¡å¼ç”µä¿¡LTEå¡ | +|DUAL_MODE_UG_CARD | 50 | åŒæ¨¡å¼UGå¡ | +|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | å•ä¸€ISIMå¡ç±»åž‹ | + +## LockType<sup>8+</sup> + +é”类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| -------- | ---- | ----------- | +| PIN_LOCK | 1 | SIMå¡å¯†ç é” | +| FDN_LOCK | 2 | 固定拨å·é” | + +## LockState<sup>8+</sup> + +é”状æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| -------- | ---- | ---------- | +| LOCK_OFF | 0 | é”å…³é—çŠ¶æ€ | +| LOCK_ON | 1 | é”å¼€å¯çŠ¶æ€ | + +## PersoLockType<sup>8+</sup> + +定制é”类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 值 | 说明 | +| ------------ | ---- | ----------------------------------------------- | +| PN_PIN_LOCK | 0 | 定制网络PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | +| PN_PUK_LOCK | 1 | 定制网络PUké” | +| PU_PIN_LOCK | 2 | 定制网络å集PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | +| PU_PUK_LOCK | 3 | 定制网络å集PUKé” | +| PP_PIN_LOCK | 4 | 定制æœåŠ¡æ供者PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | +| PP_PUK_LOCK | 5 | 定制æœåŠ¡æ供者PUKé” | +| PC_PIN_LOCK | 6 | 定制ä¼ä¸šPINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | +| PC_PUK_LOCK | 7 | 定制ä¼ä¸šPuké” | +| SIM_PIN_LOCK | 8 | 定制SIMçš„PINé”*(å‚ç…§ 3GPP TS 22.022 [33])* | +| SIM_PUK_LOCK | 9 | 定制SIMçš„PUKé” | + +## LockStatusResponse<sup>7+</sup> + +é”状æ€å“应。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| --------------- | ------ | ------------------ | +| result | number | 当å‰æ“作的结果 | +| remain?: number | number | 剩余次数(å¯ä»¥ä¸ºç©º) | + +## LockInfo<sup>8+</sup> + +é”状æ€å“应。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| -------- | ------------------------ | ------ | +| lockType | [LockType](#locktype8) | é”类型 | +| password | string | 密ç | +| state | [LockState](#lockstate8) | é”çŠ¶æ€ | + +## PersoLockInfo<sup>8+</sup> + +é”状æ€å“应。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| -------- | -------------------------------- | ------------ | +| lockType | [PersoLockType](#persolocktype8) | 定制é”的类型 | +| password | string | 密ç | + +## IccAccountInfo<sup>7+</sup> + +Icc账户信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ---------- | ------- | ---------------- | +| simId | number | SIMå¡ID | +| slotIndex | number | å¡æ§½ID | +| isEsim | boolean | æ ‡è®°å¡æ˜¯å¦æ˜¯eSim | +| isActive | boolean | å¡æ˜¯å¦è¢«æ¿€æ´» | +| iccId | string | ICCIDå·ç | +| showName | string | SIMå¡æ˜¾ç¤ºå称 | +| showNumber | string | SIMå¡æ˜¾ç¤ºå·ç | + +## OperatorConfig<sup>8+</sup> + +è¿è¥å•†é…置。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ----- | ------ | ---- | +| field | string | å—段 | +| value | string | 值 | + +## DiallingNumbersInfo<sup>8+</sup> + +拨å·å·ç ä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 + +| å称 | 类型 | 说明 | +| ------------ | ------ | -------- | +| alphaTag | string | æ ‡ç¾ | +| number | string | å·ç | +| recordNumber | number | è®°å½•ç¼–å· | +| pin2 | string | pin2密ç | + +## ContactType<sup>8+</sup> + +è”系人类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.CoreService。 +| å称 | 值 | 说明 | +| :-------------- | ---- | ---------- | +| GENERAL_CONTACT | 1 | 通用è”系人 | +| FIXED_DIALING | 2 | å›ºå®šæ‹¨å· | diff --git a/zh-cn/application-dev/reference/apis/js-apis-sms.md b/zh-cn/application-dev/reference/apis/js-apis-sms.md index ed5918167b1bc9108b845951f7ba8ef5eef4d23d..65468e08bab26059709abe64f47cf0eed8c0d5c7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sms.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sms.md @@ -375,6 +375,739 @@ let result = sms.hasSmsCapability(); console.log(`hasSmsCapability: ${JSON.stringify(result)}`); ``` +## sms.splitMessage<sup>8+</sup> + +splitMessage(content: string, callback: AsyncCallback<Array<string\>>): void + +将长çŸä¿¡æ‹†åˆ†ä¸ºå¤šä¸ªç‰‡æ®µï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------- | ---- | ----------------------------- | +| content | string | 是 | 指示çŸæ¶ˆæ¯å†…容,ä¸èƒ½ä¸ºnull。 | +| callback | AsyncCallback<Array<string\>> | 是 | 回调函数。 | + +**示例:** + +```js +string content= "long message"; +sms.splitMessage(content, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.splitMessage<sup>8+</sup> + +splitMessage(content: string): Promise<Array<string\>> + +将长çŸä¿¡æ‹†åˆ†ä¸ºå¤šä¸ªç‰‡æ®µï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ---------------------------- | +| content | string | 是 | 指示çŸæ¶ˆæ¯å†…容,ä¸èƒ½ä¸ºnull。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------- | ----------------------------------- | +| Promise<Array<string\>> | 以Promiseå½¢å¼è¿”回多个片段的的结果。 | + +**示例:** + +```js +string content = "long message"; +let promise = sms.splitMessage(content); +promise.then(data => { + console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`splitMessage fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.addSimMessage<sup>7+</sup> + +addSimMessage(options: SimMessageOptions, callback: AsyncCallback<void\>): void + +æ·»åŠ SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | --------------- | +| options | [SimMessageOptions](#simmessageoptions7) | 是 | SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let simMessageOptions = { + slotId = 0, + smsc = "test", + pdu = "xxxxxx", + status = 0 +}; +sms.addSimMessage(simMessageOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.addSimMessage<sup>7+</sup> + +addSimMessage(options: SimMessageOptions): Promise<void\> + +æ·»åŠ SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------------------- | ---- | --------------- | +| options | [SimMessageOptions](#simmessageoptions7) | 是 | SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------------- | +| Promise<void> | 以Promiseå½¢å¼è¿”å›žæ·»åŠ çš„ç»“æžœã€‚ | + +**示例:** + +```js +let simMessageOptions = { + slotId = 0, + smsc = "test", + pdu = "xxxxxx", + status = 0 +}; +let promise = sms.addSimMessage(simMessageOptions); +promise.then(data => { + console.log(`addSimMessage success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`addSimMessage fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.delSimMessage<sup>7+</sup> + +delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback<void\>): void + +åˆ é™¤SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------- | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| msgIndex | number | 是 | 消æ¯ç´¢å¼• | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let slotId = 0; +let msgIndex = 1; +sms.delSimMessage(slotId, msgIndex, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.delSimMessage<sup>7+</sup> + +delSimMessage(slotId: number, msgIndex: number): Promise<void\> + +åˆ é™¤SIMå¡ä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------ | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| msgIndex | number | 是 | 消æ¯ç´¢å¼• | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------------- | +| Promise<void> | 以Promiseå½¢å¼è¿”å›žåˆ é™¤çš„ç»“æžœã€‚ | + +**示例:** + +```js +let slotId = 0; +let msgIndex = 1; +let promise = sms.delSimMessage(slotId, msgIndex); +promise.then(data => { + console.log(`delSimMessage success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`delSimMessage fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.updateSimMessage<sup>7+</sup> + +updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback<void\>): void + +æ›´æ–°SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------- | +| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | 是 | æ›´æ–°SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let updateSimMessageOptions = { + slotId = 0, + msgIndex = 1, + newStatus = 0, + pdu = "xxxxxxx", + smsc = "test" +}; +sms.updateSimMessage(updateSimMessageOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.updateSimMessage<sup>7+</sup> + +updateSimMessage(options: UpdateSimMessageOptions): Promise<void\> + +æ›´æ–°SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------------------------------- | ---- | ------------------- | +| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | 是 | æ›´æ–°SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------------- | +| Promise<void> | 以Promiseå½¢å¼è¿”回更新的结果。 | + +**示例:** + +```js +let updateSimMessageOptions = { + slotId = 0, + msgIndex = 1, + newStatus = 0, + pdu = "xxxxxxx", + smsc = "test" +}; +let promise = sms.updateSimMessage(updateSimMessageOptions); +promise.then(data => { + console.log(`updateSimMessage success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`updateSimMessage fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.getAllSimMessages<sup>7+</sup> + +getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage\>>): void + +获å–所有SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage8)\>> | 是 | 回调函数。 | + +**示例:** + +```js +let slotId = 0; +sms.getAllSimMessages(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.getAllSimMessages<sup>7+</sup> + +getAllSimMessages(slotId: number): Promise<Array<SimShortMessage\>> + +获å–所有SIMå¡æ¶ˆæ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | ---------------------------------- | +| PromiseArray<[SimShortMessage](#simshortmessage8)\>> | 以Promiseå½¢å¼è¿”回获å–çš„SIMçŸæ¶ˆæ¯ã€‚ | + +**示例:** + +```js +let slotId = 0; +let promise = sms.getAllSimMessages(slotId); +promise.then(data => { + console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getAllSimMessages fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.setCBConfig<sup>7+</sup> + +setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void\>): void + +设置å°åŒºå¹¿æ’é…置,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------ | ---- | ------------ | +| options | [CBConfigOptions](#cbconfigoptions8) | 是 | å°åŒºå¹¿æ’é…置选项。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +let cbConfigOptions = { + slotId = 0, + smsc = "test", + pdu = "xxxxxxxx", + status = 0 +}; +sms.setCBConfig(cbConfigOptions, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.setCBConfig<sup>7+</sup> + +setCBConfig(options: CBConfigOptions): Promise<void\> + +设置å°åŒºå¹¿æ’é…置,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.RECEIVE_SMS + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------------------------------------ | ---- | ------------ | +| options | [CBConfigOptions](#cbconfigoptions8) | 是 | å°åŒºå¹¿æ’é…置选项。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ----------------------------- | +| Promise<void> | 以Promiseå½¢å¼è¿”回设置的结果。 | + +**示例:** + +```js +let cbConfigOptions = { + slotId = 0, + smsc = "test", + pdu = "xxxxxxxx", + status = 0 +}; +let promise = sms.setCBConfig(cbConfigOptions); +promise.then(data => + console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setCBConfig fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.getSmsSegmentsInfo<sup>8+</sup> + +getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback<SmsSegmentsInfo\>): void + +获å–çŸä¿¡æ®µä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| message | string | 是 | æ¶ˆæ¯ | +| force7bit | boolean | 是 | 是å¦ä½¿ç”¨7bitç¼–ç | +| callback | AsyncCallback<[SmsSegmentsInfo](#smssegmentsinfo8)> | 是 | 回调函数 | + +**示例:** + +```js +let slotId = 0; +sms.getSmsSegmentsInfo(slotId, "message", false, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.getSmsSegmentsInfo<sup>8+</sup> + +getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise<SmsSegmentsInfo\> + +获å–çŸä¿¡æ®µä¿¡æ¯ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ------- | ---- | ----------------------------------------- | +| slotId | number | 是 | SIMå¡æ§½ID:<br/>- 0:å¡æ§½1<br/>- 1:å¡æ§½2 | +| message | string | 是 | æ¶ˆæ¯ | +| force7bit | boolean | 是 | 是å¦ä½¿ç”¨7bitç¼–ç | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | ----------------------------- | +| Promise<[SmsSegmentsInfo](#smssegmentsinfo8)> | 以Promiseå½¢å¼è¿”回çŸä¿¡æ®µä¿¡æ¯ã€‚ | + +**示例:** + +```js +let slotId = 0; +let promise = sms.getSmsSegmentsInfo(slotId, "message", false); +promise.then(data => + console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getSmsSegmentsInfo fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.isImsSmsSupported<sup>8+</sup> + +isImsSmsSupported(callback: AsyncCallback<boolean\>): void + +如果IMS已注册并且在IMS上支æŒSMS,则支æŒé€šè¿‡IMSå‘é€SMS,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------- | ---- | ---------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +```js +sms.isImsSmsSupported((err, data) => { + console.log(`callback: err->${JSON.(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.isImsSmsSupported<sup>8+</sup> + +isImsSmsSupported(): Promise<boolean\> + +如果IMS已注册并且在IMS上支æŒSMS,则支æŒé€šè¿‡IMSå‘é€SMS,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ----------------------- | +| Promise<boolean> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = sms.isImsSmsSupported(); +promise.then(data => { + console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isImsSmsSupported fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.getImsShortMessageFormat<sup>8+</sup> + +getImsShortMessageFormat(callback: AsyncCallback<string\>): void + +获å–IMS上支æŒçš„SMSæ ¼å¼ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ---------- | +| callback | AsyncCallback<string> | 是 | 回调函数。 | + +**示例:** + +```js +sms.getImsShortMessageFormat((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.getImsShortMessageFormat<sup>8+</sup> + +getImsShortMessageFormat(): Promise<string\> + +获å–IMS上支æŒçš„SMSæ ¼å¼ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**返回值:** + +| 类型 | 说明 | +| --------------------- | -------------------------- | +| Promise<string> | 以Promiseå½¢å¼è¿”回SMSæ ¼å¼ã€‚ | + +**示例:** + +```js +let promise = sms.getImsShortMessageFormat(); +promise.then(data => { + console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getImsShortMessageFormat fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.decodeMms<sup>8+</sup> + +decodeMms(mmsFilePathName: string | Array<number\>, callback: AsyncCallback<MmsInformation\>): void + +彩信解ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ------------------------------------------------------- | ---- | -------------- | +| mmsFilePathName | string \|Array<number\> | 是 | 彩信文件路径å | +| callback | AsyncCallback<[MmsInformation](#mmsinformation8)> | 是 | 回调函数。 | + +**示例:** + +```js +let mmsFilePathName = "filename"; +sms.decodeMms(mmsFilePathName, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.decodeMms<sup>8+</sup> + +decodeMms(mmsFilePathName: string | Array<number\>): Promise<MmsInformation\> + +彩信解ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ----------------------- | ---- | -------------- | +| mmsFilePathName | string \|Array<number\> | 是 | 彩信文件路径å | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------------------- | --------------------------- | +| Promise<<[MmsInformation](#mmsinformation8)>> | 以Promiseå½¢å¼è¿”回彩信信æ¯ã€‚ | + +**示例:** + +```js +let mmsFilePathName = "filename"; +let promise = sms.getSmscAddr(mmsFilePathName); +promise.then(data => { + console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`decodeMms fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## sms.encodeMms<sup>8+</sup> + +encodeMms(mms: MmsInformation, callback: AsyncCallback<Array<number\>>): void + +彩信编ç ,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ----------------------------------- | ---- | ---------- | +| mms | [MmsInformation](#mmsinformation8) | 是 | 彩信信æ¯ã€‚ | +| callback | AsyncCallback<Array<number\>> | 是 | 回调函数。 | + +**示例:** + +```js +let mmsAcknowledgeInd = { + transactionId = "100", + version = 0x10, + reportAllowed = 128 +}; +let mmsInformation = { + messageType = 133, + mmsType = mmsAcknowledgeInd +}; +sms.encodeMms(mmsInformation, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sms.encodeMms<sup>8+</sup> + +encodeMms(mms: MmsInformation): Promise<Array<number\>> + +彩信编ç ,使用Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.Telephony.SmsMms + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ---------------------------------- | ---- | ---------- | +| mms | [MmsInformation](#mmsinformation8) | 是 | 彩信信æ¯ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | ----------------------------------- | +| Promise<Array<number\>> | 以Promiseå½¢å¼è¿”回彩信编ç åŽçš„结果。 | + +**示例:** + +```js +let mmsAcknowledgeInd = { + transactionId = "100", + version = 0x10, + reportAllowed = 128 +}; +let mmsInformation = { + messageType = 133, + mmsType = mmsAcknowledgeInd +}; +let promise = sms.encodeMms(mmsInformation); +promise.then(data => { + console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`encodeMms fail, promise: err->${JSON.stringify(err)}`); +}); +``` + ## ShortMessage çŸä¿¡å®žä¾‹ã€‚ @@ -463,4 +1196,422 @@ console.log(`hasSmsCapability: ${JSON.stringify(result)}`); | SEND_SMS_SUCCESS | 0 | å‘é€çŸä¿¡æˆåŠŸã€‚ | | SEND_SMS_FAILURE_UNKNOWN | 1 | å‘é€çŸä¿¡å¤±è´¥ï¼ŒåŽŸå› 未知。 | | SEND_SMS_FAILURE_RADIO_OFF | 2 | å‘é€çŸä¿¡å¤±è´¥ï¼ŒåŽŸå› 为调制解调器关机。 | -| SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | å‘é€çŸä¿¡å¤±è´¥ï¼ŒåŽŸå› 为网络ä¸å¯ç”¨ã€ä¸æ”¯æŒå‘é€æˆ–接收çŸä¿¡ã€‚ | \ No newline at end of file +| SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | å‘é€çŸä¿¡å¤±è´¥ï¼ŒåŽŸå› 为网络ä¸å¯ç”¨ã€ä¸æ”¯æŒå‘é€æˆ–接收çŸä¿¡ã€‚ | + +## MmsInformation<sup>8+</sup> + +彩信信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------------------------------------------------------------ | ---- | --------- | +| messageType | [MessageType](#messagetype8) | 是 | 消æ¯ç±»åž‹ | +| mmsType | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8) | 是 | pdu头类型 | +| attachment | Array<[MmsAttachment](#mmsattachment8)\> | å¦ | 附件 | + +## MmsSendReq<sup>8+</sup> + +彩信å‘é€è¯·æ±‚。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------------- | ------------------------------------ | ---- | ------------ | +| from | [MmsAddress](#mmsaddress8) | 是 | 彩信æ¥æº | +| transactionId | string | 是 | 事务ID | +| contentType | string | 是 | 内容类型 | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| to | Array<[MmsAddress](#mmsaddress8)\> | å¦ | å‘é€è‡³ | +| date | number | å¦ | 日期 | +| cc | Array<[MmsAddress](#mmsaddress8)\> | å¦ | æŠ„é€ | +| bcc | Array<[MmsAddress](#mmsaddress8)\> | å¦ | æš—æŠ„é€ | +| subject | string | å¦ | 主题 | +| messageClass | number | å¦ | 消æ¯ç±» | +| expiry | number | å¦ | 到期 | +| priority | [MmsPriorityType](#mmsprioritytype8) | å¦ | 优先 | +| senderVisibility | number | å¦ | å‘件人å¯è§æ€§ | +| deliveryReport | number | å¦ | 交付报告 | +| readReport | number | å¦ | 阅读报告 | + +## MmsSendConf<sup>8+</sup> + +彩信å‘é€é…置。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------- | ---------------------------------- | ---- | -------- | +| responseState | number | 是 | å“åº”çŠ¶æ€ | +| transactionId | string | 是 | 事务ID | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| messageId | string | å¦ | 消æ¯ID | + +## MmsNotificationInd<sup>8+</sup> + +彩信通知索引。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | ---------------------------------- | ---- | -------- | +| transactionId | string | 是 | 事务ID | +| messageClass | number | 是 | 消æ¯ç±» | +| messageSize | number | 是 | 消æ¯å¤§å° | +| expiry | number | 是 | 到期 | +| contentLocation | string | 是 | 内容ä½ç½® | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| from | [MmsAddress](#mmsaddress8) | å¦ | æ¥æº | +| subject | string | å¦ | 主题 | +| deliveryReport | number | å¦ | 状æ€æŠ¥å‘Š | +| contentClass | number | å¦ | 内容类 | + +## MmsAcknowledgeInd<sup>8+</sup> + +彩信确认索引。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------- | ---------------------------------- | ---- | -------- | +| transactionId | string | 是 | 事务ID | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| reportAllowed | [ReportType](#reporttype8) | å¦ | å…许报告 | + +## MmsRetrieveConf<sup>8+</sup> + +彩信检索é…置。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ------------------------------------ | ---- | -------- | +| transactionId | string | 是 | 事务ID | +| messageId | string | 是 | 消æ¯ID | +| date | number | 是 | 日期 | +| contentType | string | 是 | 内容类型 | +| to | Array<[MmsAddress](#mmsaddress8)\> | 是 | å‘é€è‡³ | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| from | [MmsAddress](#mmsaddress8) | å¦ | æ¥æº | +| cc | Array<[MmsAddress](#mmsaddress8)\> | å¦ | æŠ„é€ | +| subject | string | å¦ | 主题 | +| priority | [MmsPriorityType](#mmsprioritytype8) | å¦ | 优先级 | +| deliveryReport | number | å¦ | 状æ€æŠ¥å‘Š | +| readReport | number | å¦ | 阅读报告 | +| retrieveStatus | number | å¦ | æ£€ç´¢çŠ¶æ€ | +| retrieveText | string | å¦ | 检索文本 | + +## MmsReadOrigInd<sup>8+</sup> + +彩信读å–原始索引。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------- | ---------------------------------- | ---- | -------- | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| messageId | string | 是 | 消æ¯ID | +| to | Array<[MmsAddress](#mmsaddress8)\> | 是 | å‘é€è‡³ | +| from | [MmsAddress](#mmsaddress8) | 是 | æ¥æº | +| date | number | 是 | 日期 | +| readStatus | number | 是 | é˜…è¯»çŠ¶æ€ | + +## MmsAttachment<sup>8+</sup> + +彩信附件。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------------- | ------------------------------------ | ---- | ------------------ | +| contentId | string | 是 | 内容ID | +| contentLocation | string | 是 | 内容ä½ç½® | +| contentDisposition | [DispositionType](#dispositiontype8) | 是 | å†…å®¹å¤„ç† | +| contentTransferEncoding | string | 是 | å†…å®¹ä¼ è¾“ç¼–ç | +| contentType | string | 是 | 内容类型 | +| isSmil | boolean | 是 | åŒæ¥å¤šåª’体集æˆè¯è¨€ | +| path | string | å¦ | 路径 | +| inBuff | Array<number\> | å¦ | ç¼“å†²åŒºä¸ | +| fileName | string | å¦ | 文件å | +| charset | [MmsCharSets](#mmscharsets8) | å¦ | å—符集 | + +## MmsAddress<sup>8+</sup> + +彩信地å€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ---------------------------- | ---- | ------ | +| address | string | 是 | åœ°å€ | +| charset | [MmsCharSets](#mmscharsets8) | 是 | å—符集 | + +## MessageType<sup>8+</sup> + +消æ¯ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| ------------------------- | ---- | -------------------- | +| TYPE_MMS_SEND_REQ | 128 | 彩信å‘é€è¯·æ±‚类型 | +| TYPE_MMS_SEND_CONF | 129 | 彩信å‘é€é…置类型 | +| TYPE_MMS_NOTIFICATION_IND | 130 | 彩信通知索引类型 | +| TYPE_MMS_RESP_IND | 131 | 彩信回å¤ç´¢å¼•ç±»åž‹ | +| TYPE_MMS_RETRIEVE_CONF | 132 | 彩信检索é…置类型 | +| TYPE_MMS_ACKNOWLEDGE_IND | 133 | 彩信确认索引类型 | +| TYPE_MMS_DELIVERY_IND | 134 | å½©ä¿¡ä¼ é€ç´¢å¼•ç±»åž‹ | +| TYPE_MMS_READ_REC_IND | 135 | 彩信读å–接收索引类型 | +| TYPE_MMS_READ_ORIG_IND | 136 | 彩信读å–原始索引类型 | + +## MmsPriorityType<sup>8+</sup> + +彩信优先级类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| ---------- | ---- | -------------- | +| MMS_LOW | 128 | 彩信优先级低 | +| MMS_NORMAL | 129 | 彩信优先级æ£å¸¸ | +| MMS_HIGH | 130 | 彩信优先级高 | + +## MmsVersionType<sup>8+</sup> + +彩信版本类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| --------------- | ---- | ----------- | +| MMS_VERSION_1_0 | 0x10 | 彩信版本1_0 | +| MMS_VERSION_1_1 | 0x11 | 彩信版本1_1 | +| MMS_VERSION_1_2 | 0x12 | 彩信版本1_2 | +| MMS_VERSION_1_3 | 0x13 | 彩信版本1_3 | + +## MmsCharSets<sup>8+</sup> + +彩信å—符集。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| --------------- | ------ | ------------------- | +| BIG5 | 0X07EA | BIG5æ ¼å¼ | +| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2æ ¼å¼ | +| ISO_8859_1 | 0X04 | ISO_8859_1æ ¼å¼ | +| ISO_8859_2 | 0X05 | ISO_8859_2æ ¼å¼ | +| ISO_8859_3 | 0X06 | ISO_8859_3æ ¼å¼ | +| ISO_8859_4 | 0X07 | ISO_8859_4æ ¼å¼ | +| ISO_8859_5 | 0X08 | ISO_8859_5æ ¼å¼ | +| ISO_8859_6 | 0X09 | ISO_8859_6æ ¼å¼ | +| ISO_8859_7 | 0X0A | ISO_8859_7æ ¼å¼ | +| ISO_8859_8 | 0X0B | ISO_8859_8æ ¼å¼ | +| ISO_8859_9 | 0X0C | ISO_8859_9æ ¼å¼ | +| SHIFT_JIS | 0X11 | SHIFT_JISæ ¼å¼ | +| US_ASCII | 0X03 | US_ASCIIæ ¼å¼ | +| UTF_8 | 0X6A | UTF_8æ ¼å¼ | + +## DispositionType<sup>8+</sup> + +处ç†ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| ---------- | ---- | -------- | +| FROM_DATA | 0 | æ•°æ®æ¥æº | +| ATTACHMENT | 1 | 附件 | +| INLINE | 2 | å†…è” | + +## ReportType<sup>8+</sup> + +报告类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| ------- | ---- | ---- | +| MMS_YES | 128 | YES | +| MMS_NO | 129 | NO | + +## CBConfigOptions<sup>8+</sup> + +å°åŒºå¹¿æ’é…置选项。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | -------------------- | ---- | ------------ | +| slotId | number | 是 | å¡æ§½ID | +| enable | boolean | 是 | å¯è¡Œ | +| startMessageId | number | 是 | 消æ¯èµ·å§‹ID | +| endMessageId | number | 是 | 消æ¯ç»“æŸID | +| ranType | [RanType](#rantype7) | 是 | è®¾å¤‡ç½‘ç»œåˆ¶å¼ | + +## SimMessageStatus<sup>7+</sup> + +SIMå¡æ¶ˆæ¯çŠ¶æ€ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| ------------------------- | ---- | --------------------------- | +| SIM_MESSAGE_STATUS_FREE | 0 | SIMå¡ä¸Šçš„状æ€å¯ç”¨ç©ºé—´ | +| SIM_MESSAGE_STATUS_READ | 1 | 消æ¯å·²è¯»çŠ¶æ€ | +| SIM_MESSAGE_STATUS_UNREAD | 3 | 消æ¯æœªè¯»çŠ¶æ€ | +| SIM_MESSAGE_STATUS_SENT | 5 | å˜å‚¨å‘é€æ¶ˆæ¯ï¼ˆä»…适用于SMS) | +| SIM_MESSAGE_STATUS_UNSENT | 7 | 储未å‘é€æ¶ˆæ¯ï¼ˆä»…适用于SMS) | + +## RanType<sup>7+</sup> + +设备网络制å¼ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| --------- | ---- | ---- | +| TYPE_GSM | 1 | GSM | +| TYPE_CDMA | 2 | CMDA | + +## SmsEncodingScheme<sup>8+</sup> + +çŸä¿¡ç¼–ç 方案。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 值 | 说明 | +| -------------------- | ---- | ------------ | +| SMS_ENCODING_UNKNOWN | 0 | 未知çŸä¿¡ç¼–ç | +| SMS_ENCODING_7BIT | 1 | 7ä½çŸä¿¡ç¼–ç | +| SMS_ENCODING_8BIT | 2 | 8ä½çŸä¿¡ç¼–ç | +| SMS_ENCODING_16BIT | 3 | 16ä½çŸä¿¡ç¼–ç | + +## SimMessageOptions<sup>7+</sup> + +SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | -------------------------------------- | ---- | -------------- | +| slotId | number | 是 | å¡æ§½ID | +| smsc | string | 是 | çŸæ¶ˆæ¯ä¸šåŠ¡ä¸å¿ƒ | +| pdu | string | 是 | å议数æ®å•å…ƒ | +| status | [SimMessageStatus](#simmessagestatus7) | 是 | çŠ¶æ€ | + +## UpdateSimMessageOptions<sup>7+</sup> + +æ›´æ–°SIMå¡æ¶ˆæ¯é€‰é¡¹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | -------------------------------------- | ---- | -------------- | +| slotId | number | 是 | å¡æ§½ID | +| msgIndex | number | 是 | 消æ¯ç´¢å¼• | +| newStatus | [SimMessageStatus](#simmessagestatus7) | 是 | æ–°çŠ¶æ€ | +| pdu | string | 是 | å议数æ®å•å…ƒ | +| smsc | string | 是 | çŸæ¶ˆæ¯ä¸šåŠ¡ä¸å¿ƒ | + +## SimShortMessage<sup>8+</sup> + +SIMå¡çŸæ¶ˆæ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------------- | -------------------------------------- | ---- | ------------- | +| shortMessage | [ShortMessage](#shortmessage) | 是 | çŸæ¶ˆæ¯ | +| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | 是 | SIMå¡æ¶ˆæ¯çŠ¶æ€ | +| indexOnSim | number | 是 | SIMå¡ç´¢å¼• | + +## MmsDeliveryInd<sup>8+</sup> + +彩信å‘é€æ ‡è¯†ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | ---------------------------------- | ---- | ------ | +| messageId | string | 是 | 消æ¯ID | +| date | number | 是 | 日期 | +| to | Array<[MmsAddress](#mmsaddress8)\> | 是 | å‘é€è‡³ | +| status | number | 是 | çŠ¶æ€ | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | + +## MmsRespInd<sup>8+</sup> + +彩信回å¤æ ‡å¿—。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------- | ---------------------------------- | ---- | -------- | +| transactionId | string | 是 | 事件ID | +| status | number | 是 | çŠ¶æ€ | +| version | [MmsVersionType](#mmsversiontype8) | 是 | 版本 | +| reportAllowed | [ReportType](#reporttype8) | å¦ | å…许报告 | + +## SmsSegmentsInfo<sup>8+</sup> + +çŸä¿¡æ®µä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.Telephony.SmsMms。 + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ---------------------------------------- | ---- | ------------ | +| splitCount | number | 是 | 拆分计数 | +| encodeCount | number | 是 | ç¼–ç 计数 | +| encodeCountRemaining | number | 是 | 剩余编ç 计数 | +| scheme | [SmsEncodingScheme](#smsencodingscheme8) | 是 | çŸä¿¡ç¼–ç 方案 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index d5d8993ad9b98294182b3abc3a547e1a9aee8a40..11c4b540ab18a6092fbfa12a795c70589426c23c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -264,14 +264,13 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void ## BundleStats<sup>9+</sup> +### 属性 + **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.FileManagement.StorageService.SpatialStatistics 该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ - -### 属性 - | å称 | 类型 | 说明 | | --------- | ------ | -------------- | | appSize | number | appæ•°æ®å¤§å° | @@ -523,14 +522,13 @@ getUserStorageStats(userId: number, callback:AsyncCallback<StorageStats>): ## StorageStats<sup>9+</sup> +### 属性 + **系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.FileManagement.StorageService.SpatialStatistics 该接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ - -### 属性 - | å称 | 类型 | 说明 | | --------- | ------ | -------------- | | total | number | 内å¡æ€»ç©ºé—´å¤§å° | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md index 03a18e692036dcb20736e2e068877fe4da0da26a..8863410838a0358dcf16328583d12a169d055d9b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md @@ -40,11 +40,7 @@ matchMedia(condition: string): MediaQueryList **示例:** ``` -export default { - matchMedia() { - var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); - }, -} +var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); ``` ## MediaQueryEvent @@ -102,6 +98,11 @@ addListener(callback: (event: MediaQueryEvent) => void): void **示例:** ``` +function maxWidthMatch(e){ + if(e.matches){ + // do something + } +} mMediaQueryList.addListener(maxWidthMatch); ``` @@ -123,6 +124,11 @@ removeListener(callback: (event: MediaQueryEvent) => void): void **示例:** ``` +function maxWidthMatch(e){ + if(e.matches){ + // do something + } +} mMediaQueryList.removeListener(maxWidthMatch); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md index e64cc5b50c418e0cf4145338a446a86d4cb4c381..148570c628d44da3cfcc9c5857ebab7f70b879eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @@ -7,7 +7,7 @@ ## å¯¼å…¥æ¨¡å— ```ts -import parameter from '@ohos.systemParameter' +import parameter from '@ohos.systemparameter' ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md index ee590ae07ae5fdfa99de93abe9bb027989d6eec0..ebe7e93cc22df2b817124ae13cfc3a8666d704fb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md @@ -5,7 +5,7 @@ > - 从API Version 6开始,该模å—ä¸å†ç»´æŠ¤ï¼Œå¯ä»¥ä½¿ç”¨æ¨¡å—[`@ohos.data.storage`](js-apis-data-storage.md)。在API Version 9åŽï¼ŒæŽ¨è使用新模å—[`@ohos.data.preferences`](js-apis-data-preferences.md)。 > > - 本模å—首批接å£ä»ŽAPI version 3开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 - +> - 本模å—接å£ä»…å¯åœ¨FA模型下使用。 ## å¯¼å…¥æ¨¡å— diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index 40e5f6498283fd9625f251508de80b7e2b0d8faa..47ced8209ebc0e4508c4f56535041cc9d3004baa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -3,8 +3,8 @@ 本模å—主è¦ç”±æ—¶é—´ã€æ—¶åŒºå’Œå®šæ—¶ä¸‰å¤§åŠŸèƒ½ç»„æˆã€‚å…¶ä¸ï¼Œå®šæ—¶æœåŠ¡ç”¨æ¥ç®¡ç†å’Œä½¿ç”¨æ—¶é—´ã€æ—¶åŒºã€‚å¼€å‘者å¯ä»¥é€šè¿‡å¯¹ç³»ç»Ÿè¿›è¡Œè®¾ç½®ã€èŽ·å–ç‰æ“作管ç†ç³»ç»Ÿæ—¶é—´ã€æ—¶åŒºï¼Œä¹Ÿå¯ä»¥é€šè¿‡å®šæ—¶åŠŸèƒ½å®žçŽ°å®šæ—¶æœåŠ¡å¦‚闹钟æœåŠ¡ç‰ã€‚ >  **说明:** -> 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 - +>- 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +>- 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ ## å¯¼å…¥æ¨¡å— @@ -22,7 +22,7 @@ setTime(time : number, callback : AsyncCallback<void>) : void **需è¦æƒé™ï¼š** ohos.permission.SET_TIME -**系统能力:** SystemCapability.Miscservices.Time +**系统能力:** SystemCapability.MiscServices.Time **å‚数:** @@ -201,7 +201,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> ## systemTime.getRealTime<sup>8+</sup> -getRealTime(callback: AsyncCallback<number>): void +getRealTime(isNano?: boolean, callback: AsyncCallback<number>): void 获å–自系统å¯åŠ¨ä»¥æ¥ç»è¿‡çš„时间,包括深度ç¡çœ 时间,使用callbackå½¢å¼è¿”回结果。 @@ -229,7 +229,7 @@ getRealTime(callback: AsyncCallback<number>): void ## systemTime.getRealTime<sup>8+</sup> -getRealTime(): Promise<number> +getRealTime(isNano?: boolean): Promise<number> 获å–自系统å¯åŠ¨ä»¥æ¥ç»è¿‡çš„时间,包括深度ç¡çœ 时间,使用Promiseå½¢å¼è¿”回结果。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md new file mode 100644 index 0000000000000000000000000000000000000000..6f16a4b45aa4c92ac1e5a3d3b617ccfa0def1799 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md @@ -0,0 +1,287 @@ +# 设置系统时间 + +本模å—主è¦ç”±æ—¶é—´ã€æ—¶åŒºå’Œå®šæ—¶ä¸‰å¤§åŠŸèƒ½ç»„æˆã€‚å…¶ä¸ï¼Œå®šæ—¶æœåŠ¡ç”¨æ¥ç®¡ç†å’Œä½¿ç”¨æ—¶é—´ã€æ—¶åŒºã€‚å¼€å‘者å¯ä»¥é€šè¿‡å¯¹ç³»ç»Ÿè¿›è¡Œè®¾ç½®ã€èŽ·å–ç‰æ“作管ç†ç³»ç»Ÿæ—¶é—´ã€æ—¶åŒºï¼Œä¹Ÿå¯ä»¥é€šè¿‡å®šæ—¶åŠŸèƒ½å®žçŽ°å®šæ—¶æœåŠ¡å¦‚闹钟æœåŠ¡ç‰ã€‚ + +>  **说明:** +>- 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +>- 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +## å¯¼å…¥æ¨¡å— + + +``` +import systemTimer from '@ohos.systemTimer'; +``` + + +## systemTime.createTimer + +createTimer(options: TimerOptions, callback: AsyncCallback<number>): void + +创建定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------| ---- | --------------------------------------------------------------------------------------- | +| options | TimerOptions | 是 | const TIMER_TYPE_REALTIME: 设置为系统å¯åŠ¨æ—¶é—´å®šæ—¶å™¨ï¼Œå¦åˆ™ä¸ºwalltime定时器; <br/>const TIMER_TYPE_WAKEUP: 设置为唤醒定时器,å¦åˆ™ä¸ºéžå”¤é†’; <br/>const TIMER_TYPE_EXACT: 设置为精准定时器,å¦åˆ™ä¸ºéžç²¾å‡†å®šæ—¶å™¨; <br/>const TIMER_TYPE_IDLE: number: 设置为IDLE模å¼å®šæ—¶å™¨ï¼Œå¦åˆ™ä¸ºéžIDLE模å¼å®šæ—¶å™¨ï¼ˆæš‚ä¸æ”¯æŒï¼‰ | +| repeat | boolean | 是 | true 为循环定时器,false为å•æ¬¡å®šæ—¶å™¨ã€‚ | +| interval | number | å¦ | 如果是循环定时器,repeat值应大于5000毫秒,éžé‡å¤å®šæ—¶å™¨ç½®ä¸º0。 | +| wantAgent| wantAgent | å¦ | 设置通知的wantagent,定时器到期åŽé€šçŸ¥ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------------- | ------------------------------------------------------------ | +| syncCallback<number>| 以回调函数的形å¼è¿”回定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + systemTime.createTimer(options, (error, data) => { + if (error) { + console.error(`failed to systemTime.createTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.createTimer + +createTimer(options: TimerOptions): Promise<number> + +创建定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------| ---- | --------------------------------------------------------------------------------------- | +| options | TimerOptions | 是 | const TIMER_TYPE_REALTIME: 设置为系统å¯åŠ¨æ—¶é—´å®šæ—¶å™¨ï¼Œå¦åˆ™ä¸ºwalltime定时器; <br/>const TIMER_TYPE_WAKEUP: 设置为唤醒定时器,å¦åˆ™ä¸ºéžå”¤é†’; <br/>const TIMER_TYPE_EXACT: 设置为精准定时器,å¦åˆ™ä¸ºéžç²¾å‡†å®šæ—¶å™¨; <br/>const TIMER_TYPE_IDLE: number: 设置为IDLE模å¼å®šæ—¶å™¨ï¼Œå¦åˆ™ä¸ºéžIDLE模å¼å®šæ—¶å™¨ï¼ˆæš‚ä¸æ”¯æŒï¼‰ | +| repeat | boolean | 是 | true 为循环定时器,false为å•æ¬¡å®šæ—¶å™¨ã€‚ | +| interval | number | å¦ | 如果是循环定时器,repeat值应大于5000毫秒,éžé‡å¤å®šæ—¶å™¨ç½®ä¸º0。 | +| wantAgent| wantAgent | å¦ | 设置通知的wantagent,定时器到期åŽé€šçŸ¥ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------------------------------------------ | +| Promise<number> | 以Promiseå½¢å¼è¿”回定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + systemTime.createTimer(options).then((data) => { + console.log(`systemTime.createTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.createTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.startTimer + +startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void>): void + +开始定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | +| triggerTime | number | 是 | 定时器的触å‘时间,å•ä½ï¼šæ¯«ç§’。 | + + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + systemTime.startTimer(timerId, 10000, (error, data) => { + if (error) { + console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + }); + ``` + +## systemTime.startTimer + +startTimer(timer: number, triggerTime: number): Promise<void> + +开始定时器。 + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 +| triggerTime | number | 是 | 定时器的触å‘时间,å•ä½ï¼šæ¯«ç§’。 | + + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + systemTime.startTimer(timerId, 10000).then((data) => { + console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.stopTimer + +stopTimer(timer: number, callback: AsyncCallback<void>): void + +åœæ¢å®šæ—¶å™¨ã€‚ + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + systemTime.stopTimer(timerId, (error, data) => { + if (error) { + console.error(`failed to systemTime.stopTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.stopTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.stopTimer + +stopTimer(timer: number): Promise<void> + +åœæ¢å®šæ—¶å™¨ã€‚ + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + systemTime.stopTimer(timerId).then((data) => { + console.log(`systemTime.stopTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.stopTimer because ` + JSON.stringify(error)); + }); + ``` + + +## systemTime.destroyTimer + +destroyTimer(timer: number, callback: AsyncCallback<void>): void + +销æ¯å®šæ—¶å™¨ã€‚ + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + let stopTimerRes = systemTimer.stopTimer(timerId) + systemTime.destroyTimer(timerId, (error, data) => { + if (error) { + console.error(`failed to systemTime.destroyTimer ` + JSON.stringify(error)); + return; + } + console.log(`systemTime.destroyTimer success data : ` + JSON.stringify(data)); + }); + ``` + + +## systemTime.destroyTimer + +destroyTimer(timer: number): Promise<void> + +销æ¯å®šæ—¶å™¨ã€‚ + +**系统能力:** SystemCapability.MiscServices.Time + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------- | ---- | ------------------------------------------------------------ | +| timer | number | 是 | 定时器的ID。 | + +**示例:** + + ```js + var options = TimerOptions { + type:TIMER_TYPE_REALTIME, + repeat:false + } + let timerId = systemTimer.Timer(options) + let startTimerRes = systemTimer.startTimer(timerId, 100000) + let stopTimerRes = systemTimer.stopTimer(timerId) + systemTime.destroyTimer(timerId).then((data) => { + console.log(`systemTime.destroyTimer success data : ` + JSON.stringify(data)); + }).catch((error) => { + console.error(`failed to systemTime.destroyTimer because ` + JSON.stringify(error)); + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md b/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md index 0f1a07079c2d53227453da012f062e686683c2ae..c6b5f4294595552bea4d4ba1a3ec08e90abe4e55 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-telephony-data.md @@ -328,6 +328,240 @@ promise.then((data) => { }); ``` +## data.enableCellularData + +enableCellularData(callback: AsyncCallback<void\>): void + +å¯ç”¨èœ‚çªæ•°æ®æœåŠ¡ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +data.enableCellularData((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.enableCellularData + +enableCellularData(): Promise<void\> + +å¯ç”¨èœ‚çªæ•°æ®æœåŠ¡ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回结果。 | + +**示例:** + +```js +let promise = data.enableCellularData(); +promise.then((data) => { + console.log(`enableCellularData success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`enableCellularData fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.disableCellularData + +disableCellularData(callback: AsyncCallback<void\>): void + +ç¦ç”¨èœ‚çªæ•°æ®æœåŠ¡ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +data.disableCellularData((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.disableCellularData + +disableCellularData(): Promise<void\> + +ç¦ç”¨èœ‚çªæ•°æ®æœåŠ¡ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**返回值:** + +| 类型 | 说明 | +| --------------- | --------------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回ç¦ç”¨ç»“果。 | + +**示例:** + +```js +let promise = data.disableCellularData(); +promise.then((data) => { + console.log(`disableCellularData success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`disableCellularData fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.enableCellularDataRoaming + +enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void + +å¯ç”¨èœ‚çªæ•°æ®æ¼«æ¸¸ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br />0:å¡æ§½1。<br />1:å¡æ§½2。 | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +data.enableCellularDataRoaming(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.enableCellularDataRoaming + +enableCellularDataRoaming(slotId: number): Promise<void\> + +å¯ç”¨èœ‚çªæ•°æ®æ¼«æ¸¸ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br />0:å¡æ§½1。<br />1:å¡æ§½2。 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ------------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回å¯ç”¨ç»“æžœ | + +**示例:** + +```js +let promise = data.enableCellularDataRoaming(0); +promise.then((data) => { + console.log(`enableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`enableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.disableCellularDataRoaming + +disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void\>): void + +ç¦ç”¨èœ‚çªæ•°æ®æ¼«æ¸¸ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br />0:å¡æ§½1。<br />1:å¡æ§½2。 | +| callback | AsyncCallback\<void\> | 是 | 回调函数。 | + +**示例:** + +```js +data.disableCellularDataRoaming(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.disableCellularDataRoaming + +disableCellularDataRoaming(slotId: number): Promise<void\> + +ç¦ç”¨èœ‚çªæ•°æ®æ¼«æ¸¸ï¼Œä½¿ç”¨Promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™**:ohos.permission.SET_TELEPHONY_STATE + +**系统能力**:SystemCapability.Telephony.CellularData + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------------------------------------- | +| slotId | number | 是 | å¡æ§½ID。<br />0:å¡æ§½1。<br />1:å¡æ§½2。 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ------------------------- | +| Promise\<void\> | 以Promiseå½¢å¼è¿”回ç¦ç”¨ç»“æžœ | + +**示例:** + +```js +let promise = data.disableCellularDataRoaming(0); +promise.then((data) => { + console.log(`disableCellularDataRoaming success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`disableCellularDataRoaming fail, promise: err->${JSON.stringify(err)}`); +}); +``` + ## DataFlowType æ述蜂çªæ•°æ®æµç±»åž‹ã€‚ @@ -354,4 +588,4 @@ promise.then((data) => { | DATA_STATE_DISCONNECTED | 0 | 表示蜂çªæ•°æ®é“¾è·¯æ–开。 | | DATA_STATE_CONNECTING | 1 | 表示æ£åœ¨è¿žæŽ¥èœ‚çªæ•°æ®é“¾è·¯ã€‚ | | DATA_STATE_CONNECTED | 2 | 表示蜂çªæ•°æ®é“¾è·¯å·²è¿žæŽ¥ã€‚ | -| DATA_STATE_SUSPENDED | 3 | 表示蜂çªæ•°æ®é“¾è·¯è¢«æŒ‚起。 | \ No newline at end of file +| DATA_STATE_SUSPENDED | 3 | 表示蜂çªæ•°æ®é“¾è·¯è¢«æŒ‚起。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md index 1cbc27d7ce248ea84d4c0e20acdeaec2fe176e04..98a499564467113a1fda62564c9f116658db6202 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md @@ -2,7 +2,8 @@ 设备上报的触å±äº‹ä»¶ã€‚ ->  **说明:** +> **说明:** +> > 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -13,72 +14,72 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput ## Action -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| CANCEL | number | 是 | å¦ | 触摸å–消 | -| DOWN | number | 是 | å¦ | 触摸按下 | -| MOVE | number | 是 | å¦ | 触摸移动 | -| UP | number | 是 | å¦ | 触摸抬起 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ------ | ------ | ---- | ---- | ---- | +| CANCEL | number | 是 | å¦ | 触摸å–消 | +| DOWN | number | 是 | å¦ | 触摸按下 | +| MOVE | number | 是 | å¦ | 触摸移动 | +| UP | number | 是 | å¦ | 触摸抬起 | ## ToolType -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| FINGER | number | 是 | å¦ | 手指 | -| PEN | number | 是 | å¦ | 笔 | -| RUBBER | number | 是 | å¦ | 橡皮擦 | -| BRUSH | number | 是 | å¦ | 笔刷 | -| PENCIL | number | 是 | å¦ | 铅笔 | -| AIRBRUSH | number | 是 | å¦ | 气笔 | -| MOUSE | number | 是 | å¦ | é¼ æ ‡ | -| LENS | number | 是 | å¦ | é€é•œ | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| -------- | ------ | ---- | ---- | ---- | +| FINGER | number | 是 | å¦ | 手指 | +| PEN | number | 是 | å¦ | 笔 | +| RUBBER | number | 是 | å¦ | 橡皮擦 | +| BRUSH | number | 是 | å¦ | 笔刷 | +| PENCIL | number | 是 | å¦ | 铅笔 | +| AIRBRUSH | number | 是 | å¦ | 气笔 | +| MOUSE | number | 是 | å¦ | é¼ æ ‡ | +| LENS | number | 是 | å¦ | é€é•œ | ## SourceType -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| TOUCH_SCREEN | number | 是 | å¦ | è§¦æ‘¸å± | -| PEN | number | 是 | å¦ | 手写笔 | -| TOUCH_PAD | number | 是 | å¦ | è§¦æ‘¸æ¿ | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ------------ | ------ | ---- | ---- | ---- | +| TOUCH_SCREEN | number | 是 | å¦ | è§¦æ‘¸å± | +| PEN | number | 是 | å¦ | 手写笔 | +| TOUCH_PAD | number | 是 | å¦ | è§¦æ‘¸æ¿ | ## Touch -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core - -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| id | number | 是 | å¦ | æŒ‡é’ˆæ ‡è¯† | -| pressedTime | number | 是 | å¦ | 按下时的时间戳 | -| screenX | number | 是 | å¦ | 触摸ä½ç½®æ‰€å±žçš„å±å¹•xåæ ‡ | -| screenY | number | 是 | å¦ | 触摸ä½ç½®æ‰€å±žçš„å±å¹•yåæ ‡ | -| windowX | number | 是 | å¦ | 触摸ä½ç½®åœ¨çª—å£ä¸çš„xåæ ‡ | -| windowY | number | 是 | å¦ | 触摸ä½ç½®åœ¨çª—å£ä¸çš„yåæ ‡ | -| pressure | number | 是 | å¦ | 压力值,å–值范围是[0.0, 1.0], 0.0表示ä¸æ”¯æŒ | -| width | number | 是 | å¦ | 按下接触区域的宽度 | -| height | number | 是 | å¦ | 按下接触区域的高度 | -| tiltX | number | 是 | å¦ | 相对YZå¹³é¢çš„角度,å–值的范围[-90, 90],其ä¸æ£å€¼æ˜¯å‘å³å€¾æ–œã€‚ | -| tiltY | number | 是 | å¦ | 相对XZå¹³é¢çš„角度,值的范围[-90, 90],其ä¸æ£å€¼æ˜¯å‘下倾斜。 | -| toolX | number | 是 | å¦ | 工具区域的ä¸å¿ƒç‚¹X | -| toolY | number | 是 | å¦ | 工具区域的ä¸å¿ƒç‚¹Y | -| toolWidth | number | 是 | å¦ | 工具区域宽度 | -| toolHeight | number | 是 | å¦ | 工具区域高度 | -| rawX | number | 是 | å¦ | 输入设备上的xåæ ‡ | -| rawY | number | 是 | å¦ | 输入设备上的yåæ ‡ | -| toolType | number | 是 | å¦ | 工具类型 | +**系统能力**:SystemCapability.MultimodalInput.Input.Core + +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ----------- | ------ | ---- | ---- | ----------------------------------- | +| id | number | 是 | å¦ | æŒ‡é’ˆæ ‡è¯† | +| pressedTime | number | 是 | å¦ | 按下时的时间戳 | +| screenX | number | 是 | å¦ | 触摸ä½ç½®æ‰€å±žçš„å±å¹•xåæ ‡ | +| screenY | number | 是 | å¦ | 触摸ä½ç½®æ‰€å±žçš„å±å¹•yåæ ‡ | +| windowX | number | 是 | å¦ | 触摸ä½ç½®åœ¨çª—å£ä¸çš„xåæ ‡ | +| windowY | number | 是 | å¦ | 触摸ä½ç½®åœ¨çª—å£ä¸çš„yåæ ‡ | +| pressure | number | 是 | å¦ | 压力值,å–值范围是[0.0, 1.0], 0.0表示ä¸æ”¯æŒ | +| width | number | 是 | å¦ | 按下接触区域的宽度 | +| height | number | 是 | å¦ | 按下接触区域的高度 | +| tiltX | number | 是 | å¦ | 相对YZå¹³é¢çš„角度,å–值的范围[-90, 90],其ä¸æ£å€¼æ˜¯å‘å³å€¾æ–œã€‚ | +| tiltY | number | 是 | å¦ | 相对XZå¹³é¢çš„角度,值的范围[-90, 90],其ä¸æ£å€¼æ˜¯å‘下倾斜。 | +| toolX | number | 是 | å¦ | 工具区域的ä¸å¿ƒç‚¹X | +| toolY | number | 是 | å¦ | 工具区域的ä¸å¿ƒç‚¹Y | +| toolWidth | number | 是 | å¦ | 工具区域宽度 | +| toolHeight | number | 是 | å¦ | 工具区域高度 | +| rawX | number | 是 | å¦ | 输入设备上的xåæ ‡ | +| rawY | number | 是 | å¦ | 输入设备上的yåæ ‡ | +| toolType | number | 是 | å¦ | 工具类型 | ## TouchEvent -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.MultimodalInput.Input.Core +**系统能力**:SystemCapability.MultimodalInput.Input.Core -| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| action | Action | 是 | å¦ | 触摸动作 | -| touch | Touch | 是 | å¦ | 当å‰è§¦æ‘¸ç‚¹ | -| touches | Touch[] | 是 | å¦ | 所有触摸点 | -| sourceType | SourceType | 是 | å¦ | 触摸æ¥æºçš„设备类型 | +| å称 | å‚数类型 | å¯è¯» | å¯å†™ | æè¿° | +| ---------- | ---------- | ---- | ---- | --------- | +| action | Action | 是 | å¦ | 触摸动作 | +| touch | Touch | 是 | å¦ | 当å‰è§¦æ‘¸ç‚¹ | +| touches | Touch[] | 是 | å¦ | 所有触摸点 | +| sourceType | SourceType | 是 | å¦ | 触摸æ¥æºçš„设备类型 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md index f4e5de83987e675bc8c5d262ee40326aea132b29..28402007b002e0f214060f8dc9a629d2d042a311 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md @@ -3,7 +3,9 @@ 用户界é¢å¤–观æ供管ç†ç³»ç»Ÿå¤–观的一些基础能力,目å‰ä»…包括深浅色模å¼é…置。 > **说明:** +> > 从API Version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> > 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ @@ -19,6 +21,8 @@ import uiAppearance from '@ohos.uiAppearance' 深色模å¼æžšä¸¾ã€‚ +**系统能力:** SystemCapability.ArkUI.UiAppearance + | å称 | 值 | 说明 | | -- | -- | -- | | ALWAYS_DARK | 0 | 系统始终为深色。 | @@ -31,9 +35,9 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void 设置系统深色模å¼ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGRATION +**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGURATION -**系统能力:** SystemCapability.ArkUI.ArkUI.Full +**系统能力:** SystemCapability.ArkUI.UiAppearance **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -55,15 +59,21 @@ setDarkMode(mode: DarkMode): Promise\<void>; 设置系统深色模å¼ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGRATION +**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGURATION -**系统能力:** SystemCapability.ArkUI.ArkUI.Full +**系统能力:** SystemCapability.ArkUI.UiAppearance **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -- | -- | -- | -- | | mode | [DarkMode](#darkmode) | 是 | 指定系统深色模å¼é…ç½® | +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------------------ | +| Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。| + **示例:** ```ts uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { @@ -80,9 +90,9 @@ getDarkMode(): DarkMode; 获å–当å‰çš„深色模å¼é…置。 -**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGRATION +**需è¦æƒé™ï¼š** ohos.permission.UPDATE_CONFIGURATION -**系统能力:** SystemCapability.ArkUI.ArkUI.Full +**系统能力:** SystemCapability.ArkUI.UiAppearance **返回值:** | 类型 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-uitest.md b/zh-cn/application-dev/reference/apis/js-apis-uitest.md index efe59299e6e362d09626f74dfb325f9e7283ab22..62303e6e2b0b1e1fc9df95835de8e19faeab3907 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uitest.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uitest.md @@ -23,7 +23,7 @@ import {UiDriver, BY, MatchPattern, ResizeDirection, WindowMode} from '@ohos.uit ## By UiTest框架通过Byç±»æ供了丰富的控件特å¾æè¿°API,用于进行控件ç›é€‰æ¥åŒ¹é…/æŸ¥æ‰¾å‡ºç›®æ ‡æŽ§ä»¶ã€‚<br> -Byæ供的APIèƒ½åŠ›å…·æœ‰ä»¥ä¸‹å‡ ä¸ªç‰¹ç‚¹:<br>1ã€æ”¯æŒå•å±žæ€§åŒ¹é…和多属性组åˆåŒ¹é…,例如åŒæ—¶æŒ‡å®šç›®æ ‡æŽ§ä»¶textå’Œid。<br>2ã€æŽ§ä»¶å±žæ€§æ”¯æŒå¤šç§åŒ¹é…模å¼ã€‚<br>3ã€æ”¯æŒæŽ§ä»¶ç»å¯¹å®šä½ï¼Œç›¸å¯¹å®šä½ï¼Œå¯é€šè¿‡[By.isBefore](#byisbefore)å’Œ[By.isAfter](#byisafter)ç‰APIé™å®šé‚»è¿‘控件特å¾è¿›è¡Œè¾…助定ä½ã€‚<br>Byç±»æ供的所有APIå‡ä¸ºåŒæ¥æŽ¥å£ï¼Œå»ºè®®ä½¿ç”¨è€…通过é™æ€æž„é€ å™¨BYæ¥é“¾å¼åˆ›å»ºBy对象。 +Byæ供的APIèƒ½åŠ›å…·æœ‰ä»¥ä¸‹å‡ ä¸ªç‰¹ç‚¹:<br>1ã€æ”¯æŒå•å±žæ€§åŒ¹é…和多属性组åˆåŒ¹é…,例如åŒæ—¶æŒ‡å®šç›®æ ‡æŽ§ä»¶textå’Œid。<br>2ã€æŽ§ä»¶å±žæ€§æ”¯æŒå¤šç§åŒ¹é…模å¼ã€‚<br>3ã€æ”¯æŒæŽ§ä»¶ç»å¯¹å®šä½ï¼Œç›¸å¯¹å®šä½ï¼Œå¯é€šè¿‡[By.isBefore](#isbefore)å’Œ[By.isAfter](#isafter)ç‰APIé™å®šé‚»è¿‘控件特å¾è¿›è¡Œè¾…助定ä½ã€‚<br>Byç±»æ供的所有APIå‡ä¸ºåŒæ¥æŽ¥å£ï¼Œå»ºè®®ä½¿ç”¨è€…通过é™æ€æž„é€ å™¨BYæ¥é“¾å¼åˆ›å»ºBy对象。 ```js BY.text('123').type('button') @@ -1285,7 +1285,7 @@ async function demo() { ### triggerCombineKeys<sup>9+</sup> -triggerCombineKeys(key0: number, key1: number, key2: number): Promise\<void> +triggerCombineKeys(key0: number, key1: number, key2?: number): Promise\<void> UiDriver对象通过给定的key值,找到对应组åˆé”®å¹¶ç‚¹å‡»ã€‚例如,Key值为(2072, 2019)时,UiDriver对象找到组åˆé”®å¹¶ç‚¹å‡»ctrl+c。 @@ -1566,7 +1566,7 @@ getWindowMode(): Promise\<WindowMode> | 类型 | 说明 | | ------------------------------------------------ | ------------------------------------- | -| Promise\<[WindowMode](#WindowMode<sup>9+</sup>)> | 以Promiseå½¢å¼è¿”回窗å£çš„窗å£æ¨¡å¼ä¿¡æ¯ã€‚ | +| Promise\<[WindowMode](#windowmode9)> | 以Promiseå½¢å¼è¿”回窗å£çš„窗å£æ¨¡å¼ä¿¡æ¯ã€‚ | **示例:** @@ -1695,7 +1695,7 @@ resize(wide: number, height: number, direction: ResizeDirection): Promise\<bool> | --------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | | wide | number | 是 | 以numberçš„å½¢å¼ä¼ 入调整åŽçª—å£çš„宽度。 | | height | number | 是 | 以numberçš„å½¢å¼ä¼ 入调整åŽçª—å£çš„高度。 | -| direction | [ResizeDirection](#resizedirection<sup>9+</sup>) | 是 | 以[ResizeDirection](#ResizeDirection<sup>9+</sup>)çš„å½¢å¼ä¼ 入窗å£è°ƒæ•´çš„æ–¹å‘。 | +| direction | [ResizeDirection](#resizedirection9) | 是 | 以[ResizeDirection](#resizedirection9)çš„å½¢å¼ä¼ 入窗å£è°ƒæ•´çš„æ–¹å‘。 | **返回值:** @@ -1865,6 +1865,8 @@ async function demo() { ## WindowMode<sup>9+</sup> +**系统能力**:SystemCapability.Test.UiTest + 窗å£çš„窗å£æ¨¡å¼ã€‚ | å称 | 说明 | @@ -1872,4 +1874,4 @@ async function demo() { | FULLSCREEN | å…¨å±æ¨¡å¼ã€‚ | | PRIMARY | 主窗å£ã€‚ | | SECONDARY | 第二窗å£ã€‚ | -| FLOAT | 浮动窗å£ã€‚ | +| FLOATING | 浮动窗å£ã€‚ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index 4e7e6257e6cb4fe209cca74d41a4cfad22304a85..558ebe9b2201eabd9ee25822947e05f231fb079f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -29,9 +29,9 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ----------- | --------------------------- | ---- | ---- | -| upgradeInfo | [UpgradeInfo](#upgradeinfo) | 是 | å‡çº§ä¿¡æ¯å¯¹è±¡ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------ | +| upgradeInfo | [UpgradeInfo](#upgradeinfo) | 是 | å‡çº§ä¿¡æ¯å¯¹è±¡ | **返回值:** @@ -41,7 +41,7 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater **示例:** -``` +```ts try { var upgradeInfo = { upgradeApp: "com.ohos.ota.updateclient", @@ -67,13 +67,13 @@ getRestorer(): Restorer **返回值:** -| 类型 | 说明 | -| ------------------- | ---- | +| 类型 | 说明 | +| --------------------- | ------ | | [Restorer](#restorer) | æ¢å¤å‡ºåŽ‚对象 | **示例:** -``` +```ts try { let restorer = update.getRestorer(); } catch(error) { @@ -91,13 +91,13 @@ getLocalUpdater(): LocalUpdater **返回值:** -| 类型 | 说明 | -| ------------------- | ---- | +| 类型 | 说明 | +| ----------------------------- | ------ | | [LocalUpdater](#localupdater) | 本地å‡çº§å¯¹è±¡ | **示例:** -``` +```ts try { let localUpdater = update.getLocalUpdater(); } catch(error) { @@ -119,13 +119,13 @@ checkNewVersion(callback: AsyncCallback\<CheckResult>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback\<[CheckResult](#checkresult)> | 是 | 回调函数,返回æœåŒ…结果对象。 | **示例:** -``` +```ts updater.checkNewVersion((err, result) => { console.log(`checkNewVersion isExistNewVersion ${result?.isExistNewVersion}`); }); @@ -143,13 +143,13 @@ checkNewVersion(): Promise\<CheckResult> **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| ------------------------------------- | ------------------- | | Promise\<[CheckResult](#checkresult)> | Promise对象,返回æœåŒ…结果对象。 | **示例:** -``` +```ts updater.checkNewVersion().then(result => { console.log(`checkNewVersion isExistNewVersion: ${result.isExistNewVersion}`); // 版本摘è¦ä¿¡æ¯ @@ -171,13 +171,13 @@ getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | 是 | 回调函数,返回新版本信æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getNewVersionInfo((err, info) => { console.log(`info displayVersion = ${info?.versionComponents[0].displayVersion}`); console.log(`info innerVersion = ${info?.versionComponents[0].innerVersion}`); @@ -196,13 +196,13 @@ getNewVersionInfo(): Promise\<NewVersionInfo> **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| ---------------------------------------- | -------------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise对象,返回新版本信æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getNewVersionInfo().then(info => { console.log(`info displayVersion = ${info.versionComponents[0].displayVersion}`); console.log(`info innerVersion = ${info.versionComponents[0].innerVersion}`); @@ -211,6 +211,88 @@ updater.getNewVersionInfo().then(info => { }); ``` +### getNewVersionDescription + +getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void + +获å–新版本æ述文件。使用callback异æ¥å›žè°ƒã€‚ + +**系统能力**:SystemCapability.Update.UpdateService + +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------------ | ---------------------------------------- | ---- | -------------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | æ述文件选项 | +| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | 是 | 回调函数,返回新版本æ述文件 | + +**示例:** + +```ts +// 版本摘è¦ä¿¡æ¯ +var versionDigestInfo = { + versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ +} + +// æ述文件选项 +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // æ ‡å‡†æ ¼å¼ + language: "zh-cn" // ä¸æ–‡ +} + +updater.getNewVersionDescription(versionDigestInfo, descriptionOptions, (err, info) => { + console.log(`getNewVersionDescription info ${JSON.stringify(info)}`); + console.log(`getNewVersionDescription err ${JSON.stringify(err)}`); +}); +``` + +### getNewVersionDescription + +getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>>; + +获å–新版本æ述文件。使用Promise异æ¥å›žè°ƒã€‚ + +**系统能力**:SystemCapability.Update.UpdateService + +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------------ | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | æ述文件选项 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ------------------- | +| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise对象,返回新版本æ述文件 | + +**示例:** + +```ts +// 版本摘è¦ä¿¡æ¯ +var versionDigestInfo = { + versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ +} + +// æ述文件选项 +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // æ ‡å‡†æ ¼å¼ + language: "zh-cn" // ä¸æ–‡ +} + +updater.getNewVersionDescription(versionDigestInfo, descriptionOptions).then(info => { + console.log(`getNewVersionDescription promise info ${JSON.stringify(info)}`); +}).catch(err => { + console.log(`getNewVersionDescription promise error ${JSON.stringify(err)}`); +}); +``` + ### getCurrentVersionInfo getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void @@ -223,13 +305,13 @@ getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | 是 | 回调函数,返回当å‰ç‰ˆæœ¬ä¿¡æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getCurrentVersionInfo((err, info) => { console.log(`info osVersion = ${info?.osVersion}`); console.log(`info deviceName = ${info?.deviceName}`); @@ -249,13 +331,13 @@ getCurrentVersionInfo(): Promise\<CurrentVersionInfo> **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| ---------------------------------------- | ------------------- | | Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise对象,返回当å‰ç‰ˆæœ¬å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getCurrentVersionInfo().then(info => { console.log(`info osVersion = ${info.osVersion}`); console.log(`info deviceName = ${info.deviceName}`); @@ -265,6 +347,76 @@ updater.getCurrentVersionInfo().then(info => { }); ``` +### getCurrentVersionDescription + +getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: AsyncCallback\<Array\<ComponentDescription>>): void + +获å–当å‰ç‰ˆæœ¬æ述文件。使用callback异æ¥å›žè°ƒã€‚ + +**系统能力**:SystemCapability.Update.UpdateService + +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------------ | ---------------------------------------- | ---- | --------------- | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | æ述文件选项 | +| callback | AsyncCallback\<Array\<[ComponentDescription](#componentdescription)>>) | 是 | 回调函数,返回当å‰ç‰ˆæœ¬æ述文件 | + +**示例:** + +```ts +// æ述文件选项 +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // æ ‡å‡†æ ¼å¼ + language: "zh-cn" // ä¸æ–‡ +} + +updater.getCurrentVersionDescription(descriptionOptions, (err, info) => { + console.log(`getCurrentVersionDescription info ${JSON.stringify(info)}`); + console.log(`getCurrentVersionDescription err ${JSON.stringify(err)}`); +}); +``` + +### getCurrentVersionDescription + +getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\<Array\<ComponentDescription>> + +获å–当å‰ç‰ˆæœ¬æ述文件。使用Promise异æ¥å›žè°ƒã€‚ + +**系统能力**:SystemCapability.Update.UpdateService + +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------------ | ---------------------------------------- | ---- | ------ | +| descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | æ述文件选项 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | -------------------- | +| Promise\<Array\<[ComponentDescription](#componentdescription)>> | Promise对象,返回当å‰ç‰ˆæœ¬æ述文件 | + +**示例:** + +```ts +// æ述文件选项 +var descriptionOptions = { + format: DescriptionFormat.STANDARD, // æ ‡å‡†æ ¼å¼ + language: "zh-cn" // ä¸æ–‡ +} + +updater.getCurrentVersionDescription(descriptionOptions).then(info => { + console.log(`getCurrentVersionDescription promise info ${JSON.stringify(info)}`); +}).catch(err => { + console.log(`getCurrentVersionDescription promise error ${JSON.stringify(err)}`); +}); +``` + ### getTaskInfo getTaskInfo(callback: AsyncCallback\<TaskInfo>): void @@ -277,13 +429,13 @@ getTaskInfo(callback: AsyncCallback\<TaskInfo>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[TaskInfo](#taskinfo)> | 是 | 回调函数,返回å‡çº§ä»»åŠ¡ä¿¡æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getTaskInfo((err, info) => { console.log(`getTaskInfo isexistTask= ${info?.existTask}`); }); @@ -297,15 +449,17 @@ getTaskInfo(): Promise\<TaskInfo> **系统能力**:SystemCapability.Update.UpdateService +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| ------------------------------- | ------------------- | | Promise\<[TaskInfo](#taskinfo)> | Promise对象,返回任务信æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getTaskInfo().then(info => { console.log(`getTaskInfo isexistTask= ${info.existTask}`); }).catch(err => { @@ -325,15 +479,15 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| downloadOptions | [DownloadOptions](#downloadoptions) | 是 | 下载选项 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当下载æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ---------------------------------- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| downloadOptions | [DownloadOptions](#downloadoptions) | 是 | 下载选项 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当下载æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -361,20 +515,20 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions) **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| downloadOptions | [DownloadOptions](#downloadoptions) | 是 | 下载选项 | +| downloadOptions | [DownloadOptions](#downloadoptions) | 是 | 下载选项 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -404,15 +558,15 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | 是 | æ¢å¤ä¸‹è½½é€‰é¡¹ | -| callback | AsyncCallback\<void> | 是 | 回调函数。当æ¢å¤ä¸‹è½½æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------------- | ---------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | 是 | æ¢å¤ä¸‹è½½é€‰é¡¹ | +| callback | AsyncCallback\<void> | 是 | 回调函数。当æ¢å¤ä¸‹è½½æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -439,20 +593,20 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------------- | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | | resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | 是 | æ¢å¤ä¸‹è½½é€‰é¡¹ | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -481,15 +635,15 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | 是 | æš‚åœä¸‹è½½é€‰é¡¹ | -| callback | AsyncCallback\<void> | 是 | 回调函数。当暂åœä¸‹è½½æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ---------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | 是 | æš‚åœä¸‹è½½é€‰é¡¹ | +| callback | AsyncCallback\<void> | 是 | 回调函数。当暂åœä¸‹è½½æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -516,20 +670,20 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ---------------------------------------- | ---- | ------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | | pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | 是 | æš‚åœä¸‹è½½é€‰é¡¹ | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -558,15 +712,15 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, ca **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| upgradeOptions | [UpgradeOptions](#upgradeoptions) | 是 | 更新选项 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当å‡çº§æ‰§è¡ŒæˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | 是 | 更新选项 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当å‡çº§æ‰§è¡ŒæˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -593,20 +747,20 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): P **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| upgradeOptions | [UpgradeOptions](#upgradeoptions) | 是 | 更新选项 | +| upgradeOptions | [UpgradeOptions](#upgradeoptions) | 是 | 更新选项 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -635,15 +789,15 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, cal **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| clearOptions | [ClearOptions](#clearoptions) | 是 | 清除选项 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当清除异常æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ------------------------------------ | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | +| clearOptions | [ClearOptions](#clearoptions) | 是 | 清除选项 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当清除异常æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -670,20 +824,20 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Pr **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------------- | ---- | ------ | | versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | 版本摘è¦ä¿¡æ¯ | -| clearOptions | [ClearOptions](#clearoptions) | 是 | 更新选项 | +| clearOptions | [ClearOptions](#clearoptions) | 是 | 更新选项 | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts // 版本摘è¦ä¿¡æ¯ var versionDigestInfo = { versionDigest: "versionDigest" // 检测结果ä¸çš„版本摘è¦ä¿¡æ¯ @@ -712,13 +866,13 @@ getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | ---------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | 是 | 回调函数,返回å‡çº§ç–略信æ¯å¯¹è±¡ | **示例:** -``` +```ts updater.getUpgradePolicy((err, policy) => { console.log(`policy downloadStrategy = ${policy?.downloadStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy?.autoUpgradeStrategy}`); @@ -737,13 +891,13 @@ getUpgradePolicy(): Promise\<UpgradePolicy> **返回值:** -| 类型 | 说明 | -| --------------------------------------- | ----------------- | +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | | Promise\<[UpgradePolicy](#upgradepolicy)> | Promise对象,返回å‡çº§ç–略信æ¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.getUpgradePolicy().then(policy => { console.log(`policy downloadStrategy = ${policy.downloadStrategy}`); console.log(`policy autoUpgradeStrategy = ${policy.autoUpgradeStrategy}`); @@ -754,7 +908,7 @@ updater.getUpgradePolicy().then(policy => { ### setUpgradePolicy -setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<number>): void +setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<void>): void 设置å‡çº§ç–略。使用callback异æ¥å›žè°ƒã€‚ @@ -764,27 +918,27 @@ setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<number>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | ---------- | -| policy | [UpgradePolicy](#upgradepolicy) | 是 | å‡çº§ç–ç•¥ | -| callback | AsyncCallback\<number> | 是 | 回调函数,返回设置结果对象 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------- | ---- | ------------- | +| policy | [UpgradePolicy](#upgradepolicy) | 是 | å‡çº§ç–ç•¥ | +| callback | AsyncCallback\<void> | 是 | 回调函数,返回设置结果对象 | **示例:** -``` +```ts let policy = { downloadStrategy: false, autoUpgradeStrategy: false, autoUpgradePeriods: [ { start: 120, end: 240 } ] // 自动å‡çº§æ—¶é—´æ®µï¼Œç”¨åˆ†é’Ÿè¡¨ç¤º } -updater.setUpgradePolicy(policy, (err, value) => { - console.log(`setUpgradePolicy result: ${value}`); +updater.setUpgradePolicy(policy, (err) => { + console.log(`setUpgradePolicy result: ${err}`); }); ``` ### setUpgradePolicy -setUpgradePolicy(policy: UpgradePolicy): Promise\<number> +setUpgradePolicy(policy: UpgradePolicy): Promise\<void> 设置å‡çº§ç–略。使用Promise异æ¥å›žè°ƒã€‚ @@ -794,26 +948,26 @@ setUpgradePolicy(policy: UpgradePolicy): Promise\<number> **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ------ | ----------------------------- | ---- | ------ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------------------------------- | ---- | ---- | | policy | [UpgradePolicy](#upgradepolicy) | 是 | å‡çº§ç–ç•¥ | **返回值:** -| 类型 | 说明 | -| ---------------- | --------------- | -| Promise\<number> | Promise对象,返回设置结果对象。 | +| 类型 | 说明 | +| -------------- | ------------------- | +| Promise\<void> | Promise对象,返回设置结果对象。 | **示例:** -``` +```ts let policy = { downloadStrategy: false, autoUpgradeStrategy: false, autoUpgradePeriods: [ { start: 120, end: 240 } ] // 自动å‡çº§æ—¶é—´æ®µï¼Œç”¨åˆ†é’Ÿè¡¨ç¤º } -updater.setUpgradePolicy(policy).then(result => { - console.log(`setUpgradePolicy ${result}`); +updater.setUpgradePolicy(policy).then(() => { + console.log(`setUpgradePolicy success`); }).catch(err => { console.log(`setUpgradePolicy promise error ${JSON.stringify(err)}`); }); @@ -831,13 +985,13 @@ terminateUpgrade(callback: AsyncCallback\<void>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\<void> | 是 | 回调函数。当清除å‡çº§ç¼“å˜æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts updater.terminateUpgrade((err) => { console.log(`terminateUpgrade error ${JSON.stringify(err)}`); }); @@ -851,15 +1005,17 @@ terminateUpgrade(): Promise\<void> **系统能力**:SystemCapability.Update.UpdateService +**需è¦æƒé™**:ohos.permission.UPDATE_SYSTEM,该æƒé™ä¸ºç³»ç»Ÿæƒé™ + **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts updater.terminateUpgrade().then(() => { console.log(`terminateUpgrade success`); }).catch(err => { @@ -877,24 +1033,22 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | **示例:** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // 订阅å‡çº§æ›´æ–°äº‹ä»¶ extraInfo: "" } -function onTaskUpdate(eventInfo): void { - console.log(`on eventInfo id `, eventInfo.eventId); -} - -updater.on(eventClassifyInfo, onTaskUpdate); +updater.on(eventClassifyInfo, (eventInfo) => { + console.log("updater on " + JSON.stringify(eventInfo)); +}); ``` ### off @@ -906,24 +1060,22 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | å¦ | 事件回调 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | å¦ | 事件回调 | **示例:** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // 订阅å‡çº§æ›´æ–°äº‹ä»¶ extraInfo: "" } -function onTaskUpdate(eventInfo): void { - console.log(`on eventInfo id `, eventInfo.eventId); -} - -updater.off(eventClassifyInfo, onTaskUpdate); +updater.off(eventClassifyInfo, (eventInfo) => { + console.log("updater off " + JSON.stringify(eventInfo)); +}); ``` ## Restorer @@ -940,13 +1092,13 @@ factoryReset(callback: AsyncCallback\<void>): void **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\<void> | 是 | 回调函数。当æ¢å¤å‡ºåŽ‚执行æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts restorer.factoryReset((err) => { console.log(`factoryReset error ${JSON.stringify(err)}`); }); @@ -964,13 +1116,13 @@ factoryReset(): Promise\<void> **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts restorer.factoryReset().then(() => { console.log(`factoryReset success`); }).catch(err => { @@ -982,7 +1134,7 @@ restorer.factoryReset().then(() => { ### verifyUpgradePackage -verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<number>): void +verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<void>): void æ ¡éªŒå‡çº§åŒ…。使用callback异æ¥å›žè°ƒã€‚ @@ -992,28 +1144,28 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: Asyn **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | [UpgradeFile](#upgradefile) | 是 | å‡çº§æ–‡ä»¶ | -| certsFile | string | 是 | è¯ä¹¦æ–‡ä»¶è·¯å¾„ | -| callback | AsyncCallback\<number> | 是 | 回调函数,返回å‡çº§åŒ…æ ¡éªŒç»“æžœå¯¹è±¡ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ---------------- | +| upgradeFile | [UpgradeFile](#upgradefile) | 是 | å‡çº§æ–‡ä»¶ | +| certsFile | string | 是 | è¯ä¹¦æ–‡ä»¶è·¯å¾„ | +| callback | AsyncCallback\<void> | 是 | 回调函数,返回å‡çº§åŒ…æ ¡éªŒç»“æžœå¯¹è±¡ | **示例:** -``` +```ts var upgradeFile = { fileType: update.ComponentType.OTA, // OTA包 filePath: "path" // 本地å‡çº§åŒ…路径 } -localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err, result) => { +localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath", (err) => { console.log(`factoryReset error ${JSON.stringify(err)}`); }); ``` ### verifyUpgradePackage -verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<number> +verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<void> æ ¡éªŒå‡çº§åŒ…。使用Promise异æ¥å›žè°ƒã€‚ @@ -1023,26 +1175,26 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<numb **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | [UpgradeFile](#upgradefile) | 是 | å‡çº§æ–‡ä»¶ | -| certsFile | string | 是 | è¯ä¹¦æ–‡ä»¶è·¯å¾„ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | --------------------------- | ---- | ------ | +| upgradeFile | [UpgradeFile](#upgradefile) | 是 | å‡çº§æ–‡ä»¶ | +| certsFile | string | 是 | è¯ä¹¦æ–‡ä»¶è·¯å¾„ | **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | -| Promise\<number> | Promise对象,返回å‡çº§åŒ…æ ¡éªŒç»“æžœå¯¹è±¡ã€‚ | +| 类型 | 说明 | +| -------------- | ---------------------- | +| Promise\<void> | Promise对象,返回å‡çº§åŒ…æ ¡éªŒç»“æžœå¯¹è±¡ã€‚ | **示例:** -``` +```ts var upgradeFile = { fileType: update.ComponentType.OTA, // OTA包 filePath: "path" // 本地å‡çº§åŒ…路径 } -localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(result => { - console.log(`verifyUpgradePackage result: ${result}`); +localUpdater.verifyUpgradePackage(upgradeFile, "cerstFilePath").then(() => { + console.log(`verifyUpgradePackage success`); }).catch(err => { console.log(`verifyUpgradePackage error ${JSON.stringify(err)}`); }); @@ -1059,14 +1211,14 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: Asyn **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| upgradeFile | Array<[UpgradeFile](#upgradefile)> | 是 | å‡çº§æ–‡ä»¶ | -| callback | AsyncCallback\<void> | 是 | 回调函数。当安装å‡çº§åŒ…执行æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ---------------------------------- | ---- | --------------------------------------- | +| upgradeFile | Array<[UpgradeFile](#upgradefile)> | 是 | å‡çº§æ–‡ä»¶ | +| callback | AsyncCallback\<void> | 是 | 回调函数。当安装å‡çº§åŒ…执行æˆåŠŸæ—¶ï¼Œerr为undefined,å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **示例:** -``` +```ts var upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA包 filePath: "path" // 本地å‡çº§åŒ…路径 @@ -1089,13 +1241,13 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void **返回值:** -| 类型 | 说明 | -| ---------------------------------------- | ---------------- | +| 类型 | 说明 | +| -------------- | -------------------------- | | Promise\<void> | Promiseå¯¹è±¡ã€‚æ— è¿”å›žç»“æžœçš„Promise对象。 | **示例:** -``` +```ts var upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA包 filePath: "path" // 本地å‡çº§åŒ…路径 @@ -1116,14 +1268,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | **示例:** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // 订阅å‡çº§æ›´æ–°äº‹ä»¶ extraInfo: "" @@ -1145,14 +1297,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| -------- | ---------------------------------------- | ---- | --------- | -| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | -| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | +| taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调 | **示例:** -``` +```ts var eventClassifyInfo = { eventClassify: update.EventClassify.TASK, // 订阅å‡çº§æ›´æ–°äº‹ä»¶ extraInfo: "" @@ -1171,10 +1323,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| upgradeApp | string | 是 | 调用方包å | -| businessType | [BusinessType](#businesstype) | 是 | å‡çº§ä¸šåŠ¡ç±»åž‹ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------ | ----------------------------- | ---- | ------ | +| upgradeApp | string | 是 | 调用方包å | +| businessType | [BusinessType](#businesstype) | 是 | å‡çº§ä¸šåŠ¡ç±»åž‹ | ## BusinessType @@ -1182,10 +1334,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| vendor | [BusinessVendor](#businessvendor) | 是 | 供应商 | -| subType | [BusinessSubType](#businesssubtype) | 是 | 类型 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------- | ----------------------------------- | ---- | ---- | +| vendor | [BusinessVendor](#businessvendor) | 是 | 供应商 | +| subType | [BusinessSubType](#businesssubtype) | 是 | 类型 | ## CheckResult @@ -1193,10 +1345,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| isExistNewVersion | bool | 是 | 是å¦æœ‰æ–°ç‰ˆæœ¬ | -| newVersionInfo | [NewVersionInfo](#newversioninfo) | å¦ | æ–°ç‰ˆæœ¬æ•°æ® | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----------------- | --------------------------------- | ---- | ------ | +| isExistNewVersion | bool | 是 | 是å¦æœ‰æ–°ç‰ˆæœ¬ | +| newVersionInfo | [NewVersionInfo](#newversioninfo) | å¦ | æ–°ç‰ˆæœ¬æ•°æ® | ## NewVersionInfo @@ -1204,10 +1356,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | ç‰ˆæœ¬æ‘˜è¦ | -| versionComponents | Array\<[VersionComponent](#versioncomponent)> | 是 | 版本组件 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | ç‰ˆæœ¬æ‘˜è¦ | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | 是 | 版本组件 | ## VersionDigestInfo @@ -1215,9 +1367,9 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigest | string | 是 | ç‰ˆæœ¬æ‘˜è¦ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------- | ------ | ---- | ---- | +| versionDigest | string | 是 | ç‰ˆæœ¬æ‘˜è¦ | ## VersionComponent @@ -1225,15 +1377,38 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| componentType | [ComponentType](#componentyype) | 是 | 组件类型 | -| upgradeAction | [UpgradeAction](#upgradeaction) | 是 | å‡çº§æ–¹å¼ | -| displayVersion | string | 是 | æ˜¾ç¤ºç‰ˆæœ¬å· | -| innerVersion | string | 是 | ç‰ˆæœ¬å· | -| size | number | 是 | å‡çº§åŒ…å¤§å° | -| effectiveMode | [EffectiveMode](#effectivemode) | 是 | ç”Ÿæ•ˆæ¨¡å¼ | -| descriptionInfo | [DescriptionInfo](#descriptioninfo) | 是 | 版本æè¿°æ–‡ä»¶ä¿¡æ¯ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| --------------- | ----------------------------------- | ---- | -------- | +| componentId | number | 是 | ç»„ä»¶æ ‡è¯† | +| componentType | [ComponentType](#componenttype) | 是 | 组件类型 | +| upgradeAction | [UpgradeAction](#upgradeaction) | 是 | å‡çº§æ–¹å¼ | +| displayVersion | string | 是 | æ˜¾ç¤ºç‰ˆæœ¬å· | +| innerVersion | string | 是 | ç‰ˆæœ¬å· | +| size | number | 是 | å‡çº§åŒ…å¤§å° | +| effectiveMode | [EffectiveMode](#effectivemode) | 是 | ç”Ÿæ•ˆæ¨¡å¼ | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | 是 | 版本æè¿°æ–‡ä»¶ä¿¡æ¯ | + +## DescriptionOptions + +æ述文件选项。 + +**系统能力**:SystemCapability.Update.UpdateService + +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | --------------------------------------- | ---- | ------ | +| format | [DescriptionFormat](#descriptionformat) | 是 | æè¿°æ–‡ä»¶æ ¼å¼ | +| language | string | 是 | æ述文件è¯è¨€ | + +## ComponentDescription + +组件æ述文件。 + +**系统能力**:SystemCapability.Update.UpdateService + +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| --------------- | ----------------------------------- | ---- | ------ | +| componentId | string | 是 | ç»„ä»¶æ ‡è¯† | +| descriptionInfo | [DescriptionInfo](#descriptioninfo) | 是 | æè¿°æ–‡ä»¶ä¿¡æ¯ | ## DescriptionInfo @@ -1241,10 +1416,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| descriptionType | [DescriptionType](#descriptiontype) | 是 | æ述文件类型 | -| content | string | 是 | æ述文件内容 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| --------------- | ----------------------------------- | ---- | ------ | +| descriptionType | [DescriptionType](#descriptiontype) | 是 | æ述文件类型 | +| content | string | 是 | æ述文件内容 | ## CurrentVersionInfo @@ -1252,11 +1427,11 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| osVersion | string | 是 | ç³»ç»Ÿç‰ˆæœ¬å· | -| deviceName | string | 是 | 设备å | -| versionComponents | Array\<[VersionComponent](#vesioncomponent)> | å¦ | 版本组件 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ----- | +| osVersion | string | 是 | ç³»ç»Ÿç‰ˆæœ¬å· | +| deviceName | string | 是 | 设备å | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | å¦ | 版本组件 | ## DownloadOptions @@ -1264,10 +1439,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| allowNetwork | [NetType](#nettype) | 是 | 网络类型 | -| order | [Order](#order) | 是 | å‡çº§æŒ‡ä»¤ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------ | ------------------- | ---- | ---- | +| allowNetwork | [NetType](#nettype) | 是 | 网络类型 | +| order | [Order](#order) | 是 | å‡çº§æŒ‡ä»¤ | ## ResumeDownloadOptions @@ -1275,9 +1450,9 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| allowNetwork | [NetType](#nettype) | 是 | 网络类型 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------ | ------------------- | ---- | ---- | +| allowNetwork | [NetType](#nettype) | 是 | 网络类型 | ## PauseDownloadOptions @@ -1285,9 +1460,9 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| isAllowAutoResume | bool | 是 | 是å¦å…许自动æ¢å¤ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----------------- | ---- | ---- | -------- | +| isAllowAutoResume | bool | 是 | 是å¦å…许自动æ¢å¤ | ## UpgradeOptions @@ -1295,9 +1470,9 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| order | [Order](#order) | 是 | å‡çº§æŒ‡ä»¤ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----- | --------------- | ---- | ---- | +| order | [Order](#order) | 是 | å‡çº§æŒ‡ä»¤ | ## ClearOptions @@ -1305,9 +1480,9 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| status | [UpgradeStatus](#upgradestatus) | 是 | å¼‚å¸¸çŠ¶æ€ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------ | ------------------------------- | ---- | ---- | +| status | [UpgradeStatus](#upgradestatus) | 是 | å¼‚å¸¸çŠ¶æ€ | ## UpgradePolicy @@ -1315,11 +1490,11 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| downloadStrategy | bool | 是 | 自动下载ç–ç•¥ | -| autoUpgradeStrategy | bool | 是 | 自动å‡çº§ç–ç•¥ | -| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | 是 | 自动å‡çº§æ—¶é—´æ®µ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------------- | --------------------------------------- | ---- | ------- | +| downloadStrategy | bool | 是 | 自动下载ç–ç•¥ | +| autoUpgradeStrategy | bool | 是 | 自动å‡çº§ç–ç•¥ | +| autoUpgradePeriods | Array\<[UpgradePeriod](#upgradeperiod)> | 是 | 自动å‡çº§æ—¶é—´æ®µ | ## UpgradePeriod @@ -1327,10 +1502,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| start | number | 是 | 开始时间 | -| end | number | 是 | 结æŸæ—¶é—´ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----- | ------ | ---- | ---- | +| start | number | 是 | 开始时间 | +| end | number | 是 | 结æŸæ—¶é—´ | ## TaskInfo @@ -1338,10 +1513,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| existTask | bool | 是 | 是å¦å˜åœ¨ä»»åŠ¡ | -| taskBody | [TaskBody](#taskinfo) | 是 | ä»»åŠ¡æ•°æ® | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| --------- | --------------------- | ---- | ------ | +| existTask | bool | 是 | 是å¦å˜åœ¨ä»»åŠ¡ | +| taskBody | [TaskBody](#taskinfo) | 是 | ä»»åŠ¡æ•°æ® | ## EventInfo @@ -1349,10 +1524,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| eventId | [EventId](#eventid) | 是 | 事件ID | -| taskBody | [TaskBody](#taskinfo) | 是 | ä»»åŠ¡æ•°æ® | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | --------------------- | ---- | ---- | +| eventId | [EventId](#eventid) | 是 | 事件ID | +| taskBody | [TaskBody](#taskinfo) | 是 | ä»»åŠ¡æ•°æ® | ## TaskBody @@ -1360,15 +1535,15 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | ç‰ˆæœ¬æ‘˜è¦ | -| status | [UpgradeStatus](#upgradestatus) | 是 | å‡çº§çŠ¶æ€ | -| subStatus | number | å¦ | åçŠ¶æ€ | -| progress | number | 是 | 进度 | -| installMode | number | 是 | å®‰è£…æ¨¡å¼ | -| errorMessages | Array\<[ErrorMessage](#errormessage)> | å¦ | é”™è¯¯ä¿¡æ¯ | -| versionComponets | Array\<[VersionComponet](#versioncomponet)> | 是 | 版本组件 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ----------------- | ---------------------------------------- | ---- | ---- | +| versionDigestInfo | [VersionDigestInfo](#versiondigestinfo) | 是 | ç‰ˆæœ¬æ‘˜è¦ | +| status | [UpgradeStatus](#upgradestatus) | 是 | å‡çº§çŠ¶æ€ | +| subStatus | number | å¦ | åçŠ¶æ€ | +| progress | number | 是 | 进度 | +| installMode | number | 是 | å®‰è£…æ¨¡å¼ | +| errorMessages | Array\<[ErrorMessage](#errormessage)> | å¦ | é”™è¯¯ä¿¡æ¯ | +| versionComponents | Array\<[VersionComponent](#versioncomponent)> | 是 | 版本组件 | ## ErrorMessage @@ -1376,10 +1551,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| errorCode | number | 是 | 错误ç | -| errorMessage | string | 是 | 错误æè¿° | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------ | ------ | ---- | ---- | +| errorCode | number | 是 | 错误ç | +| errorMessage | string | 是 | 错误æè¿° | ## EventClassifyInfo @@ -1387,10 +1562,10 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| eventClassify | [EventClassify](#eventclassify) | 是 | 事件类型 | -| extraInfo | string | 是 | é¢å¤–ä¿¡æ¯ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| ------------- | ------------------------------- | ---- | ---- | +| eventClassify | [EventClassify](#eventclassify) | 是 | 事件类型 | +| extraInfo | string | 是 | é¢å¤–ä¿¡æ¯ | ## UpgradeFile @@ -1398,23 +1573,22 @@ localUpdater.off(eventClassifyInfo, onTaskUpdate); **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| ------------------- | --------------------------- | ---- | ------- | -| fileType | [ComponentType](#componenttype) | 是 | 文件类型 | -| filePath | string | 是 | 文件路径 | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ------------------------------- | ---- | ---- | +| fileType | [ComponentType](#componenttype) | 是 | 文件类型 | +| filePath | string | 是 | 文件路径 | ## UpgradeTaskCallback -### onTaskUpdate -onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void +### (eventInfo: [EventInfo](#eventinfo)): void 事件回调。 **系统能力**:SystemCapability.Update.UpdateService -| å称 | å‚数类型 | å¿…å¡« | 说明 | -| --------------- | ---------------------------------------- | ---- | ---- | -| eventInfo | [EventInfo](#eventinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | +| å称 | å‚数类型 | å¿…å¡« | 说明 | +| --------- | ----------------------- | ---- | ---- | +| eventInfo | [EventInfo](#eventinfo) | 是 | äº‹ä»¶ä¿¡æ¯ | ## BusinessVendor @@ -1422,9 +1596,9 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| PUBLIC | "public" | å¼€æº | +| å‚æ•°å | 默认值 | 说明 | +| ------ | -------- | ---- | +| PUBLIC | "public" | å¼€æº | ## BusinessSubType @@ -1432,19 +1606,19 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| FIRWARE | 1 | 固件 | +| å‚æ•°å | 默认值 | 说明 | +| -------- | ---- | ---- | +| FIRMWARE | 1 | 固件 | ## ComponentType -å‡çº§åŒ…类型。 +组件类型。 **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| OTA | 1 | 固件 | +| å‚æ•°å | 默认值 | 说明 | +| ---- | ---- | ---- | +| OTA | 1 | 固件 | ## UpgradeAction @@ -1452,10 +1626,10 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| UPGRADE | "upgrade" | 差分包 | -| RECOVERY | "recovery" | ä¿®å¤åŒ… | +| å‚æ•°å | 默认值 | 说明 | +| -------- | ---------- | ---- | +| UPGRADE | "upgrade" | 差分包 | +| RECOVERY | "recovery" | ä¿®å¤åŒ… | ## EffectiveMode @@ -1463,11 +1637,11 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| COLD | 1 | 冷å‡çº§ | -| LIVE | 2 | çƒå‡çº§ | -| LIVE_AND_COLD | 3 | èžåˆå‡çº§ | +| å‚æ•°å | 默认值 | 说明 | +| ------------- | ---- | ---- | +| COLD | 1 | 冷å‡çº§ | +| LIVE | 2 | çƒå‡çº§ | +| LIVE_AND_COLD | 3 | èžåˆå‡çº§ | ## DescriptionType @@ -1475,10 +1649,21 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| CONTENT | 0 | 内容 | -| URI | 1 | 链接 | +| å‚æ•°å | 默认值 | 说明 | +| ------- | ---- | ---- | +| CONTENT | 0 | 内容 | +| URI | 1 | 链接 | + +## DescriptionFormat + +æè¿°æ–‡ä»¶æ ¼å¼ã€‚ + +**系统能力**:SystemCapability.Update.UpdateService + +| å‚æ•°å | 默认值 | 说明 | +| ---------- | ---- | ---- | +| STANDARD | 0 | æ ‡å‡†æ ¼å¼ | +| SIMPLIFIED | 1 | ç®€æ˜“æ ¼å¼ | ## NetType @@ -1486,13 +1671,13 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| CELLULAR | 1 | æ•°æ®ç½‘络 | -| METERED_WIFI | 2 | çƒç‚¹WIFI | -| NOT_METERED_WIFI | 4 | éžçƒç‚¹WIFI | -| WIFI | 6 | WIFI | -| CELLULAR_AND_WIFI | 7 | æ•°æ®ç½‘络和WIFI | +| å‚æ•°å | 默认值 | 说明 | +| ----------------- | ---- | --------- | +| CELLULAR | 1 | æ•°æ®ç½‘络 | +| METERED_WIFI | 2 | çƒç‚¹WIFI | +| NOT_METERED_WIFI | 4 | éžçƒç‚¹WIFI | +| WIFI | 6 | WIFI | +| CELLULAR_AND_WIFI | 7 | æ•°æ®ç½‘络和WIFI | ## Order @@ -1500,13 +1685,13 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| DOWNLOAD | 1 | 下载 | -| INSTALL | 2 | 安装 | -| APPLY | 4 | 生效 | -| DOWNLOAD_AND_INSTALL | 3 | 下载并安装 | -| INSTALL_AND_APPLY | 6 | 安装并生效 | +| å‚æ•°å | 默认值 | 说明 | +| -------------------- | ---- | ----- | +| DOWNLOAD | 1 | 下载 | +| INSTALL | 2 | 安装 | +| DOWNLOAD_AND_INSTALL | 3 | 下载并安装 | +| APPLY | 4 | 生效 | +| INSTALL_AND_APPLY | 6 | 安装并生效 | ## UpgradeStatus @@ -1514,18 +1699,18 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| WAITING_DOWNLOAD | 20 | 待下载 | -| DOWNLOADING | 21 | ä¸‹è½½ä¸ | -| DOWNLOAD_PAUSE | 22 | ä¸‹è½½æš‚åœ | -| DOWNLOAD_FAIL | 23 | 下载失败 | -| WAITING_INSTALL | 30 | 待安装 | -| UPDATING | 31 | æ›´æ–°ä¸ | -| WATING_APPLY | 40 | 待生效 | -| APPLYING | 21 | ç”Ÿæ•ˆä¸ | -| UPGRADE_SUCCESS | 50 | å‡çº§æˆåŠŸ | -| UPGRADE_FAIL | 51 | å‡çº§å¤±è´¥ | +| å‚æ•°å | 默认值 | 说明 | +| ---------------- | ---- | ---- | +| WAITING_DOWNLOAD | 20 | 待下载 | +| DOWNLOADING | 21 | ä¸‹è½½ä¸ | +| DOWNLOAD_PAUSED | 22 | ä¸‹è½½æš‚åœ | +| DOWNLOAD_FAIL | 23 | 下载失败 | +| WAITING_INSTALL | 30 | 待安装 | +| UPDATING | 31 | æ›´æ–°ä¸ | +| WAITING_APPLY | 40 | 待生效 | +| APPLYING | 21 | ç”Ÿæ•ˆä¸ | +| UPGRADE_SUCCESS | 50 | å‡çº§æˆåŠŸ | +| UPGRADE_FAIL | 51 | å‡çº§å¤±è´¥ | ## EventClassify @@ -1533,9 +1718,9 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| TASK | 0x01000000 | 任务事件 | +| å‚æ•°å | 默认值 | 说明 | +| ---- | ---------- | ---- | +| TASK | 0x01000000 | 任务事件 | ## EventId @@ -1543,22 +1728,22 @@ onTaskUpdate(eventInfo: [EventInfo](#eventinfo)): void **系统能力**:SystemCapability.Update.UpdateService -| å‚æ•°å | 默认值 | 说明 | -| ------------------- | ---- | -------- | -| EVENT_TASK_BASE | 0x01000000 | 任务事件 | -| EVENT_TASK_RECEIVE | 0x01000001 | 收到任务 | -| EVENT_TASK_CANCEL | 0x01000010 | å–消任务 | -| EVENT_DOWNLOAD_WAIT | 0x01000011 | 待下载 | -| EVENT_DOWNLOAD_START | 0x01000100 | 开始下载 | -| EVENT_DOWNLOAD_UPDATE | 0x01000101 | 下载进度更新 | -| EVENT_DOWNLOAD_PAUSE | 0x01000110 | ä¸‹è½½æš‚åœ | -| EVENT_DOWNLOAD_RESUME | 0x01000111 | æ¢å¤ä¸‹è½½ | -| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | 下载æˆåŠŸ | -| EVENT_DOWNLOAD_FAIL | 0x01001001 | 下载失败 | -| EVENT_UPGRADE_WAIT | 0x01001010 | å¾…å‡çº§ | -| EVENT_UPGRADE_START | 0x01001011 | 开始å‡çº§ | -| EVENT_UPGRADE_UPDATE | 0x01001100 | å‡çº§ä¸ | -| EVENT_APPLY_WAIT | 0x01001101 | 待生效 | -| EVENT_APPLY_START | 0x01001110 | 开始生效 | -| EVENT_UPGRADE_SUCCESS | 0x01001111 | æ›´æ–°æˆåŠŸ | -| EVENT_UPGRADE_FAIL | 0x01010000 | 更新失败 | +| å‚æ•°å | 默认值 | 说明 | +| ---------------------- | ---------- | ------ | +| EVENT_TASK_BASE | 0x01000000 | 任务事件 | +| EVENT_TASK_RECEIVE | 0x01000001 | 收到任务 | +| EVENT_TASK_CANCEL | 0x01000010 | å–消任务 | +| EVENT_DOWNLOAD_WAIT | 0x01000011 | 待下载 | +| EVENT_DOWNLOAD_START | 0x01000100 | 开始下载 | +| EVENT_DOWNLOAD_UPDATE | 0x01000101 | 下载进度更新 | +| EVENT_DOWNLOAD_PAUSE | 0x01000110 | ä¸‹è½½æš‚åœ | +| EVENT_DOWNLOAD_RESUME | 0x01000111 | æ¢å¤ä¸‹è½½ | +| EVENT_DOWNLOAD_SUCCESS | 0x01001000 | 下载æˆåŠŸ | +| EVENT_DOWNLOAD_FAIL | 0x01001001 | 下载失败 | +| EVENT_UPGRADE_WAIT | 0x01001010 | å¾…å‡çº§ | +| EVENT_UPGRADE_START | 0x01001011 | 开始å‡çº§ | +| EVENT_UPGRADE_UPDATE | 0x01001100 | å‡çº§ä¸ | +| EVENT_APPLY_WAIT | 0x01001101 | 待生效 | +| EVENT_APPLY_START | 0x01001110 | 开始生效 | +| EVENT_UPGRADE_SUCCESS | 0x01001111 | æ›´æ–°æˆåŠŸ | +| EVENT_UPGRADE_FAIL | 0x01010000 | 更新失败 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index eab93b045720c98fe9c3da9cde16a1f921f745a5..f7a30ab9b74c73fc034b9d8f37d69ff1337a21f2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -108,10 +108,10 @@ getAll(name: string): string[] **示例:** ```js -let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); -paramsObject.append('fod', '3'); // Add a second value for the fod parameter. -console.log(params.getAll('fod')) // Output ["1","3"]. +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let params = new Url.URLSearchParams(urlObject.search.slice(1)); +params.append('fod', '3'); // Add a second value for the fod parameter. +console.log(params.getAll('fod').toString()) // Output ["1","3"]. ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index 6f3b930ad6295efe57cb60f7543cec2a2c528990..12943e5dc43837fc335678354036d03fbf3a4e7d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -3,7 +3,7 @@ 本模å—主è¦æ供管ç†USB设备的相关功能,包括查询USB设备列表ã€æ‰¹é‡æ•°æ®ä¼ 输ã€æŽ§åˆ¶å‘½ä»¤ä¼ 输ã€æƒé™æŽ§åˆ¶ç‰ã€‚ > **说明:** -> +> > 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— @@ -22,66 +22,66 @@ getDevices(): Array<Readonly<USBDevice>> **返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Array<Readonly<[USBDevice](#usbdevice)>> | 设备信æ¯åˆ—表。 | +| 类型 | 说明 | +| ---------------------------------------------------- | ------- | +| Array<Readonly<[USBDevice](#usbdevice)>> | 设备信æ¯åˆ—表。 | **示例:** - ```js - let devicesList = usb.getDevices(); - console.log(`devicesList = ${JSON.stringify(devicesList)}`); - //devicesList 返回的数æ®ç»“æž„ - //æ¤å¤„æ供一个简å•çš„示例,如下 - [ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subclass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subclass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - }, - ], - }, - ], - }, - ], - }, - ] - ``` +```js +let devicesList = usb.getDevices(); +console.log(`devicesList = ${JSON.stringify(devicesList)}`); +//devicesList 返回的数æ®ç»“æž„ +//æ¤å¤„æ供一个简å•çš„示例,如下 +[ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subclass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subclass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, +] +``` ## usb.connectDevice @@ -104,11 +104,11 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe> | Readonly<[USBDevicePipe](#usbdevicepipe)> | æŒ‡å®šçš„ä¼ è¾“é€šé“对象。 | **示例:** - ```js - let devicepipe= usb.connectDevice(device); - console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); - ``` +```js +let devicepipe= usb.connectDevice(device); +console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); +``` ## usb.hasRight @@ -129,12 +129,12 @@ hasRight(deviceName: string): boolean | boolean | true表示有访问设备的æƒé™ï¼Œfalse表示没有访问设备的æƒé™ã€‚ | **示例:** - ```js - let divicesName="1-1"; - let bool = usb.hasRight(divicesName); - console.log(bool); - ``` +```js +let devicesName="1-1"; +let bool = usb.hasRight(devicesName); +console.log(bool); +``` ## usb.requestRight @@ -155,12 +155,13 @@ requestRight(deviceName: string): Promise<boolean> | Promise<boolean> | 获å–到true则表示软件包的临时æƒé™å·²è®¿é—®æˆåŠŸï¼Œ 获å–到false则表示软件包的临时æƒé™å·²è®¿é—®å¤±è´¥ã€‚ | **示例:** - ```js - let divicesName="1-1"; - usb.requestRight(divicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); - }); - ``` + +```js +let devicesName="1-1"; +usb.requestRight(devicesName).then((ret) => { + console.log(`requestRight = ${JSON.stringify(ret)}`); +}); +``` ## usb.claimInterface @@ -185,11 +186,11 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): numbe | number | 注册通信接å£æˆåŠŸè¿”回0;注册通信接å£å¤±è´¥è¿”回其他错误ç 。 | **示例:** - ```js - let ret = usb.claimInterface(devicepipe, interfaces); - console.log(`claimInterface = ${ret}`); - ``` +```js +let ret = usb.claimInterface(devicepipe, interfaces); +console.log(`claimInterface = ${ret}`); +``` ## usb.releaseInterface @@ -213,11 +214,11 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | number | 释放接å£æˆåŠŸè¿”回0;释放接å£å¤±è´¥è¿”回其他错误ç 。 | **示例:** - ```js - let ret = usb.releaseInterface(devicepipe, interfaces); - console.log(`releaseInterface = ${ret}`); - ``` +```js +let ret = usb.releaseInterface(devicepipe, interfaces); +console.log(`releaseInterface = ${ret}`); +``` ## usb.setConfiguration @@ -241,10 +242,11 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | number | 设置设备é…ç½®æˆåŠŸè¿”回0;设置设备é…置失败返回其他错误ç 。 | **示例:** - ```js - let ret = usb.setConfiguration(devicepipe, config); - console.log(`setConfiguration = ${ret}`); - ``` + +```js +let ret = usb.setConfiguration(devicepipe, config); +console.log(`setConfiguration = ${ret}`); +``` ## usb.setInterface @@ -258,10 +260,10 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定总线å·å’Œè®¾å¤‡åœ°å€ã€‚ | - | iface | [USBInterface](#usbinterface) | 是 | 用于确定需è¦è®¾ç½®çš„接å£ã€‚ | +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----- | ------------------------------- | --- | ------------- | +| pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定总线å·å’Œè®¾å¤‡åœ°å€ã€‚ | +| iface | [USBInterface](#usbinterface) | 是 | 用于确定需è¦è®¾ç½®çš„接å£ã€‚ | **返回值:** | 类型 | 说明 | @@ -269,10 +271,11 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number | number | 设置设备接å£æˆåŠŸè¿”回0;设置设备接å£å¤±è´¥è¿”回其他错误ç 。 | **示例:** - ```js - let ret = usb.setInterface(devicepipe, interfaces); - console.log(`setInterface = ${ret}`); - ``` + +```js +let ret = usb.setInterface(devicepipe, interfaces); +console.log(`setInterface = ${ret}`); +``` ## usb.getRawDescriptor @@ -285,6 +288,7 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array **系统能力:** SystemCapability.USB.USBManager **å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | 是 | 用于确定总线å·å’Œè®¾å¤‡åœ°å€ã€‚ | @@ -295,10 +299,10 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Uint8Array | 返回获å–的原始数æ®ï¼›å¤±è´¥è¿”回undefined。 | **示例:** - ```js - let ret = usb.getRawDescriptor(devicepipe); - ``` +```js +let ret = usb.getRawDescriptor(devicepipe); +``` ## usb.getFileDescriptor @@ -317,15 +321,15 @@ getFileDescriptor(pipe: USBDevicePipe): number **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------ | -------------------- | | number | 返回设备对应的文件æ述符;失败返回-1。 | **示例:** - ```js - let ret = usb.getFileDescriptor(devicepipe); - ``` +```js +let ret = usb.getFileDescriptor(devicepipe); +``` ## usb.controlTransfer @@ -350,12 +354,12 @@ controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: nu | Promise<number> | 获å–ä¼ è¾“æˆ–æŽ¥æ”¶åˆ°çš„æ•°æ®å—大å°ï¼Œ 获å–到-1则表示异常。 | **示例:** - ```js - usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); - }) - ``` +```js +usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { + console.log(`controlTransfer = ${JSON.stringify(ret)}`); +}) +``` ## usb.bulkTransfer @@ -381,15 +385,15 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim | Promise<number> | 获å–ä¼ è¾“æˆ–æŽ¥æ”¶åˆ°çš„æ•°æ®å—大å°ï¼Œ 获å–到-1则表示异常。 | **示例:** - ```js - //usb.getDevices 接å£è¿”回数æ®é›†åˆï¼Œå–å…¶ä¸ä¸€ä¸ªè®¾å¤‡å¯¹è±¡ï¼Œå¹¶èŽ·å–æƒé™ 。 - //把获å–到的设备对象作为å‚æ•°ä¼ å…¥usb.connectDevice;当usb.connectDevice接å£æˆåŠŸè¿”回之åŽï¼› - //æ‰å¯ä»¥è°ƒç”¨ç¬¬ä¸‰ä¸ªæŽ¥å£usb.claimInterface.当usb.claimInterface 调用æˆåŠŸä»¥åŽ,å†è°ƒç”¨è¯¥æŽ¥å£ã€‚ - usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); - }); - ``` +```js +//usb.getDevices 接å£è¿”回数æ®é›†åˆï¼Œå–å…¶ä¸ä¸€ä¸ªè®¾å¤‡å¯¹è±¡ï¼Œå¹¶èŽ·å–æƒé™ 。 +//把获å–到的设备对象作为å‚æ•°ä¼ å…¥usb.connectDevice;当usb.connectDevice接å£æˆåŠŸè¿”回之åŽï¼› +//æ‰å¯ä»¥è°ƒç”¨ç¬¬ä¸‰ä¸ªæŽ¥å£usb.claimInterface.当usb.claimInterface 调用æˆåŠŸä»¥åŽ,å†è°ƒç”¨è¯¥æŽ¥å£ã€‚ +usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { + console.log(`bulkTransfer = ${JSON.stringify(ret)}`); +}); +``` ## usb.closePipe @@ -412,149 +416,424 @@ closePipe(pipe: USBDevicePipe): number | number | å…³é—设备消æ¯æŽ§åˆ¶é€šé“æˆåŠŸè¿”回0;关é—设备消æ¯æŽ§åˆ¶é€šé“失败返回其他错误ç 。 | **示例:** - ```js - let ret = usb.closePipe(devicepipe); - console.log(`closePipe = ${ret}`); - ``` +```js +let ret = usb.closePipe(devicepipe); +console.log(`closePipe = ${ret}`); +``` + +## usb.usbFunctionsFromString<sup>9+</sup> + +usbFunctionsFromString(funcs: string): number + +在设备模å¼ä¸‹ï¼Œå°†å—符串形å¼çš„usb功能列表转化为数å—掩ç 。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------------------- | +| funcs | string | 是 | å—符串形å¼çš„功能列表。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------ | +| number | 转化åŽçš„æ•°å—掩ç 。 | + +**示例:** + +```js +let funcs = "acm"; +let ret = usb.usbFunctionsFromString(funcs); +``` + +## usb.usbFunctionsToString<sup>9+</sup> + +usbFunctionsToString(funcs: FunctionType): string + +在设备模å¼ä¸‹ï¼Œå°†æ•°å—掩ç å½¢å¼çš„usb功能列表转化为å—符串。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------------------------------ | ---- | ----------------- | +| funcs | [FunctionType](#functiontype9) | 是 | usb功能数å—掩ç 。 | + +**返回值:** + +| 类型 | 说明 | +| ------ | ------------------------------ | +| string | 转化åŽçš„å—符串形å¼çš„功能列表。 | + +**示例:** + +```js +let funcs = ACM | ECM; +let ret = usb.usbFunctionsToString(funcs); +``` + +## usb.setCurrentFunctions<sup>9+</sup> + +setCurrentFunctions(funcs: FunctionType): Promise\<boolean\> + +在设备模å¼ä¸‹ï¼Œè®¾ç½®å½“å‰çš„USB功能列表。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------------------------------ | ---- | ----------------- | +| funcs | [FunctionType](#functiontype9) | 是 | USB功能数å—掩ç 。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------ | ------------------------------------------------------ | +| Promise\<boolean\> | 设置USB功能列表是å¦æˆåŠŸï¼Œtrue表示æˆåŠŸï¼Œfalse表示失败。 | + +**示例:** + +```js +let funcs = HDC; +let ret = usb.setCurrentFunctions(funcs); +``` + +## usb.getCurrentFunctions<sup>9+</sup> + +getCurrentFunctions(): FunctionType + +在设备模å¼ä¸‹ï¼ŒèŽ·å–当å‰çš„USB功能列表的数å—组åˆæŽ©ç 。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**返回值:** + +| 类型 | 说明 | +| ------------------------------ | --------------------------------- | +| [FunctionType](#functiontype9) | 当å‰çš„USB功能列表的数å—组åˆæŽ©ç 。 | + +**示例:** + +```js +let ret = usb.getCurrentFunctions(); +``` + +## usb.getPorts<sup>9+</sup> + +getPorts(): Array\<USBPort\> + +获å–所有物ç†USB端å£æè¿°ä¿¡æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | --------------------- | +| [Array\<USBPort\>](#usbport9) | USB端å£æè¿°ä¿¡æ¯åˆ—表。 | + +**示例:** + +```js +let ret = usb.getPorts(); +``` + +## usb.getSupportedModes<sup>9+</sup> + +getSupportedModes(portId: number): PortModeType + +获å–指定的端å£æ”¯æŒçš„模å¼åˆ—表的组åˆæŽ©ç 。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | -------- | +| portId | number | 是 | 端å£å·ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------ | -------------------------- | +| [PortModeType](#portmodetype9) | 支æŒçš„模å¼åˆ—表的组åˆæŽ©ç 。 | + +**示例:** + +```js +let ret = usb.getSupportedModes(0); +``` + +## usb.setPortRoles<sup>9+</sup> + +setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\<boolean\> + +设置指定的端å£æ”¯æŒçš„角色模å¼ï¼ŒåŒ…å«å……电角色ã€æ•°æ®ä¼ 输角色。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.USB.USBManager + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | -------------------------------- | ---- | ---------------- | +| portId | number | 是 | 端å£å·ã€‚ | +| powerRole | [PowerRoleType](#powerroletype9) | 是 | 充电的角色。 | +| dataRole | [DataRoleType](#dataroletype9) | 是 | æ•°æ®ä¼ 输的角色。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------ | -------------- | +| Promise\<boolean\> | 设置是å¦æˆåŠŸã€‚ | + +**示例:** + +```js +let ret = usb.getSupportedModes(0); +``` ## USBEndpoint 通过USBå‘é€å’ŒæŽ¥æ”¶æ•°æ®çš„端å£ã€‚通过[USBInterface](#usbinterface)获å–。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| address | number | 端点地å€ã€‚| -| attributes | number | 端点属性。| -| interval | number | 端点间隔。| -| maxPacketSize | number | 端点最大数æ®åŒ…大å°ã€‚| -| direction | [USBRequestDirection](#usbrequestdirection) | 端点的方å‘。| -| number | number | 端点å·ã€‚| -| type | number | 端点类型。| -| interfaceId | number | 端点所属的接å£çš„å”¯ä¸€æ ‡è¯†ã€‚| +**系统能力**:SystemCapability.USB.USBManager +| å称 | å‚数类型 | 说明 | +| ------------- | ------------------------------------------- | ------------- | +| address | number | 端点地å€ã€‚ | +| attributes | number | 端点属性。 | +| interval | number | 端点间隔。 | +| maxPacketSize | number | 端点最大数æ®åŒ…大å°ã€‚ | +| direction | [USBRequestDirection](#usbrequestdirection) | 端点的方å‘。 | +| number | number | 端点å·ã€‚ | +| type | number | 端点类型。 | +| interfaceId | number | 端点所属的接å£çš„å”¯ä¸€æ ‡è¯†ã€‚ | ## USBInterface 一个[USBConfig](#usbconfig)ä¸å¯ä»¥å«æœ‰å¤šä¸ªUSBInterface,æ¯ä¸ªUSBInterfaceæ供一个功能。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| id | number | 接å£çš„å”¯ä¸€æ ‡è¯†ã€‚| -| protocol | number | 接å£çš„å议。| -| clazz | number | 设备类型。| -| subClass | number | 设备å类。| -| alternateSetting | number | 在åŒä¸€ä¸ªæŽ¥å£ä¸çš„多个æ述符ä¸è¿›è¡Œåˆ‡æ¢è®¾ç½®ã€‚| -| name | string | 接å£å称。| -| endpoints | Array<[USBEndpoint](#usbendpoint)> | 当å‰æŽ¥å£æ‰€åŒ…å«çš„端点。| +**系统能力**:SystemCapability.USB.USBManager +| å称 | å‚数类型 | 说明 | +| ---------------- | ---------------------------------------- | --------------------- | +| id | number | 接å£çš„å”¯ä¸€æ ‡è¯†ã€‚ | +| protocol | number | 接å£çš„å议。 | +| clazz | number | 设备类型。 | +| subClass | number | 设备å类。 | +| alternateSetting | number | 在åŒä¸€ä¸ªæŽ¥å£ä¸çš„多个æ述符ä¸è¿›è¡Œåˆ‡æ¢è®¾ç½®ã€‚ | +| name | string | 接å£å称。 | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | 当å‰æŽ¥å£æ‰€åŒ…å«çš„端点。 | ## USBConfig USBé…置,一个[USBDevice](#usbdevice)ä¸å¯ä»¥å«æœ‰å¤šä¸ªé…置。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| id | number | é…ç½®çš„å”¯ä¸€æ ‡è¯†ã€‚| -| attributes | number | é…置的属性。| -| maxPower | number | 最大功耗,以毫安为å•ä½ã€‚| -| name | string | é…置的å称,å¯ä»¥ä¸ºç©ºã€‚| -| isRemoteWakeup | boolean | 检查当å‰é…置是å¦æ”¯æŒè¿œç¨‹å”¤é†’。| -| isSelfPowered | boolean | 检查当å‰é…置是å¦æ”¯æŒç‹¬ç«‹ç”µæºã€‚| -| interfaces | Array <[USBInterface](#usbinterface)> | é…置支æŒçš„接å£å±žæ€§ã€‚| +**系统能力**:SystemCapability.USB.USBManager +| å称 | å‚数类型 | 说明 | +| -------------- | ------------------------------------------------ | --------------- | +| id | number | é…ç½®çš„å”¯ä¸€æ ‡è¯†ã€‚ | +| attributes | number | é…置的属性。 | +| maxPower | number | 最大功耗,以毫安为å•ä½ã€‚ | +| name | string | é…置的å称,å¯ä»¥ä¸ºç©ºã€‚ | +| isRemoteWakeup | boolean | 检查当å‰é…置是å¦æ”¯æŒè¿œç¨‹å”¤é†’。 | +| isSelfPowered | boolean | 检查当å‰é…置是å¦æ”¯æŒç‹¬ç«‹ç”µæºã€‚ | +| interfaces | Array <[USBInterface](#usbinterface)> | é…置支æŒçš„接å£å±žæ€§ã€‚ | ## USBDevice USB设备信æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| busNum | number | 总线地å€ã€‚| -| devAddress | number | 设备地å€ã€‚| -| serial | string | åºåˆ—å·ã€‚| -| name | string | 设备åå—。| -| manufacturerName | string | 产商信æ¯ã€‚| -| productName | string | 产å“ä¿¡æ¯ã€‚| -| version | string | 版本。| -| vendorId | number | 厂商ID。| -| productId | number | 产å“ID。| -| clazz | number | 设备类。| -| subClass | number | 设备å类。| -| protocol | number | 设备åè®®ç 。| -| configs | Array<[USBConfig](#usbconfig)> | 设备é…ç½®æ述符信æ¯ã€‚| - +**系统能力**:SystemCapability.USB.USBManager + +| å称 | å‚数类型 | 说明 | +| ---------------- | ------------------------------------ | ---------- | +| busNum | number | 总线地å€ã€‚ | +| devAddress | number | 设备地å€ã€‚ | +| serial | string | åºåˆ—å·ã€‚ | +| name | string | 设备åå—。 | +| manufacturerName | string | 产商信æ¯ã€‚ | +| productName | string | 产å“ä¿¡æ¯ã€‚ | +| version | string | 版本。 | +| vendorId | number | 厂商ID。 | +| productId | number | 产å“ID。 | +| clazz | number | 设备类。 | +| subClass | number | 设备å类。 | +| protocol | number | 设备åè®®ç 。 | +| configs | Array<[USBConfig](#usbconfig)> | 设备é…ç½®æ述符信æ¯ã€‚ | ## USBDevicePipe USB设备消æ¯ä¼ 输通é“,用于确定设备。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| busNum | number | 总线地å€ã€‚| -| devAddress | number | 设备地å€ã€‚| +**系统能力**:SystemCapability.USB.USBManager +| å称 | å‚数类型 | 说明 | +| ---------- | ------ | ----- | +| busNum | number | 总线地å€ã€‚ | +| devAddress | number | 设备地å€ã€‚ | ## USBControlParams æŽ§åˆ¶ä¼ è¾“å‚数。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 +**系统能力**:SystemCapability.USB.USBManager + +| å称 | å‚数类型 | 说明 | +| ------- | ----------------------------------------------- | ---------------- | +| request | number | 请求类型。 | +| target | [USBRequestTargetType](#usbrequesttargettype) | è¯·æ±‚ç›®æ ‡ç±»åž‹ã€‚ | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 请求控制类型。 | +| value | number | 请求å‚数。 | +| index | number | 请求å‚æ•°value对应的索引值。 | +| data | Uint8Array | 用于写入或读å–的缓冲区。 | + +## USBPort<sup>9+</sup> + +USB设备端å£ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.USB.USBManager + +| å称 | å‚数类型 | 说明 | +| -------------- | -------------------------------- | ----------------------------------- | +| id | number | USB端å£å”¯ä¸€æ ‡è¯†ã€‚ | +| supportedModes | [PortModeType](#portmodetype9) | USB端å£æ‰€æ”¯æŒçš„模å¼çš„æ•°å—组åˆæŽ©ç 。 | +| status | [USBPortStatus](#usbportstatus9) | USB端å£è§’色。 | + +## USBPortStatus<sup>9+</sup> + +USB设备端å£è§’色信æ¯ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -| å称 | å‚数类型 | 说明 | -| -------- | -------- | -------- | -| request | number | 请求类型。 | -| target | [USBRequestTargetType](#usbrequesttargettype) | è¯·æ±‚ç›®æ ‡ç±»åž‹ã€‚| -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | 请求控制类型。| -| value | number | 请求å‚数。| -| index | number | 请求å‚æ•°value对应的索引值。| -| data | Uint8Array | 用于写入或读å–的缓冲区。| +**系统能力**:SystemCapability.USB.USBManager +| å称 | å‚数类型 | 说明 | +| ---------------- | -------- | ---------------------- | +| currentMode | number | 当å‰çš„USB模å¼ã€‚ | +| currentPowerRole | number | 当å‰è®¾å¤‡å……电模å¼ã€‚ | +| currentDataRole | number | 当å‰è®¾å¤‡æ•°æ®ä¼ 输模å¼ã€‚ | ## USBRequestTargetType è¯·æ±‚ç›®æ ‡ç±»åž‹ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| USB_REQUEST_TARGET_DEVICE | 0 | 设备。| -| USB_REQUEST_TARGET_INTERFACE | 1 | 接å£ã€‚| -| USB_REQUEST_TARGET_ENDPOINT | 2 | 端点。| -| USB_REQUEST_TARGET_OTHER | 3 | 其他。| +**系统能力**:SystemCapability.USB.USBManager +| å称 | 值 | 说明 | +| ---------------------------- | ---- | ------ | +| USB_REQUEST_TARGET_DEVICE | 0 | 设备。 | +| USB_REQUEST_TARGET_INTERFACE | 1 | 接å£ã€‚ | +| USB_REQUEST_TARGET_ENDPOINT | 2 | 端点。 | +| USB_REQUEST_TARGET_OTHER | 3 | 其他。 | ## USBControlRequestType 控制请求类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 - -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| USB_REQUEST_TYPE_STANDARD | 0 | æ ‡å‡†ã€‚| -| USB_REQUEST_TYPE_CLASS | 1 | 类。| -| USB_REQUEST_TYPE_VENDOR | 2 | 厂商。| +**系统能力**:SystemCapability.USB.USBManager +| å称 | 值 | 说明 | +| ------------------------- | ---- | ------ | +| USB_REQUEST_TYPE_STANDARD | 0 | æ ‡å‡†ã€‚ | +| USB_REQUEST_TYPE_CLASS | 1 | 类。 | +| USB_REQUEST_TYPE_VENDOR | 2 | 厂商。 | ## USBRequestDirection 请求方å‘。 -**系统能力**:以下å„项对应的系统能力å‡ä¸º SystemCapability.USB.USBManager。 +**系统能力**:SystemCapability.USB.USBManager + +| å称 | 值 | 说明 | +| --------------------------- | ---- | ------------------------ | +| USB_REQUEST_DIR_TO_DEVICE | 0 | 写数æ®ï¼Œä¸»è®¾å¤‡å¾€ä»Žè®¾å¤‡ã€‚ | +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | 读数æ®ï¼Œä»Žè®¾å¤‡å¾€ä¸»è®¾å¤‡ã€‚ | + +## FunctionType<sup>9+</sup> + +USB设备侧功能。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.USB.USBManager + +| å称 | 值 | 说明 | +| ------------ | ---- | ---------- | +| NONE | 0 | 没有功能。 | +| ACM | 1 | acm功能。 | +| ECM | 2 | ecm功能。 | +| HDC | 4 | hdc功能。 | +| MTP | 8 | æš‚ä¸æ”¯æŒã€‚ | +| PTP | 16 | æš‚ä¸æ”¯æŒã€‚ | +| RNDIS | 32 | æš‚ä¸æ”¯æŒã€‚ | +| MIDI | 64 | æš‚ä¸æ”¯æŒã€‚ | +| AUDIO_SOURCE | 128 | æš‚ä¸æ”¯æŒã€‚ | +| NCM | 256 | æš‚ä¸æ”¯æŒã€‚ | + +## PortModeType<sup>9+</sup> + +USB端å£æ¨¡å¼ç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.USB.USBManager + +| å称 | 值 | 说明 | +| --------- | ---- | ---------------------------------------------------- | +| NONE | 0 | æ— ã€‚ | +| UFP | 1 | æ•°æ®ä¸Šè¡Œï¼Œéœ€è¦å¤–部供电。 | +| DFP | 2 | æ•°æ®ä¸‹è¡Œï¼Œå¯¹å¤–æ供电æºã€‚ | +| DRP | 3 | æ—¢å¯ä»¥åšDFP(Host),也å¯ä»¥åšUFP(Device),当å‰ä¸æ”¯æŒã€‚ | +| NUM_MODES | 4 | 当å‰ä¸æ”¯æŒã€‚ | + +## PowerRoleType<sup>9+</sup> + +电æºè§’色类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.USB.USBManager + +| å称 | 值 | 说明 | +| ------ | ---- | ---------- | +| NONE | 0 | æ— ã€‚ | +| SOURCE | 1 | 外部供电。 | +| SINK | 2 | 内部供电。 | + +## DataRoleType<sup>9+</sup> + +æ•°æ®è§’色类型。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力**:SystemCapability.USB.USBManager + +| å称 | 值 | 说明 | +| ------ | ---- | ------------ | +| NONE | 0 | æ— ã€‚ | +| HOST | 1 | 主设备角色。 | +| DEVICE | 2 | 从设备角色。 | -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| USB_REQUEST_DIR_TO_DEVICE | 0 | 写数æ®ï¼Œä¸»è®¾å¤‡å¾€ä»Žè®¾å¤‡ã€‚| -| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | 读数æ®ï¼Œä»Žè®¾å¤‡å¾€ä¸»è®¾å¤‡ã€‚| diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 3d100dcbe2556cd7b2aa0676d05877d1a9f0320e..284ed6b1fd24575280e07ec2c273d5fa2f58ea4e 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -60,7 +60,7 @@ getErrorString(errno: number): string **示例:** ```js - var errnum = 10; // 10:a system error number + var errnum = 10; // 10 : a system error number var result = util.getErrorString(errnum); console.log("result = " + result); ``` @@ -104,7 +104,7 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void promiseWrapper(original: (err: Object, value: Object) => void): Object > **说明:**<br/> -> 从API Version 9开始废弃,建议使用[util.promiseWrapper9+](#utilpromisewrapper9)替代。 +> 从API Version 9开始废弃,建议使用[util.promisify9+](#utilpromisify9)替代。 对异æ¥å‡½æ•°å¤„ç†å¹¶è¿”回一个promise的版本。 @@ -131,9 +131,9 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object }) ``` -## util.promiseWrapper<sup>9+</sup> +## util.promisify<sup>9+</sup> -promiseWrapper(original: (err: Object, value: Object) => void): Function +promisify(original: (err: Object, value: Object) => void): Function 对异æ¥å‡½æ•°å¤„ç†å¹¶è¿”回一个promise的函数。 @@ -151,16 +151,16 @@ promiseWrapper(original: (err: Object, value: Object) => void): Function **示例:** ```js - function aysnFun(str1, str2, callback) { - if (typeof str1 === 'string' && typeof str2 === 'string') { - callback(null, str1 + str2); - } else { - callback('type err'); - } + function aysnFun(str1, str2) { + if (typeof str1 === 'object' && typeof str2 === 'object') { + return str2 + } else { + return str1 + } } - let newPromiseObj = util.promiseWrapper(aysnFun); - newPromiseObj("Hello", 'World').then(res => { - console.log(res); + let newPromiseObj = util.promisify(aysnFun); + newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => { + console.log(res); }) ``` @@ -215,7 +215,7 @@ decode(input: Uint8Array, options?: { stream?: false }): string **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | -| input | Unit8Array | 是 | 符åˆæ ¼å¼éœ€è¦è§£ç 的数组。 | +| input | Uint8Array | 是 | 符åˆæ ¼å¼éœ€è¦è§£ç 的数组。 | | options | Object | å¦ | 解ç 相关选项å‚数。 | **表2** options @@ -1910,8 +1910,7 @@ isExternal(value: Object): boolean **示例:** ```js var that = new util.types(); - const data = util.createExternalType(); - var result = that.isExternal(data); + var result = that.isExternal(true); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md index 535c50272bda24adad3d53bf78f20179de52cb0e..1e80088a9051d63bc368eaf24e6acdb6c25d7a0a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -191,13 +191,13 @@ getVolumeByUuid(uuid: string): Promise<Volume> **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | ------ | ---- | ---- | + | -------- | ------ | ---- | ---- | | uuid | string | 是 | å·uuid | **返回值:** | 类型 | 说明 | - | ---------------------------------- | -------------------------- | + | ---------------------------------- | -------------------------- | | Promise<[Volume](#volume)> | 返回当å‰æ‰€æœ‰å¯èŽ·å¾—çš„å·ä¿¡æ¯ | **示例:** @@ -239,7 +239,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void ## volumemanager.getVolumeById -getVolumeById(id: string): Promise<Volume> +getVolumeById(volumeId: string): Promise<Volume> 异æ¥é€šè¿‡å·id获得å·ä¿¡æ¯ï¼Œä»¥promiseæ–¹å¼è¿”回。 @@ -251,7 +251,7 @@ getVolumeById(id: string): Promise<Volume> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ------ | ---- | ---- | - | id | string | 是 | å·id | + | volumeId | string | 是 | å·id | **返回值:** @@ -262,8 +262,8 @@ getVolumeById(id: string): Promise<Volume> **示例:** ```js - let id = ""; - volumemanager.getVolumeById(id).then(function(volume) { + let volumeId = ""; + volumemanager.getVolumeById(volumeId).then(function(volume) { console.info("getVolumeById successfully:" + JSON.stringify(volume)); }).catch(function(error){ console.info("getVolumeById failed with error:"+ error); @@ -272,7 +272,7 @@ getVolumeById(id: string): Promise<Volume> ## volumemanager.getVolumeById -getVolumeById(id: string, callback: AsyncCallback<Volume>): void +getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void 异æ¥é€šè¿‡å·id获得å·ä¿¡æ¯ï¼Œä»¥callbackæ–¹å¼è¿”回。 @@ -282,16 +282,16 @@ getVolumeById(id: string, callback: AsyncCallback<Volume>): void **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | ------------------------------------------------ | ---- | -------------------- | - | id | string | 是 | å·id | - | callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获å–å·ä¿¡æ¯ä¹‹åŽçš„回调 | + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | 是 | å·id | + | callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获å–å·ä¿¡æ¯ä¹‹åŽçš„回调 | **示例:** ```js - let id = ""; - volumemanager.getVolumeById(id, (error, volume) => { + let volumeId = ""; + volumemanager.getVolumeById(volumeId, (error, volume) => { // do something }); ``` @@ -361,7 +361,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& ## volumemanager.format -format(volId: string): Promise<void> +format(volumeId: string, fsType: string): Promise<void> 异æ¥å¯¹æŒ‡å®šå·è¿›è¡Œæ ¼å¼åŒ–,以promiseæ–¹å¼è¿”回。 @@ -373,19 +373,21 @@ format(volId: string): Promise<void> | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | ----------- | ------ | ---- | ---- | - | volId | string | 是 | å·id | + | volumeId | string | 是 | å·id | + | fsType | string | 是 | 文件系统类型 | **返回值:** - | 类型 | 说明 | - | --------------------- | ----------------------- | - | Promise<void> | 对指定å·è¿›è¡Œæ ¼å¼åŒ– | + | 类型 | 说明 | + | ---------------------- | ---------- | + | Promise<void> | 对指定å·è¿›è¡Œæ ¼å¼åŒ– | **示例:** ```js - let volId = ""; - volumemanager.format(volId).then(function() { + let volumeId = ""; + let fsType = ""; + volumemanager.format(volumeId, fsType).then(function() { console.info("format successfully"); }).catch(function(error){ console.info("format failed with error:"+ error); @@ -394,7 +396,7 @@ format(volId: string): Promise<void> ## volumemanager.format -format(volId: string, callback: AsyncCallback<void>): void +format(volumeId: string, fsType: string, callback: AsyncCallback<void>): void 异æ¥å¯¹æŒ‡å®šå·è¿›è¡Œæ ¼å¼åŒ–,以callbackæ–¹å¼è¿”回。 @@ -404,23 +406,25 @@ format(volId: string, callback: AsyncCallback<void>): void **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | --------------------------------------- | ---- | ---------------- | - | volId | string | 是 | å·id | - | callback | callback:AsyncCallback<void> | 是 | 对指定å·è¿›è¡Œæ ¼å¼åŒ– | + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | ------------------------- | ---- | ----------------------------- | + | volumeId | string | 是 | å·id | + | fsType | string | 是 | 文件系统类型 | + | callback | callback:AsyncCallback<void> | 是 | 对指定å·æ ¼å¼åŒ–åŽçš„回调 | **示例:** ```js - let volId = ""; - volumemanager.format(volId, (error, bool) => { + let volumeId = ""; + let fsType = ""; + volumemanager.format(volumeId, fsType, (error, bool) => { // do something }); ``` ## volumemanager.partition -partition(volId: string, fstype: string): Promise<void> +partition(diskId: string, type: number): Promise<void> 异æ¥å¯¹ç£ç›˜è¿›è¡Œåˆ†åŒºï¼Œä»¥promiseæ–¹å¼è¿”回。 @@ -431,9 +435,9 @@ partition(volId: string, fstype: string): Promise<void> **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | ----------- | ------ | ---- | ---- | - | volId | string | 是 | å·æ‰€å±žçš„ç£ç›˜id | - | fstype | string | 是 | 分区类型 | + | ----------- | ------ | ---- | ---- | + | diskId | string | 是 | å·æ‰€å±žçš„ç£ç›˜id | + | type | number | 是 | 分区类型 | **返回值:** @@ -444,9 +448,9 @@ partition(volId: string, fstype: string): Promise<void> **示例:** ```js - let volId = ""; - let fstype = ""; - volumemanager.partition(volId, fstype).then(function() { + let diskId = ""; + let type = 0; + volumemanager.partition(diskId, type).then(function() { console.info("partition successfully"); }).catch(function(error){ console.info("partition failed with error:"+ error); @@ -455,7 +459,7 @@ partition(volId: string, fstype: string): Promise<void> ## volumemanager.partition -partition(volId: string, fstype : string, callback: AsyncCallback<void>): void +partition(diskId: string, type: number, callback: AsyncCallback<void>): void 异æ¥å¯¹ç£ç›˜è¿›è¡Œåˆ†åŒºï¼Œä»¥callbackæ–¹å¼è¿”回。 @@ -467,16 +471,16 @@ partition(volId: string, fstype : string, callback: AsyncCallback<void>): | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | --------------------------------------- | ---- | ---------------- | - | volId | string | 是 | å·æ‰€å±žçš„ç£ç›˜id | - | fstype | string | 是 | 分区类型 | + | diskId | string | 是 | å·æ‰€å±žçš„ç£ç›˜id | + | type | number | 是 | 分区类型 | | callback | callback:AsyncCallback<void> | 是 | 对ç£ç›˜è¿›è¡Œåˆ†åŒº | **示例:** ```js - let volId = ""; - let fstype = ""; - volumemanager.partition(volId, fstype, (error, bool) => { + let diskId = ""; + let type = 0; + volumemanager.partition(diskId, type, (error, bool) => { // do something }); ``` @@ -491,6 +495,7 @@ partition(volId: string, fstype : string, callback: AsyncCallback<void>): | ----------- | ------- | -------------------- | | id | string | å·id | | uuid | string | å·uuid | +| diskId | string | å·æ‰€å±žçš„ç£ç›˜id | | description | string | å·ç›¸å…³æè¿° | | removable | boolean | 是å¦ä¸ºå¯ç§»åŠ¨å˜å‚¨è®¾å¤‡ | | state | number | 当å‰å·çŠ¶æ€ | diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index 4a8a90137257be89ec32a2651130e15a6d94df77..a8a2ef957fda55a51383f73127df8edb805ba0b7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -1,5 +1,7 @@ # å£çº¸ +å£çº¸ç®¡ç†æœåŠ¡æ˜¯OpenHarmonyä¸ç³»ç»ŸæœåŠ¡ï¼Œæ˜¯ä¸»é¢˜æ¡†æž¶çš„部分组æˆï¼Œä¸»è¦ä¸ºç³»ç»Ÿæä¾›å£çº¸ç®¡ç†æœåŠ¡èƒ½åŠ›ï¼Œæ”¯æŒç³»ç»Ÿæ˜¾ç¤ºã€è®¾ç½®ã€åˆ‡æ¢å£çº¸ç‰åŠŸèƒ½ã€‚ + >  **说明:** > 本模å—首批接å£ä»ŽAPI version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 @@ -389,7 +391,7 @@ reset(wallpaperType: WallpaperType): Promise<void> 移除指定类型的å£çº¸ï¼Œæ¢å¤ä¸ºé»˜è®¤æ˜¾ç¤ºçš„å£çº¸ã€‚ -**需è¦æƒé™ï¼š**ohos.permission.SET_WALLPAPER +**需è¦æƒé™**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -422,7 +424,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call 将指定资æºè®¾ç½®ä¸ºæŒ‡å®šç±»åž‹çš„å£çº¸ã€‚ -**需è¦æƒé™:** ohos.permission.SET_WALLPAPER +**需è¦æƒé™**:ohos.permission.SET_WALLPAPER **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -530,7 +532,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo 获å–指定类型的å£çº¸æ–‡ä»¶ã€‚ -**需è¦æƒé™**:ohos.permission.SET_WALLPAPERã€ohos.permission.READ_USER_STORAGE +**需è¦æƒé™**:ohos.permission.GET_WALLPAPER å’Œ ohos.permission.READ_USER_STORAGE **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -559,7 +561,7 @@ getFile(wallpaperType: WallpaperType): Promise<number> 获å–指定类型的å£çº¸æ–‡ä»¶ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.SET_WALLPAPERã€ohos.permission.READ_USER_STORAGE +**需è¦æƒé™**:ohos.permission.GET_WALLPAPER å’Œ ohos.permission.READ_USER_STORAGE **系统能力**: SystemCapability.MiscServices.Wallpaper @@ -592,10 +594,12 @@ getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.Pixel 获å–å£çº¸å›¾ç‰‡çš„åƒç´ 图。 -**需è¦æƒé™**:ohos.permission.GET_WALLPAPERã€ohos.permission.READ_USER_STORAGE +**需è¦æƒé™**:ohos.permission.GET_WALLPAPER å’Œ ohos.permission.READ_USER_STORAGE **系统能力**: SystemCapability.MiscServices.Wallpaper +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | @@ -619,10 +623,12 @@ getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap> 获å–å£çº¸å›¾ç‰‡çš„åƒç´ 图。 -**需è¦æƒé™**:ohos.permission.GET_WALLPAPERã€ohos.permission.READ_USER_STORAGE +**需è¦æƒé™**:ohos.permission.GET_WALLPAPER å’Œ ohos.permission.READ_USER_STORAGE **系统能力**: SystemCapability.MiscServices.Wallpaper +**系统API**:æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-wifi.md b/zh-cn/application-dev/reference/apis/js-apis-wifi.md index 3e164fdca9aaa01222194bb704814a804bfaf3ce..36ca5c551e9b39b493de56f16df955595ea9a687 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wifi.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wifi.md @@ -1,4 +1,5 @@ # WLAN +该模å—主è¦æä¾›WLAN基础功能ã€P2P(peer-to-peer)功能和WLAN消æ¯é€šçŸ¥çš„相应æœåŠ¡ï¼Œè®©åº”用å¯ä»¥é€šè¿‡WLAN和其他设备互è”互通。 >  **说明:** > 本模å—首批接å£ä»ŽAPI version 6开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 @@ -10,11 +11,45 @@ import wifi from '@ohos.wifi'; ``` +## wifi.enableWifi + +enableWifi(): boolean + +使能WLAN。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。| + + +## wifi.disableWifi + +disableWifi(): boolean + +去使能WLAN。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。| + + ## wifi.isWifiActive isWifiActive(): boolean -查询WLAN是å¦å·²æ¿€æ´»ã€‚ +查询WLAN是å¦å·²ä½¿èƒ½ã€‚ **需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO @@ -23,7 +58,7 @@ isWifiActive(): boolean **返回值:** | **类型** | **说明** | | -------- | -------- | - | boolean | true:已激活, false:未激活。 | + | boolean | true:已使能, false:未使能。 | ## wifi.scan @@ -32,7 +67,7 @@ scan(): boolean å¯åŠ¨WLAN扫æ。 -**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.STA @@ -46,32 +81,32 @@ scan(): boolean getScanInfos(): Promise<Array<WifiScanInfo>> -获å–扫æ结果,使用promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–扫æ结果,使用Promise异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO以åŠohos.permission.GET_WIFI_PEERS_MACå’Œohos.permission.LOCATIONæƒé™ä¸çš„至少一个。 +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ (ohos.permission.GET_WIFI_PEERS_MAC 或 ohos.permission.LOCATION) **系统能力:** SystemCapability.Communication.WiFi.STA **返回值:** | **类型** | **说明** | | -------- | -------- | - | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | 返回扫æ到的çƒç‚¹åˆ—表。 | + | Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise对象。返回扫æ到的çƒç‚¹åˆ—表。 | ## wifi.getScanInfos getScanInfos(callback: AsyncCallback<Array<WifiScanInfo>>): void -获å–扫æ结果,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–扫æ结果,使用callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO以åŠohos.permission.GET_WIFI_PEERS_MACå’Œohos.permission.LOCATIONæƒé™ä¸çš„至少一个。 +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ (ohos.permission.GET_WIFI_PEERS_MAC 或 ohos.permission.LOCATION) **系统能力:** SystemCapability.Communication.WiFi.STA **å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | 是 | 扫æ到的çƒç‚¹åˆ—表结果回调函数。 | + | callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | 是 | 回调函数。当æˆåŠŸæ—¶ï¼Œerr为0,data为扫æ到的çƒç‚¹ï¼›å¦åˆ™err为éž0值,data为空。 | **示例:** ```js @@ -120,18 +155,21 @@ getScanInfos(callback: AsyncCallback<Array<WifiScanInfo>>): void WLANçƒç‚¹ä¿¡æ¯ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.STA + | **å‚æ•°å** | **类型** | **读写属性** | **说明** | | -------- | -------- | -------- | -------- | | ssid | string | åªè¯» | çƒç‚¹çš„SSID,编ç æ ¼å¼ä¸ºUTF-8。 | | bssid | string | åªè¯» | çƒç‚¹çš„BSSID。 | | capabilities | string | åªè¯» | çƒç‚¹èƒ½åŠ›ã€‚ | -| securityType | [WifiSecurityType](#WifiSecurityType) | åªè¯» | WLANåŠ å¯†ç±»åž‹ã€‚ | +| securityType | [WifiSecurityType](#wifisecuritytype) | åªè¯» | WLANåŠ å¯†ç±»åž‹ã€‚ | | rssi | number | åªè¯» | çƒç‚¹çš„ä¿¡å·å¼ºåº¦(dBm)。 | | band | number | åªè¯» | WLAN接入点的频段。 | | frequency | number | åªè¯» | WLAN接入点的频率。 | | channelWidth | number | åªè¯» | WLAN接入点的带宽。 | -| centerFrequency0 | number | åªè¯» | ä¸å¿ƒé¢‘点。 | -| centerFrequency1 | number | åªè¯» | ä¸å¿ƒé¢‘点。 | +| centerFrequency0<sup>9+</sup> | number | åªè¯» | ä¸å¿ƒé¢‘点。 | +| centerFrequency1<sup>9+</sup> | number | åªè¯» | ä¸å¿ƒé¢‘点。 | +| infoElems<sup>9+</sup> | Array<[WifiInfoElem](#wifiinfoelem9)> | åªè¯» | ä¿¡æ¯å…ƒç´ 。 | | timestamp | number | åªè¯» | 时间戳。 | @@ -139,6 +177,8 @@ WLANçƒç‚¹ä¿¡æ¯ã€‚ è¡¨ç¤ºåŠ å¯†ç±»åž‹çš„æžšä¸¾ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.Core + | **å称** | **默认值** | **说明** | | -------- | -------- | -------- | | WIFI_SEC_TYPE_INVALID | 0 | æ— æ•ˆåŠ å¯†ç±»åž‹ã€‚ | @@ -146,48 +186,232 @@ WLANçƒç‚¹ä¿¡æ¯ã€‚ | WIFI_SEC_TYPE_WEP | 2 | Wired Equivalent Privacy (WEP)åŠ å¯†ç±»åž‹ã€‚ | | WIFI_SEC_TYPE_PSK | 3 | Pre-shared key (PSK)åŠ å¯†ç±»åž‹ã€‚ | | WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE)åŠ å¯†ç±»åž‹ã€‚ | +| WIFI_SEC_TYPE_EAP<sup>9+</sup> | 5 | EAPåŠ å¯†ç±»åž‹ã€‚ | +| WIFI_SEC_TYPE_EAP_SUITE_B<sup>9+</sup> | 6 | Suite-B 192ä½åŠ 密类型。 | +| WIFI_SEC_TYPE_OWE<sup>9+</sup> | 7 | æœºä¼šæ€§æ— çº¿åŠ å¯†ç±»åž‹ã€‚ | +| WIFI_SEC_TYPE_WAPI_CERT<sup>9+</sup> | 8 | WAPI-CertåŠ å¯†ç±»åž‹ã€‚ | +| WIFI_SEC_TYPE_WAPI_PSK<sup>9+</sup> | 9 | WAPI-PSKåŠ å¯†ç±»åž‹ã€‚ | -## wifi.addUntrustedConfig<sup>7+</sup> +## WifiInfoElem<sup>9+</sup> -addUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> +WLANçƒç‚¹ä¿¡æ¯ã€‚ -æ·»åŠ ä¸å¯ä¿¡ç½‘络é…置,使用promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.STA -**需è¦æƒé™ï¼š** - ohos.permission.SET_WIFI_INFO +| **å‚æ•°å** | **类型** | **读写属性** | **说明** | +| -------- | -------- | -------- | -------- | +| eid | number | åªè¯» | å…ƒç´ ID。 | +| content | Uint8Array | åªè¯» | å…ƒç´ å†…å®¹ã€‚ | -**系统能力:** - SystemCapability.Communication.WiFi.STA + +## WifiChannelWidth<sup>9+</sup> + +表示带宽类型的枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| **å称** | **默认值** | **说明** | +| -------- | -------- | -------- | +| WIDTH_20MHZ | 0 | 20MHZ。 | +| WIDTH_40MHZ | 1 | 40MHZ。 | +| WIDTH_80MHZ | 2 | 80MHZ。 | +| WIDTH_160MHZ | 3 | 160MHZ。 | +| WIDTH_80MHZ_PLUS | 4 | 80MHZ<sup>+</sup>。 | +| WIDTH_INVALID | 5 | æ— æ•ˆå€¼ | + + +## wifi.getScanInfosSync<sup>9+</sup> + +getScanInfosSync(): Array<[WifiScanInfo](#wifiscaninfo)> + +获å–扫æ结果,使用åŒæ¥æ–¹å¼è¿”回结果。 + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ (ohos.permission.GET_WIFI_PEERS_MAC 或 ohos.permission.LOCATION) + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | Array<[WifiScanInfo](#wifiscaninfo)> | 扫æ结果数组。 | + + +## wifi.addDeviceConfig + +addDeviceConfig(config: WifiDeviceConfig): Promise<number> + +æ·»åŠ ç½‘ç»œé…置,使用Promise异æ¥å›žè°ƒã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.SET_WIFI_CONFIG + +**系统能力:** SystemCapability.Communication.WiFi.STA **å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | 是 | WLANé…置信æ¯ã€‚ | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | **返回值:** | **类型** | **说明** | | -------- | -------- | - | Promise<boolean> | æ“作结果,ture: æˆåŠŸï¼Œ false: 失败。 | + | Promise<number> | Promiseå¯¹è±¡ã€‚è¿”å›žæ·»åŠ çš„ç½‘ç»œé…ç½®ID,如果值为-1è¡¨ç¤ºæ·»åŠ å¤±è´¥ã€‚ | ## WifiDeviceConfig WLANé…置信æ¯ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.STA + | **å‚æ•°å** | **类型** | **读写属性** | **说明** | | -------- | -------- | -------- | -------- | | ssid | string | åªè¯» | çƒç‚¹çš„SSID,编ç æ ¼å¼ä¸ºUTF-8。 | | bssid | string | åªè¯» | çƒç‚¹çš„BSSID。 | | preSharedKey | string | åªè¯» | çƒç‚¹çš„密钥。 | | isHiddenSsid | boolean | åªè¯» | 是å¦æ˜¯éšè—网络。 | -| securityType | [WifiSecurityType](#WifiSecurityType) | åªè¯» | åŠ å¯†ç±»åž‹ã€‚ | +| securityType | [WifiSecurityType](#wifisecuritytype) | åªè¯» | åŠ å¯†ç±»åž‹ã€‚ | +| creatorUid | number | åªè¯» | 创建用户的ID,仅系统应用å¯ç”¨ã€‚ | +| disableReason | number | åªè¯» | ç¦ç”¨åŽŸå› ,仅系统应用å¯ç”¨ã€‚ | +| netId | number | åªè¯» | 分é…的网络ID, 仅系统应用å¯ç”¨ã€‚ | +| randomMacType | number | åªè¯» | éšæœºMAC类型,仅系统应用å¯ç”¨ã€‚ | +| randomMacAddr | string | åªè¯» | éšæœºMAC地å€ï¼Œä»…系统应用å¯ç”¨ã€‚ | +| ipType | [IpType](#iptype7) | åªè¯» | IP地å€ç±»åž‹ï¼Œä»…系统应用å¯ç”¨ã€‚ | +| staticIp | [IpConfig](#ipconfig7) | åªè¯» | é™æ€IPé…置信æ¯ï¼Œä»…系统应用å¯ç”¨ã€‚ | +| eapConfig<sup>9+</sup> | [WifiEapConfig](#wifieapconfig9) | åªè¯» | å¯æ‰©å±•èº«ä»½éªŒè¯åè®®é…置,仅系统应用å¯ç”¨ã€‚ | + + +## IpType<sup>7+</sup> + +表示IP类型的枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| STATIC | 0 | é™æ€IP。 | +| DHCP | 1 | 通过DHCP获å–。 | +| UNKNOWN | 2 | 未指定。 | + + +## IpConfig<sup>7+</sup> + +IPé…置信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| **å‚æ•°å** | **类型** | **读写属性** | **说明** | +| -------- | -------- | -------- | -------- | +| ipAddress | number | åªè¯» | IP地å€ã€‚ | +| gateway | number | åªè¯» | 网关。 | +| dnsServers | number[] | åªè¯» | DNSæœåŠ¡å™¨ã€‚ | +| domains | Array<string> | åªè¯» | 域信æ¯ã€‚ | + + +## WifiEapConfig<sup>9+</sup> + +å¯æ‰©å±•èº«ä»½éªŒè¯åè®®é…置信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| **å‚æ•°å** | **类型** | **读写属性** | **说明** | +| -------- | -------- | -------- | -------- | +| eapMethod | [EapMethod](#eapmethod9) | åªè¯» | EAP认è¯æ–¹å¼ã€‚ | +| phase2Method | [Phase2Method](#phase2method9) | åªè¯» | 第二阶段认è¯æ–¹å¼ã€‚ | +| identity | string | åªè¯» | 身份信æ¯ã€‚ | +| anonymousIdentity | string | åªè¯» | 匿å身份。 | +| password | string | åªè¯» | 密ç 。 | +| caCertAliases | string | åªè¯» | CA è¯ä¹¦åˆ«å。 | +| caPath | string | åªè¯» | CA è¯ä¹¦è·¯å¾„。 | +| clientCertAliases | string | åªè¯» | 客户端è¯ä¹¦åˆ«å。 | +| altSubjectMatch | string | åªè¯» | 替代主题匹é…。 | +| domainSuffixMatch | string | åªè¯» | 域åŽç¼€åŒ¹é…。 | +| realm | string | åªè¯» | 通行è¯å‡è¯çš„领域。 | +| plmn | string | åªè¯» | 公共陆地移动网的直通å‡è¯æ供商。 | +| eapSubId | number | åªè¯» | SIMå¡çš„åID。 | + + +## EapMethod<sup>9+</sup> + +表示EAP认è¯æ–¹å¼çš„枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| EAP_NONE | 0 | ä¸æŒ‡å®šã€‚ | +| EAP_PEAP | 1 | PEAP类型。 | +| EAP_TLS | 2 | TLS类型。 | +| EAP_TTLS | 3 | TTLS类型。 | +| EAP_PWD | 4 | PWD类型。 | +| EAP_SIM | 5 | SIM类型。 | +| EAP_AKA | 6 | AKA类型。 | +| EAP_AKA_PRIME | 7 | AKA Prime类型。 | +| EAP_UNAUTH_TLS | 8 | UNAUTH TLS类型。 | + + +## Phase2Method<sup>9+</sup> + +表示第二阶段认è¯æ–¹å¼çš„枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| PHASE2_NONE | 0 | ä¸æŒ‡å®šã€‚ | +| PHASE2_PAP | 1 | PAP类型。 | +| PHASE2_MSCHAP | 2 | MSCHAP类型。 | +| PHASE2_MSCHAPV2 | 3 | MSCHAPV2类型。 | +| PHASE2_GTC | 4 | GTC类型。 | +| PHASE2_SIM | 5 | SIM类型。 | +| PHASE2_AKA | 6 | AKA类型。 | +| PHASE2_AKA_PRIME | 7 | AKA Prime类型。 | + + +## wifi.addDeviceConfig + +addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>): void + +æ·»åŠ ç½‘ç»œé…置,使用callback异æ¥å›žè°ƒã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.SET_WIFI_CONFIG + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + | callback | AsyncCallback<number> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,dataä¸ºæ·»åŠ çš„ç½‘ç»œé…ç½®ID,如果data值为-1ï¼Œè¡¨ç¤ºæ·»åŠ å¤±è´¥ã€‚å½“error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | + + +## wifi.addUntrustedConfig<sup>7+</sup> + +addUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> + +æ·»åŠ ä¸å¯ä¿¡ç½‘络é…置,使用Promise异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | Promise<boolean> | Promise对象。表示æ“作结果,true: æˆåŠŸï¼Œ false: 失败。 | ## wifi.addUntrustedConfig<sup>7+</sup> addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -æ·»åŠ ä¸å¯ä¿¡ç½‘络é…置,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +æ·»åŠ ä¸å¯ä¿¡ç½‘络é…置,使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO @@ -196,15 +420,15 @@ addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean& **å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | 是 | WLANé…置信æ¯ã€‚ | - | callback | AsyncCallback<boolean> | 是 | æ“作结果,ture: æˆåŠŸï¼Œ false: 失败。 | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + | callback | AsyncCallback<boolean> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示æ“作结果,true: æˆåŠŸï¼Œ false: 失败。如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | ## wifi.removeUntrustedConfig<sup>7+</sup> removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> -移除ä¸å¯ä¿¡ç½‘络é…置,使用promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +移除ä¸å¯ä¿¡ç½‘络é…置,使用Promise异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO @@ -213,19 +437,19 @@ removeUntrustedConfig(config: WifiDeviceConfig): Promise<boolean> **å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | 是 | WLANé…置信æ¯ã€‚ | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | **返回值:** | **类型** | **说明** | | -------- | -------- | - | Promise<boolean> | æ“作结果,ture: æˆåŠŸï¼Œ false: 失败。 | + | Promise<boolean> | Promise对象。表示æ“作结果,true: æˆåŠŸï¼Œ false: 失败。 | ## wifi.removeUntrustedConfig<sup>7+</sup> removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -移除ä¸å¯ä¿¡ç½‘络é…置,使用callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +移除ä¸å¯ä¿¡ç½‘络é…置,使用callback异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO @@ -234,364 +458,892 @@ removeUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback<boole **å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiDeviceConfig](#WifiDeviceConfig) | 是 | WLANé…置信æ¯ã€‚ | - | callback | AsyncCallback<boolean> | 是 | æ“作结果,ture: æˆåŠŸï¼Œ false: 失败。 | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + | callback | AsyncCallback<boolean> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示æ“作结果,true: æˆåŠŸï¼Œ false: 失败。如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | -## wifi.getSignalLevel +## wifi.addCandidateConfig<sup>9+</sup> -getSignalLevel(rssi: number, band: number): number +addCandidateConfig(config: WifiDeviceConfig): Promise<number> -查询WLANä¿¡å·å¼ºåº¦ã€‚ +æ·»åŠ å€™é€‰ç½‘ç»œé…置,使用Promise异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO **系统能力:** SystemCapability.Communication.WiFi.STA -**å‚数:**: +**å‚数:** | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | rssi | number | 是 | çƒç‚¹çš„ä¿¡å·å¼ºåº¦(dBm)。 | - | band | number | 是 | WLAN接入点的频段。 | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | **返回值:** | **类型** | **说明** | | -------- | -------- | - | number | ä¿¡å·å¼ºåº¦ï¼Œå–值范围为[0, 4]。 | + | Promise<number> | Promise对象。表示网络é…ç½®ID。 | -## wifi.getLinkedInfo +## wifi.addCandidateConfig<sup>9+</sup> -getLinkedInfo(): Promise<WifiLinkedInfo> +addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>): void -获å–WLAN连接信æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +æ·»åŠ ä¸å¯ä¿¡ç½‘络é…置,使用callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + | callback | AsyncCallback<number> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,dataä¸ºæ·»åŠ çš„ç½‘ç»œé…ç½®ID,如果data值为-1ï¼Œè¡¨ç¤ºæ·»åŠ å¤±è´¥ã€‚å¦‚æžœæ“作出现错误,err为éž0值。 | + + +## wifi.removeCandidateConfig<sup>9+</sup> + +removeCandidateConfig(config: WifiDeviceConfig): Promise<boolean> + +移除候选候选网络é…置,使用Promise异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO **系统能力:** SystemCapability.Communication.WiFi.STA +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + **返回值:** - | 类型 | 说明 | + | **类型** | **说明** | | -------- | -------- | - | Promise<[WifiLinkedInfo](#WifiLinkedInfo)> | WLAN连接的相关信æ¯ã€‚ | + | Promise<void> | Promise对象。返回æ“作结果,true: æˆåŠŸï¼Œ false | -## wifi.getLinkedInfo +## wifi.removeCandidateConfig<sup>9+</sup> -getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void +removeCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback<boolean>): void -获å–WLAN连接信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +移除候选网络é…置,使用callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO **系统能力:** SystemCapability.Communication.WiFi.STA **å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiLinkedInfo](#WifiLinkedInfo)> | 是 | WLAN连接信æ¯ç»“果回调函数。 | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + | callback | AsyncCallback<void> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示æ“作结果,true: æˆåŠŸï¼Œ false: 失败。如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | -**示例:** - ```js - import wifi from '@ohos.wifi'; - - wifi.getLinkedInfo((err, data) => { - if (err) { - console.error("get linked info error"); - return; - } - console.info("get wifi linked info: " + JSON.stringify(data)); - }); - - wifi.getLinkedInfo().then(data => { - console.info("get wifi linked info: " + JSON.stringify(data)); - }).catch(error => { - console.info("get linked info error"); - }); - ``` +## wifi.getCandidateConfigs<sup>9+</sup> -## WifiLinkedInfo +getCandidateConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)> -æä¾›WLAN连接的相关信æ¯ã€‚ +获å–候选网络é…置。 -| å‚æ•°å | 类型 | 读写属性 | 说明 | -| -------- | -------- | -------- | -------- | -| ssid | string | åªè¯» | çƒç‚¹çš„SSID,编ç æ ¼å¼ä¸ºUTF-8。 | -| bssid | string | åªè¯» | çƒç‚¹çš„BSSID。 | -| rssi | number | åªè¯» | çƒç‚¹çš„ä¿¡å·å¼ºåº¦(dBm)。 | -| band | number | åªè¯» | WLAN接入点的频段。 | -| linkSpeed | number | åªè¯» | WLAN接入点的速度。 | -| frequency | number | åªè¯» | WLAN接入点的频率。 | -| isHidden | boolean | åªè¯» | WLAN接入点是å¦æ˜¯éšè—网络。 | -| isRestricted | boolean | åªè¯» | WLAN接入点是å¦é™åˆ¶æ•°æ®é‡ã€‚ | -| macAddress | string | åªè¯» | 设备的MAC地å€ã€‚ | -| ipAddress | number | åªè¯» | WLAN连接的IP地å€ã€‚ | -| connState | [ConnState](#ConnState) | åªè¯» | WLAN连接状æ€ã€‚ | +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | Array<[WifiDeviceConfig](#wifideviceconfig)> | 候选网络é…置数组。 | + + +## wifi.connectToCandidateConfig<sup>9+</sup> + +connectToCandidateConfig(networkId: number): boolean + +连接到候选网络。 + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | networkId | number | 是 | 候选网络é…置的ID。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.connectToNetwork + +connectToNetwork(networkId: number): boolean + +连接到指定网络。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | networkId | number | 是 | 待连接的网络é…ç½®ID。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.connectToDevice + +connectToDevice(config: WifiDeviceConfig): boolean + +连接到指定网络。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** + ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.SET_WIFI_CONFIG å’Œ ohos.permissio.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** + SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.disconnect + +disconnect(): boolean + +连接到指定网络。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** + ohos.permission.SET_WIFI_INFO å’Œ ohos.permissio.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** + SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.getSignalLevel + +getSignalLevel(rssi: number, band: number): number + +查询WLANä¿¡å·å¼ºåº¦ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:**: + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | rssi | number | 是 | çƒç‚¹çš„ä¿¡å·å¼ºåº¦(dBm)。 | + | band | number | 是 | WLAN接入点的频段。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | number | ä¿¡å·å¼ºåº¦ï¼Œå–值范围为[0, 4]。 | + + +## wifi.getLinkedInfo + +getLinkedInfo(): Promise<WifiLinkedInfo> + +获å–WLAN连接信æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise对象。表示WLAN连接信æ¯ã€‚ | + + +## wifi.getLinkedInfo + +getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void + +获å–WLAN连接信æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[WifiLinkedInfo](#wifilinkedinfo)> | 是 | 回调函数。当获å–æˆåŠŸæ—¶ï¼Œerr为0,data表示WLAN连接信æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | + +**示例:** + ```js + import wifi from '@ohos.wifi'; + + wifi.getLinkedInfo((err, data) => { + if (err) { + console.error("get linked info error"); + return; + } + console.info("get wifi linked info: " + JSON.stringify(data)); + }); + + wifi.getLinkedInfo().then(data => { + console.info("get wifi linked info: " + JSON.stringify(data)); + }).catch(error => { + console.info("get linked info error"); + }); + ``` + + +## WifiLinkedInfo + +æä¾›WLAN连接的相关信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å‚æ•°å | 类型 | 读写属性 | 说明 | +| -------- | -------- | -------- | -------- | +| ssid | string | åªè¯» | çƒç‚¹çš„SSID,编ç æ ¼å¼ä¸ºUTF-8。 | +| bssid | string | åªè¯» | çƒç‚¹çš„BSSID。 | +| networkId | number | åªè¯» | 网络é…ç½®ID, 仅系统应用å¯ç”¨ã€‚ | +| rssi | number | åªè¯» | çƒç‚¹çš„ä¿¡å·å¼ºåº¦(dBm)。 | +| band | number | åªè¯» | WLAN接入点的频段。 | +| linkSpeed | number | åªè¯» | WLAN接入点的速度。 | +| frequency | number | åªè¯» | WLAN接入点的频率。 | +| isHidden | boolean | åªè¯» | WLAN接入点是å¦æ˜¯éšè—网络。 | +| isRestricted | boolean | åªè¯» | WLAN接入点是å¦é™åˆ¶æ•°æ®é‡ã€‚ | +| chload | number | åªè¯» | 连接负载,值越大表示负载约高,仅系统应用å¯ç”¨ã€‚ | +| snr | number | åªè¯» | 信噪比,仅系统应用å¯ç”¨ã€‚ | +| macType<sup>9+</sup> | number | åªè¯» | MAC地å€ç±»åž‹ã€‚ | +| macAddress | string | åªè¯» | 设备的MAC地å€ã€‚ | +| ipAddress | number | åªè¯» | WLAN连接的IP地å€ã€‚ | +| suppState | [SuppState](#suppstate) | åªè¯» | 请求状æ€ï¼Œä»…系统应用å¯ç”¨ã€‚| +| connState | [ConnState](#connstate) | åªè¯» | WLAN连接状æ€ã€‚ | + + +## ConnState + +表示WLAN连接状æ€çš„枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| SCANNING | 0 | 设备æ£åœ¨æœç´¢å¯ç”¨çš„AP。 | +| CONNECTING | 1 | æ£åœ¨å»ºç«‹WLAN连接。 | +| AUTHENTICATING | 2 | WLAN连接æ£åœ¨è®¤è¯ä¸ã€‚ | +| OBTAINING_IPADDR | 3 | æ£åœ¨èŽ·å–WLAN连接的IP地å€ã€‚ | +| CONNECTED | 4 | WLAN连接已建立。 | +| DISCONNECTING | 5 | WLAN连接æ£åœ¨æ–开。 | +| DISCONNECTED | 6 | WLAN连接已æ–开。 | +| UNKNOWN | 7 | WLAN连接建立失败。 | + + +## SuppState + +表示请求状æ€çš„枚举。 + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| å称 | 默认值 | 说明 | +| -------- | -------- | -------- | +| DISCONNECTED | 0 | å·²æ–开。 | +| INTERFACE_DISABLED | 1 | 接å£ç¦ç”¨ã€‚ | +| INACTIVE | 2 | 未激活。 | +| SCANNING | 3 | 扫æä¸ã€‚ | +| AUTHENTICATING | 4 | 认è¯ä¸ã€‚ | +| ASSOCIATING | 5 | å…³è”ä¸ã€‚ | +| ASSOCIATED | 6 | 已关è”。 | +| FOUR_WAY_HANDSHAKE | 7 | 四次æ¡æ‰‹ã€‚ | +| GROUP_HANDSHAKE | 8 | 组æ¡æ‰‹ã€‚ | +| COMPLETED | 9 | 所有认è¯å·²å®Œæˆã€‚ | +| UNINITIALIZED | 10 | 连接建立失败。 | +| INVALID | 11 | æ— æ•ˆå€¼ã€‚ | + + +## wifi.isConnected<sup>7+</sup> + +isConnected(): boolean + +查询WLAN是å¦å·²è¿žæŽ¥ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:已连接, false:未连接。 | + + +## wifi.getSupportedFeatures<sup>7+</sup> + +getSupportedFeatures(): number + +查询设备支æŒçš„特性。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.Core + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | number | 支æŒçš„特性值。 | + +**特性ID值枚举:** + +| 枚举值 | 说明 | +| -------- | -------- | +| 0x0001 | 基础结构模å¼ç‰¹æ€§ã€‚ | +| 0x0002 | 5 GHz带宽特性。 | +| 0x0004 | GAS/ANQP特性。 | +| 0x0008 | Wifi-Direct特性。 | +| 0x0010 | Soft AP特性。 | +| 0x0040 | Wi-Fi AWare组网特性。 | +| 0x8000 | AP STAå…±å˜ç‰¹æ€§ã€‚ | +| 0x8000000 | WPA3-Personal SAE特性。 | +| 0x10000000 | WPA3-Enterprise Suite-B | +| 0x20000000 | 增强开放特性。 | + + +## wifi.isFeatureSupported<sup>7+</sup> + +isFeatureSupported(featureId: number): boolean + +判æ–设备是å¦æ”¯æŒç›¸å…³WLAN特性。 + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.Core + +**å‚数:** + + | **å‚æ•°å** | **类型** | å¿…å¡« | **说明** | + | -------- | -------- | -------- | -------- | + | featureId | number | 是 | 特性ID值。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:支æŒï¼Œ false:ä¸æ”¯æŒã€‚ | + + +## wifi.getDeviceMacAddress<sup>7+</sup> + +getDeviceMacAddress(): string[] + +获å–设备的MAC地å€ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_LOCAL_MAC å’Œ ohos.permission.GET_WIFI_INFO,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | string[] | MAC地å€ã€‚ | + + +## wifi.getIpInfo<sup>7+</sup> + +getIpInfo(): IpInfo + +获å–IPä¿¡æ¯ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | [IpInfo](#ipinfo7) | IPä¿¡æ¯ã€‚ | + + +## IpInfo<sup>7+</sup> + +IPä¿¡æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +| **å‚æ•°å** | **类型** | **读写属性** | **说明** | +| -------- | -------- | -------- | -------- | +| ipAddress | number | åªè¯» | IP地å€ã€‚ | +| gateway | number | åªè¯» | 网关。 | +| netmask | number | åªè¯» | 掩ç 。 | +| primaryDns | number | åªè¯» | 主DNSæœåŠ¡å™¨IP地å€ã€‚ | +| secondDns | number | åªè¯» | 备DNSæœåŠ¡å™¨IP地å€ã€‚ | +| serverIp | number | åªè¯» | DHCPæœåŠ¡ç«¯IP地å€ã€‚ | +| leaseDuration | number | åªè¯» | IP地å€ç§Ÿç”¨æ—¶é•¿ã€‚ | + + +## wifi.getCountryCode<sup>7+</sup> + +getCountryCode(): string + +获å–国家ç ä¿¡æ¯ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.Core + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | string | 国家ç 。 | + + +## wifi.reassociate<sup>7+</sup> + +reassociate(): boolean + +é‡æ–°å…³è”网络。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.reconnect<sup>7+</sup> + +reconnect(): boolean + +é‡æ–°è¿žæŽ¥ç½‘络。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.getDeviceConfigs<sup>7+</sup> + +getDeviceConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)> + +获å–网络é…置。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION å’Œ ohos.permission.GET_WIFI_CONFIG + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | Array<[WifiDeviceConfig](#wifideviceconfig)> | 网络é…置信æ¯çš„数组。 | + + +## wifi.updateNetwork<sup>7+</sup> + +updateNetwork(config: WifiDeviceConfig): boolean + +更新网络é…置。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.SET_WIFI_CONFIG + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [WifiDeviceConfig](#wifideviceconfig) | 是 | WLANé…置信æ¯ã€‚ | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.disableNetwork<sup>7+</sup> + +disableNetwork(netId: number): boolean + +去使能网络é…置。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | netId | number | 是 | 网络é…ç½®ID。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.removeAllNetwork<sup>7+</sup> + +removeAllNetwork(): boolean + +移除所有网络é…置。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.removeDevice<sup>7+</sup> + +removeDevice(id: number): boolean + +移除指定的网络é…置。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.STA + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | id | number | 是 | 网络é…ç½®ID。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + +## wifi.enableHotspot<sup>7+</sup> + +enableHotspot(): boolean + +使能çƒç‚¹ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.AP.Core + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。| -## ConnState +## wifi.disableHotspot<sup>7+</sup> -表示WLAN连接状æ€çš„枚举。 +disableHotspot(): boolean -| å称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| SCANNING | 0 | 设备æ£åœ¨æœç´¢å¯ç”¨çš„AP。 | -| CONNECTING | 1 | æ£åœ¨å»ºç«‹WLAN连接。 | -| AUTHENTICATING | 2 | WLAN连接æ£åœ¨è®¤è¯ä¸ã€‚ | -| OBTAINING_IPADDR | 3 | æ£åœ¨èŽ·å–WLAN连接的IP地å€ã€‚ | -| CONNECTED | 4 | WLAN连接已建立。 | -| DISCONNECTING | 5 | WLAN连接æ£åœ¨æ–开。 | -| DISCONNECTED | 6 | WLAN连接已æ–开。 | -| UNKNOWN | 7 | WLAN连接建立失败。 | +去使能çƒç‚¹ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用å¯ç”¨ã€‚ -## wifi.isConnected<sup>7+</sup> +**系统能力:** SystemCapability.Communication.WiFi.AP.Core -isConnected(): boolean +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。| -查询WLAN是å¦å·²è¿žæŽ¥ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +## wifi.isHotspotDualBandSupported<sup>7+</sup> -**系统能力:** SystemCapability.Communication.WiFi.STA +isHotspotDualBandSupported(): boolean + +çƒç‚¹æ˜¯å¦æ”¯æŒåŒé¢‘。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.AP.Core **返回值:** | **类型** | **说明** | | -------- | -------- | - | boolean | true:已连接, false:未连接。 | + | boolean | true:支æŒï¼Œ false:ä¸æ”¯æŒã€‚| -## wifi.isFeatureSupported<sup>7+</sup> +## wifi.isHotspotActive<sup>7+</sup> -isFeatureSupported(featureId: number): boolean +isHotspotActive(): boolean -判æ–设备是å¦æ”¯æŒç›¸å…³WLAN特性。 +çƒç‚¹æ˜¯å¦å·²ä½¿èƒ½ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO -**系统能力:** SystemCapability.Communication.WiFi.Core - -**å‚数:** - - | **å‚æ•°å** | **类型** | å¿…å¡« | **说明** | - | -------- | -------- | -------- | -------- | - | featureId | number | 是 | 特性ID值。 | +**系统能力:** SystemCapability.Communication.WiFi.AP.Core **返回值:** | **类型** | **说明** | | -------- | -------- | - | boolean | true:支æŒï¼Œ false:ä¸æ”¯æŒã€‚ | - -**特性ID值枚举:** + | boolean | true:已使能, false:未使能。| -| 枚举值 | 说明 | -| -------- | -------- | -| 0x0001 | 基础结构模å¼ç‰¹æ€§ã€‚ | -| 0x0002 | 5 GHz带宽特性。 | -| 0x0004 | GAS/ANQP特性。 | -| 0x0008 | Wifi-Direct特性。 | -| 0x0010 | Soft AP特性。 | -| 0x0040 | Wi-Fi AWare组网特性。 | -| 0x8000 | AP STAå…±å˜ç‰¹æ€§ã€‚ | -| 0x8000000 | WPA3-Personal SAE特性。 | -| 0x10000000 | WPA3-Enterprise Suite-B | -| 0x20000000 | 增强开放特性。 | +## wifi.setHotspotConfig<sup>7+</sup> -## wifi.getIpInfo<sup>7+</sup> +setHotspotConfig(config: HotspotConfig): boolean -getIpInfo(): IpInfo +设置çƒç‚¹é…置信æ¯ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -获å–IPä¿¡æ¯ã€‚ +**需è¦æƒé™ï¼š** ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.GET_WIFI_CONFIG -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**系统能力:** SystemCapability.Communication.WiFi.AP.Core -**系统能力:** SystemCapability.Communication.WiFi.STA +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | config | [HotspotConfig](#hotspotconfig7) | 是 | çƒç‚¹é…置信æ¯ã€‚ | **返回值:** | **类型** | **说明** | | -------- | -------- | - | [IpInfo](#IpInfo) | IPä¿¡æ¯ã€‚ | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | -## IpInfo<sup>7+</sup> +## HotspotConfig<sup>7+</sup> -IPä¿¡æ¯ã€‚ +çƒç‚¹é…置信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.AP.Core | **å‚æ•°å** | **类型** | **读写属性** | **说明** | | -------- | -------- | -------- | -------- | -| ipAddress | number | åªè¯» | IP地å€ã€‚ | -| gateway | number | åªè¯» | 网关。 | -| netmask | number | åªè¯» | 掩ç 。 | -| primaryDns | number | åªè¯» | 主DNSæœåŠ¡å™¨IP地å€ã€‚ | -| secondDns | number | åªè¯» | 备DNSæœåŠ¡å™¨IP地å€ã€‚ | -| serverIp | number | åªè¯» | DHCPæœåŠ¡ç«¯IP地å€ã€‚ | -| leaseDuration | number | åªè¯» | IP地å€ç§Ÿç”¨æ—¶é•¿ã€‚ | +| ssid | string | åªè¯» | çƒç‚¹çš„SSID,编ç æ ¼å¼ä¸ºUTF-8。 | +| securityType | [WifiSecurityType](#wifisecuritytype) | åªè¯» | åŠ å¯†ç±»åž‹ã€‚ | +| band | number | åªè¯» | çƒç‚¹çš„带宽。1: 2.4G, 2: 5G, 3: åŒæ¨¡é¢‘段 | +| preSharedKey | string | åªè¯» | çƒç‚¹çš„密钥。 | +| maxConn | number | åªè¯» | 最大设备连接数。 | -## wifi.getCountryCode<sup>7+</sup> +## wifi.getHotspotConfig<sup>7+</sup> -getCountryCode(): string +getHotspotConfig(): HotspotConfig -获å–国家ç ä¿¡æ¯ã€‚ +获å–çƒç‚¹é…置信æ¯ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.GET_WIFI_CONFIG -**系统能力:** SystemCapability.Communication.WiFi.Core +**系统能力:** SystemCapability.Communication.WiFi.AP.Core **返回值:** | **类型** | **说明** | | -------- | -------- | - | string | 国家ç 。 | + | [HotspotConfig](#hotspotconfig7) | çƒç‚¹çš„é…置信æ¯ã€‚ | -## wifi.getP2pLinkedInfo<sup>8+</sup> +## wifi.getStations<sup>7+</sup> -getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo> +getStations(): Array<[StationInfo](#stationinfo7)> -获å–P2P连接信æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–连接的设备。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION å’Œ ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用å¯ç”¨ã€‚ -**系统能力:** SystemCapability.Communication.WiFi.P2P +**系统能力:** SystemCapability.Communication.WiFi.AP.Core **返回值:** - | 类型 | 说明 | + | **类型** | **说明** | | -------- | -------- | - | Promise<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | P2P连接信æ¯ã€‚ | + | Array<[StationInfo](#stationinfo7)> | 连接的设备数组。 | + + +## StationInfo<sup>7+</sup> + +接入的设备信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.AP.Core + +| **å‚æ•°å** | **类型** | **读写属性** | **说明** | +| -------- | -------- | -------- | -------- | +| name | string | åªè¯» | 设备å称。 | +| macAddress | string | åªè¯» | MAC地å€ã€‚ | +| ipAddress | string | åªè¯» | IP地å€ã€‚ | ## wifi.getP2pLinkedInfo<sup>8+</sup> -getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void +getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo> -获å–P2P连接信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P连接信æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ **需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO **系统能力:** SystemCapability.Communication.WiFi.P2P -**å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | 是 | P2P连接信æ¯ç»“果回调函数。 | +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Promise对象。表示P2P连接信æ¯ã€‚ | + ## WifiP2pLinkedInfo<sup>8+</sup> æä¾›WLAN连接的相关信æ¯ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å‚æ•°å | 类型 | 读写属性 | 说明 | | -------- | -------- | -------- | -------- | -| connectState | [P2pConnectState](#P2pConnectState) | åªè¯» | P2P连接状æ€ã€‚ | -| isGroupOwner | boolean | åªè¯» | 是å¦æ˜¯ç¾¤ç»„。 | -| groupOwnerAddr | string | åªè¯» | 群组MAC地å€ã€‚ | +| connectState | [P2pConnectState](#p2pconnectstate8) | åªè¯» | P2P连接状æ€ã€‚ | +| isGroupOwner | boolean | åªè¯» | 是å¦æ˜¯ç¾¤ä¸»ã€‚ | +| groupOwnerAddr | string | åªè¯» | 群组MAC地å€ã€‚ ## P2pConnectState<sup>8+</sup> 表示P2P连接状æ€çš„枚举。 +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | DISCONNECTED | 0 | æ–开状æ€ã€‚ | | CONNECTED | 1 | 连接状æ€ã€‚ | +## wifi.getP2pLinkedInfo<sup>8+</sup> + +getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void + +获å–P2P连接信æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示P2P连接信æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | + + ## wifi.getCurrentGroup<sup>8+</sup> getCurrentGroup(): Promise<WifiP2pGroupInfo> -获å–P2P当å‰ç»„ä¿¡æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P当å‰ç»„ä¿¡æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P **返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | 当å‰ç»„ä¿¡æ¯ã€‚ | + | Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Promise对象。表示当å‰ç»„ä¿¡æ¯ã€‚ | ## wifi.getCurrentGroup<sup>8+</sup> getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void -获å–P2P当å‰ç»„ä¿¡æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P当å‰ç»„ä¿¡æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> | 是 | 当å‰ç»„ä¿¡æ¯çš„回调函数。 | + | callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示当å‰ç»„ä¿¡æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | -## wifi.getP2pGroups<sup>9+</sup> -getP2pGroups(): Promise<Array<WifiP2pGroupInfo> +## wifi.getP2pPeerDevices<sup>8+</sup> + +getP2pPeerDevices(): Promise<WifiP2pDevice[]> -获å–P2P当å‰åˆ›å»ºçš„所有群组信æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P对端设备列表信æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P **返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise< Array<[WifiP2pGroupInfo](#WifiP2pGroupInfo)> > | 当å‰åˆ›å»ºçš„所有群组信æ¯ã€‚ | + | Promise<[WifiP2pDevice[]](#wifip2pdevice8)> | Promise对象。表示对端设备列表信æ¯ã€‚ | -## wifi.getP2pGroups<sup>9+</sup> -getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>): void +## wifi.getP2pPeerDevices<sup>8+</sup> + +getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void -获å–P2P当å‰åˆ›å»ºçš„所有群组信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P对端设备列表信æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback< Array<[WifiP2pGroupInfo](#WifiP2pGroupInfo)>> | 是 | 当å‰åˆ›å»ºçš„所有群组信æ¯çš„回调函数。 | - -## WifiP2pGroupInfo<sup>8+</sup> - -表示P2P群组相关信æ¯ã€‚ + | callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice8)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示对端设备列表信æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | -| å‚æ•°å | 类型 | 读写属性 | 说明 | -| -------- | -------- | -------- | -------- | -| isP2pGo | boolean | åªè¯» | 是å¦æ˜¯ç¾¤ç»„。 | -| ownerInfo | [WifiP2pDevice](#WifiP2pDevice) | åªè¯» | 群组的设备信æ¯ã€‚ | -| passphrase | string | åªè¯» | 群组密钥。 | -| interface | string | åªè¯» | 接å£å称。 | -| groupName | string | åªè¯» | 群组å称。 | -| networkId | number | åªè¯» | 网络ID。 | -| frequency | number | åªè¯» | 群组的频率。 | -| clientDevices | [WifiP2pDevice[]](#WifiP2pDevice) | åªè¯» | 接入的设备列表信æ¯ã€‚ | -| goIpAddress | string | åªè¯» | 群组IP地å€ã€‚ | ## WifiP2pDevice<sup>8+</sup> 表示P2P设备信æ¯ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å‚æ•°å | 类型 | 读写属性 | 说明 | | -------- | -------- | -------- | -------- | | deviceName | string | åªè¯» | 设备å称。 | | deviceAddress | string | åªè¯» | 设备MAC地å€ã€‚ | | primaryDeviceType | string | åªè¯» | 主设备类型。 | -| deviceStatus | [P2pDeviceStatus](#P2pDeviceStatus) | åªè¯» | 设备状æ€ã€‚ | +| deviceStatus | [P2pDeviceStatus](#p2pdevicestatus8) | åªè¯» | 设备状æ€ã€‚ | | groupCapabilitys | number | åªè¯» | 群组能力。 | + ## P2pDeviceStatus<sup>8+</sup> 表示设备状æ€çš„枚举。 +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | CONNECTED | 0 | 连接状æ€ã€‚ | @@ -601,71 +1353,41 @@ getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>): void | UNAVAILABLE | 4 | ä¸å¯ç”¨çŠ¶æ€ã€‚ | -## wifi.getP2pPeerDevices<sup>8+</sup> - -getP2pPeerDevices(): Promise<WifiP2pDevice[]> - -获å–P2P对端设备列表信æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ - -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION - -**系统能力:** SystemCapability.Communication.WiFi.P2P - -**返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<[WifiP2pDevice[]](#WifiP2pDevice)> | 对端设备列表信æ¯ã€‚ | - - -## wifi.getP2pPeerDevices<sup>8+</sup> - -getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void - -获å–P2P对端设备列表信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ - -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION - -**系统能力:** SystemCapability.Communication.WiFi.P2P - -**å‚数:** - | å‚æ•°å | 类型 | å¿…å¡« | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pDevice[]](#WifiP2pDevice)> | 是 | 对端设备列表信æ¯å›žè°ƒå‡½æ•°ã€‚ | - ## wifi.getP2pLocalDevice<sup>9+</sup> getP2pLocalDevice(): Promise<WifiP2pDevice> -获å–P2P本端设备信æ¯ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P本端设备信æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.GET_WIFI_CONFIG +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.GET_WIFI_CONFIG **系统能力:** SystemCapability.Communication.WiFi.P2P **返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise<[WifiP2pDevice](#WifiP2pDevice)> | 本端设备信æ¯ã€‚ | + | Promise<[WifiP2pDevice](#wifip2pdevice8)> | Promise对象。表示本端设备信æ¯ã€‚ | -## wifi.getP2pLocalDevice<sup>8+</sup> +## wifi.getP2pLocalDevice<sup>9+</sup> getP2pLocalDevice(callback: AsyncCallback<WifiP2pDevice>): void -获å–P2P本端设备信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–P2P本端设备信æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.GET_WIFI_CONFIG +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.GET_WIFI_CONFIG **系统能力:** SystemCapability.Communication.WiFi.P2P **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[WifiP2pDevice](#WifiP2pDevice)> | 是 | 本端设备信æ¯å›žè°ƒå‡½æ•°ã€‚ | + | callback | AsyncCallback<[WifiP2pDevice](#wifip2pdevice8)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示本端设备信æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | + ## wifi.createGroup<sup>8+</sup> -createGroup(config: WifiP2PConfig): boolean; +createGroup(config: WifiP2PConfig): boolean 创建群组。 @@ -677,39 +1399,45 @@ createGroup(config: WifiP2PConfig): boolean; | **å‚æ•°å** | **类型** | å¿…å¡« | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#WifiP2PConfig) | 是 | 群组é…置信æ¯ã€‚ | + | config | [WifiP2PConfig](#wifip2pconfig8) | 是 | 群组é…置信æ¯ã€‚ | **返回值:** | 类型 | 说明 | | -------- | -------- | | boolean | true:创建群组æ“作执行æˆåŠŸï¼Œ false:创建群组æ“作执行失败。 | + ## WifiP2PConfig<sup>8+</sup> 表示P2Pé…置信æ¯ã€‚ +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å‚æ•°å | 类型 | 读写属性 | 说明 | | -------- | -------- | -------- | -------- | | deviceAddress | string | åªè¯» | 设备地å€ã€‚ | | netId | number | åªè¯» | 网络ID。创建群组时-1表示创建临时组,-2表示创建永久组。 | | passphrase | string | åªè¯» | 群组密钥。 | | groupName | string | åªè¯» | 群组å称。 | -| goBand | [GroupOwnerBand](#GroupOwnerBand) | åªè¯» | 群组带宽。 | +| goBand | [GroupOwnerBand](#groupownerband8) | åªè¯» | 群组带宽。 | ## GroupOwnerBand<sup>8+</sup> 表示群组带宽的枚举。 +**系统能力:** SystemCapability.Communication.WiFi.P2P + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | GO_BAND_AUTO | 0 | 自动模å¼ã€‚ | | GO_BAND_2GHZ | 1 | 2GHZ。 | | GO_BAND_5GHZ | 2 | 5GHZ。 | + ## wifi.removeGroup<sup>8+</sup> -removeGroup(): boolean; +removeGroup(): boolean 移除群组。 @@ -725,11 +1453,11 @@ removeGroup(): boolean; ## wifi.p2pConnect<sup>8+</sup> -p2pConnect(config: WifiP2PConfig): boolean; +p2pConnect(config: WifiP2PConfig): boolean 执行P2P连接。 -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P @@ -737,7 +1465,7 @@ p2pConnect(config: WifiP2PConfig): boolean; | **å‚æ•°å** | **类型** | å¿…å¡« | **说明** | | -------- | -------- | -------- | -------- | - | config | [WifiP2PConfig](#WifiP2PConfig) | 是 | 连接é…置信æ¯ã€‚ | + | config | [WifiP2PConfig](#wifip2pconfig8) | 是 | 连接é…置信æ¯ã€‚ | **返回值:** | 类型 | 说明 | @@ -792,7 +1520,7 @@ p2pConnect(config: WifiP2PConfig): boolean; } wifi.on("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc); - var recvP2pPersistentGroupChangeFunc = result => { + var recvP2pPersistentGroupChangeFunc = () => { console.info("p2p persistent group change receive event"); wifi.getCurrentGroup((err, data) => { @@ -814,7 +1542,7 @@ p2pConnect(config: WifiP2PConfig): boolean; ## wifi.p2pCancelConnect<sup>8+</sup> -p2pCancelConnect(): boolean; +p2pCancelConnect(): boolean å–消P2P连接。 @@ -825,16 +1553,16 @@ p2pCancelConnect(): boolean; **返回值:** | 类型 | 说明 | | -------- | -------- | - | boolean | true:å–消连接æ“作执行æˆåŠŸï¼Œ false:å–消连接æ“作执行失败。 | + | boolean | true:æ“作执行æˆåŠŸï¼Œ false:æ“作执行失败。 | ## wifi.startDiscoverDevices<sup>8+</sup> -startDiscoverDevices(): boolean; +startDiscoverDevices(): boolean 开始å‘现设备。 -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P @@ -846,7 +1574,7 @@ startDiscoverDevices(): boolean; ## wifi.stopDiscoverDevices<sup>8+</sup> -stopDiscoverDevices(): boolean; +stopDiscoverDevices(): boolean åœæ¢å‘现设备。 @@ -860,6 +1588,103 @@ stopDiscoverDevices(): boolean; | boolean | true:æ“作执行æˆåŠŸï¼Œæ“作执行失败。 | +## wifi.deletePersistentGroup<sup>8+</sup> + +deletePersistentGroup(netId: number): boolean + +åˆ é™¤æ°¸ä¹…ç»„ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +**å‚数:** + + | **å‚æ•°å** | **类型** | å¿…å¡« | **说明** | + | -------- | -------- | -------- | -------- | + | netId | number | 是 | 组的ID。 | + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | boolean | true:æ“作执行æˆåŠŸï¼Œæ“作执行失败。 | + + +## wifi.getP2pGroups<sup>9+</sup> +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +getP2pGroups(): Promise<Array<WifiP2pGroupInfo>> + +获å–创建的所有P2P群组信æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> > | Promise对象。表示所有群组信æ¯ã€‚ | + + +## WifiP2pGroupInfo<sup>8+</sup> + +表示P2P群组相关信æ¯ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +| å‚æ•°å | 类型 | 读写属性 | 说明 | +| -------- | -------- | -------- | -------- | +| isP2pGo | boolean | åªè¯» | 是å¦æ˜¯ç¾¤ä¸»ã€‚ | +| ownerInfo | [WifiP2pDevice](#wifip2pdevice8) | åªè¯» | 群组的设备信æ¯ã€‚ | +| passphrase | string | åªè¯» | 群组密钥。 | +| interface | string | åªè¯» | 接å£å称。 | +| groupName | string | åªè¯» | 群组å称。 | +| networkId | number | åªè¯» | 网络ID。 | +| frequency | number | åªè¯» | 群组的频率。 | +| clientDevices | [WifiP2pDevice[]](#wifip2pdevice8) | åªè¯» | 接入的设备列表信æ¯ã€‚ | +| goIpAddress | string | åªè¯» | 群组IP地å€ã€‚ | + + +## wifi.getP2pGroups<sup>9+</sup> + +getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void + +获å–创建的所有P2P群组信æ¯ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ + +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +**å‚数:** + | å‚æ•°å | 类型 | å¿…å¡« | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo8)>> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示所有群组信æ¯ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | + + +## wifi.setDeviceName<sup>8+</sup> + +setDeviceName(devName: string): boolean + +设置设备å称。 +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**需è¦æƒé™ï¼š** + ohos.permission.SET_WIFI_INFO å’Œ ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用å¯ç”¨ã€‚ + +**系统能力:** SystemCapability.Communication.WiFi.P2P + +**å‚数:** + | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | + | -------- | -------- | -------- | -------- | + | devName | string | 是 | 设备å称。 | + +**返回值:** + | **类型** | **说明** | + | -------- | -------- | + | boolean | true:æ“作æˆåŠŸï¼Œ false:æ“作失败。 | + + ## wifi.on('wifiStateChange')<sup>7+</sup> on(type: "wifiStateChange", callback: Callback<number>): void @@ -1136,7 +1961,7 @@ on(type: "p2pConnectionChange", callback: Callback<WifiP2pLinkedInfo>): vo | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pConnectionChange"å—符串。 | - | callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | + | callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | ## wifi.off('p2pConnectionChange')<sup>8+</sup> @@ -1153,7 +1978,7 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>): | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pConnectionChange"å—符串。 | - | callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | + | callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | ## wifi.on('p2pDeviceChange')<sup>8+</sup> @@ -1162,7 +1987,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void 注册P2P设备状æ€æ”¹å˜äº‹ä»¶ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P @@ -1170,7 +1995,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pDeviceChange"å—符串。 | - | callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | + | callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | ## wifi.off('p2pDeviceChange')<sup>8+</sup> @@ -1187,7 +2012,7 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pDeviceChange"å—符串。 | - | callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | + | callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | ## wifi.on('p2pPeerDeviceChange')<sup>8+</sup> @@ -1196,7 +2021,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void 注册P2P对端设备状æ€æ”¹å˜äº‹ä»¶ã€‚ -**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO,ohos.permission.LOCATION +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO å’Œ ohos.permission.LOCATION **系统能力:** SystemCapability.Communication.WiFi.P2P @@ -1204,7 +2029,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pPeerDeviceChange"å—符串。 | - | callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | + | callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | 是 | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚ | ## wifi.off('p2pPeerDeviceChange')<sup>8+</sup> @@ -1221,7 +2046,7 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo | **å‚æ•°å** | **类型** | **å¿…å¡«** | **说明** | | -------- | -------- | -------- | -------- | | type | string | 是 | 固定填"p2pPeerDeviceChange"å—符串。 | - | callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | + | callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | å¦ | 状æ€æ”¹å˜å›žè°ƒå‡½æ•°ã€‚如果callbackä¸å¡«ï¼Œå°†åŽ»æ³¨å†Œè¯¥äº‹ä»¶å…³è”的所有回调函数。 | ## wifi.on('p2pPersistentGroupChange')<sup>8+</sup> diff --git a/zh-cn/application-dev/reference/apis/js-apis-wifiext.md b/zh-cn/application-dev/reference/apis/js-apis-wifiext.md index ff85bfddbd8c67bd1410f11f5ba7b993ea85952b..9afdcf23bfa5127d0477d8543d0dbeb855f1d29b 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-wifiext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wifiext.md @@ -1,4 +1,5 @@ # WLAN +该模å—主è¦æä¾›WLAN扩展接å£ï¼Œä¾›éžé€šç”¨ç±»åž‹äº§å“使用。 >  **说明:** > 本模å—首批接å£ä»ŽAPI version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 @@ -17,13 +18,11 @@ enableHotspot(): boolean; 使能WLANçƒç‚¹ã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.MANAGE_WIFI_HOTSPOT_EXT +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- 返回值: +**返回值:** | **类型** | **说明** | | -------- | -------- | | boolean | æ“作结果, true: æˆåŠŸï¼Œ false: 失败。 | @@ -35,13 +34,11 @@ disableHotspot(): boolean; 去使能WLANçƒç‚¹ã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.MANAGE_WIFI_HOTSPOT_EXT +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- 返回值: +**返回值:** | **类型** | **说明** | | -------- | -------- | | boolean | æ“作结果, true: æˆåŠŸï¼Œ false: 失败。 | @@ -51,24 +48,24 @@ disableHotspot(): boolean; getSupportedPowerModel(): Promise<Array<PowerModel>> -获å–支æŒçš„功率模å¼ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–支æŒçš„功率模å¼ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- 返回值: +**返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise<Array<[PowerModel](#PowerModel)>> | 功率模å¼ã€‚ | + | Promise<Array<[PowerModel](#powermodel)>> | Promise对象。表示功率模å¼ã€‚ | ## PowerModel 表示功率模å¼çš„枚举。 +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension + | å称 | 默认值 | 说明 | | -------- | -------- | -------- | | SLEEPING | 0 | ç¡çœ 模å¼ã€‚ | @@ -80,54 +77,48 @@ getSupportedPowerModel(): Promise<Array<PowerModel>> getSupportedPowerModel(callback: AsyncCallback<Array<PowerModel>>): void -获å–支æŒçš„功率模å¼ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–支æŒçš„功率模å¼ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- å‚æ•° +**å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[PowerModel](#PowerModel)> | 是 | 功率模å¼ã€‚ | + | callback | AsyncCallback<[PowerModel](#powermodel)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示支æŒçš„功率模å¼ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | ## wifiext.getPowerModel getPowerModel(): Promise<PowerModel> -获å–功率模å¼ï¼Œä½¿ç”¨promiseæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–功率模å¼ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- 返回值: +**返回值:** | 类型 | 说明 | | -------- | -------- | - | Promise<[PowerModel](#PowerModel)> | 功率模å¼ã€‚ | + | Promise<[PowerModel](#powermodel)> | Promise对象。表示功率模å¼ã€‚ | ## wifiext.getPowerModel getPowerModel(callback: AsyncCallback<PowerModel>): void -获å–功率模å¼ï¼Œä½¿ç”¨callbackæ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•ã€‚ +获å–功率模å¼ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.GET_WIFI_INFO +**需è¦æƒé™ï¼š** ohos.permission.GET_WIFI_INFO -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- å‚æ•° +**å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[PowerModel](#PowerModel)> | 是 | 功率模å¼ã€‚ | + | callback | AsyncCallback<[PowerModel](#powermodel)> | 是 | 回调函数。当æ“作æˆåŠŸæ—¶ï¼Œerr为0,data表示功率模å¼ã€‚如果error为éž0,表示处ç†å‡ºçŽ°é”™è¯¯ã€‚ | ## wifiext.setPowerModel @@ -136,18 +127,16 @@ setPowerModel(model: PowerModel) : boolean; 设置功率模å¼ã€‚ -- 需è¦æƒé™ï¼š - ohos.permission.MANAGE_WIFI_HOTSPOT_EXT +**需è¦æƒé™ï¼š** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT -- 系统能力: - SystemCapability.Communication.WiFi.AP.Extension +**系统能力:** SystemCapability.Communication.WiFi.AP.Extension -- å‚æ•° +**å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | -------- | -------- | -------- | - | model | AsyncCallback<[PowerModel](#PowerModel)> | 是 | 功率模å¼ã€‚ | + | model | AsyncCallback<[PowerModel](#powermodel)> | 是 | 功率模å¼ã€‚ | -- 返回值: +**返回值:** | **类型** | **说明** | | -------- | -------- | | boolean | æ“作结果, true: æˆåŠŸï¼Œ false: 失败。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 78d5e8d5b274f4ae960c31e3b35acb308ede5a6f..b33a44742d7d5e4dafc522700532f82e34f26ba7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -27,19 +27,21 @@ import window from '@ohos.window'; | ----------------- | ------ | ------------------ | | TYPE_APP | 0 | 表示应用å窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨FA模型下使用。 | | TYPE_SYSTEM_ALERT | 1 | 表示系统告è¦çª—å£ã€‚ | -| TYPE_INPUT_METHOD<sup>9+</sup> | 2 | 表示输入法窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_STATUS_BAR<sup>9+</sup> | 3 | 表示状æ€æ 窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_PANEL<sup>9+</sup> | 4 | 表示通知æ 。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_KEYGUARD<sup>9+</sup> | 5 | 表示é”å±ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6 | 表示音é‡æ¡ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7 | 表示导航æ 窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| TYPE_INPUT_METHOD<sup>9+</sup> | 2 | 表示输入法窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_STATUS_BAR<sup>9+</sup> | 3 | 表示状æ€æ 窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_PANEL<sup>9+</sup> | 4 | 表示通知æ 。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_KEYGUARD<sup>9+</sup> | 5 | 表示é”å±ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6 | 表示音é‡æ¡ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7 | 表示导航æ 窗å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | | TYPE_FLOAT<sup>9+</sup> | 8 | 表示悬浮窗。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br>**需è¦æƒé™ï¼š** ohos.permission.SYSTEM_FLOAT_WINDOW | -| TYPE_WALLPAPER<sup>9+</sup> | 9 | 表示å£çº¸ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_DESKTOP<sup>9+</sup> | 10 | 表示桌é¢ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11 | 表示多任务ä¸å¿ƒã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | 表示桌é¢Dockæ 。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13 | 表示智慧è¯éŸ³ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | -| TYPE_POINTER<sup>9+</sup> | 14 | è¡¨ç¤ºé¼ æ ‡ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ | +| TYPE_WALLPAPER<sup>9+</sup> | 9 | 表示å£çº¸ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_DESKTOP<sup>9+</sup> | 10 | 表示桌é¢ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11 | 表示多任务ä¸å¿ƒã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | 表示桌é¢Dockæ 。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13 | 表示智慧è¯éŸ³ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_POINTER<sup>9+</sup> | 14 | è¡¨ç¤ºé¼ æ ‡ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15 | 表示相机类型悬浮窗。æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br>**需è¦æƒé™ï¼š** ohos.permission.SYSTEM_FLOAT_WINDOW | +| TYPE_DIALOG<sup>9+</sup> | 16 | 表示模æ€çª—å£ã€‚æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。<br/>æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | ## AvoidAreaType<sup>7+</sup> @@ -58,7 +60,7 @@ import window from '@ohos.window'; 窗å£æ¨¡å¼æžšä¸¾ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -74,7 +76,7 @@ import window from '@ohos.window'; 窗å£å¸ƒå±€æ¨¡å¼æžšä¸¾ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -119,11 +121,26 @@ import window from '@ohos.window'; | AUTO_ROTATION_LANDSCAPE_RESTRICTED | 10 | 表述å—开关控制的自动横å‘旋转模å¼ã€‚ | | LOCKED | 11 | 表示é”定模å¼ã€‚ | +## BlurStyle<sup>9+</sup> + +窗å£æ¨¡ç³Šç±»åž‹æžšä¸¾ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å称 | 值 | 说明 | +| ------- | ---- | -------------------- | +| OFF | 0 | 表示关é—模糊。 | +| THIN | 1 | 表示较薄的模糊类型。 | +| REGULAR | 2 | 表示适ä¸çš„模糊类型。 | +| THICK | 3 | 表示较厚的模糊类型。 | + ## SystemBarRegionTint<sup>8+</sup> å•ä¸ªå¯¼èˆªæ 或状æ€æ 回调信æ¯ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -139,7 +156,7 @@ import window from '@ohos.window'; 当å‰ç³»ç»Ÿæ 回调信æ¯é›†åˆã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -544,7 +561,7 @@ minimizeAll(id: number, callback: AsyncCallback<void>): void 最å°åŒ–æŸæ˜¾ç¤ºè®¾å¤‡ä¸‹çš„所有窗å£ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -582,7 +599,7 @@ minimizeAll(id: number): Promise<void> 最å°åŒ–æŸæ˜¾ç¤ºè®¾å¤‡ä¸‹çš„所有窗å£ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -624,7 +641,7 @@ toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void 多窗å£å¿«é€Ÿåˆ‡æ¢æ—¶éšè—或者æ¢å¤åº”用窗å£ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -651,7 +668,7 @@ toggleShownStateForAllAppWindows(): Promise<void> 多窗å£å¿«é€Ÿåˆ‡æ¢æ—¶éšè—或者æ¢å¤åº”用窗å£ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -677,7 +694,7 @@ setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>) 设置窗å£å¸ƒå±€æ¨¡å¼ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -701,7 +718,7 @@ setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> 设置窗å£å¸ƒå±€æ¨¡å¼ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -734,7 +751,7 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v å¼€å¯çŠ¶æ€æ ã€å¯¼èˆªæ 属性å˜åŒ–的监å¬ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -759,7 +776,7 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) å…³é—状æ€æ ã€å¯¼èˆªæ 属性å˜åŒ–的监å¬ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -788,7 +805,7 @@ hide (callback: AsyncCallback<void>): void éšè—当å‰çª—å£ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -816,7 +833,7 @@ hide(): Promise<void> éšè—当å‰çª—å£ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1066,7 +1083,7 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void 设置窗å£ç±»åž‹ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1096,7 +1113,7 @@ setWindowType(type: WindowType): Promise<void> 设置窗å£ç±»åž‹ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1854,8 +1871,8 @@ on(type: 'avoidAreaChange', callback: Callback<{[AvoidAreaType](#avoidareatyp **示例:** ```js -windowClass.on('avoidAreaChange', (type, data) => { - console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(type) + 'Data: ' + JSON.stringify(data)); +windowClass.on('avoidAreaChange', (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. type:' + JSON.stringify(data.type) + ', area: ' + JSON.stringify(data.area)); }); ``` @@ -1929,7 +1946,7 @@ windowClass.off('keyboardHeightChange'); on(type: 'touchOutside', callback: Callback<void>): void å¼€å¯æœ¬çª—å£åŒºåŸŸèŒƒå›´å¤–的点击事件的监å¬ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1953,7 +1970,7 @@ windowClass.on('touchOutside', () => { off(type: 'touchOutside', callback?: Callback<void>): void å…³é—本窗å£åŒºåŸŸèŒƒå›´å¤–的点击事件的监å¬ã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -1970,6 +1987,199 @@ off(type: 'touchOutside', callback?: Callback<void>): void windowClass.off('touchOutside'); ``` +### on('screenshot')<sup>9+</sup> + +on(type: 'screenshot', callback: Callback<void>): void + +å¼€å¯æˆªå±äº‹ä»¶çš„监å¬ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'screenshot',å³æˆªå±äº‹ä»¶ã€‚ | +| callback | Callback<void> | 是 | 回调函数。å‘生截å±äº‹ä»¶æ—¶çš„回调。 | + +**示例:** + +```js +windowClass.on('screenshot', () => { + console.info('screenshot happened'); +}); +``` + +### off('screenshot')<sup>9+</sup> + +off(type: 'screenshot', callback?: Callback<void>): void + +å…³é—截å±äº‹ä»¶çš„监å¬ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'screenshot',å³æˆªå±äº‹ä»¶ã€‚ | +| callback | Callback<void> | å¦ | 回调函数。å‘生截å±äº‹ä»¶æ—¶çš„回调。 | + +**示例:** + +```js +var callback = ()=>{ + console.info('screenshot happened'); +} +windowClass.on('screenshot', callback) +windowClass.off('screenshot', callback) + +// 如果通过onå¼€å¯å¤šä¸ªcallback进行监å¬ï¼ŒåŒæ—¶å…³é—所有监å¬ï¼š +windowClass.off('screenshot'); +``` + +### on('dialogTargetTouch')<sup>9+</sup> + +on(type: 'dialogTargetTouch', callback: Callback<void>): void + +å¼€å¯æ¨¡æ€çª—å£ç›®æ ‡çª—å£çš„点击事件的监å¬ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'dialogTargetTouch',å³æ¨¡æ€çª—å£ç›®æ ‡çª—å£çš„点击事件。 | +| callback | Callback<void>| 是 | 回调函数。当点击事件å‘生在模æ€çª—å£ç›®æ ‡çª—å£çš„回调。 | + +**示例:** + +```js +windowClass.on('dialogTargetTouch', () => { + console.info('touch dialog target'); +}); +``` + +### off('dialogTargetTouch')<sup>9+</sup> + +off(type: 'dialogTargetTouch', callback?: Callback<void>): void + +å…³é—模æ€çª—å£ç›®æ ‡çª—å£çš„点击事件的监å¬ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 监å¬äº‹ä»¶ï¼Œå›ºå®šä¸º'dialogTargetTouch',å³æ¨¡æ€çª—å£ç›®æ ‡çª—å£çš„点击事件。 | +| callback | Callback<void> | å¦ | 回调函数。当点击事件å‘生在模æ€çª—å£ç›®æ ‡çª—å£çš„回调。 | + +**示例:** + +```js +windowClass.off('dialogTargetTouch'); +``` + +### bindDialogTarget<sup>9+</sup> + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void + +绑定模æ€çª—å£ä¸Žç›®æ ‡çª—å£å¹¶æ·»åŠ 模æ€çª—å£é”€æ¯ç›‘å¬ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | ç›®æ ‡çª—å£token值。 | +| deathCallback | Callback<void> | 是 | 模æ€çª—å£é”€æ¯ç›‘å¬ã€‚ | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject("testObject"); +windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); +}, (err, data) => { + if (err.code) { + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); +}); +``` + +### bindDialogTarget<sup>9+</sup> + +bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> + +绑定模æ€çª—å£ä¸Žç›®æ ‡çª—å£å¹¶æ·»åŠ 模æ€çª—å£é”€æ¯ç›‘å¬ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| token | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | ç›®æ ‡çª—å£token值。 | +| deathCallback | Callback<void> | 是 | 模æ€çª—å£é”€æ¯ç›‘å¬ã€‚ | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | æ— è¿”å›žç»“æžœçš„Promise对象。 | + +**示例:** + +```js +class TestRemoteObject extends rpc.RemoteObject { + constructor(descriptor) { + super(descriptor); + } + addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { + return true; + } + isObjectDead(): boolean { + return false; + } +} +let token = new TestRemoteObject("testObject"); +let promise = windowClass.bindDialogTarget(token, () => { + console.info('Dialog Window Need Destroy.'); +}); +promise.then((data)=> { + console.info('Succeeded in binding dialog target. Data:' + JSON.stringify(data)); +}).catch((err)=>{ + console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err)); +}); +``` + ### isSupportWideGamut<sup>8+</sup> isSupportWideGamut(callback: AsyncCallback<boolean>): void @@ -2190,6 +2400,29 @@ promise.then((data)=> { }); ``` +### setWakeUpScreen()<sup>9+</sup> + +setWakeUpScreen(wakeUp: boolean): void; + +窗å£å”¤é†’å±å¹•ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ---------------- | ------- | ---- | ---------------------------- | +| wakeUp | boolean | 是 | 是å¦è®¾ç½®å”¤é†’å±å¹•ã€‚ | + +**示例:** + +```ts +var wakeUp = true; +windowClass.setWakeUpScreen(wakeUp); +``` + ### setBrightness setBrightness(brightness: number, callback: AsyncCallback<void>): void @@ -2256,9 +2489,9 @@ setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void 窗å£å åŠ æ—¶ï¼Œè®¾å¤‡æœ‰å窗å£çš„情况下设置é åŽçš„窗å£çš„暗度值,使用callback异æ¥å›žè°ƒã€‚ -> **说明:** 从API version 9开始废弃。 -> -> 从 API version 7开始支æŒã€‚ +> **说明:** 该接å£ä¸æ”¯æŒä½¿ç”¨ã€‚ +> +> 从API version 9开始废弃。从API Version 7开始支æŒã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2287,9 +2520,9 @@ setDimBehind(dimBehindValue: number): Promise<void> 窗å£å åŠ æ—¶ï¼Œè®¾å¤‡æœ‰å窗å£çš„情况下设置é åŽçš„窗å£çš„暗度值,使用Promise异æ¥å›žè°ƒã€‚ -> **说明:** 从API version 9开始废弃。 +> **说明:** 该接å£ä¸æ”¯æŒä½¿ç”¨ã€‚ > -> 从 API version 7开始支æŒã€‚ +> 从API version 9开始废弃。从API Version 7开始支æŒã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2442,9 +2675,9 @@ setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): vo 设置是å¦å…许å¯ç‚¹å‡»å窗å£ä¹‹å¤–的区域,使用callback异æ¥å›žè°ƒã€‚ -> **说明:** 从API version 9开始废弃。 +> **说明:** 该接å£ä¸æ”¯æŒä½¿ç”¨ã€‚ > -> 从 API version 7开始支æŒã€‚ +> 从API version 9开始废弃。从API Version 7开始支æŒã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2473,9 +2706,9 @@ setOutsideTouchable(touchable: boolean): Promise<void> 设置是å¦å…许å¯ç‚¹å‡»å窗å£ä¹‹å¤–的区域,使用Promise异æ¥å›žè°ƒã€‚。 -> **说明:** 从API version 9开始废弃。 +> **说明:** 该接å£ä¸æ”¯æŒä½¿ç”¨ã€‚ > -> 从 API version 7开始支æŒã€‚ +> 从API version 9开始废弃。从 API version 7开始支æŒã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2506,7 +2739,7 @@ promise.then((data)=> { setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void -设置窗å£æ˜¯å¦ä¸ºéšç§æ¨¡å¼ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ +设置窗å£æ˜¯å¦ä¸ºéšç§æ¨¡å¼ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚设置为éšç§æ¨¡å¼çš„窗å£ï¼Œçª—å£å†…å®¹å°†æ— æ³•è¢«æˆªå±æˆ–录å±ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2535,7 +2768,7 @@ windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { setPrivacyMode(isPrivacyMode: boolean): Promise<void> -设置窗å£æ˜¯å¦ä¸ºéšç§æ¨¡å¼ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ +设置窗å£æ˜¯å¦ä¸ºéšç§æ¨¡å¼ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚设置为éšç§æ¨¡å¼çš„窗å£ï¼Œçª—å£å†…å®¹å°†æ— æ³•è¢«æˆªå±æˆ–录å±ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2563,6 +2796,25 @@ promise.then((data)=> { }); ``` +### setSnapshotSkip<sup>9+</sup> +setSnapshotSkip(isSkip: boolean): void + +截å±å½•å±æ˜¯å¦å¿½ç•¥å½“å‰çª—å£ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------------- | ------- | ---- | -------------------- | +| isSkip | boolean | 是 | 截å±å½•å±æ˜¯å¦å¿½ç•¥å½“å‰çª—å£ï¼Œé»˜è®¤ä¸ºfalse。<br>true表示忽略当å‰çª—å£ï¼Œfalse表示ä¸å¿½ç•¥å½“å‰çª—å£ã€‚</br> | +```js +var isSkip = true; +windowClass.setSnapshotSkip(isSkip); +``` + ### setTouchable<sup>7+</sup> setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void @@ -2630,7 +2882,7 @@ setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void&g 设置窗å£åœ¨åˆ†å±æ¨¡å¼ä¸‹æ˜¯å¦è¢«ç¦æ¢ç§»åŠ¨ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2661,7 +2913,7 @@ setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> 设置窗å£åœ¨åˆ†å±æ¨¡å¼ä¸‹æ˜¯å¦è¢«ç¦æ¢ç§»åŠ¨ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -2689,6 +2941,172 @@ promise.then((data)=> { }); ``` +### snapshot<sup>9+</sup> + +snapshot(callback: AsyncCallback<image.PixelMap>): void + +获å–窗å£æˆªå›¾ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调函数。 | + +**示例:** + +```js +windowClass.snapshot((err, data) => { + if (err.code) { + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + data.release(); // PixelMap使用完åŽåŠæ—¶é‡Šæ”¾å†…å˜ +}); +``` + +### snapshot<sup>9+</sup> + +snapshot(): Promise<image.PixelMap> + +获å–窗å£æˆªå›¾ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise对象。返回当å‰çª—å£æˆªå›¾ã€‚ | + +**示例:** + +```js +let promise = windowClass.snapshot(); +promise.then((pixelMap)=> { + console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); + pixelMap.release(); // PixelMap使用完åŽåŠæ—¶é‡Šæ”¾å†…å˜ +}).catch((err)=>{ + console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); +}); +``` + +### setBlur<sup>9+</sup> + +setBlur(radius: number): void + +设置窗å£æ¨¡ç³Šã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗å£æ¨¡ç³Šçš„åŠå¾„值,å–值范围为大于ç‰äºŽ0,0表示关é—窗å£æ¨¡ç³Šã€‚ | + +**示例:** + +```js +windowClass.setBlur(4.0); +``` + +### setBackdropBlur<sup>9+</sup> + +setBackdropBlur(radius: number): void + +设置窗å£èƒŒæ™¯æ¨¡ç³Šã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗å£èƒŒæ™¯æ¨¡ç³Šçš„åŠå¾„值,å–值范围为大于ç‰äºŽ0,0表示关é—窗å£èƒŒæ™¯æ¨¡ç³Šã€‚ | + +**示例:** + +```js +windowClass.setBackdropBlur(4.0); +``` + +### setBackdropBlurStyle<sup>9+</sup> + +setBackdropBlurStyle(blurStyle: BlurStyle): void + +设置窗å£èƒŒæ™¯æ¨¡ç³Šç±»åž‹ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------- | --------- | ---- | ---------------------- | +| blurStyle | [BlurStyle](#blurstyle9) | 是 | 表示窗å£èƒŒæ™¯æ¨¡ç³Šç±»åž‹ã€‚ | + +**示例:** + +```js +windowClass.setBackdropBlurStyle(window.BlurType.THIN); +``` + +### setShadow<sup>9+</sup> + +setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void + +设置窗å£è¾¹ç¼˜é˜´å½±ã€‚ + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| radius | number | 是 | 表示窗å£è¾¹ç¼˜é˜´å½±çš„模糊åŠå¾„,å–值范围为大于ç‰äºŽ0,0表示关é—窗å£è¾¹ç¼˜é˜´å½±ã€‚ | +| color | string | å¦ | 表示窗å£è¾¹ç¼˜é˜´å½±çš„颜色,为åå…进制颜色,ä¸åŒºåˆ†å¤§å°å†™ï¼Œä¾‹å¦‚`#00FF00`或`#FF00FF00`。 | +| offsetX | number | å¦ | 表示窗å£è¾¹ç¼˜é˜´å½±çš„Xè½´çš„å移é‡ï¼Œå•ä½ä¸ºpx。 | +| offsetY | number | å¦ | 表示窗å£è¾¹ç¼˜é˜´å½±çš„Yè½´çš„å移é‡ï¼Œå•ä½ä¸ºpx。 | + +**示例:** + +```js +windowClass.setShadow(4.0, '#FF00FF00', 2, 3); +``` + +### setCornerRadius<sup>9+</sup> + +setCornerRadius(cornerRadius: number): void + +设置窗å£åœ†è§’åŠå¾„。 + +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| ----------- | ------- | ---- | -------------------- | +| radius | number | 是 | 表示窗å£åœ†è§’çš„åŠå¾„值,å–值范围为大于ç‰äºŽ0,0表示没有窗å£åœ†è§’。 | + +**示例:** + +```js +windowClass.setCornerRadius(4.0); +``` + ## WindowStageEventType<sup>9+</sup> WindowStage生命周期。 @@ -3112,7 +3530,7 @@ disableWindowDecor(): void æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 -æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ **系统能力:** SystemCapability.WindowManager.WindowManager.Core @@ -3133,6 +3551,7 @@ class myAbility extends Ability { setShowOnLockScreen(showOnLockScreen: boolean): void 设置应用显示在é”å±ä¹‹ä¸Šã€‚ +æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ï¼Œä¸‰æ–¹åº”用ä¸æ”¯æŒè°ƒç”¨ã€‚ æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md b/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md new file mode 100644 index 0000000000000000000000000000000000000000..7a05d608c5f43e65e1a6a62ec647d6e8cff084e8 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @@ -0,0 +1,266 @@ +# 窗å£åŠ¨ç”»ç®¡ç† +窗å£åŠ¨ç”»ç®¡ç†å™¨ï¼Œå¯ä»¥ç›‘å¬åº”用å¯åŠ¨é€€å‡ºæ—¶åº”用的动画窗å£ï¼Œæä¾›å¯åŠ¨é€€å‡ºè¿‡ç¨‹ä¸æŽ§ä»¶åŠ¨ç”»å’Œåº”用窗å£è”动动画能力。 + +> **说明:** +> 该组件从API Version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> +> 本模å—接å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + +## å¯¼å…¥æ¨¡å— + +```js +import windowAnimationManager from '@ohos.animation.windowAnimationManager' +``` + +## windowAnimationManager.setController + +setController(controller: WindowAnimationController): void + +设置窗å£åŠ¨ç”»æŽ§åˆ¶å™¨ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**å‚数:** + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------- | -------- | -------- | -------- | +| controller | [WindowAnimationController](#windowanimationcontroller) | 是 | 窗å£åŠ¨ç”»çš„控制器。| + +**示例:** + +```js +var controller = { + onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromLauncher', startingWindowTarget); + }, + onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromRecent', startingWindowTarget); + }, + onStartAppFromOther(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromOther', startingWindowTarget); + }, + onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + }, + onScreenUnlock(finishCallback: WindowAnimationFinishedCallback): void { + } +} + +windowAnimationManager.setController(controller) +``` + +## WindowAnimationController + +窗å£åŠ¨ç”»æŽ§åˆ¶å™¨ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +### onStartAppFromLauncher + +onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +从桌é¢å¯åŠ¨åº”用时的回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | åŠ¨ç”»ç›®æ ‡çª—å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromLauncher', startingWindowTarget); + } +} +``` + +### onStartAppFromRecent + +onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget,finishCallback:WindowAnimationFinishedCallback): void + +从最近任务列表å¯åŠ¨åº”用时的回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | åŠ¨ç”»ç›®æ ‡çª—å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromRecent', startingWindowTarget); + } +} +``` + +### onStartAppFromOther + +onStartAppFromOther(startingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +从除了桌é¢å’Œæœ€è¿‘任务列表以外其他地方å¯åŠ¨åº”用时的回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------ | +| startingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | åŠ¨ç”»ç›®æ ‡çª—å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onStartAppFromOther(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onStartAppFromOther', startingWindowTarget); + } +} +``` + +### onAppTransition + +onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +应用转场时的回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------- | ---- | ---------------- | +| fromWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | 转场å‰çš„动画窗å£ã€‚ | +| toWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | 转场åŽçš„动画窗å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget, + finishCallback: WindowAnimationFinishedCallback): void { + console.log('onAppTransition', fromWindowTarget); + } +} +``` + +### onMinimizeWindow + +onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +最å°åŒ–窗å£æ—¶çš„回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------- | ---- | ---------------- | +| minimizingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | åŠ¨ç”»ç›®æ ‡çª—å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onMinimizeWindow', minimizingWindowTarget); + } +} +``` + +### onCloseWindow + +onCloseWindow(closingWindowTarget: WindowAnimationTarget,finishCallback: WindowAnimationFinishedCallback): void + +å…³é—窗å£æ—¶çš„回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------------- | ------------------------------- | ---- | ---------------- | +| closingWindowTarget | [WindowAnimationTarget](#windowanimationtarget) | 是 | åŠ¨ç”»ç›®æ ‡çª—å£ã€‚ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + console.log('onCloseWindow', closingWindowTarget); + } +} +``` + +### onScreenUnlock + +onScreenUnlock(finishCallback: [WindowAnimationFinishedCallback](#windowanimationfinishedcallback)): void + +å±å¹•è§£é”时的回调。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| -------------- | ------------------------------------------------------------ | ---- | ------------------ | +| finishCallback | [WindowAnimationFinishedCallback](#windowanimationfinishedcallback) | 是 | 动画完æˆåŽçš„回调。 | + +**示例:** + +```js +var controller = { + onScreenUnlock(finishCallback: WindowAnimationFinishedCallback): void { + console.log('onScreenUnlock'.); + } +} +``` + +## WindowAnimationFinishedCallback +动画完æˆåŽçš„回调。 + +### onAnimationFinish + +onAnimationFinish():void + +结æŸæœ¬æ¬¡åŠ¨ç”»ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +**示例:** + +```js +var controller = { + onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void { + finishCallback.onAnimationFinish(); + } +} +``` + +## WindowAnimationTarget +åŠ¨ç”»ç›®æ ‡çª—å£ï¼Œç”¨æ¥å®žçŽ°åŠ¨ç”»ã€‚ + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•° | 类型 | æè¿° | +| ------- | ------ | ----------------------- | +| bundleName | string | åŠ¨ç”»ç›®æ ‡çª—å£æ‰€å¯¹åº”的包å。 | +| abilityName | string | åŠ¨ç”»ç›®æ ‡çª—å£æ‰€å¯¹åº”çš„Abilityå称。 | +| windowBounds | [RRect](#rrect) | åŠ¨ç”»ç›®æ ‡çª—å£æ‰€å¯¹åº”的实际大å°ã€‚ | + +## RRect +圆角矩形。 + +**系统能力:** SystemCapability.WindowManager.WindowManager.Core + +| å‚æ•° | 类型 | æè¿° | +| ------- | ------ | ----------------------- | +| left | number | åŠ¨ç”»ç›®æ ‡çª—å£å·¦ä¸Šè§’相对于å±å¹•çš„横åæ ‡ã€‚ | +| top | number | åŠ¨ç”»ç›®æ ‡çª—å£å·¦ä¸Šè§’相对于å±å¹•çš„纵åæ ‡ã€‚ | +| width | number | åŠ¨ç”»ç›®æ ‡çª—å£çš„宽度大å°ã€‚ | +| height | number | åŠ¨ç”»ç›®æ ‡çª—å£çš„高度大å°ã€‚ | +| radius | number | åŠ¨ç”»ç›®æ ‡çª—å£çš„圆角大å°ã€‚ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md index 7b1ef57eb95465ae025c4d13d9c0675549d244bc..898c5117ba3283d96a67a2d93f4b53921f7e2b67 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -4,13 +4,15 @@ å¼€å‘者在开å‘应用时,通过调用延迟任务注册接å£ï¼Œæ³¨å†Œå¯¹å®žæ—¶æ€§è¦æ±‚ä¸é«˜çš„å»¶è¿Ÿä»»åŠ¡ï¼Œè¯¥ä»»åŠ¡é»˜è®¤ç”±ç³»ç»Ÿå®‰æŽ’ï¼Œåœ¨ç³»ç»Ÿç©ºé—²æ—¶æ ¹æ®æ€§èƒ½ã€åŠŸè€—ã€çƒç‰æƒ…况进行调度执行。 ->  **说明:** -> 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> **说明:** +> +> - 本模å—首批接å£ä»ŽAPI version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 +> - 本模å—接å£ä»…å¯åœ¨Stage模型下使用。 ## å¯¼å…¥æ¨¡å— -``` +```js import workScheduler from '@ohos.workScheduler' ``` @@ -35,7 +37,7 @@ startWork(work: WorkInfo): boolean **示例**: -``` +```js let workInfo = { workId: 1, batteryLevel:50, @@ -71,7 +73,7 @@ stopWork(work: WorkInfo, needCancel?: boolean): boolean **示例**: -``` +```js let workInfo = { workId: 1, batteryLevel:50, @@ -101,7 +103,7 @@ getWorkStatus(workId: number, callback : AsyncCallback\<WorkInfo>): void **示例**: -``` +```js workScheduler.getWorkStatus(50, (err, res) => { if (err) { console.info('workschedulerLog getWorkStatus failed, because:' + err.code); @@ -134,7 +136,7 @@ getWorkStatus(workId: number): Promise\<WorkInfo> **示例**: -``` +```js workScheduler.getWorkStatus(50).then((res) => { for (let item in res) { console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); @@ -165,7 +167,7 @@ obtainAllWorks(callback : AsyncCallback\<void>): Array\<WorkInfo> **示例**: -``` +```js workScheduler.obtainAllWorks((err, res) =>{ if (err) { console.info('workschedulerLog obtainAllWorks failed, because:' + err.code); @@ -190,7 +192,7 @@ obtainAllWorks(): Promise<Array\<WorkInfo>> **示例**: -``` +```js workScheduler.obtainAllWorks().then((res) => { console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); }).catch((err) => { @@ -207,7 +209,7 @@ stopAndClearWorks(): boolean **示例**: -``` +```js let res = workScheduler.stopAndClearWorks(); console.info("workschedulerLog res:" + res); ``` @@ -234,7 +236,7 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\<void>): boolean **示例**: -``` +```js workScheduler.isLastWorkTimeOut(500, (err, res) =>{ if (err) { console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code); @@ -265,7 +267,7 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> **示例**: -``` +```js workScheduler.isLastWorkTimeOut(500) .then(res => { console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); @@ -278,30 +280,30 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ## WorkInfo æ供工作的具体信æ¯ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.WorkScheduler - -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| --------------- | --------------------------------- | ---- | -------------------------------- | -| workId | number | 是 | 当å‰å·¥ä½œçš„ID | -| bundleName | string | 是 | 延迟任务包å | -| abilityName | string | 是 | 延迟任务回调通知的组件å(必填) | -| networkType | [NetworkType](#networktype) | å¦ | 网络类型 | -| isCharging | boolean | å¦ | 是å¦å……电 | -| chargerType | [ChargingType](#chargingtype) | å¦ | 充电类型 | -| batteryLevel | number | å¦ | ç”µé‡ | -| batteryStatus | [BatteryStatus](#batterystatus) | å¦ | ç”µæ± çŠ¶æ€ | -| storageRequest | [StorageRequest](#storagerequest) | å¦ | å˜å‚¨çŠ¶æ€ | -| isRepeat | boolean | å¦ | 是å¦å¾ªçŽ¯ä»»åŠ¡ | -| repeatCycleTime | number | å¦ | 循环间隔 | -| repeatCount | number | å¦ | 循环次数 | -| isPersisted | boolean | å¦ | 是å¦æŒä¹…化ä¿å˜å·¥ä½œ | -| isDeepIdle | boolean | å¦ | 是å¦è¦æ±‚è®¾å¤‡è¿›å…¥ç©ºé—²çŠ¶æ€ | -| idleWaitTime | number | å¦ | 空闲ç‰å¾…时间 | +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler + +| å‚æ•°å | 类型 | å¿…å¡« | 说明 | +| --------------- | --------------------------------- | ---- | ---------------- | +| workId | number | 是 | 当å‰å·¥ä½œçš„ID | +| bundleName | string | 是 | 延迟任务包å | +| abilityName | string | 是 | 延迟任务回调通知的组件å(必填) | +| networkType | [NetworkType](#networktype) | å¦ | 网络类型 | +| isCharging | boolean | å¦ | 是å¦å……电 | +| chargerType | [ChargingType](#chargingtype) | å¦ | 充电类型 | +| batteryLevel | number | å¦ | ç”µé‡ | +| batteryStatus | [BatteryStatus](#batterystatus) | å¦ | ç”µæ± çŠ¶æ€ | +| storageRequest | [StorageRequest](#storagerequest) | å¦ | å˜å‚¨çŠ¶æ€ | +| isRepeat | boolean | å¦ | 是å¦å¾ªçŽ¯ä»»åŠ¡ | +| repeatCycleTime | number | å¦ | 循环间隔 | +| repeatCount | number | å¦ | 循环次数 | +| isPersisted | boolean | å¦ | 是å¦æŒä¹…化ä¿å˜å·¥ä½œ | +| isDeepIdle | boolean | å¦ | 是å¦è¦æ±‚è®¾å¤‡è¿›å…¥ç©ºé—²çŠ¶æ€ | +| idleWaitTime | number | å¦ | 空闲ç‰å¾…时间 | ## NetworkType 触å‘工作的网络类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.WorkScheduler +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler | å称 | 默认值 | 说明 | | ---------------------- | ---- | ----------------------- | @@ -315,7 +317,7 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ## ChargingType 触å‘工作的充电类型。 -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.WorkScheduler +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler | å称 | 默认值 | 说明 | | ------------------------- | ---- | -------------------- | @@ -327,7 +329,7 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ## BatteryStatus 触å‘å·¥ä½œçš„ç”µæ± çŠ¶æ€ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.WorkScheduler +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler | å称 | 默认值 | 说明 | | -------------------------- | ---- | -------------------------- | @@ -338,10 +340,10 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ## StorageRequest 触å‘工作的å˜å‚¨çŠ¶æ€ã€‚ -**系统能力**:以下å„项对应的系统能力å‡ä¸ºSystemCapability.ResourceSchedule.WorkScheduler +**系统能力**:SystemCapability.ResourceSchedule.WorkScheduler - |å称 |默认值 |说明| - | -------- | -------- | -------- | - |STORAGE_LEVEL_LOW |0 |表示这个触å‘æ¡ä»¶æ˜¯å˜å‚¨ç©ºé—´ä¸è¶³ã€‚ - |STORAGE_LEVEL_OKAY |1 |表示这个触å‘æ¡ä»¶æ˜¯ä»Žå˜å‚¨ç©ºé—´ä¸è¶³æ¢å¤åˆ°æ£å¸¸ã€‚ - |STORAGE_LEVEL_LOW_OR_OKAY |2 |表示这个触å‘æ¡ä»¶æ˜¯ä»Žå˜å‚¨ç©ºé—´ä¸è¶³æ¢å¤åˆ°æ£å¸¸æˆ–者å˜å‚¨ç©ºé—´ä¸è¶³ã€‚ \ No newline at end of file +| å称 | 默认值 | 说明 | +| ------------------------- | ---- | ------------------------------ | +| STORAGE_LEVEL_LOW | 0 | 表示这个触å‘æ¡ä»¶æ˜¯å˜å‚¨ç©ºé—´ä¸è¶³ã€‚ | +| STORAGE_LEVEL_OKAY | 1 | 表示这个触å‘æ¡ä»¶æ˜¯ä»Žå˜å‚¨ç©ºé—´ä¸è¶³æ¢å¤åˆ°æ£å¸¸ã€‚ | +| STORAGE_LEVEL_LOW_OR_OKAY | 2 | 表示这个触å‘æ¡ä»¶æ˜¯ä»Žå˜å‚¨ç©ºé—´ä¸è¶³æ¢å¤åˆ°æ£å¸¸æˆ–者å˜å‚¨ç©ºé—´ä¸è¶³ã€‚ | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index 4ef8ba58b6092774b74d096a3ab36cf09996661c..2a1209a974d273ca6187367ca3fa58cc981c5a10 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -1,98 +1,99 @@ # 基于JS扩展的类Webå¼€å‘èŒƒå¼ -- 组件 - - 通用 - - [通用属性](js-components-common-attributes.md) - - [é€šç”¨æ ·å¼](js-components-common-styles.md) - - [通用事件](js-components-common-events.md) - - [通用方法](js-components-common-methods.md) - - [åŠ¨ç”»æ ·å¼](js-components-common-animation.md) - - [æ¸å˜æ ·å¼](js-components-common-gradient.md) - - [è½¬åœºæ ·å¼](js-components-common-transition.md) - - [媒体查询](js-components-common-mediaquery.md) - - [自定义å—ä½“æ ·å¼](js-components-common-customizing-font.md) - - [原å布局](js-components-common-atomic-layout.md) - - 容器组件 - - [badge](js-components-container-badge.md) - - [dialog](js-components-container-dialog.md) - - [div](js-components-container-div.md) - - [form](js-components-container-form.md) - - [list](js-components-container-list.md) - - [list-item](js-components-container-list-item.md) - - [list-item-group](js-components-container-list-item-group.md) - - [panel](js-components-container-panel.md) - - [popup](js-components-container-popup.md) - - [refresh](js-components-container-refresh.md) - - [stack](js-components-container-stack.md) - - [stepper](js-components-container-stepper.md) - - [stepper-item](js-components-container-stepper-item.md) - - [swiper](js-components-container-swiper.md) - - [tabs](js-components-container-tabs.md) - - [tab-bar](js-components-container-tab-bar.md) - - [tab-content](js-components-container-tab-content.md) - - 基础组件 - - [button](js-components-basic-button.md) - - [chart](js-components-basic-chart.md) - - [divider](js-components-basic-divider.md) - - [image](js-components-basic-image.md) - - [image-animator](js-components-basic-image-animator.md) - - [input](js-components-basic-input.md) - - [label](js-components-basic-label.md) - - [marquee](js-components-basic-marquee.md) - - [menu](js-components-basic-menu.md) - - [option](js-components-basic-option.md) - - [picker](js-components-basic-picker.md) - - [picker-view](js-components-basic-picker-view.md) - - [piece](js-components-basic-piece.md) - - [progress](js-components-basic-progress.md) - - [qrcode](js-components-basic-qrcode.md) - - [rating](js-components-basic-rating.md) - - [richtext](js-components-basic-richtext.md) - - [search](js-components-basic-search.md) - - [select](js-components-basic-select.md) - - [slider](js-components-basic-slider.md) - - [span](js-components-basic-span.md) - - [switch](js-components-basic-switch.md) - - [text](js-components-basic-text.md) - - [textarea](js-components-basic-textarea.md) - - [toolbar](js-components-basic-toolbar.md) - - [toolbar-item](js-components-basic-toolbar-item.md) - - [toggle](js-components-basic-toggle.md) - - [web](js-components-basic-web.md) - - [xcomponent](js-components-basic-xcomponent.md) - - 媒体组件 - - [video](js-components-media-video.md) - - 画布组件 - - [canvas组件](js-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) - - [Image对象](js-components-canvas-image.md) - - [CanvasGradient对象](js-components-canvas-canvasgradient.md) - - [ImageData对象](js-components-canvas-imagedata.md) - - [Path2D对象](js-components-canvas-path2d.md) - - [ImageBitmap对象](js-components-canvas-imagebitmap.md) - - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) - - æ …æ ¼ç»„ä»¶ - - [基本概念](js-components-grid-basic-concepts.md) - - [grid-container](js-components-grid-container.md) - - [grid-row](js-components-grid-row.md) - - [grid-col](js-components-grid-col.md) - - svg组件 - - [通用属性](js-components-svg-common-attributes.md) - - [svg](js-components-svg.md) - - [rect](js-components-svg-rect.md) - - [circle](js-components-svg-circle.md) - - [ellipse](js-components-svg-ellipse.md) - - [path](js-components-svg-path.md) - - [line](js-components-svg-line.md) - - [polyline](js-components-svg-polyline.md) - - [polygon](js-components-svg-polygon.md) - - [text](js-components-svg-text.md) - - [tspan](js-components-svg-tspan.md) - - [textPath](js-components-svg-textpath.md) - - [animate](js-components-svg-animate.md) - - [animateMotion](js-components-svg-animatemotion.md) - - [animateTransform](js-components-svg-animatetransform.md) +- ç»„ä»¶é€šç”¨ä¿¡æ¯ + - [通用属性](js-components-common-attributes.md) + - [é€šç”¨æ ·å¼](js-components-common-styles.md) + - [通用事件](js-components-common-events.md) + - [通用方法](js-components-common-methods.md) + - [åŠ¨ç”»æ ·å¼](js-components-common-animation.md) + - [æ¸å˜æ ·å¼](js-components-common-gradient.md) + - [è½¬åœºæ ·å¼](js-components-common-transition.md) + - [媒体查询](js-components-common-mediaquery.md) + - [自定义å—ä½“æ ·å¼](js-components-common-customizing-font.md) + - [原å布局](js-components-common-atomic-layout.md) +- 容器组件 + - [badge](js-components-container-badge.md) + - [dialog](js-components-container-dialog.md) + - [div](js-components-container-div.md) + - [form](js-components-container-form.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [list-item-group](js-components-container-list-item-group.md) + - [panel](js-components-container-panel.md) + - [popup](js-components-container-popup.md) + - [refresh](js-components-container-refresh.md) + - [stack](js-components-container-stack.md) + - [stepper](js-components-container-stepper.md) + - [stepper-item](js-components-container-stepper-item.md) + - [swiper](js-components-container-swiper.md) + - [tabs](js-components-container-tabs.md) + - [tab-bar](js-components-container-tab-bar.md) + - [tab-content](js-components-container-tab-content.md) +- 基础组件 + - [button](js-components-basic-button.md) + - [chart](js-components-basic-chart.md) + - [divider](js-components-basic-divider.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [label](js-components-basic-label.md) + - [marquee](js-components-basic-marquee.md) + - [menu](js-components-basic-menu.md) + - [option](js-components-basic-option.md) + - [picker](js-components-basic-picker.md) + - [picker-view](js-components-basic-picker-view.md) + - [piece](js-components-basic-piece.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [rating](js-components-basic-rating.md) + - [richtext](js-components-basic-richtext.md) + - [search](js-components-basic-search.md) + - [select](js-components-basic-select.md) + - [slider](js-components-basic-slider.md) + - [span](js-components-basic-span.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) + - [textarea](js-components-basic-textarea.md) + - [toolbar](js-components-basic-toolbar.md) + - [toolbar-item](js-components-basic-toolbar-item.md) + - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) + - [xcomponent](js-components-basic-xcomponent.md) +- 媒体组件 + - [video](js-components-media-video.md) +- 画布组件 + - [canvas组件](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](js-components-canvas-image.md) + - [CanvasGradient对象](js-components-canvas-canvasgradient.md) + - [ImageData对象](js-components-canvas-imagedata.md) + - [Path2D对象](js-components-canvas-path2d.md) + - [ImageBitmap对象](js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) +- æ …æ ¼ç»„ä»¶ + - [基本概念](js-components-grid-basic-concepts.md) + - [grid-container](js-components-grid-container.md) + - [grid-row](js-components-grid-row.md) + - [grid-col](js-components-grid-col.md) +- svg组件 + - [通用属性](js-components-svg-common-attributes.md) + - [svg](js-components-svg.md) + - [rect](js-components-svg-rect.md) + - [circle](js-components-svg-circle.md) + - [ellipse](js-components-svg-ellipse.md) + - [path](js-components-svg-path.md) + - [line](js-components-svg-line.md) + - [polyline](js-components-svg-polyline.md) + - [polygon](js-components-svg-polygon.md) + - [text](js-components-svg-text.md) + - [tspan](js-components-svg-tspan.md) + - [textPath](js-components-svg-textpath.md) + - [animate](js-components-svg-animate.md) + - [animateMotion](js-components-svg-animatemotion.md) + - [animateTransform](js-components-svg-animatetransform.md) + + - 自定义组件 - [基本用法](js-components-custom-basic-usage.md) - [ç»§æ‰¿æ ·å¼](js-components-custom-style.md) @@ -101,5 +102,4 @@ - [事件å‚æ•°](js-components-custom-event-parameter.md) - [slotæ’槽](js-components-custom-slot.md) - [生命周期定义](js-components-custom-lifecycle.md) -- 附录 - - [类型说明](js-appendix-types.md) +- [æ•°æ®ç±»åž‹è¯´æ˜Ž](js-appendix-types.md) diff --git a/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md b/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md index 27c952f8c6c970bfa4cb427dd22baec0e61db6f4..db674a87f14740cceb8380d62bf20433b982632d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md +++ b/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md @@ -1,4 +1,4 @@ -# 类型说明 +# æ•°æ®ç±»åž‹è¯´æ˜Ž ## 长度类型 @@ -10,8 +10,8 @@ ## 颜色类型 -| å称 | 类型定义 | æè¿° | -| ----- | --------------------- | ---------------------------------------- | +| å称 | 类型定义 | æè¿° | +| ----- | --------------------------- | ---------------------------------------- | | color | string \| 颜色枚举å—符串 | 用于æ述颜色信æ¯ï¼ŒJS脚本ä¸ä¸æ”¯æŒé¢œè‰²æžšä¸¾æ ¼å¼ã€‚<br/>å—ç¬¦ä¸²æ ¼å¼å¦‚下:<br/>- 'rgb(255, 255, 255)'<br/>- 'rgba(255, 255, 255, 1.0)'<br/>- HEXæ ¼å¼ï¼š'\#rrggbb','\#aarrggbb'<br/>- æžšä¸¾æ ¼å¼ï¼š'black','white'。 | **表1** 当å‰æ”¯æŒçš„颜色枚举 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md index 737797a239fb7a7789d0fbb7633aae75dd156e28..7e4751d2b207bc43d252d3a36e6dfdf6eea1d9d4 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md @@ -18,7 +18,7 @@ ## 属性 -除支æŒ[通用属性](../arkui-js/js-components-common-attributes.md)外,还支æŒå¦‚下属性:↵ +除支æŒ[通用属性](../arkui-js/js-components-common-attributes.md)外,还支æŒå¦‚下属性: | å称 | 类型 | 默认值 | å¿…å¡« | æè¿° | | ---- | ------ | ---- | ---- | ---------------------------------------- | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md index 7e15c7fe8db6ac15a3fde659c8e29b101e49f435..a8b786f7d2b8bb5449a63effabe5d92533ff81e3 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md @@ -22,7 +22,7 @@ addColorStop(offset: number, color: string): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> <input type="button" style="width: 180px; height: 60px;" value="fillStyle"onclick="handleClick" /> </div> ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index 0c9b90fb19dfb7a42fb73f97f786d72966fe03fa..51aa4618b3bd86def22292491ef4c056c513fb0f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -1777,7 +1777,7 @@ getImageData(sx: number, sy: number, sw: number, sh: number): Object ```html <!-- xxx.hml --> <div> - <canvas style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> + <canvas id="getImageData" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -1813,7 +1813,7 @@ putImageData(imageData: Object, dx: number, dy: number, dirtyX: number, dirtyY: ```html <!-- xxx.hml --> <div> - <canvas style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> + <canvas id="getImageData" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md index b5921f229cf767b55c435695fc43e11c6090a649..803ca487efb7fb7c181a7d975828f5c0319c7765 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md @@ -21,7 +21,7 @@ addPath(path: Object): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 500px; height: 500px; background-color: #ffff00;"></canvas> </div> ``` @@ -61,7 +61,7 @@ setTransform(scaleX: number, skewX: number, skewY: number, scaleY: number, trans ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -91,7 +91,7 @@ closePath(): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -130,7 +130,7 @@ moveTo(x: number, y: number): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 300px; height: 250px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 300px; height: 250px; background-color: #ffff00;"></canvas> </div> ``` @@ -169,7 +169,7 @@ lineTo(x: number, y: number): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 400px; height: 450px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 400px; height: 450px; background-color: #ffff00;"></canvas> </div> ``` @@ -213,7 +213,7 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -252,7 +252,7 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -293,7 +293,7 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -332,7 +332,7 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 200px; height: 150px; background-color: #ffff00;"></canvas> </div> ``` @@ -374,7 +374,7 @@ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 500px; height: 450px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 500px; height: 450px; background-color: #ffff00;"></canvas> </div> ``` @@ -412,7 +412,7 @@ rect(x: number, y: number, width: number, height: number): void ```html <!-- xxx.hml --> <div> - <canvas ref="canvas" style="width: 500px; height: 450px; background-color: #ffff00;"</canvas> + <canvas ref="canvas" style="width: 500px; height: 450px; background-color: #ffff00;"></canvas> </div> ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md index f421cec1de41e922c2576f6f306436f38facd00d..52930bd935d7e69a83d3253121154cf869c91f33 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md @@ -77,6 +77,7 @@ display: flex; justify-content: center; align-items: center; + margin: 150px; } .rect{ width: 200px; @@ -92,7 +93,7 @@ } /* å¯ä»¥é€šè¿‡ç™¾åˆ†æ¯”指定动画è¿è¡Œçš„ä¸é—´çŠ¶æ€ */ 50% { - background-color: \#f76160; + background-color: #f76160; transform:translate(100px) rotate(60deg) scale(1.3); } to { diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index ee8b4a65a998809b645117db9d2bf04101b48e38..67e55748dcf4baf58b5df617cc9bd0300baab7a0 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -49,6 +49,8 @@ PageA跳转到PageBï¼Œè·³è½¬çš„å…±äº«å…ƒç´ ä¸ºimage, shareid为“shareImage <list> <list-item type="description"> <image src="item.jpg" shareid="shareImage" onclick="jump" class="shared-transition-style"></image> + </list-item> + <list-item> <text onclick="jump">Click on picture to Jump to ths details</text> </list-item> </list> @@ -61,7 +63,8 @@ import router from '@system.router'; export default { jump() { router.push({ - uri: 'detailpage', + // 路径è¦ä¸Žconfig.jsoné…置里é¢çš„ç›¸åŒ + uri: 'pages/detailpage', }); }, } diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md index 3e98506602702595eb6a35d279b688fc470a9315..4df75ebf6511acbe66d25da3d0f012541c8bdee9 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md @@ -94,10 +94,10 @@ <div class="container"> <svg> <text y="50" font-size="30" fill="blue"> + text attribute x|opacity|rotate <animate attributeName="x" from="100" by="400" dur="3s" repeatCount="indefinite"></animate> <animate attributeName="opacity" from="0.01" to="0.99" dur="3s" repeatCount="indefinite"></animate> <animate attributeName="rotate" from="0" to="360" dur="3s" repeatCount="indefinite"></animate> - text attribute x|opacity|rotate </text> </svg> </div> diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index cb447c2fb3dfad40c9c212822e9727e29d2ee66d..1695c7d920128c10e0d842c1dfe1a174bc5aa3bc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -1,136 +1,139 @@ # 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ -- 组件 - - 通用 - - 通用事件 - - [点击事件](ts-universal-events-click.md) - - [触摸事件](ts-universal-events-touch.md) - - [挂载å¸è½½äº‹ä»¶](ts-universal-events-show-hide.md) - - [拖拽事件](ts-universal-events-drag-drop.md) - - [按键事件](ts-universal-events-key.md) - - [焦点事件](ts-universal-focus-event.md) - - [é¼ æ ‡äº‹ä»¶](ts-universal-mouse-key.md) - - [组件区域å˜åŒ–事件](ts-universal-component-area-change-event.md) - - 通用属性 - - [尺寸设置](ts-universal-attributes-size.md) - - [ä½ç½®è®¾ç½®](ts-universal-attributes-location.md) - - [布局约æŸ](ts-universal-attributes-layout-constraints.md) - - [Flex布局](ts-universal-attributes-flex-layout.md) - - [边框设置](ts-universal-attributes-border.md) - - [图片边框设置](ts-universal-attributes-border-image.md) - - [背景设置](ts-universal-attributes-background.md) - - [é€æ˜Žåº¦è®¾ç½®](ts-universal-attributes-opacity.md) - - [显éšæŽ§åˆ¶](ts-universal-attributes-visibility.md) - - [ç¦ç”¨æŽ§åˆ¶](ts-universal-attributes-enable.md) - - [浮层](ts-universal-attributes-overlay.md) - - [ZåºæŽ§åˆ¶](ts-universal-attributes-z-order.md) - - [图形å˜æ¢](ts-universal-attributes-transformation.md) - - [图åƒæ•ˆæžœ](ts-universal-attributes-image-effect.md) - - [形状è£å‰ª](ts-universal-attributes-sharp-clipping.md) - - [æ–‡æœ¬æ ·å¼è®¾ç½®](ts-universal-attributes-text-style.md) - - [æ …æ ¼è®¾ç½®](ts-universal-attributes-grid.md) - - [颜色æ¸å˜](ts-universal-attributes-gradient-color.md) - - [Popup控制](ts-universal-attributes-popup.md) - - [Menu控制](ts-universal-attributes-menu.md) - - [点击控制](ts-universal-attributes-click.md) - - [焦点控制](ts-universal-attributes-focus.md) - - [悬浮æ€æ•ˆæžœ](ts-universal-attributes-hover-effect.md) - - [ç»„ä»¶æ ‡è¯†](ts-universal-attributes-component-id.md) - - [触摸çƒåŒºè®¾ç½®](ts-universal-attributes-touch-target.md) - - [多æ€æ ·å¼](ts-universal-attributes-polymorphic-style.md) - - æ‰‹åŠ¿å¤„ç† - - [绑定手势方法](ts-gesture-settings.md) - - 基础手势 - - [TapGesture](ts-basic-gestures-tapgesture.md) - - [LongPressGesture](ts-basic-gestures-longpressgesture.md) - - [PanGesture](ts-basic-gestures-pangesture.md) - - [PinchGesture](ts-basic-gestures-pinchgesture.md) - - [RotationGesture](ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](ts-basic-gestures-swipegesture.md) - - [组åˆæ‰‹åŠ¿](ts-combined-gestures.md) - - 基础组件 - - [Blank](ts-basic-components-blank.md) - - [Button](ts-basic-components-button.md) - - [Checkbox](ts-basic-components-checkbox.md) - - [CheckboxGroup](ts-basic-components-checkboxgroup.md) - - [DataPanel](ts-basic-components-datapanel.md) - - [DatePicker](ts-basic-components-datepicker.md) - - [Divider](ts-basic-components-divider.md) - - [Gauge](ts-basic-components-gauge.md) - - [Image](ts-basic-components-image.md) - - [ImageAnimator](ts-basic-components-imageanimator.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) - - [Marquee](ts-basic-components-marquee.md) - - [Navigation](ts-basic-components-navigation.md) - - [PatternLock](ts-basic-components-patternlock.md) - - [PluginComponent](ts-basic-components-plugincomponent.md) - - [Progress](ts-basic-components-progress.md) - - [QRCode](ts-basic-components-qrcode.md) - - [Radio](ts-basic-components-radio.md) - - [Rating](ts-basic-components-rating.md) - - [RichText](ts-basic-components-richtext.md) - - [ScrollBar](ts-basic-components-scrollbar.md) - - [Search](ts-basic-components-search.md) - - [Select](ts-basic-components-select.md) - - [Slider](ts-basic-components-slider.md) - - [Span](ts-basic-components-span.md) - - [Stepper](ts-basic-components-stepper.md) - - [StepperItem](ts-basic-components-stepperitem.md) - - [Text](ts-basic-components-text.md) - - [TextArea](ts-basic-components-textarea.md) - - [TextClock](ts-basic-components-textclock.md) - - [TextInput](ts-basic-components-textinput.md) - - [TextPicker](ts-basic-components-textpicker.md) - - [TextTimer](ts-basic-components-texttimer.md) - - [TimePicker](ts-basic-components-timepicker.md) - - [Toggle](ts-basic-components-toggle.md) - - [Web](ts-basic-components-web.md) - - [XComponent](ts-basic-components-xcomponent.md) - - 容器组件 - - [AbilityComponent](ts-container-ability-component.md) - - [AlphabetIndexer](ts-container-alphabet-indexer.md) - - [Badge](ts-container-badge.md) - - [Column](ts-container-column.md) - - [ColumnSplit](ts-container-columnsplit.md) - - [Counter](ts-container-counter.md) - - [Flex](ts-container-flex.md) - - [GridContainer](ts-container-gridcontainer.md) - - [Grid](ts-container-grid.md) - - [GridItem](ts-container-griditem.md) - - [List](ts-container-list.md) - - [ListItem](ts-container-listitem.md) - - [Navigator](ts-container-navigator.md) - - [Panel](ts-container-panel.md) - - [Refresh](ts-container-refresh.md) - - [RelativeContainer](ts-container-relativecontainer.md) - - [Row](ts-container-row.md) - - [RowSplit](ts-container-rowsplit.md) - - [Scroll](ts-container-scroll.md) - - [SideBarContainer](ts-container-sidebarcontainer.md) - - [Stack](ts-container-stack.md) - - [Swiper](ts-container-swiper.md) - - [Tabs](ts-container-tabs.md) - - [TabContent](ts-container-tabcontent.md) - - 媒体组件 - - [Video](ts-media-components-video.md) - - 绘制组件 - - [Circle](ts-drawing-components-circle.md) - - [Ellipse](ts-drawing-components-ellipse.md) - - [Line](ts-drawing-components-line.md) - - [Polyline](ts-drawing-components-polyline.md) - - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) - - [Rect](ts-drawing-components-rect.md) - - [Shape](ts-drawing-components-shape.md) - - 画布组件 - - [Canvas](ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D对象](ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](ts-components-canvas-lottie.md) - - [Path2D对象](ts-components-canvas-path2d.md) - - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) - - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) - - [ImageData对象](ts-components-canvas-imagedata.md) +- ç»„ä»¶é€šç”¨ä¿¡æ¯ + - 通用事件 + - [点击事件](ts-universal-events-click.md) + - [触摸事件](ts-universal-events-touch.md) + - [挂载å¸è½½äº‹ä»¶](ts-universal-events-show-hide.md) + - [拖拽事件](ts-universal-events-drag-drop.md) + - [按键事件](ts-universal-events-key.md) + - [焦点事件](ts-universal-focus-event.md) + - [é¼ æ ‡äº‹ä»¶](ts-universal-mouse-key.md) + - [组件区域å˜åŒ–事件](ts-universal-component-area-change-event.md) + - [组件å¯è§åŒºåŸŸå˜åŒ–事件](ts-universal-component-visible-area-change-event.md) + - 通用属性 + - [尺寸设置](ts-universal-attributes-size.md) + - [ä½ç½®è®¾ç½®](ts-universal-attributes-location.md) + - [布局约æŸ](ts-universal-attributes-layout-constraints.md) + - [Flex布局](ts-universal-attributes-flex-layout.md) + - [边框设置](ts-universal-attributes-border.md) + - [图片边框设置](ts-universal-attributes-border-image.md) + - [背景设置](ts-universal-attributes-background.md) + - [é€æ˜Žåº¦è®¾ç½®](ts-universal-attributes-opacity.md) + - [显éšæŽ§åˆ¶](ts-universal-attributes-visibility.md) + - [ç¦ç”¨æŽ§åˆ¶](ts-universal-attributes-enable.md) + - [浮层](ts-universal-attributes-overlay.md) + - [ZåºæŽ§åˆ¶](ts-universal-attributes-z-order.md) + - [图形å˜æ¢](ts-universal-attributes-transformation.md) + - [图åƒæ•ˆæžœ](ts-universal-attributes-image-effect.md) + - [形状è£å‰ª](ts-universal-attributes-sharp-clipping.md) + - [æ–‡æœ¬æ ·å¼è®¾ç½®](ts-universal-attributes-text-style.md) + - [æ …æ ¼è®¾ç½®](ts-universal-attributes-grid.md) + - [颜色æ¸å˜](ts-universal-attributes-gradient-color.md) + - [Popup控制](ts-universal-attributes-popup.md) + - [Menu控制](ts-universal-attributes-menu.md) + - [点击控制](ts-universal-attributes-click.md) + - [焦点控制](ts-universal-attributes-focus.md) + - [悬浮æ€æ•ˆæžœ](ts-universal-attributes-hover-effect.md) + - [ç»„ä»¶æ ‡è¯†](ts-universal-attributes-component-id.md) + - [触摸çƒåŒºè®¾ç½®](ts-universal-attributes-touch-target.md) + - [多æ€æ ·å¼](ts-universal-attributes-polymorphic-style.md) + - æ‰‹åŠ¿å¤„ç† + - [绑定手势方法](ts-gesture-settings.md) + - 基础手势 + - [TapGesture](ts-basic-gestures-tapgesture.md) + - [LongPressGesture](ts-basic-gestures-longpressgesture.md) + - [PanGesture](ts-basic-gestures-pangesture.md) + - [PinchGesture](ts-basic-gestures-pinchgesture.md) + - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) + - [组åˆæ‰‹åŠ¿](ts-combined-gestures.md) +- 基础组件 + - [Blank](ts-basic-components-blank.md) + - [Button](ts-basic-components-button.md) + - [Checkbox](ts-basic-components-checkbox.md) + - [CheckboxGroup](ts-basic-components-checkboxgroup.md) + - [DataPanel](ts-basic-components-datapanel.md) + - [DatePicker](ts-basic-components-datepicker.md) + - [Divider](ts-basic-components-divider.md) + - [Gauge](ts-basic-components-gauge.md) + - [Image](ts-basic-components-image.md) + - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Marquee](ts-basic-components-marquee.md) + - [Navigation](ts-basic-components-navigation.md) + - [PatternLock](ts-basic-components-patternlock.md) + - [PluginComponent](ts-basic-components-plugincomponent.md) + - [Progress](ts-basic-components-progress.md) + - [QRCode](ts-basic-components-qrcode.md) + - [Radio](ts-basic-components-radio.md) + - [Rating](ts-basic-components-rating.md) + - [RemoteWindow](ts-basic-components-remotewindow.md) + - [RichText](ts-basic-components-richtext.md) + - [ScrollBar](ts-basic-components-scrollbar.md) + - [Search](ts-basic-components-search.md) + - [Select](ts-basic-components-select.md) + - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) + - [Stepper](ts-basic-components-stepper.md) + - [StepperItem](ts-basic-components-stepperitem.md) + - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextClock](ts-basic-components-textclock.md) + - [TextInput](ts-basic-components-textinput.md) + - [TextPicker](ts-basic-components-textpicker.md) + - [TextTimer](ts-basic-components-texttimer.md) + - [TimePicker](ts-basic-components-timepicker.md) + - [Toggle](ts-basic-components-toggle.md) + - [Web](ts-basic-components-web.md) + - [XComponent](ts-basic-components-xcomponent.md) +- 容器组件 + - [AbilityComponent](ts-container-ability-component.md) + - [AlphabetIndexer](ts-container-alphabet-indexer.md) + - [Badge](ts-container-badge.md) + - [Column](ts-container-column.md) + - [ColumnSplit](ts-container-columnsplit.md) + - [Counter](ts-container-counter.md) + - [Flex](ts-container-flex.md) + - [GridContainer](ts-container-gridcontainer.md) + - [Grid](ts-container-grid.md) + - [GridItem](ts-container-griditem.md) + - [List](ts-container-list.md) + - [ListItem](ts-container-listitem.md) + - [Navigator](ts-container-navigator.md) + - [Panel](ts-container-panel.md) + - [Refresh](ts-container-refresh.md) + - [RelativeContainer](ts-container-relativecontainer.md) + - [Row](ts-container-row.md) + - [RowSplit](ts-container-rowsplit.md) + - [Scroll](ts-container-scroll.md) + - [SideBarContainer](ts-container-sidebarcontainer.md) + - [Stack](ts-container-stack.md) + - [Swiper](ts-container-swiper.md) + - [Tabs](ts-container-tabs.md) + - [TabContent](ts-container-tabcontent.md) +- 媒体组件 + - [Video](ts-media-components-video.md) +- 绘制组件 + - [Circle](ts-drawing-components-circle.md) + - [Ellipse](ts-drawing-components-ellipse.md) + - [Line](ts-drawing-components-line.md) + - [Polyline](ts-drawing-components-polyline.md) + - [Polygon](ts-drawing-components-polygon.md) + - [Path](ts-drawing-components-path.md) + - [Rect](ts-drawing-components-rect.md) + - [Shape](ts-drawing-components-shape.md) +- 画布组件 + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D对象](ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](ts-components-canvas-lottie.md) + - [Path2D对象](ts-components-canvas-path2d.md) + - [CanvasGradient对象](ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](ts-components-canvas-imagebitmap.md) + - [ImageData对象](ts-components-canvas-imagedata.md) + + - 动画 - [属性动画](ts-animatorproperty.md) - [显å¼åŠ¨ç”»](ts-explicit-animation.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.png b/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.png index a111a8e4ed06adf129c010801d10880a22018b25..22285e0910e3c447036d2144194a2e4301c2df6f 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.png and b/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/borderImageGradient.png b/zh-cn/application-dev/reference/arkui-ts/figures/borderImageGradient.png new file mode 100644 index 0000000000000000000000000000000000000000..edf91d4844deeee4f997f65d2d88b45bf7ff7f1d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/borderImageGradient.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/075424f4-e9d4-4b96-93a9-22d80f31e316 .png b/zh-cn/application-dev/reference/arkui-ts/figures/focus.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-ts/figures/075424f4-e9d4-4b96-93a9-22d80f31e316 .png rename to zh-cn/application-dev/reference/arkui-ts/figures/focus.png diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982705.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982705.gif index e5566aaf94677c85c889362eedefc2ce484ed9d5..794e6fea1ccbe37ea7bac2dc93b57333fa412ead 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982705.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219982705.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg index b12c5fb6563c7ee9d8dfa7e6af1cfe1dcfa1361c..e5af4f50ebd9bdab6af30219f30fdf948a019a52 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001236876377.jpg differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif index 6b44b6a2adc2528e13e95bc10d2a67874226a63b..96afd9a948c90e22cd52ab4c55218bf97591b3ec 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md index efd45c871b0b9a7f4c34f503bc76a67ae763646f..88a5ed06137d53013fc251ef068033a6623feb0a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -31,7 +31,7 @@ Blank(min?: Length) | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| color | Color | 0x00000000 | 设置空白填充的填充颜色。 | +| color | [ResourceColor](../../ui/ts-types.md) | 0x00000000 | 设置空白填充的填充颜色。 | > **说明:** > - ä¸æ”¯æŒé€šç”¨å±žæ€§æ–¹æ³•ã€‚ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md index 27ac9a92677ae717972bb9a7e759189f78d157f0..8c92eb8a03de16824b0511d0c54415106396aa1c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -3,7 +3,7 @@ 按钮组件,å¯å¿«é€Ÿåˆ›å»ºä¸åŒæ ·å¼çš„按钮。 > **说明:** -> 该组件从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> 该组件从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 ## æƒé™åˆ—表 @@ -21,44 +21,44 @@ - Button(options?: {type?: ButtonType, stateEffect?: boolean}) **表1** optionså‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | -------- | -------- | -------- | -------- | -------- | - | type | ButtonType | å¦ | Capsule | æè¿°æŒ‰é’®é£Žæ ¼ã€‚ | - | stateEffect | boolean | å¦ | true | 按钮按下时是å¦å¼€å¯åˆ‡æ¢æ•ˆæžœï¼Œå½“状æ€ç½®ä¸ºfalse时,点击效果关é—。 | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | ----------- | ---------- | ---- | ------- | --------------------------------- | + | type | ButtonType | å¦ | Capsule | æè¿°æŒ‰é’®é£Žæ ¼ã€‚ | + | stateEffect | boolean | å¦ | true | 按钮按下时是å¦å¼€å¯åˆ‡æ¢æ•ˆæžœï¼Œå½“状æ€ç½®ä¸ºfalse时,点击效果关é—。 | -- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean }) + +- Button(label?: ResourceStr, options?: { type?: ButtonType, stateEffect?: boolean }) 使用文本内容创建相应的按钮组件,æ¤æ—¶Buttonæ— æ³•åŒ…å«å组件。 **表2** valueå‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | -------- | -------- | -------- | -------- | -------- | - | label | string | å¦ | - | 按钮文本内容。 | - | options | Object | å¦ | - | è§optionså‚数说明。 | + + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | ------- | ----------------------------------- | ---- | ---- | ------------- | + | label | [ResourceStr](../../ui/ts-types.md) | å¦ | - | 按钮文本内容。 | + | options | Object | å¦ | - | è§optionså‚数说明。 | ## 属性 -| å称 | å‚数类型 | 默认值 | æè¿° | -| -------- | -------- | -------- | -------- | -| type | ButtonType | Capsule | 设置Buttonæ ·å¼ã€‚ | -| stateEffect | boolean | true | 状æ€åˆ‡æ¢æ—¶æ˜¯å¦å¼€å¯åˆ‡æ¢æ•ˆæžœï¼Œå½“状æ€ç½®ä¸ºfalse时,点击效果关é—。 | +| å称 | å‚数类型 | 默认值 | æè¿° | +| ----------- | ---------- | ------- | --------------------------------- | +| type | ButtonType | Capsule | 设置Buttonæ ·å¼ã€‚ | +| stateEffect | boolean | true | 状æ€åˆ‡æ¢æ—¶æ˜¯å¦å¼€å¯åˆ‡æ¢æ•ˆæžœï¼Œå½“状æ€ç½®ä¸ºfalse时,点击效果关é—。 | - ButtonType枚举说明 - | å称 | æè¿° | - | -------- | -------- | + | å称 | æè¿° | + | ------- | ------------------ | | Capsule | 胶囊型按钮(圆角默认为高度的一åŠï¼‰ã€‚ | - | Circle | 圆形按钮。 | - | Normal | 普通按钮(默认ä¸å¸¦åœ†è§’)。 | + | Circle | 圆形按钮。 | + | Normal | 普通按钮(默认ä¸å¸¦åœ†è§’)。 | > **说明:** -> - 按钮圆角通过[通用属性borderRadius设置](ts-universal-attributes-border.md)(ä¸æ”¯æŒé€šè¿‡border接å£è®¾ç½®åœ†è§’)。 -> - 当按钮类型为Capsule时,borderRadius设置ä¸ç”Ÿæ•ˆï¼ŒæŒ‰é’®åœ†è§’始终为高度的一åŠã€‚ -> - 当按钮类型为Circle时,borderRadiuså³ä¸ºæŒ‰é’®åŠå¾„,若未设置borderRadius按钮åŠå¾„则为宽ã€é«˜ä¸è¾ƒå°å€¼çš„一åŠã€‚ -> - 按钮文本通过[é€šç”¨æ–‡æœ¬æ ·å¼](ts-universal-attributes-text-style.md)进行设置。 +> - 按钮圆角通过[通用属性borderRadius设置](ts-universal-attributes-border.md)(ä¸æ”¯æŒé€šè¿‡border接å£è®¾ç½®åœ†è§’)。 +> - 当按钮类型为Capsule时,borderRadius设置ä¸ç”Ÿæ•ˆï¼ŒæŒ‰é’®åœ†è§’始终为高度的一åŠã€‚ +> - 当按钮类型为Circle时,borderRadiuså³ä¸ºæŒ‰é’®åŠå¾„,若未设置borderRadius按钮åŠå¾„则为宽ã€é«˜ä¸è¾ƒå°å€¼çš„一åŠã€‚ +> - 按钮文本通过[é€šç”¨æ–‡æœ¬æ ·å¼](ts-universal-attributes-text-style.md)进行设置。 ## 示例 @@ -75,6 +75,7 @@ struct ButtonExample { Button('Ok', { type: ButtonType.Normal, stateEffect: true }).borderRadius(8).backgroundColor(0x317aff).width(90) Button({ type: ButtonType.Normal, stateEffect: true }) { Row() { + // 图片建议通过$r创建Resource对象引入 Image($r('app.media.loading')).width(20).height(20).margin({ left: 12 }) Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 }) }.alignItems(VerticalAlign.Center) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index ed99d0137cd965b927013eda6897a0ee0040d528..1eb4e1283c1c98c888489b5dbfa1e75ae33d488d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -53,45 +53,47 @@ CheckboxGroup( group?: string ) @Entry @Component struct CheckboxExample { - build() { Scroll() { Column() { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - CheckboxGroup({group : 'checkboxGroup'}) - .selectedColor(0xed6f21) - .onChange((itemName:CheckboxGroupResult) => { - console.info("TextPicker::dialogResult is" + JSON.stringify(itemName)) - }) - Text('select all').fontSize(20) - } - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) - .select(true) - .selectedColor(0x39a2db) - .onChange((value: boolean) => { - console.info('Checkbox1 change is' + value) - }) - Text('Checkbox1').fontSize(20) - } - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) - .select(false) - .selectedColor(0x39a2db) - .onChange((value: boolean) => { - console.info('Checkbox2 change is' + value) - }) - Text('Checkbox2').fontSize(20) - } - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) - .select(true) - .selectedColor(0x39a2db) - .onChange((value: boolean) => { - console.info('Checkbox3 change is' + value) - }) - Text('Checkbox3').fontSize(20) - } + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CheckboxGroup({ group: 'checkboxGroup' }) + .selectedColor(0xed6f21) + .onChange((itemName: CheckboxGroupResult) => { + console.info("TextPicker::dialogResult is" + JSON.stringify(itemName)) + }) + Text('select all').fontSize(20) + } + + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) + .select(true) + .selectedColor(0x39a2db) + .onChange((value: boolean) => { + console.info('Checkbox1 change is' + value) + }) + Text('Checkbox1').fontSize(20) + } + + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) + .select(false) + .selectedColor(0x39a2db) + .onChange((value: boolean) => { + console.info('Checkbox2 change is' + value) + }) + Text('Checkbox2').fontSize(20) + } + + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) + .select(true) + .selectedColor(0x39a2db) + .onChange((value: boolean) => { + console.info('Checkbox3 change is' + value) + }) + Text('Checkbox3').fontSize(20) + } } } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index c2d7304ceeedfb3237be0b2dbdaa5897d869a6b5..c38f05907fb98fc1832fb1f482fe9953460a8f59 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -34,9 +34,9 @@ Image(src: string | PixelMap | Resource) **å‚数:** -| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| ------ | ------------------------------------------------------------ | ---- | ------ | ------------------------------------------------------------ | -| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](../../ui/ts-types.md#resource类型) | 是 | - | 图片的数æ®æºï¼Œæ”¯æŒæœ¬åœ°å›¾ç‰‡å’Œç½‘络图片。<br/>当使用相对路径引用图片资æºæ—¶ï¼Œä¾‹å¦‚`Image("common/test.jpg")`,ä¸æ”¯æŒè¯¥Image组件被跨包/跨模å—调用,建议使用`$r`æ–¹å¼æ¥ç®¡ç†éœ€å…¨å±€ä½¿ç”¨çš„图片资æºã€‚<br/>\- 支æŒçš„å›¾ç‰‡æ ¼å¼åŒ…括pngã€jpgã€bmpã€svgå’Œgif。<br/>\- 支æŒ`Base64`å—ç¬¦ä¸²ã€‚æ ¼å¼`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, å…¶ä¸`[base64 data]`为`Base64`å—符串数æ®ã€‚<br/>\- 支æŒ`dataability://`路径å‰ç¼€çš„å—符串,用于访问通过data abilityæ供的图片路径。 | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | +| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](../../ui/ts-types.md#resource类型) | 是 | - | 图片的数æ®æºï¼Œæ”¯æŒæœ¬åœ°å›¾ç‰‡å’Œç½‘络图片。<br/>当使用相对路径引用图片资æºæ—¶ï¼Œä¾‹å¦‚`Image("common/test.jpg")`,ä¸æ”¯æŒè¯¥Image组件被跨包/跨模å—调用,建议使用`$r`æ–¹å¼æ¥ç®¡ç†éœ€å…¨å±€ä½¿ç”¨çš„图片资æºã€‚<br/>\- 支æŒçš„å›¾ç‰‡æ ¼å¼åŒ…括pngã€jpgã€bmpã€svgå’Œgif。<br/>\- 支æŒ`Base64`å—ç¬¦ä¸²ã€‚æ ¼å¼`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, å…¶ä¸`[base64 data]`为`Base64`å—符串数æ®ã€‚<br/>\- 支æŒ`dataability://`路径å‰ç¼€çš„å—符串,用于访问通过data abilityæ供的图片路径。 | ## 属性 @@ -45,7 +45,7 @@ Image(src: string | PixelMap | Resource) | å称 | å‚数类型 | 默认值 | æè¿° | | --------------------- | ---------------------------------------- | ------------------------ | ---------------------------------------- | | alt | string \| [Resource](../../ui/ts-types.md#resource类型) | - | åŠ è½½æ—¶æ˜¾ç¤ºçš„å ä½å›¾ï¼Œæ”¯æŒæœ¬åœ°å›¾ç‰‡å’Œç½‘络图片。 | -| objectFit | [ImageFit](#imagefit枚举说明) | ImageFit.Cover | 设置图片的缩放类型。 | +| objectFit | ImageFit | ImageFit.Cover | 设置图片的缩放类型。 | | objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | NoRepeat | 设置图片的é‡å¤æ ·å¼ã€‚<br/>> **说明:**<br/>> - svg类型图æºä¸æ”¯æŒè¯¥å±žæ€§ã€‚ | | interpolation | [ImageInterpolation](#imageinterpolation) | ImageInterpolation.None | 设置图片的æ’值效果,仅针对图片放大æ’值。<br/>> **说明:**<br/>> - svg类型图æºä¸æ”¯æŒè¯¥å±žæ€§ã€‚<br/>> - PixelMap资æºä¸æ”¯æŒè¯¥å±žæ€§ã€‚ | | renderMode | [ImageRenderMode](#imagerendermode) | ImageRenderMode.Original | 设置图片渲染的模å¼ã€‚<br/>> **说明:**<br/>> - svg类型图æºä¸æ”¯æŒè¯¥å±žæ€§ã€‚ | @@ -234,8 +234,8 @@ struct ImageExample2 { @Entry @Component struct ImageExample3 { - @State width: number = 0 - @State height: number = 0 + @State widthValue: number = 0 + @State heightValue: number = 0 private on: Resource = $r('app.media.image_on') private off: Resource = $r('app.media.image_off') private on2off: Resource = $r('app.media.image_on2off') @@ -256,8 +256,8 @@ struct ImageExample3 { .height(180).width(180) // å›¾ç‰‡åŠ è½½å®ŒæˆåŽï¼ŒèŽ·å–图片尺寸。 .onComplete((msg: { width: number,height: number }) => { - this.width = msg.width - this.height = msg.height + this.widthValue = msg.width + this.heightValue = msg.height }) .onError(() => { console.log('load image fail') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index 45c6e0a64f6076918d4cbc52da043b69b1522d6a..fc70ceca6fdedde145509690484b3fafe1a4dc93 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -88,7 +88,11 @@ struct ProgressExample { Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Row({ space: 40 }) { Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50) - Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100).height(50) + Progress({ value: 20, total: 150, type: ProgressType.Capsule }) + .color(Color.Grey) + .value(50) + .width(100) + .height(50) } }.width('100%').margin({ top: 30 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md new file mode 100644 index 0000000000000000000000000000000000000000..83968b2c31527c44783936c828ec688a41408fe6 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md @@ -0,0 +1,75 @@ +# RemoteWindow + +远程控制窗å£ç»„件,å¯ä»¥é€šè¿‡æ¤ç»„件控制应用窗å£ï¼Œæä¾›å¯åŠ¨é€€å‡ºè¿‡ç¨‹ä¸æŽ§ä»¶åŠ¨ç”»å’Œåº”用窗å£è”动动画的能力。 + +> **说明:** +> +> 该组件从API Version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> +> 该组件为系统接å£ã€‚ + +## å组件 + +ä¸å¯ä»¥åŒ…å«å组件。 + +## æŽ¥å£ + +RemoteWindow(target: WindowAnimationTarget) + +通过窗å£åŠ¨ç”»å¯¹è±¡åˆ›å»ºç»„件。 + +- å‚æ•° + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | -------- | -------- | -------- | -------- | -------- | + | target | [WindowAnimationTarget](#windowanimationtarget) | 是 | - | 需è¦æŽ§åˆ¶çš„动画窗å£çš„æ述。 | + +## WindowAnimationTarget +ç›®æ ‡çª—å£ï¼Œç”¨æ¥è¿œç¨‹æŽ§åˆ¶å®žçŽ°åŠ¨ç”»ã€‚ + +| å‚æ•° | 类型 | æè¿° | +| ------- | ------ | ----------------------- | +| bundleName | string | 动画窗å£æ‰€å¯¹åº”的进程。| +| abilityName | string | 动画窗å£æ‰€å¯¹åº”çš„Ability。| +| windowBounds | [RRect](#rrect) | 动画窗å£å®žé™…大å°ã€‚| + +## RRect +圆角矩形。 + +| å‚æ•° | 类型 | æè¿° | +| ------- | ------ | ----------------------- | +| left | number | 动画窗å£å·¦ä¸Šè§’相对于å±å¹•æ¨ªåæ ‡ã€‚| +| top | number | 动画窗å£å·¦ä¸Šè§’相对于å±å¹•çºµåæ ‡ã€‚| +| width | number | 动画窗å£å®½åº¦å¤§å°ã€‚| +| height | number | 动画窗å£é«˜åº¦å¤§å°ã€‚| +| radius | number | 动画窗å£åœ†è§’大å°ã€‚| + +## 属性 + +支æŒ[通用属性](ts-universal-attributes-size.md)。 + +## 事件 + +支æŒ[通用事件](ts-universal-events-click.md)。 + +## 示例 + +```ts +// xxx.ets +@Entry +@Component +struct RemoteWindowExample { + @State target: WindowAnimationTarget = undefined // 通过windowAnimationManagerèŽ·å– + + build() { + Column() { + RemoteWindow(this.target) + .translate({x:100, y:200}) + .scale({x:0.5, y:0.5}) + .opacity(0.8) + .position({x:px2vp(this.target?.windowBounds.left), y:px2vp(this.target?.windowBounds.top)}) + .width(px2vp(this.target?.windowBounds.width)) + .height(px2vp(this.target?.windowBounds.height)) + } + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index 0cad7bdb93a51273eddf25c96c70edfbe208e2f1..0f6bafb6ce0a4fffc2f41e93c164e3c9d41bceeb 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -48,7 +48,7 @@ RichText\(content:string\) | \<script>\</script> | 用于定义客户端文本,比如JavaScript。 | \<script>document.write("Hello World!")\</script> | ## 示例 - +示例效果请以真机è¿è¡Œä¸ºå‡†ï¼Œå½“å‰IDE预览器ä¸æ”¯æŒã€‚ ```ts // xxx.ets @Entry diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index 290c065e01ab19dda9b62fda3739171d764f6d86..b7b0543679eab4ca33d6d88e88f3ab3144f977d0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -53,16 +53,16 @@ Select(options: Array\<SelectOption\>) struct SelectExample { build() { Column() { - Select([{value:'aaa',icon: "/common/1.png"}, - {value:'bbb',icon: "/common/2.png"}, - {value:'ccc',icon: "/common/3.png"}, - {value:'ddd',icon: "/common/4.png"}]) + Select([{ value: 'aaa', icon: "/common/1.png" }, + { value: 'bbb', icon: "/common/2.png" }, + { value: 'ccc', icon: "/common/3.png" }, + { value: 'ddd', icon: "/common/4.png" }]) .selected(2) .value('TTT') - .font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal }) - .selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) - .optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) - .onSelect((index:number)=>{ + .font({ size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) + .selectedOptionFont({ size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) + .optionFont({ size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) + .onSelect((index: number) => { console.info("Select:" + index) }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index e1757785d1b091caa538b4404c87ae48a034af2d..bc01e8bd1f71a5dc8c195d937e95433b2aab3fbc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -33,39 +33,39 @@ Slider(value:{value?: number, min?: number, max?: number, step?: number, style?: | reverse<sup>8+</sup> | boolean | å¦ | false | 设置滑动æ¡å–值范围是å¦åå‘。 | - SliderStyle枚举说明 - | å称 | æè¿° | + | å称 | æè¿° | | -------- | -------- | - | OutSet | 滑å—在滑轨上。 | - | InSet | 滑å—在滑轨内。 | + | OutSet | 滑å—在滑轨上。 | + | InSet | 滑å—在滑轨内。 | ## 属性 ä¸æ”¯æŒè§¦æ‘¸çƒåŒºè®¾ç½®ã€‚ -| å称 | å‚数类型 | 默认值 | æè¿° | +| å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| blockColor | Color | - | 设置滑å—的颜色。 | -| trackColor | Color | - | 设置滑轨的背景颜色。 | -| selectedColor | Color | - | 设置滑轨的已滑动颜色。 | -| showSteps | boolean | false | 设置当å‰æ˜¯å¦æ˜¾ç¤ºæ¥é•¿åˆ»åº¦å€¼ã€‚ | -| showTips | boolean | false | 设置滑动时是å¦æ˜¾ç¤ºæ°”泡æ示百分比。 | +| blockColor | Color | - | 设置滑å—的颜色。 | +| trackColor | Color | - | 设置滑轨的背景颜色。 | +| selectedColor | Color | - | 设置滑轨的已滑动颜色。 | +| showSteps | boolean | false | 设置当å‰æ˜¯å¦æ˜¾ç¤ºæ¥é•¿åˆ»åº¦å€¼ã€‚ | +| showTips | boolean | false | 设置滑动时是å¦æ˜¾ç¤ºæ°”泡æ示百分比。 | ## 事件 通用事件仅支æŒï¼šOnAppear,OnDisAppear。 -| å称 | 功能æè¿° | +| å称 | 功能æè¿° | | -------- | -------- | -| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触å‘事件回调。<br/>value:当å‰è¿›åº¦å€¼ã€‚<br/>mode:拖动状æ€ã€‚ | +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Slider滑动时触å‘事件回调。<br/>value:当å‰è¿›åº¦å€¼ã€‚<br/>mode:拖动状æ€ã€‚ | - SliderChangeMode枚举说明 - | å称 | æè¿° | - | -------- | -------- | - | Begin | 用户开始拖动滑å—。 | - | Moving | 用户拖动滑å—ä¸ã€‚ | - | End | 用户结æŸæ‹–动滑å—。 | + | å称 | 值 | æè¿° | + | -------- | -------- | -------- | + | Begin | 0 | 用户开始拖动滑å—。 | + | Moving | 1 | 用户拖动滑å—ä¸ã€‚ | + | End | 2 | 用户结æŸæ‹–动滑å—。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md index 4e57b1813c3091e0fdb802d955c64f12613d0c64..d8cb0bb3008facedca47015abeb1270802e1f9a9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md @@ -63,47 +63,50 @@ struct StepperExample { .fontColor(Color.Blue) .width(200) .lineHeight(50) - .margin({top:250}) + .margin({ top: 250 }) } .nextLabel('') - .position({x: '35%', y: 0}) + .position({ x: '35%', y: 0 }) + StepperItem() { Text('Page Two') .fontSize(35) .fontColor(Color.Blue) .width(200) .lineHeight(50) - .margin({top:250}) - .onClick(()=>{ + .margin({ top: 250 }) + .onClick(() => { this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip }) } .nextLabel('Next') .prevLabel('Previous') .status(this.firstState) - .position({x: '35%', y: 0}) + .position({ x: '35%', y: 0 }) + StepperItem() { Text('Page Three') .fontSize(35) .fontColor(Color.Blue) .width(200) .lineHeight(50) - .margin({top:250}) - .onClick(()=>{ + .margin({ top: 250 }) + .onClick(() => { this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting }) } - .position({x: '35%', y: 0}) + .position({ x: '35%', y: 0 }) .status(this.secondState) + StepperItem() { Text('Page four') .fontSize(35) .fontColor(Color.Blue) .width(200) .lineHeight(50) - .margin({top:250}) + .margin({ top: 250 }) } - .position({x: '35%', y: 0}) + .position({ x: '35%', y: 0 }) .nextLabel('Finish') } .onFinish(() => { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index b01ca87835f4d78d370d767d30944bd9483b3cb3..879b659b80285fc1330a05ecad42de5f5e0e155f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -23,7 +23,7 @@ Text(content?: string) - å‚æ•° | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | | -------- | -------- | -------- | -------- | -------- | - | content | string | å¦ | '' | 文本内容,包å«å组件Spanæ—¶ä¸ç”Ÿæ•ˆï¼Œæ˜¾ç¤ºSpan内容。 | + | content | string | å¦ | '' | 文本内容。包å«å组件Spanæ—¶ä¸ç”Ÿæ•ˆï¼Œæ˜¾ç¤ºSpan内容,并且æ¤æ—¶textç»„ä»¶çš„æ ·å¼ä¸ç”Ÿæ•ˆã€‚ | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md index 92cd8df915ddee1167ecd688daef50e527743335..b5edeedb5dc259f890202404e5b6c83abb27e133 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md @@ -58,7 +58,7 @@ TimePicker(options?: TimePickerOptions) @Entry @Component struct TimePickerExample { - private selectedTime: Date = new Date('08-00') + private selectedTime: Date = new Date('7/22/2022 8:00:00') build() { Column() { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index 25395c310c362dd9e69fd7901e6de7de7e9fafdc..2cc6753eaa71fe6436ebb6b7f19e868ca2735160 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -1,12 +1,14 @@ # Web > **说明:** -> 该组件从API Version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> +> - 该组件从API Version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> - 示例效果请以真机è¿è¡Œä¸ºå‡†ï¼Œå½“å‰IDE预览器ä¸æ”¯æŒã€‚ æ供具有网页显示能力的Web组件。 ## æƒé™åˆ—表 -è®¿é—®åœ¨çº¿ç½‘é¡µæ—¶éœ€æ·»åŠ ç½‘ç»œæƒé™ï¼šohos.permission.INTERNET +è®¿é—®åœ¨çº¿ç½‘é¡µæ—¶éœ€æ·»åŠ ç½‘ç»œæƒé™ï¼šohos.permission.INTERNET。 ## å组件 @@ -14,39 +16,437 @@ ## æŽ¥å£ -- Web\(options: { src: string, controller?: WebController }\) - - 表1 optionså‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ---------- | ------------------------------- | ---- | ------ | -------------- | - | src | string | 是 | - | 网页资æºåœ°å€ã€‚ | - | controller | [WebController](#webcontroller) | å¦ | - | 控制器。 | - +Web(options: { src: string, controller?: WebController }) + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | ------------------------------- | ---- | ---- | ------- | +| src | string | 是 | - | 网页资æºåœ°å€ã€‚ | +| controller | [WebController](#webcontroller) | å¦ | - | 控制器。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + } + } + } + ``` > **说明:** > -> - ä¸æ”¯æŒè½¬åœºåŠ¨ç”»ï¼› -> - ä¸æ”¯æŒå¤šå®žä¾‹ï¼› -> - 仅支æŒæœ¬åœ°éŸ³è§†é¢‘æ’放。 +> ä¸æ”¯æŒè½¬åœºåŠ¨ç”»ã€‚ ## 属性 -| å称 | å‚数类型 | 默认值 | æè¿° | -| ------------------ | ------------------------------------------------------------ | ----------------- | ------------------------------------------------------------ | -| domStorageAccess | boolean | false | 设置是å¦å¼€å¯æ–‡æ¡£å¯¹è±¡æ¨¡åž‹å˜å‚¨æŽ¥å£ï¼ˆDOM Storage API)æƒé™ï¼Œé»˜è®¤æœªå¼€å¯ã€‚ | -| fileAccess | boolean | false | 设置是å¦å¼€å¯é€šè¿‡[$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md#资æºå¼•ç”¨)访问应用ä¸rawfile路径的文件, 默认å¯ç”¨ã€‚ | -| fileFromUrlAccess | boolean | true | 设置是å¦å…许通过网页ä¸çš„JavaScript脚本访问[$rawfile(filepath/filename)](../../ui/ts-application-resource-access.md#资æºå¼•ç”¨)的内容,默认未å¯ç”¨ã€‚ | -| imageAccess | boolean | true | 设置是å¦å…è®¸è‡ªåŠ¨åŠ è½½å›¾ç‰‡èµ„æºï¼Œé»˜è®¤å…许。 | -| javaScriptProxy | { <br> object: object, <br/> name: string, <br/> methodList: Array\<string\>, <br/> controller: WebController <br>} | - | 注入JavaScript对象到window对象ä¸ï¼Œå¹¶åœ¨window对象ä¸è°ƒç”¨è¯¥å¯¹è±¡çš„方法。所有å‚æ•°ä¸æ”¯æŒæ›´æ–°ã€‚ <br/> - object: å‚与注册的对象。åªèƒ½å£°æ˜Žæ–¹æ³•ï¼Œä¸èƒ½å£°æ˜Žå±žæ€§ 。其ä¸æ–¹æ³•çš„å‚数和返回类型åªèƒ½ä¸ºstring,number,boolean。<br/> - name: 注册对象的å称,与windowä¸è°ƒç”¨çš„对象å一致。注册åŽwindow对象å¯ä»¥é€šè¿‡æ¤åå—访问应用侧JavaScript对象。<br/> - methodList: å‚与注册的应用侧JavaScript对象的方法。<br/> - controller: 控制器。 | -| javaScriptAccess | boolean | true | 设置是å¦å…许执行JavaScript脚本,默认å…许执行。 | -| mixedMode | [MixedMode](#mixedmode枚举说明) | MixedMode.None | 设置是å¦å…è®¸åŠ è½½è¶…æ–‡æœ¬ä¼ è¾“å议(HTTPï¼‰å’Œè¶…æ–‡æœ¬ä¼ è¾“å®‰å…¨å议(HTTPS)混åˆå†…容,默认ä¸å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。 | -| onlineImageAccess | boolean | true | 设置是å¦å…è®¸ä»Žç½‘ç»œåŠ è½½å›¾ç‰‡èµ„æºï¼ˆé€šè¿‡HTTPå’ŒHTTPS访问的资æºï¼‰ï¼Œé»˜è®¤å…许访问。 | -| zoomAccess | boolean | true | 设置是å¦æ”¯æŒæ‰‹åŠ¿è¿›è¡Œç¼©æ”¾ï¼Œé»˜è®¤å…许执行缩放。 | -| overviewModeAccess | boolean | true | 设置是å¦ä½¿ç”¨æ¦‚览模å¼åŠ 载网页,默认使用该方å¼ã€‚ | -| databaseAccess | boolean | false | 设置是å¦å¼€å¯æ•°æ®åº“å˜å‚¨APIæƒé™ï¼Œé»˜è®¤ä¸å¼€å¯ã€‚ | -| cacheMode | [CacheMode](#cachemode枚举说明) | CacheMode.Default | 设置缓å˜æ¨¡å¼ã€‚ | -| textZoomAtio | number | 100 | 设置页é¢çš„文本缩放百分比,默认为100%。 | -| userAgent | string | - | 设置用户代ç†ã€‚ | + +web组件的网络属性。 + +### domStorageAccess + +domStorageAccess(domStorageAccess: boolean) + +设置是å¦å¼€å¯æ–‡æ¡£å¯¹è±¡æ¨¡åž‹å˜å‚¨æŽ¥å£ï¼ˆDOM Storage API)æƒé™ï¼Œé»˜è®¤æœªå¼€å¯ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------------- | ------- | ---- | ---- | ------------------------------------ | +| domStorageAccess | boolean | 是 | - | 设置是å¦å¼€å¯æ–‡æ¡£å¯¹è±¡æ¨¡åž‹å˜å‚¨æŽ¥å£ï¼ˆDOM Storage API)æƒé™ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .domStorageAccess(true) + } + } + } + ``` + +### fileAccess + +fileAccess(fileAccess: boolean) + +设置是å¦å¼€å¯é€šè¿‡[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)访问应用ä¸rawfile路径的文件, 默认å¯ç”¨ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | ------- | ---- | ---- | ---------------------------------------- | +| fileAccess | boolean | 是 | true | 设置是å¦å¼€å¯é€šè¿‡[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)访问应用ä¸rawfile路径的文件,默认å¯ç”¨ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .fileAccess(true) + } + } + } + ``` + +### fileFromUrlAccess<sup>9+</sup> + +fileFromUrlAccess(fileFromUrlAccess: boolean) + +设置是å¦å…许通过网页ä¸çš„JavaScript脚本访问[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)的内容,默认未å¯ç”¨ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ----------------- | ------- | ---- | ----- | ---------------------------------------- | +| fileFromUrlAccess | boolean | 是 | false | 设置是å¦å…许通过网页ä¸çš„JavaScript脚本访问[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)的内容,默认未å¯ç”¨ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .fileFromUrlAccess(true) + } + } + } + ``` + +### imageAccess + +imageAccess(imageAccess: boolean) + +设置是å¦å…è®¸è‡ªåŠ¨åŠ è½½å›¾ç‰‡èµ„æºï¼Œé»˜è®¤å…许。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ----------- | ------- | ---- | ---- | --------------- | +| imageAccess | boolean | 是 | - | 设置是å¦å…è®¸è‡ªåŠ¨åŠ è½½å›¾ç‰‡èµ„æºã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .imageAccess(true) + } + } + } + ``` + +### javaScriptProxy + +javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Array\<string\>, + controller: WebController }) + +注入JavaScript对象到window对象ä¸ï¼Œå¹¶åœ¨window对象ä¸è°ƒç”¨è¯¥å¯¹è±¡çš„方法。所有å‚æ•°ä¸æ”¯æŒæ›´æ–°ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | --------------- | ---- | ---- | ------------------------- | +| object | object | 是 | - | å‚与注册的对象。åªèƒ½å£°æ˜Žæ–¹æ³•ï¼Œä¸èƒ½å£°æ˜Žå±žæ€§ã€‚ | +| name | string | 是 | - | 注册对象的å称,与windowä¸è°ƒç”¨çš„对象å一致。 | +| methodList | Array\<string\> | 是 | - | å‚与注册的应用侧JavaScript对象的方法。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + testObj = { + test: (data1, data2, data3) => { + console.log("data1:" + data1); + console.log("data2:" + data2); + console.log("data3:" + data3); + return "AceString"; + }, + toString: () => { + console.log('toString' + "interface instead."); + } + } + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .javaScriptAccess(true) + .javaScriptProxy({ + object: this.testObj, + name: "objName", + methodList: ["test", "toString"], + controller: this.controller, + }) + } + } + } + ``` + +### javaScriptAccess + +javaScriptAccess(javaScriptAccess: boolean) + +设置是å¦å…许执行JavaScript脚本,默认å…许执行。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------------- | ------- | ---- | ---- | ------------------- | +| javaScriptAccess | boolean | 是 | - | 是å¦å…许执行JavaScript脚本。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .javaScriptAccess(true) + } + } + } + ``` + +### mixedMode + +mixedMode(mixedMode: MixedMode) + +设置是å¦å…è®¸åŠ è½½è¶…æ–‡æœ¬ä¼ è¾“å议(HTTPï¼‰å’Œè¶…æ–‡æœ¬ä¼ è¾“å®‰å…¨å议(HTTPS)混åˆå†…容,默认ä¸å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| --------- | --------------------------- | ---- | ---- | --------- | +| mixedMode | [MixedMode](#mixedmode枚举说明) | 是 | - | è¦è®¾ç½®çš„æ··åˆå†…容。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + @State mode:MixedMode = MixedMode.All; + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .mixedMode(this.mode) + } + } + } + ``` + +### onlineImageAccess + +onlineImageAccess(onlineImageAccess: boolean) + +设置是å¦å…è®¸ä»Žç½‘ç»œåŠ è½½å›¾ç‰‡èµ„æºï¼ˆé€šè¿‡HTTPå’ŒHTTPS访问的资æºï¼‰ï¼Œé»˜è®¤å…许访问。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ----------------- | ------- | ---- | ---- | ---------------- | +| onlineImageAccess | boolean | 是 | - | 设置是å¦å…è®¸ä»Žç½‘ç»œåŠ è½½å›¾ç‰‡èµ„æºã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onlineImageAccess(true) + } + } + } + ``` + +### zoomAccess + +zoomAccess(zoomAccess: boolean) + +设置是å¦æ”¯æŒæ‰‹åŠ¿è¿›è¡Œç¼©æ”¾ï¼Œé»˜è®¤å…许执行缩放。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | ------- | ---- | ---- | ------------- | +| zoomAccess | boolean | 是 | - | 设置是å¦æ”¯æŒæ‰‹åŠ¿è¿›è¡Œç¼©æ”¾ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .zoomAccess(true) + } + } + } + ``` + +### overviewModeAccess + +overviewModeAccess(overviewModeAccess: boolean) + +设置是å¦ä½¿ç”¨æ¦‚览模å¼åŠ 载网页,默认使用该方å¼ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------------ | ------- | ---- | ---- | --------------- | +| overviewModeAccess | boolean | 是 | - | 设置是å¦ä½¿ç”¨æ¦‚览模å¼åŠ 载网页。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .overviewModeAccess(true) + } + } + } + ``` + +### databaseAccess + +databaseAccess(databaseAccess: boolean) + +设置是å¦å¼€å¯æ•°æ®åº“å˜å‚¨APIæƒé™ï¼Œé»˜è®¤ä¸å¼€å¯ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------------- | ------- | ---- | ---- | ----------------- | +| databaseAccess | boolean | 是 | - | 设置是å¦å¼€å¯æ•°æ®åº“å˜å‚¨APIæƒé™ã€‚ | + + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### cacheMode + +cacheMode(cacheMode: CacheMode) + +设置缓å˜æ¨¡å¼ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| --------- | --------------------------- | ---- | ---- | --------- | +| cacheMode | [CacheMode](#cachemode枚举说明) | 是 | - | è¦è®¾ç½®çš„缓å˜æ¨¡å¼ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + @State mode:CacheMode = CacheMode.None; + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .cacheMode(this.mode) + } + } + } + ``` + +### textZoomAtio + +textZoomAtio(textZoomAtio: number) + +设置页é¢çš„文本缩放百分比,默认为100%。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------ | ------ | ---- | ---- | --------------- | +| textZoomAtio | number | 是 | - | è¦è®¾ç½®çš„页é¢çš„文本缩放百分比。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + @State atio:number = 150; + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .textZoomAtio(this.atio) + } + } + } + ``` + +### userAgent + +userAgent(userAgent: string) + +设置用户代ç†ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| --------- | ------ | ---- | ---- | --------- | +| userAgent | string | 是 | - | è¦è®¾ç½®çš„用户代ç†ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + @State userAgent:string = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'; + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .userAgent(this.userAgent) + } + } + } + ``` > **说明:** > @@ -56,149 +456,1229 @@ ä¸æ”¯æŒé€šç”¨äº‹ä»¶ã€‚ -| å称 | 功能æè¿° | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| onAlert(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) | <p>网页触å‘alert()å‘Šè¦å¼¹çª—时触å‘回调。<br />当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(åªæœ‰ç¡®è®¤åœºæ™¯ï¼‰ï¼Œå¹¶ä¸”æ ¹æ®ç”¨æˆ·çš„确认æ“作调用JsResult通知Web组件。<br />- url:当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。<br />- message:弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚<br />- result:通知Web组件用户æ“作行为。</p> | -| onBeforeUnload(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) | <p>刷新或关é—场景下,在å³å°†ç¦»å¼€å½“å‰é¡µé¢æ—¶è§¦å‘æ¤å›žè°ƒã€‚<br />当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件最终是å¦ç¦»å¼€å½“å‰é¡µé¢ã€‚<br />- url:当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。<br />- message:弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚<br />- result:通知Web组件用户æ“作行为。</p> | -| onConfirm(callback: (event?: { url: string; message: string; result: [JsResult](#jsresult对象说明) }) => boolean) | <p>网页调用confirm()å‘Šè¦æ—¶è§¦å‘æ¤å›žè°ƒã€‚<br />当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件。<br />- url:当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。<br />- message:弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚<br />- result:通知Web组件用户æ“作行为。</p> | -| onPrompt<sup>9+</sup>(callback: (event?: { url: string; message: string; value: string; result: [JsResult](#jsresult对象说明) }) => boolean) | <p>网页调用prompt()å‘Šè¦æ—¶è§¦å‘æ¤å›žè°ƒã€‚<br />当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件。<br />- url:当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。<br />- message:弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚<br />- value:对è¯æ¡†ä¸çš„默认值。<br />- result:通知Web组件用户æ“作行为,åŠå¯¹è¯æ¡†å†…容。</p> | -| onConsole(callback: (event?: { message: [ConsoleMessage](#consolemessage对象说明) }) => boolean) | <p>通知宿主应用JavaScript console消æ¯ã€‚<br/>- message:触å‘的控制å°ä¿¡æ¯ã€‚</p> | -| onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) | <p>网页的下载任务开始时触å‘该回调。<br />- url:文件下载的URL。<br />- userAgent:下载的用户代ç†ï¼ˆUA)å称。<br />- contentDisposition:æœåŠ¡å™¨è¿”回的 Content-Dispositionå“应头,å¯èƒ½ä¸ºç©ºã€‚<br />- mimetype:æœåŠ¡å™¨è¿”回内容媒体类型(MIME)信æ¯ã€‚<br />- contentLength:æœåŠ¡å™¨è¿”回文件的长度。</p> | -| onErrorReceive(callback: (event?: { request: [WebResourceRequest](#webresourceerror对象说明), error: [WebResourceError](#webresourceerror对象说明) }) => void) | <p>ç½‘é¡µåŠ è½½é‡åˆ°é”™è¯¯æ—¶è§¦å‘该回调。<br/>出于性能考虑,建议æ¤å›žè°ƒä¸å°½é‡æ‰§è¡Œç®€å•é€»è¾‘。<br/>- request:网页请求的å°è£…ä¿¡æ¯ã€‚<br/>- errorï¼šç½‘é¡µåŠ è½½èµ„æºé”™è¯¯çš„å°è£…ä¿¡æ¯ ã€‚</p> | -| onHttpErrorReceive(callback: (event?: { request: [WebResourceRequest](#webresourceerror对象说明), response: [WebResourceResponse](#webresourceresponse对象说明) }) => void) | <p>ç½‘é¡µåŠ è½½èµ„æºé‡åˆ°çš„HTTP错误(å“应ç >=400)时触å‘该回调。<br/>- request:网页请求的å°è£…ä¿¡æ¯ã€‚<br/>- response:网页å“应的å°è£…ä¿¡æ¯</p> | -| onPageBegin(callback: (event?: { url: string }) => void) | <p>ç½‘é¡µå¼€å§‹åŠ è½½æ—¶è§¦å‘该回调,且åªåœ¨ä¸»frame触å‘,iframe或者framesetçš„å†…å®¹åŠ è½½æ—¶ä¸ä¼šè§¦å‘æ¤å›žè°ƒã€‚<br/>- url:页é¢çš„URL地å€ã€‚</p> | -| onPageEnd(callback: (event?: { url: string }) => void) | <p>ç½‘é¡µåŠ è½½å®Œæˆæ—¶è§¦å‘该回调,且åªåœ¨ä¸»frame触å‘。<br/>- url:页é¢çš„URL地å€ã€‚</p> | -| onProgressChange(callback: (event?: { newProgress: number }) => void) | <p>ç½‘é¡µåŠ è½½è¿›åº¦å˜åŒ–时触å‘该回调。<br/>- newProgressï¼šæ–°çš„åŠ è½½è¿›åº¦ï¼Œå–值范围为0到100的整数。</p> | -| onTitleReceive(callback: (event?: { title: string }) => void) | <p>网页documentæ ‡é¢˜æ›´æ”¹æ—¶è§¦å‘该回调。<br/>- title:documentæ ‡é¢˜å†…å®¹ã€‚</p> | -| onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean }) => void) | <p>åŠ è½½ç½‘é¡µé¡µé¢å®Œæˆæ—¶è§¦å‘该回调,用于应用更新其访问的历å²é“¾æŽ¥ã€‚<br/>- url:访问的url。<br/>- isRefreshed:true表示该页é¢æ˜¯è¢«é‡æ–°åŠ 载的,false表示该页é¢æ˜¯æ–°åŠ 载的。</p> | -| onRenderExited(callback: (event?: { renderExitReason: [RenderExitReason](#renderexitreason枚举说明) }) => void) | <p>应用渲染进程异常退出时触å‘该回调。<br/>- renderExitReasonï¼šæ¸²æŸ“è¿›ç¨‹è¿›ç¨‹å¼‚å¸¸é€€å‡ºçš„å…·ä½“åŽŸå› ã€‚</p> | -| onShowFileSelector(callback: (event?: { result: [FileSelectorResult](#fileselectorresult对象说明), fileSelector: [FileSelectorParam](#fileselectorparam对象说明) }) => void) | <p>调用æ¤å‡½æ•°ä»¥å¤„ç†å…·æœ‰â€œæ–‡ä»¶â€è¾“入类型的HTML表å•ï¼Œä»¥å“应用户按下的“选择文件â€æŒ‰é’®<br/>- result:用于通知Web组件文件选择的结果。<br/>- fileSelector:文件选择器的相关信æ¯ã€‚</p> | -| onUrlLoadIntercept(callback: (event?: { data:string \| [WebResourceRequest](#webresourcerequest对象说明) }) => boolean) | <p>当Webç»„ä»¶åŠ è½½url之å‰è§¦å‘该回调,用于是å¦é˜»æ¢æ¤æ¬¡è®¿é—®ã€‚callback返回true表示阻æ¢æ¤æ¬¡åŠ 载,å¦åˆ™å…许æ¤æ¬¡åŠ 载。<br/>- data:url的相关信æ¯ã€‚</p> | -| onInterceptRequest<sup>9+</sup>(callback: (event?: { request: [WebResourceRequest](#webresourcerequest对象说明)}) => [WebResourceResponse](#webresourceresponse对象说明)) | <p>当Webç»„ä»¶åŠ è½½url之å‰è§¦å‘该回调,用于拦截url并返回å“应数æ®ã€‚callback返回å“应数æ®ä¸ºç©ºè¡¨ç¤ºæŒ‰åŽŸæ¥æ–¹å¼åŠ 载,å¦åˆ™åŠ è½½å“应数æ®ã€‚<br/>- request:url请求的相关信æ¯ã€‚</p> | - -## ConsoleMessage对象说明 - -| 接å£å称 | 功能æè¿° | -| -------------------------------------------------------- | ------------------------------ | -| getLineNumber(): number | 获å–ConsoleMessage的行数。 | -| getMessage(): string | 获å–ConsoleMessage的日志信æ¯ã€‚ | -| getMessageLevel(): [MessageLevel](#messagelevel枚举说明) | 获å–ConsoleMessageçš„ä¿¡æ¯çº§åˆ«ã€‚ | -| getSourceId(): string | 获å–网页æºæ–‡ä»¶è·¯å¾„å’Œåå—。 | +### onAlert + +onAlert(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) + +网页触å‘alert()å‘Šè¦å¼¹çª—时触å‘回调。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | --------------------- | --------------- | +| url | string | 当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。 | +| message | string | 弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚ | +| result | [JsResult](#jsresult) | 通知Web组件用户æ“作行为。 | + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件最终是å¦ç¦»å¼€å½“å‰é¡µé¢ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onAlert((event) => { + AlertDialog.show({ + title: 'title', + message: 'text', + confirm: { + value: 'onAlert', + action: () => { + event.result.handleConfirm() + } + }, + cancel: () => { + event.result.handleCancel() + } + }) + return true; + }) + } + } + } + ``` + +### onBeforeUnload + +onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) + +刷新或关é—场景下,在å³å°†ç¦»å¼€å½“å‰é¡µé¢æ—¶è§¦å‘æ¤å›žè°ƒã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | --------------------- | --------------- | +| url | string | 当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。 | +| message | string | 弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚ | +| result | [JsResult](#jsresult) | 通知Web组件用户æ“作行为。 | + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件最终是å¦ç¦»å¼€å½“å‰é¡µé¢ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onBeforeUnload((event) => { + console.log("event.url:" + event.url); + console.log("event.message:" + event.message); + console.log("event.result:" + event.result); + return false; + }) + } + } + } + ``` + +### onConfirm + +onConfirm(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) + +网页调用confirm()å‘Šè¦æ—¶è§¦å‘æ¤å›žè°ƒã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | --------------------- | --------------- | +| url | string | 当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。 | +| message | string | 弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚ | +| result | [JsResult](#jsresult) | 通知Web组件用户æ“作行为。 | + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onConfirm((event) => { + console.log("event.url:" + event.url); + console.log("event.message:" + event.message); + console.log("event.result:" + event.result); + AlertDialog.show({ + title: 'title', + message: 'text', + confirm: { + value: 'onConfirm', + action: () => { + event.result.handleConfirm() + } + }, + cancel: () => { + event.result.handleCancel() + } + }) + return true; + }) + } + } + } + ``` + +### onPrompt<sup>9+</sup> + +onPrompt(callback: (event?: { url: string; message: string; value: string; result: JsResult }) => boolean) + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | --------------------- | --------------- | +| url | string | 当å‰æ˜¾ç¤ºå¼¹çª—所在网页的URL。 | +| message | string | 弹窗ä¸æ˜¾ç¤ºçš„ä¿¡æ¯ã€‚ | +| result | [JsResult](#jsresult) | 通知Web组件用户æ“作行为。 | + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 当回调返回false时,触å‘默认弹窗。当回调返回true时,系统应用å¯ä»¥è°ƒç”¨ç³»ç»Ÿå¼¹çª—能力(包括确认和å–消),并且需è¦æ ¹æ®ç”¨æˆ·çš„确认或å–消æ“作调用JsResult通知Web组件。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onPrompt((event) => { + console.log("url:" + event.url); + console.log("message:" + event.message); + console.log("value:" + event.value); + console.log("result:" + event.result); + return true; + }) + } + } + ``` + +### onConsole + +onConsole(callback: (event?: { message: ConsoleMessage }) => boolean) + +通知宿主应用JavaScript console消æ¯ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | --------------------------------- | --------- | +| message | [ConsoleMessage](#consolemessage) | 触å‘的控制å°ä¿¡æ¯ã€‚ | + +**返回值:** +| 类型 | 说明 | +| ------- | ----------------------------------- | +| boolean | 当返回true时,该æ¡æ¶ˆæ¯å°†ä¸ä¼šå†æ‰“å°è‡³æŽ§åˆ¶å°ï¼Œå之ä»ä¼šæ‰“å°è‡³æŽ§åˆ¶å°ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onConsole((event) => { + console.log('getMessage:' + event.message.getMessage()); + console.log('getSourceId:' + event.message.getSourceId()); + console.log('getLineNumber:' + event.message.getLineNumber()); + console.log('getMessageLevel:' + event.message.getMessageLevel()); + return false; + }) + } + } + } + ``` + +### onDownloadStart + +onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------------------ | ------------- | ----------------------------------- | +| url | string | 文件下载的URL。 | +| contentDisposition | string | æœåŠ¡å™¨è¿”回的 Content-Dispositionå“应头,å¯èƒ½ä¸ºç©ºã€‚ | +| mimetype | string | æœåŠ¡å™¨è¿”回内容媒体类型(MIME)信æ¯ã€‚ | +| contentLength | contentLength | æœåŠ¡å™¨è¿”回文件的长度。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onDownloadStart((event) => { + console.log('url:' + event.url); + console.log('userAgent:' + event.userAgent); + console.log('contentDisposition:' + event.contentDisposition); + console.log('contentLength:' + event.contentLength); + console.log('mimetype:' + event.mimetype); + }) + } + } + } + ``` + +### onErrorReceive + +onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResourceError }) => void) + +ç½‘é¡µåŠ è½½é‡åˆ°é”™è¯¯æ—¶è§¦å‘该回调。出于性能考虑,建议æ¤å›žè°ƒä¸å°½é‡æ‰§è¡Œç®€å•é€»è¾‘。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | ---------------------------------------- | --------------- | +| request | [WebResourceRequest](#webresourcerequest) | 网页请求的å°è£…ä¿¡æ¯ã€‚ | +| error | [WebResourceError](#webresourceerror) | ç½‘é¡µåŠ è½½èµ„æºé”™è¯¯çš„å°è£…ä¿¡æ¯ ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onErrorReceive((event) => { + console.log('getErrorInfo:' + event.error.getErrorInfo()); + console.log('getErrorCode:' + event.error.getErrorCode()); + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestHeader_headerKey:' + event.request.getRequestHeader().toString()); + let result = event.request.getRequestHeader(); + console.log('The request header result size is ' + result.length); + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ', value is : ' + i.headerValue); + } + }) + } + } + } + ``` + +### onHttpErrorReceive + +onHttpErrorReceive(callback: (event?: { request: WebResourceRequest, response: WebResourceResponse }) => void) + +ç½‘é¡µåŠ è½½èµ„æºé‡åˆ°çš„HTTP错误(å“应ç >=400)时触å‘该回调。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | ---------------------------------------- | --------------- | +| request | [WebResourceRequest](#webresourcerequest) | 网页请求的å°è£…ä¿¡æ¯ã€‚ | +| error | [WebResourceError](#webresourceerror) | ç½‘é¡µåŠ è½½èµ„æºé”™è¯¯çš„å°è£…ä¿¡æ¯ ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getResponseData:' + event.response.getResponseData()); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader(); + console.log('The request header result size is ' + result.length); + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader(); + console.log('The response header result size is ' + resph.length); + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + }) + } + } + } + ``` + +### onPageBegin + +onPageBegin(callback: (event?: { url: string }) => void) + + +ç½‘é¡µå¼€å§‹åŠ è½½æ—¶è§¦å‘该回调,且åªåœ¨ä¸»frame触å‘,iframe或者framesetçš„å†…å®¹åŠ è½½æ—¶ä¸ä¼šè§¦å‘æ¤å›žè°ƒã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ---- | ------ | --------- | +| url | string | 页é¢çš„URL地å€ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onPageBegin((event) => { + console.log('url:' + event.url); + }) + } + } + } + ``` + +### onPageEnd + +onPageEnd(callback: (event?: { url: string }) => void) + + +ç½‘é¡µåŠ è½½å®Œæˆæ—¶è§¦å‘该回调,且åªåœ¨ä¸»frame触å‘。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ---- | ------ | --------- | +| url | string | 页é¢çš„URL地å€ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onPageEnd((event) => { + console.log('url:' + event.url); + }) + } + } + } + ``` + +### onProgressChange + +onProgressChange(callback: (event?: { newProgress: number }) => void) + +ç½‘é¡µåŠ è½½è¿›åº¦å˜åŒ–时触å‘该回调。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ----------- | ------ | --------------------- | +| newProgress | number | æ–°çš„åŠ è½½è¿›åº¦ï¼Œå–值范围为0到100的整数。 | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onProgressChange((event) => { + console.log('newProgress:' + event.newProgress) + }) + } + } + } + ``` + +### onTitleReceive + +onTitleReceive(callback: (event?: { title: string }) => void) + +网页documentæ ‡é¢˜æ›´æ”¹æ—¶è§¦å‘该回调。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ----- | ------ | ------------- | +| title | string | documentæ ‡é¢˜å†…å®¹ã€‚ | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onTitleReceive((event) => { + console.log('title:' + event.title) + }) + } + } + } + ``` + +### onRefreshAccessedHistory + +onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean }) => void) + +åŠ è½½ç½‘é¡µé¡µé¢å®Œæˆæ—¶è§¦å‘该回调,用于应用更新其访问的历å²é“¾æŽ¥ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ----------- | ------- | --------------------------------- | +| url | string | 访问的url。 | +| isRefreshed | boolean | true表示该页é¢æ˜¯è¢«é‡æ–°åŠ 载的,false表示该页é¢æ˜¯æ–°åŠ 载的。 | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onRefreshAccessedHistory((event) => { + console.log('url:' + event.url + ' isReload:' + event.refreshed); + }) + } + } + } + ``` + +### onRenderExited + +onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => void) + +应用渲染进程异常退出时触å‘该回调。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ---------------- | ---------------------------------------- | ---------------- | +| renderExitReason | [RenderExitReason](#renderexitreason枚举说明) | æ¸²æŸ“è¿›ç¨‹è¿›ç¨‹å¼‚å¸¸é€€å‡ºçš„å…·ä½“åŽŸå› ã€‚ | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'chrome://crash/', controller: this.controller }) + .onRenderExited((event) => { + console.log('reason:' + event.renderExitReason); + }) + } + } + } + ``` + +### onShowFileSelector<sup>9+</sup> + +onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector: FileSelectorParam }) => void) + +调用æ¤å‡½æ•°ä»¥å¤„ç†å…·æœ‰â€œæ–‡ä»¶â€è¾“入类型的HTML表å•ï¼Œä»¥å“应用户按下的“选择文件â€æŒ‰é’®ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------------ | ---------------------------------------- | ----------------- | +| result | [FileSelectorResult](#fileselectorresult9) | 用于通知Web组件文件选择的结果。 | +| fileSelector | [FileSelectorParam](#fileselectorparam9) | 文件选择器的相关信æ¯ã€‚ | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onShowFileSelector((event) => { + AlertDialog.show({ + title: event.fileSelector.getTitle(), + message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(), + confirm: { + value: 'upload', + action: () => { + let fileList: Array<string> = [ + '/data/storage/el2/base/test', + ] + event.result.handleFileList(fileList) + } + }, + cancel: () => { + let fileList: Array<string> = [] + event.result.handleFileList(fileList) + } + }) + return true; + }) + } + } + } + ``` + +### onUrlLoadIntercept + +onUrlLoadIntercept(callback: (event?: { data:string | WebResourceRequest }) => boolean) + +当Webç»„ä»¶åŠ è½½url之å‰è§¦å‘该回调,用于是å¦é˜»æ¢æ¤æ¬¡è®¿é—®ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ---- | ---------------------------------------- | --------- | +| data | string / [WebResourceRequest](#webresourcerequest) | url的相关信æ¯ã€‚ | + +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------ | +| boolean | 返回true表示阻æ¢æ¤æ¬¡åŠ 载,å¦åˆ™å…许æ¤æ¬¡åŠ 载。 | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .onUrlLoadIntercept((event) => { + console.log('onUrlLoadIntercept ' + event.data.toString()) + return true; + }) + } + } + } + ``` + +### onInterceptRequest<sup>9+</sup> + +onInterceptRequest9+(callback: (event?: { request: WebResourceRequest}) => WebResourceResponse) + +当Webç»„ä»¶åŠ è½½url之å‰è§¦å‘该回调,用于拦截url并返回å“应数æ®ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | ---------------------------------------- | ----------- | +| request | [WebResourceRequest](#webresourcerequest) | url请求的相关信æ¯ã€‚ | + +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | --------------------------- | +| [WebResourceResponse](#webresourceresponse) | 返回å“应数æ®ä¸ºç©ºè¡¨ç¤ºæŒ‰åŽŸæ¥æ–¹å¼åŠ 载,å¦åˆ™åŠ è½½å“应数æ®ã€‚ | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + responseweb: WebResourceResponse = new WebResourceResponse(); + heads:Header[] = new Array(); + @State webdata: string = "<!DOCTYPE html>\n" + + "<html>\n"+ + "<head>\n"+ + "<title>intercept test</title>\n"+ + "</head>\n"+ + "<body>\n"+ + "<h1>intercept test</h1>\n"+ + "</body>\n"+ + "</html>" + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()); + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1); + length = this.heads.push(head2); + this.responseweb.setResponseHeader(this.heads); + this.responseweb.setResponseData(this.webdata); + this.responseweb.setResponseEncoding('utf-8'); + this.responseweb.setResponseMimeType('text/html'); + this.responseweb.setResponseCode(200); + this.responseweb.setReasonMessage('OK'); + return this.responseweb; + }) + } + } + } + ``` + +### onHttpAuthRequest<sup>9+</sup> + +onHttpAuthRequest(callback: (event?: { handler: HttpAuthHandler, host: string, realm: string}) => boolean) + +通知收到http auth认è¯è¯·æ±‚。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | ------------------------------------ | ---------------- | +| handler | [HttpAuthHandler](#httpauthhandler9) | 通知Web组件用户æ“作行为。 | +| host | string | HTTP身份验è¯å‡æ®åº”用的主机。 | +| realm | string | HTTP身份验è¯å‡æ®åº”用的域。 | + +**返回值:** +| 类型 | 说明 | +| ------- | --------------------- | +| boolean | 返回false表示æ¤æ¬¡è®¤è¯å¤±è´¥ï¼Œå¦åˆ™æˆåŠŸã€‚ | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + httpAuth:boolean = false; + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onHttpAuthRequest((event) => { + AlertDialog.show({ + title: 'title', + message: 'text', + confirm: { + value: 'onConfirm', + action: () => { + this.httpAuth = event.handler.isHttpAuthInfoSaved(); + if (this.httpAuth == false) { + web.WebDataBase.saveHttpAuthCredentials( + event.host, + event.realm, + "2222", + "2222" + ) + event.handler.cancel(); + } + } + }, + cancel: () => { + event.handler.cancel(); + } + }) + return true; + }) + } + } + ``` +### onPermissionRequest<sup>9+</sup> + +onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void) + +通知收到获å–æƒé™è¯·æ±‚。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å‚æ•°æè¿° | +| ------- | ------------------------------------ | ---------------- | +| request | [PermissionRequest](#permissionrequest9) | 通知Web组件用户æ“作行为。 | + + **示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Web({ src:'www.example.com', controller:this.controller }) + .onPermissionRequest((event) => { + AlertDialog.show({ + title: 'title', + message: 'text', + confirm: { + value: 'onConfirm', + action: () => { + event.request.grant(event.request.getAccessibleResource()); + } + }, + cancel: () => { + event.request.deny(); + } + }) + }) + } + } + ``` + +## ConsoleMessage -## MessageLevel枚举说明 +Web组件获å–控制å°ä¿¡æ¯å¯¹è±¡ã€‚示例代ç å‚考[onConsole事件](#onconsole)。 -| å称 | æè¿° | -| ----- | :--------- | -| Debug | 调试级别。 | -| Error | 错误级别。 | -| Info | 消æ¯çº§åˆ«ã€‚ | -| Log | 日志级别。 | -| Warn | è¦å‘Šçº§åˆ«ã€‚ | +### getLineNumber + +getLineNumber(): number + +获å–ConsoleMessage的行数。 + +**返回值:** +| 类型 | 说明 | +| ------ | -------------------- | +| number | 返回ConsoleMessage的行数。 | + +### getMessage + +getMessage(): string + +获å–ConsoleMessage的日志信æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ---------------------- | +| string | 返回ConsoleMessage的日志信æ¯ã€‚ | + +### getMessageLevel + +getMessageLevel(): MessageLevel + +获å–ConsoleMessageçš„ä¿¡æ¯çº§åˆ«ã€‚ + +**返回值:** +| 类型 | 说明 | +| --------------------------------- | ---------------------- | +| [MessageLevel](#messagelevel枚举说明) | 返回ConsoleMessageçš„ä¿¡æ¯çº§åˆ«ã€‚ | + +### getSourceId + +getSourceId(): string + +获å–网页æºæ–‡ä»¶è·¯å¾„å’Œåå—。 -## JsResult对象说明 +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 返回网页æºæ–‡ä»¶è·¯å¾„å’Œåå—。 | -Web组件返回的弹窗确认或弹窗å–消功能对象。 +## JsResult -| 接å£å称 | 功能æè¿° | -| ------------------------------------------------------ | ------------------------------------------------ | -| handleCancel(): void | <p>通知Web组件用户å–消弹窗æ“作。</p> | -| handleConfirm(): void | <p>通知Web组件用户确认弹窗æ“作。</p> | -| handlePromptConfirm<sup>9+</sup>(result: string): void | <p>通知Web组件用户确认弹窗æ“作åŠå¯¹è¯æ¡†å†…容。</p> | +Web组件返回的弹窗确认或弹窗å–消功能对象。示例代ç å‚考[onAlert事件](#onalert)。 -## WebResourceError对象说明 +### handleCancel -| 接å£å称 | 功能æè¿° | -| ---------------------- | ------------------------ | -| getErrorCode(): number | 获å–åŠ è½½èµ„æºçš„错误ç 。 | -| getErrorInfo(): string | 获å–åŠ è½½èµ„æºçš„错误信æ¯ã€‚ | +handleCancel(): void -## WebResourceRequest对象说明 +通知Web组件用户å–消弹窗æ“作。 -| 接å£å称 | 功能æè¿° | -| ------------------------------------------------------ | ---------------------------------------- | -| getRequestHeader(): Array\<[Header](#header对象说明)\> | 获å–资æºè¯·æ±‚头信æ¯ã€‚ | -| getRequestUrl(): string | 获å–资æºè¯·æ±‚çš„URLä¿¡æ¯ã€‚ | -| isMainFrame(): boolean | 判æ–资æºè¯·æ±‚是å¦ä¸ºä¸»frame。 | -| isRedirect(): boolean | 判æ–资æºè¯·æ±‚是å¦è¢«æœåŠ¡ç«¯é‡å®šå‘。 | -| isRequestGesture(): boolean | 获å–资æºè¯·æ±‚是å¦ä¸Žæ‰‹åŠ¿ï¼ˆå¦‚点击)相关è”。 | +### handleConfirm -## Header对象说明 +handleConfirm(): void + +通知Web组件用户确认弹窗æ“作。 + +### handlePromptConfirm<sup>9+</sup> + +handlePromptConfirm(result: string): void + +通知Web组件用户确认弹窗æ“作åŠå¯¹è¯æ¡†å†…容。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------ | ------ | ---- | ---- | ----------- | +| result | string | 是 | - | 用户输入的对è¯æ¡†å†…容。 | + +## WebResourceError + +web组件资æºç®¡ç†é”™è¯¯ä¿¡æ¯å¯¹è±¡ã€‚示例代ç å‚考[onErrorReceive事件](#onerrorreceive)。 + +### getErrorCode + +getErrorCode(): number + +获å–åŠ è½½èµ„æºçš„错误ç 。 + +**返回值:** +| 类型 | 说明 | +| ------ | ----------- | +| number | è¿”å›žåŠ è½½èµ„æºçš„错误ç 。 | + +### getErrorInfo + +getErrorInfo(): string + +获å–åŠ è½½èµ„æºçš„错误信æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| string | è¿”å›žåŠ è½½èµ„æºçš„错误信æ¯ã€‚ | + +## WebResourceRequest + +web组件获å–资æºè¯·æ±‚对象。示例代ç å‚考[onErrorReceive事件](#onerrorreceive)。 + +### getRequestHeader + +getResponseHeader() : Array\<Header\> + +获å–资æºè¯·æ±‚头信æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| -------------------------- | ---------- | +| Array\<[Header](#header)\> | 返回资æºè¯·æ±‚头信æ¯ã€‚ | + +### getRequestUrl + +getRequestUrl(): string + +获å–资æºè¯·æ±‚çš„URLä¿¡æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 返回资æºè¯·æ±‚çš„URLä¿¡æ¯ã€‚ | + +### isMainFrame + +isMainFrame(): boolean + +判æ–资æºè¯·æ±‚是å¦ä¸ºä¸»frame。 + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------- | +| boolean | 返回资æºè¯·æ±‚是å¦ä¸ºä¸»frame。 | + +### isRedirect + +isRedirect(): boolean + +判æ–资æºè¯·æ±‚是å¦è¢«æœåŠ¡ç«¯é‡å®šå‘。 + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------- | +| boolean | 返回资æºè¯·æ±‚是å¦è¢«æœåŠ¡ç«¯é‡å®šå‘。 | + +### isRequestGesture + +isRequestGesture(): boolean + +获å–资æºè¯·æ±‚是å¦ä¸Žæ‰‹åŠ¿ï¼ˆå¦‚点击)相关è”。 + +**返回值:** +| 类型 | 说明 | +| ------- | -------------------- | +| boolean | 返回资æºè¯·æ±‚是å¦ä¸Žæ‰‹åŠ¿ï¼ˆå¦‚点击)相关è”。 | + +## Header Web组件返回的请求/å“应头对象。 -| å‚æ•°å称 | å‚数类型 | å‚æ•°æè¿° | -| ----------- | -------- | -------------------- | -| headerKey | string | 请求/å“应头的key。 | -| headerValue | string | 请求/å“应头的value。 | - - -## WebResourceResponse对象说明 - -| 接å£å称 | 功能æè¿° | -| ------------------------------------------------------- | -------------------------------- | -| getReasonMessage(): string | 获å–资æºå“应的状æ€ç æ述。 | -| getResponseCode(): number | 获å–资æºå“应的状æ€ç 。 | -| getResponseData(): string | 获å–资æºå“应数æ®ã€‚ | -| getResponseEncoding(): string | 获å–资æºå“应的编ç 。 | -| getResponseHeader(): Array\<[Header](#header对象说明)\> | 获å–资æºå“应头。 | -| getResponseMimeType(): string | 获å–资æºå“应的媒体(MIME)类型。 | -| setResponseData<sup>9+</sup>(data: string) | 设置资æºå“应数æ®ã€‚ | -| setResponseEncoding<sup>9+</sup>(encoding: string) | 设置资æºå“应的编ç 。 | -| setResponseMimeType<sup>9+</sup>(mimeType: string) | 设置资æºå“应的媒体(MIME)类型。 | -| setReasonMessage<sup>9+</sup>(reason: string) | 设置资æºå“应的状æ€ç æ述。 | -| setResponseHeader<sup>9+</sup>(header: Array\<[Header](#header对象说明)\>) | 设置资æºå“应头。 | -| setResponseCode<sup>9+</sup>(code: number) | 设置资æºå“应的状æ€ç 。 | +| å称 | 类型 | æè¿° | +| ----------- | ------ | ------------- | +| headerKey | string | 请求/å“应头的key。 | +| headerValue | string | 请求/å“应头的value。 | -## RenderExitReason枚举说明 -onRenderExited接å£è¿”å›žçš„æ¸²æŸ“è¿›ç¨‹é€€å‡ºçš„å…·ä½“åŽŸå› ã€‚ +## WebResourceResponse -| å称 | æè¿° | -| -------------------------- | ---------------------------- | -| ProcessAbnormalTermination | 渲染进程异常退出。 | -| ProcessWasKilled | 收到SIGKILL,或被手动终æ¢ã€‚ | -| ProcessCrashed | 渲染进程崩溃退出,如段错误。 | -| ProcessOom | 程åºå†…å˜ä¸è¶³ã€‚ | -| ProcessExitUnknown | å…¶ä»–åŽŸå› ã€‚ | +web组件资æºå“应对象。示例代ç å‚考[onHttpErrorReceive事件](#onhttperrorreceive)。 -## MixedMode枚举说明 +### getReasonMessage -| å称 | æè¿° | -| ---------- | ----------------------------------------------------------- | -| All | å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。所有ä¸å®‰å…¨çš„内容都å¯ä»¥è¢«åŠ 载。 | -| Compatible | æ··åˆå†…容兼容性模å¼ï¼Œéƒ¨åˆ†ä¸å®‰å…¨çš„内容å¯èƒ½è¢«åŠ 载。 | -| None | ä¸å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。 | +getReasonMessage(): string -## CacheMode枚举说明 -| å称 | æè¿° | -| ------- | ------------------------------------------------------------ | -| Default | 使用未过期的cacheåŠ è½½èµ„æºï¼Œå¦‚æžœcacheä¸æ— 该资æºåˆ™ä»Žç½‘络ä¸èŽ·å–。 | -| None | åŠ è½½èµ„æºä½¿ç”¨cache,如果cacheä¸æ— 该资æºåˆ™ä»Žç½‘络ä¸èŽ·å–。 | -| Online | åŠ è½½èµ„æºä¸ä½¿ç”¨cache,全部从网络ä¸èŽ·å–。 | -| Only | åªä»Žcacheä¸åŠ 载资æºã€‚ | +获å–资æºå“应的状æ€ç æ述。 -## FileSelectorResult对象说明 -通知Web组件的文件选择结果。 +**返回值:** +| 类型 | 说明 | +| ------ | ------------- | +| string | 返回资æºå“应的状æ€ç æ述。 | -| 接å£å称 | 功能æè¿° | -| ---------------------------------------------- | ------------------------------------------------------------ | -| handleFileList(fileList: Array\<string>): void | 通知Web组件进行文件选择æ“作。fileList: 需è¦è¿›è¡Œæ“作的文件列表。 | +### getResponseCode -## FileSelectorParam对象说明 -| 接å£å称 | 功能æè¿° | -| -------------------------------- | ------------------------ | -| getTitle(): string | 获å–æ–‡ä»¶é€‰æ‹©å™¨æ ‡é¢˜ã€‚ | -| getMode(): FileSelectorMode | 获å–文件选择器的模å¼ã€‚ | -| getAcceptType(): Array\<string\> | 获å–文件过滤类型。 | -| isCapture(): boolean | 获å–是å¦è°ƒç”¨å¤šåª’体能力。 | +getResponseCode(): number -## FileSelectorMode枚举说明 -| å称 | æè¿° | -| -------------------- | -------------------- | -| FileOpenMode | æ‰“å¼€ä¸Šä¼ å•ä¸ªæ–‡ä»¶ã€‚ | -| FileOpenMultipleMode | æ‰“å¼€ä¸Šä¼ å¤šä¸ªæ–‡ä»¶ã€‚ | -| FileOpenFolderMode | æ‰“å¼€ä¸Šä¼ æ–‡ä»¶å¤¹æ¨¡å¼ã€‚ | -| FileSaveMode | 文件ä¿å˜æ¨¡å¼ã€‚ | +获å–资æºå“应的状æ€ç 。 + +**返回值:** +| 类型 | 说明 | +| ------ | ----------- | +| number | 返回资æºå“应的状æ€ç 。 | + +### getResponseData + +getResponseData(): string + +获å–资æºå“应数æ®ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | --------- | +| string | 返回资æºå“应数æ®ã€‚ | + +### getResponseEncoding + +getResponseEncoding(): string + +获å–资æºå“应的编ç 。 + +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | 返回资æºå“应的编ç 。 | + +### getResponseHeader + +getResponseHeader() : Array\<Header\> + +获å–资æºå“应头。 + +**返回值:** +| 类型 | 说明 | +| -------------------------- | -------- | +| Array\<[Header](#header)\> | 返回资æºå“应头。 | + +### getResponseMimeType + +getResponseMimeType(): string + +获å–资æºå“应的媒体(MIME)类型。 + +**返回值:** +| 类型 | 说明 | +| ------ | ------------------ | +| string | 返回资æºå“应的媒体(MIME)类型。 | + +### setResponseData<sup>9+</sup> + +setResponseData(data: string) + +设置资æºå“应数æ®ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ------ | ---- | ---- | ----------- | +| data | string | 是 | - | è¦è®¾ç½®çš„资æºå“应数æ®ã€‚ | + +### setResponseEncoding<sup>9+</sup> + +setResponseEncoding(encoding: string) + +设置资æºå“应的编ç 。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | ---- | ---- | ------------ | +| encoding | string | 是 | - | è¦è®¾ç½®çš„资æºå“应的编ç 。 | + +### setResponseMimeType<sup>9+</sup> + +setResponseMimeType(mimeType: string) + +设置资æºå“应的媒体(MIME)类型。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | ---- | ---- | -------------------- | +| mimeType | string | 是 | - | è¦è®¾ç½®çš„资æºå“应的媒体(MIME)类型。 | + +### setReasonMessage<sup>9+</sup> + +setReasonMessage(reason: string) + +设置资æºå“应的状æ€ç æ述。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------ | ------ | ---- | ---- | --------------- | +| reason | string | 是 | - | è¦è®¾ç½®çš„资æºå“应的状æ€ç æ述。 | + +### setResponseHeader<sup>9+</sup> + +setResponseHeader(header: Array\<Header\>) + +设置资æºå“应头。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------ | -------------------------- | ---- | ---- | ---------- | +| header | Array\<[Header](#header)\> | 是 | - | è¦è®¾ç½®çš„资æºå“应头。 | + +### setResponseCode<sup>9+</sup> + +setResponseCode(code: number) + +设置资æºå“应的状æ€ç 。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ------ | ---- | ---- | ------------- | +| code | number | 是 | - | è¦è®¾ç½®çš„资æºå“应的状æ€ç 。 | + +## FileSelectorResult<sup>9+</sup> + +通知Web组件的文件选择结果。示例代ç å‚考[onShowFileSelector事件](#onshowfileselector9)。 + +### handleFileList<sup>9+</sup> + +handleFileList(fileList: Array\<string\>): void + +通知Web组件进行文件选择æ“作。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | --------------- | ---- | ---- | ------------ | +| fileList | Array\<string\> | 是 | - | 需è¦è¿›è¡Œæ“作的文件列表。 | + +## FileSelectorParam<sup>9+</sup> + +web组件获å–文件对象。示例代ç å‚考[onShowFileSelector事件](#onshowfileselector9)。 + +### getTitle<sup>9+</sup> + +getTitle(): string + +获å–æ–‡ä»¶é€‰æ‹©å™¨æ ‡é¢˜ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| string | è¿”å›žæ–‡ä»¶é€‰æ‹©å™¨æ ‡é¢˜ã€‚ | + +### getMode<sup>9+</sup> + +getMode(): FileSelectorMode + +获å–文件选择器的模å¼ã€‚ + +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ----------- | +| [FileSelectorMode](#fileselectormode枚举说明) | 返回文件选择器的模å¼ã€‚ | + +### getAcceptType<sup>9+</sup> + +getAcceptType(): Array\<string\> + +获å–文件过滤类型。 + +**返回值:** +| 类型 | 说明 | +| --------------- | --------- | +| Array\<string\> | 返回文件过滤类型。 | + +### isCapture<sup>9+</sup> + +isCapture(): boolean + +获å–是å¦è°ƒç”¨å¤šåª’体能力。 + +**返回值:** +| 类型 | 说明 | +| ------- | ------------ | +| boolean | 返回是å¦è°ƒç”¨å¤šåª’体能力。 | + +## HttpAuthHandler<sup>9+</sup> + +Web组件返回的http auth认è¯è¯·æ±‚确认或å–消和使用缓å˜å¯†ç 认è¯åŠŸèƒ½å¯¹è±¡ã€‚示例代ç å‚考[onHttpAuthRequest事件](#onhttpauthrequest9)。 + +### cancel<sup>9+</sup> + +cancel(): void + +通知Web组件用户å–消HTTP认è¯æ“作。 + +### confirm<sup>9+</sup> + +confirm(userName: string, pwd: string): boolean + +使用用户å和密ç 进行HTTP认è¯æ“作。 + +**å‚数:** + +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | ---- | ---- | ---------- | +| userName | string | 是 | - | HTTP认è¯ç”¨æˆ·å。 | +| pwd | string | 是 | - | HTTP认è¯å¯†ç 。 | + +**返回值:** +| 类型 | 说明 | +| ------- | --------------------- | +| boolean | 认è¯æˆåŠŸè¿”回true,失败返回false。 | + +### isHttpAuthInfoSaved<sup>9+</sup> + +isHttpAuthInfoSaved(): boolean + +通知Web组件用户使用æœåŠ¡å™¨ç¼“å˜çš„è´¦å·å¯†ç 认è¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------- | ------------------------- | +| boolean | å˜åœ¨å¯†ç 认è¯æˆåŠŸè¿”回true,其他返回false。 | + +## PermissionRequest<sup>9+</sup> + +Web组件返回授æƒæˆ–æ‹’ç»æƒé™åŠŸèƒ½çš„对象。示例代ç å‚考[onPermissionRequest事件](#onpermissionrequest9)。 + +### deny<sup>9+</sup> + +deny(): void + +æ‹’ç»ç½‘页所请求的æƒé™ã€‚ + +### getOrigin<sup>9+</sup> + +getOrigin(): string + +获å–网页æ¥æºã€‚ + +**返回值:** + +| 类型 | 说明 | +| ------- | --------------------- | +| string | 当å‰è¯·æ±‚æƒé™ç½‘页的æ¥æºã€‚ | + +### getAccessibleResource<sup>9+</sup> + +getAccessibleResource(): Array\<string\> + +获å–网页所请求的æƒé™èµ„æºåˆ—表,资æºåˆ—表类型å‚考[ProtectedResourceType](#protectedresourcetype9枚举说明)。 + +**返回值:** + +| 类型 | 说明 | +| --------------- | ----------------------- | +| Array\<string\> | 网页所请求的æƒé™èµ„æºåˆ—表。 | + +### grant<sup>9+</sup> + +grant(resources: Array\<string\>): void + +对网页访问的给定æƒé™è¿›è¡ŒæŽˆæƒã€‚ + +**å‚数:** + +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| --------- | --------------- | ---- | ----- | ---------------------- | +| resources | Array\<string\> | 是 | - | 网页所请求的æƒé™èµ„æºåˆ—表。| ## WebController @@ -216,29 +1696,102 @@ accessBackward(): boolean 当å‰é¡µé¢æ˜¯å¦å¯åŽé€€ï¼Œå³å½“å‰é¡µé¢æ˜¯å¦æœ‰è¿”回历å²è®°å½•ã€‚ +**返回值:** +| 类型 | 说明 | +| ------- | --------------------- | +| boolean | å¯ä»¥åŽé€€è¿”回true,å¦åˆ™è¿”回false。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('accessBackward') + .onClick(() => { + let result = this.controller.accessBackward(); + console.log('result:' + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### accessForward accessForward(): boolean 当å‰é¡µé¢æ˜¯å¦å¯å‰è¿›ï¼Œå³å½“å‰é¡µé¢æ˜¯å¦æœ‰å‰è¿›åŽ†å²è®°å½•ã€‚ +**返回值:** +| 类型 | 说明 | +| ------- | --------------------- | +| boolean | å¯ä»¥å‰è¿›è¿”回true,å¦åˆ™è¿”回false。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('accessForward') + .onClick(() => { + let result = this.controller.accessForward(); + console.log('result:' + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### accessStep accessStep(step: number): boolean 当å‰é¡µé¢æ˜¯å¦å¯å‰è¿›æˆ–者åŽé€€ç»™å®šçš„stepæ¥ã€‚ -- å‚æ•° - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ------ | -------- | ---- | ------ | ------------------------------------------ | - | step | number | 是 | - | è¦è·³è½¬çš„æ¥æ•°ï¼Œæ£æ•°ä»£è¡¨å‰è¿›ï¼Œè´Ÿæ•°ä»£è¡¨åŽé€€ã€‚ | - -- 返回值 - - | å‚数类型 | 说明 | - | -------- | ------------------ | - | boolean | 页é¢æ˜¯å¦å‰è¿›æˆ–åŽé€€ | +**å‚数:** + +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ------ | ---- | ---- | --------------------- | +| step | number | 是 | - | è¦è·³è½¬çš„æ¥æ•°ï¼Œæ£æ•°ä»£è¡¨å‰è¿›ï¼Œè´Ÿæ•°ä»£è¡¨åŽé€€ã€‚ | + +**返回值:** +| 类型 | 说明 | +| ------- | --------- | +| boolean | 页é¢æ˜¯å¦å‰è¿›æˆ–åŽé€€ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + @State steps: number = 2; + + build() { + Column() { + Button('accessStep') + .onClick(() => { + let result = this.controller.accessStep(this.steps); + console.log('result:' + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` ### backward @@ -246,23 +1799,112 @@ backward(): void 按照历å²æ ˆï¼ŒåŽé€€ä¸€ä¸ªé¡µé¢ã€‚一般结åˆaccessBackward一起使用。 -### deleteJavaScriptRegister +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('backward') + .onClick(() => { + this.controller.backward(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` -deleteJavaScriptRegister(name: string): void +### forward -åˆ é™¤é€šè¿‡registerJavaScriptProxy注册到window上的指定name的应用侧JavaScript对象。 +forward(): void -- å‚æ•° +按照历å²æ ˆï¼Œå‰è¿›ä¸€ä¸ªé¡µé¢ã€‚一般结åˆaccessForward一起使用。 - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ------ | -------- | ---- | ------ | ------------------------------------------------------------ | - | name | string | 是 | - | 注册对象的å称,å¯åœ¨ç½‘页侧JavaScriptä¸é€šè¿‡æ¤å称调用应用侧JavaScript对象。 | +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('forward') + .onClick(() => { + this.controller.forward(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### backOrForward<sup>9+</sup> + +backOrForward(step: number): void + +按照历å²æ ˆï¼Œå‰è¿›æˆ–者åŽé€€æŒ‡å®šæ¥é•¿çš„页é¢ï¼Œå½“历å²æ ˆä¸ä¸å˜åœ¨å¯¹åº”æ¥é•¿çš„页é¢æ—¶ï¼Œä¸ä¼šè¿›è¡Œé¡µé¢è·³è½¬ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ------ | ---- | ---- | ----------- | +| step | number | 是 | - | 需è¦å‰è¿›æˆ–åŽé€€çš„æ¥é•¿ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller:WebController = new WebController(); + build() { + Column() { + Button('backOrForward') + .onClick(() => { + this.controller.backOrForward(); + }) + Web({ src:'www.example.com', controller:this.controller }) + } + } + ``` -### forward +### deleteJavaScriptRegister -forward(): void +deleteJavaScriptRegister(name: string) -按照历å²æ ˆï¼Œå‰è¿›ä¸€ä¸ªé¡µé¢ã€‚一般结åˆaccessForward一起使用。 +åˆ é™¤é€šè¿‡registerJavaScriptProxy注册到window上的指定name的应用侧JavaScript对象。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| name | string | 是 | - | 注册对象的å称,å¯åœ¨ç½‘页侧JavaScriptä¸é€šè¿‡æ¤å称调用应用侧JavaScript对象。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + @State name: string = 'Object'; + + build() { + Column() { + Button('deleteJavaScriptRegister') + .onClick(() => { + this.controller.deleteJavaScriptRegister(this.name); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` ### getHitTest @@ -270,21 +1912,191 @@ getHitTest(): HitTestType 获å–当å‰è¢«ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ç±»åž‹ã€‚ -- HitTestType枚举说明 - - | å称 | æè¿° | - | ------------- | ----------------------------------------- | - | EditText | å¯ç¼–辑的区域。 | - | Email | 电å邮件地å€ã€‚ | - | HttpAnchor | 超链接。其src为http。 | - | HttpAnchorImg | 带有超链接的图片,其ä¸è¶…链接的src为http。 | - | Img | HTML::imgæ ‡ç¾ã€‚ | - | Map | 地ç†åœ°å€ã€‚ | - | Unknown | 未知内容。 | +**返回值:** +| 类型 | 说明 | +| ------------------------------- | ----------- | +| [HitTestType](#hittesttype枚举说明) | è¢«ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ç±»åž‹ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getHitTest') + .onClick(() => { + let hitType = this.controller.getHitTest(); + console.log("hitType: " + hitType); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getHitTestValue<sup>9+</sup> +getHitTestValue(): HitTestValue + +获å–当å‰è¢«ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ä¿¡æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------------------------------ | ---------- | +| [HitTestValue](#hittestvalue9) | ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ä¿¡æ¯ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getHitTestValue') + .onClick(() => { + let hitValue = this.controller.getHitTestValue(); + console.log("hitType: " + hitValue.getType()); + console.log("extra: " + hitValue.getExtra()); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getWebId<sup>9+</sup> +getWebId(): number + +获å–当å‰Web组件的索引值,用于多个Web组件的管ç†ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| number | 当å‰Web组件的索引值。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getWebId') + .onClick(() => { + let id = this.controller.getWebId(); + console.log("id: " + id); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getTitle<sup>9+</sup> +getTitle(): string + +获å–当å‰ç½‘é¡µçš„æ ‡é¢˜ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | -------- | +| string | 当å‰ç½‘é¡µçš„æ ‡é¢˜ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getTitle') + .onClick(() => { + let title = this.controller.getTitle(); + console.log("title: " + title); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getPageHeight<sup>9+</sup> +getPageHeight(): number + +获å–当å‰ç½‘页的页é¢é«˜åº¦ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ---------- | +| number | 当å‰ç½‘页的页é¢é«˜åº¦ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getPageHeight') + .onClick(() => { + let pageHeight = this.controller.getPageHeight(); + console.log("pageHeight: " + pageHeight); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getDefaultUserAgent<sup>9+</sup> +getDefaultUserAgent(): string + +获å–当å‰é»˜è®¤ç”¨æˆ·ä»£ç†ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ------- | +| string | 默认用户代ç†ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getDefaultUserAgent') + .onClick(() => { + let userAgent = this.controller.getDefaultUserAgent(); + console.log("userAgent: " + userAgent); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` ### loadData -loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string }): void +loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string }) baseUrl为空时,通过â€data“åè®®åŠ è½½æŒ‡å®šçš„ä¸€æ®µå—符串。 @@ -292,19 +2104,42 @@ baseUrl为空时,通过â€data“åè®®åŠ è½½æŒ‡å®šçš„ä¸€æ®µå—符串。 当baseUrl为“http/https"å议时,编ç åŽçš„dataå—符串将被Web组件以类似loadUrlçš„æ–¹å¼ä»¥éžç¼–ç å—符串处ç†ã€‚ -- optionså‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ---------- | -------- | ---- | ------ | ------------------------------------------------------------ | - | data | string | 是 | - | 按照â€Base64“或者â€URL"ç¼–ç åŽçš„一段å—符串。 | - | mimeType | string | 是 | - | 媒体类型(MIME)。 | - | encoding | string | 是 | - | ç¼–ç 类型,具体为“Base64"或者â€URLç¼–ç 。 | - | baseUrl | string | å¦ | - | 指定的一个URL路径(“httpâ€/“httpsâ€/"data"å议),并由Web组件赋值给window.origin。 | - | historyUrl | string | å¦ | - | 历å²è®°å½•URL。éžç©ºæ—¶ï¼Œå¯è¢«åŽ†å²è®°å½•ç®¡ç†ï¼Œå®žçŽ°å‰åŽåŽé€€åŠŸèƒ½ã€‚当baseUrl为空时,æ¤å±žæ€§æ— 效。 | +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | ------ | ---- | ---- | ---------------------------------------- | +| data | string | 是 | - | 按照â€Base64“或者â€URL"ç¼–ç åŽçš„一段å—符串。 | +| mimeType | string | 是 | - | 媒体类型(MIME)。 | +| encoding | string | 是 | - | ç¼–ç 类型,具体为“Base64"或者â€URLç¼–ç 。 | +| baseUrl | string | å¦ | - | 指定的一个URL路径(“httpâ€/“httpsâ€/"data"å议),并由Web组件赋值给window.origin。 | +| historyUrl | string | å¦ | - | 历å²è®°å½•URL。éžç©ºæ—¶ï¼Œå¯è¢«åŽ†å²è®°å½•ç®¡ç†ï¼Œå®žçŽ°å‰åŽåŽé€€åŠŸèƒ½ã€‚当baseUrl为空时,æ¤å±žæ€§æ— 效。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('loadData') + .onClick(() => { + this.controller.loadData({ + data: "<html><body bgcolor=\"white\">Source:<pre>source</pre></body></html>", + mimeType: "text/html", + encoding: "UTF-8" + }); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` ### loadUrl -loadUrl(options:{ url: string, headers?: Array\<Header\> }): void +loadUrl(options: { url: string | Resource, headers?: Array\<Header\> }) 使用指定的httpå¤´åŠ è½½æŒ‡å®šçš„URL。 @@ -312,12 +2147,31 @@ loadUrl(options:{ url: string, headers?: Array\<Header\> }): void 而通过registerJavaScriptProxy注入的对象,在loadUrl导航到新的页é¢ä¹Ÿä¼šæœ‰æ•ˆã€‚ -- optionså‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ------- | ---------------------------------- | ---- | ------ | --------------------- | - | url | string | 是 | - | 需è¦åŠ 载的 URL。 | - | headers | Array\<[Header](#header对象说明)\> | å¦ | [] | URLçš„é™„åŠ HTTP请求头。 | +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------- | -------------------------- | ---- | ---- | -------------- | +| url | string | 是 | - | 需è¦åŠ 载的 URL。 | +| headers | Array\<[Header](#header)\> | å¦ | [] | URLçš„é™„åŠ HTTP请求头。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('loadUrl') + .onClick(() => { + this.controller.loadUrl({ url: 'www.example.com' }); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` ### onActive @@ -325,130 +2179,992 @@ onActive(): void 调用æ¤æŽ¥å£é€šçŸ¥Web组件进入å‰å°æ¿€æ´»çŠ¶æ€ã€‚ +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('onActive') + .onClick(() => { + this.controller.onActive(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### onInactive onInactive(): void 调用æ¤æŽ¥å£é€šçŸ¥Web组件进入未激活状æ€ã€‚ +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('onInactive') + .onClick(() => { + this.controller.onInactive(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### zoom +zoom(factor: number): void + +调整当å‰ç½‘页的缩放比例。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | å‚æ•°æè¿° | +| ------ | ------ | ---- | ------------------------------ | +| factor | number | 是 | 基于当å‰ç½‘页所需调整的相对缩放比例,æ£å€¼ä¸ºæ”¾å¤§ï¼Œè´Ÿå€¼ä¸ºç¼©å°ã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + @State factor: number = 1; + + build() { + Column() { + Button('zoom') + .onClick(() => { + this.controller.zoom(this.factor); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### zoomIn<sup>9+</sup> +zoomIn(): boolean + +调用æ¤æŽ¥å£å°†å½“å‰ç½‘页进行放大,比列20%。 + +**返回值:** +| 类型 | 说明 | +| ------- | ----------- | +| boolean | 放大æ“作是å¦æˆåŠŸæ‰§è¡Œã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('zoomIn') + .onClick(() => { + let result = this.controller.zoomIn(); + console.log("result: " + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### zoomOut<sup>9+</sup> +zoomOut(): boolean + +调用æ¤æŽ¥å£å°†å½“å‰ç½‘页进行缩å°ï¼Œæ¯”列20%。 + +**返回值:** +| 类型 | 说明 | +| ------- | ----------- | +| boolean | 缩å°æ“作是å¦æˆåŠŸæ‰§è¡Œã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('zoomOut') + .onClick(() => { + let result = this.controller.zoomOut(); + console.log("result: " + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### refresh -refresh(): void +refresh() 调用æ¤æŽ¥å£é€šçŸ¥Web组件刷新网页。 +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('refresh') + .onClick(() => { + this.controller.refresh(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### registerJavaScriptProxy -registerJavaScriptProxy(options: { object: object, name: string, methodList: Array\<string\> }): void +registerJavaScriptProxy(options: { object: object, name: string, methodList: Array\<string\> }) 注入JavaScript对象到window对象ä¸ï¼Œå¹¶åœ¨window对象ä¸è°ƒç”¨è¯¥å¯¹è±¡çš„方法。注册åŽï¼Œé¡»è°ƒç”¨refresh接å£ç”Ÿæ•ˆã€‚ -- options å‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ---------- | --------------- | ---- | ------ | ------------------------------------------------------------ | - | object | object | 是 | - | å‚与注册的应用侧JavaScript对象。åªèƒ½å£°æ˜Žæ–¹æ³•ï¼Œä¸èƒ½å£°æ˜Žå±žæ€§ 。其ä¸æ–¹æ³•çš„å‚数和返回类型åªèƒ½ä¸ºstring,number,boolean | - | name | string | 是 | - | 注册对象的å称,与windowä¸è°ƒç”¨çš„对象å一致。注册åŽwindow对象å¯ä»¥é€šè¿‡æ¤åå—访问应用侧JavaScript对象。 | - | methodList | Array\<string\> | 是 | - | å‚与注册的应用侧JavaScript对象的方法。 | +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------- | --------------- | ---- | ---- | ---------------------------------------- | +| object | object | 是 | - | å‚与注册的应用侧JavaScript对象。åªèƒ½å£°æ˜Žæ–¹æ³•ï¼Œä¸èƒ½å£°æ˜Žå±žæ€§ 。其ä¸æ–¹æ³•çš„å‚数和返回类型åªèƒ½ä¸ºstring,number,boolean | +| name | string | 是 | - | 注册对象的å称,与windowä¸è°ƒç”¨çš„对象å一致。注册åŽwindow对象å¯ä»¥é€šè¿‡æ¤åå—访问应用侧JavaScript对象。 | +| methodList | Array\<string\> | 是 | - | å‚与注册的应用侧JavaScript对象的方法。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct Index { + controller: WebController = new WebController() + testObj = { + test: (data) => { + return "ArkUI Web Component"; + }, + toString: () => { + console.log('Web Component toString'); + } + } + build() { + Column() { + Row() { + Button('Register JavaScript To Window').onClick(() => { + this.controller.registerJavaScriptProxy({ + object: this.testObj, + name: "objName", + methodList: ["test", "toString"], + }); + }) + } + Web({ src: $rawfile('index.html'), controller: this.controller }) + .javaScriptAccess(true) + } + } + } + ``` + + ```html + <!-- index.html --> + <!DOCTYPE html> + <html> + <meta charset="utf-8"> + <body> + Hello world! + </body> + <script type="text/javascript"> + function htmlTest() { + str = objName.test("test function"); + console.log('objName.test result:'+ str); + } + </script> + </html> + + ``` ### runJavaScript -runJavaScript(options: { script: string, callback?: (result: string) => void }): void +runJavaScript(options: { script: string, callback?: (result: string) => void }) 异æ¥æ‰§è¡ŒJavaScript脚本,并通过回调方å¼è¿”回脚本执行的结果。runJavaScript需è¦åœ¨loadUrl完æˆåŽï¼Œæ¯”如onPageEndä¸è°ƒç”¨ã€‚ -- optionså‚数说明 +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------------------------ | ---- | ---- | ---------------------------------------- | +| script | string | 是 | - | JavaScript脚本。 | +| callback | (result: string) => void | å¦ | - | 回调执行JavaScript脚本结果。JavaScriptè„šæœ¬è‹¥æ‰§è¡Œå¤±è´¥æˆ–æ— è¿”å›žå€¼æ—¶ï¼Œè¿”å›žnull。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + @State webResult: string = '' + build() { + Column() { + Text(this.webResult).fontSize(20) + Web({ src: $rawfile('index.html'), controller: this.controller }) + .javaScriptAccess(true) + .onPageEnd(e => { + this.controller.runJavaScript({ + script: 'test()', + callback: (result: string)=> { + this.webResult = result + console.info(`The test() return value is: ${result}`) + }}); + console.info('url: ', e.url); + }) + } + } + } + ``` + + ```html + <!-- index.html --> + <!DOCTYPE html> + <html> + <meta charset="utf-8"> + <body> + Hello world! + </body> + <script type="text/javascript"> + function test() { + console.log('Ark WebComponent'); + return "This value is from index.html" + } + </script> + </html> - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | -------- | ------------------------ | ---- | ------ | ------------------------------------------------------------ | - | script | string | 是 | - | JavaScript脚本。 | - | callback | (result: string) => void | å¦ | - | 回调执行JavaScript脚本结果。JavaScriptè„šæœ¬è‹¥æ‰§è¡Œå¤±è´¥æˆ–æ— è¿”å›žå€¼æ—¶ï¼Œè¿”å›žnull。 | + ``` ### stop -stop(): void +stop() åœæ¢é¡µé¢åŠ 载。 +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('stop') + .onClick(() => { + this.controller.stop(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + ### clearHistory clearHistory(): void åˆ é™¤æ‰€æœ‰å‰è¿›åŽé€€è®°å½•ã€‚ -### getCookieManager +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('clearHistory') + .onClick(() => { + this.controller.clearHistory(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getCookieManager<sup>9+</sup> getCookieManager(): WebCookie 获å–web组件cookie管ç†å¯¹è±¡ã€‚ -- 返回值 - | å‚数类型 | 说明 | - | --------- | -------------------------------------------------------- | - | WebCookie | web组件cookie管ç†å¯¹è±¡ï¼Œå‚考[WebCookie](#webcookie)定义。 | + +**返回值:** +| 类型 | 说明 | +| --------- | ---------------------------------------- | +| WebCookie | web组件cookie管ç†å¯¹è±¡ï¼Œå‚考[WebCookie](#webcookie)定义。 | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('getCookieManager') + .onClick(() => { + let cookieManager = this.controller.getCookieManager(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +## HitTestValue<sup>9+</sup> +æä¾›ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ä¿¡æ¯ã€‚示例代ç å‚考[getHitTestValue](#gethittestvalue9)。 + +### getType<sup>9+</sup> +getType(): HitTestType + +获å–当å‰è¢«ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ç±»åž‹ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------------------------------- | ------------- | +| [HitTestType](#hittesttype枚举说明) | 当å‰è¢«ç‚¹å‡»åŒºåŸŸçš„å…ƒç´ ç±»åž‹ã€‚ | + +### getExtra<sup>9+</sup> +getExtra(): string + +è‹¥è¢«ç‚¹å‡»åŒºåŸŸä¸ºå›¾ç‰‡æˆ–é“¾æŽ¥ï¼Œåˆ™é™„åŠ å‚æ•°ä¿¡æ¯ä¸ºå…¶url地å€ã€‚ + +**返回值:** +| 类型 | 说明 | +| ------ | ------------ | +| string | ç‚¹å‡»åŒºåŸŸçš„é™„åŠ å‚æ•°ä¿¡æ¯ã€‚ | + ## WebCookie + 通过WebCookieå¯ä»¥æŽ§åˆ¶Web组件ä¸çš„cookieçš„å„ç§è¡Œä¸ºï¼Œå…¶ä¸æ¯ä¸ªåº”用ä¸çš„所有web组件共享一个WebCookie。通过controller方法ä¸çš„getCookieManager方法å¯ä»¥èŽ·å–WebCookie对象,进行åŽç»çš„cookie管ç†æ“作。 -### setCookie + +### setCookie<sup>9+</sup> setCookie(url: string, value: string): boolean 设置cookie,该方法为åŒæ¥æ–¹æ³•ã€‚设置æˆåŠŸè¿”回true,å¦åˆ™è¿”回false。 -- å‚数说明 - - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | ------ | -------- | ---- | ------ | ------------------------- | - | url | string | 是 | - | è¦è®¾ç½®çš„cookie所属的url。 | - | value | string | 是 | - | cookie的值。 | -- 返回值 - | å‚数类型 | 说明 | - | -------- | -------------------- | - | boolean | 设置cookie是å¦æˆåŠŸã€‚ | +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ----- | ------ | ---- | ---- | ----------------- | +| url | string | 是 | - | è¦è®¾ç½®çš„cookie所属的url。 | +| value | string | 是 | - | cookie的值。 | + +**返回值:** +| 类型 | 说明 | +| ------- | ------------- | +| boolean | 设置cookie是å¦æˆåŠŸã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('setCookie') + .onClick(() => { + let result = this.controller.getCookieManager().setCookie("www.example.com", "a=b"); + console.log("result: " + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` -### saveCookieSync +### saveCookieSync<sup>9+</sup> saveCookieSync(): boolean 将当å‰å˜åœ¨å†…å˜ä¸çš„cookieåŒæ¥åˆ°ç£ç›˜ä¸ï¼Œè¯¥æ–¹æ³•ä¸ºåŒæ¥æ–¹æ³•ã€‚ -- 返回值 - | å‚数类型 | 说明 | - | -------- | ---------------------------------- | - | boolean | åŒæ¥å†…å˜cookie到ç£ç›˜æ“作是å¦æˆåŠŸã€‚ | -## 示例 - -```ts -// webComponent.ets -@Entry -@Component -struct WebComponent { - @State javaScriptAccess: boolean = true; - @State fileAccess: boolean = true; - controller: WebController = new WebController(); - build() { - Column() { - Web({ src: $rawfile('index.html'), controller: this.controller }) - .javaScriptAccess(this.javaScriptAccess) - .fileAccess(this.fileAccess) - .onPageEnd(e => { - // test() 在 index.html ä¸å·²å®šä¹‰ - this.controller.runJavaScript({ script: 'test()' }); - console.log("url: ", e.url); - }) - } - } -} -``` -```html -<!-- index.html --> -<!DOCTYPE html> -<html> -<meta charset="utf-8"> -<body> - Hello world! -</body> -<script type="text/javascript"> - function test() { - console.log('Ark WebComponent'); - } -</script> -</html> -``` - \ No newline at end of file +**返回值:** +| 类型 | 说明 | +| ------- | -------------------- | +| boolean | åŒæ¥å†…å˜cookie到ç£ç›˜æ“作是å¦æˆåŠŸã€‚ | + +**示例:** + ```ts + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('saveCookieSync') + .onClick(() => { + let result = this.controller.getCookieManager().saveCookieSync(); + console.log("result: " + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +## WebDataBase<sup>9+</sup> +web组件数æ®åº“管ç†å¯¹è±¡ã€‚ + +### existHttpAuthCredentials<sup>9+</sup> + +static existHttpAuthCredentials(): boolean + +判æ–是å¦å˜åœ¨ä»»ä½•å·²ä¿å˜çš„HTTP身份验è¯å‡æ®ï¼Œè¯¥æ–¹æ³•ä¸ºåŒæ¥æ–¹æ³•ã€‚å˜åœ¨è¿”回true,ä¸å˜åœ¨è¿”回false。 + +**返回值:** +| 类型 | 说明 | +| ------- | ---------------------------------------- | +| boolean | 是å¦å˜åœ¨ä»»ä½•å·²ä¿å˜çš„HTTP身份验è¯å‡æ®ã€‚å˜åœ¨è¿”回true,ä¸å˜åœ¨è¿”回false | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('existHttpAuthCredentials') + .onClick(() => { + let result = web.WebDataBase.existHttpAuthCredentials(); + console.log('result: ' + result); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### deleteHttpAuthCredentials<sup>9+</sup> + +static deleteHttpAuthCredentials(): void + +清除所有已ä¿å˜çš„HTTP身份验è¯å‡æ®ï¼Œè¯¥æ–¹æ³•ä¸ºåŒæ¥æ–¹æ³•ã€‚ + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + + build() { + Column() { + Button('deleteHttpAuthCredentials') + .onClick(() => { + web.WebDataBase.deleteHttpAuthCredentials(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### getHttpAuthCredentials<sup>9+</sup> + +static getHttpAuthCredentials(host: string, realm: string): Array\<string\> + +检索给定主机和域的HTTP身份验è¯å‡æ®ï¼Œè¯¥æ–¹æ³•ä¸ºåŒæ¥æ–¹æ³•ã€‚检索æˆåŠŸè¿”回一个包å«ç”¨æˆ·å和密ç 的组数,检索ä¸æˆåŠŸè¿”回空数组。 + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ----- | ------ | ---- | ---- | ---------------- | +| host | string | 是 | - | HTTP身份验è¯å‡æ®åº”用的主机。 | +| realm | string | 是 | - | HTTP身份验è¯å‡æ®åº”用的域。 | + +**返回值:** +| 类型 | 说明 | +| --------------- | ---------------------- | +| Array\<string\> | 包å«ç”¨æˆ·å和密ç 的组数,检索失败返回空数组。 | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + host: string = "www.spincast.org"; + realm: string = "protected example"; + username_password: string[]; + build() { + Column() { + Button('getHttpAuthCredentials') + .onClick(() => { + this.username_password = web.WebDataBase.getHttpAuthCredentials(this.host, this.realm); + console.log('num: ' + this.username_password.length); + ForEach(this.username_password, (item) => { + console.log('username_password: ' + item); + }, item => item) + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +### saveHttpAuthCredentials<sup>9+</sup> + +static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void + +ä¿å˜ç»™å®šä¸»æœºå’ŒåŸŸçš„HTTP身份验è¯å‡æ®ï¼Œè¯¥æ–¹æ³•ä¸ºåŒæ¥æ–¹æ³•ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | ---- | ---- | ---------------- | +| host | string | 是 | - | HTTP身份验è¯å‡æ®åº”用的主机。 | +| realm | string | 是 | - | HTTP身份验è¯å‡æ®åº”用的域。 | +| username | string | 是 | - | 用户å。 | +| password | string | 是 | - | 密ç 。 | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + host: string = "www.spincast.org"; + realm: string = "protected example"; + build() { + Column() { + Button('saveHttpAuthCredentials') + .onClick(() => { + web.WebDataBase.saveHttpAuthCredentials(this.host, this.realm, "Stromgol", "Laroche"); + }) + Web({ src: 'www.example.com', controller: this.controller }) + } + } + } + ``` + +## WebStorage<sup>9+</sup> +通过WebStorageå¯ç®¡ç†Web SQLæ•°æ®åº“接å£å’ŒHTML5 Webå˜å‚¨æŽ¥å£ï¼Œæ¯ä¸ªåº”用ä¸çš„所有Web组件共享一个WebStorage。 +### deleteAllData<sup>9+</sup> +static deleteAllData(): void + +清除Web SQLæ•°æ®åº“当å‰ä½¿ç”¨çš„所有å˜å‚¨ã€‚ + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + build() { + Column() { + Button('deleteAllData') + .onClick(() => { + web.WebStorage.deleteAllData(); + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### deleteOrigin<sup>9+</sup> +static deleteOrigin(origin : string): void + +清除指定æºæ‰€ä½¿ç”¨çš„å˜å‚¨ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------- | +| origin | string | 是 | 指定æºçš„å—符串索引。 | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getHttpAuthCredentials') + .onClick(() => { + web.WebStorage.deleteOrigin(this.origin); + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOrigins<sup>9+</sup> +static getOrigins(callback: AsyncCallback<Array<[WebStorageOrigin]>>) : void + +以回调方å¼å¼‚æ¥èŽ·å–当å‰ä½¿ç”¨Web SQLæ•°æ®åº“的所有æºçš„ä¿¡æ¯ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ---------------------------------------- | ---- | ----------------------------------- | +| callback | AsyncCallback<Array<[WebStorageOrigin](#webstorageorigin9)>> | 是 | 以数组方å¼è¿”回æºçš„ä¿¡æ¯ï¼Œä¿¡æ¯å†…容å‚考WebStorageOrigin。 | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOrigins') + .onClick(() => { + web.WebStorage.getOrigins((error, origins) => { + if (error) { + console.log('error: ' + error); + return; + } + for (let i = 0; i < origins.length; i++) { + console.log('origin: ' + origins[i].origin); + console.log('usage: ' + origins[i].usage); + console.log('quota: ' + origins[i].quota); + } + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOrigins<sup>9+</sup> +static getOrigins() : Promise<Array<[WebStorageOrigin]>> + +以Promiseæ–¹å¼å¼‚æ¥èŽ·å–当å‰ä½¿ç”¨Web SQLæ•°æ®åº“的所有æºçš„ä¿¡æ¯ã€‚ + +**返回值:** +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------------- | +| Promise<Array<[WebStorageOrigin](#webstorageorigin9)>> | Promise实例,用于获å–当å‰æ‰€æœ‰æºçš„ä¿¡æ¯ï¼Œä¿¡æ¯å†…容å‚考WebStorageOrigin。 | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOrigins') + .onClick(() => { + web.WebStorage.getOrigins() + .then(origins => { + for (let i = 0; i < origins.length; i++) { + console.log('origin: ' + origins[i].origin); + console.log('usage: ' + origins[i].usage); + console.log('quota: ' + origins[i].quota); + } + }) + .catch(error => { + console.log('error: ' + error); + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOriginQuota<sup>9+</sup> +static getOriginQuota(origin : string, callback : AsyncCallback\<number>) : void + +使用callback回调异æ¥èŽ·å–指定æºçš„Web SQLæ•°æ®åº“çš„å˜å‚¨é…é¢ï¼Œé…é¢ä»¥å—节为å•ä½ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | --------- | +| origin | string | 是 | 指定æºçš„å—符串索引 | +| callback | AsyncCallback\<number> | 是 | 指定æºçš„å˜å‚¨é…é¢ã€‚ | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOriginQuota') + .onClick(() => { + web.WebStorage.getOriginQuota(this.origin, (error, quota) => { + if (error) { + console.log('error: ' + error); + return; + } + console.log('quota: ' + quota); + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOriginQuota<sup>9+</sup> +static getOriginQuota(origin : string) : Promise\<number> + +以Promiseæ–¹å¼å¼‚æ¥èŽ·å–指定æºçš„Web SQLæ•°æ®åº“çš„å˜å‚¨é…é¢ï¼Œé…é¢ä»¥å—节为å•ä½ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------- | +| origin | string | 是 | 指定æºçš„å—符串索引。 | + +**返回值:** +| 类型 | 说明 | +| ---------------- | ----------------------- | +| Promise\<number> | Promise实例,用于获å–指定æºçš„å˜å‚¨é…é¢ã€‚ | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOriginQuota') + .onClick(() => { + web.WebStorage.getOriginQuota(this.origin) + .then(quota => { + console.log('quota: ' + quota); + }) + .catch(error => { + console.log('error: ' + error); + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOriginUsage<sup>9+</sup> +static getOriginUsage(origin : string, callback : AsyncCallback\<number>) : void + +以回调方å¼å¼‚æ¥èŽ·å–指定æºçš„Web SQLæ•°æ®åº“çš„å˜å‚¨é‡ï¼Œå˜å‚¨é‡ä»¥å—节为å•ä½ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| -------- | ---------------------- | ---- | ---------- | +| origin | string | 是 | 指定æºçš„å—符串索引。 | +| callback | AsyncCallback\<number> | 是 | 指定æºçš„å˜å‚¨é‡ã€‚ | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOriginUsage') + .onClick(() => { + web.WebStorage.getOriginUsage(this.origin, (error, usage) => { + if (error) { + console.log('error: ' + error); + return; + } + consloe.log('usage: ' + usage); + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +### getOriginUsage<sup>9+</sup> +static getOriginUsage(origin : string) : Promise\<number> + +以Promiseæ–¹å¼å¼‚æ¥èŽ·å–指定æºçš„Web SQLæ•°æ®åº“çš„å˜å‚¨é‡ï¼Œå˜å‚¨é‡ä»¥å—节为å•ä½ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------- | +| origin | string | 是 | 指定æºçš„å—符串索引。 | + +**返回值:** +| 类型 | 说明 | +| ---------------- | ---------------------- | +| Promise\<number> | Promise实例,用于获å–指定æºçš„å˜å‚¨é‡ã€‚ | + +**示例:** + ```ts + // xxx.ets + import web from '@ohos.web'; + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + origin: string = "origin"; + build() { + Column() { + Button('getOriginQuota') + .onClick(() => { + web.WebStorage.getOriginUsage(this.origin) + .then(usage => { + console.log('usage: ' + usage); + }) + .catch(error => { + console.log('error: ' + error); + }) + }) + Web({ src: 'www.example.com', controller: this.controller }) + .databaseAccess(true) + } + } + } + ``` + +## WebStorageOrigin<sup>9+</sup> + +æä¾›Web SQLæ•°æ®åº“的使用信æ¯ã€‚ + +**å‚数:** +| å‚æ•°å | å‚数类型 | å¿…å¡« | 说明 | +| ------ | ------ | ---- | ---------- | +| origin | string | 是 | 指定æºçš„å—符串索引。 | +| usage | number | 是 | 指定æºçš„å˜å‚¨é‡ã€‚ | +| quota | number | 是 | 指定æºçš„å˜å‚¨é…é¢ã€‚ | + +## MessageLevel枚举说明 + +| å称 | æè¿° | +| ----- | :---- | +| Debug | 调试级别。 | +| Error | 错误级别。 | +| Info | 消æ¯çº§åˆ«ã€‚ | +| Log | 日志级别。 | +| Warn | è¦å‘Šçº§åˆ«ã€‚ | + +## RenderExitReason枚举说明 + +onRenderExited接å£è¿”å›žçš„æ¸²æŸ“è¿›ç¨‹é€€å‡ºçš„å…·ä½“åŽŸå› ã€‚ + +| å称 | æè¿° | +| -------------------------- | ----------------- | +| ProcessAbnormalTermination | 渲染进程异常退出。 | +| ProcessWasKilled | 收到SIGKILL,或被手动终æ¢ã€‚ | +| ProcessCrashed | 渲染进程崩溃退出,如段错误。 | +| ProcessOom | 程åºå†…å˜ä¸è¶³ã€‚ | +| ProcessExitUnknown | å…¶ä»–åŽŸå› ã€‚ | + +## MixedMode枚举说明 + +| å称 | æè¿° | +| ---------- | ---------------------------------- | +| All | å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。所有ä¸å®‰å…¨çš„内容都å¯ä»¥è¢«åŠ 载。 | +| Compatible | æ··åˆå†…容兼容性模å¼ï¼Œéƒ¨åˆ†ä¸å®‰å…¨çš„内容å¯èƒ½è¢«åŠ 载。 | +| None | ä¸å…è®¸åŠ è½½HTTPå’ŒHTTPSæ··åˆå†…容。 | + +## CacheMode枚举说明 +| å称 | æè¿° | +| ------- | ------------------------------------ | +| Default | 使用未过期的cacheåŠ è½½èµ„æºï¼Œå¦‚æžœcacheä¸æ— 该资æºåˆ™ä»Žç½‘络ä¸èŽ·å–。 | +| None | åŠ è½½èµ„æºä½¿ç”¨cache,如果cacheä¸æ— 该资æºåˆ™ä»Žç½‘络ä¸èŽ·å–。 | +| Online | åŠ è½½èµ„æºä¸ä½¿ç”¨cache,全部从网络ä¸èŽ·å–。 | +| Only | åªä»Žcacheä¸åŠ 载资æºã€‚ | + +## FileSelectorMode枚举说明 +| å称 | æè¿° | +| -------------------- | ---------- | +| FileOpenMode | æ‰“å¼€ä¸Šä¼ å•ä¸ªæ–‡ä»¶ã€‚ | +| FileOpenMultipleMode | æ‰“å¼€ä¸Šä¼ å¤šä¸ªæ–‡ä»¶ã€‚ | +| FileOpenFolderMode | æ‰“å¼€ä¸Šä¼ æ–‡ä»¶å¤¹æ¨¡å¼ã€‚ | +| FileSaveMode | 文件ä¿å˜æ¨¡å¼ã€‚ | + + ## HitTestType枚举说明 + +| å称 | æè¿° | +| ------------- | ------------------------ | +| EditText | å¯ç¼–辑的区域。 | +| Email | 电å邮件地å€ã€‚ | +| HttpAnchor | 超链接,其src为http。 | +| HttpAnchorImg | 带有超链接的图片,其ä¸è¶…链接的src为http。 | +| Img | HTML::imgæ ‡ç¾ã€‚ | +| Map | 地ç†åœ°å€ã€‚ | +| Unknown | 未知内容。 | + +## ProtectedResourceType<sup>9+</sup>枚举说明 + +| å称 | æè¿° | 备注 | +| --------- | -------------- | -------------- | +| MidiSysex | MIDI SYSEX资æºã€‚| ç›®å‰ä»…支æŒæƒé™äº‹ä»¶ä¸ŠæŠ¥ï¼ŒMIDI设备的使用还未支æŒã€‚| \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md index a9d70accd7d88e1d2715d06407c7c9bfc627dccd..a16c30fb3ab8e46fb947384bc86869b7dff8316f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-xcomponent.md @@ -1,7 +1,7 @@ # XComponent > **说明:** - > 该组件从API Version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 + > 该组件从API Version 8 开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 å¯ç”¨äºŽEGL/OpenGLES和媒体数æ®å†™å…¥ï¼Œå¹¶æ˜¾ç¤ºåœ¨XComponent组件。 @@ -83,8 +83,8 @@ getXComponentContext(): Object ## 示例 -æä¾›surface类型XComponent,支æŒç›¸æœºé¢„览ç‰èƒ½åŠ›ã€‚ - +æä¾›surface类型XComponent,支æŒç›¸æœºé¢„览ç‰èƒ½åŠ›ã€‚ +示例效果请以真机è¿è¡Œä¸ºå‡†ï¼Œå½“å‰IDE预览器ä¸æ”¯æŒã€‚ ```ts // xxx.ets import camera from '@ohos.multimedia.camera'; diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md index 317f763e1e1af6bba81cf61bfbed7749992b7751..d55eb0105e3ab4ff05f8b12c0169b73e8c44d702 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md @@ -46,21 +46,21 @@ PinchGesture(options?: { fingers?: number, distance?: number }) @Entry @Component struct PinchGestureExample { - @State scale: number = 1 + @State scaleValue: number = 1 build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Text('PinchGesture scale:' + this.scale) } .height(100).width(200).padding(20).border({ width: 1 }).margin(80) - .scale({ x: this.scale, y: this.scale, z: this.scale }) + .scale({ x: this.scaleValue, y: this.scaleValue, z: this.scaleValue }) .gesture( PinchGesture() .onActionStart((event: GestureEvent) => { console.info('Pinch start') }) .onActionUpdate((event: GestureEvent) => { - this.scale = event.scale + this.scaleValue = event.scale }) .onActionEnd(() => { console.info('Pinch end') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 602a4899e45964f304c58de3f5a725fde384ea2d..fcbb96d0992f6a596f7b0ea8856e40acf31dcf66 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -19,14 +19,14 @@ CanvasRenderingContext2D(setting: RenderingContextSetting) ### RenderingContextSettings -RenderingContextSettings(antialias?: bool) +RenderingContextSettings(antialias?: boolean) 用æ¥é…ç½®CanvasRenderingContext2D对象的å‚数,包括是å¦å¼€å¯æŠ—锯齿。 - å‚æ•° - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | - | --------- | ---- | ---- | ----- | ---------------- | - | antialias | bool | å¦ | false | 表明canvas是å¦å¼€å¯æŠ—锯齿。 | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | --------- | ------- | ---- | ----- | ---------------- | + | antialias | boolean | å¦ | false | 表明canvas是å¦å¼€å¯æŠ—锯齿。 | ## 属性 @@ -258,7 +258,7 @@ struct MiterLimit { // xxx.ets @Entry @Component -struct Font { +struct Fonts { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) @@ -1746,17 +1746,17 @@ drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sWidth: number, 进行图åƒç»˜åˆ¶ã€‚ - å‚æ•° - | å‚æ•° | 类型 | å¿…å¡« | 默认值 | æè¿° | - | ------- | ---------------------------------------- | ---- | ---- | ----------------------------- | - | image | [ImageBitmap](ts-components-canvas-imagebitmap.md)或[PixelMap](../apis/js-apis-image.md#pixelmap7) | 是 | null | 图片资æºï¼Œè¯·å‚考ImageBitmap或PixelMap。 | - | sx | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶è·ç¦»æºå›¾åƒå·¦ä¸Šè§’çš„xåæ ‡å€¼ã€‚ | - | sy | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶è·ç¦»æºå›¾åƒå·¦ä¸Šè§’çš„yåæ ‡å€¼ã€‚ | - | sWidth | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶éœ€è¦è£åˆ‡çš„宽度。 | - | sHeight | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶éœ€è¦è£åˆ‡çš„高度。 | - | dx | number | 是 | 0 | 绘制区域左上角在xè½´çš„ä½ç½®ã€‚ | - | dy | number | 是 | 0 | 绘制区域左上角在y è½´çš„ä½ç½®ã€‚ | - | dWidth | number | å¦ | 0 | 绘制区域的宽度。 | - | dHeight | number | å¦ | 0 | 绘制区域的高度。 | + | å‚æ•° | 类型 | å¿…å¡« | 默认值 | æè¿° | + | ------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | + | image | [ImageBitmap](ts-components-canvas-imagebitmap.md)或[PixelMap](../apis/js-apis-image.md#pixelmap7) | 是 | null | 图片资æºï¼Œè¯·å‚考ImageBitmap或PixelMap。 | + | sx | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶è·ç¦»æºå›¾åƒå·¦ä¸Šè§’çš„xåæ ‡å€¼ã€‚ | + | sy | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶è·ç¦»æºå›¾åƒå·¦ä¸Šè§’çš„yåæ ‡å€¼ã€‚ | + | sWidth | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶éœ€è¦è£åˆ‡çš„宽度。 | + | sHeight | number | å¦ | 0 | è£åˆ‡æºå›¾åƒæ—¶éœ€è¦è£åˆ‡çš„高度。 | + | dx | number | 是 | 0 | 绘制区域左上角在xè½´çš„ä½ç½®ã€‚ | + | dy | number | 是 | 0 | 绘制区域左上角在y è½´çš„ä½ç½®ã€‚ | + | dWidth | number | å¦ | 0 | 绘制区域的宽度。当绘制区域的宽度和è£å‰ªå›¾åƒçš„宽度ä¸ä¸€è‡´æ—¶ï¼Œå°†å›¾åƒå®½åº¦æ‹‰ä¼¸æˆ–压缩为绘制区域的宽度。 | + | dHeight | number | å¦ | 0 | 绘制区域的高度。当绘制区域的高度和è£å‰ªå›¾åƒçš„高度ä¸ä¸€è‡´æ—¶ï¼Œå°†å›¾åƒé«˜åº¦æ‹‰ä¼¸æˆ–压缩为绘制区域的高度。 | - 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-combined-gestures.md b/zh-cn/application-dev/reference/arkui-ts/ts-combined-gestures.md index d5d3324e8a027846ca166638f9be4c9a93d90602..b702af0af1c0573fb956353f282a4704dd47c084 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-combined-gestures.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-combined-gestures.md @@ -46,13 +46,13 @@ struct GestureGroupExample { @State count: number = 0 @State offsetX: number = 0 @State offsetY: number = 0 - @State borderStyle: BorderStyle = BorderStyle.Solid + @State borderStyles: BorderStyle = BorderStyle.Solid build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) }.translate({ x: this.offsetX, y: this.offsetY, z: 5 }) - .height(100).width(200).padding(10).margin(80).border({ width: 1, style: this.borderStyle }) + .height(100).width(200).padding(10).margin(80).border({ width: 1, style: this.borderStyles }) .gesture( GestureGroup(GestureMode.Sequence, LongPressGesture({ repeat: true }) @@ -65,7 +65,7 @@ struct GestureGroupExample { }), PanGesture({}) .onActionStart(() => { - this.borderStyle = BorderStyle.Dashed + this.borderStyles = BorderStyle.Dashed console.log('pan start') }) .onActionUpdate((event: GestureEvent) => { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md index 90c23a37039a941962026127fbbb90a0ce6fc1db..2c37265fd0b029bed6458350d2642c2a5500ec18 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md @@ -17,7 +17,7 @@ addColorStop(offset: number, color: string): void | å‚æ•° | 类型 | å¿…å¡« | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -------- | | offset | number | 是 | 0 | 设置æ¸å˜ç‚¹è·ç¦»èµ·ç‚¹çš„ä½ç½®å 总体长度的比例,范围为0到1。 | - | color | string | 是 | 'ffffff' | 设置æ¸å˜çš„颜色。 | + | color | string | 是 | '#ffffff' | 设置æ¸å˜çš„颜色。 | - 示例 ```ts diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md index d6717d2d95ec031d03f99441c2504acc2dd0d15d..b0bfd71a88505c675658bca83cb2eda3d39851d7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-ability-component.md @@ -41,34 +41,20 @@ ohos.permission.INTEGRATED_INTERIOR_WINDOW ## æŽ¥å£ -AbilityComponent(value: {want : Want, controller? : AbilityController}) +AbilityComponent(value: {want : Want}) - å‚æ•° | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | | -------- | -------- | -------- | -------- | -------- | | want | [Want](../../reference/apis/js-apis-application-Want.md) | 是 | - | é»˜è®¤åŠ è½½çš„Abilityæ述。 | - | controller | [AbilityController](#abilityController) | å¦ | - | Ability控制器。 | ## 事件 | å称 | 功能æè¿° | | -------- | -------- | -| onReady() => void | AbilityComponent环境å¯åŠ¨å®Œæˆæ—¶çš„回调,之åŽå¯ä½¿ç”¨AbilityComponent的方法。 | -| onDestroy() => void | AbilityComponent环境销æ¯æ—¶çš„回调。 | -| onAbilityCreated(name: string) => void | åŠ è½½Ability时触å‘,name为Abilityå。 | -| onAbilityMoveToFont() => void | 当Ability移动到å‰å°æ—¶è§¦å‘。 | -| onAbilityWillRemove() => void | Ability移除之å‰è§¦å‘。 | - -## AbilityController - -Ability控制器,æä¾›AbilityComponent的控制接å£ã€‚ - -| å称 | 功能æè¿° | -| --------------------------------------- | ------------------------------------------------------------ | -| startAbility() => want | 在AbilityComponentå†…éƒ¨åŠ è½½Ability。<br>want:è¦åŠ 载的Abilityæè¿°ä¿¡æ¯ã€‚ | -| preformBackPress() => void | 在AbilityComponent内部执行返回æ“作。 | -| getStackCount() => void | 获å–AbilityComponentå†…éƒ¨ä»»åŠ¡æ ˆä¸ä»»åŠ¡çš„个数。 | +| onConnect() => void | AbilityComponent环境å¯åŠ¨å®Œæˆæ—¶çš„回调,之åŽå¯ä½¿ç”¨AbilityComponent的方法。 | +| onDisconnect() => void | AbilityComponent环境销æ¯æ—¶çš„回调。 | ## 示例 @@ -78,7 +64,6 @@ Ability控制器,æä¾›AbilityComponent的控制接å£ã€‚ @Entry @Component struct MyComponent { - @State controller: AbilityController = new AbilityController() build() { Column() { @@ -87,26 +72,12 @@ struct MyComponent { bundleName: '', abilityName: '' }, - controller: this.controller - }) - .onReady(() => { - console.log('AbilityComponent ready'); }) - .onDestory(() => { - console.log('AbilityComponent destory'); - }) - Button("Start New") - .onClick(() => { - this.controller.startAbility({ - bundleName: '', - abilityName: '' - }); + .onConnect(() => { + console.log('AbilityComponent connect'); }) - Button("Back") - .onClick(() => { - if (this.controller.getStacjCount() > 1) { - this.controller.preformBackPress(); - } + .onDisconnect(() => { + console.log('AbilityComponent disconnect'); }) } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md index 4f83bc1fcc1967187cb60abf1efa133d12741171..e618bdb2db9974a8686548e96a2bea53202ec68b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md @@ -23,9 +23,9 @@ Column(value:{space?: Length}) - å‚æ•° - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | | -------- | -------- | -------- | -------- | -------- | - | space | Length | å¦ | 0 | 纵å‘å¸ƒå±€å…ƒç´ é—´è·ã€‚ | + | space | Length | å¦ | 0 | 纵å‘å¸ƒå±€å…ƒç´ é—´è·ã€‚ | ## 属性 @@ -33,13 +33,13 @@ Column(value:{space?: Length}) | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | | alignItems | HorizontalAlign | HorizontalAlign.Center | 设置å组件在水平方å‘上的对é½æ ¼å¼ã€‚ | -| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | 设置å组件在垂直方å‘上的对é½æ ¼å¼ã€‚ | +| justifyContent<sup>8+</sup> | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | 设置å组件在垂直方å‘上的对é½æ ¼å¼ã€‚ | - HorizontalAlign枚举说明 - | å称 | æè¿° | + | å称 | æè¿° | | -------- | -------- | - | Start | 按照è¯è¨€æ–¹å‘起始端对é½ã€‚ | - | Center | å±…ä¸å¯¹é½ï¼Œé»˜è®¤å¯¹é½æ–¹å¼ã€‚ | + | Start | 按照è¯è¨€æ–¹å‘起始端对é½ã€‚ | + | Center | å±…ä¸å¯¹é½ï¼Œé»˜è®¤å¯¹é½æ–¹å¼ã€‚ | | End | 按照è¯è¨€æ–¹å‘末端对é½ã€‚ | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-flex.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-flex.md index 8cf11c00aebb020da33014a16a1bd50bce0ccabb..354136dd9454b0c5734f556e75d4f778d1a2ae33 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-flex.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-flex.md @@ -3,7 +3,8 @@ 应用弹性方å¼å¸ƒå±€å组件的容器组件。 > **说明:** -> 该组件从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> - 该组件从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> - Flex组件在设置flexShrinkã€flexGrowæ—¶å˜åœ¨äºŒæ¬¡å¸ƒå±€è¿‡ç¨‹ï¼Œå› æ¤åœ¨å¯¹æ€§èƒ½æœ‰ä¸¥æ ¼è¦æ±‚的场景下建议使用[Column](ts-container-column.md)ã€[Row](ts-container-row.md)代替。 ## æƒé™åˆ—表 @@ -40,21 +41,21 @@ Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: F | ColumnReverse | 与Column相åæ–¹å‘进行布局。 | - FlexWrap枚举说明 - | å称 | æè¿° | - | ----------- | --------------------------- | - | NoWrap | Flexå®¹å™¨çš„å…ƒç´ å•è¡Œ/列布局,å项å…许超出容器。 | - | Wrap | Flexå®¹å™¨çš„å…ƒç´ å¤šè¡Œ/列排布,å项å…许超出容器。 | + | å称 | æè¿° | + | ----------- | ------------------------------------------------- | + | NoWrap | Flexå®¹å™¨çš„å…ƒç´ å•è¡Œ/列布局,å项ä¸å…许超出容器。 | + | Wrap | Flexå®¹å™¨çš„å…ƒç´ å¤šè¡Œ/列排布,å项å…许超出容器。 | | WrapReverse | Flexå®¹å™¨çš„å…ƒç´ åå‘多行/列排布,å项å…许超出容器。 | - FlexAlign枚举说明 - | å称 | æè¿° | - | ------------ | ---------------------------------------- | - | Start | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘首端对é½, ç¬¬ä¸€ä¸ªå…ƒç´ ä¸Žè¡Œé¦–å¯¹é½ï¼ŒåŒæ—¶åŽç»çš„å…ƒç´ ä¸Žå‰ä¸€ä¸ªå¯¹é½ã€‚ | - | Center | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘ä¸å¿ƒå¯¹é½ï¼Œç¬¬ä¸€ä¸ªå…ƒç´ 与行首的è·ç¦»ä¸Žæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾è·ç¦»ç›¸åŒã€‚ | - | End | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘尾部对é½, 最åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ï¼Œå…¶ä»–å…ƒç´ ä¸ŽåŽä¸€ä¸ªå¯¹é½ã€‚ | - | SpaceBetween | Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ ç¬¬ä¸€ä¸ªå…ƒç´ ä¸Žè¡Œé¦–å¯¹é½ï¼Œæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ã€‚ | - | SpaceAround | Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ ç¬¬ä¸€ä¸ªå…ƒç´ åˆ°è¡Œé¦–çš„è·ç¦»å’Œæœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的è·ç¦»æ˜¯ç›¸é‚»å…ƒç´ 之间è·ç¦»çš„一åŠã€‚ | - | SpaceEvenly | Flex主轴方å‘å…ƒç´ ç‰é—´è·å¸ƒå±€ï¼Œ ç›¸é‚»å…ƒç´ ä¹‹é—´çš„é—´è·ã€ç¬¬ä¸€ä¸ªå…ƒç´ 与行首的间è·ã€æœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的间è·éƒ½å®Œå…¨ä¸€æ ·ã€‚ | + | å称 | æè¿° | + | ------------ | ------------------------------------------------------------ | + | Start | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘首端对é½ï¼Œç¬¬ä¸€ä¸ªå…ƒç´ 与行首对é½ï¼ŒåŒæ—¶åŽç»çš„å…ƒç´ ä¸Žå‰ä¸€ä¸ªå¯¹é½ã€‚ | + | Center | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘ä¸å¿ƒå¯¹é½ï¼Œç¬¬ä¸€ä¸ªå…ƒç´ 与行首的è·ç¦»ä¸Žæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾è·ç¦»ç›¸åŒã€‚ | + | End | å…ƒç´ åœ¨ä¸»è½´æ–¹å‘尾部对é½ï¼Œæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ï¼Œå…¶ä»–å…ƒç´ ä¸ŽåŽä¸€ä¸ªå¯¹é½ã€‚ | + | SpaceBetween | Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ç¬¬ä¸€ä¸ªå…ƒç´ ä¸Žè¡Œé¦–å¯¹é½ï¼Œæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ã€‚ | + | SpaceAround | Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ç¬¬ä¸€ä¸ªå…ƒç´ åˆ°è¡Œé¦–çš„è·ç¦»å’Œæœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的è·ç¦»æ˜¯ç›¸é‚»å…ƒç´ 之间è·ç¦»çš„一åŠã€‚ | + | SpaceEvenly | Flex主轴方å‘å…ƒç´ ç‰é—´è·å¸ƒå±€ï¼Œç›¸é‚»å…ƒç´ 之间的间è·ã€ç¬¬ä¸€ä¸ªå…ƒç´ 与行首的间è·ã€æœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的间è·éƒ½å®Œå…¨ä¸€æ ·ã€‚ | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md index 36959733612a951be41c2149c7ceca7e4c9a4a8e..8bb8b3941407b4d87c412161d1b0453a75865348 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md @@ -4,7 +4,7 @@ > 该组件从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 -å¯æ»‘动é¢æ¿ã€‚æ供一ç§è½»é‡çš„内容展示的窗å£ï¼Œå¯æ–¹ä¾¿çš„在ä¸åŒå°ºå¯¸ä¸åˆ‡æ¢ï¼Œå±žäºŽå¼¹å‡ºå¼ç»„件。 +å¯æ»‘动é¢æ¿ï¼Œæ供一ç§è½»é‡çš„内容展示窗å£ï¼Œæ–¹ä¾¿åœ¨ä¸åŒå°ºå¯¸ä¸åˆ‡æ¢ã€‚ ## æƒé™åˆ—表 @@ -37,6 +37,7 @@ Panel(value:{show:boolean}) | fullHeight | Length | - | 指定PanelMode.Full状æ€ä¸‹çš„高度。 | | halfHeight | Length | - | 指定PanelMode.Half状æ€ä¸‹çš„高度,默认为å±å¹•å°ºå¯¸çš„一åŠã€‚ | | miniHeight | Length | - | 指定PanelMode.Mini状æ€ä¸‹çš„高度。 | +| backgroundMask<sup>9+</sup>|(color: ResourceColor)| - |指定Panel的背景蒙层。| - PanelType枚举说明 | å称 | æè¿° | @@ -58,7 +59,7 @@ Panel(value:{show:boolean}) | å称 | 功能æè¿° | | -------- | -------- | | onChange(callback: (width: number, height: number, mode: PanelMode) => void) | 当å¯æ»‘动é¢æ¿å‘生状æ€å˜åŒ–时触å‘, 返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbaré«˜åº¦åŠ ä¸Šå†…å®¹åŒºé«˜åº¦ã€‚ | - +| onHeightChange(callback: (value: number) => void)<sup>9+</sup> |当å¯æ»‘动é¢æ¿å‘生高度å˜åŒ–时触å‘,返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbaré«˜åº¦åŠ ä¸Šå†…å®¹åŒºé«˜åº¦ã€‚å› ç”¨æˆ·ä½“éªŒè®¾è®¡åŽŸå› ï¼Œpanel最高åªèƒ½æ»‘到 fullHeight-8vp | ## 示例 @@ -70,7 +71,7 @@ struct PanelExample { @State show: boolean = false build() { - Column() { + Stack() { Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') .width('90%').height(50).borderRadius(10) .backgroundColor(0xFFFFFF).padding({ left: 20 }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md index df2ace39644d48184188f66496ca8e03e40b48ed..4fa205a6d17c448a23c7036382a17dba00f84a21 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -21,7 +21,7 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri | å‚æ•° | å‚æ•°å | å¿…å¡« | 默认值 | å‚æ•°æè¿° | | -------- | -------- | -------- | -------- | -------- | - | refreshing | boolean | 是 | - | 当å‰ç»„件是å¦æ£åœ¨åˆ·æ–°ã€‚ | + | refreshing | boolean | 是 | - | 当å‰ç»„件是å¦æ£åœ¨åˆ·æ–°ã€‚<br/>该å‚数支æŒ[$$](../../ui/ts-syntactic-sugar.md)åŒå‘绑定å˜é‡ã€‚ | | offset | Length | å¦ | 16 | 刷新组件é™æ¢æ—¶è·ç¦»çˆ¶ç»„件顶部的è·ç¦»ã€‚| | friction | number \| string | å¦ | 62 | 下拉摩擦系数,å–值范围为0到100。<br/>- 0表示下拉刷新容器ä¸è·Ÿéšæ‰‹åŠ¿ä¸‹æ‹‰è€Œä¸‹æ‹‰ã€‚<br/>- 100表示下拉刷新容器紧紧跟éšæ‰‹åŠ¿ä¸‹æ‹‰è€Œä¸‹æ‹‰ã€‚<br/>- 数值越大,下拉刷新容器跟éšæ‰‹åŠ¿ä¸‹æ‹‰çš„å应越çµæ•ã€‚ | @@ -58,7 +58,7 @@ struct RefreshExample { build() { Column() { - Refresh({refreshing: this.isRefreshing, offset: 120, friction: 100}) { + Refresh({refreshing: $$this.isRefreshing, offset: 120, friction: 100}) { Text('Pull Down and refresh: ' + this.counter) .fontSize(30) .margin(10) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 7adf41f484b9c26ce78810d87ecd8bf6a6e401a1..08577a7f5c796380fb31d6bd004bd768579caa81 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -1,7 +1,8 @@ # Scroll > **说明:** -> 该组件从API version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> - 该组件从API version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> - 该组件嵌套Listå组件滚动时,若Listä¸è®¾ç½®å®½é«˜ï¼Œåˆ™é»˜è®¤å…¨éƒ¨åŠ 载,在对性能有è¦æ±‚的场景下建议指定List的宽高。 å¯æ»šåŠ¨çš„容器组件,当å组件的布局尺寸超过父组件的视å£æ—¶ï¼Œå†…容å¯ä»¥æ»šåŠ¨ã€‚ @@ -172,14 +173,20 @@ struct ScrollExample { Column() { ForEach(this.arr, (item) => { Text(item.toString()) - .width('90%').height(150).backgroundColor(0xFFFFFF) - .borderRadius(15).fontSize(16).textAlign(TextAlign.Center) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) .margin({ top: 10 }) }, item => item) }.width('100%') } - .scrollable(ScrollDirection.Vertical).scrollBar(BarState.On) - .scrollBarColor(Color.Gray).scrollBarWidth(30) + .scrollable(ScrollDirection.Vertical) + .scrollBar(BarState.On) + .scrollBarColor(Color.Gray) + .scrollBarWidth(30) .onScroll((xOffset: number, yOffset: number) => { console.info(xOffset + ' ' + yOffset) }) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 6217c50da6b0fd7d2eec01b7d3b98a59b372ebf9..7bcd121930a08b8e892d31cda640625c455117c4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -43,6 +43,7 @@ SideBarContainer( type?: SideBarContainerType ) | minSideBarWidth | number \| [Length<sup>9+</sup>](../../ui/ts-types.md#长度类型) | 200 | 设置侧边æ 最å°å®½åº¦ã€‚ | | maxSideBarWidth | number \| [Length<sup>9+</sup>](../../ui/ts-types.md#长度类型) | 280 | 设置侧边æ 最大宽度。 | | autoHide<sup>9+</sup> | boolean | true | 设置当侧边æ 拖拽到å°äºŽæœ€å°å®½åº¦åŽï¼Œæ˜¯å¦è‡ªåŠ¨éšè—。 | +| sideBarPosition<sup>9+</sup> | SideBarPosition | SideBarPosition.Start | 设置侧边æ 显示ä½ç½®ã€‚ | - ButtonStyle对象说明 | å称 | å‚数类型 | å¿…å¡« | 默认值 | æè¿° | @@ -53,6 +54,11 @@ SideBarContainer( type?: SideBarContainerType ) | height | number | å¦ | 32 | 设置侧边æ 控制按钮的高度。 | | icons | {<br/>shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md) <br/>} | å¦ | - | 设置侧边æ æŽ§åˆ¶æŒ‰é’®çš„å›¾æ ‡ï¼š<br/> </p> - shown: 设置侧边æ æ˜¾ç¤ºæ—¶æŽ§åˆ¶æŒ‰é’®çš„å›¾æ ‡ã€‚<br>- hidden: 设置侧边æ éšè—æ—¶æŽ§åˆ¶æŒ‰é’®çš„å›¾æ ‡ã€‚<br>- switching:设置侧边æ 显示和éšè—状æ€åˆ‡æ¢æ—¶æŽ§åˆ¶æŒ‰é’®çš„å›¾æ ‡ã€‚ | +- SideBarPosition<sup>9+</sup>枚举说明 + | å称 | æè¿° | + | -------- | -------- | + | Start | 侧边æ ä½äºŽå®¹å™¨å·¦ä¾§ã€‚ | + | End | 侧边æ ä½äºŽå®¹å™¨å³ä¾§ã€‚ | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md index 7c612c94cb36f2894a1482b48013b6e5cc3c69b2..65ecaca1ec862b6c3e1adcaa6dec536c82f68960 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -35,7 +35,7 @@ Swiper(value:{controller?: SwiperController}) | autoPlay | boolean | false | å组件是å¦è‡ªåŠ¨æ’放,自动æ’放状æ€ä¸‹ï¼Œå¯¼èˆªç‚¹ä¸å¯æ“作。 | | interval | number | 3000 | 使用自动æ’放时æ’放的时间间隔,å•ä½ä¸ºæ¯«ç§’。 | | indicator | boolean | true | 是å¦å¯ç”¨å¯¼èˆªç‚¹æŒ‡ç¤ºå™¨ã€‚ | -| loop | boolean | true | 是å¦å¼€å¯å¾ªçŽ¯ã€‚ | +| loop | boolean | true | 是å¦å¼€å¯å¾ªçŽ¯ã€‚<br>设置为true时表示开å¯å¾ªçŽ¯ï¼Œåœ¨LazyForEachæ‡’å¾ªçŽ¯åŠ è½½æ¨¡å¼ä¸‹ï¼ŒåŠ 载的组件数é‡å»ºè®®å¤§äºŽ5个。 | | duration | number | 400 | å组件切æ¢çš„动画时长,å•ä½ä¸ºæ¯«ç§’。 | | vertical | boolean | false | 是å¦ä¸ºçºµå‘滑动。 | | itemSpace | Length | 0 | 设置å组件与å组件之间间隙。 | @@ -45,7 +45,7 @@ Swiper(value:{controller?: SwiperController}) | indicatorStyle<sup>8+</sup> | {<br/>left?: Length,<br/>top?: Length,<br/>right?: Length,<br/>bottom?: Length,<br/>size?: Length,<br/>color?: Color,<br/>selectedColor?: Color<br/>} | - | 设置indicatoræ ·å¼ï¼š<br/>- left: 设置导航点è·ç¦»Swiper组件左边的è·ç¦»ã€‚<br/>- top: 设置导航点è·ç¦»Swiper组件顶部的è·ç¦»ã€‚<br/>- right: 设置导航点è·ç¦»Swiper组件å³è¾¹çš„è·ç¦»ã€‚<br/>- bottom: 设置导航点è·ç¦»Swiper组件底部的è·ç¦»ã€‚<br/>- size: 设置导航点的直径。<br/>- color: 设置导航点的颜色。<br/>- selectedColor: 设置选ä¸çš„导航点的颜色。 | -### SwiperController +## SwiperController Swiper容器组件的控制器,å¯ä»¥å°†æ¤å¯¹è±¡ç»‘定至Swiper组件,然åŽé€šè¿‡å®ƒæŽ§åˆ¶ç¿»é¡µã€‚ @@ -96,7 +96,7 @@ struct SwiperExample { private swiperController: SwiperController = new SwiperController() private data: MyDataSource = new MyDataSource([]) - private aboutToAppear(): void { + aboutToAppear(): void { let list = [] for (var i = 1; i <= 10; i++) { list.push(i.toString()); diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md index 810c345c4c352220c258f5fd3d5990e0a1f6b3d4..ea24e62cf3c731f2c63e493f23c741469d136c2c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -29,10 +29,10 @@ Tabs(value: {barPosition?: BarPosition, index?: number, controller?: [TabsContro | controller | [TabsController](#tabscontroller) | å¦ | - | 设置Tabs控制器。 | - BarPosition枚举说明 - | å称 | æè¿° | + | å称 | æè¿° | | -------- | -------- | - | Start | vertical属性方法设置为true时,页ç¾ä½äºŽå®¹å™¨å·¦ä¾§ï¼›vertical属性方法设置为false时,页ç¾ä½äºŽå®¹å™¨é¡¶éƒ¨ã€‚ | - | End | vertical属性方法设置为true时,页ç¾ä½äºŽå®¹å™¨å³ä¾§ï¼›vertical属性方法设置为false时,页ç¾ä½äºŽå®¹å™¨åº•éƒ¨ã€‚ | + | Start | vertical属性方法设置为true时,页ç¾ä½äºŽå®¹å™¨å·¦ä¾§ï¼›vertical属性方法设置为false时,页ç¾ä½äºŽå®¹å™¨é¡¶éƒ¨ã€‚ | + | End | vertical属性方法设置为true时,页ç¾ä½äºŽå®¹å™¨å³ä¾§ï¼›vertical属性方法设置为false时,页ç¾ä½äºŽå®¹å™¨åº•éƒ¨ã€‚ | ## 属性 @@ -41,25 +41,25 @@ Tabs(value: {barPosition?: BarPosition, index?: number, controller?: [TabsContro | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| vertical | boolean | 是å¦ä¸ºçºµå‘Tab,默认为false。 | 是å¦ä¸ºçºµå‘Tab,默认为false。 | -| scrollable | boolean | 是å¦å¯ä»¥é€šè¿‡å·¦å³æ»‘动进行页é¢åˆ‡æ¢ï¼Œé»˜è®¤ä¸ºtrue。 | 是å¦å¯ä»¥é€šè¿‡å·¦å³æ»‘动进行页é¢åˆ‡æ¢ï¼Œé»˜è®¤ä¸ºtrue。 | -| barMode | BarMode | TabBar布局模å¼ã€‚ | TabBar布局模å¼ã€‚ | -| barWidth | number | TabBar的宽度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | TabBar的宽度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | -| barHeight | number | TabBar的高度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | TabBar的高度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | +| vertical | boolean | false | 是å¦ä¸ºçºµå‘Tab,默认为false。 | +| scrollable | boolean | true | 是å¦å¯ä»¥é€šè¿‡å·¦å³æ»‘动进行页é¢åˆ‡æ¢ï¼Œé»˜è®¤ä¸ºtrue。 | +| barMode | BarMode | BarMode.Fixed | TabBar布局模å¼ã€‚ | +| barWidth | number | - | TabBar的宽度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | +| barHeight | number | - | TabBar的高度值,ä¸è®¾ç½®æ—¶ä½¿ç”¨ç³»ç»Ÿä¸»é¢˜ä¸çš„默认值。 | | animationDuration | number | 200 | TabContent滑动动画时长。 | - BarMode枚举说明 - | å称 | æè¿° | + | å称 | æè¿° | | -------- | -------- | - | Scrollable | TabBar使用实际布局宽度, 超过总长度åŽå¯æ»‘动。 | - | Fixed | 所有TabBarå¹³å‡åˆ†é…宽度。 | + | Scrollable | TabBar使用实际布局宽度, 超过总长度åŽå¯æ»‘动。 | + | Fixed | 所有TabBarå¹³å‡åˆ†é…宽度。 | ## 事件 -| å称 | 功能æè¿° | +| å称 | 功能æè¿° | | -------- | -------- | -| onChange(callback: (index: number) => void) | Tab页ç¾åˆ‡æ¢åŽè§¦å‘的事件。 | +| onChange(callback: (index: number) => void) | Tab页ç¾åˆ‡æ¢åŽè§¦å‘的事件。 | ## TabsController @@ -79,7 +79,7 @@ changeIndex(value: number): void 控制Tabs切æ¢åˆ°æŒ‡å®šé¡µç¾ã€‚ - å‚æ•° - | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | + | å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | | -------- | -------- | -------- | -------- | -------- | | value | number | 是 | - | 页ç¾åœ¨Tabs里的索引值,索引值从0开始。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md index 20e5fafc7e541a777b61d16ae3199c2fcae4d1fa..e5fa15b4f5f00a4e48c29d4fda75d75293b97b5d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md @@ -12,30 +12,30 @@ - 示例 ``` -// xxx.ets @Entry - @Component - struct Index { - @Builder MenuBuilder(){ - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Text('close') - .fontSize(30) - .fontWeight(FontWeight.Bold) - .onClick(() => { - ContextMenu.close(); - }) - }.height(400) - .backgroundColor(Color.Pink) - - } - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { - Column(){ - Text("Text") - }.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) - } - .width('100%') - .height('100%') +@Component +struct Index { + @Builder MenuBuilder() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('close') + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + ContextMenu.close(); + }) + }.height(400) + .backgroundColor(Color.Pink) + + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { + Column() { + Text("Text") + }.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) } + .width('100%') + .height('100%') } +} ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 636b48a740299ad172913c7f111ab131e6ddb4e4..67c71bd0f8629e485eca456e700dddd7047c2ab2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -266,7 +266,7 @@ struct MiterLimit { // xxx.ets @Entry @Component -struct Font { +struct Fonts { private settings: RenderingContextSettings = new RenderingContextSettings(true) private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) @@ -1920,12 +1920,12 @@ getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap 以当å‰canvas指定区域内的åƒç´ 创建[PixelMap](../apis/js-apis-image.md#pixelmap7)对象。 - å‚æ•° - | å‚æ•° | 类型 | å¿…å¡« | 默认值 | æè¿° | + | å‚æ•° | 类型 | å¿…å¡« | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -------- | - | sx | number | 是 | 0 | 需è¦è¾“出的区域的左上角xåæ ‡ã€‚ | - | sy | number | 是 | 0 | 需è¦è¾“出的区域的左上角yåæ ‡ã€‚ | - | sw | number | 是 | 0 | 需è¦è¾“出的区域的宽度。 | - | sh | number | 是 | 0 | 需è¦è¾“出的区域的高度。 | + | sx | number | 是 | 0 | 需è¦è¾“出的区域的左上角xåæ ‡ã€‚ | + | sy | number | 是 | 0 | 需è¦è¾“出的区域的左上角yåæ ‡ã€‚ | + | sw | number | 是 | 0 | 需è¦è¾“出的区域的宽度。 | + | sh | number | 是 | 0 | 需è¦è¾“出的区域的高度。 | ### getImageData diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md index 5ff8def81916cc2620824bca29910b1b74457e74..357c5614ab7bab703cea7ec9d7b2fbd78fb5e61c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -68,8 +68,8 @@ PageTransitionEnterå’ŒPageTransitionExit组件支æŒçš„事件: @Entry @Component struct PageTransitionExample1 { - @State scale: number = 1 - @State opacity: number = 1 + @State scale1: number = 1 + @State opacity1: number = 1 @State active: boolean = false build() { Column() { @@ -79,19 +79,19 @@ struct PageTransitionExample1 { .onClick(() => { this.active = true }) - }.scale({ x: this.scale }).opacity(this.opacity) + }.scale({ x: this.scale1 }).opacity(this.opacity1) } // 自定义方å¼1:完全自定义转场过程的效果 pageTransition() { PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { - this.scale = 1 - this.opacity = progress + this.scale1 = 1 + this.opacity1 = progress }) // 进场过程ä¸ä¼šé€å¸§è§¦å‘onEnter回调,入å‚为动效的归一化进度(0% -- 100%) PageTransitionExit({ duration: 1500, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { - this.scale = 1 - progress - this.opacity = 1 + this.scale1 = 1 - progress + this.opacity1 = 1 }) // 退场过程ä¸ä¼šé€å¸§è§¦å‘onExit回调,入å‚为动效的归一化进度(0% -- 100%) } } @@ -102,27 +102,27 @@ struct PageTransitionExample1 { @Entry @Component struct AExample { - @State scale: number = 1 - @State opacity: number = 1 + @State scale2: number = 1 + @State opacity2: number = 1 @State active: boolean = false build() { Column() { Navigator({ target: 'pages/index' ,type: NavigationType.Push}) { Image($r('app.media.bg2')).width("100%").height("100%") } - }.height("100%").width("100%").scale({ x: this.scale }).opacity(this.opacity) + }.height("100%").width("100%").scale({ x: this.scale2 }).opacity(this.opacity2) } // 自定义方å¼1:完全自定义转场过程的效果 pageTransition() { PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { - this.scale = 1 - this.opacity = progress + this.scale2 = 1 + this.opacity2 = progress }) // 进场过程ä¸ä¼šé€å¸§è§¦å‘onEnter回调,入å‚为动效的归一化进度(0% -- 100%) PageTransitionExit({ duration: 1500, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { - this.scale = 1 - progress - this.opacity = 1 + this.scale2 = 1 - progress + this.opacity2 = 1 }) // 退场过程ä¸ä¼šé€å¸§è§¦å‘onExit回调,入å‚为动效的归一化进度(0% -- 100%) } } @@ -137,8 +137,8 @@ struct AExample { @Entry @Component struct PageTransitionExample { - @State scale: number = 1 - @State opacity: number = 1 + @State scale1: number = 1 + @State opacity1: number = 1 @State active: boolean = false build() { @@ -149,7 +149,7 @@ struct PageTransitionExample { .onClick(() => { this.active = true }) - }.scale({ x: this.scale }).opacity(this.opacity) + }.scale({ x: this.scale1 }).opacity(this.opacity1) } // 自定义方å¼2:使用系统æ供的多ç§é»˜è®¤æ•ˆæžœ(平移ã€ç¼©æ”¾ã€é€æ˜Žåº¦ç‰) @@ -168,8 +168,8 @@ struct PageTransitionExample { @Entry @Component struct PageTransitionExample1 { - @State scale: number = 1 - @State opacity: number = 1 + @State scale2: number = 1 + @State opacity2: number = 1 @State active: boolean = false build() { @@ -180,7 +180,7 @@ struct PageTransitionExample1 { .onClick(() => { this.active = true }) - }.scale({ x: this.scale }).opacity(this.opacity) + }.scale({ x: this.scale2 }).opacity(this.opacity2) } // 自定义方å¼2:使用系统æ供的多ç§é»˜è®¤æ•ˆæžœ(平移ã€ç¼©æ”¾ã€é€æ˜Žåº¦ç‰) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 123824d1a5deba3e49c73e5986e905dde35956db..15d710e5e01f8accbfe481cc31930f7df3128f48 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -17,8 +17,8 @@ | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| backgroundColor | Color | - | 设置组件的背景色。 | -| backgroundImage | src: string,<br/>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | - | srcå‚数:图片地å€ï¼Œæ”¯æŒç½‘络图片资æºå’Œæœ¬åœ°å›¾ç‰‡èµ„æºåœ°å€(ä¸æ”¯æŒsvg类型的图片)。<br/>repeatå‚数:设置背景图片的é‡å¤æ ·å¼ï¼Œé»˜è®¤ä¸é‡å¤ã€‚ | +| backgroundColor | [ResourceColor](../../ui/ts-types.md) | - | 设置组件的背景色。 | +| backgroundImage | src: [ResourceStr](../../ui/ts-types.md),<br/>repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | - | srcå‚数:图片地å€ï¼Œæ”¯æŒç½‘络图片资æºå’Œæœ¬åœ°å›¾ç‰‡èµ„æºåœ°å€(ä¸æ”¯æŒsvg类型的图片)。<br/>repeatå‚数:设置背景图片的é‡å¤æ ·å¼ï¼Œé»˜è®¤ä¸é‡å¤ã€‚ | | backgroundImageSize | {<br/>width?: Length,<br/>height?: Length<br/>} \| ImageSize | Auto | 设置背景图åƒçš„高度和宽度。当输入为{width: Length, height: Length}对象时,如果åªè®¾ç½®ä¸€ä¸ªå±žæ€§ï¼Œåˆ™ç¬¬äºŒä¸ªå±žæ€§ä¿æŒå›¾ç‰‡åŽŸå§‹å®½é«˜æ¯”进行调整。默认ä¿æŒåŽŸå›¾çš„比例ä¸å˜ã€‚ | | backgroundImagePosition | {<br/>x?: Length,<br/>y?: Length<br/>} \| [Alignment](ts-appendix-enums.md#alignment枚举说明) | {<br/>x: 0,<br/>y: 0<br/>} | 设置背景图在组件ä¸æ˜¾ç¤ºä½ç½®ã€‚ | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md index 0bedbd2b915ad4facda451efeb8c1d0bfbb63ece..ca42d63a08616226c97fba1f376c95eea8d3ec73 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md @@ -43,13 +43,10 @@ @Entry @Component struct Index { - @State message: string = 'This is\nborderImage.' - @State message2: string = 'This is\ngradient color.' - build() { Row() { Column() { - Text(this.message).textAlign(TextAlign.Center) + Text('This is\nborderImage.').textAlign(TextAlign.Center) .borderImage({ source: "borderOrigin.png", slice: {top:"31%", bottom:"31%", left:"31%", right:"31%"}, @@ -58,8 +55,26 @@ struct Index { repeat: RepeatMode.Repeat, fill: false }); - Text(this.message2).textAlign(TextAlign.Center) - .margin(10) + } + .width('100%') + } + .height('100%') + } +} +``` + + + + +```ts +// xxx.ets +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('This is\ngradient color.').textAlign(TextAlign.Center) .borderImage({ source: {angle:90, direction: GradientDirection.Left, @@ -77,4 +92,4 @@ struct Index { } ``` - + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md index f7fc976acce8ab56f4db900b814d1287ca3b5c36..4232e4edc4edef65815bfc289f63d6f81ff98b0d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md @@ -2,9 +2,9 @@ > **说明:** > -> 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 > -> 从API Version 9开始,父节点的border显示在å节点内容之上。 +> 从API Version 9开始,父节点的border显示在å节点内容之上。 è®¾ç½®ç»„ä»¶è¾¹æ¡†æ ·å¼ã€‚ @@ -18,43 +18,75 @@ ## 属性 -| å称 | å‚数类型 | 默认值 | æè¿° | -| -------- | -------- | -------- | -------- | -| border | BorderOptions | - | ç»Ÿä¸€è¾¹æ¡†æ ·å¼è®¾ç½®æŽ¥å£ã€‚ | -| borderStyle | BorderStyle | BorderStyle.Solid | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†æ ·å¼ã€‚ | -| borderWidth | Length | 0 | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†å®½åº¦ã€‚ | -| borderColor | Color | - | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†é¢œè‰²ã€‚ | -| borderRadius | Length | 0 | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†åœ†è§’åŠå¾„。 | +| å称 | å‚数类型 | 默认值 | æè¿° | +| ------------ | ------------- | ----------------------- | ------------------------ | +| border | BorderOptions | - | ç»Ÿä¸€è¾¹æ¡†æ ·å¼è®¾ç½®æŽ¥å£ã€‚ | +| borderStyle | BorderStyle | BorderStyle.Solid | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†æ ·å¼ã€‚ | +| borderWidth | Length | 0 | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†å®½åº¦ã€‚ | +| borderColor | [ResourceColor](../../ui/ts-types.md) | - | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†é¢œè‰²ã€‚ | +| borderRadius | Length \| BorderRadiuses<sup>9+</sup> | 0 | è®¾ç½®å…ƒç´ çš„è¾¹æ¡†åœ†è§’åŠå¾„。 | - BorderOptions属性说明 - | å‚æ•°å称 | å‚数类型 | 默认值 | å¿…å¡« | å‚æ•°æè¿° | - | -------- | -------- | -------- | -------- | -------- | - | width | [Length](../../ui/ts-types.md#长度类型) | 0 | å¦ | 边框宽度。 | - | color | [ResourceColor](../../ui/ts-types.md) | 'Black' | å¦ | 边框颜色。 | - | radius | [Length](../../ui/ts-types.md#长度类型)\| EdgeRadiuses<sup>9+</sup> | 0 | å¦ | 边框角度。 | - | style | BorderStyle | BorderStyle.Solid | å¦ | è¾¹æ¡†æ ·å¼ã€‚ | + | å‚æ•°å称 | å‚数类型 | 默认值 | å¿…å¡« | å‚æ•°æè¿° | + | -------- | ------------------------------------------------------------ | ----------------- | ---- | ---------- | + | width | [Length](../../ui/ts-types.md#长度类型) \| EdgeWidth<sup>9+</sup> | 0 | å¦ | 边框宽度。 | + | color | [ResourceColor](../../ui/ts-types.md) \| EdgeColor<sup>9+</sup> | 'Black' | å¦ | 边框颜色。 | + | radius | [Length](../../ui/ts-types.md#长度类型) \| BorderRadiuses<sup>9+</sup> | 0 | å¦ | 边框角度。 | + | style | BorderStyle \| EdgeStyle<sup>9+</sup> | BorderStyle.Solid | å¦ | è¾¹æ¡†æ ·å¼ã€‚ | + + +- EdgeWidth<sup>9+</sup>对象说明 + + å¼•å…¥è¯¥å¯¹è±¡æ—¶ï¼Œè‡³å°‘ä¼ å…¥ä¸€ä¸ªå‚数。 + + | å称 | å‚数类型 | å¿…å¡« | 默认值 | æè¿° | + | ------ | -------- | ---- | ------ | -------------- | + | left | length | å¦ | 0 | 左侧边框宽度。 | + | right | length | å¦ | 0 | å³ä¾§è¾¹æ¡†å®½åº¦ã€‚ | + | top | length | å¦ | 0 | 上侧边框宽度。 | + | bottom | length | å¦ | 0 | 下侧边框宽度。 | + +- EdgeColor<sup>9+</sup>对象说明 + + å¼•å…¥è¯¥å¯¹è±¡æ—¶ï¼Œè‡³å°‘ä¼ å…¥ä¸€ä¸ªå‚数。 + + | å称 | å‚数类型 | å¿…å¡« | 默认值 | æè¿° | + | ------ | ------------------------------------- | ---- | ------- | -------------- | + | left | [ResourceColor](../../ui/ts-types.md) | å¦ | 'Black' | 左侧边框颜色。 | + | right | [ResourceColor](../../ui/ts-types.md) | å¦ | 'Black' | å³ä¾§è¾¹æ¡†é¢œè‰²ã€‚ | + | top | [ResourceColor](../../ui/ts-types.md) | å¦ | 'Black' | 上侧边框颜色。 | + | bottom | [ResourceColor](../../ui/ts-types.md) | å¦ | 'Black' | 下侧边框颜色。 | + +- BorderRadiuses<sup>9+</sup>对象说明 -- EdgeRadiuses<sup>9+</sup>对象说明 - å¼•ç”¨è¯¥å¯¹è±¡æ—¶ï¼Œè‡³å°‘ä¼ å…¥ä¸€ä¸ªå‚数。 - + | å称 | å‚数类型 | å¿…å¡« | 默认值 | æè¿° | | ----------- | -------- | ---- | ------ | ---------------- | | topLeft | length | å¦ | 0 | 左上角圆角åŠå¾„。 | | topRight | length | å¦ | 0 | å³ä¸Šè§’圆角åŠå¾„。 | | bottomLeft | length | å¦ | 0 | 左下角圆角åŠå¾„。 | | bottomRight | length | å¦ | 0 | å³ä¸‹è§’圆角åŠå¾„。 | - - - + +- EdgeStyle<sup>9+</sup>对象说明 + + å¼•å…¥è¯¥å¯¹è±¡æ—¶ï¼Œè‡³å°‘ä¼ å…¥ä¸€ä¸ªå‚数。 + + | å称 | å‚数类型 | å¿…å¡« | 默认值 | æè¿° | + | ------ | ----------- | ---- | ----------------- | -------------- | + | left | BorderStyle | å¦ | BorderStyle.Solid | å·¦ä¾§è¾¹æ¡†æ ·å¼ã€‚ | + | right | BorderStyle | å¦ | BorderStyle.Solid | å³ä¾§è¾¹æ¡†æ ·å¼ã€‚ | + | top | BorderStyle | å¦ | BorderStyle.Solid | ä¸Šä¾§è¾¹æ¡†æ ·å¼ã€‚ | + | bottom | BorderStyle | å¦ | BorderStyle.Solid | ä¸‹ä¾§è¾¹æ¡†æ ·å¼ã€‚ | + - BorderStyle枚举说明 - - | å称 | æè¿° | - | -------- | -------- | + + | å称 | æè¿° | + | ------ | ----------------------------------------------- | | Dotted | 显示为一系列圆点,圆点åŠå¾„为borderWidth的一åŠã€‚ | - | Dashed | 显示为一系列çŸçš„方形虚线。 | - | Solid | 显示为一æ¡å®žçº¿ã€‚ | + | Dashed | 显示为一系列çŸçš„方形虚线。 | + | Solid | 显示为一æ¡å®žçº¿ã€‚ | ## 示例 @@ -65,22 +97,35 @@ @Component struct BorderExample { build() { - Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { - // 线段 - Text('dashed') + Column() { + Flex({ justifyContent: FlexAlign.SpaceAround, alignItems: ItemAlign.Center }) { + // 线段 + Text('dashed') .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE).borderRadius(10) - .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) - Text('dashed') - .borderStyle(BorderStyle.Dashed).borderWidth(5).borderColor(0xAFEEEE) - .borderRadius({ topLeft: 10, topRight: 20, bottomLeft: 30, bottomRight: 60 }) - .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) - // 点线 - Text('dotted') - .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted }) - .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) - }.width('100%').height(150) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + // 点线 + Text('dotted') + .border({ width: 5, color: 0x317AF7, radius: 10, style: BorderStyle.Dotted }) + .width(120).height(120).textAlign(TextAlign.Center).fontSize(16) + }.width('100%').height(150) + Text('.border') + .fontSize(50) + .width(300) + .height(300) + .border({ + width: { left: '5lpx', right: '10lpx', top: '20lpx', bottom: '30lpx' }, + color: { left: '#e3bbbb', right: Color.Blue, top: Color.Red, bottom: Color.Green }, + radius: { topLeft: 10, topRight: 20, bottomLeft: 40, bottomRight: 80 }, + style: { + left: BorderStyle.Dotted, + right: BorderStyle.Dotted, + top: BorderStyle.Solid, + bottom: BorderStyle.Dashed + } + }).textAlign(TextAlign.Center) + } } } ``` - + \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md index b372ccc183263a9321011a8c6df308cd36fa6a6a..5c09e5661536f243fe005474aab5befe31ed72a8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md @@ -21,7 +21,7 @@ idä¸ºç»„ä»¶çš„å”¯ä¸€æ ‡è¯†ï¼Œåœ¨æ•´ä¸ªåº”ç”¨å†…å”¯ä¸€ã€‚æœ¬æ¨¡å—æä¾›ç»„ä»¶æ ‡ ## æŽ¥å£ -### getInspectorByKey +### getInspectorByKey<sup>9+</sup> getInspectorByKey(id: string): string @@ -37,7 +37,7 @@ getInspectorByKey(id: string): string | -------- | -------- | | string | 组件属性列表的JSONå—符串。 | -### getInspectorTree +### getInspectorTree<sup>9+</sup> getInspectorTree(): string @@ -49,7 +49,7 @@ getInspectorTree(): string | ------ | ---------------------------------- | | string | ç»„ä»¶æ ‘åŠç»„件属性列表的JSONå—符串。 | -### sendEventByKey +### sendEventByKey<sup>9+</sup> sendEventByKey(id: string, action: number, params: string): boolean @@ -67,7 +67,7 @@ sendEventByKey(id: string, action: number, params: string): boolean | -------- | -------- | | boolean | 找ä¸åˆ°æŒ‡å®šid的组件时返回false,其余情况返回true。 | -### sendTouchEvent +### sendTouchEvent<sup>9+</sup> sendTouchEvent(event: TouchObject): boolean @@ -85,7 +85,7 @@ sendTouchEvent(event: TouchObject): boolean | ------- | ------------------------------------------- | | boolean | 事件å‘é€å¤±è´¥æ—¶è¿”回false,其余情况返回true。 | -### sendKeyEvent +### sendKeyEvent<sup>9+</sup> sendKeyEvent(event: KeyEvent): boolean @@ -103,7 +103,7 @@ sendKeyEvent(event: KeyEvent): boolean | ------- | --------------------------------------------- | | boolean | 事件å‘é€å¤±è´¥æ—¶æ—¶è¿”回false,其余情况返回true。 | -### sendMouseEvent +### sendMouseEvent<sup>9+</sup> sendMouseEvent(event: MouseEvent): boolean diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md index 936e442bc01103c1ffbaed62253cec38ccdd4508..4f51c85fb0db13fa699d016583bcea7ddb5304c8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md @@ -3,7 +3,7 @@ 自定义组件的走焦效果,å¯è®¾ç½®ç»„件是å¦èµ°ç„¦å’Œå…·ä½“的走焦顺åºï¼Œtab键或者方å‘键切æ¢ç„¦ç‚¹ã€‚ > **说明:** -> 从API Version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> 从API Version 8开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 ## æƒé™åˆ—表 @@ -13,13 +13,13 @@ ## 属性 -| **å称** | **å‚数类型** | **默认值** | **æè¿°** | -| -------- | -------- | -------- | -------- | -| 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键走焦æ¥è®¿é—®åˆ°è¯¥å…ƒç´ | +| **å称** | **å‚数类型** | **默认值** | **æè¿°** | +| -------------------- | -------- | ------- | ---------------------------------------- | +| 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。 +> 支æŒç„¦ç‚¹æŽ§åˆ¶çš„组件:Buttonã€Textã€Imageã€Listã€Grid。 ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index c2ccb7bf9bf00de306bcffeac847361bc76f5885..67a5d725dd39f3f2ed671a5ffe96252c7a5c1449 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -3,6 +3,7 @@ 设置组件的颜色æ¸å˜æ•ˆæžœã€‚ > **说明:** +> > 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 @@ -16,7 +17,7 @@ | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| linearGradient | {<br/>angle?: [Angle](../../ui/ts-types.md),<br/>direction?: GradientDirection,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | 线性æ¸å˜ã€‚<br/>angle: 线性æ¸å˜çš„角度。<br/>direction: 线性æ¸å˜çš„æ–¹å‘。<br/>colors: 为æ¸å˜çš„颜色æ述。<br/>repeating: 为æ¸å˜çš„颜色é‡å¤ç€è‰²ã€‚ | +| linearGradient | {<br/>angle?: [Angle](../../ui/ts-types.md),<br/>direction?: GradientDirection,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | 线性æ¸å˜ã€‚<br/>angle: 线性æ¸å˜çš„角度。<br/>direction: 线性æ¸å˜çš„æ–¹å‘,设置angleåŽä¸ç”Ÿæ•ˆã€‚<br/>colors: 为æ¸å˜çš„颜色æ述。<br/>repeating: 为æ¸å˜çš„颜色é‡å¤ç€è‰²ã€‚ | | sweepGradient | {<br/>center: Point,<br/>start?: angle,<br/>end?: angle,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating?: boolean<br/>} | - | 角度æ¸å˜ã€‚<br/>center:为角度æ¸å˜çš„ä¸å¿ƒç‚¹ã€‚<br/>start:角度æ¸å˜çš„起点。<br/>end:角度æ¸å˜çš„终点。<br/>colors: 为æ¸å˜çš„颜色æ述。<br/>repeating: 为æ¸å˜çš„颜色é‡å¤ç€è‰²ã€‚ | | radialGradient | {<br/>center: Point,<br/>radius: Length,<br/>colors: Array<[ColorStop](../../ui/ts-types.md)><br/>repeating: boolean<br/>} | - | 径å‘æ¸å˜ã€‚<br/>center:径å‘æ¸å˜çš„ä¸å¿ƒç‚¹ã€‚<br/>radius:径å‘æ¸å˜çš„åŠå¾„。<br/>colors: 为æ¸å˜çš„颜色æ述。<br/>repeating: 为æ¸å˜çš„颜色é‡å¤ç€è‰²ã€‚ | @@ -52,7 +53,6 @@ struct ColorGradientExample { .height(50) .linearGradient({ angle: 90, - direction: GradientDirection.Left, colors: [[0xAEE1E1, 0.0], [0xD3E0DC, 0.3], [0xFCD1D1, 1.0]] }) Text('sweepGradient').fontSize(12).width('90%').fontColor(0xCCCCCC) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index e7e0a8eaef78ba7020faefba9c16a8947bfd4dd1..9168b2896a1d0ca20e7389d4c477c4667ca315f1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -3,6 +3,7 @@ 例如背景模糊ã€å†…容模糊和ç°åº¦æ•ˆæžœç‰ã€‚ > **说明:** +> > 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 @@ -18,13 +19,13 @@ | -------- | -------- | -------- | -------- | | blur | number | - | 为当å‰ç»„ä»¶æ·»åŠ å†…å®¹æ¨¡ç³Šæ•ˆæžœï¼Œå…¥å‚为模糊åŠå¾„,模糊åŠå¾„越大越模糊,为0æ—¶ä¸æ¨¡ç³Šã€‚ | | backdropBlur | number | - | 为当å‰ç»„ä»¶æ·»åŠ èƒŒæ™¯æ¨¡ç³Šæ•ˆæžœï¼Œå…¥å‚为模糊åŠå¾„,模糊åŠå¾„越大越模糊,为0æ—¶ä¸æ¨¡ç³Šã€‚ | -| shadow | {<br/>radius: number,<br/>color?: Color,<br/>offsetX?: number,<br/>offsetY?: number<br/>} | - | 为当å‰ç»„ä»¶æ·»åŠ é˜´å½±æ•ˆæžœï¼Œå…¥å‚为模糊åŠå¾„(å¿…å¡«)ã€é˜´å½±çš„颜色(å¯é€‰ï¼Œé»˜è®¤ä¸ºç°è‰²)ã€Xè½´çš„å移é‡(å¯é€‰ï¼Œé»˜è®¤ä¸º0),Yè½´çš„å移é‡(å¯é€‰ï¼Œé»˜è®¤ä¸º0),å移é‡å•ä½ä¸ºpx。 | +| shadow | {<br/>radius: number,<br/>color?: Color \| string \| [Resource](../../ui/ts-types.md#resource类型),<br/>offsetX?: number,<br/>offsetY?: number<br/>} | - | 为当å‰ç»„ä»¶æ·»åŠ é˜´å½±æ•ˆæžœï¼Œå…¥å‚为模糊åŠå¾„(å¿…å¡«)ã€é˜´å½±çš„颜色(å¯é€‰ï¼Œé»˜è®¤ä¸ºç°è‰²)ã€Xè½´çš„å移é‡(å¯é€‰ï¼Œé»˜è®¤ä¸º0),Yè½´çš„å移é‡(å¯é€‰ï¼Œé»˜è®¤ä¸º0),å移é‡å•ä½ä¸ºpx。 | | grayscale | number | 0.0 | 为当å‰ç»„ä»¶æ·»åŠ ç°åº¦æ•ˆæžœã€‚值定义为ç°åº¦è½¬æ¢çš„比例,入å‚1.0则完全转为ç°åº¦å›¾åƒï¼Œå…¥å‚则0.0图åƒæ— å˜åŒ–,入å‚在0.0å’Œ1.0之间时,效果呈线性å˜åŒ–。(百分比) | | brightness | number | 1.0 | 为当å‰ç»„ä»¶æ·»åŠ é«˜å…‰æ•ˆæžœï¼Œå…¥å‚为高光比例,值为1时没有效果,å°äºŽ1时亮度å˜æš—,0为全黑;大于1æ—¶äº®åº¦å¢žåŠ ï¼Œæ•°å€¼è¶Šå¤§äº®åº¦è¶Šå¤§ã€‚ | | saturate | number | 1.0 | 为当å‰ç»„ä»¶æ·»åŠ é¥±å’Œåº¦æ•ˆæžœï¼Œé¥±å’Œåº¦ä¸ºé¢œè‰²ä¸çš„å«è‰²æˆåˆ†å’Œæ¶ˆè‰²æˆåˆ†(ç°)的比例,入å‚为1时,显示原图åƒï¼Œå¤§äºŽ1æ—¶å«è‰²æˆåˆ†è¶Šå¤§ï¼Œé¥±å’Œåº¦è¶Šå¤§ï¼›å°äºŽ1时消色æˆåˆ†è¶Šå¤§ï¼Œé¥±å’Œåº¦è¶Šå°ã€‚(百分比) | | contrast | number | 1.0 | 为当å‰ç»„ä»¶æ·»åŠ å¯¹æ¯”åº¦æ•ˆæžœï¼Œå…¥å‚为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图åƒè¶Šæ¸…晰醒目;å°äºŽ1时,值越å°å¯¹æ¯”度越低;当对比度为0时,图åƒå˜ä¸ºå…¨ç°ã€‚(百分比) | | invert | number | 0 | å转输入的图åƒã€‚å…¥å‚为图åƒå转的比例。值为1时完全å转。值为0则图åƒæ— å˜åŒ–。(百分比) | -| colorBlend <sup>8+</sup> | Color | - | 为当å‰ç»„ä»¶æ·»åŠ é¢œè‰²å åŠ æ•ˆæžœï¼Œå…¥å‚为å åŠ çš„é¢œè‰²ã€‚ | +| colorBlend <sup>8+</sup> | Color \| string \| [Resource](../../ui/ts-types.md#resource类型)| | - | 为当å‰ç»„ä»¶æ·»åŠ é¢œè‰²å åŠ æ•ˆæžœï¼Œå…¥å‚为å åŠ çš„é¢œè‰²ã€‚ | | sepia | number | 0 | 将图åƒè½¬æ¢ä¸ºæ·±è¤è‰²ã€‚å…¥å‚为图åƒå转的比例。值为1则完全是深è¤è‰²çš„,值为0图åƒæ— å˜åŒ–。 (百分比) | | hueRotate | number \| string | '0deg' | 为当å‰ç»„ä»¶æ·»åŠ è‰²ç›¸æ—‹è½¬æ•ˆæžœï¼Œå…¥å‚为旋转的角度值,0deg时图åƒæ— å˜åŒ–。入å‚没有最大值,超过360deg时相当于åˆç»•ä¸€åœˆï¼Œå³ï¼Œ370degå’Œ10deg的色相旋转效果相åŒã€‚ | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index c674cb11ba10f0cee96871bdc533756c662d765b..aa285f3ccb765adc4c27712a8182b1838a6f2d8b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -17,7 +17,7 @@ | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| opacity | number | 1 | å…ƒç´ çš„ä¸é€æ˜Žåº¦ï¼Œå–值范围为0到1,1表示为ä¸é€æ˜Žï¼Œ0表示为完全é€æ˜Žã€‚ | +| opacity | number \| [Resource](../../ui/ts-types.md#resource类型) | 1 | å…ƒç´ çš„ä¸é€æ˜Žåº¦ï¼Œå–值范围为0到1,1表示为ä¸é€æ˜Žï¼Œ0表示为完全é€æ˜Žã€‚ | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md index 2363e09c47a0faac853927abe2a58bbdf4f3930b..a0ae6d4562cbbe2a6bd508f8315d9ac0fd416338 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md @@ -23,7 +23,9 @@ | -------- | -------- | -------- | -------- | -------- | | normal | ()=>void | å¦ | - | ç»„ä»¶æ— çŠ¶æ€æ—¶çš„æ ·å¼ã€‚ | | pressed | ()=>void | å¦ | - | 组件按下状æ€çš„æ ·å¼ã€‚ | - | disabled | ()=>void | å¦ | - | 组件ç¦ç”¨çŠ¶æ€çš„æ ·å¼ã€‚ | + | disabled | ()=>void | å¦ | - | 组件ç¦ç”¨çŠ¶æ€çš„æ ·å¼ã€‚ | + | focused | ()=>void | å¦ | - | 组件èšç„¦çŠ¶æ€çš„æ ·å¼ã€‚ | + | clicked | ()=>void | å¦ | - | 组件点击状æ€çš„æ ·å¼ã€‚ | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 77436ad352ee1e63bd608c25ad4a13e1a848b593..009ec4b28d422fa28fb6dd7673b3de5dffcf1830 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -33,8 +33,8 @@ | -------- | -------- | -------- | -------- | -------- | | builder | () => any | 是 | - | æç¤ºæ°”æ³¡å†…å®¹çš„æž„é€ å™¨ã€‚ | | placement | Placement | å¦ | Placement.Bottom | 气泡组件优先显示的ä½ç½®ï¼Œå½“å‰ä½ç½®æ˜¾ç¤ºä¸ä¸‹æ—¶ï¼Œä¼šè‡ªåŠ¨è°ƒæ•´ä½ç½®ã€‚ | - | maskColor | [Color](../../ui/ts-types.md#颜色类型) | å¦ | - | æ示气泡é®éšœå±‚的颜色。 | - | popupColor | [Color](../../ui/ts-types.md#颜色类型) | å¦ | - | æ示气泡的颜色。 | + | maskColor | [ResourceColor](../../ui/ts-types.md) | å¦ | - | æ示气泡é®éšœå±‚的颜色。 | + | popupColor | [ResourceColor](../../ui/ts-types.md) | å¦ | - | æ示气泡的颜色。 | | enableArrow | boolean | å¦ | true | 是å¦æ˜¾ç¤ºç®å¤´ã€‚<br/>从API Version 9开始,如果ç®å¤´æ‰€åœ¨æ–¹ä½ä¾§çš„气泡长度ä¸è¶³ä»¥æ˜¾ç¤ºä¸‹ç®å¤´ï¼Œåˆ™ä¼šé»˜è®¤ä¸æ˜¾ç¤ºç®å¤´ã€‚比如:placement设置为Left,但气泡高度å°äºŽç®å¤´çš„宽度(32vp),则实际ä¸ä¼šæ˜¾ç¤ºç®å¤´ã€‚ | | autoCancel | boolean | å¦ | true | 页é¢æœ‰æ“作时,是å¦è‡ªåŠ¨å…³é—气泡 | | onStateChange | (isVisible: boolean) => void | å¦ | - | 弹窗状æ€å˜åŒ–事件回调,å‚数为弹窗当å‰çš„显示状æ€ã€‚ | @@ -70,7 +70,7 @@ struct PopupExample { @Builder popupBuilder() { Row({ space: 2 }) { Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 }) - Text('Custom Popup').fontSize(12) + Text('Custom Popup').fontSize(10) }.width(100).height(50).backgroundColor(Color.White) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index f78f9b14162965fef2311137216c1bbec7fe3db4..940dcc2f820dd3c9ad35e862dbe1a3004a289bf2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -1,6 +1,7 @@ # æ–‡æœ¬æ ·å¼è®¾ç½® > **说明:** +> > 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 @@ -17,11 +18,11 @@ | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| fontColor | Color | - | 设置文本颜色。 | -| fontSize | Length | - | 设置文本尺寸,Length为number类型时,使用fpå•ä½ã€‚ | +| fontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置文本颜色。 | +| fontSize | Length \| [Resource](../../ui/ts-types.md#resource类型) | - | 设置文本尺寸,Length为number类型时,使用fpå•ä½ã€‚ | | fontStyle | FontStyle | FontStyle.Normal | 设置文本的å—ä½“æ ·å¼ã€‚ | -| fontWeight | number \| FontWeight | FontWeight.FontWeightNormal | 设置文本的å—体粗细,number类型å–值[100, 900],å–值间隔为100,默认为400,å–值越大,å—体越粗。<br/>æ供常用枚举值,å‚考:FontWeight枚举说明。 | -| fontFamily | string | - | 设置文本的å—体列表。使用多个å—体,使用','进行分割,优先级按顺åºç”Ÿæ•ˆã€‚例如:'Arial, sans-serif'。 | +| fontWeight | number \| FontWeight \| string | FontWeight.FontWeightNormal | 设置文本的å—体粗细,number类型å–值[100, 900],å–值间隔为100,默认为400,å–值越大,å—体越粗。<br/>æ供常用枚举值,å‚考:FontWeight枚举说明。 | +| fontFamily | string \| [Resource](../../ui/ts-types.md#resource类型) | - | 设置文本的å—体列表。使用多个å—体,使用','进行分割,优先级按顺åºç”Ÿæ•ˆã€‚例如:'Arial, sans-serif'。 | - FontStyle枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md index c6cdc3e4c94058689933bbeacbedc293ed35af57..5f476bd46fe9c34d2b7dea57f89372690b374938 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md @@ -16,7 +16,7 @@ | å称 | å‚数类型 | 默认值 | æè¿° | | -------- | -------- | -------- | -------- | -| visibility | Visibility | Visibility.Visible | 控制当å‰ç»„件显示或éšè—。 | +| visibility | Visibility | Visibility.Visible | 控制当å‰ç»„件显示或éšè—。注æ„,å³ä½¿ç»„件处于éšè—状æ€ï¼Œåœ¨é¡µé¢åˆ·æ–°æ—¶ä»å˜åœ¨é‡æ–°åˆ›å»ºè¿‡ç¨‹ï¼Œå› æ¤å½“å¯¹æ€§èƒ½æœ‰ä¸¥æ ¼è¦æ±‚时建议使用[æ¡ä»¶æ¸²æŸ“](../../ui/ts-rending-control-syntax-if-else.md)代替。| - Visibility枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md index a9858490e745609b02b4f18e0ef25c53138af706..2bd3623df2a7b695f535b9acd91a252fb017f8b0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md @@ -39,7 +39,7 @@ struct ZIndexExample { Text('third child, zIndex(1)') .size({width: '70%', height: '50%'}).backgroundColor(0xc1cbac).align(Alignment.TopStart) .zIndex(1) - } + }.width('100%').height(200) }.width('100%').height(200) } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md index 290515df466fb954f78ed884ebb4282d68283a09..4f9dfcd7904d09e167a33d281cf32fa1fec72f07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md @@ -26,7 +26,7 @@ @Component struct AreaExample { @State value: string = 'Text' - @State size: string = '' + @State size1: string = '' build() { Column() { @@ -37,7 +37,7 @@ struct AreaExample { }) .onAreaChange((oldValue: Area, newValue: Area) => { console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) - this.size = JSON.stringify(newValue) + this.size1 = JSON.stringify(newValue) }) Text('new area is: \n' + this.size).margin({ right: 30, left: 30 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md index ab6dbb0ceb179b1752c1d7cc0be4ba573aa2295f..97c10547361437bc146d9a87415ca15cb837b00d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-visible-area-change-event.md @@ -2,7 +2,7 @@ 组件å¯è§åŒºåŸŸå˜åŒ–事件指组件在å±å¹•ä¸æ˜¾ç¤ºçš„é¢ç§¯å˜åŒ–,æ供了判æ–组件是å¦å®Œå…¨æˆ–部分显示在å±å¹•ä¸çš„能力,通常适用于åƒå¹¿å‘Šæ›å…‰åŸ‹ç‚¹ä¹‹ç±»çš„场景。 -> **说明:**从API Version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 +> **说明:** 从API Version 9开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 ## æƒé™åˆ—表 @@ -13,7 +13,7 @@ | å称 | 功能æè¿° | | -------- | -------- | -| onVisibleAreaChange(ratios: Array<number>, event: (isVisible: boolean, currentRatio: number) => void) | 组件å¯è§åŒºåŸŸå˜åŒ–时触å‘该回调。<br/>-ratios:阈值数组。其ä¸ï¼Œæ¯ä¸ªé˜ˆå€¼ä»£è¡¨ç»„件å¯è§é¢ç§¯ï¼ˆå³ç»„件在å±å¹•æ˜¾ç¤ºåŒºçš„é¢ç§¯ï¼‰ä¸Žç»„件自身é¢ç§¯çš„比值。当组件å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值大于或å°äºŽé˜ˆå€¼æ—¶ï¼Œå‡ä¼šè§¦å‘该回调。æ¯ä¸ªé˜ˆå€¼çš„å–值范围为[0.0, 1.0],如果开å‘者设置的阈值超出该范围,则会实际å–值0.0或1.0.<br/>-isVisible:表示组件的å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值是å¦å¤§äºŽé˜ˆå€¼ï¼Œtrue表示大于,false表示å°äºŽã€‚<br/>-currentRatio:触å‘回调时,组件å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值。 | +| onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void) | 组件å¯è§åŒºåŸŸå˜åŒ–时触å‘该回调。<br/>-ratios:阈值数组。其ä¸ï¼Œæ¯ä¸ªé˜ˆå€¼ä»£è¡¨ç»„件å¯è§é¢ç§¯ï¼ˆå³ç»„件在å±å¹•æ˜¾ç¤ºåŒºçš„é¢ç§¯ï¼‰ä¸Žç»„件自身é¢ç§¯çš„比值。当组件å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值大于或å°äºŽé˜ˆå€¼æ—¶ï¼Œå‡ä¼šè§¦å‘该回调。æ¯ä¸ªé˜ˆå€¼çš„å–值范围为[0.0, 1.0],如果开å‘者设置的阈值超出该范围,则会实际å–值0.0或1.0.<br/>-isVisible:表示组件的å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值是å¦å¤§äºŽé˜ˆå€¼ï¼Œtrue表示大于,false表示å°äºŽã€‚<br/>-currentRatio:触å‘回调时,组件å¯è§é¢ç§¯ä¸Žè‡ªèº«é¢ç§¯çš„比值。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index ae2bda63aad1304b7cc1211fc3ff723daf3c2616..78689dca4d56faa7b67ecec8e4618fb558e99419 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -3,16 +3,9 @@ 点击事件指组件被点击时触å‘的事件。 > **说明:** +> > 从API Version 7开始支æŒã€‚åŽç»ç‰ˆæœ¬å¦‚æœ‰æ–°å¢žå†…å®¹ï¼Œåˆ™é‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°è¯¥å†…容的起始版本。 -## 支æŒè®¾å¤‡ - -| 手机 | å¹³æ¿ | æ™ºæ…§å± | 智能穿戴 | -| ---- | ---- | ------ | -------- | -| æ”¯æŒ | æ”¯æŒ | ä¸æ”¯æŒ | ä¸æ”¯æŒ | - - - ## æƒé™åˆ—表 æ— @@ -44,8 +37,8 @@ | -------------- | -------------------------- | ------------------- | | width | number | ç›®æ ‡å…ƒç´ çš„å®½åº¦ï¼Œå•ä½ä¸ºvp。 | | height | number | ç›®æ ‡å…ƒç´ çš„é«˜åº¦ï¼Œå•ä½ä¸ºvp。 | -| position | [Position](#position8对象说明) | ç›®æ ‡å…ƒç´ å·¦ä¸Šè§’ç›¸å¯¹çˆ¶å…ƒç´ å·¦ä¸Šè§’çš„ä½ç½®ã€‚ | -| globalPosition | [Position](#position8对象说明) | ç›®æ ‡å…ƒç´ å·¦ä¸Šè§’ç›¸å¯¹é¡µé¢å·¦ä¸Šè§’çš„ä½ç½®ã€‚ | +| position | Position | ç›®æ ‡å…ƒç´ å·¦ä¸Šè§’ç›¸å¯¹çˆ¶å…ƒç´ å·¦ä¸Šè§’çš„ä½ç½®ã€‚ | +| globalPosition | Position | ç›®æ ‡å…ƒç´ å·¦ä¸Šè§’ç›¸å¯¹é¡µé¢å·¦ä¸Šè§’çš„ä½ç½®ã€‚ | ## Position<sup>8+</sup>对象说明 | 属性å称 | å‚数类型 | æè¿° | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md index 4488aeb52c7ad1235b8df921e4815b16718afdc8..cdcabb4b2d4b75a11d0c284074475e447be47ece 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -15,21 +15,21 @@ | å称 | 支æŒå†’泡 | 功能æè¿° | | ---------------------------------------- | ---- | ---------------------------------------- | -| onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 按键动作触å‘该方法调用,eventå‚æ•°è§[KeyEvent](#keyevent对象说明)介ç»ã€‚ | +| onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 绑定该方法的组件获焦åŽï¼ŒæŒ‰é”®åŠ¨ä½œè§¦å‘该方法调用,eventå‚æ•°è§[KeyEvent](#keyevent对象说明)介ç»ã€‚ | ## KeyEvent对象说明 - 属性 - | 属性å称 | 类型 | æè¿° | - | --------- | --------------------------- | -------------------------- | - | type | [KeyType](#keytype枚举说明) | 按键的类型。 | - | keyCode | number | 按键的键ç 。 | - | keyText | string | 按键的键值。 | - | keySource | [KeySource](#keysource枚举说明) | 触å‘当å‰æŒ‰é”®çš„输入设备类型。 | - | deviceId | number | 触å‘当å‰æŒ‰é”®çš„输入设备ID。 | - | metaKey | number | 按键å‘生时元键的状æ€ï¼Œ1表示按压æ€ï¼Œ0表示未按压æ€ã€‚ | - | timestamp | number | 按键å‘生时的时间戳。 | + | 属性å称 | 类型 | æè¿° | + | ------------------------------------- | --------------------------- | -------------------------- | + | type | [KeyType](#keytype枚举说明) | 按键的类型。 | + | [keyCode](../apis/js-apis-keycode.md) | number | 按键的键ç 。 | + | keyText | string | 按键的键值。 | + | keySource | [KeySource](#keysource枚举说明) | 触å‘当å‰æŒ‰é”®çš„输入设备类型。 | + | deviceId | number | 触å‘当å‰æŒ‰é”®çš„输入设备ID。 | + | metaKey | number | 按键å‘生时元键的状æ€ï¼Œ1表示按压æ€ï¼Œ0表示未按压æ€ã€‚ | + | timestamp | number | 按键å‘生时的时间戳。 | - æŽ¥å£ @@ -45,21 +45,12 @@ ## KeySource枚举说明 -| å称 | æè¿° | -| ----------------------- | ---------- | -| Unknown | 输入设备类型未知。 | -| [KeyCode](#常用keycode说明) | 输入设备类型为键盘。 | - -## 常用KeyCode说明 -| 数值 | 行为 | 物ç†æŒ‰é”® | -| ---- | ---- | ---------- | -| 19 | 上 | å‘上方å‘键。 | -| 20 | 下 | å‘下方å‘键。 | -| 21 | å·¦ | å‘左方å‘键。 | -| 22 | å³ | å‘å³æ–¹å‘键。 | -| 23 | 确定 | é¥æŽ§å™¨çš„确认键。 | -| 66 | 确定 | 键盘的回车键。 | -| 160 | 确定 | 键盘的å°é”®ç›˜å›žè½¦é”®ã€‚ | +| å称 | æè¿° | +| -------- | ---------- | +| Unknown | 输入设备类型未知。 | +| Keyboard | 输入设备类型为键盘。 | + + ## 示例 diff --git a/zh-cn/application-dev/reference/native-apis/Readme-CN.md b/zh-cn/application-dev/reference/native-apis/Readme-CN.md index f11bbcfaeab3ce93169b180441050e380b314f88..f8b7f9562bf6c3865998581e46695312eb59caa6 100644 --- a/zh-cn/application-dev/reference/native-apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/native-apis/Readme-CN.md @@ -1,33 +1,33 @@ # Native API -- MyProject +- æ¨¡å— - [Native XComponent](_o_h___native_x_component.md) - [Native_Bundle](_native___bundle.md) - [HiLog](_hi_log.md) - [NativeWindow](_native_window.md) - [Drawing](_drawing.md) - [Rawfile](rawfile.md) -- 头文件和结构体 - - 头文件 - - [drawing_bitmap.h](drawing__bitmap_8h.md) - - [drawing_brush.h](drawing__brush_8h.md) - - [drawing_canvas.h](drawing__canvas_8h.md) - - [drawing_color.h](drawing__color_8h.md) - - [drawing_font_collection.h](drawing__font__collection_8h.md) - - [drawing_path.h](drawing__path_8h.md) - - [drawing_pen.h](drawing__pen_8h.md) - - [drawing_text_declaration.h](drawing__text__declaration_8h.md) - - [drawing_text_typography.h](drawing__text__typography_8h.md) - - [drawing_types.h](drawing__types_8h.md) - - [external_window.h](external__window_8h.md) - - [log.h](log_8h.md) - - [native_interface_bundle.h](native__interface__bundle_8h.md) - - [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) - - [raw_dir.h](raw__dir_8h.md) - - [raw_file.h](raw__file_8h.md) - - 结构体 - - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) - - [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) - - [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) - - [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) - - [RawFileDescriptor](_raw_file_descriptor.md) +- 头文件 + + - [drawing_bitmap.h](drawing__bitmap_8h.md) + - [drawing_brush.h](drawing__brush_8h.md) + - [drawing_canvas.h](drawing__canvas_8h.md) + - [drawing_color.h](drawing__color_8h.md) + - [drawing_font_collection.h](drawing__font__collection_8h.md) + - [drawing_path.h](drawing__path_8h.md) + - [drawing_pen.h](drawing__pen_8h.md) + - [drawing_text_declaration.h](drawing__text__declaration_8h.md) + - [drawing_text_typography.h](drawing__text__typography_8h.md) + - [drawing_types.h](drawing__types_8h.md) + - [external_window.h](external__window_8h.md) + - [log.h](log_8h.md) + - [native_interface_bundle.h](native__interface__bundle_8h.md) + - [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) + - [raw_dir.h](raw__dir_8h.md) + - [raw_file.h](raw__file_8h.md) +- 结构体 + - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) + - [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) + - [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) + - [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) + - [RawFileDescriptor](_raw_file_descriptor.md) diff --git a/zh-cn/application-dev/reference/native-apis/_drawing.md b/zh-cn/application-dev/reference/native-apis/_drawing.md index 76b6c2c2e5d3cf7de0243980547f62d9bc8a7475..c8a55c1922209caf6049442320650f7335d7d352 100644 --- a/zh-cn/application-dev/reference/native-apis/_drawing.md +++ b/zh-cn/application-dev/reference/native-apis/_drawing.md @@ -43,7 +43,7 @@ Drawing模å—æ供包括2D图形渲染ã€æ–‡å—绘制和图片显示ç‰åŠŸèƒ½ ### Classes - | Classe Name | Description | + | Classes Name | Description | | -------- | -------- | | [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | 结构体用于æè¿°ä½å›¾åƒç´ çš„æ ¼å¼ï¼ŒåŒ…括颜色类型和é€æ˜Žåº¦ç±»åž‹ | diff --git a/zh-cn/application-dev/reference/native-apis/annotated.md b/zh-cn/application-dev/reference/native-apis/annotated.md deleted file mode 100644 index b4b83d5bb7a4e1fe605a00b1c4af4bba8b540b57..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/native-apis/annotated.md +++ /dev/null @@ -1,13 +0,0 @@ -# 结构体 - - - -- **[OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md)** - -- **[OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md)** - -- **[OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md)** - -- **[OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md)** - -- **[RawFileDescriptor](_raw_file_descriptor.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-apis/drawing__bitmap_8h.md b/zh-cn/application-dev/reference/native-apis/drawing__bitmap_8h.md index e16944b2b8e814b2239ae0fc73a6dd40c9629d07..3b78678ae631f68f037a07a4a194be3cb8bcf8a6 100644 --- a/zh-cn/application-dev/reference/native-apis/drawing__bitmap_8h.md +++ b/zh-cn/application-dev/reference/native-apis/drawing__bitmap_8h.md @@ -21,7 +21,7 @@ ### Classes - | Classe Name | Description | + | Classes Name | Description | | -------- | -------- | | [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | 结构体用于æè¿°ä½å›¾åƒç´ çš„æ ¼å¼ï¼ŒåŒ…括颜色类型和é€æ˜Žåº¦ç±»åž‹ | diff --git a/zh-cn/application-dev/reference/native-apis/files.md b/zh-cn/application-dev/reference/native-apis/files.md deleted file mode 100644 index f4beb38e74356c62ccb498720313d2fd6a879a9f..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/native-apis/files.md +++ /dev/null @@ -1,35 +0,0 @@ -# 头文件 - - - -- **[drawing_bitmap.h](drawing__bitmap_8h.md)** - -- **[drawing_brush.h](drawing__brush_8h.md)** - -- **[drawing_canvas.h](drawing__canvas_8h.md)** - -- **[drawing_color.h](drawing__color_8h.md)** - -- **[drawing_font_collection.h](drawing__font__collection_8h.md)** - -- **[drawing_path.h](drawing__path_8h.md)** - -- **[drawing_pen.h](drawing__pen_8h.md)** - -- **[drawing_text_declaration.h](drawing__text__declaration_8h.md)** - -- **[drawing_text_typography.h](drawing__text__typography_8h.md)** - -- **[drawing_types.h](drawing__types_8h.md)** - -- **[external_window.h](external__window_8h.md)** - -- **[log.h](log_8h.md)** - -- **[native_interface_bundle.h](native__interface__bundle_8h.md)** - -- **[native_interface_xcomponent.h](native__interface__xcomponent_8h.md)** - -- **[raw_dir.h](raw__dir_8h.md)** - -- **[raw_file.h](raw__file_8h.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-apis/index.md b/zh-cn/application-dev/reference/native-apis/index.md deleted file mode 100644 index f04f11fd3ba729aa2e871108fbf1679511b026dc..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/native-apis/index.md +++ /dev/null @@ -1,15 +0,0 @@ -# MyProject - - - -- **[Native XComponent](_o_h___native_x_component.md)** - -- **[Native_Bundle](_native___bundle.md)** - -- **[HiLog](_hi_log.md)** - -- **[NativeWindow](_native_window.md)** - -- **[Drawing](_drawing.md)** - -- **[Rawfile](rawfile.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-lib/Readme-CN.md b/zh-cn/application-dev/reference/native-lib/Readme-CN.md index ce6736a94f7fa5dc06bf1775dcc4cc166cf3600d..6ab376d22cdee59e3d8c3ba5b1c1a702012b1b92 100644 --- a/zh-cn/application-dev/reference/native-lib/Readme-CN.md +++ b/zh-cn/application-dev/reference/native-lib/Readme-CN.md @@ -1,6 +1,8 @@ # Native APIæ ‡å‡†åº“ - -- [æ ‡å‡†åº“](third_party_libc/musl.md) -- [Native APIä¸æ²¡æœ‰å¯¼å‡ºçš„符å·åˆ—表](third_party_libc/musl-peculiar-symbol.md) -- [Node_API](third_party_napi/napi.md) -- [libuv](third_party_libuv/libuv.md) \ No newline at end of file +- [Node_API](third_party_napi/napi.md) +- [libuv](third_party_libuv/libuv.md) +- [支æŒçš„æ ‡å‡†åº“ä»‹ç»](third_party_libc/musl.md) +- 附录 + - [Native apiä¸æ²¡æœ‰å¯¼å‡ºçš„符å·åˆ—表](third_party_libc/musl-peculiar-symbol.md) + - [Native apiä¸å¯¼å‡ºçš„EGL符å·åˆ—表](third_party_opengl/egl-symbol.md) + - [Native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表](third_party_opengl/openglesv3-symbol.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md index 3a8bc6520078b412752abfe19aa7e5e6038c96af..376d39a7c62fe0cfc5a5f59738de24788b64356d 100644 --- a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md +++ b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl-peculiar-symbol.md @@ -1,4 +1,4 @@ -**native apiä¸æ²¡æœ‰å¯¼å‡ºçš„符å·åˆ—表** +# Native apiä¸æ²¡æœ‰å¯¼å‡ºçš„符å·åˆ—表 |符å·ç±»åž‹|符å·å|备注| | --- | --- | --- | diff --git a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md index 33c549ac2ecfe1549f8d6a9e638fe0d1048ad8cb..88766ad86a7acfcd04aba191f695d894009ca5d2 100644 --- a/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md +++ b/zh-cn/application-dev/reference/native-lib/third_party_libc/musl.md @@ -1,11 +1,7 @@ # Native APIä¸æ”¯æŒçš„æ ‡å‡†åº“ - - ## 简介 - - **表1** OpenHarmony支æŒçš„æ ‡å‡†åº“ | å称 | 简介 | @@ -19,8 +15,6 @@ ## æ ‡å‡†C库 - - [libcã€libmã€libdl](https://zh.cppreference.com/w/c/header)组åˆå®žçŽ°C11æ ‡å‡†C库。 libc:包å«çº¿ç¨‹ç›¸å…³æŽ¥å£ï¼Œä»¥åŠå¤§éƒ¨åˆ†æ ‡å‡†æŽ¥å£ã€‚ @@ -43,8 +37,6 @@ Cæ ‡å‡†å‡½æ•°åº“æ˜¯åœ¨Cè¯è¨€ç¨‹åºè®¾è®¡ä¸ï¼Œæ‰€æœ‰ç¬¦åˆæ ‡å‡†çš„头文件的 ## æ ‡å‡†C++库 - - [libc++](https://libcxx.llvm.org/)是C++æ ‡å‡†åº“çš„ä¸€ç§å®žçŽ°ã€‚ **版本** @@ -57,24 +49,12 @@ C++11ã€C++14æ ‡å‡†å·²å®Œå…¨æ”¯æŒï¼ŒC++17å’ŒC++20æ ‡å‡†æ£åœ¨å®Œå–„。 ## OpenSL ES - - [OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/)是一个嵌入å¼è·¨å¹³å°çš„音频处ç†åº“。 - - ## zlib - - [Zlib](https://zlib.net/)是基于C/C++è¯è¨€å®žçŽ°çš„一个通用的数æ®åŽ‹ç¼©åº“。 - - - - - - ## EGL EGL 是Khronos渲染API (如OpenGL ES 或 OpenVG) 与底层原生窗å£ç³»ç»Ÿä¹‹é—´çš„接å£ã€‚OpenHarmony çŽ°å·²æ”¯æŒ EGL。 @@ -83,8 +63,6 @@ EGL 是Khronos渲染API (如OpenGL ES 或 OpenVG) 与底层原生窗å£ç³»ç»Ÿä¹‹ [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。 @@ -95,5 +73,4 @@ OpenGL ES 3.0 **æ ‡å‡†åº“ä¸å¯¼å‡ºçš„符å·åˆ—表** -[native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表](../third_party_opengl/openglesv3-symbol.md) - +[native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表](../third_party_opengl/openglesv3-symbol.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md b/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md index 1b66ad0e12659eca0eb6fefeaffb2730dce12f5e..3c313db67b3fce890adff06e4f3a4eb8e6fcfcd8 100644 --- a/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md +++ b/zh-cn/application-dev/reference/native-lib/third_party_napi/napi.md @@ -1,22 +1,17 @@ -# Node_API - - +# Node-API ## 简介 +Node-API是用于å°è£…JavaScript能力为Nativeæ’件的API,独立于底层JavaScript,并作为Node.js的一部分。 -Node-API是用于å°è£…JavaScript能力为nativeæ’件的API,独立于底层JavaScript,并作为Node.js的一部分。 - ## 支æŒçš„能力 - - Node-APIå¯ä»¥åŽ»é™¤åº•å±‚çš„JavaScript引擎的差异,æ供一套稳定的接å£ã€‚ -NAPI组件对Node-API的接å£è¿›è¡Œäº†é‡æ–°å®žçŽ°ï¼Œåº•å±‚对接了ArkJsç‰å¼•æ“Žã€‚当å‰æ”¯æŒNode-APIæ ‡å‡†åº“ä¸çš„部分接å£ã€‚ +OpenHarmonyçš„Native API组件对Node-API的接å£è¿›è¡Œäº†é‡æ–°å®žçŽ°ï¼Œåº•å±‚对接了ArkJSç‰å¼•æ“Žã€‚当å‰æ”¯æŒNode-APIæ ‡å‡†åº“ä¸çš„部分接å£ã€‚ -**NAPI组件扩展的符å·åˆ—表** +## Native API组件扩展的符å·åˆ—表 |符å·ç±»åž‹|符å·å|备注| | --- | --- | --- | diff --git a/zh-cn/application-dev/reference/native-lib/third_party_opengl/egl-symbol.md b/zh-cn/application-dev/reference/native-lib/third_party_opengl/egl-symbol.md index 0812ae9c45832cf44c988bdd3e9701286d07f0e8..d9f9bbf871cdc5d6d952467685b460beb388fce3 100644 --- a/zh-cn/application-dev/reference/native-lib/third_party_opengl/egl-symbol.md +++ b/zh-cn/application-dev/reference/native-lib/third_party_opengl/egl-symbol.md @@ -1,4 +1,4 @@ -**native apiä¸å¯¼å‡ºçš„EGL符å·åˆ—表** +# Native apiä¸å¯¼å‡ºçš„EGL符å·åˆ—表 |符å·ç±»åž‹|符å·å|备注| | --- | --- | --- | diff --git a/zh-cn/application-dev/reference/native-lib/third_party_opengl/openglesv3-symbol.md b/zh-cn/application-dev/reference/native-lib/third_party_opengl/openglesv3-symbol.md index 1c68fcb17ae4b78c78491376a2061af728141bec..8a94b7e83e1d4692f8113dfec02668a7cdc64681 100644 --- a/zh-cn/application-dev/reference/native-lib/third_party_opengl/openglesv3-symbol.md +++ b/zh-cn/application-dev/reference/native-lib/third_party_opengl/openglesv3-symbol.md @@ -1,4 +1,4 @@ -**native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表** +# Native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表 |符å·ç±»åž‹|符å·å|备注| | --- | --- | --- | diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md index 9354ed496a1c07573f7f9000a54fe030c737aa73..f4550869894c3dcaf7f2523ee76066e849ca5658 100644 --- a/zh-cn/application-dev/security/accesstoken-guidelines.md +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -182,3 +182,10 @@ ``` > **说明:** > 动æ€æŽˆæƒç”³è¯·æŽ¥å£çš„使用详è§[APIå‚考](../reference/apis/js-apis-ability-context.md)。 + +## 相关实例 + +针对访问控制,有以下相关实例å¯ä¾›å‚考: + +- [`AbilityAccessCtrl`:访问æƒé™æŽ§åˆ¶ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/Safety/AbilityAccessCtrl) +- [ä¸ºåº”ç”¨æ·»åŠ è¿è¡Œæ—¶æƒé™ï¼ˆeTS)(API 9)](https://gitee.com/openharmony/codelabs/tree/master/Ability/AccessPermission) \ No newline at end of file diff --git a/zh-cn/application-dev/security/accesstoken-overview.md b/zh-cn/application-dev/security/accesstoken-overview.md index 29283090785f340d671e6b32b0dd2d8f4d6b9389..75c63227541bbe2e75cc28b06eb5fc248d32226d 100644 --- a/zh-cn/application-dev/security/accesstoken-overview.md +++ b/zh-cn/application-dev/security/accesstoken-overview.md @@ -170,7 +170,7 @@ ATM(AccessTokenManager)是OpenHarmony上基于AccessToken构建的统一的 在æƒé™Bçš„ACL使能为TRUE的情况下,æ¤æ—¶ï¼Œå¼€å‘者å¯ä»¥ä½¿ç”¨ACLæ–¹å¼æ¥ç”³è¯·æƒé™B。 -ACLæ–¹å¼çš„工作æµç¨‹å¯ä»¥å‚考[ACLæ–¹å¼ä½¿ç”¨è¯´æ˜Ž](#ACLæ–¹å¼ä½¿ç”¨è¯´æ˜Ž)。 +ACLæ–¹å¼çš„工作æµç¨‹å¯ä»¥å‚考[ACLæ–¹å¼ä½¿ç”¨è¯´æ˜Ž](#aclæ–¹å¼ä½¿ç”¨è¯´æ˜Ž)。 具体æŸä¸ªæƒé™èƒ½å¦é€šè¿‡ACL使能情况å¯æŸ¥é˜…[æƒé™å®šä¹‰åˆ—表](permission-list.md)。 ### ACLæ–¹å¼ä½¿ç”¨è¯´æ˜Ž diff --git a/zh-cn/application-dev/security/huks-overview.md b/zh-cn/application-dev/security/huks-overview.md index b6bfae7f5a0be1cfb7bce7fa381a5b4e0b641032..3711420d9b14dba3709cddfe07a58741760173f5 100755 --- a/zh-cn/application-dev/security/huks-overview.md +++ b/zh-cn/application-dev/security/huks-overview.md @@ -16,13 +16,13 @@ HUKS对密钥的使用主è¦é€šè¿‡Initã€Updateã€Finishæ“作æ¥å®žçŽ°ã€‚ - **Initæ“作**:读å–密钥,并为其创建Session Id返回给调用者。 -- **Udateæ“作**ï¼šæ ¹æ®Initæ“作获å–çš„Session Id对数æ®è¿›è¡Œåˆ†æ®µupdate处ç†ã€‚ +- **Updateæ“作**ï¼šæ ¹æ®Initæ“作获å–çš„Session Id对数æ®è¿›è¡Œåˆ†æ®µupdate处ç†ã€‚ -- **Fnishæ“作**:当所有待处ç†çš„æ•°æ®å‡ä¼ å…¥HUKSåŽï¼Œè°ƒç”¨Finishæ“作完æˆæœ€ç»ˆæ•°æ®å¤„ç†ï¼Œé‡Šæ”¾èµ„æºã€‚ +- **Finishæ“作**:当所有待处ç†çš„æ•°æ®å‡ä¼ å…¥HUKSåŽï¼Œè°ƒç”¨Finishæ“作完æˆæœ€ç»ˆæ•°æ®å¤„ç†ï¼Œé‡Šæ”¾èµ„æºã€‚ > **须知:**<br> > 当Initã€Updateã€Finishæ“作ä¸çš„任一阶段å‘生错误时,都需è¦è°ƒç”¨Abortæ“作æ¥ç»ˆæ¢å¯†é’¥çš„使用。 ## 约æŸä¸Žé™åˆ¶ -ä¸æ¶‰åŠã€‚ \ No newline at end of file +ä¸æ¶‰åŠã€‚ diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index b8f1e3000977295f7eed6d7407a1dfdfd4a883bc..e661b3eb83a4aa5b195bb8bd9130663a9412ceac 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -97,7 +97,7 @@ | ohos.permission.EDM_MANAGE_DATETIME | normal | system_grant | FALSE | å…许设备管ç†å‘˜åº”用设置系统时间。 | | ohos.permission.NFC_TAG | normal | system_grant | FALSE | å…许应用读å–Tagå¡ç‰‡ã€‚ | | ohos.permission.NFC_CARD_EMULATION | normal | system_grant | FALSE | å…许应用实现å¡æ¨¡æ‹ŸåŠŸèƒ½ã€‚ | -| ohos.permission.PERMISSION_USED_STATS | system_core | system_grant | TRUE | å…许系统应用访问æƒé™ä½¿ç”¨è®°å½•ã€‚ | +| ohos.permission.PERMISSION_USED_STATS | system_basic | system_grant | TRUE | å…许系统应用访问æƒé™ä½¿ç”¨è®°å½•ã€‚ | | ohos.permission.NOTIFICATION_AGENT_CONTROLLER | system_core | system_grant | TRUE | å…许应用å‘é€ä»£ç†é€šçŸ¥ã€‚ | | ohos.permission.ANSWER_CALL | system_basic | user_grant | TRUE | å…许应用接å¬æ¥ç”µã€‚ | | ohos.permission.READ_CALENDAR | normal | user_grant | TRUE | å…许应用读å–日历信æ¯ã€‚ | @@ -129,4 +129,5 @@ | ohos.permission.ACCESS_IDS | system_core | system_grant | TRUE | å…è®¸åº”ç”¨æŸ¥è¯¢è®¾å¤‡çš„å”¯ä¸€æ ‡è¯†ç¬¦ä¿¡æ¯ã€‚ | | ohos.permission.DUMP | system_core | system_grant | TRUE | å…许导出系统基础信æ¯å’ŒSAæœåŠ¡ä¿¡æ¯ã€‚ | | ohos.permission.DISTRIBUTED_SOFTBUS_CENTER | system_basic | system_grant | FALSE | å…许ä¸åŒè®¾å¤‡ä¹‹é—´è¿›è¡Œç»„网处ç†ã€‚ | -| ohos.permission.ACCESS_DLP_FILE | system_core | system_grant | TRUE | å…许对DLP文件进行æƒé™é…置和管ç†ã€‚ | \ No newline at end of file +| ohos.permission.ACCESS_DLP_FILE | system_core | system_grant | TRUE | å…许对DLP文件进行æƒé™é…置和管ç†ã€‚ | +| ohos.permission.PROVISIONING_MESSAGE | system_core | system_grant | TRUE | å…许激活超级设备管ç†å™¨åº”用。 | \ No newline at end of file diff --git a/zh-cn/application-dev/task-management/background-task-dev-guide.md b/zh-cn/application-dev/task-management/background-task-dev-guide.md index 8652b3012d203b154ea0a669eadaf2a731d24655..54998ed2986075f4b89942e277ef10a96ea0d6f9 100644 --- a/zh-cn/application-dev/task-management/background-task-dev-guide.md +++ b/zh-cn/application-dev/task-management/background-task-dev-guide.md @@ -116,6 +116,8 @@ ohos.permission.KEEP_BACKGROUND_RUNNING ### å¼€å‘æ¥éª¤ +基于FA模型: + 1. 新建Api Version 8的工程åŽï¼Œåœ¨å·¥ç¨‹ç›®å½•ä¸å³é”®é€‰æ‹©â€œnew†-> “Ability†-> “Service Ability†快速创建Service Ability组件。并在config.json文件ä¸é…置长时任务æƒé™ã€åŽå°æ¨¡å¼ç±»åž‹ï¼Œå…¶ä¸Ability类型为“serviceâ€ã€‚ ``` @@ -138,7 +140,7 @@ ohos.permission.KEEP_BACKGROUND_RUNNING } ``` -2. 申请长时任务 +2. 申请长时任务。 ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; @@ -168,7 +170,7 @@ ohos.permission.KEEP_BACKGROUND_RUNNING }); ``` -3. åœæ¢é•¿æ—¶ä»»åŠ¡ +3. åœæ¢é•¿æ—¶ä»»åŠ¡ã€‚ ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; @@ -182,7 +184,75 @@ ohos.permission.KEEP_BACKGROUND_RUNNING ``` +基于Stage模型: + +1. 新建Api Version 9的工程åŽï¼Œåœ¨å·¥ç¨‹ç›®å½•ä¸å³é”®é€‰æ‹©â€œNew†-> “Ability†快速创建Ability组件。并在module.json5文件ä¸é…置长时任务æƒé™ã€åŽå°æ¨¡å¼ç±»åž‹ã€‚ + + ``` + "module": { + "abilities": [ + { + "backgroundModes": [ + "dataTransfer", + "location" + ], // åŽå°æ¨¡å¼ç±»åž‹ + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" // 长时任务æƒé™ + } + ] + } + ``` + +2. 申请长时任务。 + + ```ts + import backgroundTaskManager from '@ohos.backgroundTaskManager'; + import wantAgent from '@ohos.wantAgent'; + + let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + // 通过wantAgent模å—çš„getWantAgent方法获å–WantAgent对象 + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + backgroundTaskManager.startBackgroundRunning(this.context, + backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { + console.info("Operation startBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation startBackgroundRunning failed Cause: " + err); + }); + }); + ``` + +3. åœæ¢é•¿æ—¶ä»»åŠ¡ã€‚ + + ```ts + import backgroundTaskManager from '@ohos.backgroundTaskManager'; + + backgroundTaskManager.stopBackgroundRunning(this.context).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation stopBackgroundRunning failed Cause: " + err); + }); + + ``` + + ### å¼€å‘实例 + +基于FA模型: + 基于FAçš„Service Ability使用,å‚考[ServiceAbilityå¼€å‘指导](../ability/fa-serviceability.md)。 当ä¸éœ€è¦ä¸ŽåŽå°æ‰§è¡Œçš„长时任务交互时,å¯ä»¥é‡‡ç”¨startAbility()方法å¯åŠ¨Service Ability。并在Service Abilityçš„onStart回调方法ä¸ï¼Œè°ƒç”¨é•¿æ—¶ä»»åŠ¡çš„申请接å£ï¼Œå£°æ˜Žæ¤æœåŠ¡éœ€è¦åœ¨åŽå°é•¿æ—¶è¿è¡Œã€‚当任务执行完,å†è°ƒç”¨é•¿æ—¶ä»»åŠ¡å–消接å£ï¼ŒåŠæ—¶é‡Šæ”¾èµ„æºã€‚ @@ -285,6 +355,130 @@ export default { }; ``` +基于Stage模型: + +Stage模型的相关信æ¯å‚考[Stage模型综述](../ability/stage-brief.md)。 +当应用需è¦åœ¨åŽå°æ‰§è¡Œé•¿æ—¶ä»»åŠ¡æ—¶ï¼Œå¯ä»¥é€šè¿‡Callçš„æ–¹å¼åœ¨åŽå°åˆ›å»ºå¹¶è¿è¡ŒAbility。使用方å¼å‚考[Call调用开å‘指导](../ability/stage-call.md)。 + +```ts +import Ability from '@ohos.application.Ability' +import backgroundTaskManager from '@ohos.backgroundTaskManager'; +import wantAgent from '@ohos.wantAgent'; + +let mContext = null; + +function startContinuousTask() { + let wantAgentInfo = { + // 点击通知åŽï¼Œå°†è¦æ‰§è¡Œçš„动作列表 + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + // 点击通知åŽï¼ŒåŠ¨ä½œç±»åž‹ + operationType: wantAgent.OperationType.START_ABILITY, + // 使用者自定义的一个ç§æœ‰å€¼ + requestCode: 0, + // 点击通知åŽï¼ŒåŠ¨ä½œæ‰§è¡Œå±žæ€§ + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + // 通过wantAgent模å—çš„getWantAgent方法获å–WantAgent对象 + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + backgroundTaskManager.startBackgroundRunning(mContext, + backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { + console.info("Operation startBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation startBackgroundRunning failed Cause: " + err); + }); + }); +} + +function stopContinuousTask() { + backgroundTaskManager.stopBackgroundRunning(mContext).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((err) => { + console.error("Operation stopBackgroundRunning failed Cause: " + err); + }); +} + +class MySequenceable { + num: number = 0; + str: String = ""; + + constructor(num, string) { + this.num = num; + this.str = string; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } +} + +function sendMsgCallback(data) { + console.info('BgTaskAbility funcCallBack is called ' + data) + let receivedData = new Mysequenceable(0, "") + data.readSequenceable(receivedData) + console.info(`receiveData[${receivedData.num}, ${receivedData.str}]`) + if (receivedData.str === 'start_bgtask') { + startContinuousTask() + } else if (receivedData.str === 'stop_bgtask') { + stopContinuousTask(); + } + return new Mysequenceable(10, "Callee test"); +} + +export default class BgTaskAbility extends Ability { + onCreate(want, launchParam) { + console.info("[Demo] BgTaskAbility onCreate") + this.callee.on("test", sendMsgCallback); + + try { + this.callee.on(MSG_SEND_METHOD, sendMsgCallback) + } catch (error) { + console.error(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) + } + mContext = this.context; + } + + onDestroy() { + console.info("[Demo] BgTaskAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + console.info("[Demo] BgTaskAbility onWindowStageCreate") + + windowStage.loadContent("pages/second").then((data)=> { + console.info(`load content succeed with data ${JSON.stringify(data)}`) + }).catch((error)=>{ + console.error(`load content failed with error ${JSON.stringify(error)}`) + }) + } + + onWindowStageDestroy() { + console.info("[Demo] BgTaskAbility onWindowStageDestroy") + } + + onForeground() { + console.info("[Demo] BgTaskAbility onForeground") + } + + onBackground() { + console.info("[Demo] BgTaskAbility onBackground") + } +}; +``` + ## 相关实例 基于åŽå°ä»»åŠ¡ç®¡ç†ï¼Œæœ‰ä»¥ä¸‹ç›¸å…³å®žä¾‹å¯ä¾›å‚考: diff --git a/zh-cn/application-dev/telephony/cellular-network-signal-info.md b/zh-cn/application-dev/telephony/cellular-network-signal-info.md index 34a244080874d04ad63b638485a2bd6addfc1222..90d9087aae3b0995ccb86a35149449217f2a7854 100644 --- a/zh-cn/application-dev/telephony/cellular-network-signal-info.md +++ b/zh-cn/application-dev/telephony/cellular-network-signal-info.md @@ -49,3 +49,8 @@ radio模å—æ供了获å–当å‰ç½‘络信å·ä¿¡æ¯çš„方法。observer模å—为 console.log("signal info change, data is:" + JSON.stringify(data)); }); ``` + +## 相关实例 + +针对蜂çªç½‘络数æ®å¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`MobileNetwork`:蜂çªæ•°æ®ï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Telephony/MobileNetwork) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index c7a2b79e0bccc29a38a355b4d4113e74882dbfbc..ab862d2dd3c3d4a50f066ce49fc261ecebdbc650 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -1,6 +1,78 @@ # UIå¼€å‘ - [方舟开å‘框架(ArkUI)概述](arkui-overview.md) +- 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ + - [概述](ui-ts-overview.md) + - 框架说明 + - 文件组织 + - [目录结构](ts-framework-directory.md) + - [应用代ç 文件访问规则](ts-framework-file-access-rules.md) + - [jsæ ‡ç¾é…ç½®](ts-framework-js-tag.md) + - 资æºç®¡ç† + - [资æºæ–‡ä»¶çš„分类](ui-ts-basic-resource-file-categories.md) + - [资æºè®¿é—®](ts-resource-access.md) + - [åƒç´ å•ä½](ts-pixel-units.md) + - [类型定义](ts-types.md) + - 声明å¼è¯æ³• + - [æ述规范使用说明](ts-syntax-intro.md) + - 通用UIæ述规范 + - [基本概念](ts-general-ui-concepts.md) + - 声明å¼UIæ述规范 + - [æ— æž„é€ å‚æ•°é…ç½®](ts-parameterless-configuration.md) + - [必选å‚æ•°æž„é€ é…ç½®](ts-configuration-with-mandatory-parameters.md) + - [属性é…ç½®](ts-attribution-configuration.md) + - [事件é…ç½®](ts-event-configuration.md) + - [å组件é…ç½®](ts-child-component-configuration.md) + - 组件化 + - [@Component](ts-component-based-component.md) + - [@Entry](ts-component-based-entry.md) + - [@Preview](ts-component-based-preview.md) + - [@Builder](ts-component-based-builder.md) + - [@Extend](ts-component-based-extend.md) + - [@CustomDialog](ts-component-based-customdialog.md) + - [@Styles](ts-component-based-styles.md) + - UI状æ€ç®¡ç† + - [基本概念](ts-ui-state-mgmt-concepts.md) + - 管ç†ç»„ä»¶æ‹¥æœ‰çš„çŠ¶æ€ + - [@State](ts-component-states-state.md) + - [@Prop](ts-component-states-prop.md) + - [@Link](ts-component-states-link.md) + - 管ç†åº”用程åºçš„çŠ¶æ€ + - [应用程åºçš„æ•°æ®å˜å‚¨](ts-application-states-appstorage.md) + - [Abilityæ•°æ®å˜å‚¨](ui-ts-local-storage.md) + - [æŒä¹…化数æ®ç®¡ç†](ts-application-states-apis-persistentstorage.md) + - [环境å˜é‡](ts-application-states-apis-environment.md) + - 其他类目的状æ€ç®¡ç† + - [Observedå’ŒObjectLinkæ•°æ®ç®¡ç†](ts-other-states-observed-objectlink.md) + - [@Consumeå’Œ@Provideæ•°æ®ç®¡ç†](ts-other-states-consume-provide.md) + - [@Watch](ts-other-states-watch.md) + - 渲染控制è¯æ³• + - [æ¡ä»¶æ¸²æŸ“](ts-rending-control-syntax-if-else.md) + - [循环渲染](ts-rending-control-syntax-foreach.md) + - [æ•°æ®æ‡’åŠ è½½](ts-rending-control-syntax-lazyforeach.md) + - 深入ç†è§£ç»„件化 + - [build函数](ts-function-build.md) + - [自定义组件åˆå§‹åŒ–](ts-custom-component-initialization.md) + - [自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md) + - [组件创建和é‡æ–°åˆå§‹åŒ–示例](ts-component-creation-re-initialization.md) + - [è¯æ³•ç³–](ts-syntactic-sugar.md) + - 常è§ç»„件开å‘指导 + - [Buttonå¼€å‘指导](ui-ts-basic-components-button.md) + - [Webå¼€å‘指导](ui-ts-components-web.md) + - 常è§å¸ƒå±€å¼€å‘指导 + - [弹性布局](ui-ts-layout-flex.md) + - [æ …æ ¼å¸ƒå±€](ui-ts-layout-grid-container.md) + - [媒体查询](ui-ts-layout-mediaquery.md) + - 体验声明å¼UI + - [创建声明å¼UI工程](ui-ts-creating-project.md) + - [åˆè¯†Component](ui-ts-components.md) + - [创建简å•è§†å›¾](ui-ts-creating-simple-page.md) + - 页é¢å¸ƒå±€ä¸Žè¿žæŽ¥ + - [构建食物数æ®æ¨¡åž‹](ui-ts-building-data-model.md) + - [构建食物列表List布局](ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) + - [页é¢è·³è½¬ä¸Žæ•°æ®ä¼ 递](ui-ts-page-redirection-data-transmission.md) + - 基于JS扩展的类Webå¼€å‘èŒƒå¼ - [概述](ui-js-overview.md) - 框架说明 @@ -72,76 +144,4 @@ - æ’值器动画 - [动画动效](ui-js-animate-dynamic-effects.md) - [动画帧](ui-js-animate-frame.md) - - [自定义组件](ui-js-custom-components.md) -- 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ - - [概述](ui-ts-overview.md) - - 框架说明 - - 文件组织 - - [目录结构](ts-framework-directory.md) - - [应用代ç 文件访问规则](ts-framework-file-access-rules.md) - - [jsæ ‡ç¾é…ç½®](ts-framework-js-tag.md) - - 资æºè®¿é—® - - [访问应用资æº](ts-application-resource-access.md) - - [访问系统资æº](ts-system-resource-access.md) - - [媒体资æºç±»åž‹è¯´æ˜Ž](ts-media-resource-type.md) - - [åƒç´ å•ä½](ts-pixel-units.md) - - [类型定义](ts-types.md) - - 声明å¼è¯æ³• - - [æ述规范使用说明](ts-syntax-intro.md) - - 通用UIæ述规范 - - [基本概念](ts-general-ui-concepts.md) - - 声明å¼UIæ述规范 - - [æ— æž„é€ å‚æ•°é…ç½®](ts-parameterless-configuration.md) - - [必选å‚æ•°æž„é€ é…ç½®](ts-configuration-with-mandatory-parameters.md) - - [属性é…ç½®](ts-attribution-configuration.md) - - [事件é…ç½®](ts-event-configuration.md) - - [å组件é…ç½®](ts-child-component-configuration.md) - - 组件化 - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - [@Styles](ts-component-based-styles.md) - - UI状æ€ç®¡ç† - - [基本概念](ts-ui-state-mgmt-concepts.md) - - 管ç†ç»„ä»¶æ‹¥æœ‰çš„çŠ¶æ€ - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - 管ç†åº”用程åºçš„çŠ¶æ€ - - [应用程åºçš„æ•°æ®å˜å‚¨](ts-application-states-appstorage.md) - - [Abilityæ•°æ®å˜å‚¨](ui-ts-local-storage.md) - - [æŒä¹…化数æ®ç®¡ç†](ts-application-states-apis-persistentstorage.md) - - [环境å˜é‡](ts-application-states-apis-environment.md) - - 其他类目的状æ€ç®¡ç† - - [Observedå’ŒObjectLinkæ•°æ®ç®¡ç†](ts-other-states-observed-objectlink.md) - - [@Consumeå’Œ@Provideæ•°æ®ç®¡ç†](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - 渲染控制è¯æ³• - - [æ¡ä»¶æ¸²æŸ“](ts-rending-control-syntax-if-else.md) - - [循环渲染](ts-rending-control-syntax-foreach.md) - - [æ•°æ®æ‡’åŠ è½½](ts-rending-control-syntax-lazyforeach.md) - - 深入ç†è§£ç»„件化 - - [build函数](ts-function-build.md) - - [自定义组件åˆå§‹åŒ–](ts-custom-component-initialization.md) - - [自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md) - - [组件创建和é‡æ–°åˆå§‹åŒ–示例](ts-component-creation-re-initialization.md) - - [è¯æ³•ç³–](ts-syntactic-sugar.md) - - 常è§ç»„件开å‘指导 - - [Buttonå¼€å‘指导](ui-ts-basic-components-button.md) - - [Webå¼€å‘指导](ui-ts-components-web.md) - - 常è§å¸ƒå±€å¼€å‘指导 - - [弹性布局](ui-ts-layout-flex.md) - - [æ …æ ¼å¸ƒå±€](ui-ts-layout-grid-container.md) - - [媒体查询](ui-ts-layout-mediaquery.md) - - 体验声明å¼UI - - [创建声明å¼UI工程](ui-ts-creating-project.md) - - [åˆè¯†Component](ui-ts-components.md) - - [创建简å•è§†å›¾](ui-ts-creating-simple-page.md) - - 页é¢å¸ƒå±€ä¸Žè¿žæŽ¥ - - [构建食物数æ®æ¨¡åž‹](ui-ts-building-data-model.md) - - [构建食物列表List布局](ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui-ts-building-category-grid-layout.md) - - [页é¢è·³è½¬ä¸Žæ•°æ®ä¼ 递](ui-ts-page-redirection-data-transmission.md) + - [自定义组件](ui-js-custom-components.md) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/arkui-overview.md b/zh-cn/application-dev/ui/arkui-overview.md index 73e9103b88de19305b750de003d0bfaa5c998436..e1dc6e11c2013cacebac3cae38b516e08751ff57 100644 --- a/zh-cn/application-dev/ui/arkui-overview.md +++ b/zh-cn/application-dev/ui/arkui-overview.md @@ -26,12 +26,12 @@ - å¹³å°API通é“:方舟开å‘框架æ供了API扩展机制,平å°èƒ½åŠ›é€šè¿‡æ¤ç§æœºåˆ¶è¿›è¡Œå°è£…,æä¾›é£Žæ ¼ç»Ÿä¸€çš„JS接å£ã€‚ -- 两ç§å¼€å‘范å¼ï¼šæ–¹èˆŸå¼€å‘框架针对ä¸åŒç›®çš„和技术背景的开å‘者æ供了两ç§å¼€å‘范å¼ï¼Œåˆ†åˆ«æ˜¯åŸºäºŽJS扩展的类Webå¼€å‘范å¼ï¼ˆç®€ç§°â€œç±»Webå¼€å‘范å¼â€ï¼‰å’ŒåŸºäºŽTS扩展的声明å¼å¼€å‘范å¼ï¼ˆç®€ç§°â€œå£°æ˜Žå¼å¼€å‘范å¼â€ï¼‰ã€‚ +- 两ç§å¼€å‘范å¼ï¼šæ–¹èˆŸå¼€å‘框架针对ä¸åŒç›®çš„和技术背景的开å‘者æ供了两ç§å¼€å‘范å¼ï¼Œåˆ†åˆ«æ˜¯åŸºäºŽTS扩展的声明å¼å¼€å‘范å¼ï¼ˆç®€ç§°â€œå£°æ˜Žå¼å¼€å‘范å¼â€ï¼‰å’ŒåŸºäºŽJS扩展的类Webå¼€å‘范å¼ï¼ˆç®€ç§°â€œç±»Webå¼€å‘范å¼â€ï¼‰ã€‚ | å¼€å‘范å¼å称 | 简介 | 适用场景 | 适用人群 | | -------- | ---------------------------------------- | ---------------- | ------------------- | - | ç±»Webå¼€å‘èŒƒå¼ | 采用ç»å…¸çš„HMLã€CSSã€JavaScript三段å¼å¼€å‘æ–¹å¼ã€‚使用HMLæ ‡ç¾æ–‡ä»¶è¿›è¡Œå¸ƒå±€æ建,使用CSSæ–‡ä»¶è¿›è¡Œæ ·å¼æ述,使用JavaScript文件进行逻辑处ç†ã€‚UI组件与数æ®ä¹‹é—´é€šè¿‡å•å‘æ•°æ®ç»‘定的方å¼å»ºç«‹å…³è”,当数æ®å‘生å˜åŒ–时,UIç•Œé¢è‡ªåŠ¨è§¦å‘更新。æ¤ç§å¼€å‘æ–¹å¼ï¼Œæ›´æŽ¥è¿‘Webå‰ç«¯å¼€å‘è€…çš„ä½¿ç”¨ä¹ æƒ¯ï¼Œå¿«é€Ÿå°†å·²æœ‰çš„Webåº”ç”¨æ”¹é€ æˆæ–¹èˆŸå¼€å‘框架应用。 | ç•Œé¢è¾ƒä¸ºç®€å•çš„ä¸å°åž‹åº”用和å¡ç‰‡ | Webå‰ç«¯å¼€å‘人员 | | 声明å¼å¼€å‘èŒƒå¼ | 采用TSè¯è¨€å¹¶è¿›è¡Œå£°æ˜Žå¼UIè¯æ³•æ‰©å±•ï¼Œä»Žç»„件ã€åŠ¨æ•ˆå’ŒçŠ¶æ€ç®¡ç†ä¸‰ä¸ªç»´åº¦æ供了UI绘制能力。UIå¼€å‘更接近自然è¯ä¹‰çš„编程方å¼ï¼Œè®©å¼€å‘者直观地æè¿°UIç•Œé¢ï¼Œä¸å¿…关心框架如何实现UI绘制和渲染,实现æžç®€é«˜æ•ˆå¼€å‘。åŒæ—¶ï¼Œé€‰ç”¨æœ‰ç±»åž‹æ ‡æ³¨çš„TSè¯è¨€ï¼Œå¼•å…¥ç¼–è¯‘æœŸçš„ç±»åž‹æ ¡éªŒã€‚ | å¤æ‚度较大ã€å›¢é˜Ÿåˆä½œåº¦è¾ƒé«˜çš„ç¨‹åº | 移动系统应用开å‘人员ã€ç³»ç»Ÿåº”用开å‘人员 | + | ç±»Webå¼€å‘èŒƒå¼ | 采用ç»å…¸çš„HMLã€CSSã€JavaScript三段å¼å¼€å‘æ–¹å¼ã€‚使用HMLæ ‡ç¾æ–‡ä»¶è¿›è¡Œå¸ƒå±€æ建,使用CSSæ–‡ä»¶è¿›è¡Œæ ·å¼æ述,使用JavaScript文件进行逻辑处ç†ã€‚UI组件与数æ®ä¹‹é—´é€šè¿‡å•å‘æ•°æ®ç»‘定的方å¼å»ºç«‹å…³è”,当数æ®å‘生å˜åŒ–时,UIç•Œé¢è‡ªåŠ¨è§¦å‘更新。æ¤ç§å¼€å‘æ–¹å¼ï¼Œæ›´æŽ¥è¿‘Webå‰ç«¯å¼€å‘è€…çš„ä½¿ç”¨ä¹ æƒ¯ï¼Œå¿«é€Ÿå°†å·²æœ‰çš„Webåº”ç”¨æ”¹é€ æˆæ–¹èˆŸå¼€å‘框架应用。 | ç•Œé¢è¾ƒä¸ºç®€å•çš„ä¸å°åž‹åº”用和å¡ç‰‡ | Webå‰ç«¯å¼€å‘人员 | diff --git a/zh-cn/application-dev/ui/figures/create-resource-file-1.png b/zh-cn/application-dev/ui/figures/create-resource-file-1.png new file mode 100644 index 0000000000000000000000000000000000000000..a6d82caac558cd58b78aba3014b6ac60148f6bc8 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/create-resource-file-1.png differ diff --git a/zh-cn/application-dev/ui/figures/create-resource-file-2.png b/zh-cn/application-dev/ui/figures/create-resource-file-2.png new file mode 100644 index 0000000000000000000000000000000000000000..b4d23e8dc15bafbb08ca691575ce2ea9fe989e91 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/create-resource-file-2.png differ diff --git a/zh-cn/application-dev/ui/figures/create-resource-file-3.png b/zh-cn/application-dev/ui/figures/create-resource-file-3.png new file mode 100644 index 0000000000000000000000000000000000000000..566653c5e49753e1f04d0d6b5b5c3e931f4354b5 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/create-resource-file-3.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642001.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642001.gif new file mode 100644 index 0000000000000000000000000000000000000000..03a0350651c4e4e1fa70593befa45455b662acd1 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642001.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642002.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642002.gif new file mode 100644 index 0000000000000000000000000000000000000000..f07cd18d127944605658f4424ad3b41a39b553c3 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642002.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642003.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642003.png new file mode 100644 index 0000000000000000000000000000000000000000..2c514af73d06209da17532eb6e3c9657f7a97060 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642003.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642004.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642004.gif new file mode 100644 index 0000000000000000000000000000000000000000..eaee7ddb8a27352887aa17b30e906408bd236e9e Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642004.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642005.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642005.gif new file mode 100644 index 0000000000000000000000000000000000000000..7d12fd80ac4f5ceec08b463b24eb48935227f621 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642005.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642006.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642006.png new file mode 100644 index 0000000000000000000000000000000000000000..90a3e2af63bcc5c18114bfd8d112ca58f2c69e1b Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642006.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642007.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642007.gif new file mode 100644 index 0000000000000000000000000000000000000000..9325cd75369ef2a2b1d7784ce5aeef97ae1ec71c Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642007.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642008.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642008.png new file mode 100644 index 0000000000000000000000000000000000000000..4e3f22225a2e1a04c19b9c2d948d8b8351c73056 Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642008.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642009.gif b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642009.gif new file mode 100644 index 0000000000000000000000000000000000000000..057e146194b5e63ebeb5b07b0556e3495a4ce2ca Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001118642009.gif differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png deleted file mode 100644 index 00964c1cfa5f006f2e8ac064133e23a2d8fc92aa..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001195117633.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213462329.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213462329.png deleted file mode 100644 index 99a2f37ce14924c6c2d91f828d7ffaa8c87ec77f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001213462329.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/js-framework-file.md b/zh-cn/application-dev/ui/js-framework-file.md index 983b0f4bf4bf64be037a15fe046ba8d1e420bc3d..c9d892c9ffc3ccb5afcf2c575dea706731a9236a 100644 --- a/zh-cn/application-dev/ui/js-framework-file.md +++ b/zh-cn/application-dev/ui/js-framework-file.md @@ -32,15 +32,15 @@ JS FA应用的JS模å—(entry/src/main/js/module)的典型开å‘目录结构如 - share目录用于é…置多个实例共享的资æºå†…容,比如:shareä¸çš„图片和JSON文件å¯è¢«default1å’Œdefault2实例共享。 ->  **说明:** +> **说明:** > - i18nå’Œresources是开å‘ä¿ç•™æ–‡ä»¶å¤¹ï¼Œä¸å¯é‡å‘½å。 > -> +> > - 如果share目录ä¸çš„资æºå’Œå®žä¾‹(default)ä¸çš„资æºæ–‡ä»¶åŒå且目录一致时,实例ä¸èµ„æºçš„优先级高于shareä¸èµ„æºçš„优先级。 > -> +> > - share目录当å‰ä¸æ”¯æŒi18n。 -> +> > - 在使用DevEco Studio进行应用开å‘时,目录结构ä¸çš„å¯é€‰æ–‡ä»¶å¤¹éœ€è¦å¼€å‘è€…æ ¹æ®å®žé™…情况自行创建。 @@ -56,14 +56,14 @@ JS FA应用的JS模å—(entry/src/main/js/module)的典型开å‘目录结构如 - CSSæ ·å¼æ–‡ä»¶ä¸é€šè¿‡url()函数创建<url>æ•°æ®ç±»åž‹ï¼Œå¦‚:url(/common/xxx.png)。 ->  **说明:** +> **说明:** > 当代ç 文件A需è¦å¼•ç”¨ä»£ç 文件B时: -> +> > - 如果代ç 文件A和文件Bä½äºŽåŒä¸€ç›®å½•ï¼Œåˆ™ä»£ç 文件B引用资æºæ–‡ä»¶æ—¶å¯ä½¿ç”¨ç›¸å¯¹è·¯å¾„,也å¯ä½¿ç”¨ç»å¯¹è·¯å¾„。 -> +> > - 如果代ç 文件A和文件Bä½äºŽä¸åŒç›®å½•ï¼Œåˆ™ä»£ç 文件B引用资æºæ–‡ä»¶æ—¶å¿…须使用ç»å¯¹è·¯å¾„ã€‚å› ä¸ºWebpack打包时,代ç 文件B的目录会å‘生å˜åŒ–。 > -> +> > - 在js文件ä¸é€šè¿‡æ•°æ®ç»‘定的方å¼æŒ‡å®šèµ„æºæ–‡ä»¶è·¯å¾„时,必须使用ç»å¯¹è·¯å¾„。 @@ -71,16 +71,16 @@ JS FA应用的JS模å—(entry/src/main/js/module)的典型开å‘目录结构如 **表1** 支æŒçš„å›¾ç‰‡æ ¼å¼ -| æ ¼å¼ | 支æŒçš„文件类型 | -| -------- | -------- | -| BMP | .bmp | -| GIF | .gif | -| JPEG | .jpg | -| PNG | .png | -| WebP | .webp | +| æ ¼å¼ | 支æŒçš„文件类型 | +| ---- | ------- | +| BMP | .bmp | +| GIF | .gif | +| JPEG | .jpg | +| PNG | .png | +| WebP | .webp | **表2** 支æŒçš„è§†é¢‘æ ¼å¼ -| æ ¼å¼ | 支æŒçš„文件类型 | -| -------- | -------- | +| æ ¼å¼ | 支æŒçš„文件类型 | +| ---------------------------------------- | ------------- | | H.264 AVC<br/>Baseline Profile (BP) | .3gp<br/>.mp4 | diff --git a/zh-cn/application-dev/ui/js-framework-js-file.md b/zh-cn/application-dev/ui/js-framework-js-file.md index 5f72eb98d3ede8caabcf450f91ef34d7a5eab110..82716c99f1db5cb1b8d5249bdf99521ed95bc4f7 100644 --- a/zh-cn/application-dev/ui/js-framework-js-file.md +++ b/zh-cn/application-dev/ui/js-framework-js-file.md @@ -3,7 +3,7 @@ ## 应用生命周期 æ¯ä¸ªåº”用å¯ä»¥åœ¨app.js自定义应用级[生命周期](../ui/js-framework-lifecycle.md)的实现逻辑,以下示例仅在生命周期函数ä¸æ‰“å°å¯¹åº”日志: -``` +```js // app.js export default { onCreate() { @@ -18,13 +18,13 @@ export default { ## 应用对象<sup>6+</sup> -| 属性 | 类型 | æè¿° | -| -------- | -------- | -------- | +| 属性 | 类型 | æè¿° | +| ------ | -------- | ---------------------------------------- | | getApp | Function | æä¾›getApp()全局方法,å¯ä»¥åœ¨è‡ªå®šä¹‰js文件ä¸èŽ·å–app.jsä¸æš´éœ²çš„对象。 | 示例如下: -``` +```js // app.js export default { data: { @@ -39,7 +39,7 @@ export default { }; ``` -``` +```js // test.js 自定义逻辑代ç export var appData = getApp().data; ``` diff --git a/zh-cn/application-dev/ui/js-framework-js-tag.md b/zh-cn/application-dev/ui/js-framework-js-tag.md index b08ba57338f2305dd5da16142b8ac33546b75463..1e226db4955413cb50f6b0715788ced6a4bceb70 100644 --- a/zh-cn/application-dev/ui/js-framework-js-tag.md +++ b/zh-cn/application-dev/ui/js-framework-js-tag.md @@ -3,14 +3,14 @@ jsæ ‡ç¾ä¸åŒ…å«äº†å®žä¾‹å称ã€é¡µé¢è·¯ç”±å’Œçª—å£æ ·å¼ä¿¡æ¯ã€‚ -| æ ‡ç¾ | 类型 | 默认值 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| name | string | default | 是 | æ ‡è¯†JS实例的åå—。 | -| pages | Array | - | 是 | 路由信æ¯ï¼Œè¯¦è§â€œ**[pages](#pages)**â€ã€‚ | -| window | Object | - | å¦ | 窗å£ä¿¡æ¯ï¼Œè¯¦è§â€œ**[window](#window)**â€ã€‚ | +| æ ‡ç¾ | 类型 | 默认值 | å¿…å¡« | æè¿° | +| ------ | ------ | ------- | ---- | ------------------------------- | +| name | string | default | 是 | æ ‡è¯†JS实例的åå—。 | +| pages | Array | - | 是 | 路由信æ¯ï¼Œè¯¦è§â€œ**[pages](#pages)**â€ã€‚ | +| window | Object | - | å¦ | 窗å£ä¿¡æ¯ï¼Œè¯¦è§â€œ**[window](#window)**â€ã€‚ | ->  **说明:** +> **说明:** > nameã€pageså’Œwindowç‰æ ‡ç¾é…置需在é…置文件(config.json)ä¸çš„“jsâ€æ ‡ç¾ä¸å®Œæˆè®¾ç½®ã€‚ @@ -18,7 +18,7 @@ jsæ ‡ç¾ä¸åŒ…å«äº†å®žä¾‹å称ã€é¡µé¢è·¯ç”±å’Œçª—å£æ ·å¼ä¿¡æ¯ã€‚ 定义æ¯ä¸ªé¡µé¢çš„路由信æ¯ï¼Œæ¯ä¸ªé¡µé¢ç”±é¡µé¢è·¯å¾„和页é¢å组æˆï¼Œé¡µé¢çš„文件å就是页é¢å。比如: -``` +```json { ... "pages": [ @@ -29,11 +29,11 @@ jsæ ‡ç¾ä¸åŒ…å«äº†å®žä¾‹å称ã€é¡µé¢è·¯ç”±å’Œçª—å£æ ·å¼ä¿¡æ¯ã€‚ } ``` ->  **说明:** -> +> **说明:** +> > - pages列表ä¸ç¬¬ä¸€ä¸ªé¡µé¢æ˜¯åº”用的首页,å³entryå…¥å£ã€‚ > -> +> > - 页é¢æ–‡ä»¶åä¸èƒ½ä½¿ç”¨ç»„件å称,比如:text.hmlã€button.hmlç‰ã€‚ ## window @@ -43,19 +43,19 @@ window用于定义与显示窗å£ç›¸å…³çš„é…置。对于å±å¹•é€‚é…问题, - 指定designWidth(å±å¹•é€»è¾‘宽度),所有与大å°ç›¸å…³çš„æ ·å¼ï¼ˆä¾‹å¦‚widthã€font-size)å‡ä»¥designWidth和实际å±å¹•å®½åº¦çš„比例进行缩放,例如在designWidth为720时,如果设置width为100px时,在实际宽度为1440物ç†åƒç´ çš„å±å¹•ä¸Šï¼Œwidth实际渲染åƒç´ 为200物ç†åƒç´ 。 - 设置autoDesignWidth为true,æ¤æ—¶designWidthå—段将会被忽略,渲染组件和布局时按å±å¹•å¯†åº¦è¿›è¡Œç¼©æ”¾ã€‚å±å¹•é€»è¾‘宽度由设备宽度和å±å¹•å¯†åº¦è‡ªåŠ¨è®¡ç®—得出,在ä¸åŒè®¾å¤‡ä¸Šå¯èƒ½ä¸åŒï¼Œè¯·ä½¿ç”¨ç›¸å¯¹å¸ƒå±€æ¥é€‚é…多ç§è®¾å¤‡ã€‚例如:在466\*466分辨率,320dpi的设备上,å±å¹•å¯†åº¦ä¸º2(以160dpi为基准),1pxç‰äºŽæ¸²æŸ“出的2物ç†åƒç´ 。 - - >  **说明:** + + > **说明:** > 1. ç»„ä»¶æ ·å¼ä¸<length>类型的默认值,按å±å¹•å¯†åº¦è¿›è¡Œè®¡ç®—和绘制,如:在å±å¹•å¯†åº¦ä¸º2(以160dpi为基准)的设备上,默认<length>为1px时,设备上实际渲染出2物ç†åƒç´ 。 - > + > > 2. autoDesignWidthã€designWidth的设置ä¸å½±å“默认值计算方å¼å’Œç»˜åˆ¶ç»“果。 -| 属性 | 类型 | å¿…å¡« | 缺çœå€¼ | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| designWidth | number | å¦ | 720<br/> | 页é¢æ˜¾ç¤ºè®¾è®¡æ—¶çš„å‚考值,实际显示效果基于设备宽度与å‚考值之间的比例进行缩放。 | -| autoDesignWidth | boolean | å¦ | false | 页é¢è®¾è®¡åŸºå‡†å®½åº¦æ˜¯å¦è‡ªåŠ¨è®¡ç®—,当设为true时,designWidth将会被忽略,设计基准宽度由设备宽度与å±å¹•å¯†åº¦è®¡ç®—得出。 | +| 属性 | 类型 | å¿…å¡« | 缺çœå€¼ | æè¿° | +| --------------- | ------- | ---- | -------- | ---------------------------------------- | +| designWidth | number | å¦ | 720<br/> | 页é¢æ˜¾ç¤ºè®¾è®¡æ—¶çš„å‚考值,实际显示效果基于设备宽度与å‚考值之间的比例进行缩放。 | +| autoDesignWidth | boolean | å¦ | false | 页é¢è®¾è®¡åŸºå‡†å®½åº¦æ˜¯å¦è‡ªåŠ¨è®¡ç®—,当设为true时,designWidth将会被忽略,设计基准宽度由设备宽度与å±å¹•å¯†åº¦è®¡ç®—得出。 | 示例如下: -``` +```json { ... "window": { @@ -69,7 +69,7 @@ window用于定义与显示窗å£ç›¸å…³çš„é…置。对于å±å¹•é€‚é…问题, ## 示例 -``` +```json { "app": { "bundleName": "com.example.player", diff --git a/zh-cn/application-dev/ui/js-framework-multiple-languages.md b/zh-cn/application-dev/ui/js-framework-multiple-languages.md index 19d9df8df27a7dcb43eefc9e4621919ee499394d..0cbe216fb69f7ea6785a725c363d07ca27e5b8ec 100644 --- a/zh-cn/application-dev/ui/js-framework-multiple-languages.md +++ b/zh-cn/application-dev/ui/js-framework-multiple-languages.md @@ -29,7 +29,7 @@ language[-script-region].json 资æºæ–‡ä»¶å†…å®¹æ ¼å¼å¦‚下: en-US.json -``` +```json { "strings": { "hello": "Hello world!", @@ -53,7 +53,7 @@ en-US.json en-US.json -``` +```json { "strings": { "people": { @@ -67,7 +67,7 @@ en-US.json ar-AE.json -``` +```json { "strings": { "people": { @@ -104,7 +104,7 @@ ar-AE.json | params | Array\|Object | å¦ | è¿è¡Œæ—¶ç”¨æ¥æ›¿æ¢å ä½ç¬¦çš„实际内容,å ä½ç¬¦åˆ†ä¸ºä¸¤ç§ï¼š<br/>- å…·åå ä½ç¬¦ï¼Œä¾‹å¦‚{name}。实际内容必须用Object类型指定,例如:```$t('strings.object', {name:'Hello world'})```。 <br> - æ•°å—å ä½ç¬¦ï¼Œä¾‹å¦‚{0}。实际内容必须用Array类型指定,例如:```$t('strings.array', [Hello world']``` | - 简å•æ ¼å¼åŒ–示例代ç - ``` + ```html <!-- xxx.hml --> <div> <!-- ä¸ä½¿ç”¨å ä½ç¬¦ï¼Œtextä¸æ˜¾ç¤ºâ€œHello world!†--> @@ -127,7 +127,7 @@ ar-AE.json </div> ``` - ``` + ```js // xxx.js // 下é¢ä¸ºåœ¨js文件ä¸çš„使用方法。 export default { @@ -147,7 +147,7 @@ ar-AE.json ``` - å•å¤æ•°æ ¼å¼åŒ–方法 - + 表4 å•å¤æ•°æ ¼å¼åŒ– | 属性 | 类型 | å‚æ•° | å¿…å¡« | æè¿° | @@ -162,7 +162,7 @@ ar-AE.json | count | number | 是 | è¦è¡¨è¾¾çš„值 | - å•å¤æ•°æ ¼å¼åŒ–示例代ç - ``` + ```html <!--xxx.hml--> <div> <!-- ä¼ é€’æ•°å€¼ä¸º0时: "0 people" 阿拉伯è¯ä¸æ¤å¤„匹é…key为zeroçš„è¯æ¡--> diff --git a/zh-cn/application-dev/ui/js-framework-resource-restriction.md b/zh-cn/application-dev/ui/js-framework-resource-restriction.md index 7cdbbe2c52a8711c6160620dc64b3c189145d0d9..2d43d44e821c3c9dd81cac82dfc1086eb1ce6fb5 100644 --- a/zh-cn/application-dev/ui/js-framework-resource-restriction.md +++ b/zh-cn/application-dev/ui/js-framework-resource-restriction.md @@ -88,5 +88,5 @@ resources/res-defaults.json: </div> ``` ->  **说明:** +> **说明:** > 资æºé™å®šæ–‡ä»¶ä¸ä¸æ”¯æŒé¢œè‰²æžšä¸¾æ ¼å¼ã€‚ diff --git a/zh-cn/application-dev/ui/js-framework-syntax-css.md b/zh-cn/application-dev/ui/js-framework-syntax-css.md index a9937650333f75338257615a82d5c6cb840b8b47..9def147357018c331a88ede5c43bf35f652636cb 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-css.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-css.md @@ -1,6 +1,6 @@ # CSSè¯æ³•å‚考 -CSS是æè¿°HML页é¢ç»“æž„çš„æ ·å¼è¯è¨€ã€‚所有组件å‡å˜åœ¨ç³»ç»Ÿé»˜è®¤æ ·å¼ï¼Œä¹Ÿå¯åœ¨é¡µé¢CSSæ ·å¼æ–‡ä»¶ä¸å¯¹ç»„件ã€é¡µé¢è‡ªå®šä¹‰ä¸åŒçš„æ ·å¼ã€‚ +CSS是æè¿°HML页é¢ç»“æž„çš„æ ·å¼è¯è¨€ã€‚所有组件å‡å˜åœ¨ç³»ç»Ÿé»˜è®¤æ ·å¼ï¼Œä¹Ÿå¯åœ¨é¡µé¢CSSæ ·å¼æ–‡ä»¶ä¸å¯¹ç»„件ã€é¡µé¢è‡ªå®šä¹‰ä¸åŒçš„æ ·å¼ã€‚请å‚考[é€šç”¨æ ·å¼](../reference/arkui-js/js-components-common-styles.md)了解基于JS扩展的类Webå¼€å‘范å¼æ”¯æŒçš„ç»„ä»¶æ ·å¼ã€‚ ## 尺寸å•ä½ @@ -22,14 +22,14 @@ CSS是æè¿°HML页é¢ç»“æž„çš„æ ·å¼è¯è¨€ã€‚所有组件å‡å˜åœ¨ç³»ç»Ÿé»˜è®¤ æ¯ä¸ªé¡µé¢ç›®å½•ä¸‹å˜åœ¨ä¸€ä¸ªä¸Žå¸ƒå±€hml文件åŒåçš„css文件,用æ¥æ述该hml页é¢ä¸ç»„ä»¶çš„æ ·å¼ï¼Œå†³å®šç»„件应该如何显示。 1. å†…éƒ¨æ ·å¼ï¼Œæ”¯æŒä½¿ç”¨styleã€class属性æ¥æŽ§åˆ¶ç»„ä»¶çš„æ ·å¼ã€‚例如: - ``` + ```html <!-- index.hml --> <div class="container"> <text style="color: red">Hello World</text> </div> ``` - ``` + ```css /* index.css */ .container { justify-content: center; @@ -37,14 +37,14 @@ CSS是æè¿°HML页é¢ç»“æž„çš„æ ·å¼è¯è¨€ã€‚所有组件å‡å˜åœ¨ç³»ç»Ÿé»˜è®¤ ``` 2. 文件导入,åˆå¹¶å¤–éƒ¨æ ·å¼æ–‡ä»¶ã€‚例如,在common目录ä¸å®šä¹‰æ ·å¼æ–‡ä»¶style.css,并在index.css文件首行ä¸è¿›è¡Œå¯¼å…¥ï¼š - ``` + ```css /* style.css */ .title { font-size: 50px; } ``` - ``` + ```css /* index.css */ @import '../../common/style.css'; .container { @@ -57,17 +57,17 @@ CSS是æè¿°HML页é¢ç»“æž„çš„æ ·å¼è¯è¨€ã€‚所有组件å‡å˜åœ¨ç³»ç»Ÿé»˜è®¤ css选择器用于选择需è¦æ·»åŠ æ ·å¼çš„å…ƒç´ ï¼Œæ”¯æŒçš„选择器如下表所示: -| 选择器 | æ ·ä¾‹ | æ ·ä¾‹æè¿° | -| -------- | -------- | -------- | -| .class | .container | 用于选择class="container"的组件。 | -| \#id | \#titleId | 用于选择id="titleId"的组件。 | -| tag | text | 用于选择text组件。 | -| , | .title, .content | 用于选择class="title"å’Œclass="content"的组件。 | +| 选择器 | æ ·ä¾‹ | æ ·ä¾‹æè¿° | +| ------------------------- | ------------------------------------- | ---------------------------------------- | +| .class | .container | 用于选择class="container"的组件。 | +| \#id | \#titleId | 用于选择id="titleId"的组件。 | +| tag | text | 用于选择text组件。 | +| , | .title, .content | 用于选择class="title"å’Œclass="content"的组件。 | | \#id .class tag | \#containerId .content text | éžä¸¥æ ¼çˆ¶å关系的åŽä»£é€‰æ‹©å™¨ï¼Œé€‰æ‹©å…·æœ‰id="containerId"ä½œä¸ºç¥–å…ˆå…ƒç´ ï¼Œclass="content"ä½œä¸ºæ¬¡çº§ç¥–å…ˆå…ƒç´ çš„æ‰€æœ‰textç»„ä»¶ã€‚å¦‚éœ€ä½¿ç”¨ä¸¥æ ¼çš„çˆ¶å关系,å¯ä»¥ä½¿ç”¨â€œ>â€ä»£æ›¿ç©ºæ ¼ï¼Œå¦‚:\#containerId>.content。 | 示例: -``` +```html <!-- 页é¢å¸ƒå±€xxx.hml --> <div id="containerId" class="container"> <text id="titleId" class="title">æ ‡é¢˜</text> @@ -77,7 +77,7 @@ css选择器用于选择需è¦æ·»åŠ æ ·å¼çš„å…ƒç´ ï¼Œæ”¯æŒçš„选择器如下 </div> ``` -``` +```css /* 页é¢æ ·å¼xxx.css */ /\* 对所有divç»„ä»¶è®¾ç½®æ ·å¼ \*/ div { @@ -124,30 +124,30 @@ css伪类是选择器ä¸çš„关键å—,用于指定è¦é€‰æ‹©å…ƒç´ 的特殊状 除了å•ä¸ªä¼ªç±»ä¹‹å¤–,还支æŒä¼ªç±»çš„组åˆï¼Œä¾‹å¦‚,:focus:checked状æ€å¯ä»¥ç”¨æ¥è®¾ç½®å…ƒç´ çš„focus属性和checked属性åŒæ—¶ä¸ºtrueæ—¶çš„æ ·å¼ã€‚支æŒçš„å•ä¸ªä¼ªç±»å¦‚下表所示,按照优先级é™åºæŽ’列: -| å称 | 支æŒç»„件 | æè¿° | -| -------- | -------- | -------- | -| :disabled | 支æŒdisabled属性的组件 | 表示disabled属性å˜ä¸ºtrueæ—¶çš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | -| :active | 支æŒclick事件的组件<br/> | è¡¨ç¤ºè¢«ç”¨æˆ·æ¿€æ´»çš„å…ƒç´ ï¼Œå¦‚ï¼šè¢«ç”¨æˆ·æŒ‰ä¸‹çš„æŒ‰é’®ã€è¢«æ¿€æ´»çš„tab-bar页ç¾ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | -| :waiting | button | 表示waiting属性为trueçš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | -| :checked | input[type="checkbox"ã€type="radio"]〠switch | 表示checked属性为trueçš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | +| å称 | 支æŒç»„件 | æè¿° | +| --------- | ---------------------------------------- | ---------------------------------------- | +| :disabled | 支æŒdisabled属性的组件 | 表示disabled属性å˜ä¸ºtrueæ—¶çš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | +| :active | 支æŒclick事件的组件<br/> | è¡¨ç¤ºè¢«ç”¨æˆ·æ¿€æ´»çš„å…ƒç´ ï¼Œå¦‚ï¼šè¢«ç”¨æˆ·æŒ‰ä¸‹çš„æŒ‰é’®ã€è¢«æ¿€æ´»çš„tab-bar页ç¾ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | +| :waiting | button | 表示waiting属性为trueçš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | +| :checked | input[type="checkbox"ã€type="radio"]〠switch | 表示checked属性为trueçš„å…ƒç´ ï¼ˆä¸æ”¯æŒåŠ¨ç”»æ ·å¼çš„设置)。 | 伪类示例如下,设置按钮的:active伪类å¯ä»¥æŽ§åˆ¶è¢«ç”¨æˆ·æŒ‰ä¸‹æ—¶çš„æ ·å¼ï¼š -``` +```html <!-- index.hml --> <div class="container"> <input type="button" class="button" value="Button"></input> </div> ``` -``` +```css /* index.css */ .button:active { background-color: #888888;/*按钮被激活时,背景颜色å˜ä¸º#888888 */ } ``` ->  **说明:** +> **说明:** > 针对弹窗类组件åŠå…¶åå…ƒç´ ä¸æ”¯æŒä¼ªç±»æ•ˆæžœï¼ŒåŒ…括popupã€dialogã€menuã€optionã€picker @@ -156,7 +156,7 @@ css伪类是选择器ä¸çš„关键å—,用于指定è¦é€‰æ‹©å…ƒç´ 的特殊状 预编译æ供了利用特有è¯æ³•ç”Ÿæˆcss的程åºï¼Œå¯ä»¥æä¾›å˜é‡ã€è¿ç®—ç‰åŠŸèƒ½ï¼Œä»¤å¼€å‘者更便æ·åœ°å®šä¹‰ç»„ä»¶æ ·å¼ï¼Œç›®å‰æ”¯æŒlessã€sasså’Œscssçš„é¢„ç¼–è¯‘ã€‚ä½¿ç”¨æ ·å¼é¢„编译时,需è¦å°†åŽŸcss文件åŽç¼€æ”¹ä¸ºlessã€sass或scss,如index.css改为index.lessã€index.sass或index.scss。 - 当å‰æ–‡ä»¶ä½¿ç”¨æ ·å¼é¢„编译,例如将原index.css改为index.less: - ``` + ```less /* index.less */ /* 定义å˜é‡ */ @colorBackground: #000000; @@ -166,7 +166,7 @@ css伪类是选择器ä¸çš„关键å—,用于指定è¦é€‰æ‹©å…ƒç´ 的特殊状 ``` - 引用预编译文件,例如commonä¸å˜åœ¨style.scss文件,将原index.css改为index.scss,并引入style.scss: - ``` + ```scss /* style.scss */ /* 定义å˜é‡ */ $colorBackground: #000000; @@ -174,7 +174,7 @@ css伪类是选择器ä¸çš„关键å—,用于指定è¦é€‰æ‹©å…ƒç´ 的特殊状 在index.scssä¸å¼•ç”¨ï¼š - ``` + ```scss /* index.scss */ /* 引入外部scss文件 */ @import '../../common/style.scss'; @@ -183,7 +183,7 @@ css伪类是选择器ä¸çš„关键å—,用于指定è¦é€‰æ‹©å…ƒç´ 的特殊状 } ``` - >  **说明:** + > **说明:** > 引用的预编译文件建议放在common目录进行管ç†ã€‚ ## CSSæ ·å¼ç»§æ‰¿<sup>6+</sup> diff --git a/zh-cn/application-dev/ui/js-framework-syntax-hml.md b/zh-cn/application-dev/ui/js-framework-syntax-hml.md index 2684911c682c245a0c43b739904dd91bf28f1876..be8967e462a13e3a9154c3e6dfbadda5c2721d25 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-hml.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-hml.md @@ -5,7 +5,7 @@ HML(OpenHarmony Markup Language)是一套类HTMLçš„æ ‡è®°è¯è¨€ï¼Œé€šè¿‡ç»„ ## 页é¢ç»“æž„ -``` +```html <!-- xxx.hml --> <div class="item-container"> <text class="item-title">Image Show</text> @@ -18,14 +18,19 @@ HML(OpenHarmony Markup Language)是一套类HTMLçš„æ ‡è®°è¯è¨€ï¼Œé€šè¿‡ç»„ ## æ•°æ®ç»‘定 -``` +```html <!-- xxx.hml --> <div onclick="changeText"> <text> {{content[1]}} </text> </div> ``` - +```css +/*xxx.css*/ +.container{ + margin: 200px; +} ``` +```js // xxx.js export default { data: { @@ -37,11 +42,12 @@ export default { } ``` ->  **说明:** +> **说明:** > - 针对数组内的数æ®ä¿®æ”¹ï¼Œè¯·ä½¿ç”¨splice方法生效数æ®ç»‘定å˜æ›´ã€‚ > > - hml文件ä¸çš„js表达å¼ä¸æ”¯æŒES6è¯æ³•ã€‚ + ## 普通事件绑定 @@ -54,7 +60,7 @@ export default { - "funcName(a,b)":函数å‚数例如a,bå¯ä»¥æ˜¯å¸¸é‡ï¼Œæˆ–者是在JS文件ä¸çš„dataä¸å®šä¹‰çš„å˜é‡ï¼ˆå‰é¢ä¸ç”¨å†™this.)。 - 示例 - ``` + ```html <!-- xxx.hml --> <div class="container"> <text class="title">{{count}}</text> @@ -69,7 +75,7 @@ export default { </div> ``` - ``` + ```js // xxx.js export default { data: { @@ -87,7 +93,7 @@ export default { }; ``` - ``` + ```css /* xxx.css */ .container { display: flex; @@ -120,6 +126,7 @@ export default { } ``` + ## 冒泡事件绑定<sup>5+</sup> @@ -128,11 +135,11 @@ export default { - 绑定冒泡事件:on:{event}.bubble。on:{event}ç‰ä»·äºŽon:{event}.bubble。 - 绑定并阻æ¢å†’泡事件å‘上冒泡:grab:{event}.bubble。grab:{event}ç‰ä»·äºŽgrab:{event}.bubble。 - >  **说明:** + > **说明:** > 详细冒泡事件说明å‚è§[通用事件](../reference/arkui-js/js-components-common-events.md)ç« èŠ‚ã€‚ - 示例 - ``` + ```html <!-- xxx.hml --> <div> <!-- 使用事件冒泡模å¼ç»‘定事件回调函数。5+ -->; @@ -150,7 +157,7 @@ export default { </div> ``` - ``` + ```js // xxx.js export default { clickfunc: function(e) { @@ -162,7 +169,7 @@ export default { } ``` ->  **说明:** +> **说明:** > 采用旧写法(onclick)的事件绑定在最å°API版本6以下时采用ä¸å†’泡处ç†ï¼Œåœ¨æœ€å°API版本为6åŠ6以上时采用冒泡处ç†ã€‚ ## æ•èŽ·äº‹ä»¶ç»‘定<sup>5+</sup> @@ -176,7 +183,7 @@ Touch触摸类事件支æŒæ•èŽ·ï¼Œæ•èŽ·é˜¶æ®µä½äºŽå†’泡阶段之å‰ï¼Œæ•èŽ· - 绑定并阻æ¢äº‹ä»¶å‘ä¸‹ä¼ é€’ï¼šgrab:{event}.capture。 - 示例 - ``` + ```html <!-- xxx.hml --> <div> <!-- 使用事件æ•èŽ·æ¨¡å¼ç»‘定事件回调函数。5+ --> @@ -186,7 +193,7 @@ Touch触摸类事件支æŒæ•èŽ·ï¼Œæ•èŽ·é˜¶æ®µä½äºŽå†’泡阶段之å‰ï¼Œæ•èŽ· </div> ``` - ``` + ```js // xxx.js export default { touchstartfuc: function(e) { @@ -198,9 +205,9 @@ Touch触摸类事件支æŒæ•èŽ·ï¼Œæ•èŽ·é˜¶æ®µä½äºŽå†’泡阶段之å‰ï¼Œæ•èŽ· ## 列表渲染 -``` +```html <!-- xxx.hml --> -<div class="array-container"> +<div class="array-container" style="flex-direction: column;margin: 200px;"> <!-- div列表渲染 --> <!-- 默认$item代表数组ä¸çš„å…ƒç´ , $idx代表数组ä¸çš„å…ƒç´ ç´¢å¼• --> <div for="{{array}}" tid="id" onclick="changeText"> @@ -218,7 +225,7 @@ Touch触摸类事件支æŒæ•èŽ·ï¼Œæ•èŽ·é˜¶æ®µä½äºŽå†’泡阶段之å‰ï¼Œæ•èŽ· ``` -``` +```js // xxx.js export default { data: { @@ -245,19 +252,20 @@ tid属性主è¦ç”¨æ¥åŠ 速for循环的é‡æ¸²æŸ“,旨在列表ä¸çš„æ•°æ®æœ‰ - for="(i, v) in array":其ä¸å…ƒç´ 索引为iï¼Œå…ƒç´ å˜é‡ä¸ºv,é历数组对象array。 ->  **说明:** +> **说明:** > - 数组ä¸çš„æ¯ä¸ªå…ƒç´ å¿…é¡»å˜åœ¨tid指定的数æ®å±žæ€§ï¼Œå¦åˆ™è¿è¡Œæ—¶å¯èƒ½ä¼šå¯¼è‡´å¼‚常。 > > - 数组ä¸è¢«tid指定的属性è¦ä¿è¯å”¯ä¸€æ€§ï¼Œå¦‚æžœä¸æ˜¯åˆ™ä¼šé€ æˆæ€§èƒ½æŸè€—。比如,示例ä¸åªæœ‰idå’Œnameå¯ä»¥ä½œä¸ºtidå—æ®µï¼Œå› ä¸ºå®ƒä»¬å±žäºŽå”¯ä¸€å—段。 > > - tidä¸æ”¯æŒè¡¨è¾¾å¼ã€‚ + ## æ¡ä»¶æ¸²æŸ“ æ¡ä»¶æ¸²æŸ“分为2ç§ï¼šif/elif/elseå’Œshow。两ç§å†™æ³•çš„区别在于:第一ç§å†™æ³•é‡Œif为false时,组件ä¸ä¼šåœ¨vdomä¸æž„建,也ä¸ä¼šæ¸²æŸ“,而第二ç§å†™æ³•é‡Œshow为false时虽然也ä¸æ¸²æŸ“,但会在vdomä¸æž„建;å¦å¤–,当使用if/elif/else写法时,节点必须是兄弟节点,å¦åˆ™ç¼–è¯‘æ— æ³•é€šè¿‡ã€‚å®žä¾‹å¦‚ä¸‹ï¼š -``` +```html <!-- xxx.hml --> <div class="container"> <button class="btn" type="capsule" value="toggleShow" onclick="toggleShow"></button> @@ -268,7 +276,7 @@ tid属性主è¦ç”¨æ¥åŠ 速for循环的é‡æ¸²æŸ“,旨在列表ä¸çš„æ•°æ®æœ‰ </div> ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -281,7 +289,7 @@ tid属性主è¦ç”¨æ¥åŠ 速for循环的é‡æ¸²æŸ“,旨在列表ä¸çš„æ•°æ®æœ‰ } ``` -``` +```js // xxx.js export default { data: { @@ -297,9 +305,11 @@ export default { } ``` + + 优化渲染优化:show方法。当show为true时,节点æ£å¸¸æ¸²æŸ“;当为false时,仅仅设置displayæ ·å¼ä¸ºnone。 -``` +```html <!-- xxx.hml --> <div class="container"> <button class="btn" type="capsule" value="toggle" onclick="toggle"></button> @@ -307,7 +317,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -320,7 +330,7 @@ export default { } ``` -``` +```js // xxx.js export default { data: { @@ -332,14 +342,16 @@ export default { } ``` ->  **说明:** +> **说明:** > ç¦æ¢åœ¨åŒä¸€ä¸ªå…ƒç´ 上åŒæ—¶è®¾ç½®forå’Œif属性。 + + ## é€»è¾‘æŽ§åˆ¶å— <block>控制å—使得循环渲染和æ¡ä»¶æ¸²æŸ“å˜å¾—æ›´åŠ çµæ´»ï¼›block在构建时ä¸ä¼šè¢«å½“作真实的节点编译。注æ„blockæ ‡ç¾åªæ”¯æŒforå’Œif属性。 -``` +```html <!-- xxx.hml --> <list> <block for="glasses"> @@ -355,7 +367,7 @@ export default { </list> ``` -``` +```js // xxx.js export default { data: { @@ -367,11 +379,13 @@ export default { } ``` + + ## 模æ¿å¼•ç”¨ HMLå¯ä»¥é€šè¿‡element引用模æ¿æ–‡ä»¶ï¼Œè¯¦ç»†ä»‹ç»å¯å‚考[自定义组件](../reference/arkui-js/js-components-custom-basic-usage.md)ç« èŠ‚ã€‚ -``` +```html <!-- template.hml --> <div class="item"> <text>Name: {{name}}</text> @@ -379,7 +393,7 @@ HMLå¯ä»¥é€šè¿‡element引用模æ¿æ–‡ä»¶ï¼Œè¯¦ç»†ä»‹ç»å¯å‚考[自定义组件 </div> ``` -``` +```html <!-- index.hml --> <element name='comp' src='../../common/template.hml'></element> <div> diff --git a/zh-cn/application-dev/ui/js-framework-syntax-js.md b/zh-cn/application-dev/ui/js-framework-syntax-js.md index ed3b8c30913e680cb7898fb360c76c9a516dfaab..8233a1903b741f09f847ec542912db31c55bf8da 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-js.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-js.md @@ -10,14 +10,14 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ - 模å—声明 使用import方法引入功能模å—: - ``` + ```js import router from '@system.router'; ``` - 代ç 引用 使用import方法导入js代ç : - ``` + ```js import utils from '../../common/utils.js'; ``` @@ -25,13 +25,13 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ ## 对象 - 应用对象 - | 属性 | 类型 | æè¿° | - | -------- | -------- | -------- | + | 属性 | 类型 | æè¿° | + | ---- | ------ | ---------------------------------------- | | $def | Object | 使用this.$app.$def获å–在app.jsä¸æš´éœ²çš„对象。<br/>>  **说明:**<br/>> 应用对象ä¸æ”¯æŒæ•°æ®ç»‘定,需主动触å‘UI更新。 | 示例代ç - ``` + ```js // app.js export default { onCreate() { @@ -51,7 +51,7 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ }; ``` - ``` + ```js // index.js页é¢é€»è¾‘代ç export default { data: { @@ -72,26 +72,26 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ ``` - 页é¢å¯¹è±¡ - | 属性 | 类型 | æè¿° | - | -------- | -------- | -------- | - | data | Object/Function | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œç±»åž‹æ˜¯å¯¹è±¡æˆ–者函数,如果类型是函数,返回值必须是对象。属性åä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—for, if, show, tid。<br/>data与privateå’Œpublicä¸èƒ½é‡åˆä½¿ç”¨ã€‚ | - | $refs | Object | æŒæœ‰æ³¨å†Œè¿‡ref 属性的DOMå…ƒç´ æˆ–å组件实例的对象。示例è§[获å–DOMå…ƒç´ ](#获å–domå…ƒç´ )。 | - | private | Object | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œprivate下的数æ®å±žæ€§åªèƒ½ç”±å½“å‰é¡µé¢ä¿®æ”¹ã€‚ | - | public | Object | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œpublic下的数æ®å±žæ€§çš„行为与dataä¿æŒä¸€è‡´ã€‚ | - | props | Array/Object | props用于组件之间的通信,å¯ä»¥é€šè¿‡<tag xxxx='value'>æ–¹å¼ä¼ 递给组件;propså称必须用å°å†™ï¼Œä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—for, if, show, tid。目å‰propsçš„æ•°æ®ç±»åž‹ä¸æ”¯æŒFunction。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。 | - | computed | Object | 用于在读å–或设置进行预先处ç†ï¼Œè®¡ç®—属性的结果会被缓å˜ã€‚计算属性åä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。 | + | 属性 | 类型 | æè¿° | + | -------- | --------------- | ---------------------------------------- | + | data | Object/Function | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œç±»åž‹æ˜¯å¯¹è±¡æˆ–者函数,如果类型是函数,返回值必须是对象。属性åä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—for, if, show, tid。<br/>data与privateå’Œpublicä¸èƒ½é‡åˆä½¿ç”¨ã€‚ | + | $refs | Object | æŒæœ‰æ³¨å†Œè¿‡ref 属性的DOMå…ƒç´ æˆ–å组件实例的对象。示例è§[获å–DOMå…ƒç´ ](#获å–domå…ƒç´ )。 | + | private | Object | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œprivate下的数æ®å±žæ€§åªèƒ½ç”±å½“å‰é¡µé¢ä¿®æ”¹ã€‚ | + | public | Object | 页é¢çš„æ•°æ®æ¨¡åž‹ï¼Œpublic下的数æ®å±žæ€§çš„行为与dataä¿æŒä¸€è‡´ã€‚ | + | props | Array/Object | props用于组件之间的通信,å¯ä»¥é€šè¿‡<tag xxxx='value'>æ–¹å¼ä¼ 递给组件;propså称必须用å°å†™ï¼Œä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—for, if, show, tid。目å‰propsçš„æ•°æ®ç±»åž‹ä¸æ”¯æŒFunction。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。 | + | computed | Object | 用于在读å–或设置进行预先处ç†ï¼Œè®¡ç®—属性的结果会被缓å˜ã€‚计算属性åä¸èƒ½ä»¥$或_开头,ä¸è¦ä½¿ç”¨ä¿ç•™å—。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。 | ## 方法 - æ•°æ®æ–¹æ³• - | 方法 | å‚æ•° | æè¿° | - | -------- | -------- | -------- | - | $set | key: string, value: any | æ·»åŠ æ–°çš„æ•°æ®å±žæ€§æˆ–者修改已有数æ®å±žæ€§ã€‚<br/>用法:<br/>this.$set('key',value)ï¼šæ·»åŠ æ•°æ®å±žæ€§ã€‚ | - | $delete | key: string | åˆ é™¤æ•°æ®å±žæ€§ã€‚<br/>用法:<br/>this.$delete('key')ï¼šåˆ é™¤æ•°æ®å±žæ€§ã€‚ | + | 方法 | å‚æ•° | æè¿° | + | ------- | -------------------------------------- | ---------------------------------------- | + | $set | key: string, value: any | æ·»åŠ æ–°çš„æ•°æ®å±žæ€§æˆ–者修改已有数æ®å±žæ€§ã€‚<br/>用法:<br/>this.$set('key',value)ï¼šæ·»åŠ æ•°æ®å±žæ€§ã€‚ | + | $delete | key: string | åˆ é™¤æ•°æ®å±žæ€§ã€‚<br/>用法:<br/>this.$delete('key')ï¼šåˆ é™¤æ•°æ®å±žæ€§ã€‚ | 示例代ç - ``` + ```js // index.js export default { data: { @@ -103,7 +103,7 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ getAppVersion() { this.$set('keyMap.Version', '3.0'); console.info("keyMap.Version = " + this.keyMap.Version); // keyMap.Version = 3.0 - + this.$delete('keyMap'); console.info("keyMap.Version = " + this.keyMap); // log print: keyMap.Version = undefined } @@ -111,37 +111,37 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ ``` - 公共方法 - | 方法 | å‚æ•° | æè¿° | - | -------- | -------- | -------- | - | $element | id: string | 获得指定idçš„ç»„ä»¶å¯¹è±¡ï¼Œå¦‚æžœæ— æŒ‡å®šidï¼Œåˆ™è¿”å›žæ ¹ç»„ä»¶å¯¹è±¡ã€‚ç¤ºä¾‹è§[获å–DOMå…ƒç´ ](#获å–domå…ƒç´ )。<br/>用法:<br/><div id='xxx'></div><br/>- this.$element('xxx'):获得id为xxx的组件对象。<br/>- this.$element()ï¼šèŽ·å¾—æ ¹ç»„ä»¶å¯¹è±¡ã€‚ | - | $rootElement | æ— | 获å–æ ¹ç»„ä»¶å¯¹è±¡ã€‚<br/>用法:this.$rootElement().scrollTo({ duration: 500, position: 300 }), 页é¢åœ¨500ms内滚动300px。 | - | $root | æ— | 获得顶级ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。 | - | $parent | æ— | 获得父级ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。 | - | $child | id: string | 获得指定idçš„å级自定义组件的ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。<br/>用法:<br/>this.$child('xxx') :获å–id为xxxçš„å级自定义组件的ViewModel实例。 | + | 方法 | å‚æ•° | æè¿° | + | ------------ | --------------- | ---------------------------------------- | + | $element | id: string | 获得指定idçš„ç»„ä»¶å¯¹è±¡ï¼Œå¦‚æžœæ— æŒ‡å®šidï¼Œåˆ™è¿”å›žæ ¹ç»„ä»¶å¯¹è±¡ã€‚ç¤ºä¾‹è§[获å–DOMå…ƒç´ ](#获å–domå…ƒç´ )。<br/>用法:<br/><div id='xxx'></div><br/>- this.$element('xxx'):获得id为xxx的组件对象。<br/>- this.$element()ï¼šèŽ·å¾—æ ¹ç»„ä»¶å¯¹è±¡ã€‚ | + | $rootElement | æ— | 获å–æ ¹ç»„ä»¶å¯¹è±¡ã€‚<br/>用法:this.$rootElement().scrollTo({ duration: 500, position: 300 }), 页é¢åœ¨500ms内滚动300px。 | + | $root | æ— | 获得顶级ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。 | + | $parent | æ— | 获得父级ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。 | + | $child | id: string | 获得指定idçš„å级自定义组件的ViewModel实例。[获å–ViewModel](#获å–viewmodel)示例。<br/>用法:<br/>this.$child('xxx') :获å–id为xxxçš„å级自定义组件的ViewModel实例。 | - 事件方法 - | 方法 | å‚æ•° | æè¿° | - | -------- | -------- | -------- | - | $watch | data: string, callback: string \| Function | 观察dataä¸çš„属性å˜åŒ–,如果属性值改å˜ï¼Œè§¦å‘绑定的事件。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。<br/>用法:<br/>this.$watch('key', callback) | + | 方法 | å‚æ•° | æè¿° | + | ---------------------------------------- | ---- | ---- | + | $watch | data: string, callback: string \| Function | 观察dataä¸çš„属性å˜åŒ–,如果属性值改å˜ï¼Œè§¦å‘绑定的事件。示例è§[自定义组件](../reference/arkui-js/js-components-custom-props.md)。<br/>用法:<br/>this.$watch('key', callback) | | | - 页é¢æ–¹æ³• - | 方法 | å‚æ•° | æè¿° | - | -------- | -------- | -------- | + | 方法 | å‚æ•° | æè¿° | + | --------------------- | -------------------------------- | ------------------------------- | | scrollTo<sup>6+</sup> | scrollPageParam: ScrollPageParam | 将页é¢æ»šåŠ¨åˆ°ç›®æ ‡ä½ç½®ï¼Œå¯ä»¥é€šè¿‡ID选择器指定或者滚动è·ç¦»æŒ‡å®šã€‚ | **表1** ScrollPageParam<sup>6+</sup> - - | å称 | 类型 | 默认值 | æè¿° | - | -------- | -------- | -------- | -------- | - | position | number | - | 指定滚动ä½ç½®ã€‚ | - | id | string | - | 指定需è¦æ»šåŠ¨åˆ°çš„å…ƒç´ id。 | - | duration | number | 300 | 指定滚动时长,å•ä½ä¸ºæ¯«ç§’。 | - | timingFunction | string | ease | 指定滚动动画曲线,å¯é€‰å€¼å‚考<br/>[åŠ¨ç”»æ ·å¼animation-timing-function](../reference/arkui-js/js-components-common-animation.md)。 | - | complete | () => void | - | 指定滚动完æˆåŽéœ€è¦æ‰§è¡Œçš„回调函数。 | + + | å称 | 类型 | 默认值 | æè¿° | + | -------------- | ----------------------- | ---- | ---------------------------------------- | + | position | number | - | 指定滚动ä½ç½®ã€‚ | + | id | string | - | 指定需è¦æ»šåŠ¨åˆ°çš„å…ƒç´ id。 | + | duration | number | 300 | 指定滚动时长,å•ä½ä¸ºæ¯«ç§’。 | + | timingFunction | string | ease | 指定滚动动画曲线,å¯é€‰å€¼å‚考<br/>[åŠ¨ç”»æ ·å¼animation-timing-function](../reference/arkui-js/js-components-common-animation.md)。 | + | complete | () => void | - | 指定滚动完æˆåŽéœ€è¦æ‰§è¡Œçš„回调函数。 | 示例: - ``` + ```js this.$rootElement().scrollTo({position: 0}) this.$rootElement().scrollTo({id: 'id', duration: 200, timingFunction: 'ease-in', complete: ()=>void}) ``` @@ -150,14 +150,14 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ ## 获å–DOMå…ƒç´ 1. 通过$refs获å–DOMå…ƒç´ - ``` + ```html <!-- index.hml --> <div class="container"> <image-animator class="image-player" ref="animator" images="{{images}}" duration="1s" onclick="handleClick"></image-animator> </div> ``` - ``` + ```js // index.js export default { data: { @@ -182,14 +182,14 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ ``` 2. 通过$element获å–DOMå…ƒç´ - ``` + ```html <!-- index.hml --> - <div class="container"> + <div class="container" style="width:500px;height: 700px; margin: 100px;"> <image-animator class="image-player" id="animator" images="{{images}}" duration="1s" onclick="handleClick"></image-animator> </div> ``` - ``` + ```js // index.js export default { data: { @@ -213,11 +213,13 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ }; ``` + + ## 获å–ViewModel æ ¹èŠ‚ç‚¹æ‰€åœ¨é¡µé¢ï¼š -``` +```html <!-- root.hml --> <element name='parentComp' src='../../common/component/parent/parent.hml'></element> <div class="container"> @@ -228,7 +230,7 @@ JS文件用æ¥å®šä¹‰HML页é¢çš„业务逻辑,支æŒECMA规范的JavaScriptè¯ </div> ``` -``` +```js // root.js export default { data: { @@ -237,9 +239,11 @@ export default { } ``` + + 自定义parent组件: -``` +```html <!-- parent.hml --> <element name='childComp' src='../child/child.hml'></element> <div class="item" onclick="textClicked"> @@ -249,7 +253,7 @@ export default { </div> ``` -``` +```js // parent.js export default { data: { @@ -268,23 +272,23 @@ export default { 自定义child组件: -``` +```html <!-- child.hml --> <div class="item" onclick="textClicked"> <text class="text-style" onclick="childClicked">child component clicked</text> - <text class="text-style" if="{{show}}">hello child component</text> + <text class="text-style" if="{{isShow}}">hello child component</text> </div> ``` -``` +```js // child.js export default { data: { - show: false, + isShow: false, text: 'I am child component!', }, childClicked () { - this.show = !this.show; + this.isShow = !this.isShow; console.info('child component get parent text'); console.info('${this.$parent().text}'); console.info('child component get root text'); @@ -292,3 +296,5 @@ export default { }, } ``` + + \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md b/zh-cn/application-dev/ui/ts-application-states-apis-environment.md index b4354b222772bffddb301b77de9b8ef045103ee3..54c3703e6bf98ac25926741fe4fdc18bf25c3bbe 100644 --- a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md +++ b/zh-cn/application-dev/ui/ts-application-states-apis-environment.md @@ -3,7 +3,7 @@ Environment是框架在应用程åºå¯åŠ¨æ—¶åˆ›å»ºçš„å•ä¾‹å¯¹è±¡ï¼Œå®ƒä¸ºAppStorageæ供了一系列应用程åºéœ€è¦çš„环境状æ€å±žæ€§ï¼Œè¿™äº›å±žæ€§æ述了应用程åºè¿è¡Œçš„设备环境。EnvironmentåŠå…¶å±žæ€§æ˜¯ä¸å¯å˜çš„,所有属性值类型å‡ä¸ºç®€å•ç±»åž‹ã€‚如下示例展示了从Environment获å–è¯éŸ³çŽ¯å¢ƒï¼š -``` +```ts Environment.EnvProp("accessibilityEnabled", "default"); var enable = AppStorage.Get("accessibilityEnabled"); ``` @@ -13,20 +13,20 @@ accessibilityEnabled是Environmentæ供默认系统å˜é‡è¯†åˆ«ç¬¦ã€‚首先需 ## EnvironmentæŽ¥å£ -| key | å‚æ•° | 返回值 | 说明 | -| -------- | -------- | -------- | -------- | -| EnvProp | key: string,<br/>defaultValue: any | boolean | å…³è”æ¤ç³»ç»Ÿé¡¹åˆ°AppStorageä¸ï¼Œå»ºè®®åœ¨appå¯åŠ¨æ—¶ä½¿ç”¨æ¤æŽ¥å£ã€‚如果该属性在AppStorageå·²å˜åœ¨ï¼Œè¿”回false。请勿使用AppStorageä¸çš„å˜é‡ï¼Œåœ¨è°ƒç”¨æ¤æ–¹æ³•å…³è”环境å˜é‡ã€‚ | -| EnvProps | keys: {<br/>key: string,<br/>defaultValue: any<br/>}[] | void | å…³è”æ¤ç³»ç»Ÿé¡¹æ•°ç»„到AppStorageä¸ã€‚ | -| Keys | Array<string> | number | 返回关è”的系统项。 | +| key | å‚æ•° | 返回值 | 说明 | +| -------- | ---------------------------------------- | ------- | ---------------------------------------- | +| EnvProp | key: string,<br/>defaultValue: any | boolean | å…³è”æ¤ç³»ç»Ÿé¡¹åˆ°AppStorageä¸ï¼Œå»ºè®®åœ¨appå¯åŠ¨æ—¶ä½¿ç”¨æ¤æŽ¥å£ã€‚如果该属性在AppStorageå·²å˜åœ¨ï¼Œè¿”回false。请勿使用AppStorageä¸çš„å˜é‡ï¼Œåœ¨è°ƒç”¨æ¤æ–¹æ³•å…³è”环境å˜é‡ã€‚ | +| EnvProps | keys: {<br/>key: string,<br/>defaultValue: any<br/>}[] | void | å…³è”æ¤ç³»ç»Ÿé¡¹æ•°ç»„到AppStorageä¸ã€‚ | +| Keys | Array<string> | number | 返回关è”的系统项。 | ## Environment内置的环境å˜é‡ -| key | 类型 | 说明 | -| -------- | -------- | -------- | -| accessibilityEnabled | boolean | æ— éšœç¢å±å¹•æœ—读是å¦å¯ç”¨ã€‚ | -| colorMode | ColorMode | 深浅色模å¼ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- ColorMode.LIGHT:浅色模å¼ï¼›<br/>- ColorMode.DARK:深色模å¼ã€‚ | -| fontScale | number | å—体大å°æ¯”例,å–值范围为[0.85, 1.45]。 | -| fontWeightScale | number | å—体æƒé‡æ¯”例,å–值范围为[0.6, 1.6]。 | -| layoutDirection | LayoutDirection | 布局方å‘类型,å¯é€‰å€¼ä¸ºï¼š<br/>- LayoutDirection.LTR:从左到å³ï¼›<br/>- LayoutDirection.RTL:从å³åˆ°å·¦ã€‚ | -| languageCode | string | 设置当å‰ç³»ç»Ÿçš„è¯è¨€ï¼Œå°å†™å—æ¯ï¼Œä¾‹å¦‚zh。 | +| key | 类型 | 说明 | +| -------------------- | --------------- | ---------------------------------------- | +| accessibilityEnabled | boolean | æ— éšœç¢å±å¹•æœ—读是å¦å¯ç”¨ã€‚ | +| colorMode | ColorMode | 深浅色模å¼ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- ColorMode.LIGHT:浅色模å¼ï¼›<br/>- ColorMode.DARK:深色模å¼ã€‚ | +| fontScale | number | å—体大å°æ¯”例,å–值范围为[0.85, 1.45]。 | +| fontWeightScale | number | å—体æƒé‡æ¯”例,å–值范围为[0.6, 1.6]。 | +| layoutDirection | LayoutDirection | 布局方å‘类型,å¯é€‰å€¼ä¸ºï¼š<br/>- LayoutDirection.LTR:从左到å³ï¼›<br/>- LayoutDirection.RTL:从å³åˆ°å·¦ã€‚ | +| languageCode | string | 设置当å‰ç³»ç»Ÿçš„è¯è¨€ï¼Œå°å†™å—æ¯ï¼Œä¾‹å¦‚zh。 | diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md b/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md index 43a1fe25b4c5a87010b9ac00875f5b747af66439..6c8c29d7ca078f56ae8fccbd14aaf61fb75931d9 100644 --- a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md +++ b/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md @@ -3,21 +3,22 @@ 方舟开å‘框架通过PersistentStorageç±»æ供了一些é™æ€æ–¹æ³•ç”¨æ¥ç®¡ç†åº”用æŒä¹…化数æ®ï¼Œå¯ä»¥å°†ç‰¹å®šæ ‡è®°çš„æŒä¹…化数æ®é“¾æŽ¥åˆ°AppStorageä¸ï¼Œå¹¶ç”±AppStorage接å£è®¿é—®å¯¹åº”æŒä¹…化数æ®ï¼Œæˆ–者通过@StorageLink装饰器æ¥è®¿é—®å¯¹åº”keyçš„å˜é‡ã€‚ -| 方法 | å‚数说明 | 返回值 | 定义 | -| -------- | -------- | -------- | -------- | -| PersistProp | key : string<br/>defaultValue: T | void | å…³è”命å的属性在AppStorageå˜ä¸ºæŒä¹…化数æ®ï¼Œèµ‹å€¼è¦†ç›–顺åºå¦‚下:<br/>- 首先,如果该属性å˜åœ¨äºŽAppStorage,将Persistentä¸çš„æ•°æ®å¤å†™ä¸ºAppStorageä¸çš„属性值。<br/>- 其次,Persistentä¸æœ‰æ¤å‘½å的属性,使用Persistentä¸çš„属性值。<br/>- 最åŽï¼Œä»¥ä¸Šæ¡ä»¶å‡ä¸æ»¡è¶³ï¼Œåˆ™ä½¿ç”¨defaultValue,ä¸æ”¯æŒnullå’Œundefined。 | -| DeleteProp | key: string | void | å–消åŒå‘æ•°æ®ç»‘定,该属性值将从æŒä¹…å˜å‚¨ä¸åˆ 除。 | -| PersistProps | keys: {<br/>key: string,<br/>defaultValue: any<br/>}[] | void | å…³è”多个命å的属性绑定。 | -| Keys | void | Array<string> | 返回所有æŒä¹…åŒ–å±žæ€§çš„æ ‡è®°ã€‚ | +| 方法 | å‚数说明 | 返回值 | 定义 | +| ------------ | ---------------------------------------- | ------------------- | ---------------------------------------- | +| PersistProp | key : string<br/>defaultValue: T | void | å…³è”命å的属性在AppStorageå˜ä¸ºæŒä¹…化数æ®ï¼Œèµ‹å€¼è¦†ç›–顺åºå¦‚下:<br/>- 首先,如果该属性å˜åœ¨äºŽAppStorage,将Persistentä¸çš„æ•°æ®å¤å†™ä¸ºAppStorageä¸çš„属性值。<br/>- 其次,Persistentä¸æœ‰æ¤å‘½å的属性,使用Persistentä¸çš„属性值。<br/>- 最åŽï¼Œä»¥ä¸Šæ¡ä»¶å‡ä¸æ»¡è¶³ï¼Œåˆ™ä½¿ç”¨defaultValue,ä¸æ”¯æŒnullå’Œundefined。 | +| DeleteProp | key: string | void | å–消åŒå‘æ•°æ®ç»‘定,该属性值将从æŒä¹…å˜å‚¨ä¸åˆ 除。 | +| PersistProps | keys: {<br/>key: string,<br/>defaultValue: any<br/>}[] | void | å…³è”多个命å的属性绑定。 | +| Keys | void | Array<string> | 返回所有æŒä¹…åŒ–å±žæ€§çš„æ ‡è®°ã€‚ | ->  **说明:** +> **说明:** > - PersistProp接å£ä½¿ç”¨æ—¶ï¼Œéœ€è¦ä¿è¯è¾“入对应的key应当在AppStorageå˜åœ¨ã€‚ -> +> > - DeleteProp接å£ä½¿ç”¨æ—¶ï¼Œåªèƒ½å¯¹æœ¬æ¬¡å¯åŠ¨å·²ç»link过的数æ®ç”Ÿæ•ˆã€‚ -``` +```ts +// xxx.ets PersistentStorage.PersistProp("highScore", "0"); @Entry diff --git a/zh-cn/application-dev/ui/ts-application-states-appstorage.md b/zh-cn/application-dev/ui/ts-application-states-appstorage.md index 4a2c477f8f873575be97ca9b913ab675c0adf414..6562cc1a9e3fd1b019432026952d5ec616b3c885 100644 --- a/zh-cn/application-dev/ui/ts-application-states-appstorage.md +++ b/zh-cn/application-dev/ui/ts-application-states-appstorage.md @@ -14,20 +14,20 @@ AppStorage的选择状æ€å±žæ€§å¯ä»¥ä¸Žä¸åŒçš„æ•°æ®æºæˆ–æ•°æ®æŽ¥æ”¶å™¨åŒ ## AppStorageæŽ¥å£ -| 方法 | å‚数说明 | 返回值 | 定义 | -| -------- | -------- | -------- | -------- | -| SetAndLink | key: string,<br/>defaultValue: T | @Link | 与Link接å£ç±»ä¼¼ï¼Œå¦‚果当å‰çš„keyä¿å˜äºŽAppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Link返回。 | -| Set | key: string,<br/>newValue: T | void | 对已ä¿å˜çš„key值,替æ¢å…¶value值。 | -| Link | key: string | @Link | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„æ•°æ®ï¼Œåˆ™è¿”回到æ¤å±žæ€§çš„åŒå‘æ•°æ®ç»‘定,该åŒå‘绑定æ„味ç€å˜é‡æˆ–者组件对数æ®çš„更改将åŒæ¥åˆ°AppStorage,通过AppStorage对数æ®çš„修改将åŒæ¥åˆ°å˜é‡æˆ–者组件。如果具有æ¤é”®çš„属性ä¸å˜åœ¨æˆ–属性为åªè¯»ï¼Œåˆ™è¿”回undefined。 | -| SetAndProp | propName: string,<br/>defaultValue: S | @Prop | 与Prop接å£ç±»ä¼¼ï¼Œå¦‚果当å‰çš„keyä¿å˜äºŽAppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Prop返回。 | -| Prop | key: string | @Prop | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„属性,则返回æ¤å±žæ€§çš„å•å‘æ•°æ®ç»‘定。该å•å‘绑定æ„味ç€åªèƒ½é€šè¿‡AppStorage将属性的更改åŒæ¥åˆ°å˜é‡æˆ–者组件。该方法返回的å˜é‡ä¸ºä¸å¯å˜å˜é‡ï¼Œé€‚用于å¯å˜å’Œä¸å¯å˜çš„状æ€å±žæ€§ï¼Œå¦‚果具有æ¤é”®çš„属性ä¸å˜åœ¨åˆ™è¿”回undefined。<br/>>  **说明:**<br/>> prop方法对应的属性值类型为简å•ç±»åž‹ã€‚ | -| SetOrCreate | key: string,<br/>newValue: T | boolean | 如果已å˜åœ¨ä¸Žç»™å®šé”®åå—相åŒçš„属性,如果æ¤å±žæ€§å¯ä»¥è¢«æ›´æ”¹åˆ™æ›¿æ¢å…¶value值且返回true,å¦åˆ™ä¸æ›¿æ¢ä¸”返回false。<br/>如果ä¸å˜åœ¨å˜åœ¨ä¸Žç»™å®šé”®åå—相åŒçš„属性, 则创建一个键为key, 值为newValue的属性,属性值ä¸æ”¯æŒnullå’Œundefined。 | -| Get | key: string | T或undefined | 通过æ¤æŽ¥å£èŽ·å–对应key值的value。 | -| Has | propName: string | boolean | 判æ–对应键值的属性是å¦å˜åœ¨ã€‚ | -| Keys | void | array<string> | 返回包å«æ‰€æœ‰é”®çš„å—符串数组。 | -| Delete | key: string | boolean | åˆ é™¤key指定的键值对,如果å˜åœ¨ä¸”åˆ é™¤æˆåŠŸè¿”回true,ä¸å˜åœ¨æˆ–åˆ é™¤å¤±è´¥è¿”å›žfalse。 | -| Clear | void | boolean | åˆ é™¤æ‰€æœ‰çš„å±žæ€§ï¼Œå¦‚æžœå½“å‰æœ‰çŠ¶æ€å˜é‡ä¾æ—§å¼•ç”¨æ¤å±žæ€§ï¼Œåˆ™è¿”回false。 | -| IsMutable | key: string | boolean | 返回æ¤å±žæ€§æ˜¯å¦å˜åœ¨å¹¶ä¸”是å¦å¯ä»¥æ”¹å˜ã€‚ | +| 方法 | å‚数说明 | 返回值 | 定义 | +| ----------- | ---------------------------------------- | ------------------- | ---------------------------------------- | +| SetAndLink | key: string,<br/>defaultValue: T | @Link | 与Link接å£ç±»ä¼¼ï¼Œå¦‚果当å‰çš„keyä¿å˜äºŽAppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Link返回。 | +| Set | key: string,<br/>newValue: T | void | 对已ä¿å˜çš„key值,替æ¢å…¶value值。 | +| Link | key: string | @Link | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„æ•°æ®ï¼Œåˆ™è¿”回到æ¤å±žæ€§çš„åŒå‘æ•°æ®ç»‘定,该åŒå‘绑定æ„味ç€å˜é‡æˆ–者组件对数æ®çš„更改将åŒæ¥åˆ°AppStorage,通过AppStorage对数æ®çš„修改将åŒæ¥åˆ°å˜é‡æˆ–者组件。如果具有æ¤é”®çš„属性ä¸å˜åœ¨æˆ–属性为åªè¯»ï¼Œåˆ™è¿”回undefined。 | +| SetAndProp | propName: string,<br/>defaultValue: S | @Prop | 与Prop接å£ç±»ä¼¼ï¼Œå¦‚果当å‰çš„keyä¿å˜äºŽAppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Prop返回。 | +| Prop | key: string | @Prop | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„属性,则返回æ¤å±žæ€§çš„å•å‘æ•°æ®ç»‘定。该å•å‘绑定æ„味ç€åªèƒ½é€šè¿‡AppStorage将属性的更改åŒæ¥åˆ°å˜é‡æˆ–者组件。该方法返回的å˜é‡ä¸ºä¸å¯å˜å˜é‡ï¼Œé€‚用于å¯å˜å’Œä¸å¯å˜çš„状æ€å±žæ€§ï¼Œå¦‚果具有æ¤é”®çš„属性ä¸å˜åœ¨åˆ™è¿”回undefined。<br/>>  **说明:**<br/>> prop方法对应的属性值类型为简å•ç±»åž‹ã€‚ | +| SetOrCreate | key: string,<br/>newValue: T | boolean | 如果已å˜åœ¨ä¸Žç»™å®šé”®åå—相åŒçš„属性,如果æ¤å±žæ€§å¯ä»¥è¢«æ›´æ”¹åˆ™æ›¿æ¢å…¶value值且返回true,å¦åˆ™ä¸æ›¿æ¢ä¸”返回false。<br/>如果ä¸å˜åœ¨å˜åœ¨ä¸Žç»™å®šé”®åå—相åŒçš„属性, 则创建一个键为key, 值为newValue的属性,属性值ä¸æ”¯æŒnullå’Œundefined。 | +| Get | key: string | T或undefined | 通过æ¤æŽ¥å£èŽ·å–对应key值的value。 | +| Has | propName: string | boolean | 判æ–对应键值的属性是å¦å˜åœ¨ã€‚ | +| Keys | void | array<string> | 返回包å«æ‰€æœ‰é”®çš„å—符串数组。 | +| Delete | key: string | boolean | åˆ é™¤key指定的键值对,如果å˜åœ¨ä¸”åˆ é™¤æˆåŠŸè¿”回true,ä¸å˜åœ¨æˆ–åˆ é™¤å¤±è´¥è¿”å›žfalse。 | +| Clear | void | boolean | åˆ é™¤æ‰€æœ‰çš„å±žæ€§ï¼Œå¦‚æžœå½“å‰æœ‰çŠ¶æ€å˜é‡ä¾æ—§å¼•ç”¨æ¤å±žæ€§ï¼Œåˆ™è¿”回false。 | +| IsMutable | key: string | boolean | 返回æ¤å±žæ€§æ˜¯å¦å˜åœ¨å¹¶ä¸”是å¦å¯ä»¥æ”¹å˜ã€‚ | ## AppStorage与组件åŒæ¥ @@ -49,7 +49,8 @@ AppStorage的选择状æ€å±žæ€§å¯ä»¥ä¸Žä¸åŒçš„æ•°æ®æºæˆ–æ•°æ®æŽ¥æ”¶å™¨åŒ ## 示例 -``` +```ts +// xxx.ets let varA = AppStorage.Link('varA') let envLang = AppStorage.Prop('languageCode') diff --git a/zh-cn/application-dev/ui/ts-attribution-configuration.md b/zh-cn/application-dev/ui/ts-attribution-configuration.md index a497ba586acbc78f04d4ba8e893a1217ade85e1e..64834f2571e3819a8c3cb5084b42c150f6ff6a2d 100644 --- a/zh-cn/application-dev/ui/ts-attribution-configuration.md +++ b/zh-cn/application-dev/ui/ts-attribution-configuration.md @@ -5,14 +5,14 @@ - é…ç½®Text组件的å—体大å°å±žæ€§ï¼š - ``` + ```ts Text('123') .fontSize(12) ``` - 使用“.â€æ“作进行链å¼è°ƒç”¨å¹¶åŒæ—¶é…置组件的多个属性,如下所示: - ``` + ```ts Image('a.jpg') .alt('error.jpg') .width(100) @@ -21,7 +21,7 @@ - é™¤äº†ç›´æŽ¥ä¼ é€’å¸¸é‡å‚数外,还å¯ä»¥ä¼ 递å˜é‡æˆ–表达å¼ï¼Œå¦‚下所示: - ``` + ```ts // Size, count, and offset are private variables defined in the component. Text('hello') .fontSize(this.size) @@ -32,7 +32,7 @@ - 对于内置组件,框架还为其属性预定义了一些枚举类型,供开å‘人员调用,枚举值å¯ä»¥ä½œä¸ºå‚æ•°ä¼ é€’ã€‚æžšä¸¾ç±»åž‹å¿…é¡»æ»¡è¶³å‚数类型è¦æ±‚,有关特定属性的枚举类型定义的详细信æ¯ã€‚å¯ä»¥æŒ‰ä»¥ä¸‹æ–¹å¼é…ç½®Text组件的颜色和å—体属性: - ``` + ```ts Text('hello') .fontSize(20) .fontColor(Color.Red) diff --git a/zh-cn/application-dev/ui/ts-child-component-configuration.md b/zh-cn/application-dev/ui/ts-child-component-configuration.md index 4c7389173443f3ba02874dff923ed909dccacd06..926d1d1c4f49a35598ef46597382285468fa50fb 100644 --- a/zh-cn/application-dev/ui/ts-child-component-configuration.md +++ b/zh-cn/application-dev/ui/ts-child-component-configuration.md @@ -5,7 +5,7 @@ - 以下是简å•çš„Column示例: - ``` + ```ts Column() { Text('Hello') .fontSize(100) @@ -18,7 +18,7 @@ - å¯ä»¥åµŒå¥—多个å组件: - ``` + ```ts Column() { Column() { Button() { diff --git a/zh-cn/application-dev/ui/ts-component-based-builder.md b/zh-cn/application-dev/ui/ts-component-based-builder.md index fd0d4f5be109fdd4cb43df3f78244b93b08657be..23abd1f50cd482f0f5580d476b2f8ed4a2cc072b 100644 --- a/zh-cn/application-dev/ui/ts-component-based-builder.md +++ b/zh-cn/application-dev/ui/ts-component-based-builder.md @@ -4,16 +4,17 @@ @Builder装饰的方法用于定义组件的声明å¼UIæ述,在一个自定义组件内快速生æˆå¤šä¸ªå¸ƒå±€å†…容。\@Builder装饰方法的功能和è¯æ³•è§„范与[build函数](ts-function-build.md)相åŒã€‚ -``` +```ts +// xxx.ets @Entry @Component struct CompA { - size : number = 100; + size1 : number = 100; @Builder SquareText(label: string) { Text(label) - .width(1 * this.size) - .height(1 * this.size) + .width(1 * this.size1) + .height(1 * this.size1) } @Builder RowOfSquareTexts(label1: string, label2: string) { @@ -21,8 +22,8 @@ struct CompA { this.SquareText(label1) this.SquareText(label2) } - .width(2 * this.size) - .height(1 * this.size) + .width(2 * this.size1) + .height(1 * this.size1) } build() { @@ -32,12 +33,12 @@ struct CompA { this.SquareText("B") // or as long as tsc is used } - .width(2 * this.size) - .height(1 * this.size) + .width(2 * this.size1) + .height(1 * this.size1) this.RowOfSquareTexts("C", "D") } - .width(2 * this.size) - .height(2 * this.size) + .width(2 * this.size1) + .height(2 * this.size1) } } ``` @@ -51,7 +52,8 @@ struct CompA { ### å‚æ•°åˆå§‹åŒ–组件 通过å‚æ•°åˆå§‹åŒ–组件时,将@Builder装饰的方法赋值给@BuilderParam修饰的属性,并在自定义组件内调用content属性值。对@BuilderParam修饰的属性进行赋值时ä¸å¸¦å‚数(如:`content: this.specificParam`),则æ¤å±žæ€§çš„类型需定义æˆæ— 返回值的函数(如:`@BuilderParam content: () => void`)。若带å‚数(如:`callContent: this.specificParam1("111")`),则æ¤å±žæ€§çš„类型需定义æˆany(如:`@BuilderParam callContent: any;`)。 -``` +```ts +// xxx.ets @Component struct CustomContainer { header: string = ""; @@ -100,7 +102,8 @@ struct CustomContainerUser { 在自定义组件ä¸ä½¿ç”¨@BuilderParam修饰的属性接收尾éšé—包(在åˆå§‹åŒ–自定义组件时,组件å称紧跟一个大括å·â€œ{}â€å½¢æˆå°¾éšé—包场景(`CustomComponent(){}`)。开å‘者å¯æŠŠå°¾éšé—包看åšä¸€ä¸ªå®¹å™¨ï¼Œå‘其填充内容,如在é—åŒ…å†…å¢žåŠ ç»„ä»¶ï¼ˆ`{Column(){Text("content")}`),é—包内è¯æ³•è§„范与[build](../ui/ts-function-build.md)一致。æ¤åœºæ™¯ä¸‹è‡ªå®šä¹‰ç»„件内有且仅有一个使用@BuilderParam修饰的属性。 示例:在é—åŒ…å†…å¢žåŠ Columnç»„ä»¶å¹¶æ·»åŠ ç‚¹å‡»äº‹ä»¶ï¼Œåœ¨æ–°å¢žçš„Column组件内调用@Builder修饰的specificParam方法,点击Column组件åŽè¯¥æ”¹å˜è‡ªå®šä¹‰ç»„件ä¸header的属性值为“changeHeaderâ€ã€‚并且在åˆå§‹åŒ–自定义组件时会把尾éšé—包的内容赋值给使用@BuilderParam修饰的closer属性。 -``` +```ts +// xxx.ets @Component struct CustomContainer { header: string = ""; diff --git a/zh-cn/application-dev/ui/ts-component-based-component.md b/zh-cn/application-dev/ui/ts-component-based-component.md index aaaeeb40622b2918e9af9da73c7106c0fe317bcc..fd7a8f8cab8dbb989e077d5871ee55dc013dfc95 100644 --- a/zh-cn/application-dev/ui/ts-component-based-component.md +++ b/zh-cn/application-dev/ui/ts-component-based-component.md @@ -4,27 +4,25 @@ - å¯ç»„åˆï¼šå…许开å‘人员组åˆä½¿ç”¨å†…置组件ã€å…¶ä»–组件ã€å…¬å…±å±žæ€§å’Œæ–¹æ³•ï¼› - +- 链å¼è°ƒç”¨<sup>9+</sup>:通过链å¼è°ƒç”¨é€šç”¨å±žæ€§æ”¹å˜ç»„ä»¶æ ·å¼ï¼› - å¯é‡ç”¨ï¼šè‡ªå®šä¹‰ç»„件å¯ä»¥è¢«å…¶ä»–组件é‡ç”¨ï¼Œå¹¶ä½œä¸ºä¸åŒçš„实例在ä¸åŒçš„父组件或容器ä¸ä½¿ç”¨ï¼› - - 生命周期:生命周期的回调方法å¯ä»¥åœ¨ç»„件ä¸é…置,用于业务逻辑处ç†ï¼› - - æ•°æ®é©±åŠ¨æ›´æ–°ï¼šç”±çŠ¶æ€å˜é‡çš„æ•°æ®é©±åŠ¨ï¼Œå®žçŽ°UI自动更新。 -对组件化的深入æ述,请å‚考深入ç†è§£ç»„件化。 +对组件化的深入æ述,请å‚考[深入ç†è§£ç»„件化](ts-custom-component-initialization.md)。 ->  **说明:** -> - 自定义组件必须定义build方法。 -> -> - 自定义组件ç¦æ¢è‡ªå®šä¹‰æž„é€ å‡½æ•°ã€‚ +> **说明:** +> +> - 自定义组件必须定义build方法。 +>- 自定义组件ç¦æ¢è‡ªå®šä¹‰æž„é€ å‡½æ•°ã€‚ 如下代ç 定义了MyComponent组件: -``` +```ts @Component struct MyComponent { build() { @@ -43,7 +41,7 @@ MyComponentçš„build方法会在åˆå§‹æ¸²æŸ“时执行,æ¤å¤–,当组件ä¸çš„ 以下代ç 使用了MyComponent组件: -``` +```ts @Component struct ParentComponent { build() { @@ -60,7 +58,7 @@ struct ParentComponent { å¯ä»¥å¤šæ¬¡ä½¿ç”¨MyComponent,并在ä¸åŒçš„组件ä¸è¿›è¡Œé‡ç”¨ï¼š -``` +```ts @Component struct ParentComponent { build() { @@ -78,12 +76,46 @@ struct ParentComponent { } } - private aboutToAppear() { + aboutToAppear() { console.log('ParentComponent: Just created, about to become rendered first time.') } - private aboutToDisappear() { + aboutToDisappear() { console.log('ParentComponent: About to be removed from the UI.') } } ``` + +å¯é“¾å¼è°ƒç”¨é€šç”¨å±žæ€§ï¼Œä½¿ç»„ä»¶æ ·å¼å¤šæ ·åŒ–: + +> **说明:** 从API version 9开始支æŒã€‚ +> +> 自定义组件链å¼è°ƒç”¨æš‚ä¸æ”¯æŒå°¾éšé—包写法(在åˆå§‹åŒ–自定义组件时,组件å称紧跟一个大括å·â€œ{}â€å½¢æˆå°¾éšé—包场景`(Inedx(){})`。开å‘者å¯æŠŠå°¾éšé—包看åšä¸€ä¸ªå®¹å™¨ï¼Œå‘其填充内容,如在é—åŒ…å†…å¢žåŠ ç»„ä»¶`{Column(){Text("content")}` )。 + +```ts +@Entry +@Component +struct Index { + @State bannerValue: string = 'Hello,world'; + build() { + Column() { + Chind({ ChindBannerValue:$bannerValue }) + .height(60) + .width(250) + .border({ width:5, color:Color.Red, radius:10, style: BorderStyle.Dotted }) + } + } +} + +@Component +struct Chind { + @Link ChindBannerValue: string; + build() { + Column() { + Text(this.ChindBannerValue) + .fontSize(30) + } + } +} +``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-customdialog.md b/zh-cn/application-dev/ui/ts-component-based-customdialog.md index 72b8c9cb6b64b2e410caff9dc3934d6cc171c4aa..13082cfa353e705fcd464a21cfba17b7d0b61f21 100644 --- a/zh-cn/application-dev/ui/ts-component-based-customdialog.md +++ b/zh-cn/application-dev/ui/ts-component-based-customdialog.md @@ -3,7 +3,7 @@ @CustomDialog装饰器用于装饰自定义弹窗。 -``` +```ts // custom-dialog-demo.ets @CustomDialog struct DialogExample { diff --git a/zh-cn/application-dev/ui/ts-component-based-entry.md b/zh-cn/application-dev/ui/ts-component-based-entry.md index 24e1ec5772b4acae04f8e6b85b9c38013bb5b9d7..74e81fe05e1681b687a5b6827d6c41bbd903bac4 100644 --- a/zh-cn/application-dev/ui/ts-component-based-entry.md +++ b/zh-cn/application-dev/ui/ts-component-based-entry.md @@ -3,14 +3,14 @@ 用@Entry装饰的自定义组件用作页é¢çš„默认入å£ç»„ä»¶ï¼ŒåŠ è½½é¡µé¢æ—¶ï¼Œå°†é¦–先创建并呈现@Entry装饰的自定义组件。 ->  **说明:** +> **说明:** > 在å•ä¸ªæºæ–‡ä»¶ä¸ï¼Œæœ€å¤šå¯ä»¥ä½¿ç”¨@Entry装饰一个自定义组件。 @Entry的用法如下: -``` +```ts // Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed. @Entry @Component diff --git a/zh-cn/application-dev/ui/ts-component-based-extend.md b/zh-cn/application-dev/ui/ts-component-based-extend.md index d8f8c63f1a42e41d87082f4efaa1477604026ae7..567f5b7f04aa76809a2785c5ddaee22a34472cfe 100644 --- a/zh-cn/application-dev/ui/ts-component-based-extend.md +++ b/zh-cn/application-dev/ui/ts-component-based-extend.md @@ -3,7 +3,8 @@ @Extendè£…é¥°å™¨å°†æ–°çš„å±žæ€§å‡½æ•°æ·»åŠ åˆ°å†…ç½®ç»„ä»¶ä¸Šï¼Œå¦‚Textã€Columnã€Buttonç‰ã€‚通过@Extend装饰器å¯ä»¥å¿«é€Ÿå®šä¹‰å¹¶å¤ç”¨ç»„ä»¶çš„è‡ªå®šä¹‰æ ·å¼ã€‚ -``` +```ts +// xxx.ets @Extend(Text) function fancy(fontSize: number) { .fontColor(Color.Red) .fontSize(fontSize) @@ -25,5 +26,5 @@ struct FancyUse { ``` ->  **说明:** +> **说明:** > @Extend装饰器ä¸èƒ½ç”¨åœ¨è‡ªå®šä¹‰ç»„件struct定义框内。 diff --git a/zh-cn/application-dev/ui/ts-component-based-preview.md b/zh-cn/application-dev/ui/ts-component-based-preview.md index b7c790de7201fddbf0e6fe68cff729bf06fa9933..574ba980deb2eb261fe82c40ddf06729b66f3bd6 100644 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ b/zh-cn/application-dev/ui/ts-component-based-preview.md @@ -3,14 +3,15 @@ 用@Preview装饰的自定义组件å¯ä»¥åœ¨DevEco Studioçš„é¢„è§ˆå™¨ä¸Šè¿›è¡Œé¢„è§ˆï¼ŒåŠ è½½é¡µé¢æ—¶ï¼Œå°†åˆ›å»ºå¹¶å‘ˆçŽ°@Preview装饰的自定义组件。 ->  **说明:** +> **说明:** > 在å•ä¸ªæºæ–‡ä»¶ä¸ï¼Œæœ€å¤šå¯ä»¥ä½¿ç”¨10个@Preview装饰自定义组件。 @Preview的用法如下: -``` +```ts +// xxx.ets @Entry @Component struct MyComponent { diff --git a/zh-cn/application-dev/ui/ts-component-based-styles.md b/zh-cn/application-dev/ui/ts-component-based-styles.md index c655aaa5e925637bfc945f992e7fa1867d200c3a..288081d69ff3d0c4a7908c883319d5a4f430f7f0 100644 --- a/zh-cn/application-dev/ui/ts-component-based-styles.md +++ b/zh-cn/application-dev/ui/ts-component-based-styles.md @@ -4,10 +4,11 @@ @Stylesè£…é¥°å™¨å°†æ–°çš„å±žæ€§å‡½æ•°æ·»åŠ åˆ°åŸºæœ¬ç»„ä»¶ä¸Šï¼Œå¦‚Textã€Columnã€Buttonç‰ã€‚当å‰@Styles仅支æŒé€šç”¨å±žæ€§ã€‚通过@Styles装饰器å¯ä»¥å¿«é€Ÿå®šä¹‰å¹¶å¤ç”¨ç»„ä»¶çš„è‡ªå®šä¹‰æ ·å¼ã€‚ -@Styleså¯ä»¥å®šä¹‰åœ¨ç»„件内或组件外,在组件外定义时需带上function关键å—,组件内定义时ä¸éœ€è¦ã€‚ +@Styleså¯ä»¥å®šä¹‰åœ¨ç»„件内或组件外,在组件外定义时需在方法å‰æ·»åŠ function关键å—,组件内定义时ä¸éœ€è¦æ·»åŠ function关键å—。 -``` +```ts +// xxx.ets @Styles function globalFancy() { .backgroundColor(Color.Red) } @@ -39,7 +40,8 @@ struct FancyUse { 在StateStyles内å¯ä»¥ç›´æŽ¥è°ƒç”¨ç»„件外定义的Styles,但需è¦é€šè¿‡this关键å—调用组件内定义的Styles。 -``` +```ts +// xxx.ets @Styles function globalFancy() { .width(100) .height(100) diff --git a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md index 1786a365cb4098141f02e8a0f9c2a79993abd91b..2ec686adbe79f83c44d548b31d928c51d7f841f9 100644 --- a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md +++ b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md @@ -46,7 +46,8 @@ ## 示例 -``` +```ts +// xxx.ets @Entry @Component struct ParentComp { diff --git a/zh-cn/application-dev/ui/ts-component-states-link.md b/zh-cn/application-dev/ui/ts-component-states-link.md index 6855651df3ac977b3237e81666120a6d191e4842..e6aef9bf933352edd56b46dfc8050cc91259b377 100644 --- a/zh-cn/application-dev/ui/ts-component-states-link.md +++ b/zh-cn/application-dev/ui/ts-component-states-link.md @@ -14,13 +14,14 @@ - 创建自定义组件时需è¦å°†å˜é‡çš„å¼•ç”¨ä¼ é€’ç»™@Linkå˜é‡ï¼Œåœ¨åˆ›å»ºç»„件的新实例时,必须使用命åå‚æ•°åˆå§‹åŒ–所有@Linkå˜é‡ã€‚@Linkå˜é‡å¯ä»¥ä½¿ç”¨@Stateå˜é‡æˆ–@Linkå˜é‡çš„引用进行åˆå§‹åŒ–,@Stateå˜é‡å¯ä»¥é€šè¿‡`'$'`æ“作符创建引用。 ->  说明: +> 说明: > @Linkå˜é‡ä¸èƒ½åœ¨ç»„件内部进行åˆå§‹åŒ–。 ## 简å•ç±»åž‹ç¤ºä¾‹ -``` +```ts +// xxx.ets @Entry @Component struct Player { @@ -53,7 +54,8 @@ struct PlayButton { ## å¤æ‚类型示例 -``` +```ts +// xxx.ets @Entry @Component struct Parent { @@ -93,7 +95,8 @@ struct Child { ## @Linkã€@Stateå’Œ@Prop结åˆä½¿ç”¨ç¤ºä¾‹ -``` +```ts +// xxx.ets @Entry @Component struct ParentView { diff --git a/zh-cn/application-dev/ui/ts-component-states-prop.md b/zh-cn/application-dev/ui/ts-component-states-prop.md index e62d23fa7646714a0edfe187920213fe77c7f27c..997bf63e91803ccfef3f03fcad26021bc28968b8 100644 --- a/zh-cn/application-dev/ui/ts-component-states-prop.md +++ b/zh-cn/application-dev/ui/ts-component-states-prop.md @@ -16,7 +16,8 @@ ## 示例 -``` +```ts +// xxx.ets @Entry @Component struct ParentComponent { @@ -65,5 +66,5 @@ struct CountDownComponent { 在上述示例ä¸ï¼Œå½“按“+1â€æˆ–“-1â€æŒ‰é’®æ—¶ï¼Œçˆ¶ç»„件状æ€å‘生å˜åŒ–,é‡æ–°æ‰§è¡Œbuild方法,æ¤æ—¶å°†åˆ›å»ºä¸€ä¸ªæ–°çš„CountDownComponent组件。父组件的countDownStartValue状æ€å±žæ€§è¢«ç”¨äºŽåˆå§‹åŒ–å组件的@Propå˜é‡ï¼Œå½“按下å组件的“Try againâ€æŒ‰é’®æ—¶ï¼Œå…¶@Propå˜é‡count将被更改,CountDownComponenté‡æ–°æ¸²æŸ“。但是count值的更改ä¸ä¼šå½±å“父组件的countDownStartValue值。 ->  **说明:** +> **说明:** > 创建新组件实例时,必须åˆå§‹åŒ–其所有@Propå˜é‡ã€‚ diff --git a/zh-cn/application-dev/ui/ts-component-states-state.md b/zh-cn/application-dev/ui/ts-component-states-state.md index 6db720203f0641239c0c4084deca000201db9893..2dd964f10e9d8ac6c85741c57a8ce9051a5ad0cf 100644 --- a/zh-cn/application-dev/ui/ts-component-states-state.md +++ b/zh-cn/application-dev/ui/ts-component-states-state.md @@ -18,7 +18,8 @@ ## 简å•ç±»åž‹çš„状æ€å±žæ€§ç¤ºä¾‹ -``` +```ts +// xxx.ets @Entry @Component struct MyComponent { @@ -42,8 +43,9 @@ struct MyComponent { ## å¤æ‚类型的状æ€å˜é‡ç¤ºä¾‹ -``` +```ts // Customize the status data class. +// xxx.ets class Model { value: string constructor(value: string) { @@ -97,6 +99,6 @@ struct MyComponent { - EntryComponentä¸æœ‰å¤šä¸ªMyComponent组件实例,第一个MyComponent内部状æ€çš„更改ä¸ä¼šå½±å“第二个MyComponentï¼› - 创建MyComponent实例时通过å˜é‡å给组件内的å˜é‡è¿›è¡Œåˆå§‹åŒ–,如: - ``` + ```ts MyComponent({title: {value: 'Hello, World 2'}, count: 7}) ``` diff --git a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md b/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md index 25b4d88fe9516f416b22044a4ce099bc15062df0..17c9aa3f3fa21e28cb37de06095141bde7ec7ddf 100644 --- a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md +++ b/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md @@ -8,13 +8,13 @@ - Image组件的必选å‚æ•°src: - ``` + ```ts Image('http://xyz/a.jpg') ``` - Text组件的必选å‚æ•°content: - ``` + ```ts Text('123') ``` @@ -22,7 +22,7 @@ å˜é‡æˆ–表达å¼ä¹Ÿå¯ä»¥ç”¨äºŽå‚数赋值,其ä¸è¡¨è¾¾å¼è¿”回的结果类型必须满足å‚数类型è¦æ±‚ã€‚ä¾‹å¦‚ï¼Œä¼ é€’å˜é‡æˆ–表达å¼æ¥æž„é€ Imageå’ŒText组件的å‚数: -``` +```ts // imagePath, where imageUrl is a private data variable defined in the component. Image(this.imagePath) Image('http://' + this.imageUrl) diff --git a/zh-cn/application-dev/ui/ts-custom-component-initialization.md b/zh-cn/application-dev/ui/ts-custom-component-initialization.md index 0e407eb84db9a6b15f82a9bd24214b2c35b4b9c5..1433542af3203e3a54f6d883ef099b8f5438f52f 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-initialization.md +++ b/zh-cn/application-dev/ui/ts-custom-component-initialization.md @@ -4,30 +4,30 @@ - 本地åˆå§‹åŒ–,例如: - ``` + ```ts @State counter: Counter = new Counter() ``` - åœ¨æž„é€ ç»„ä»¶æ—¶é€šè¿‡æž„é€ å‚æ•°åˆå§‹åŒ–,例如: - ``` - MyComponent(counter: $myCounter) + ```ts + MyComponent({counter: $myCounter}) ``` 具体å…许哪ç§æ–¹å¼å–决于状æ€å˜é‡çš„装饰器: -| 装饰器类型 | 本地åˆå§‹åŒ– | é€šè¿‡æž„é€ å‡½æ•°å‚æ•°åˆå§‹åŒ– | -| -------- | -------- | -------- | -| @State | å¿…é¡» | å¯é€‰ | -| @Prop | ç¦æ¢ | å¿…é¡» | -| @Link | ç¦æ¢ | å¿…é¡» | -| @StorageLink | å¿…é¡» | ç¦æ¢ | -| @StorageProp | å¿…é¡» | ç¦æ¢ | -| @Provide | å¿…é¡» | å¯é€‰ | -| @Consume | ç¦æ¢ | ç¦æ¢ | -| @ObjectLink | ç¦æ¢ | å¿…é¡» | -| 常规æˆå‘˜å˜é‡ | 推è | å¯é€‰ | +| 装饰器类型 | 本地åˆå§‹åŒ– | é€šè¿‡æž„é€ å‡½æ•°å‚æ•°åˆå§‹åŒ– | +| ------------ | ----- | ----------- | +| @State | å¿…é¡» | å¯é€‰ | +| @Prop | ç¦æ¢ | å¿…é¡» | +| @Link | ç¦æ¢ | å¿…é¡» | +| @StorageLink | å¿…é¡» | ç¦æ¢ | +| @StorageProp | å¿…é¡» | ç¦æ¢ | +| @Provide | å¿…é¡» | å¯é€‰ | +| @Consume | ç¦æ¢ | ç¦æ¢ | +| @ObjectLink | ç¦æ¢ | å¿…é¡» | +| 常规æˆå‘˜å˜é‡ | 推è | å¯é€‰ | 从上表ä¸å¯ä»¥çœ‹å‡ºï¼š @@ -42,13 +42,13 @@ | 从父组件ä¸çš„å˜é‡ï¼ˆä¸‹ï¼‰åˆ°å组件ä¸çš„å˜é‡ï¼ˆå³ï¼‰ | @State | @Link | @Prop | 常规å˜é‡ | -| -------- | -------- | -------- | -------- | -------- | -| @State | ä¸å…许 | å…许 | å…许 | å…许 | -| @Link | ä¸å…许 | å…许 | ä¸æŽ¨è | å…许 | -| @Prop | ä¸å…许 | ä¸å…许 | å…许 | å…许 | -| @StorageLink | ä¸å…许 | å…许 | ä¸å…许 | å…许 | -| @StorageProp | ä¸å…许 | ä¸å…许 | ä¸å…许 | å…许 | -| 常规å˜é‡ | å…许 | ä¸å…许 | ä¸å…许 | å…许 | +| ---------------------- | ------ | ----- | ----- | ---- | +| @State | ä¸å…许 | å…许 | å…许 | å…许 | +| @Link | ä¸å…许 | å…许 | ä¸æŽ¨è | å…许 | +| @Prop | ä¸å…许 | ä¸å…许 | å…许 | å…许 | +| @StorageLink | ä¸å…许 | å…许 | ä¸å…许 | å…许 | +| @StorageProp | ä¸å…许 | ä¸å…许 | ä¸å…许 | å…许 | +| 常规å˜é‡ | å…许 | ä¸å…许 | ä¸å…许 | å…许 | 从上表ä¸å¯ä»¥çœ‹å‡ºï¼š @@ -69,43 +69,57 @@ ## 示例 -``` +```ts +// xxx.ets +class ClassA { + public a:number + constructor(a: number) { + this.a = a + } +} @Entry @Component struct Parent { - @State parentState: ClassA = new ClassA() - build() { - Row() { - CompA({aState: new ClassA, aLink: $parentState}) // valid - CompA({aLink: $parentState}) // valid - CompA() // invalid, @Link aLink remains uninitialized - CompA({aLink: new ClassA}) // invalid, @Link aLink must be a reference ($) to either @State or @Link variable - } + @State parentState: ClassA = new ClassA(1) + + build() { + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aState: new ClassA(2), aLink: $parentState }) + } + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aLink: $parentState }) + } + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CompA({ aState: new ClassA(3), aLink: $parentState }) + } } + } } @Component struct CompA { - @State aState: boolean = false // must initialize locally - @Link aLink: ClassA // must not initialize locally - - build() { - Row() { - CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, - bProp: this.aState}) // valid init a @Prop with value of a @State - CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean - bProp: false}) // valid init a @Prop by constants value - } + @State aState: any = false + @Link aLink: ClassA + + build() { + Column() { + CompB({ bLink: $aLink, bProp: this.aState }) + CompB({ bLink: $aState, bProp: false }) } + } } @Component struct CompB { - @Link bLink: ClassA = new ClassA() // invalid, must not initialize locally - @Prop bProp: boolean = false // invalid must not initialize locally - - build() { - ... - } + @Link bLink: ClassA + @Prop bProp: boolean + + build() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Text(JSON.stringify(this.bLink.a)).fontSize(30) + Text(JSON.stringify(this.bProp)).fontSize(30).fontColor(Color.Red) + }.margin(10) + } } ``` diff --git a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 9c1cd67d3df25064d8f45d9d63ecdf2b5bf9ae8d..7057e34756c738d113ba3e65bc67d51c86491a20 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -5,18 +5,19 @@ ## 生命周期回调函数定义 -| 函数å | æè¿° | -| -------- | -------- | -| aboutToAppear | 函数在创建自定义组件的新实例åŽï¼Œåœ¨æ‰§è¡Œå…¶build函数之å‰æ‰§è¡Œã€‚å…许在aboutToAppear函数ä¸æ”¹å˜çŠ¶æ€å˜é‡ï¼Œæ›´æ”¹å°†åœ¨åŽç»æ‰§è¡Œbuild函数ä¸ç”Ÿæ•ˆã€‚ | +| 函数å | æè¿° | +| ---------------- | ---------------------------------------- | +| aboutToAppear | 函数在创建自定义组件的新实例åŽï¼Œåœ¨æ‰§è¡Œå…¶build函数之å‰æ‰§è¡Œã€‚å…许在aboutToAppear函数ä¸æ”¹å˜çŠ¶æ€å˜é‡ï¼Œæ›´æ”¹å°†åœ¨åŽç»æ‰§è¡Œbuild函数ä¸ç”Ÿæ•ˆã€‚ | | aboutToDisappear | 函数在自定义组件æžæž„消耗之å‰æ‰§è¡Œã€‚ä¸å…许在aboutToDisappear函数ä¸æ”¹å˜çŠ¶æ€å˜é‡ï¼Œç‰¹åˆ«æ˜¯@Linkå˜é‡çš„修改å¯èƒ½ä¼šå¯¼è‡´åº”用程åºè¡Œä¸ºä¸ç¨³å®šã€‚ | -| onPageShow | 页é¢æ˜¾ç¤ºæ—¶è§¦å‘一次,包括路由过程ã€åº”用进入å‰åŽå°ç‰åœºæ™¯ï¼Œä»…@Entry修饰的自定义组件生效。 | -| onPageHide | 页é¢æ¶ˆå¤±æ—¶è§¦å‘一次,包括路由过程ã€åº”用进入å‰åŽå°ç‰åœºæ™¯ï¼Œä»…@Entry修饰的自定义组件生效。 | -| onBackPress | 当用户点击返回按钮时触å‘,仅\@Entry修饰的自定义组件生效。<br/>- 返回true表示页é¢è‡ªå·±å¤„ç†è¿”回逻辑, ä¸è¿›è¡Œé¡µé¢è·¯ç”±ã€‚<br/>- 返回false表示使用默认的返回逻辑。<br/>- ä¸è¿”回值会作为false处ç†ã€‚ | +| onPageShow | 页é¢æ˜¾ç¤ºæ—¶è§¦å‘一次,包括路由过程ã€åº”用进入å‰åŽå°ç‰åœºæ™¯ï¼Œä»…@Entry修饰的自定义组件生效。 | +| onPageHide | 页é¢æ¶ˆå¤±æ—¶è§¦å‘一次,包括路由过程ã€åº”用进入å‰åŽå°ç‰åœºæ™¯ï¼Œä»…@Entry修饰的自定义组件生效。 | +| onBackPress | 当用户点击返回按钮时触å‘,仅\@Entry修饰的自定义组件生效。<br/>- 返回true表示页é¢è‡ªå·±å¤„ç†è¿”回逻辑, ä¸è¿›è¡Œé¡µé¢è·¯ç”±ã€‚<br/>- 返回false表示使用默认的返回逻辑。<br/>- ä¸è¿”回值会作为false处ç†ã€‚ | ## 示例 -``` +```ts +// xxx.ets @Entry @Component struct CountDownTimerComponent { @@ -48,7 +49,7 @@ struct CountDownTimerComponent { 上述示例表明,生命周期函数对于å…许CountDownTimerComponent管ç†å…¶è®¡æ—¶å™¨èµ„æºè‡³å…³é‡è¦ï¼Œç±»ä¼¼çš„函数也包括异æ¥ä»Žç½‘ç»œè¯·æ±‚åŠ è½½èµ„æºã€‚ ->  **说明:** +> **说明:** > - å…许在生命周期函数ä¸ä½¿ç”¨Promise和异æ¥å›žè°ƒå‡½æ•°ï¼Œæ¯”如网络资æºèŽ·å–,定时器设置ç‰ï¼› -> +> > - ä¸å…许在生命周期函数ä¸ä½¿ç”¨async await。 diff --git a/zh-cn/application-dev/ui/ts-event-configuration.md b/zh-cn/application-dev/ui/ts-event-configuration.md index 9ded73d381b0a29f0d6a1115a65a778596dac212..d9c2274dca564d045e687e391ce791e964dd8c00 100644 --- a/zh-cn/application-dev/ui/ts-event-configuration.md +++ b/zh-cn/application-dev/ui/ts-event-configuration.md @@ -1,10 +1,10 @@ # 事件é…ç½® -通过事件方法å¯ä»¥é…置组件支æŒçš„事件。 +通过事件方法å¯ä»¥é…置组件支æŒçš„事件。从API Version 9开始,å¯ä»¥åœ¨å›žè°ƒå‡½æ•°ä¸èŽ·å–当å‰componentå…³è”çš„Context,具体用法请å‚考[在eTS页é¢ä¸è®¿é—®Context](../ability/context-userguide.md)。 - 使用lambda表达å¼é…置组件的事件方法: - ``` + ```ts // Counter is a private data variable defined in the component. Button('add counter') .onClick(() => { @@ -14,7 +14,7 @@ - 使用匿å函数表达å¼é…置组件的事件方法,è¦æ±‚使用bind,以确ä¿å‡½æ•°ä½“ä¸çš„this引用包å«çš„组件: - ``` + ```ts // Counter is a private data variable defined in the component. Button('add counter') .onClick(function () { @@ -24,13 +24,13 @@ - 使用组件的æˆå‘˜å‡½æ•°é…置组件的事件方法: - ``` + ```ts myClickHandler(): void { // do something } - + ... - + Button('add counter') .onClick(this.myClickHandler) ``` diff --git a/zh-cn/application-dev/ui/ts-framework-directory.md b/zh-cn/application-dev/ui/ts-framework-directory.md index 70c440aaa079787674094c18b2218ac22eb2d186..b4a7b831db8239dede96749a1bd7a19a0419cc23 100644 --- a/zh-cn/application-dev/ui/ts-framework-directory.md +++ b/zh-cn/application-dev/ui/ts-framework-directory.md @@ -24,8 +24,8 @@ FA应用的eTS模å—(entry/src/main)的典型开å‘目录结构如下: - **common**目录用于å˜æ”¾å…¬å…±ä»£ç 文件,比如:自定义组件和公共方法。 ->  **说明:** -> -> - 资æºç›®å½•resources文件夹ä½äºŽsrc/main下,æ¤ç›®å½•ä¸‹èµ„æºæ–‡ä»¶çš„详细规范以åŠå目录结构规范å‚看[资æºæ–‡ä»¶çš„分类](../quick-start/basic-resource-file-categories.md)。 +> **说明:** +> +> - 资æºç›®å½•resources文件夹ä½äºŽsrc/main下,æ¤ç›®å½•ä¸‹èµ„æºæ–‡ä»¶çš„详细规范以åŠå目录结构规范å‚看[资æºæ–‡ä»¶çš„分类](ui-ts-basic-resource-file-categories.md)。 > > - 页é¢æ”¯æŒå¯¼å…¥TypeScriptå’ŒJavaScript文件。 diff --git a/zh-cn/application-dev/ui/ts-framework-file-access-rules.md b/zh-cn/application-dev/ui/ts-framework-file-access-rules.md index ffc32f5b1b0b2c7c51fb17f919a5f93ea70a6fef..3d8a3b5709b49781d3aa3d51dafdf38c7ec2a3b3 100644 --- a/zh-cn/application-dev/ui/ts-framework-file-access-rules.md +++ b/zh-cn/application-dev/ui/ts-framework-file-access-rules.md @@ -12,7 +12,8 @@ ## 示例 -``` +```ts +// xxx.ets import { FoodData, FoodList } from "../common/utils/utils.ets"; @Entry @@ -33,7 +34,7 @@ struct FoodCategoryList { 导入文件示例: -``` +```ts //common/utils/utils.ets export class FoodData { diff --git a/zh-cn/application-dev/ui/ts-framework-js-tag.md b/zh-cn/application-dev/ui/ts-framework-js-tag.md index c86383841617c4f0157c9a6371f82e9cf54e8da1..fd31748b849bd62ea9379e35ab82ad5b0f7f9423 100644 --- a/zh-cn/application-dev/ui/ts-framework-js-tag.md +++ b/zh-cn/application-dev/ui/ts-framework-js-tag.md @@ -3,19 +3,19 @@ å¼€å‘框架需è¦åº”用的config.jsonä¸é…置相关的jsæ ‡ç¾ï¼Œå…¶ä¸åŒ…å«äº†å®žä¾‹å称ã€é¡µé¢è·¯ç”±ã€è§†å›¾çª—å£é…置信æ¯ã€‚ -| æ ‡ç¾ | 类型 | 默认值 | å¿…å¡« | æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| name | string | default | 是 | æ ‡è¯†ETS实例的åå—。 | -| pages | Array | - | 是 | 页é¢è·¯ç”±ä¿¡æ¯ï¼Œè¯¦è§[pages](#pages)说明。 | -| window | Object | - | å¦ | 视图窗å£é…置信æ¯ï¼Œè¯¦è§[window](#window)说明。 | -| mode | Object | - | å¦ | é…ç½®Js Componentè¿è¡Œç±»åž‹ä¸Žè¯æ³•é£Žæ ¼ï¼Œè¯¦è§[mode](#mode)说明。 | +| æ ‡ç¾ | 类型 | 默认值 | å¿…å¡« | æè¿° | +| ------ | ------ | ------- | ---- | ---------------------------------------- | +| name | string | default | 是 | æ ‡è¯†ETS实例的åå—。 | +| pages | Array | - | 是 | 页é¢è·¯ç”±ä¿¡æ¯ï¼Œè¯¦è§[pages](#pages)说明。 | +| window | Object | - | å¦ | 视图窗å£é…置信æ¯ï¼Œè¯¦è§[window](#window)说明。 | +| mode | Object | - | å¦ | é…ç½®Js Componentè¿è¡Œç±»åž‹ä¸Žè¯æ³•é£Žæ ¼ï¼Œè¯¦è§[mode](#mode)说明。 | ## pages 定义æ¯ä¸ªé¡µé¢å…¥å£ç»„件的路由信æ¯ï¼Œæ¯ä¸ªé¡µé¢ç”±é¡µé¢è·¯å¾„和页é¢å组æˆï¼Œé¡µé¢çš„文件å就是页é¢å。比如: -``` +```json { "pages": [ "pages/index", @@ -24,11 +24,11 @@ } ``` ->  **说明:** +> **说明:** > - pages列表ä¸ç¬¬ä¸€ä¸ªé¡µé¢ä¸ºåº”用的首页入å£ã€‚ -> +> > - 页é¢æ–‡ä»¶åä¸èƒ½ä½¿ç”¨ç»„件å称,比如:Text.etsã€Button.etsç‰ã€‚ -> +> > - æ¯ä¸ªé¡µé¢æ–‡ä»¶ä¸å¿…须包å«[页é¢å…¥å£ç»„件](../ui/ts-component-based-entry.md)(\@Entry装饰)。 @@ -36,11 +36,11 @@ window用于é…置相关视图显示窗å£ï¼Œæ”¯æŒé…置如下属性: -| 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -| designWidth | - | é…置视图显示的逻辑宽度,缺çœé»˜è®¤720(智能穿戴默认454)。视图显示的逻辑宽度决定了lpxåƒç´ å•ä½å¤§å°ï¼Œå¦‚designWidthé…ç½®720时,在视图宽度为1440物ç†åƒç´ 时,1lpx为2物ç†åƒç´ 。详è§[lpxåƒç´ å•ä½](../ui/ts-pixel-units.md)说明。 | +| 类型 | 默认值 | 说明 | +| ----------- | ---- | ---------------------------------------- | +| designWidth | - | é…置视图显示的逻辑宽度,缺çœé»˜è®¤720(智能穿戴默认454)。视图显示的逻辑宽度决定了lpxåƒç´ å•ä½å¤§å°ï¼Œå¦‚designWidthé…ç½®720时,在视图宽度为1440物ç†åƒç´ 时,1lpx为2物ç†åƒç´ 。详è§[lpxåƒç´ å•ä½](../ui/ts-pixel-units.md)说明。 | -``` +```json { ... "window": { @@ -55,12 +55,12 @@ window用于é…置相关视图显示窗å£ï¼Œæ”¯æŒé…置如下属性: mode用于é…ç½®JS Componentçš„è¿è¡Œç±»åž‹ä¸Žè¯æ³•é£Žæ ¼ï¼Œæ”¯æŒå¦‚下属性: -| 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -| type | - | é…置该JS Componentçš„è¿è¡Œç±»åž‹ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- pageAbility:以abilityçš„æ–¹å¼è¿è¡Œè¯¥JS Component。<br/>- form:以å¡ç‰‡çš„æ–¹å¼è¿è¡Œè¯¥JS Component。 | -| syntax | - | é…置该JS Componentçš„è¯æ³•é£Žæ ¼ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- hml:以hml/css/jsé£Žæ ¼è¿›è¡Œç¼–å†™ã€‚<br/>- ets:以声明å¼è¯æ³•é£Žæ ¼è¿›è¡Œç¼–写。 | +| 类型 | 默认值 | 说明 | +| ------ | ---- | ---------------------------------------- | +| type | - | é…置该JS Componentçš„è¿è¡Œç±»åž‹ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- pageAbility:以abilityçš„æ–¹å¼è¿è¡Œè¯¥JS Component。<br/>- form:以å¡ç‰‡çš„æ–¹å¼è¿è¡Œè¯¥JS Component。 | +| syntax | - | é…置该JS Componentçš„è¯æ³•é£Žæ ¼ï¼Œå¯é€‰å€¼ä¸ºï¼š<br/>- hml:以hml/css/jsé£Žæ ¼è¿›è¡Œç¼–å†™ã€‚<br/>- ets:以声明å¼è¯æ³•é£Žæ ¼è¿›è¡Œç¼–写。 | ->  **说明:** +> **说明:** > ä¸æ”¯æŒåŒæ—¶é…ç½®type类型为form,syntax类型为ets。 @@ -68,7 +68,7 @@ mode用于é…ç½®JS Componentçš„è¿è¡Œç±»åž‹ä¸Žè¯æ³•é£Žæ ¼ï¼Œæ”¯æŒå¦‚下属性 config.json: -``` +```json { "app": { "bundleName": "com.example.player", diff --git a/zh-cn/application-dev/ui/ts-function-build.md b/zh-cn/application-dev/ui/ts-function-build.md index 240d262cddc48ade5dcea88a66de7bb284e9b2db..82d6b93c4f563e013c6d3c9b8930d4d4dca34334 100644 --- a/zh-cn/application-dev/ui/ts-function-build.md +++ b/zh-cn/application-dev/ui/ts-function-build.md @@ -3,12 +3,12 @@ build函数满足Builderæž„é€ å™¨æŽ¥å£å®šä¹‰ï¼Œç”¨äºŽå®šä¹‰ç»„件的声明å¼UIæ述。必须éµå¾ªä¸Šè¿°Builder接å£çº¦æŸï¼Œåœ¨build方法ä¸ä»¥å£°æ˜Žå¼æ–¹å¼è¿›è¡Œç»„åˆè‡ªå®šä¹‰ç»„件或系统内置组件,在组件创建和更新场景ä¸éƒ½ä¼šè°ƒç”¨build方法。 -``` +```ts interface Builder { build: () => void } ``` ->  **说明:** +> **说明:** > build方法仅支æŒç»„åˆç»„件,使用渲染控制è¯æ³•ã€‚ diff --git a/zh-cn/application-dev/ui/ts-general-ui-concepts.md b/zh-cn/application-dev/ui/ts-general-ui-concepts.md index 3b56f1795a766404c5edf60a7822158e29ba80ce..d155cd948d690b9d9fee99f50c0e1d15af18bb46 100644 --- a/zh-cn/application-dev/ui/ts-general-ui-concepts.md +++ b/zh-cn/application-dev/ui/ts-general-ui-concepts.md @@ -5,8 +5,9 @@ ## HelloWorld基本示例 -``` +```ts // An example of displaying Hello World. After you click the button, Hello UI is displayed. +// xxx.ets @Entry @Component struct Hello { diff --git a/zh-cn/application-dev/ui/ts-media-resource-type.md b/zh-cn/application-dev/ui/ts-media-resource-type.md deleted file mode 100644 index 10be60e4aff925fe9be48b23f3d02a613052fa2b..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-media-resource-type.md +++ /dev/null @@ -1,23 +0,0 @@ -# 媒体资æºç±»åž‹è¯´æ˜Ž - - - -- 图片资æºç±»åž‹è¯´æ˜Ž - | æ ¼å¼ | 文件åŽç¼€å | - | -------- | -------- | - | JPEG | .jpg | - | PNG | .png | - | GIF | .gif | - | SVG | .svg | - | WEBP | .webp | - | BMP | .bmp | - -- 音视频资æºç±»åž‹è¯´æ˜Ž - | æ ¼å¼ | 支æŒçš„文件类型 | - | -------- | -------- | - | H.263 | .3gp <br>.mp4 | - | H.264 AVC <br> Baseline Profile (BP) | .3gp <br>.mp4 | - | MPEG-4 SP | .3gp | - | VP8 | .webm <br> .mkv | - - diff --git a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md b/zh-cn/application-dev/ui/ts-other-states-consume-provide.md index 3166aba4f90567802fba7c869b2c0be25d15e94d..020490d649adba95d3dfe17fc0693d9c356e17e5 100644 --- a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md +++ b/zh-cn/application-dev/ui/ts-other-states-consume-provide.md @@ -4,28 +4,29 @@ Provide作为数æ®çš„æ供方,å¯ä»¥æ›´æ–°å…¶åå™èŠ‚点的数æ®ï¼Œå¹¶è§¦ 表1 @Provide -| å称 | 说明 | -| -------- | -------- | -| 装饰器å‚æ•° | 是一个string类型的常é‡ï¼Œç”¨äºŽç»™è£…饰的å˜é‡èµ·åˆ«å。如果规定别å,则æ供对应别åçš„æ•°æ®æ›´æ–°ã€‚如果没有,则使用å˜é‡å作为别å。推è使用@Provide("alias")è¿™ç§å½¢å¼ã€‚ | -| åŒæ¥æœºåˆ¶ | @Provideçš„å˜é‡ç±»ä¼¼@state,å¯ä»¥ä¿®æ”¹å¯¹åº”å˜é‡è¿›è¡Œé¡µé¢é‡æ–°æ¸²æŸ“。也å¯ä»¥ä¿®æ”¹@Consume装饰的å˜é‡ï¼Œåå‘修改@Stateå˜é‡ã€‚ | -| åˆå§‹å€¼ | 必须制定åˆå§‹å€¼ã€‚ | +| å称 | 说明 | +| ------- | ---------------------------------------- | +| 装饰器å‚æ•° | 是一个string类型的常é‡ï¼Œç”¨äºŽç»™è£…饰的å˜é‡èµ·åˆ«å。如果规定别å,则æ供对应别åçš„æ•°æ®æ›´æ–°ã€‚如果没有,则使用å˜é‡å作为别å。推è使用@Provide("alias")è¿™ç§å½¢å¼ã€‚ | +| åŒæ¥æœºåˆ¶ | @Provideçš„å˜é‡ç±»ä¼¼@state,å¯ä»¥ä¿®æ”¹å¯¹åº”å˜é‡è¿›è¡Œé¡µé¢é‡æ–°æ¸²æŸ“。也å¯ä»¥ä¿®æ”¹@Consume装饰的å˜é‡ï¼Œåå‘修改@Stateå˜é‡ã€‚ | +| åˆå§‹å€¼ | 必须制定åˆå§‹å€¼ã€‚ | | 页é¢é‡æ¸²æŸ“场景 | 触å‘页é¢æ¸²æŸ“的修改:<br/>- 基础类型(boolean,string,number)å˜é‡çš„改å˜ï¼›<br/>- @Observed class类型å˜é‡åŠå…¶å±žæ€§çš„修改;<br/>- æ·»åŠ ï¼Œåˆ é™¤ï¼Œæ›´æ–°æ•°ç»„ä¸çš„å…ƒç´ ã€‚ | 表2 @Consume -| 类型 | 说明 | -| -------- | -------- | -| åˆå§‹å€¼ | ä¸å¯è®¾ç½®é»˜è®¤å€¼ã€‚ | +| 类型 | 说明 | +| ---- | -------- | +| åˆå§‹å€¼ | ä¸å¯è®¾ç½®é»˜è®¤å€¼ã€‚ | ->  **说明:** +> **说明:** > 使用@Provide å’Œ@Consumeæ—¶é¿å…循环引用导致æ»å¾ªçŽ¯ã€‚ 其他属性说明与Provide一致。 -``` +```ts +// xxx.ets @Entry @Component struct CompA { diff --git a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md b/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md index ab86d632486c287664da6a25e227fb5b383e31c5..7a76f0d0c4fa4a308610b992697f2c8b71f4b368 100644 --- a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md +++ b/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md @@ -120,7 +120,7 @@ struct ViewB { ### 案例2 ```ts -//父组件ViewBä¸çš„类对象ClassA与å组件ViewAä¿æŒæ•°æ®åŒæ¥æ—¶ï¼Œå¯ä»¥ä½¿ç”¨@ObjectLinkå’Œ@Observed,绑定该数æ®å¯¹è±¡çš„父组件和其他å组件åŒæ¥æ›´æ–° +// 父组件ViewBä¸çš„类对象ClassA与å组件ViewAä¿æŒæ•°æ®åŒæ¥æ—¶ï¼Œå¯ä»¥ä½¿ç”¨@ObjectLinkå’Œ@Observed,绑定该数æ®å¯¹è±¡çš„父组件和其他å组件åŒæ¥æ›´æ–° var nextID: number = 0; @Observed class ClassA { diff --git a/zh-cn/application-dev/ui/ts-other-states-watch.md b/zh-cn/application-dev/ui/ts-other-states-watch.md index 40c9dd2d5047db2e43be2f6d0b6ae130cb42317b..b1a6feb21e920d193d44e5a8b06f8fe79bd20e4a 100644 --- a/zh-cn/application-dev/ui/ts-other-states-watch.md +++ b/zh-cn/application-dev/ui/ts-other-states-watch.md @@ -3,7 +3,7 @@ @Watch用于监å¬çŠ¶æ€å˜é‡çš„å˜åŒ–,è¯æ³•ç»“构为: -``` +```ts @State @Watch("onChanged") count : number = 0 ``` @@ -14,7 +14,8 @@ 装饰器@Stateã€@Propã€@Linkã€@ObjectLinkã€@Provideã€@Consumeã€@StorageProp以åŠ@StorageLink装饰的å˜é‡å¯ä»¥ç›‘å¬å…¶å˜åŒ–。 -``` +```ts +// xxx.ets @Entry @Component struct CompA { diff --git a/zh-cn/application-dev/ui/ts-parameterless-configuration.md b/zh-cn/application-dev/ui/ts-parameterless-configuration.md index 51a176b90867e515db529c44084c17d756ba71b2..b328a96662d96cced6ec5d664aede1f3e2bdc355 100644 --- a/zh-cn/application-dev/ui/ts-parameterless-configuration.md +++ b/zh-cn/application-dev/ui/ts-parameterless-configuration.md @@ -4,7 +4,7 @@ 组件的接å£å®šä¹‰ä¸åŒ…å«å¿…é€‰æž„é€ å‚数,组件åŽé¢çš„“()â€ä¸ä¸éœ€è¦é…置任何内容。例如,Divider组件ä¸åŒ…å«æž„é€ å‚数: -``` +```ts Column() { Text('item 1') Divider() // No parameter configuration of the divider component diff --git a/zh-cn/application-dev/ui/ts-pixel-units.md b/zh-cn/application-dev/ui/ts-pixel-units.md index 0265bac90e606c4154c19cb85375e0c062ed009e..eda7b03168d427675641436eeeef4cf75fed7de2 100644 --- a/zh-cn/application-dev/ui/ts-pixel-units.md +++ b/zh-cn/application-dev/ui/ts-pixel-units.md @@ -3,31 +3,32 @@ 为开å‘者æä¾›4ç§åƒç´ å•ä½ï¼Œæ¡†æž¶é‡‡ç”¨vp为基准数æ®å•ä½ã€‚ -| å称 | æè¿° | -| -------- | -------- | -| px | å±å¹•ç‰©ç†åƒç´ å•ä½ã€‚ | -| vp | å±å¹•å¯†åº¦ç›¸å…³åƒç´ ï¼Œæ ¹æ®å±å¹•åƒç´ 密度转æ¢ä¸ºå±å¹•ç‰©ç†åƒç´ 。 | -| fp | å—体åƒç´ ,与vp类似适用å±å¹•å¯†åº¦å˜åŒ–,éšç³»ç»Ÿå—体大å°è®¾ç½®å˜åŒ–。 | -| lpx | 视窗逻辑åƒç´ å•ä½ï¼Œlpxå•ä½ä¸ºå®žé™…å±å¹•å®½åº¦ä¸Žé€»è¾‘宽度(通过[designWidth](../ui/ts-framework-js-tag.md)é…置)的比值。如é…ç½®designWidth为720时,在实际宽度为1440物ç†åƒç´ çš„å±å¹•ä¸Šï¼Œ1lpx为2px大å°ã€‚ | +| å称 | æè¿° | +| ---- | ---------------------------------------- | +| px | å±å¹•ç‰©ç†åƒç´ å•ä½ã€‚ | +| vp | å±å¹•å¯†åº¦ç›¸å…³åƒç´ ï¼Œæ ¹æ®å±å¹•åƒç´ 密度转æ¢ä¸ºå±å¹•ç‰©ç†åƒç´ 。 | +| fp | å—体åƒç´ ,与vp类似适用å±å¹•å¯†åº¦å˜åŒ–,éšç³»ç»Ÿå—体大å°è®¾ç½®å˜åŒ–。 | +| lpx | 视窗逻辑åƒç´ å•ä½ï¼Œlpxå•ä½ä¸ºå®žé™…å±å¹•å®½åº¦ä¸Žé€»è¾‘宽度(通过[designWidth](../ui/ts-framework-js-tag.md)é…置)的比值。如é…ç½®designWidth为720时,在实际宽度为1440物ç†åƒç´ çš„å±å¹•ä¸Šï¼Œ1lpx为2px大å°ã€‚ | ## åƒç´ å•ä½è½¬æ¢ æ供其他å•ä½ä¸Žpxå•ä½äº’相转æ¢çš„方法。 -| æŽ¥å£ | æè¿° | -| -------- | -------- | -| vp2px(value : number) : number | å°†vpå•ä½çš„数值转æ¢ä¸ºä»¥px为å•ä½çš„数值。 | -| px2vp(value : number) : number | å°†pxå•ä½çš„数值转æ¢ä¸ºä»¥vp为å•ä½çš„数值。 | -| fp2px(value : number) : number | å°†fpå•ä½çš„数值转æ¢ä¸ºä»¥px为å•ä½çš„数值。 | -| px2fp(value : number) : number | å°†pxå•ä½çš„数值转æ¢ä¸ºä»¥fp为å•ä½çš„数值。 | +| æŽ¥å£ | æè¿° | +| ---------------------------------------- | ---------------------- | +| vp2px(value : number) : number | å°†vpå•ä½çš„数值转æ¢ä¸ºä»¥px为å•ä½çš„数值。 | +| px2vp(value : number) : number | å°†pxå•ä½çš„数值转æ¢ä¸ºä»¥vp为å•ä½çš„数值。 | +| fp2px(value : number) : number | å°†fpå•ä½çš„数值转æ¢ä¸ºä»¥px为å•ä½çš„数值。 | +| px2fp(value : number) : number | å°†pxå•ä½çš„数值转æ¢ä¸ºä»¥fp为å•ä½çš„数值。 | | lpx2px(value : number) : number | å°†lpxå•ä½çš„数值转æ¢ä¸ºä»¥px为å•ä½çš„数值。 | | px2lpx(value : number) : number | å°†pxå•ä½çš„数值转æ¢ä¸ºä»¥lpx为å•ä½çš„数值。 | ## 示例 -``` +```ts +// xxx.ets @Entry @Component struct Example { @@ -71,3 +72,10 @@ struct Example { ```  + + +## 相关实例 + +基于åƒç´ 转æ¢ï¼Œæœ‰ä»¥ä¸‹ç›¸å…³å®žä¾‹å¯ä¾›å‚考: + +- [åƒç´ 转æ¢ï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/PixelUnitsDemo) diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md index a4f390c0b09714c13a1ad5bd109df8c6a298aeef..9ee7f145cefcf6e026edbeb881bd076f75e5aa0b 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md @@ -1,9 +1,9 @@ # 循环渲染 -å¼€å‘框架æ供循环渲染(ForEach组件)æ¥è¿ä»£æ•°ç»„,并为æ¯ä¸ªæ•°ç»„项创建相应的组件。ForEach定义如下: +å¼€å‘框架æ供循环渲染(ForEach组件)æ¥è¿ä»£æ•°ç»„,并为æ¯ä¸ªæ•°ç»„é¡¹åˆ›å»ºç›¸åº”çš„ç»„ä»¶ã€‚å½“å¾ªçŽ¯æ¸²æŸ“çš„å…ƒç´ è¾ƒå¤šæ—¶ï¼Œä¼šå‡ºçŽ°é¡µé¢åŠ è½½å˜æ…¢çš„情况,出于性能考虑,建议使用[LazyForEach](ts-rending-control-syntax-lazyforeach.md)代替。ForEach定义如下: -``` +```ts ForEach( arr: any[], // Array to be iterated itemGenerator: (item: any, index?: number) => void, // child component generator @@ -20,26 +20,26 @@ ForEach(arr: any[],itemGenerator: (item: any, index?: number) => void, keyGen 表1 å‚数说明 -| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| arr | any[] | 是 | - | 必须是数组,å…许空数组,空数组场景下ä¸ä¼šåˆ›å»ºå组件。åŒæ—¶å…许设置返回值为数组类型的函数,例如arr.slice(1, 3),设置的函数ä¸å¾—改å˜åŒ…括数组本身在内的任何状æ€å˜é‡ï¼Œå¦‚Array.spliceã€Array.sort或Array.reverse这些改å˜åŽŸæ•°ç»„的函数。 | -| itemGenerator | (item: any, index?: number) => void | 是 | - | 生æˆå组件的lambda函数,为给定数组项生æˆä¸€ä¸ªæˆ–多个å组件,å•ä¸ªç»„件和å组件列表必须括在大括å·â€œ{....}â€ä¸ã€‚ | -| keyGenerator | (item: any, index?: number) => string | å¦ | - | 匿åå‚数,用于给定数组项生æˆå”¯ä¸€ä¸”稳定的键值。当å项在数组ä¸çš„ä½ç½®æ›´æ”¹æ—¶ï¼Œå项的键值ä¸å¾—更改,当数组ä¸çš„å项被新项替æ¢æ—¶ï¼Œè¢«æ›¿æ¢é¡¹çš„键值和新项的键值必须ä¸åŒã€‚键值生æˆå™¨çš„功能是å¯é€‰çš„,但是,为了使开å‘框架能够更好地识别数组更改,æ高性能,建议æ供。如将数组åå‘时,如果没有æ供键值生æˆå™¨ï¼Œåˆ™ForEachä¸çš„所有节点都将é‡å»ºã€‚ | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- | +| arr | any[] | 是 | - | 必须是数组,å…许空数组,空数组场景下ä¸ä¼šåˆ›å»ºå组件。åŒæ—¶å…许设置返回值为数组类型的函数,例如arr.slice(1, 3),设置的函数ä¸å¾—改å˜åŒ…括数组本身在内的任何状æ€å˜é‡ï¼Œå¦‚Array.spliceã€Array.sort或Array.reverse这些改å˜åŽŸæ•°ç»„的函数。 | +| itemGenerator | (item: any, index?: number) => void | 是 | - | 生æˆå组件的lambda函数,为给定数组项生æˆä¸€ä¸ªæˆ–多个å组件,å•ä¸ªç»„件和å组件列表必须括在大括å·â€œ{....}â€ä¸ã€‚ | +| keyGenerator | (item: any, index?: number) => string | å¦ | - | 匿åå‚数,用于给定数组项生æˆå”¯ä¸€ä¸”稳定的键值。当å项在数组ä¸çš„ä½ç½®æ›´æ”¹æ—¶ï¼Œå项的键值ä¸å¾—更改,当数组ä¸çš„å项被新项替æ¢æ—¶ï¼Œè¢«æ›¿æ¢é¡¹çš„键值和新项的键值必须ä¸åŒã€‚键值生æˆå™¨çš„功能是å¯é€‰çš„,但是,为了使开å‘框架能够更好地识别数组更改,æ高性能,建议æ供。如将数组åå‘时,如果没有æ供键值生æˆå™¨ï¼Œåˆ™ForEachä¸çš„所有节点都将é‡å»ºã€‚ | ->  **说明:** +> **说明:** > - 必须在容器组件内使用; -> +> > - 生æˆçš„å组件å…许在ForEach的父容器组件ä¸ï¼Œå…许å组件生æˆå™¨å‡½æ•°ä¸åŒ…å«if/elseæ¡ä»¶æ¸²æŸ“,åŒæ—¶ä¹Ÿå…许ForEach包å«åœ¨if/elseæ¡ä»¶æ¸²æŸ“è¯å¥ä¸ï¼› -> +> > - å项生æˆå™¨å‡½æ•°çš„调用顺åºä¸ä¸€å®šå’Œæ•°ç»„ä¸çš„æ•°æ®é¡¹ç›¸åŒï¼Œåœ¨å¼€å‘过程ä¸ä¸è¦å‡è®¾å项生æˆå™¨å’Œé”®å€¼ç”Ÿæˆå™¨å‡½æ•°æ˜¯å¦æ‰§è¡Œä»¥åŠæ‰§è¡Œé¡ºåºã€‚如下示例å¯èƒ½æ— 法æ£å¸¸å·¥ä½œï¼š -> ``` +> ```ts > ForEach(anArray, item => {Text(`${++counter}. item.label`)}) > ``` -> +> > æ£ç¡®çš„示例如下: -> -> ``` +> +> ```ts > ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), > item => Text(`${item.i}. item.data.label`), > item => item.data.id.toString()) @@ -50,7 +50,8 @@ ForEach(arr: any[],itemGenerator: (item: any, index?: number) => void, keyGen 简å•ç±»åž‹æ•°ç»„示例: -``` +```ts +// xxx.ets @Entry @Component struct MyComponent { @@ -76,7 +77,8 @@ struct MyComponent { ``` å¤æ‚类型数组示例: -``` +```ts +// xxx.ets class Month { year: number month: number diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md index 8bbe9f8734f6f0d523bb60502fd0fd4efabda4c0..fc496c42b66c5d45e44490b5c8356123f14fafd6 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md @@ -3,13 +3,13 @@ 使用if/else进行æ¡ä»¶æ¸²æŸ“。 ->  **说明:** +> **说明:** > - ifæ¡ä»¶è¯å¥å¯ä»¥ä½¿ç”¨çŠ¶æ€å˜é‡ã€‚ -> +> > - 使用ifå¯ä»¥ä½¿å组件的渲染ä¾èµ–æ¡ä»¶è¯å¥ã€‚ -> +> > - 必须在容器组件内使用。 -> +> > - æŸäº›å®¹å™¨ç»„件é™åˆ¶å组件的类型或数é‡ã€‚å°†if放置在这些组件内时,这些é™åˆ¶å°†åº”用于ifå’Œelseè¯å¥å†…创建的组件。例如,Grid组件的å组件仅支æŒGridItem组件,在Grid组件内使用if时,则ifæ¡ä»¶è¯å¥å†…ä»…å…许使用GridItem组件。 @@ -17,7 +17,7 @@ 使用ifæ¡ä»¶è¯å¥ï¼š -``` +```ts Column() { if (this.count > 0) { Text('count is positive') @@ -29,7 +29,7 @@ Column() { 使用ifã€else ifã€elseæ¡ä»¶è¯å¥ï¼š -``` +```ts Column() { if (this.count < 0) { Text('count is negative') diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md index 1b3604307c78cd28b1c4d14ecb92e39f4b9a7bc5..7c70032decd5629764a49e0998cc12bc6285147a 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md @@ -3,7 +3,7 @@ å¼€å‘框架æ供数æ®æ‡’åŠ è½½ï¼ˆLazyForEach组件)从æ供的数æ®æºä¸æŒ‰éœ€è¿ä»£æ•°æ®ï¼Œå¹¶åœ¨æ¯æ¬¡è¿ä»£è¿‡ç¨‹ä¸åˆ›å»ºç›¸åº”的组件。LazyForEach定义如下: -``` +```ts LazyForEach( dataSource: IDataSource, // Data source to be iterated itemGenerator: (item: any) => void, // child component generator @@ -36,57 +36,57 @@ LazyForEach(dataSource: IDataSource, itemGenerator: (item: any) => void, keyG 表1 å‚数说明 -| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | -------- | -------- | -------- | -------- | -| dataSource | IDataSource | 是 | - | 实现IDataSource接å£çš„对象,需è¦å¼€å‘者实现相关接å£ã€‚ | -| itemGenerator | (item: any) => void | 是 | - | 生æˆå组件的lambda函数,为给定数组项生æˆä¸€ä¸ªæˆ–多个å组件,å•ä¸ªç»„件和å组件列表必须括在大括å·â€œ{....}â€ä¸ã€‚ | -| keyGenerator | (item: any) => string | å¦ | - | 匿å函数,用于键值生æˆï¼Œä¸ºç»™å®šæ•°ç»„项生æˆå”¯ä¸€ä¸”稳定的键值。当å项在数组ä¸çš„ä½ç½®æ›´æ”¹æ—¶ï¼Œå项的键值ä¸å¾—更改,当数组ä¸çš„å项被新项替æ¢æ—¶ï¼Œè¢«æ›¿æ¢é¡¹çš„键值和新项的键值必须ä¸åŒã€‚键值生æˆå™¨çš„功能是å¯é€‰çš„,但是,为了使开å‘框架能够更好地识别数组更改,æ高性能,建议æ供。如将数组åå‘时,如果没有æ供键值生æˆå™¨ï¼Œåˆ™LazyForEachä¸çš„所有节点都将é‡å»ºã€‚ | +| å‚æ•°å | å‚数类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------- | --------------------------------------- | ---- | ---- | ---------------------------------------- | +| dataSource | IDataSource | 是 | - | 实现IDataSource接å£çš„对象,需è¦å¼€å‘者实现相关接å£ã€‚ | +| itemGenerator | (item: any) => void | 是 | - | 生æˆå组件的lambda函数,为给定数组项生æˆä¸€ä¸ªæˆ–多个å组件,å•ä¸ªç»„件和å组件列表必须括在大括å·â€œ{....}â€ä¸ã€‚ | +| keyGenerator | (item: any) => string | å¦ | - | 匿å函数,用于键值生æˆï¼Œä¸ºç»™å®šæ•°ç»„项生æˆå”¯ä¸€ä¸”稳定的键值。当å项在数组ä¸çš„ä½ç½®æ›´æ”¹æ—¶ï¼Œå项的键值ä¸å¾—更改,当数组ä¸çš„å项被新项替æ¢æ—¶ï¼Œè¢«æ›¿æ¢é¡¹çš„键值和新项的键值必须ä¸åŒã€‚键值生æˆå™¨çš„功能是å¯é€‰çš„,但是,为了使开å‘框架能够更好地识别数组更改,æ高性能,建议æ供。如将数组åå‘时,如果没有æ供键值生æˆå™¨ï¼Œåˆ™LazyForEachä¸çš„所有节点都将é‡å»ºã€‚ | 表2 IDataSource类型说明 -| å称 | æè¿° | -| -------- | -------- | -| totalCount(): number | 获å–æ•°æ®æ€»æ•°ã€‚ | -| getData(index: number): any | 获å–索引对应的数æ®ã€‚ | +| å称 | æè¿° | +| ---------------------------------------- | ----------- | +| totalCount(): number | 获å–æ•°æ®æ€»æ•°ã€‚ | +| getData(index: number): any | 获å–索引对应的数æ®ã€‚ | | registerDataChangeListener(listener:DataChangeListener): void | 注册改å˜æ•°æ®çš„控制器。 | | unregisterDataChangeListener(listener:DataChangeListener): void | 注销改å˜æ•°æ®çš„控制器。 | 表3 DataChangeListener类型说明 -| å称 | æè¿° | -| -------- | -------- | -| onDataReloaded(): void | é‡æ–°åŠ 载所有数æ®ã€‚ | -| onDataAdded(index: number): void <sup>(deprecated) </sup>| 通知组件indexçš„ä½ç½®æœ‰æ•°æ®æ·»åŠ 。 | -| onDataMoved(from: number, to: number): void <sup>(deprecated) </sup>| 通知组件数æ®ä»Žfromçš„ä½ç½®ç§»åˆ°toçš„ä½ç½®ã€‚ | -| onDataDeleted(index: number): void <sup>(deprecated) </sup>| 通知组件indexçš„ä½ç½®æœ‰æ•°æ®åˆ 除。 | -| onDataChanged(index: number): void <sup>(deprecated) </sup>| 通知组件indexçš„ä½ç½®æœ‰æ•°æ®å˜åŒ–。 | -| onDataAdd(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®æ·»åŠ 。 | +| å称 | æè¿° | +| ---------------------------------------- | ---------------------- | +| onDataReloaded(): void | é‡æ–°åŠ 载所有数æ®ã€‚ | +| onDataAdded(index: number): void <sup>(deprecated) </sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®æ·»åŠ 。 | +| onDataMoved(from: number, to: number): void <sup>(deprecated) </sup> | 通知组件数æ®ä»Žfromçš„ä½ç½®ç§»åˆ°toçš„ä½ç½®ã€‚ | +| onDataDeleted(index: number): void <sup>(deprecated) </sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®åˆ 除。 | +| onDataChanged(index: number): void <sup>(deprecated) </sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®å˜åŒ–。 | +| onDataAdd(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®æ·»åŠ 。 | | onDataMove(from: number, to: number): void <sup>8+</sup> | 通知组件数æ®ä»Žfromçš„ä½ç½®ç§»åˆ°toçš„ä½ç½®ã€‚ | -| onDataDelete(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®åˆ 除。 | -| onDataChange(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®å˜åŒ–。 | +| onDataDelete(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®åˆ 除。 | +| onDataChange(index: number): void <sup>8+</sup> | 通知组件indexçš„ä½ç½®æœ‰æ•°æ®å˜åŒ–。 | ->  **说明:** +> **说明:** > - æ•°æ®æ‡’åŠ è½½å¿…é¡»åœ¨å®¹å™¨ç»„ä»¶å†…ä½¿ç”¨ï¼Œä¸”ä»…æœ‰Listã€Grid以åŠSwiper组件支æŒæ•°æ®çš„æ‡’åŠ è½½ï¼ˆå³åªåŠ è½½å¯è§†éƒ¨åˆ†ä»¥åŠå…¶å‰åŽå°‘é‡æ•°æ®ç”¨äºŽç¼“冲),其他组件ä»ç„¶æ˜¯ä¸€æ¬¡åŠ 载所有的数æ®ï¼› -> +> > - LazyForEach在æ¯æ¬¡è¿ä»£ä¸ï¼Œå¿…须且åªå…许创建一个å组件; -> +> > - 生æˆçš„å组件必须å…许在LazyForEach的父容器组件ä¸ï¼› -> +> > - å…许LazyForEach包å«åœ¨if/elseæ¡ä»¶æ¸²æŸ“è¯å¥ä¸ï¼Œä¸å…许LazyForEachä¸å‡ºçŽ°if/elseæ¡ä»¶æ¸²æŸ“è¯å¥ï¼› -> +> > - 为了高性能渲染,通过DataChangeListener对象的onDataChange方法æ¥æ›´æ–°UI时,仅itemGeneratorä¸çš„UIæ述的组件内使用了状æ€å˜é‡æ—¶ï¼Œæ‰ä¼šè§¦å‘组件刷新; -> +> > - å项生æˆå™¨å‡½æ•°çš„调用顺åºä¸ä¸€å®šå’Œæ•°æ®æºä¸çš„æ•°æ®é¡¹ç›¸åŒï¼Œåœ¨å¼€å‘过程ä¸ä¸è¦å‡è®¾å项生æˆå™¨å’Œé”®å€¼ç”Ÿæˆå™¨å‡½æ•°æ˜¯å¦æ‰§è¡Œä»¥åŠæ‰§è¡Œé¡ºåºã€‚如下示例å¯èƒ½æ— 法æ£å¸¸å·¥ä½œï¼š -> ``` +> ```ts > LazyForEach(dataSource, item => {Text(`${++counter}. item.label`)}) > ``` -> +> > æ£ç¡®çš„示例如下: -> -> ``` +> +> ```ts > LazyForEach(dataSource, > item => Text(`${item.i}. item.data.label`)), > item => item.data.id.toString()) @@ -95,7 +95,7 @@ LazyForEach(dataSource: IDataSource, itemGenerator: (item: any) => void, keyG ## 示例 -``` +```ts // Basic implementation of IDataSource to handle data listener class BasicDataSource implements IDataSource { private listeners: DataChangeListener[] = [] diff --git a/zh-cn/application-dev/ui/ts-application-resource-access.md b/zh-cn/application-dev/ui/ts-resource-access.md similarity index 57% rename from zh-cn/application-dev/ui/ts-application-resource-access.md rename to zh-cn/application-dev/ui/ts-resource-access.md index d12e3fd86fb38f34f06b9528af1d1cf8bd87676c..7858ba7a8adee799dbf99aede2092ce54b21513a 100644 --- a/zh-cn/application-dev/ui/ts-application-resource-access.md +++ b/zh-cn/application-dev/ui/ts-resource-access.md @@ -1,61 +1,69 @@ -# è®¿é—®åº”ç”¨èµ„æº +# 资æºè®¿é—® -## 资æºå®šä¹‰ +## è®¿é—®åº”ç”¨èµ„æº -应用资æºç”±å¼€å‘者在工程的resources目录ä¸å®šä¹‰ï¼Œresources目录按照两级目录的形å¼æ¥ç»„织: +在工程ä¸ï¼Œé€šè¿‡```"$r('app.type.name')"```çš„å½¢å¼å¼•ç”¨åº”用资æºã€‚app代表是应用内resources目录ä¸å®šä¹‰çš„资æºï¼›type代表资æºç±»åž‹ï¼ˆæˆ–资æºçš„å˜æ”¾ä½ç½®ï¼‰ï¼Œå¯ä»¥å–“colorâ€ã€â€œfloatâ€ã€â€œstringâ€ã€â€œpluralâ€ã€â€œmediaâ€ï¼Œname代表资æºå‘½å,由开å‘者定义资æºæ—¶ç¡®å®šã€‚ -- 一级目录为base目录ã€é™å®šè¯ç›®å½•ä»¥åŠrawfile目录 - - base目录是默认å˜åœ¨çš„目录。当应用的resources资æºç›®å½•ä¸æ²¡æœ‰ä¸Žè®¾å¤‡çŠ¶æ€åŒ¹é…çš„é™å®šè¯ç›®å½•æ—¶ï¼Œä¼šè‡ªåŠ¨å¼•ç”¨è¯¥ç›®å½•ä¸çš„资æºæ–‡ä»¶ã€‚ - - é™å®šè¯ç›®å½•éœ€è¦å¼€å‘者自行创建,其å¯ä»¥ç”±ä¸€ä¸ªæˆ–多个表å¾åº”用场景或设备特å¾çš„é™å®šè¯ç»„åˆè€Œæˆï¼ŒåŒ…括移动国家ç 和移动网络ç ã€è¯è¨€ã€æ–‡å—ã€å›½å®¶æˆ–地区ã€æ¨ªç«–å±ã€è®¾å¤‡ç±»åž‹ã€é¢œè‰²æ¨¡å¼å’Œå±å¹•å¯†åº¦ç‰ç»´åº¦ï¼Œé™å®šè¯ä¹‹é—´é€šè¿‡ä¸‹åˆ’线(_)或者ä¸åˆ’线(-)连接。 - - 在引用rawfileä¸çš„资æºæ—¶ï¼Œä¸ä¼šæ ¹æ®ç³»ç»Ÿçš„状æ€åŽ»åŒ¹é…,rawfile目录ä¸å¯ä»¥ç›´æŽ¥å˜æ”¾èµ„æºæ–‡ä»¶ã€‚ +引用rawfile下资æºæ—¶ä½¿ç”¨```"$rawfile('filename')"```çš„å½¢å¼ï¼Œfilename需è¦è¡¨ç¤ºä¸ºrawfile目录下的文件相对路径,文件å需è¦åŒ…å«åŽç¼€ï¼Œè·¯å¾„开头ä¸å¯ä»¥ä»¥"/"开头。 -- 二级目录为资æºç›®å½• - - 用于å˜æ”¾å—符串ã€é¢œè‰²ã€æµ®ç‚¹æ•°ç‰åŸºç¡€å…ƒç´ ,以åŠåª’体ç‰èµ„æºæ–‡ä»¶ã€‚ - - 当å‰æ”¯æŒçš„文件和资æºç±»åž‹å¦‚下: - | 文件å | 资æºç±»åž‹ | - | -------- | -------- | - | color.json | 颜色资æºã€‚ | - | float.json | é—´è·ã€åœ†è§’ã€å—体ç‰èµ„æºã€‚ | - | string.json | å—符串资æºã€‚ | - | plural.json | å—符串资æºã€‚ | - | media目录 | 图片资æºã€‚ | +> **说明:** +> 资æºæ述符ä¸èƒ½æ‹¼æŽ¥ä½¿ç”¨ï¼Œä»…支æŒæ™®é€šå—符串如`'app.type.name'`。 +在xxx.ets文件ä¸ï¼Œå¯ä»¥ä½¿ç”¨åœ¨resources目录ä¸å®šä¹‰çš„资æºã€‚ -## 资æºå¼•ç”¨ +```ts +Text($r('app.string.string_hello')) + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} -在工程ä¸ï¼Œé€šè¿‡```"$r('app.type.name')"```çš„å½¢å¼å¼•ç”¨åº”用资æºã€‚app代表是应用内resources目录ä¸å®šä¹‰çš„资æºï¼›type代表资æºç±»åž‹ï¼ˆæˆ–资æºçš„å˜æ”¾ä½ç½®ï¼‰ï¼Œå¯ä»¥å–“colorâ€ã€â€œfloatâ€ã€â€œstringâ€ã€â€œpluralâ€ã€â€œmediaâ€ï¼Œname代表资æºå‘½å,由开å‘者定义资æºæ—¶ç¡®å®šã€‚ +Text($r('app.string.string_world')) + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Text($r('app.string.message_arrive', "five of the clock")) // 引用string资æºï¼Œ$r的第二个å‚数用于替æ¢%s + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} -引用rawfile下资æºæ—¶ä½¿ç”¨```"$rawfile('filename')"```çš„å½¢å¼ï¼Œå½“å‰$rawfile仅支æŒImage控件引用图片资æºï¼Œfilename需è¦è¡¨ç¤ºä¸ºrawfile目录下的文件相对路径,文件å需è¦åŒ…å«åŽç¼€ï¼Œè·¯å¾„开头ä¸å¯ä»¥ä»¥"/"开头。 +Text($r('app.plural.eat_apple', 5, 5)) // plural$r引用,第一个指定plural资æºï¼Œç¬¬äºŒä¸ªå‚数指定å•å¤æ•°çš„æ•°é‡ï¼Œæ¤å¤„第三个数å—为对%dçš„æ›¿æ¢ + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} ->  **说明:** -> 资æºæ述符ä¸èƒ½æ‹¼æŽ¥ä½¿ç”¨ï¼Œä»…支æŒæ™®é€šå—符串如`'app.type.name'`。 +Image($r('app.media.my_background_image')) // media资æºçš„$r引用 +Image($rawfile('test.png')) // rawfile$r引用rawfile目录下图片 -## 示例 +Image($rawfile('newDir/newTest.png')) // rawfile$r引用rawfile目录下图片 +``` +## è®¿é—®ç³»ç»Ÿèµ„æº -base目录ä¸éƒ¨åˆ†è‡ªå®šä¹‰èµ„æºå¦‚下所示: +系统资æºåŒ…å«è‰²å½©ã€åœ†è§’ã€å—体ã€é—´è·ã€å—符串åŠå›¾ç‰‡ç‰ã€‚通过使用系统资æºï¼Œä¸åŒçš„å¼€å‘者å¯ä»¥å¼€å‘出具有相åŒè§†è§‰é£Žæ ¼çš„应用。 +å¼€å‘者å¯ä»¥é€šè¿‡```“$r('sys.type.resource_id')â€```çš„å½¢å¼å¼•ç”¨ç³»ç»Ÿèµ„æºã€‚sys代表是系统资æºï¼›type代表资æºç±»åž‹ï¼Œå¯ä»¥å–“colorâ€ã€â€œfloatâ€ã€â€œstringâ€ã€â€œmediaâ€ï¼›resource_id代表资æºid。 + +```ts +Text('Hello') + .fontColor($r('sys.color.ohos_id_color_emphasize')) + .fontSize($r('sys.float.ohos_id_text_size_headline1')) + .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) + .backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) +Image($r('sys.media.ohos_app_icon')) + .border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) + .margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) + .height(200) + .width(300) ``` - resources - ├─ base - │ ├─ element - │ │ ├─ color.json - │ │ ├─ string.json - │ │ └─ float.json - │ └─ media - │ └─ my_background_image.png - └─ rawfile - ├─ test.png - └─ newDir - └─ newTest.png -``` +## 资æºæ–‡ä»¶ç¤ºä¾‹ color.json文件的内容如下: -``` +```json { "color": [ { @@ -73,7 +81,7 @@ color.json文件的内容如下: float.json文件的内容如下: -``` +```json { "float":[ { @@ -91,7 +99,7 @@ float.json文件的内容如下: string.json文件的内容如下: -``` +```json { "string":[ { @@ -113,7 +121,7 @@ string.json文件的内容如下: plural.json文件的内容如下: -``` +```json { "plural":[ { @@ -133,35 +141,7 @@ plural.json文件的内容如下: } ``` - 在ets文件ä¸ï¼Œå¯ä»¥ä½¿ç”¨åœ¨resources目录ä¸å®šä¹‰çš„资æºã€‚ - -``` -Text($r('app.string.string_hello')) - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.string.string_world')) - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Text($r('app.string.message_arrive', "five of the clock")) // 引用string资æºï¼Œ$r的第二个å‚数用于替æ¢%s - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.plural.eat_apple', 5, 5)) // plural$r引用,第一个指定plural资æºï¼Œç¬¬äºŒä¸ªå‚数指定å•å¤æ•°çš„æ•°é‡ï¼Œæ¤å¤„第三个数å—为对%dçš„æ›¿æ¢ - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Image($r('app.media.my_background_image')) // media资æºçš„$r引用 - -Image($rawfile('test.png')) // rawfile$r引用rawfile目录下图片 - -Image($rawfile('newDir/newTest.png')) // rawfile$r引用rawfile目录下图片 -``` + ## 相关实例 diff --git a/zh-cn/application-dev/ui/ts-syntactic-sugar.md b/zh-cn/application-dev/ui/ts-syntactic-sugar.md index bc36b2e26aea9dcc3fd45850a628a80d81940535..5b824e089fdeec1e38552e7737abff9d9d7b954c 100644 --- a/zh-cn/application-dev/ui/ts-syntactic-sugar.md +++ b/zh-cn/application-dev/ui/ts-syntactic-sugar.md @@ -9,7 +9,7 @@ 如下示例为@Componentå’Œ@State的使用,被 @Componentè£…é¥°çš„å…ƒç´ å…·å¤‡äº†ç»„ä»¶åŒ–çš„å«ä¹‰ï¼Œä½¿ç”¨@State装饰的å˜é‡å…·å¤‡äº†çŠ¶æ€æ•°æ®çš„å«ä¹‰ã€‚ -``` +```ts @Component struct MyComponent { @State count: number = 0 @@ -20,7 +20,7 @@ struct MyComponent { 装饰器定义在åŒä¸€è¡Œä¸Šçš„æ述如下: -``` +```ts @Entry @Component struct MyComponent { } ``` @@ -29,7 +29,7 @@ struct MyComponent { 但更推è定义在多行上: -``` +```ts @Entry @Component struct MyComponent { @@ -39,29 +39,29 @@ struct MyComponent { ### 支æŒçš„装饰器列表 -| 装饰器 | 装饰内容 | 说明 | -| -------- | -------- | -------- | -| @Component | struct | 结构体在装饰åŽå…·æœ‰åŸºäºŽç»„件的能力,需è¦å®žçŽ°build方法æ¥æ›´æ–°UI。 | -| @Entry | struct | 组件被装饰åŽä½œä¸ºé¡µé¢çš„å…¥å£ï¼Œé¡µé¢åŠ 载时将被渲染显示。 | -| @Preview | struct | 用@Preview装饰的自定义组件å¯ä»¥åœ¨DevEco Studioçš„é¢„è§ˆå™¨ä¸Šè¿›è¡Œé¢„è§ˆï¼ŒåŠ è½½é¡µé¢æ—¶ï¼Œå°†åˆ›å»ºå¹¶å‘ˆçŽ°@Preview装饰的自定义组件。 | -| @Builder | 方法 | 在@Builder装饰的方法用通过声明å¼UIæ述,å¯ä»¥åœ¨ä¸€ä¸ªè‡ªå®šä¹‰ç»„件内快速生æˆå¤šä¸ªå¸ƒå±€å†…容。 | -| @Extend | 方法 | @Extendè£…é¥°å™¨å°†æ–°çš„å±žæ€§å‡½æ•°æ·»åŠ åˆ°å†…ç½®ç»„ä»¶ä¸Šï¼Œé€šè¿‡@Extend装饰器å¯ä»¥å¿«é€Ÿå®šä¹‰å¹¶å¤ç”¨ç»„ä»¶çš„è‡ªå®šä¹‰æ ·å¼ã€‚ | -| @CustomDialog | struct | @CustomDialog装饰器用于装饰自定义弹窗。 | -| @State | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | 修饰的状æ€æ•°æ®è¢«ä¿®æ”¹æ—¶ä¼šè§¦å‘组件的build方法进行UIç•Œé¢æ›´æ–°ã€‚ | -| @Prop | 基本数æ®ç±»åž‹ | 修改åŽçš„状æ€æ•°æ®ç”¨äºŽåœ¨çˆ¶ç»„件和å组件之间建立å•å‘æ•°æ®ä¾èµ–关系。修改父组件关è”æ•°æ®æ—¶ï¼Œæ›´æ–°å½“å‰ç»„件的UI。 | -| @Link | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | 父å组件之间的åŒå‘æ•°æ®ç»‘定,父组件的内部状æ€æ•°æ®ä½œä¸ºæ•°æ®æºï¼Œä»»ä½•ä¸€æ–¹æ‰€åšçš„修改都会åæ˜ ç»™å¦ä¸€æ–¹ã€‚ | -| @Observed | ç±» | @Observed应用于类,表示该类ä¸çš„æ•°æ®å˜æ›´è¢«UI页é¢ç®¡ç†ã€‚ | -| @ObjectLink | 被@Observed所装饰类的对象 | 装饰的状æ€æ•°æ®è¢«ä¿®æ”¹æ—¶ï¼Œåœ¨çˆ¶ç»„件或者其他兄弟组件内与它关è”的状æ€æ•°æ®æ‰€åœ¨çš„组件都会更新UI。 | -| @Consume | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | @Consume装饰的å˜é‡åœ¨æ„ŸçŸ¥åˆ°@Provide装饰的å˜é‡æ›´æ–°åŽï¼Œä¼šè§¦å‘当å‰è‡ªå®šä¹‰ç»„件的é‡æ–°æ¸²æŸ“。 | -| @Provide | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | @Provide作为数æ®çš„æ供方,å¯ä»¥æ›´æ–°å…¶åå™èŠ‚点的数æ®ï¼Œå¹¶è§¦å‘页é¢æ¸²æŸ“。 | -| @Watch | 被@State, @Prop, @Link, @ObjectLink, <br>@Provide, @Consume, @StorageProp, @StorageLinkä¸ä»»æ„一个装饰的å˜é‡ | @Watch用于监å¬çŠ¶æ€å˜é‡çš„å˜åŒ–,应用å¯ä»¥æ³¨å†Œå›žè°ƒæ–¹æ³•ã€‚ | +| 装饰器 | 装饰内容 | 说明 | +| ------------- | ---------------------------------------- | ---------------------------------------- | +| @Component | struct | 结构体在装饰åŽå…·æœ‰åŸºäºŽç»„件的能力,需è¦å®žçŽ°build方法æ¥æ›´æ–°UI。 | +| @Entry | struct | 组件被装饰åŽä½œä¸ºé¡µé¢çš„å…¥å£ï¼Œé¡µé¢åŠ 载时将被渲染显示。 | +| @Preview | struct | 用@Preview装饰的自定义组件å¯ä»¥åœ¨DevEco Studioçš„é¢„è§ˆå™¨ä¸Šè¿›è¡Œé¢„è§ˆï¼ŒåŠ è½½é¡µé¢æ—¶ï¼Œå°†åˆ›å»ºå¹¶å‘ˆçŽ°@Preview装饰的自定义组件。 | +| @Builder | 方法 | 在@Builder装饰的方法里,通过声明å¼UIæ述,å¯ä»¥åœ¨ä¸€ä¸ªè‡ªå®šä¹‰ç»„件内快速生æˆå¤šä¸ªå¸ƒå±€å†…容。 | +| @Extend | 方法 | @Extendè£…é¥°å™¨å°†æ–°çš„å±žæ€§å‡½æ•°æ·»åŠ åˆ°å†…ç½®ç»„ä»¶ä¸Šï¼Œé€šè¿‡@Extend装饰器å¯ä»¥å¿«é€Ÿå®šä¹‰å¹¶å¤ç”¨ç»„ä»¶çš„è‡ªå®šä¹‰æ ·å¼ã€‚ | +| @CustomDialog | struct | @CustomDialog装饰器用于装饰自定义弹窗。 | +| @State | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | 修饰的状æ€æ•°æ®è¢«ä¿®æ”¹æ—¶ä¼šè§¦å‘组件的build方法进行UIç•Œé¢æ›´æ–°ã€‚ | +| @Prop | 基本数æ®ç±»åž‹ | 修改åŽçš„状æ€æ•°æ®ç”¨äºŽåœ¨çˆ¶ç»„件和å组件之间建立å•å‘æ•°æ®ä¾èµ–关系。修改父组件关è”æ•°æ®æ—¶ï¼Œæ›´æ–°å½“å‰ç»„件的UI。 | +| @Link | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | 父å组件之间的åŒå‘æ•°æ®ç»‘定,父组件的内部状æ€æ•°æ®ä½œä¸ºæ•°æ®æºï¼Œä»»ä½•ä¸€æ–¹æ‰€åšçš„修改都会åæ˜ ç»™å¦ä¸€æ–¹ã€‚ | +| @Observed | ç±» | @Observed应用于类,表示该类ä¸çš„æ•°æ®å˜æ›´è¢«UI页é¢ç®¡ç†ã€‚ | +| @ObjectLink | 被@Observed所装饰类的对象 | 装饰的状æ€æ•°æ®è¢«ä¿®æ”¹æ—¶ï¼Œåœ¨çˆ¶ç»„件或者其他兄弟组件内与它关è”的状æ€æ•°æ®æ‰€åœ¨çš„组件都会更新UI。 | +| @Consume | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | @Consume装饰的å˜é‡åœ¨æ„ŸçŸ¥åˆ°@Provide装饰的å˜é‡æ›´æ–°åŽï¼Œä¼šè§¦å‘当å‰è‡ªå®šä¹‰ç»„件的é‡æ–°æ¸²æŸ“。 | +| @Provide | 基本数æ®ç±»åž‹ï¼Œç±»ï¼Œæ•°ç»„ | @Provide作为数æ®çš„æ供方,å¯ä»¥æ›´æ–°å…¶åå™èŠ‚点的数æ®ï¼Œå¹¶è§¦å‘页é¢æ¸²æŸ“。 | +| @Watch | 被@State, @Prop, @Link, @ObjectLink, <br>@Provide, @Consume, @StorageProp, @StorageLinkä¸ä»»æ„一个装饰的å˜é‡ | @Watch用于监å¬çŠ¶æ€å˜é‡çš„å˜åŒ–,应用å¯ä»¥æ³¨å†Œå›žè°ƒæ–¹æ³•ã€‚ | ## 链å¼è°ƒç”¨ å…许开å‘者以“.â€é“¾å¼è°ƒç”¨çš„æ–¹å¼é…ç½®UI结构åŠå…¶å±žæ€§ã€äº‹ä»¶ç‰ã€‚ -``` +```ts Column() { Image('1.jpg') .alt('error.jpg') @@ -75,7 +75,7 @@ Column() { 组件å¯ä»¥åŸºäºŽstruct实现,组件ä¸èƒ½æœ‰ç»§æ‰¿å…³ç³»ï¼Œstructå¯ä»¥æ¯”classæ›´åŠ å¿«é€Ÿçš„åˆ›å»ºå’Œé”€æ¯ã€‚ -``` +```ts @Component struct MyComponent { @State data: string = '' @@ -90,7 +90,7 @@ struct MyComponent { 对于struct的实例化,å¯ä»¥çœç•¥new。 -``` +```ts // 定义 @Component struct MyComponent { @@ -124,7 +124,7 @@ TSè¯è¨€çš„使用在生æˆå™¨å‡½æ•°ä¸å˜åœ¨ä¸€å®šçš„é™åˆ¶ï¼š éžæ³•ç¤ºä¾‹ï¼š -``` +```ts build() { let a: number = 1 // invalid: variable declaration not allowed Column() { @@ -137,14 +137,15 @@ build() { ``` -## $$ +## å˜é‡åŒå‘绑定 $$支æŒå˜é‡åŒå‘绑定,支æŒç®€å•å˜é‡ã€@Stateã€@Linkã€@Propç‰ç±»åž‹ã€‚ -当å‰$$仅支æŒ[bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md)属性的showå‚æ•°å’Œ@Stateå˜é‡ä¹‹é—´çš„渲染,以åŠRadio组件的checked属性。 +当å‰$$仅支æŒ[bindPopup](../reference/arkui-ts/ts-universal-attributes-popup.md)属性的showå‚æ•°å’Œ@Stateå˜é‡ä¹‹é—´çš„渲染,以åŠRadio组件的checked属性和Refresh组件的refreshingå‚数。 -``` +```ts +// xxx.ets @Entry @Component struct bindPopup { diff --git a/zh-cn/application-dev/ui/ts-syntax-intro.md b/zh-cn/application-dev/ui/ts-syntax-intro.md index cd2e1b5bc67c5fbc4414a926f31658cb055b7102..129f1d5459c04ed6d859ee5cf50088e564e84206 100644 --- a/zh-cn/application-dev/ui/ts-syntax-intro.md +++ b/zh-cn/application-dev/ui/ts-syntax-intro.md @@ -6,7 +6,7 @@ 本节为应用开å‘人员开å‘UIæ供了å‚考规范。有关组件的详细信æ¯ï¼Œè¯·å‚考组件说明。 ->  **说明:** +> **说明:** > - 本节所有示例都以TSè¯è¨€ä¸ºä¾‹ï¼Œè¯·éµå¾ªç›¸åº”è¯è¨€çš„è¯æ³•è¦æ±‚。 > > - 示例ä¸çš„Imageã€Buttonã€Textã€Dividerã€Rowå’ŒColumnç‰ç»„件是UI框架ä¸é¢„置的组件控件,仅用于解释UIæ述规范。 diff --git a/zh-cn/application-dev/ui/ts-system-resource-access.md b/zh-cn/application-dev/ui/ts-system-resource-access.md deleted file mode 100644 index ac9a956742e2238a338653c0360078a4c0161c66..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-system-resource-access.md +++ /dev/null @@ -1,20 +0,0 @@ -# è®¿é—®ç³»ç»Ÿèµ„æº - - -系统资æºåŒ…å«è‰²å½©ã€åœ†è§’ã€å—体ã€é—´è·ã€å—符串åŠå›¾ç‰‡ç‰ã€‚通过使用系统资æºï¼Œä¸åŒçš„å¼€å‘者å¯ä»¥å¼€å‘出具有相åŒè§†è§‰é£Žæ ¼çš„应用。 - - -å¼€å‘者å¯ä»¥é€šè¿‡```“$r('sys.type.resource_id')â€```çš„å½¢å¼å¼•ç”¨ç³»ç»Ÿèµ„æºã€‚sys代表是系统资æºï¼›type代表资æºç±»åž‹ï¼Œå¯ä»¥å–“colorâ€ã€â€œfloatâ€ã€â€œstringâ€ã€â€œmediaâ€ï¼›resource_id代表资æºid。 - -``` -Text('Hello') - .fontColor($r('sys.color.ohos_id_color_emphasize')) - .fontSize($r('sys.float.ohos_id_text_size_headline1')) - .fontFamily($r('sys.string.ohos_id_text_font_family_medium')) - .backgroundColor($r('sys.color.ohos_id_color_palette_aux1')) -Image($r('sys.media.ohos_app_icon')) - .border({color: $r('sys.color.ohos_id_color_palette_aux1'), radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2}) - .margin({top: $r('sys.float.ohos_id_elements_margin_horizontal_m'), bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')}) - .height(200) - .width(300) -``` diff --git a/zh-cn/application-dev/ui/ts-types.md b/zh-cn/application-dev/ui/ts-types.md index 665108d5c1e259ed0d058b646033f927349a1226..7fe41c4e11547cc1fa02f4678f4c907518ba93ca 100644 --- a/zh-cn/application-dev/ui/ts-types.md +++ b/zh-cn/application-dev/ui/ts-types.md @@ -2,65 +2,65 @@ ## 长度类型 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| Length | string \| number | 用于æ述尺寸å•ä½ï¼Œè¾“入为number类型时,使用vpå•ä½ï¼›è¾“入为string类型时,需è¦æ˜¾å¼æŒ‡å®šåƒç´ å•ä½ï¼Œå¦‚'10px',也å¯è®¾ç½®ç™¾åˆ†æ¯”å—符串,如'100%'。 | +| å称 | 类型定义 | æè¿° | +| ------ | -------------------------- | ---------------------------------------- | +| Length | string \| number | 用于æ述尺寸å•ä½ï¼Œè¾“入为number类型时,使用vpå•ä½ï¼›è¾“入为string类型时,需è¦æ˜¾å¼æŒ‡å®šåƒç´ å•ä½ï¼Œå¦‚'10px',也å¯è®¾ç½®ç™¾åˆ†æ¯”å—符串,如'100%'。 | ## 角度类型 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| Angle | string \| number | 用于角度å•ä½ï¼Œè¾“入为number类型时,使用degå•ä½ï¼›è¾“入为string类型时需è¦æ˜¾ç¤ºæŒ‡å®šè§’度å•ä½ï¼Œæ”¯æŒä»¥ä¸‹ä¸¤ç§è§’度å•ä½ï¼š<br/>- deg:如'100deg'。<br/>- rad:如'3.14rad'。 | +| å称 | 类型定义 | æè¿° | +| ----- | -------------------------- | ---------------------------------------- | +| Angle | string \| number | 用于角度å•ä½ï¼Œè¾“入为number类型时,使用degå•ä½ï¼›è¾“入为string类型时需è¦æ˜¾ç¤ºæŒ‡å®šè§’度å•ä½ï¼Œæ”¯æŒä»¥ä¸‹ä¸¤ç§è§’度å•ä½ï¼š<br/>- deg:如'100deg'。<br/>- rad:如'3.14rad'。 | ## 点类型 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| Point | [Length, Length] | 用于æ述点åæ ‡ï¼Œç¬¬ä¸€ä¸ªå€¼ä¸ºxè½´åæ ‡ï¼Œç¬¬äºŒä¸ªå€¼ä¸ºyåæ ‡ã€‚ | +| å称 | 类型定义 | æè¿° | +| ----- | --------------------- | --------------------------- | +| Point | [Length, Length] | 用于æ述点åæ ‡ï¼Œç¬¬ä¸€ä¸ªå€¼ä¸ºxè½´åæ ‡ï¼Œç¬¬äºŒä¸ªå€¼ä¸ºyåæ ‡ã€‚ | ## 颜色类型 组件属性方法使用的颜色Color说明如下: -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| Color | string \| number \| Color | 用于æ述颜色信æ¯ï¼Œè¾“入为string类型时,使用rgb或者rgba进行æ述;输入为number类型是,使用HEXæ ¼å¼é¢œè‰²ï¼›è¾“入类型为Color枚举时,使用颜色枚举值。<br/>- 'rgb(255, 255, 255)'。<br/>- 'rgba(255, 255, 255, 1.0)'。<br/>- HEXæ ¼å¼ï¼š0xrrggbb,0xaarrggbb,'\#FFFFFF'。<br/>- æžšä¸¾æ ¼å¼ï¼šColor.Black,Color.Whiteç‰ã€‚ | +| å称 | 类型定义 | æè¿° | +| ----- | ---------------------------------------- | ---------------------------------------- | +| Color | string \| number \| Color | 用于æ述颜色信æ¯ï¼Œè¾“入为string类型时,使用rgb或者rgba进行æ述;输入为number类型是,使用HEXæ ¼å¼é¢œè‰²ï¼›è¾“入类型为Color枚举时,使用颜色枚举值。<br/>- 'rgb(255, 255, 255)'。<br/>- 'rgba(255, 255, 255, 1.0)'。<br/>- HEXæ ¼å¼ï¼š0xrrggbb,0xaarrggbb,'\#FFFFFF'。<br/>- æžšä¸¾æ ¼å¼ï¼šColor.Black,Color.Whiteç‰ã€‚ | 当å‰æ”¯æŒçš„Color颜色枚举: -| 颜色å称 | 颜色值 | é¢œè‰²ç¤ºæ„ | -| -------- | -------- | -------- | -| Black | 0x000000 |  | -| Blue | 0x0000ff |  | -| Brown | 0xa52a2a |  | -| Gray | 0x808080 |  | -| Green | 0x008000 |  | -| Orange | 0xffa500 |  | -| Pink | 0xffc0cb |  | -| Red | 0xff0000 |  | -| White | 0xffffff |  | -| Yellow | 0xffff00 |  | +| 颜色å称 | 颜色值 | é¢œè‰²ç¤ºæ„ | +| ------ | -------- | ---------------------------------------- | +| Black | 0x000000 |  | +| Blue | 0x0000ff |  | +| Brown | 0xa52a2a |  | +| Gray | 0x808080 |  | +| Green | 0x008000 |  | +| Orange | 0xffa500 |  | +| Pink | 0xffc0cb |  | +| Red | 0xff0000 |  | +| White | 0xffffff |  | +| Yellow | 0xffff00 |  | ## ColorStop类型 颜色æ–点类型,用于æè¿°æ¸è¿›è‰²é¢œè‰²æ–点。 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| ColorStop | [Color, number] | æè¿°æ¸è¿›è‰²é¢œè‰²æ–点类型,第一个å‚数为颜色值,第二个å‚数为0~1之间的比例值。 | +| å称 | 类型定义 | æè¿° | +| --------- | -------------------- | -------------------------------------- | +| ColorStop | [Color, number] | æè¿°æ¸è¿›è‰²é¢œè‰²æ–点类型,第一个å‚数为颜色值,第二个å‚数为0~1之间的比例值。 | ## Resource类型 资æºå¼•ç”¨ç±»åž‹ï¼Œç”¨äºŽè®¾ç½®ç»„件属性的值。 -å¯ä»¥é€šè¿‡`$r`或者`$rawfile`创建Resource类型对象,详è§[资æºè®¿é—®](ts-application-resource-access.md)。 +å¯ä»¥é€šè¿‡`$r`或者`$rawfile`创建Resource类型对象,详è§[资æºè®¿é—®](ts-resource-access.md)。 - `$r('belonging.type.name')` @@ -74,42 +74,43 @@ filename:工程ä¸resources/rawfile目录下的文件å称。 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| Resource | {<br/>readonly id: [number];<br/>readonly type: [number];<br/>readonly params?: any[];<br/>} | - id:资æºid值。<br/>- type:资æºç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰ã€‚<br/>- params:å¯é€‰å‚数。<br/>通过`$r`或者`$rawfile`创建Resource类型对象,ä¸å¯ä»¥ä¿®æ”¹Resourceä¸çš„å„属性的值。 | +| å称 | 类型定义 | æè¿° | +| -------- | ---------------------------------------- | ---------------------------------------- | +| Resource | {<br/>readonly id: [number];<br/>readonly type: [number];<br/>readonly params?: any[];<br/>} | - id:资æºid值。<br/>- type:资æºç±»åž‹ï¼ˆæžšä¸¾å€¼ï¼‰ã€‚<br/>- params:å¯é€‰å‚数。<br/>通过`$r`或者`$rawfile`创建Resource类型对象,ä¸å¯ä»¥ä¿®æ”¹Resourceä¸çš„å„属性的值。 | ## ResourceStr类型<sup>8+</sup> -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| ResourceStr | string \| Resource| 用于æ述资æºå—符串的类型。 | +| å称 | 类型定义 | æè¿° | +| ----------- | ---------------------------- | ------------- | +| ResourceStr | string \| Resource | 用于æ述资æºå—符串的类型。 | ## ResourceColor类型<sup>8+</sup> -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | -| ResourceColor | Color \| number \| string \| Resource | 用于æ述资æºé¢œè‰²ç±»åž‹ã€‚ | +| å称 | 类型定义 | æè¿° | +| ------------- | ---------------------------------------- | ----------- | +| ResourceColor | Color \| number \| string \| Resource | 用于æ述资æºé¢œè‰²ç±»åž‹ã€‚ | ## Font类型<sup>8+</sup> -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | +| å称 | 类型定义 | æè¿° | +| ---- | ---------------------------------------- | ---------------------------------------- | | Font | {<br/>size?: Length;<br/>weight?: <a href="https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md#li24391125115311">FontWeight</a> \| number \| string;<br/>family?: string \| <a href="ts-types.md#Resource">Resource</a>;<br/>style?: <a href="https://gitee.com/superFat/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md#li6906111945316">FontStyle</a>;<br/>} | è®¾ç½®æ–‡æœ¬æ ·å¼ï¼š<br/>size: 设置文本尺寸,Length为number类型时,使用fpå•ä½ã€‚<br/>weight: 设置文本的å—体粗细,number类型å–值[100, 900],å–值间隔为100,默认为400,å–值越大,å—体越粗。<br/>family: 设置文本的å—体列表。使用多个å—体,使用','进行分割,优先级按顺åºç”Ÿæ•ˆã€‚例如:'Arial, sans-serif'。<br/>style: 设置文本的å—ä½“æ ·å¼ã€‚ | ## CustomBuilder类型<sup>8+</sup> 组件属性方法å‚æ•°å¯ä½¿ç”¨CustomBuilder类型æ¥è‡ªå®šä¹‰UIæ述。 -| å称 | 类型定义 | æè¿° | -| -------- | -------- | -------- | +| å称 | 类型定义 | æè¿° | +| ------------- | ---------------------- | ---------------------------------------- | | CustomBuilder | () => any | è¿™ç§æ–¹æ³•ç±»åž‹å¿…须使用@Builder装饰器修饰。具体用法è§[@Builder](ts-component-based-builder.md)。 | ## 示例 -``` +```ts +// xxx.ets @Entry @Component struct dataTypeExample { diff --git a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md b/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md index 9ee8bcd9bb7da37b8480687feab450a2c45ca5ff..4ae1fd27f0dae8477177bcab5eac2acb0dfa1646 100644 --- a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md +++ b/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md @@ -13,7 +13,7 @@ - @Link:组件ä¾èµ–于其父组件拥有的æŸäº›çŠ¶æ€å±žæ€§ï¼Œå½“任何一个组件ä¸çš„æ•°æ®æ›´æ–°æ—¶ï¼Œå¦ä¸€ä¸ªç»„件的状æ€éƒ½ä¼šæ›´æ–°ï¼Œçˆ¶å组件é‡æ–°æ¸²æŸ“。 - @Prop:原ç†ç±»ä¼¼@Link,但是å组件所åšçš„更改ä¸ä¼šåŒæ¥åˆ°çˆ¶ç»„件上,属于å•å‘ä¼ é€’ã€‚ ->  **说明:** +> **说明:** > 状æ€å˜é‡å称ä¸èƒ½ä½¿ç”¨id,如@Prop id:number 。 diff --git a/zh-cn/application-dev/ui/ui-js-animate-attribute-style.md b/zh-cn/application-dev/ui/ui-js-animate-attribute-style.md index 070efe2fd5b06eddf290c99ca91a9d24dddb49db..ed82f95ad103deb99230ef795154d7f268b2bac0 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-attribute-style.md +++ b/zh-cn/application-dev/ui/ui-js-animate-attribute-style.md @@ -5,7 +5,7 @@ 在关键帧(Keyframes)ä¸åŠ¨æ€è®¾ç½®çˆ¶ç»„件的widthå’Œheight,实现组件å˜å¤§ç¼©å°ã€‚å组件设置scale属性使父å组件åŒæ—¶ç¼©æ”¾ï¼Œå†è®¾ç½®opacity实现父å组件的显示与éšè—。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="fade"> @@ -18,7 +18,7 @@ ``` -``` +```css /* xxx.css */ .container { background-color:#F1F3F5; @@ -86,7 +86,7 @@ text{  ->  **说明:** +> **说明:** > - animationå–值ä¸åŒºåˆ†å…ˆåŽï¼Œduration (动画执行时间)/ delay (动画延迟执行时间)按照出现的先åŽé¡ºåºè§£æžã€‚ -> +> > - 必须设置animation-durationæ ·å¼ï¼Œå¦åˆ™æ—¶é•¿ä¸º0则ä¸ä¼šæœ‰åŠ¨ç”»æ•ˆæžœã€‚当设置animation-fill-mode属性为forwards时,组件直接展示最åŽä¸€å¸§çš„æ ·å¼ã€‚ diff --git a/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md b/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md index c293ca9b6a00b0eb11f0fa65220b0041525a450d..b9fb5bb919b03b5c25a67a96f828c2f663527903 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md +++ b/zh-cn/application-dev/ui/ui-js-animate-background-position-style.md @@ -5,7 +5,7 @@ 通过改å˜background-position属性(第一个值为Xè½´çš„ä½ç½®ï¼Œç¬¬äºŒä¸ªå€¼ä¸ºYè½´çš„ä½ç½®ï¼‰ç§»åŠ¨èƒŒæ™¯å›¾ç‰‡ä½ç½®ï¼Œè‹¥èƒŒæ™¯å›¾ä½ç½®è¶…出组件则超出部分的背景图ä¸æ˜¾ç¤ºã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="content"></div> @@ -14,7 +14,7 @@ ``` -``` +```css /* xxx.css */ .container { height: 100%; @@ -80,7 +80,7 @@ ``` ->  **说明:** +> **说明:** > background-position仅支æŒèƒŒæ™¯å›¾ç‰‡çš„移动,ä¸æ”¯æŒèƒŒæ™¯é¢œè‰²ï¼ˆbackground-color)。  diff --git a/zh-cn/application-dev/ui/ui-js-animate-component.md b/zh-cn/application-dev/ui/ui-js-animate-component.md index 91baf79e1993a469e46f03560e64d79e3c14e0ae..03b8b958ea70a55e62714ef492b18a84430bd3f9 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-component.md +++ b/zh-cn/application-dev/ui/ui-js-animate-component.md @@ -7,14 +7,14 @@ 通过调用animate方法获得animation对象,animation对象支æŒåŠ¨ç”»å±žæ€§ã€åŠ¨ç”»æ–¹æ³•å’ŒåŠ¨ç”»äº‹ä»¶ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div id="content" class="box" onclick="Show"></div> </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -30,7 +30,7 @@ } ``` -``` +```js /* xxx.js */ export default { data: { @@ -60,23 +60,23 @@ export default {  ->  **说明:** ->- 使用animateæ–¹æ³•æ—¶å¿…é¡»ä¼ å…¥Keyframeså’ŒOptionså‚数。 ->- 多次调用animate方法时,采用replaceç–略,å³æœ€åŽä¸€æ¬¡è°ƒç”¨æ—¶ä¼ 入的å‚数生效。 +> **说明:** +> - 使用animateæ–¹æ³•æ—¶å¿…é¡»ä¼ å…¥Keyframeså’ŒOptionså‚数。 +> - 多次调用animate方法时,采用replaceç–略,å³æœ€åŽä¸€æ¬¡è°ƒç”¨æ—¶ä¼ 入的å‚数生效。 ## 设置动画å‚æ•° 在获å–动画对象åŽï¼Œé€šè¿‡è®¾ç½®å‚æ•°Keyframesè®¾ç½®åŠ¨ç”»åœ¨ç»„ä»¶ä¸Šçš„æ ·å¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div id="content" class="box" onclick="Show"></div> </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -92,7 +92,7 @@ export default { } ``` -``` +```js /* xxx.js */ export default { data: { @@ -138,21 +138,21 @@ export default {  ->  **说明:** +> **说明:** > - translateã€scaleå’Œrtotateçš„å…ˆåŽé¡ºåºä¼šå½±å“动画效果。 -> +> > - transformOriginåªå¯¹scaleå’Œrtotate起作用。 在获å–动画对象åŽï¼Œé€šè¿‡è®¾ç½®å‚æ•°Optionsæ¥è®¾ç½®åŠ¨ç”»çš„属性。 -``` +```html <!-- xxx.hml --> <div class="container"> <div id="content" class="box" onclick="Show"></div> </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -168,7 +168,7 @@ export default { } ``` -``` +```js /* xxx.js */ export default { data: { @@ -206,15 +206,15 @@ export default {  ->  **说明:** +> **说明:** > direction:指定动画的æ’放模å¼ã€‚ -> +> > normal: 动画æ£å‘循环æ’放。 -> +> > reverse: 动画åå‘循环æ’放。 -> +> > alternate:动画交替循环æ’放,奇数次æ£å‘æ’放,å¶æ•°æ¬¡åå‘æ’放。 -> +> > alternate-reverse:动画åå‘交替循环æ’放,奇数次åå‘æ’放,å¶æ•°æ¬¡æ£å‘æ’放。 @@ -222,7 +222,7 @@ export default { animation对象支æŒåŠ¨ç”»äº‹ä»¶å’ŒåŠ¨ç”»æ–¹æ³•ã€‚å¯ä»¥é€šè¿‡æ·»åŠ 开始和å–消事件,调用æ’放ã€æš‚åœã€å€’放和结æŸæ–¹æ³•å®žçŽ°é¢„期动画。 -``` +```html <!-- xxx.hml --> <div class="container"> <div id="content" style="width: 350px;height: 350px;margin-top: 100px;background: linear-gradient(pink, purple);"> @@ -238,7 +238,7 @@ animation对象支æŒåŠ¨ç”»äº‹ä»¶å’ŒåŠ¨ç”»æ–¹æ³•ã€‚å¯ä»¥é€šè¿‡æ·»åŠ 开始和 </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -270,8 +270,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { data: { @@ -348,7 +348,7 @@ export default { 通过改å˜playStat的属性实现动画状æ€çš„改å˜ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div id="content" style="width: 350px;height: 350px;margin-top: 100px;background: linear-gradient(pink, purple);"> @@ -362,7 +362,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -394,8 +394,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md b/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md index 1d56e5a4f7c5e59d14771f7570b1bb91f354efbf..e9d60c5cf47743b28b909dcdfd84d06e837284f2 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md +++ b/zh-cn/application-dev/ui/ui-js-animate-dynamic-effects.md @@ -3,7 +3,7 @@ 通过设置æ’值器æ¥å®žçŽ°åŠ¨ç”»æ•ˆæžœã€‚ ->  **说明:** +> **说明:** > 从API Version 6 开始支æŒã€‚ @@ -11,7 +11,7 @@ 通过createAnimator创建一个动画对象,通过设置å‚æ•°optionsæ¥è®¾ç½®åŠ¨ç”»çš„属性。 -``` +```html <!-- xxx.hml --> <div class="container"> <div style="width: 300px;height: 300px;margin-top: 100px;background: linear-gradient(pink, purple);transform: translate({{translateVal}});"> @@ -22,7 +22,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -44,8 +44,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js import animator from '@ohos.animator'; export default { data: { @@ -78,7 +78,7 @@ export default {  ->  **说明:** +> **说明:** > - 使用createAnimatoråˆ›å»ºåŠ¨ç”»å¯¹è±¡æ—¶å¿…é¡»ä¼ å…¥optionså‚数。 > > - beginæ’值起点,ä¸è®¾ç½®æ—¶é»˜è®¤ä¸º0。 @@ -90,7 +90,7 @@ export default { animator支æŒäº‹ä»¶å’ŒæŽ¥å£ï¼Œå¯ä»¥é€šè¿‡æ·»åŠ frameã€cancelã€repeatã€finish事件和调用updateã€playã€pauseã€cancelã€reverseã€finish接å£è‡ªå®šä¹‰åŠ¨ç”»æ•ˆæžœã€‚animator支æŒçš„事件和接å£å…·ä½“è§åŠ¨ç”»ä¸çš„[createAnimator](../reference/apis/js-apis-animator.md)。 -``` +```html <!-- xxx.hml --> <div style="flex-direction: column;align-items: center;width: 100%;height: 100%;"> <div style="width:200px;height: 200px;margin-top: 100px;background: linear-gradient(#b30d29, #dcac1b); @@ -113,7 +113,7 @@ animator支æŒäº‹ä»¶å’ŒæŽ¥å£ï¼Œå¯ä»¥é€šè¿‡æ·»åŠ frameã€cancelã€repeatã€fini </div> ``` -``` +```css /* xxx.css */ button{ width: 200px; @@ -150,8 +150,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js import animator from '@ohos.animator'; import prompt from '@system.prompt'; export default { @@ -234,5 +234,5 @@ export default {  ->  **说明:** +> **说明:** > 在调用update接å£çš„过程ä¸å¯ä»¥ä½¿ç”¨è¿™ä¸ªæŽ¥å£æ›´æ–°åŠ¨ç”»å‚数,入å‚与createAnimator一致。 diff --git a/zh-cn/application-dev/ui/ui-js-animate-frame.md b/zh-cn/application-dev/ui/ui-js-animate-frame.md index 8489cfd5f02ddcb2e24f55cfe44c38c94cef9817..ae798d98906c4b40ed443a5b1ed3a43651bb7adb 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-frame.md +++ b/zh-cn/application-dev/ui/ui-js-animate-frame.md @@ -6,7 +6,7 @@ runframe在调用requestAnimationFrameæ—¶ä¼ å…¥å¸¦æœ‰timestampå‚数的回调函数step,将stepä¸çš„timestamp赋予起始的startTime。当timestamp与startTime的差值å°äºŽè§„定的时间时将å†æ¬¡è°ƒç”¨requestAnimationFrame,最终动画将会åœæ¢ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <tabs onchange="changecontent"> @@ -25,7 +25,7 @@ runframe在调用requestAnimationFrameæ—¶ä¼ å…¥å¸¦æœ‰timestampå‚数的回调函 </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -39,8 +39,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { timer: null, @@ -95,7 +95,7 @@ export default {  ->  **说明:** +> **说明:** > requestAnimationFrame函数在调用回调函数时在第一个å‚æ•°ä½ç½®ä¼ å…¥timestamp时间戳,表示requestAnimationFrame开始去执行回调函数的时刻。 @@ -103,7 +103,7 @@ export default { 通过cancelAnimationFrame函数å–消é€å¸§å›žè°ƒï¼Œåœ¨è°ƒç”¨cancelAnimationFrame函数时å–消requestAnimationFrame函数的请求。 -``` +```html <!-- xxx.hml --> <div class="container"> <tabs onchange="changecontent"> @@ -122,7 +122,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -136,8 +136,8 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { timer: null, @@ -184,5 +184,5 @@ export default {  ->  **说明:** +> **说明:** > åœ¨è°ƒç”¨è¯¥å‡½æ•°æ—¶éœ€ä¼ å…¥ä¸€ä¸ªå…·æœ‰æ ‡è¯†idçš„å‚数。 diff --git a/zh-cn/application-dev/ui/ui-js-animate-svg.md b/zh-cn/application-dev/ui/ui-js-animate-svg.md index f4e20529894244958e7bfee674e8b4ac3eeb6cff..beed6f9df285dc966a03ea46f63085d962fc16be 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-svg.md +++ b/zh-cn/application-dev/ui/ui-js-animate-svg.md @@ -9,7 +9,7 @@ 在Svgçš„å组件[animate](../reference/arkui-js/js-components-svg-animate.md)ä¸ï¼Œé€šè¿‡attributeName设置需è¦è¿›è¡ŒåŠ¨æ•ˆçš„属性,from设置开始值,to设置结æŸå€¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <svg> @@ -37,7 +37,7 @@  ->  **说明:** +> **说明:** > 在设置动画å˜åŒ–值时,如果已ç»è®¾ç½®äº†values属性,则fromå’Œto都失效。 @@ -46,7 +46,7 @@ 在Svgçš„å组件[animateMotion](../reference/arkui-js/js-components-svg-animatemotion.md)ä¸ï¼Œé€šè¿‡path设置动画å˜åŒ–的路径。 -``` +```html <!-- xxx.hml --> <div class="container"> <svg fill="white" width="800" height="900"> @@ -68,7 +68,7 @@ 在Svgçš„å组件[animateMotion](../reference/arkui-js/js-components-svg-animatetransform.md)ä¸ï¼Œé€šè¿‡attributeName绑定transform属性,type设置动画类型,from设置开始值,to设置结æŸå€¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container" style=""> <svg> @@ -94,7 +94,7 @@ ``` -``` +```css /* xxx.css */ .container { flex-direction: column; diff --git a/zh-cn/application-dev/ui/ui-js-animate-transform.md b/zh-cn/application-dev/ui/ui-js-animate-transform.md index 4a0dfed33828eefabc90d42c648b875b4122ae0e..4c642a9325fae074ba5a18b6e8d4c87b9a3c6106 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-transform.md +++ b/zh-cn/application-dev/ui/ui-js-animate-transform.md @@ -7,7 +7,7 @@ 创建一个æ£æ–¹å½¢å¹¶æ—‹è½¬90°å˜æˆè±å½¢ï¼Œå¹¶ç”¨ä¸‹æ–¹çš„长方形把è±å½¢ä¸‹åŠéƒ¨åˆ†é®ç›–å½¢æˆå±‹é¡¶ï¼Œè®¾ç½®é•¿æ–¹å½¢translate属性值为(150px,-150px)确定åæ ‡ä½ç½®å½¢æˆé—¨ï¼Œå†ä½¿ç”¨position属性使横纵线跟éšçˆ¶ç»„件(æ£æ–¹å½¢ï¼‰ç§»åŠ¨åˆ°æŒ‡å®šåæ ‡ä½ç½®ï¼ŒæŽ¥ç€è®¾ç½®scale属性使父å组件一起å˜å¤§å½¢æˆçª—户大å°ï¼Œæœ€åŽä½¿ç”¨skewX属性使组件倾斜åŽè®¾ç½®åæ ‡translate(200px,-830px)得到烟囱。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="top"></div> @@ -22,7 +22,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -96,7 +96,7 @@ å°çƒä¸‹é™åŠ¨ç”»ï¼Œæ”¹å˜å°çƒçš„Yè½´åæ ‡å®žçŽ°å°çƒä¸‹è½ï¼Œåœ¨ä¸‹ä¸€æ®µæ˜¯æ—¶é—´å†…å‡å°Yè½´åæ ‡å®žçŽ°å°çƒå›žå¼¹ï¼Œè®©æ¯æ¬¡å›žå¼¹çš„高度é€æ¬¡å‡å°ç›´è‡³å›žå¼¹é«˜åº¦ä¸º0,就模拟出了å°çƒä¸‹é™çš„动画。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="circle"></div> @@ -104,7 +104,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -175,7 +175,7 @@ 设置ä¸åŒçš„原点ä½ç½®ï¼ˆtransform-origin)改å˜å…ƒç´ 所围绕的旋转ä¸å¿ƒã€‚rotate3d属性å‰ä¸‰ä¸ªå‚数值分别为Xè½´ã€Yè½´ã€Z轴的旋转å‘é‡ï¼Œç¬¬å››ä¸ªå€¼ä¸ºæ—‹è½¬è§’度,旋转å‘角度å¯ä¸ºè´Ÿå€¼ï¼Œè´Ÿå€¼åˆ™ä»£è¡¨æ—‹è½¬æ–¹å‘为逆时针方å‘。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="rotate"> @@ -194,7 +194,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -301,7 +301,7 @@  ->  **说明:** +> **说明:** > transform-originå˜æ¢å¯¹è±¡çš„原点ä½ç½®ï¼Œå¦‚果仅设置一个值,å¦ä¸€ä¸ªå€¼ä¸º50%,若设置两个值第一个值表示Xè½´çš„ä½ç½®ï¼Œç¬¬äºŒä¸ªå€¼è¡¨ç¤ºYè½´çš„ä½ç½®ã€‚ @@ -311,7 +311,7 @@ 设置sacle3dä¸Xè½´ã€Yè½´ã€Z轴的缩放å‚数实现动画。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="circle"> @@ -326,7 +326,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -414,7 +414,7 @@ text{  ->  **说明:** +> **说明:** > 设置transform属性值åŽï¼Œåå…ƒç´ ä¼šè·Ÿç€çˆ¶å…ƒç´ 一起改å˜ï¼Œè‹¥åªæ”¹å˜çˆ¶å…ƒç´ 其他属性值时(如:height,width),åå…ƒç´ ä¸ä¼šæ”¹å˜ã€‚ @@ -422,14 +422,14 @@ text{ matrix是一个入å‚为å…个值的矩阵,6个值分别代表:scaleX, skewY, skewX, scaleY, translateX, translateY。下é¢ç¤ºä¾‹ä¸è®¾ç½® 了matrix属性为matrix(1,0,0,1,0,200)使组件移动和倾斜。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="rect"> </div> </div> ``` -``` +```css /* xxx.css */ .container{ background-color:#F1F3F5; @@ -465,7 +465,7 @@ matrix是一个入å‚为å…个值的矩阵,6个值分别代表:scaleX, skewY transformå¯ä»¥è®¾ç½®å¤šä¸ªå€¼å¹¶ä¸”多个值å¯åŒæ—¶è®¾ç½®ï¼Œä¸‹é¢æ¡ˆä¾‹ä¸å±•ç¤ºåŒæ—¶è®¾ç½®ç¼©æ”¾ï¼ˆscale),平移(translate),旋转(rotate)属性时的动画效果。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="rect1"></div> @@ -476,7 +476,7 @@ transformå¯ä»¥è®¾ç½®å¤šä¸ªå€¼å¹¶ä¸”多个值å¯åŒæ—¶è®¾ç½®ï¼Œä¸‹é¢æ¡ˆä¾‹ä¸ </div> ``` -``` +```css /* xxx.css */ .container{ flex-direction:column; @@ -568,11 +568,11 @@ transformå¯ä»¥è®¾ç½®å¤šä¸ªå€¼å¹¶ä¸”多个值å¯åŒæ—¶è®¾ç½®ï¼Œä¸‹é¢æ¡ˆä¾‹ä¸  ->  **说明:** +> **说明:** > - 当设置多个transform时,åŽç»çš„transform值会把å‰é¢çš„覆盖掉。若想åŒæ—¶ä½¿ç”¨å¤šä¸ªåŠ¨ç”»æ ·å¼å¯ç”¨å¤åˆå†™æ³•ï¼Œä¾‹ï¼štransform: scale(1) rotate(0) translate(0,0)。 -> +> > - transform进行å¤åˆå†™æ³•æ—¶ï¼Œå˜åŒ–æ ·å¼å†…å¤šä¸ªæ ·å¼å€¼é¡ºåºçš„ä¸åŒä¼šå‘ˆçŽ°ä¸ä¸€æ ·çš„动画效果。 -> +> > - transformå±žæ€§è®¾ç½®çš„æ ·å¼å€¼è¦ä¸€ä¸€å¯¹åº”,若å‰åŽä¸å¯¹åº”,则该动画ä¸ç”Ÿæ•ˆã€‚è‹¥è®¾ç½®å¤šä¸ªæ ·å¼å€¼åˆ™åªä¼šå‘ˆçŽ°å‡ºå·²å¯¹åº”值的动画效果。 @@ -586,6 +586,8 @@ transformå¯ä»¥è®¾ç½®å¤šä¸ªå€¼å¹¶ä¸”多个值å¯åŒæ—¶è®¾ç½®ï¼Œä¸‹é¢æ¡ˆä¾‹ä¸ - [`Clock`:时钟(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock) -- [åŠ¨ç”»æ ·å¼ï¼ˆJS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo) +- [`JsAnimator`:动画(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation) + +- [åŠ¨ç”»æ ·å¼ï¼ˆJS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo) -- [图片常è§æ“作](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo) +- [图片常è§æ“作(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo) diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-animation.md b/zh-cn/application-dev/ui/ui-js-building-ui-animation.md index eeecc674d8f2242e81e35cd0709bb812d89515dc..03c99a2899ceea6680d97a434e3e0d527a8b7ef5 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-animation.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-animation.md @@ -15,7 +15,7 @@ 具体的使用示例如下,更多信æ¯è¯·å‚考[组件方法](../reference/arkui-js/js-components-common-methods.md)。 -``` +```html <!-- xxx.hml --> <div class="container"> <text class="translate">hello</text> @@ -24,7 +24,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -78,7 +78,7 @@ animationæ ·å¼éœ€è¦åœ¨css文件ä¸å…ˆå®šä¹‰keyframe,在keyframeä¸è®¾ç½®åŠ¨ç”»çš„è¿‡æ¸¡æ•ˆæžœï¼Œå¹¶é€šè¿‡ä¸€ä¸ªæ ·å¼ç±»åž‹åœ¨hml文件ä¸è°ƒç”¨ã€‚animation-name的使用示例如下: -``` +```html <!-- xxx.hml --> <div class="item-container"> <text class="header">animation-name</text> @@ -92,7 +92,7 @@ animationæ ·å¼éœ€è¦åœ¨css文件ä¸å…ˆå®šä¹‰keyframe,在keyframeä¸è®¾ç½®åŠ¨ </div> ``` -``` +```css /* xxx.css */ .item-container { margin-right: 60px; diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-component.md b/zh-cn/application-dev/ui/ui-js-building-ui-component.md index d57c8c901cca78e1cf07c9b13a11ebff581081d7..e190e0b5bed9f96258d5dfedc969f3c0abfb4732 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-component.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-component.md @@ -41,6 +41,6 @@ - [`JsVideo`:视频æ’放(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsVideo) -- [rating(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication) +- [rating(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication) -- [简易视频æ’放器](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoOpenHarmony) +- [简易视频æ’放器(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoOpenHarmony) diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-event.md b/zh-cn/application-dev/ui/ui-js-building-ui-event.md index 93752ddd5cce56023faa9d10a306fb22087ed1b5..9c09ebb86f3b0a6177307deb7d7cd6b5ebca2bc2 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-event.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-event.md @@ -21,7 +21,7 @@ longpress:用户在相åŒä½ç½®é•¿æ—¶é—´ä¿æŒä¸Žå±å¹•æŽ¥è§¦ã€‚ 具体的使用示例如下: -``` +```html <!-- xxx.hml --> <div class="container"> <div class="text-container" onclick="click"> @@ -45,7 +45,7 @@ longpress:用户在相åŒä½ç½®é•¿æ—¶é—´ä¿æŒä¸Žå±å¹•æŽ¥è§¦ã€‚ </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -68,7 +68,7 @@ longpress:用户在相åŒä½ç½®é•¿æ—¶é—´ä¿æŒä¸Žå±å¹•æŽ¥è§¦ã€‚ } ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-interactions.md b/zh-cn/application-dev/ui/ui-js-building-ui-interactions.md index 8f6957b695624691d317ae437c328acf45ae13b3..b520951a42448f717f0da0c1bf77f9f768fc5bc9 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-interactions.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-interactions.md @@ -17,7 +17,7 @@ click事件作为一个函数定义在js文件ä¸ï¼Œå¯ä»¥æ›´æ”¹isPressed的状æ€ï¼Œä»Žè€Œæ›´æ–°æ˜¾ç¤ºçš„image组件。如果isPressedä¸ºçœŸï¼Œåˆ™ç‚¹èµžæ•°åŠ 1。该函数在hml文件ä¸å¯¹åº”çš„div组件上生效,点赞按钮å„åç»„ä»¶çš„æ ·å¼è®¾ç½®åœ¨css文件当ä¸ã€‚具体的实现示例如下: -``` +```html <!-- xxx.hml --> <!-- 点赞按钮 --> <div> @@ -29,7 +29,7 @@ click事件作为一个函数定义在js文件ä¸ï¼Œå¯ä»¥æ›´æ”¹isPressed的状 ``` -``` +```css /* xxx.css */ .like { width: 104px; @@ -53,7 +53,7 @@ click事件作为一个函数定义在js文件ä¸ï¼Œå¯ä»¥æ›´æ”¹isPressed的状 ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-layout-comment.md b/zh-cn/application-dev/ui/ui-js-building-ui-layout-comment.md index ffc8508d19579769417b4faef3a46b14971f63f4..295661a261d13d362161cf44a89e900e7cb11d1f 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-layout-comment.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-layout-comment.md @@ -6,7 +6,7 @@ 留言区域由divã€textã€inputå…³è”click事件实现。开å‘者å¯ä»¥ä½¿ç”¨input组件实现输入留言的部分,使用text组件实现留言完æˆéƒ¨åˆ†ï¼Œä½¿ç”¨commentText的状æ€æ ‡è®°æ¤æ—¶æ˜¾ç¤ºçš„组件(通过if属性控制)。在包å«æ–‡æœ¬å®Œæˆå’Œåˆ 除的text组件ä¸å…³è”click事件,更新commentText状æ€å’ŒinputValue的内容。具体的实现示例如下: -``` +```html <!-- xxx.hml --> <div class="container"> <text class="comment-title">Comment</text> @@ -22,7 +22,7 @@ ``` -``` +```css /* xxx.css */ .container { margin-top: 24px; @@ -64,7 +64,7 @@ ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-layout-external-container.md b/zh-cn/application-dev/ui/ui-js-building-ui-layout-external-container.md index 9745b4d08ffa54470ec8c3150601b1450e686b43..aa4941473248b85510bb5243d20f103183448822 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-layout-external-container.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-layout-external-container.md @@ -7,7 +7,7 @@ 当页é¢ç»“构较为å¤æ‚时,如果使用div循环渲染,容易出现å¡é¡¿ï¼Œå› æ¤æŽ¨è使用list组件代替divç»„ä»¶å®žçŽ°é•¿åˆ—è¡¨å¸ƒå±€ï¼Œä»Žè€Œå®žçŽ°æ›´åŠ æµç•…的列表滚动体验。需è¦æ³¨æ„的是,list仅支æŒlist-item作为å组件,具体的使用示例如下: -``` +```html <!-- xxx.hml --> <list class="list"> <list-item type="listItem" for="{{textList}}"> @@ -16,7 +16,7 @@ </list> ``` -``` +```css /* xxx.css */ .desc-text { width: 683.3px; @@ -24,7 +24,7 @@ } ``` -``` +```js // xxx.js export default { data: { @@ -40,7 +40,7 @@ export default { 当页é¢ç»å¸¸éœ€è¦åŠ¨æ€åŠ 载时,推è使用tabs组件。tabs组件支æŒchange事件,在页ç¾åˆ‡æ¢åŽè§¦å‘。tabs组件仅支æŒä¸€ä¸ªtab-bar和一个tab-content。具体的使用示例如下: -``` +```html <!-- xxx.hml --> <tabs> <tab-bar> @@ -56,7 +56,7 @@ export default { </tabs> ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-layout-image.md b/zh-cn/application-dev/ui/ui-js-building-ui-layout-image.md index 78672e1b5d4bcad2f80805b01be30d33ba07aec1..0bcfe0af4e7690c7992504471ca107ada142c328 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-layout-image.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-layout-image.md @@ -7,13 +7,13 @@ 图片资æºå»ºè®®æ”¾åœ¨jsdefaultcommon目录下,common目录需自行创建,详细的目录结构è§[目录结构](../ui/js-framework-file.md#目录结构)。代ç 示例如下: -``` +```html <!-- xxx.hml --> <image class="img" src="{{middleImage}}"></image> ``` -``` +```css /* xxx.css */ .img { margin-top: 30px; @@ -23,7 +23,7 @@ ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-layout-text.md b/zh-cn/application-dev/ui/ui-js-building-ui-layout-text.md index cb3a7c1a186b90c4fd1395d00e363295dd9e91a1..9dbcf23ef49a459e35a5dd29f087dd553ea200fb 100755 --- a/zh-cn/application-dev/ui/ui-js-building-ui-layout-text.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-layout-text.md @@ -3,7 +3,7 @@ å®žçŽ°æ ‡é¢˜å’Œæ–‡æœ¬åŒºåŸŸæœ€å¸¸ç”¨çš„æ˜¯åŸºç¡€ç»„ä»¶text。text组件用于展示文本,å¯ä»¥è®¾ç½®ä¸åŒçš„å±žæ€§å’Œæ ·å¼ï¼Œæ–‡æœ¬å†…容需è¦å†™åœ¨æ ‡ç¾å†…å®¹åŒºï¼Œå®Œæ•´å±žæ€§å’Œæ ·å¼ä¿¡æ¯è¯·å‚考[text](../reference/arkui-js/js-components-basic-text.md)。在页é¢ä¸æ’å…¥æ ‡é¢˜å’Œæ–‡æœ¬åŒºåŸŸçš„ç¤ºä¾‹å¦‚ä¸‹ï¼š -``` +```html <!-- xxx.hml --> <div class="container"> <text class="title-text">{{headTitle}}</text> @@ -13,7 +13,7 @@ ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -34,7 +34,7 @@ ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-building-ui-routes.md b/zh-cn/application-dev/ui/ui-js-building-ui-routes.md index eaa20d1aa8db22928bbd55d19447d71168de6ea6..084977da6a4e67f865906d1a98e8041b6646594d 100644 --- a/zh-cn/application-dev/ui/ui-js-building-ui-routes.md +++ b/zh-cn/application-dev/ui/ui-js-building-ui-routes.md @@ -17,7 +17,7 @@ indexå’Œdetail这两个页é¢å‡åŒ…å«ä¸€ä¸ªtext组件和button组件:text组件用æ¥æŒ‡æ˜Žå½“å‰é¡µé¢ï¼Œbutton组件用æ¥å®žçŽ°ä¸¤ä¸ªé¡µé¢ä¹‹é—´çš„相互跳转。hml文件代ç 示例如下: -``` +```html <!-- index.hml --> <div class="container"> <text class="title">This is the index page.</text> @@ -25,7 +25,7 @@ indexå’Œdetail这两个页é¢å‡åŒ…å«ä¸€ä¸ªtext组件和button组件:text组 </div> ``` -``` +```html <!-- detail.hml --> <div class="container"> <text class="title">This is the detail page.</text> @@ -38,7 +38,7 @@ indexå’Œdetail这两个页é¢å‡åŒ…å«ä¸€ä¸ªtext组件和button组件:text组 构建indexå’Œdetail页é¢çš„页é¢æ ·å¼ï¼Œtext组件和button组件居ä¸æ˜¾ç¤ºï¼Œä¸¤ä¸ªç»„件之间间è·ä¸º50px。css代ç 如下(两个页é¢æ ·å¼ä»£ç 一致): -``` +```css /* index.css */ /* detail.css */ .container { @@ -58,7 +58,7 @@ indexå’Œdetail这两个页é¢å‡åŒ…å«ä¸€ä¸ªtext组件和button组件:text组 为了使button组件的launch方法生效,需è¦åœ¨é¡µé¢çš„js文件ä¸å®žçŽ°è·³è½¬é€»è¾‘。调用router.push()接å£å°†uri指定的页é¢æ·»åŠ åˆ°è·¯ç”±æ ˆä¸ï¼Œå³è·³è½¬åˆ°uri指定的页é¢ã€‚在调用router方法之å‰ï¼Œéœ€è¦å¯¼å…¥router模å—。代ç 示例如下: -``` +```js // index.js import router from '@system.router'; export default { @@ -70,7 +70,7 @@ export default { } ``` -``` +```js // detail.js import router from '@system.router'; export default { diff --git a/zh-cn/application-dev/ui/ui-js-component-tabs.md b/zh-cn/application-dev/ui/ui-js-component-tabs.md index 59421b9fefdaba9363a61368da04b71cc6821446..f4d3ff942c7212f8e78954d83487ac6d23b3cc70 100644 --- a/zh-cn/application-dev/ui/ui-js-component-tabs.md +++ b/zh-cn/application-dev/ui/ui-js-component-tabs.md @@ -1,14 +1,14 @@ -# Tabs +# tabså¼€å‘指导 -Tabs是一ç§å¸¸è§çš„ç•Œé¢å¯¼èˆªç»“构。通过页ç¾å®¹å™¨ï¼Œç”¨æˆ·å¯ä»¥å¿«æ·åœ°è®¿é—®åº”用的ä¸åŒæ¨¡å—。具体用法请å‚考[Tabs API](../reference/arkui-js/js-components-container-tabs.md)。 +tabs是一ç§å¸¸è§çš„ç•Œé¢å¯¼èˆªç»“构。通过页ç¾å®¹å™¨ï¼Œç”¨æˆ·å¯ä»¥å¿«æ·åœ°è®¿é—®åº”用的ä¸åŒæ¨¡å—。具体用法请å‚考[tabs API](../reference/arkui-js/js-components-container-tabs.md)。 -## 创建Tabs +## 创建tabs -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªTabs组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªtabs组件。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container" > <tabs> <tab-bar> <text>item1</text> @@ -26,7 +26,7 @@ Tabs是一ç§å¸¸è§çš„ç•Œé¢å¯¼èˆªç»“构。通过页ç¾å®¹å™¨ï¼Œç”¨æˆ·å¯ä»¥å¿« </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -45,12 +45,12 @@ Tabs是一ç§å¸¸è§çš„ç•Œé¢å¯¼èˆªç»“构。通过页ç¾å®¹å™¨ï¼Œç”¨æˆ·å¯ä»¥å¿«  -## 设置Tabsæ–¹å‘ +## 设置tabsæ–¹å‘ -Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使组件纵å‘展示。 +tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使组件纵å‘展示。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;"> <tabs index="1" vertical="true"> <tab-bar > @@ -73,8 +73,8 @@ Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使 设置mode属性使tab-barçš„å组件å‡åˆ†ï¼Œè®¾ç½®scrollable属性使tab-contentä¸å¯è¿›è¡Œå·¦å³æ»‘动切æ¢å†…容。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;"> <tabs style="margin-top: 30px;"> <tab-bar mode="fixed"> @@ -98,9 +98,9 @@ Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使 ## è®¾ç½®æ ·å¼ -设置Tabs背景色åŠè¾¹æ¡†å’Œtab-content布局。 -``` -<!-- index.hml --> +设置tabs背景色åŠè¾¹æ¡†å’Œtab-content布局。 +```html +<!-- xxx.hml --> <div class="container"> <tabs class="tabs"> <tab-bar class="tabBar"> @@ -119,7 +119,7 @@ Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使 </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -152,10 +152,10 @@ Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使 ## 显示页ç¾ç´¢å¼• -å¼€å‘者å¯ä»¥ä¸ºTabsæ·»åŠ change事件,实现页ç¾åˆ‡æ¢åŽæ˜¾ç¤ºå½“å‰é¡µç¾ç´¢å¼•çš„功能。 +å¼€å‘者å¯ä»¥ä¸ºtabsæ·»åŠ change事件,实现页ç¾åˆ‡æ¢åŽæ˜¾ç¤ºå½“å‰é¡µç¾ç´¢å¼•çš„功能。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;"> <tabs class="tabs" onchange="tabChange"> <tab-bar class="tabBar"> @@ -174,8 +174,8 @@ Tabs默认展示索引为indexçš„æ ‡ç¾åŠå†…容。通过设置vertical属性使 </div> ``` -``` -/* index.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { tabChange(e){ @@ -189,7 +189,7 @@ export default {  ->  **说明:** +> **说明:** > > tabså组件仅支æŒä¸€ä¸ª[\<tab-bar>](../reference/arkui-js/js-components-container-tab-bar.md)和一个[\<tab-content>](../reference/arkui-js/js-components-container-tab-content.md)。 @@ -200,8 +200,8 @@ export default { 用tabsã€tab-barå’Œtab-content实现点击切æ¢åŠŸèƒ½ï¼Œå†å®šä¹‰æ•°ç»„,设置属性。使用change事件改å˜æ•°ç»„内的属性值实现å˜è‰²åŠä¸‹åˆ’线的显示。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <tabs onchange="changeTabactive"> <tab-content> @@ -228,7 +228,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -264,8 +264,8 @@ background-color:#F1F3F5; } ``` -``` -/* index.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { data() { @@ -312,6 +312,6 @@ export default { ## 相关实例 -针对Tabså¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对tabså¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Tabs`:页ç¾å®¹å™¨ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-button.md b/zh-cn/application-dev/ui/ui-js-components-button.md index b6ac4f467946db47b417145fbdb9f0ee05932d5b..6e6fd208a3ba964963cdf09a937e09a2f6286068 100644 --- a/zh-cn/application-dev/ui/ui-js-components-button.md +++ b/zh-cn/application-dev/ui/ui-js-components-button.md @@ -1,20 +1,20 @@ -# Button +# buttonå¼€å‘指导 -Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰é’®ã€å¼§å½¢æŒ‰é’®ã€ä¸‹è½½æŒ‰é’®ã€‚具体用法请å‚考[Button API](../reference/arkui-js/js-components-basic-button.md)。 +button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰é’®ã€å¼§å½¢æŒ‰é’®ã€ä¸‹è½½æŒ‰é’®ã€‚具体用法请å‚考[button API](../reference/arkui-js/js-components-basic-button.md)。 -## 创建Button组件 +## 创建button组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªButton组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªbutton组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <button type="capsule" value="Capsule button"></button> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -29,12 +29,12 @@ Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰  -## 设置Button类型 +## 设置button类型 -通过设置Buttonçš„type属性æ¥é€‰æ‹©æŒ‰é’®ç±»åž‹ï¼Œå¦‚定义Button为圆形按钮ã€æ–‡æœ¬æŒ‰é’®ç‰ã€‚ +通过设置buttonçš„type属性æ¥é€‰æ‹©æŒ‰é’®ç±»åž‹ï¼Œå¦‚定义button为圆形按钮ã€æ–‡æœ¬æŒ‰é’®ç‰ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <button class="circle" type="circle" >+</button> @@ -43,7 +43,7 @@ Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -73,14 +73,14 @@ Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰  ->  **说明:** +> **说明:** > - 胶囊按钮(type=capsule)ä¸æ”¯æŒborderç›¸å…³æ ·å¼ã€‚ -> +> > - 圆形按钮(type=circle)ä¸æ”¯æŒæ–‡æœ¬ç›¸å…³æ ·å¼ã€‚ -> +> > - 文本按钮(type=text),自适应文本大å°ï¼Œä¸æ”¯æŒå°ºå¯¸æ ·å¼è®¾ç½®ï¼ˆradius,width,height),背景é€æ˜Žä¸æ”¯æŒbackground-coloræ ·å¼ã€‚ -> -> - Button组件使用的iconå›¾æ ‡å¦‚æžœæ¥è‡ªäº‘端路径,需è¦æ·»åŠ 网络访问æƒé™ ohos.permission.INTERNET。 +> +> - button组件使用的iconå›¾æ ‡å¦‚æžœæ¥è‡ªäº‘端路径,需è¦æ·»åŠ 网络访问æƒé™ ohos.permission.INTERNET。 如果需è¦æ·»åŠ ohos.permission.INTERNETæƒé™ï¼Œåˆ™åœ¨resources文件夹下的config.json文件里进行æƒé™é…置。 @@ -98,16 +98,16 @@ Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰ ## 显示下载进度 -为Buttonç»„ä»¶æ·»åŠ progress方法,æ¥å®žæ—¶æ˜¾ç¤ºä¸‹è½½è¿›åº¦æ¡çš„进度。 +为buttonç»„ä»¶æ·»åŠ progress方法,æ¥å®žæ—¶æ˜¾ç¤ºä¸‹è½½è¿›åº¦æ¡çš„进度。 -``` +```html <!-- xxx.hml --> <div class="container"> <button class="button download" type="download" id="download-btn" onclick="setProgress">{{downloadText}}</button> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -124,7 +124,7 @@ Button是按钮组件,其类型包括胶囊按钮ã€åœ†å½¢æŒ‰é’®ã€æ–‡æœ¬æŒ‰ } ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -174,16 +174,16 @@ export default {  ->  **说明:** +> **说明:** > setProgress方法åªæ”¯æŒbutton的类型为download。 ## 场景示例 -在本场景ä¸ï¼Œå¼€å‘者å¯æ ¹æ®è¾“入的文本内容进行Button类型切æ¢ã€‚ +在本场景ä¸ï¼Œå¼€å‘者å¯æ ¹æ®è¾“入的文本内容进行button类型切æ¢ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="input-item"> @@ -201,7 +201,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -248,7 +248,7 @@ export default { ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-components-canvas.md b/zh-cn/application-dev/ui/ui-js-components-canvas.md index 5eb3b7ac4d5cf0051ad0db76c87755992abe339a..36793f7a6bda601b634d748dc775be3e36318db2 100644 --- a/zh-cn/application-dev/ui/ui-js-components-canvas.md +++ b/zh-cn/application-dev/ui/ui-js-components-canvas.md @@ -17,7 +17,7 @@ Canvas组件æ供画布,用于自定义绘制图形。具体用法请å‚考[C ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -32,7 +32,7 @@ canvas{  ->  **说明:** +> **说明:** > - Canvas组件默认背景色与父组件的背景色一致。 > > - Canvas默认宽高为width: 300px,height: 150px。 @@ -43,7 +43,7 @@ canvas{ Canvas组件设置宽(width)ã€é«˜ï¼ˆheight)ã€èƒŒæ™¯è‰²ï¼ˆbackground-color)åŠè¾¹æ¡†æ ·å¼ï¼ˆborder)。 -``` +```html <!-- xxx.hml --> <div class="container"> <canvas></canvas> @@ -51,7 +51,7 @@ Canvas组件设置宽(width)ã€é«˜ï¼ˆheight)ã€èƒŒæ™¯è‰²ï¼ˆbackground-colo ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -75,7 +75,7 @@ canvas{ Canvasæ·»åŠ é•¿æŒ‰äº‹ä»¶ï¼Œé•¿æŒ‰åŽå¯èŽ·å–Canvas组件的dataUrl值(toDataURL方法返回的图片信æ¯ï¼‰ï¼Œæ‰“å°åœ¨ä¸‹æ–¹æ–‡æœ¬åŒºåŸŸå†…。 -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1" onlongpress="getUrl"></canvas> @@ -85,7 +85,7 @@ Canvasæ·»åŠ é•¿æŒ‰äº‹ä»¶ï¼Œé•¿æŒ‰åŽå¯èŽ·å–Canvas组件的dataUrl值(toDataU ``` -``` +```css /* xxx.css */ .container{ width:100%; @@ -112,7 +112,7 @@ Canvasæ·»åŠ é•¿æŒ‰äº‹ä»¶ï¼Œé•¿æŒ‰åŽå¯èŽ·å–Canvas组件的dataUrl值(toDataU ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -137,7 +137,7 @@ export default {  ->  **说明:** +> **说明:** > 画布ä¸æ”¯æŒåœ¨onInitå’ŒonReadyä¸è¿›è¡Œåˆ›å»ºã€‚ ## 相关实例 diff --git a/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md b/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md index 3865c41f1e740d805909dee85c0d5b0d62ea8c53..85a737f4d78f8e9ec6aa60130dadf788c06090bc 100644 --- a/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md @@ -9,7 +9,7 @@ 使用moveToå’ŒlineTo画出一æ¡çº¿æ®µï¼Œå½“使用closePath方法时会结æŸå½“å‰è·¯å¾„å½¢æˆä¸€ä¸ªå°é—图形 。设置quadraticCurveTo(二次è´èµ›å°”曲线)或bezierCurveTo(三次è´èµ›å°”曲线)的值组æˆå›¾å½¢ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1"></canvas> @@ -24,7 +24,7 @@ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -47,7 +47,7 @@ select{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -209,7 +209,7 @@ export default { -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1"></canvas> @@ -224,7 +224,7 @@ export default { -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -248,7 +248,7 @@ select{ -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -307,7 +307,7 @@ export default { æ·»åŠ createLinearGradientå’ŒcreateRadialGradient属性创建æ¸å˜å®¹å™¨ï¼ŒæŽ¥ç€ç”¨addColorStopæ–¹æ³•æ·»åŠ å¤šä¸ªè‰²å—组æˆæ¸å˜è‰²ï¼Œå†è®¾ç½®fillStyle为gradientå°†æ¸å˜è‰²å¡«å……到矩形ä¸ï¼Œæœ€åŽè®¾ç½®é˜´å½±çš„模糊级别(shadowBlur)ã€é˜´å½±é¢œè‰²ï¼ˆshadowColor)åŠé˜´å½±å移é‡ï¼ˆshadowOffset)。 -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1"></canvas> @@ -321,7 +321,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -344,7 +344,7 @@ select{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -432,7 +432,7 @@ export default { 先创建文本,å†ç”¨fillText方法把文å—写在画布上。通过globalAlpha属性改å˜åŸºçº¿é€æ˜Žåº¦ï¼Œä½¿åŸºçº¿ä¸ä¼šæŒ¡ä½æ–‡å—,å†è®¾ç½®textAlignå’ŒtextBaseline属性确定文å—基于基线的ä½ç½®ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1"></canvas> @@ -445,7 +445,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -468,7 +468,7 @@ select{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -557,7 +557,7 @@ export default {  ->  **说明:** +> **说明:** > ltr布局模å¼ä¸‹startå’Œleft一致,rtl布局模å¼ä¸‹startå’Œright一致·。 @@ -566,7 +566,7 @@ export default { 创建图片对象åŽä½¿ç”¨drawImageå±žæ€§ç”»å‡ºå›¾ç‰‡ï¼Œç»™å›¾ç‰‡è®¾ç½®ä¸€äº›åŠ¨ç”»æ ·å¼å¦‚scale(缩放)ã€translate(平移)或rotate(旋转)。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="content"> @@ -588,7 +588,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -623,7 +623,7 @@ text{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -638,7 +638,7 @@ export default { img.src = 'common/images/2.png'; // 设置图片宽度 img.width= 150; - // 设置图片告度 + // 设置图片高度 img.height=150; // 图片平铺容器 var pat = ctx.createPattern(img, 'repeat');ctx.fillStyle = pat; @@ -728,12 +728,12 @@ export default {  ->  **说明:** +> **说明:** > - setTransfrom方法使用的å‚æ•°å’Œtransform()方法相åŒï¼Œä½†setTransform()方法会é‡ç½®çŽ°æœ‰çš„å˜æ¢çŸ©é˜µå¹¶åˆ›å»ºæ–°çš„å˜æ¢çŸ©é˜µã€‚ -> +> > - å˜æ¢åŽçš„åæ ‡è®¡ç®—æ–¹å¼ï¼ˆxå’Œy为å˜æ¢å‰åæ ‡ï¼Œx'å’Œy'为å˜æ¢åŽåæ ‡ï¼‰ï¼š > x' = scaleX \* x + skewY \* y + translateX -> +> > y' = skewX \* x + scaleY \* y + translateY @@ -742,7 +742,7 @@ export default { save方法å¯å¯¹ç”»ç¬”æ ·å¼è¿›è¡Œå˜å‚¨ï¼Œrestoreå¯å¯¹å˜å‚¨çš„画笔进行æ¢å¤ã€‚如下é¢çš„示例,先设置画笔为红色,在ä¿å˜ç”»ç¬”åŽå¯¹ç”»å¸ƒè¿›è¡Œæ¸…除并改å˜ç”»ç¬”为è“色,当我们直接使用画笔时会画出一个è“色矩形,对å˜å‚¨çš„画笔进行æ¢å¤åŽå°±å¯ç”»å‡ºçº¢è‰²çŸ©å½¢ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="content"> @@ -757,7 +757,7 @@ save方法å¯å¯¹ç”»ç¬”æ ·å¼è¿›è¡Œå˜å‚¨ï¼Œrestoreå¯å¯¹å˜å‚¨çš„ç”»ç¬”è¿›è¡Œæ¢ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -791,7 +791,7 @@ text{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -816,7 +816,8 @@ export default { restore(){ this.ctx.beginPath(); // 画笔æ¢å¤ - this.ctx.restore(); this.ctx.fillRect(200, 150, 200, 200); + this.ctx.restore(); + this.ctx.fillRect(200, 150, 200, 200); }, } ``` diff --git a/zh-cn/application-dev/ui/ui-js-components-chart.md b/zh-cn/application-dev/ui/ui-js-components-chart.md index 7c4d1ee6d9907c5c2c12de9f638d42af1d20a254..339f9697711518d9924aa1ac4112cece6dcdb39b 100644 --- a/zh-cn/application-dev/ui/ui-js-components-chart.md +++ b/zh-cn/application-dev/ui/ui-js-components-chart.md @@ -1,21 +1,21 @@ -# Chartå¼€å‘指导 +# chartå¼€å‘指导 -Chart为图表组件,用于呈现线形图ã€æŸ±çŠ¶å›¾å’Œé‡è§„图界é¢ã€‚具体用法请å‚考[Chart](../reference/arkui-js/js-components-basic-chart.md)。 +chart为图表组件,用于呈现线形图ã€æŸ±çŠ¶å›¾å’Œé‡è§„图界é¢ã€‚具体用法请å‚考[chart](../reference/arkui-js/js-components-basic-chart.md)。 -## 创建Chart组件 +## 创建chart组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªChart组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªchart组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <chart class="chart-data" type="line" options="{{lineOps}}" datasets="{{lineData}}"></chart> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -31,8 +31,8 @@ Chart为图表组件,用于呈现线形图ã€æŸ±çŠ¶å›¾å’Œé‡è§„图界é¢ã€‚å…· } ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { lineData: [ @@ -67,10 +67,10 @@ export default { ## 设置图表类型 -Chart组件通过设置type属性定义图表t类型,如将图表设置为柱状图。 +chart组件通过设置type属性定义图表t类型,如将图表设置为柱状图。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="container"> @@ -108,7 +108,7 @@ Chart组件通过设置type属性定义图表t类型,如将图表设置为柱 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -144,8 +144,8 @@ Chart组件通过设置type属性定义图表t类型,如将图表设置为柱 ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { title: "类型展示", @@ -211,16 +211,16 @@ export default {  ->  **说明:** -> Chartä¸æ”¯æŒæ˜¾ç¤ºæ¯ä¸ªç‚¹çš„值。 +> **说明:** +> chartä¸æ”¯æŒæ˜¾ç¤ºæ¯ä¸ªç‚¹çš„值。 ## 设置图表属性 -Chart组件在options属性ä¸è®¾ç½®å¯¹xè½´ã€y轴和数æ®åºåˆ—å‚数的设置,在datasetså±žæ€§é‡Œæ·»åŠ å¯¹çº¿æ¡é¢œè‰²ã€å¡«å……颜色ã€å¡«å……æ¸å˜é¢œè‰²å’Œç»˜åˆ¶ç‚¹é›†çš„设置。 +chart组件在options属性ä¸è®¾ç½®å¯¹xè½´ã€y轴和数æ®åºåˆ—å‚数的设置,在datasetså±žæ€§é‡Œæ·»åŠ å¯¹çº¿æ¡é¢œè‰²ã€å¡«å……颜色ã€å¡«å……æ¸å˜é¢œè‰²å’Œç»˜åˆ¶ç‚¹é›†çš„设置。 -``` +```html <!-- xxx.hml --> <div class="container"> <chart class="chart-data" type="line" options="{{lineOps}}" datasets="{{lineData}}"></chart> @@ -228,7 +228,7 @@ Chart组件在options属性ä¸è®¾ç½®å¯¹xè½´ã€y轴和数æ®åºåˆ—å‚数的设置 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -245,8 +245,8 @@ Chart组件在options属性ä¸è®¾ç½®å¯¹xè½´ã€y轴和数æ®åºåˆ—å‚数的设置 ``` -``` -/* xxx.js */ +```js +// xxx.js export default { data: { //çº¿å½¢å›¾æ•°æ® @@ -298,20 +298,20 @@ export default { } ``` ->  **说明:** +> **说明:** > - optionsåªæ”¯æŒæŸ±çŠ¶å›¾å’Œçº¿å½¢å›¾è®¾ç½®å‚数,é‡è§„图ä¸ç”Ÿæ•ˆã€‚ -> +> > - datasetsåªæ”¯æŒæŸ±çŠ¶å›¾å’Œçº¿å½¢å›¾è®¾ç½®æ•°æ®é›†åˆï¼Œé‡è§„图ä¸ç”Ÿæ•ˆã€‚ -> +> > - seriesåªæœ‰çº¿å½¢å›¾æ”¯æŒã€‚ ## æ·»åŠ æ•°æ® -通过Chart组件的append方法,实现动æ€æ·»åŠ æ•°æ®ã€‚ +通过chart组件的append方法,实现动æ€æ·»åŠ æ•°æ®ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <stack class="chart-region"> @@ -322,7 +322,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -348,7 +348,7 @@ button { ``` -``` +```js // xxx.js export default { data: { @@ -391,7 +391,12 @@ export default { } }, }, - addData() { this.$refs.linechart.append({ serial: 0, data: [Math.floor(Math.random() * 400) + 200] }) } + addData() { + this.$refs.linechart.append({ + serial: 0, + data: [Math.floor(Math.random() * 400) + 200] + }) + } } ``` @@ -403,7 +408,7 @@ export default { å¼€å‘者å¯ä»¥æ ¹æ®å¼€å…³Switch的状æ€æ¥é€‰æ‹©æ•°æ®å±•ç¤ºçš„状æ€ï¼Œå½“Switch状æ€ä¸ºtrue时,通过定时器æ¥å®žçŽ°æ•°æ®çš„动æ€å±•ç¤ºã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="container"> @@ -452,7 +457,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ display:flex; @@ -490,7 +495,7 @@ export default { ``` -``` +```js // xxx.js export default { data: { @@ -617,8 +622,8 @@ export default { ## 相关实例 -针对Chartå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对chartå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [`Chart`:图表组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) +- [`chart`:图表组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) -- [chart(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SwitchApplication) +- [chart(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SwitchApplication) diff --git a/zh-cn/application-dev/ui/ui-js-components-dialog.md b/zh-cn/application-dev/ui/ui-js-components-dialog.md index 00e1f1c7cd5504c46acb79e9200024bd240cfe07..7d01daf9b39b71b81bb41b9bd9bcda5fe2d3b01f 100644 --- a/zh-cn/application-dev/ui/ui-js-components-dialog.md +++ b/zh-cn/application-dev/ui/ui-js-components-dialog.md @@ -1,12 +1,12 @@ -# Dialog +# dialogå¼€å‘指导 -Dialog组件用于创建自定义弹窗,通常用æ¥å±•ç¤ºç”¨æˆ·å½“å‰éœ€è¦æˆ–用户必须关注的信æ¯æˆ–æ“作。具体用法请å‚考[Dialog API](../reference/arkui-js/js-components-container-dialog.md)。 +dialog组件用于创建自定义弹窗,通常用æ¥å±•ç¤ºç”¨æˆ·å½“å‰éœ€è¦æˆ–用户必须关注的信æ¯æˆ–æ“作。具体用法请å‚考[dialog API](../reference/arkui-js/js-components-container-dialog.md)。 -## 创建Dialog组件 +## 创建dialog组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªDialogç»„ä»¶ï¼Œå¹¶æ·»åŠ Button组件æ¥è§¦å‘Dialog。Dialog组件仅支æŒwidthã€heightã€marginã€margin-[left|top|right|bottom]ã€margin-[start|end]æ ·å¼ã€‚ -``` +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªdialogç»„ä»¶ï¼Œå¹¶æ·»åŠ Button组件æ¥è§¦å‘dialog。dialog组件仅支æŒwidthã€heightã€marginã€margin-[left|top|right|bottom]ã€margin-[start|end]æ ·å¼ã€‚ +```html <!-- xxx.hml --> <div class="doc-page"> <dialog class="dialogClass" id="dialogId" dragable="true"> @@ -14,11 +14,11 @@ Dialog组件用于创建自定义弹窗,通常用æ¥å±•ç¤ºç”¨æˆ·å½“å‰éœ€è¦ <text>this is a dialog</text> </div> </dialog> - <button value="click me" onclick="openDialog"></button> + <button value="click me" onclick="opendialog"></button> </div> ``` -``` +```css /* xxx.css */ .doc-page { width:100%; @@ -51,11 +51,11 @@ button{ } ``` -``` -/* xxx.js */ +```js +// xxx.js export default { //Touch to open the dialog box. - openDialog(){ + opendialog(){ this.$element('dialogId').show() }, } @@ -66,10 +66,10 @@ export default { ## 设置弹窗å“应 -å¼€å‘者点击页é¢ä¸ŠéžDialog的区域时,将触å‘cancel事件而关é—弹窗。åŒæ—¶ä¹Ÿå¯ä»¥é€šè¿‡å¯¹Dialogæ·»åŠ showå’Œclose方法æ¥æ˜¾ç¤ºå’Œå…³é—弹窗。 +å¼€å‘者点击页é¢ä¸Šéždialog的区域时,将触å‘cancel事件而关é—弹窗。åŒæ—¶ä¹Ÿå¯ä»¥é€šè¿‡å¯¹dialogæ·»åŠ showå’Œclose方法æ¥æ˜¾ç¤ºå’Œå…³é—弹窗。 -``` +```html <!-- xxx.hml --> <div class="doc-page"> <dialog class="dialogClass" id="dialogId" oncancel="canceldialog"> @@ -78,12 +78,12 @@ export default { <button value="confirm" onclick="confirmClick"></button> </div> </dialog> - <button value="click me" onclick="openDialog"></button> + <button value="click me" onclick="opendialog"></button> </div> ``` -``` +```css /* xxx.css */ .doc-page { width:100%; @@ -117,8 +117,8 @@ button{ ``` -``` -/* xxx.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { canceldialog(e){ @@ -126,7 +126,7 @@ export default { message: 'dialogCancel' }) }, - openDialog(){ + opendialog(){ this.$element('dialogId').show() prompt.showToast({ message: 'dialogShow' @@ -145,21 +145,21 @@ export default {  ->  **说明:** +> **说明:** > - 仅支æŒå•ä¸ªå组件。 -> -> - Dialog属性ã€æ ·å¼å‡ä¸æ”¯æŒåŠ¨æ€æ›´æ–°ã€‚ -> -> - Dialog组件ä¸æ”¯æŒfocusableã€click-effect属性。 +> +> - dialog属性ã€æ ·å¼å‡ä¸æ”¯æŒåŠ¨æ€æ›´æ–°ã€‚ +> +> - dialog组件ä¸æ”¯æŒfocusableã€click-effect属性。 ## 场景示例 -在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥é€šè¿‡Dialog组件实现一个日程表。弹窗在打开状æ€ä¸‹ï¼Œåˆ©ç”¨[Textarea组件](../reference/arkui-js/js-components-basic-textarea.md)输入当å‰æ—¥ç¨‹ï¼Œç‚¹å‡»ç¡®è®¤æŒ‰é’®åŽèŽ·å–当å‰æ—¶é—´å¹¶ä¿å˜è¾“入文本。最åŽä»¥åˆ—表形å¼å°†å„日程进行展示。 +在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥é€šè¿‡dialog组件实现一个日程表。弹窗在打开状æ€ä¸‹ï¼Œåˆ©ç”¨[Textarea组件](../reference/arkui-js/js-components-basic-textarea.md)输入当å‰æ—¥ç¨‹ï¼Œç‚¹å‡»ç¡®è®¤æŒ‰é’®åŽèŽ·å–当å‰æ—¶é—´å¹¶ä¿å˜è¾“入文本。最åŽä»¥åˆ—表形å¼å°†å„日程进行展示。 -``` +```html <!-- xxx.hml --> <div class="doc-page"> <text style="margin-top: 60px;margin-left: 30px;"> @@ -194,7 +194,7 @@ export default { ``` -``` +```css /* xxx.css */ .doc-page { flex-direction: column; @@ -263,8 +263,8 @@ export default { ``` -``` -/* xxx.js */ +```js +// xxx.js var info = null; import prompt from '@system.prompt'; import router from '@system.router'; @@ -323,8 +323,8 @@ export default { ## 相关实例 -针对Dialogå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对dialogå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`JsDialog`:页é¢å¼¹çª—(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) -- [dialog(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/DialogDemo) +- [Dialog(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/DialogDemo) diff --git a/zh-cn/application-dev/ui/ui-js-components-form.md b/zh-cn/application-dev/ui/ui-js-components-form.md index c14e9d2df6c3aeadd5fbb8b9cafcf02be43ece33..7568eef0ccef5c5dd5548ad571c6b841d0fc93d2 100644 --- a/zh-cn/application-dev/ui/ui-js-components-form.md +++ b/zh-cn/application-dev/ui/ui-js-components-form.md @@ -1,16 +1,16 @@ -# Form +# formå¼€å‘指导 -Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-components-basic-input.md)组件内容的æ交和é‡ç½®ã€‚具体用法请å‚考[Form API](../reference/arkui-js/js-components-container-form.md)。 +form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-components-basic-input.md)组件内容的æ交和é‡ç½®ã€‚具体用法请å‚考[form API](../reference/arkui-js/js-components-container-form.md)。 ->  **说明:** +> **说明:** > 从 API Version 6 开始支æŒã€‚ -## 创建Form组件 +## 创建form组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªForm组件。 -``` +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªform组件。 +```html <!-- xxx.hml --> <div class="container"> <form style="width: 100%; height: 20%"> @@ -19,7 +19,7 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -36,8 +36,8 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp ## 实现表å•ç¼©æ”¾ -为Formç»„ä»¶æ·»åŠ click-effect属性,实现点击表å•åŽçš„缩放效果,click-effect枚举值请å‚考[通用属性](../reference/arkui-js/js-components-common-attributes.md)。 -``` +为formç»„ä»¶æ·»åŠ click-effect属性,实现点击表å•åŽçš„缩放效果,click-effect枚举值请å‚考[通用属性](../reference/arkui-js/js-components-common-attributes.md)。 +```html <!-- xxx.hml --> <div class="container"> <form id="formId" class="formClass" click-effect="spring-large"> @@ -47,13 +47,13 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp ``` -## 设置Formæ ·å¼ +## 设置formæ ·å¼ -通过为Formæ·»åŠ background-colorå’Œborder属性,æ¥è®¾ç½®è¡¨å•çš„背景颜色和边框。 +通过为formæ·»åŠ background-colorå’Œborder属性,æ¥è®¾ç½®è¡¨å•çš„背景颜色和边框。 -``` +```css /* xxx.css */ .container { width: 100%; @@ -77,9 +77,9 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp ## æ·»åŠ å“应事件 -为Formç»„ä»¶æ·»åŠ submitå’Œreset事件,æ¥æ交表å•å†…容或é‡ç½®è¡¨å•é€‰é¡¹ã€‚ +为formç»„ä»¶æ·»åŠ submitå’Œreset事件,æ¥æ交表å•å†…容或é‡ç½®è¡¨å•é€‰é¡¹ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <form onsubmit='onSubmit' onreset='onReset' class="form"> @@ -98,7 +98,7 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp </div> ``` -``` +```css /* index.css */ .container{ width: 100%; @@ -118,8 +118,8 @@ Form是一个表å•å®¹å™¨ï¼Œæ”¯æŒå®¹å™¨å†…[Input](../reference/arkui-js/js-comp } ``` -``` -/* xxx.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default{ onSubmit(result) { @@ -143,14 +143,14 @@ export default{ 在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥é€‰æ‹©ç›¸åº”选项并æ交或é‡ç½®æ•°æ®ã€‚ -创建[Input](../reference/arkui-js/js-components-basic-input.md)组件,分别设置type属性为checkbox(多选框)和radio(å•é€‰æ¡†ï¼‰ï¼Œå†ä½¿ç”¨Form组件的onsubmitå’Œonreset事件实现表å•æ•°æ®çš„æ交与é‡ç½®ã€‚ +创建[Input](../reference/arkui-js/js-components-basic-input.md)组件,分别设置type属性为checkbox(多选框)和radio(å•é€‰æ¡†ï¼‰ï¼Œå†ä½¿ç”¨form组件的onsubmitå’Œonreset事件实现表å•æ•°æ®çš„æ交与é‡ç½®ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <form onsubmit="formSubmit" onreset="formReset"> <text style="font-size: 30px; margin-bottom: 20px; margin-top: 100px;"> - <span > Form </span> + <span > form </span> </text> <div style="flex-direction: column;width: 90%;padding: 30px 0px;"> <text class="txt">Select 1 or more options</text> @@ -180,7 +180,7 @@ export default{ </div> ``` -``` +```css /* index.css */ .container { flex-direction:column; @@ -197,8 +197,8 @@ label{ } ``` -``` -/* xxx.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { formSubmit() { diff --git a/zh-cn/application-dev/ui/ui-js-components-grid.md b/zh-cn/application-dev/ui/ui-js-components-grid.md index e17190343be5be83ce9093b5442358748db529d4..b801fc9f30144d73e2888f3428d9f3665da09e91 100644 --- a/zh-cn/application-dev/ui/ui-js-components-grid.md +++ b/zh-cn/application-dev/ui/ui-js-components-grid.md @@ -9,7 +9,7 @@ 在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªgrid-containerç»„ä»¶ï¼Œå¹¶æ·»åŠ [Grid-row](../reference/arkui-js/js-components-grid-row.md)å组件。 -``` +```html <!-- index.hml --> <div class="container"> <grid-container id="mygrid" columns="5" gutter="20px" style="background-color: pink;"> @@ -22,7 +22,7 @@ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -35,7 +35,7 @@  ->  **说明:** +> **说明:** > grid-container仅支æŒgrid-row为å组件。 @@ -44,7 +44,7 @@ grid-container点击组件调用getColumnsã€getColumnWidthã€getGutterWidthæ–¹æ³•ï¼Œè¿”å›žæ …æ ¼å®¹å™¨åˆ—æ•°ã€column宽度åŠgutter宽度。长按调用getSizeType方法返回当å‰å®¹å™¨å“应尺寸类型(xs|sm|md|lg)。 -``` +```html <!-- index.hml --> <div class="container"> <grid-container id="mygrid" columns="6" gutter="20px" style="background-color: pink;padding-top: 100px;" @@ -61,7 +61,7 @@ grid-container点击组件调用getColumnsã€getColumnWidthã€getGutterWidthæ–¹ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -73,7 +73,7 @@ grid-container点击组件调用getColumnsã€getColumnWidthã€getGutterWidthæ–¹ ``` -``` +```js // index.js import prompt from '@system.prompt'; export default { @@ -113,7 +113,7 @@ export default { 创建grid-containerç»„ä»¶å¹¶æ·»åŠ grid-row,在grid-rowç»„ä»¶å†…æ·»åŠ grild-col组件形æˆå¸ƒå±€ã€‚ -``` +```html <!-- index.hml --> <div class="container"> <grid-container id="mygrid" columns="4" gutter="0" style="background-color: pink;" onclick="getColumns" onlongpress="getSizeType"> @@ -148,7 +148,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -165,7 +165,7 @@ text{  ->  **说明:** +> **说明:** > grid-row仅支æŒgrid-col为å组件,åªèƒ½åœ¨grid-col组件ä¸æ·»åŠ 填充的内容。 @@ -174,7 +174,7 @@ text{ 本场景ä¸å¾ªçŽ¯è¾“出listä¸çš„å†…å®¹ï¼Œåˆ›å»ºå‡ºç½‘æ ¼å¸ƒå±€ã€‚è¿›è¡Œä¸‹æ‹‰æ“时触å‘refresh(刷新页é¢ï¼‰æ–¹æ³•ï¼Œè¿™æ—¶ä¼šå‘list数组ä¸æ·»åŠ 一æ¡æ•°æ®å¹¶è®¾ç½®setTimeout(延迟触å‘),达到刷新请求数æ®çš„效果。 -``` +```html <!-- index.hml --> <div class="container"> <refresh refreshing="{{fresh}}" onrefresh="refresh"> @@ -197,7 +197,7 @@ text{ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -211,7 +211,7 @@ text{ ``` -``` +```js // index.js import prompt from '@system.prompt'; export default { diff --git a/zh-cn/application-dev/ui/ui-js-components-image-animator.md b/zh-cn/application-dev/ui/ui-js-components-image-animator.md index e9fe87f31f9e5127eee4aea5eca80222b31e06f9..420c989789f43d5db64345c682eb162425d88559 100644 --- a/zh-cn/application-dev/ui/ui-js-components-image-animator.md +++ b/zh-cn/application-dev/ui/ui-js-components-image-animator.md @@ -1,15 +1,15 @@ -# Image-animatorå¼€å‘指导 +# image-animatorå¼€å‘指导 -Image-animator组件为图片帧动画æ’放器。具体用法请å‚考[Image-animator](../reference/arkui-js/js-components-basic-image-animator.md)。 +image-animator组件为图片帧动画æ’放器。具体用法请å‚考[image-animator](../reference/arkui-js/js-components-basic-image-animator.md)。 -## 创建Image-animator组件 +## 创建image-animator组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªImage-animator组件,css文件ä¸ç¼–å†™ç»„ä»¶æ ·å¼ï¼Œjs文件ä¸å¼•ç”¨å›¾ç‰‡ã€‚ +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªimage-animator组件,css文件ä¸ç¼–å†™ç»„ä»¶æ ·å¼ï¼Œjs文件ä¸å¼•ç”¨å›¾ç‰‡ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <image-animator class="animator" images="{{frames}}" duration="3s"/> @@ -17,7 +17,7 @@ Image-animator组件为图片帧动画æ’放器。具体用法请å‚考[Image-an ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -34,8 +34,8 @@ Image-animator组件为图片帧动画æ’放器。具体用法请å‚考[Image-an ``` -``` -/* index.js */ +```js +// index.js export default { data: { frames: [ @@ -53,12 +53,12 @@ export default {  -## 设置Image-animator组件属性 +## 设置image-animator组件属性 æ·»åŠ iteration(æ’放次数)ã€reverse(æ’放顺åºï¼‰ã€fixedsize(图片大å°æ˜¯å¦å›ºå®šä¸ºç»„件大å°ï¼‰ã€duration(æ’放时长)和fillmode(执行结æŸåŽçš„状æ€ï¼‰å±žæ€§ï¼ŒæŽ§åˆ¶å›¾ç‰‡çš„æ’放效果。 -``` +```html <!-- xxx.hml --> <div class="container"> <image-animator class="animator" fixedsize="false" iteration='2' reverse="false" ref="animator" fillmode="none" images="{{frames}}" duration="5s" /> @@ -66,7 +66,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -81,8 +81,8 @@ export default { ``` -``` -/* index.js */ +```js +// index.js export default { data: { frames: [ @@ -135,20 +135,20 @@ export default {  ->  **说明:** -> - 如果在images属性ä¸è®¾ç½®äº†å•ç‹¬çš„duration属性,在Image-animator组件ä¸è®¾ç½®çš„durationå±žæ€§æ— æ•ˆã€‚ -> +> **说明:** +> - 如果在images属性ä¸è®¾ç½®äº†å•ç‹¬çš„duration属性,在image-animator组件ä¸è®¾ç½®çš„durationå±žæ€§æ— æ•ˆã€‚ +> > - 如果fixedsize属性值设置为true,图片的width ã€height ã€top å’Œleftå±žæ€§æ— æ•ˆã€‚ -> +> > - 如果reverse属性值设置为false,表示从第1å¼ å›¾ç‰‡æ’放到最åŽ1å¼ å›¾ç‰‡ã€‚ 如果reverse属性值设置为true,表示从最åŽ1å¼ å›¾ç‰‡æ’放到第1å¼ å›¾ç‰‡ã€‚ ## 绑定事件 -å‘Image-animatorç»„ä»¶æ·»åŠ startã€pauseã€stopå’Œresume事件。当图片æ’放器开始æ’放时触å‘start事件,当图片æ’放器被点击时触å‘pause事件,长按图片æ’放器触å‘resume事件,图片æ’放器åœæ¢æ’放时触å‘stop事件。 +å‘image-animatorç»„ä»¶æ·»åŠ startã€pauseã€stopå’Œresume事件。当图片æ’放器开始æ’放时触å‘start事件,当图片æ’放器被点击时触å‘pause事件,长按图片æ’放器触å‘resume事件,图片æ’放器åœæ¢æ’放时触å‘stop事件。 -``` +```html <!-- xxx.hml --> <div class="doc-page"> <image-animator class="img" id="img" images="{{imginfo}}" iteration="1" duration="10s" onstart="popstart" onpause="poppause" onstop="popstop" onresume="popresume" onlongpress="setresume" onclick="setpause"> @@ -157,7 +157,7 @@ export default { ``` -``` +```css /* xxx.css */ .doc-page { width: 100%; @@ -175,8 +175,8 @@ export default { ``` -``` -/* index.js */ +```js +// index.js import prompt from '@system.prompt'; export default { data: { @@ -230,10 +230,10 @@ export default { 在本场景ä¸ï¼Œå¼€å‘者å¯é€šè¿‡å¼€å§‹æ’放ã€åœæ¢æ’放ç‰æŒ‰é’®åˆ‡æ¢å›¾ç‰‡çš„æ’放状æ€ã€‚ -Image-animator组件通过调用startã€pauseã€stopå’Œresume方法控制图片的开始ã€æš‚åœã€åœæ¢å’Œé‡æ–°æ’放,通过getState方法查询图片的æ’放状æ€ã€‚ +image-animator组件通过调用startã€pauseã€stopå’Œresume方法控制图片的开始ã€æš‚åœã€åœæ¢å’Œé‡æ–°æ’放,通过getState方法查询图片的æ’放状æ€ã€‚ -``` +```html <!-- xxx.hml --> <div class="doc-page"> <image-animator class="img" id="img" images="{{imginfo}}" iteration="2" reverse="{{rev}}" duration="10s"> @@ -256,7 +256,7 @@ Image-animator组件通过调用startã€pauseã€stopå’Œresume方法控制图片 ``` -``` +```css /* xxx.css */ .doc-page { width: 100%; @@ -283,8 +283,8 @@ button{ ``` -``` -/* index.js */ +```js +// index.js import prompt from '@system.prompt'; export default { data: { @@ -337,6 +337,6 @@ export default { ## 相关实例 -针对Image-animatorå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对image-animatorå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [imageã€image-animator(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ClickableJsDemo) +- [imageã€image-animator(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ClickableJsDemo) diff --git a/zh-cn/application-dev/ui/ui-js-components-images.md b/zh-cn/application-dev/ui/ui-js-components-images.md index b7f9d9fb580e6998ef43c5232d6a2fb1669e9c3d..6ef8576c64b4ec9a95f747bf0454922f2f03736a 100644 --- a/zh-cn/application-dev/ui/ui-js-components-images.md +++ b/zh-cn/application-dev/ui/ui-js-components-images.md @@ -1,19 +1,19 @@ -# Image +# imageå¼€å‘指导 -Image是图片组件,用æ¥æ¸²æŸ“展示图片。具体用法请å‚考[Image API](../reference/arkui-js/js-components-basic-image.md)。 +image是图片组件,用æ¥æ¸²æŸ“展示图片。具体用法请å‚考[image API](../reference/arkui-js/js-components-basic-image.md)。 -## 创建Image组件 +## 创建image组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªImage组件。 -``` +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªimage组件。 +```html <!-- index.hml --> <div class="container"> <image style="height: 30%;" src="common/images/bg-tv.jpg"> </image> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -28,12 +28,12 @@ Image是图片组件,用æ¥æ¸²æŸ“展示图片。具体用法请å‚考[Image AP  -## 设置Imageæ ·å¼ +## 设置imageæ ·å¼ é€šè¿‡è®¾ç½®widthã€heightå’Œobject-fit属性定义图片的宽ã€é«˜å’Œç¼©æ”¾æ ·å¼ã€‚ -``` +```html <!-- index.hml --> <div class="container"> <image src="common/images/bg-tv.jpg"> </image> @@ -41,7 +41,7 @@ Image是图片组件,用æ¥æ¸²æŸ“展示图片。具体用法请å‚考[Image AP ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -69,7 +69,7 @@ image{ 图片æˆåŠŸåŠ 载时触å‘completeäº‹ä»¶ï¼Œè¿”å›žåŠ è½½çš„å›¾æºå°ºå¯¸ã€‚åŠ è½½å¤±è´¥åˆ™è§¦å‘error事件,打å°å›¾ç‰‡åŠ 载失败。 -``` +```html <!-- index.hml --> <div class="container" > <div> @@ -81,7 +81,7 @@ image{ </div> ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -99,13 +99,13 @@ image{ } ``` -``` -/* index.js */ +```js +// index.js import prompt from '@system.prompt'; export default { imageComplete(i,e){ prompt.showToast({ - message: "Image "+i+"'s width"+ e.width+"----Image "+i+"'s height"+e.height, + message: "image "+i+"'s width"+ e.width+"----image "+i+"'s height"+e.height, duration: 3000, }) }, @@ -127,7 +127,7 @@ export default { ## 场景示例 在本场景ä¸ï¼Œå¼€å‘者长按图片åŽå°†æ…¢æ…¢éšè—图片,当完全éšè—åŽå†é‡æ–°æ˜¾ç¤ºåŽŸå§‹å›¾ç‰‡ã€‚定时器setIntervalæ¯éš”一段时间改å˜å›¾ç‰‡é€æ˜Žåº¦,实现慢慢éšè—的效果,当é€æ˜Žåº¦ä¸º0时清除定时器,设置é€æ˜Žåº¦ä¸º1。 -``` +```html <!-- index.hml --> <div class="page-container"> <div class="content"> @@ -141,7 +141,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .page-container { width: 100%; @@ -175,8 +175,8 @@ export default { } ``` -``` -/* index.js */ +```js +// index.js import prompt from '@system.prompt'; export default { data: { @@ -206,8 +206,8 @@ export default { ## 相关实例 -针对Imageå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对imageå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [imageã€image-animator(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ClickableJsDemo) +- [imageã€image-animator(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ClickableJsDemo) -- [图片编辑模æ¿](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageEditorTemplate) \ No newline at end of file +- [图片编辑模æ¿ï¼ˆJS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageEditorTemplate) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-input.md b/zh-cn/application-dev/ui/ui-js-components-input.md index a94be316352c467acc2c81c25e56cc7b05f01681..391c88d5da258a50e04a9f1a1a13730b48de5658 100644 --- a/zh-cn/application-dev/ui/ui-js-components-input.md +++ b/zh-cn/application-dev/ui/ui-js-components-input.md @@ -1,20 +1,22 @@ -# Input +# inputå¼€å‘指导 -Input是交互å¼ç»„件,用于接收用户数æ®ã€‚其类型å¯è®¾ç½®ä¸ºæ—¥æœŸã€å¤šé€‰æ¡†å’ŒæŒ‰é’®ç‰ã€‚具体用法请å‚考[Input API](../reference/arkui-js/js-components-basic-input.md)。 +input是交互å¼ç»„件,用于接收用户数æ®ã€‚其类型å¯è®¾ç½®ä¸ºæ—¥æœŸã€å¤šé€‰æ¡†å’ŒæŒ‰é’®ç‰ã€‚具体用法请å‚考[input API](../reference/arkui-js/js-components-basic-input.md)。 -## 创建Input组件 +## 创建input组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªInput组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªinput组件。 -``` +```html <!-- xxx.hml --> <div class="container"> - <input type="text"> Please enter the content </input> + <input type="text"> + Please enter the content + </input> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -29,11 +31,11 @@ Input是交互å¼ç»„件,用于接收用户数æ®ã€‚其类型å¯è®¾ç½®ä¸ºæ—¥æœŸ  -## 设置Input类型 +## 设置input类型 -通过设置type属性æ¥å®šä¹‰Input类型,如将Input设置为buttonã€dateç‰ã€‚ +通过设置type属性æ¥å®šä¹‰input类型,如将input设置为buttonã€dateç‰ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="div-button"> @@ -53,7 +55,7 @@ Input是交互å¼ç»„件,用于接收用户数æ®ã€‚其类型å¯è®¾ç½®ä¸ºæ—¥æœŸ </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -87,7 +89,7 @@ Input是交互å¼ç»„件,用于接收用户数æ®ã€‚其类型å¯è®¾ç½®ä¸ºæ—¥æœŸ } ``` -``` +```js // xxx.js export default { btnclick(){ @@ -100,15 +102,15 @@ export default {  ->  **说明:** +> **说明:** > -> 仅当Input类型为checkboxå’Œradio时,当å‰ç»„件是å¦é€‰ä¸çš„属性checkedæ‰ç”Ÿæ•ˆï¼Œé»˜è®¤å€¼ä¸ºfalse。 +> 仅当input类型为checkboxå’Œradio时,当å‰ç»„件是å¦é€‰ä¸çš„属性checkedæ‰ç”Ÿæ•ˆï¼Œé»˜è®¤å€¼ä¸ºfalse。 ## 事件绑定 -å‘Inputç»„ä»¶æ·»åŠ searchå’Œtranslate事件。 -``` +å‘inputç»„ä»¶æ·»åŠ searchå’Œtranslate事件。 +```html <!-- xxx.hml --> <div class="content"> <text style="margin-left: -7px;"> @@ -119,7 +121,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .content { width: 100%; @@ -141,7 +143,7 @@ text{ } ``` -``` +```js // xxx.js import prompt from '@system.prompt' export default { @@ -165,9 +167,9 @@ export default { ## 设置输入æ示 -通过对Inputç»„ä»¶æ·»åŠ showError方法æ¥æç¤ºè¾“å…¥çš„é”™è¯¯åŽŸå› ã€‚ +通过对inputç»„ä»¶æ·»åŠ showError方法æ¥æç¤ºè¾“å…¥çš„é”™è¯¯åŽŸå› ã€‚ -``` +```html <!-- xxx.hml --> <div class="content"> <input id="input" class="input" type="text" maxlength="20" placeholder="Please input text" onchange="change"> @@ -176,7 +178,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .content { width: 100%; @@ -196,7 +198,7 @@ export default { } ``` -``` +```js // xxx.js import prompt from '@system.prompt' export default { @@ -212,9 +214,13 @@ import prompt from '@system.prompt' }, buttonClick(e){ if(this.value.length > 6){ - this.$element("input").showError({ error: 'Up to 6 characters are allowed.' }); + this.$element("input").showError({ + error: 'Up to 6 characters are allowed.' + }); }else if(this.value.length == 0){ - this.$element("input").showError({ error:this.value + 'This field cannot be left empty.' }); + this.$element("input").showError({ + error:this.value + 'This field cannot be left empty.' + }); }else{ prompt.showToast({ message: "success " @@ -226,17 +232,17 @@ import prompt from '@system.prompt'  ->  **说明:** -> 该方法在Input类型为textã€emailã€dateã€timeã€numberå’Œpassword时生效。 +> **说明:** +> 该方法在input类型为textã€emailã€dateã€timeã€numberå’Œpassword时生效。 ## 场景示例 -æ ¹æ®åœºæ™¯é€‰æ‹©ä¸åŒç±»åž‹çš„Input输入框,完æˆä¿¡æ¯å½•å…¥ã€‚ +æ ¹æ®åœºæ™¯é€‰æ‹©ä¸åŒç±»åž‹çš„input输入框,完æˆä¿¡æ¯å½•å…¥ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="label-item"> @@ -265,7 +271,7 @@ import prompt from '@system.prompt' ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -294,7 +300,7 @@ label { ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -316,6 +322,6 @@ export default { ## 相关实例 -针对Inputå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对inputå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [inputã€label(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/InputApplication) +- [inputã€label(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/InputApplication) diff --git a/zh-cn/application-dev/ui/ui-js-components-list.md b/zh-cn/application-dev/ui/ui-js-components-list.md index 858e7ce407f85079702f317a2d7af9d4f6ee5085..44a12641e5574bed96564e0fc9bf9fb83663393d 100644 --- a/zh-cn/application-dev/ui/ui-js-components-list.md +++ b/zh-cn/application-dev/ui/ui-js-components-list.md @@ -1,14 +1,14 @@ -# List +# listå¼€å‘指导 -List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项,适åˆè¿žç»ã€å¤šè¡Œåœ°å‘ˆçŽ°åŒç±»æ•°æ®ã€‚具体用法请å‚考[List API](../reference/arkui-js/js-components-container-list.md)。 +list是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项,适åˆè¿žç»ã€å¤šè¡Œåœ°å‘ˆçŽ°åŒç±»æ•°æ®ã€‚具体用法请å‚考[list API](../reference/arkui-js/js-components-container-list.md)。 -## 创建List组件 +## 创建list组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªList组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªlist组件。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <list> <list-item class="listItem"></list-item> @@ -19,7 +19,7 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -37,7 +37,7 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项,  ->  **说明:** +> **说明:** > - <list-item-group>是<list>çš„å组件,实现列表分组功能,ä¸èƒ½å†åµŒå¥—<list>,å¯ä»¥åµŒå¥—<list-item>。 > > - <list-item>是<list>çš„å组件,展示列表的具体项。 @@ -47,8 +47,8 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, 设置scrollbar属性为onå³å¯åœ¨å±å¹•å³ä¾§ç”Ÿæˆæ»šåŠ¨æ¡ï¼Œå®žçŽ°é•¿åˆ—表或者å±å¹•æ»šåŠ¨ç‰æ•ˆæžœã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <list class="listCss" scrollbar="on" > <list-item class="listItem"></list-item> @@ -61,8 +61,8 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { flex-direction: column; background-color: #F1F3F5; @@ -86,8 +86,8 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, 设置indexer属性为自定义索引时,索引æ 会显示在列表å³è¾¹ç•Œå¤„,indexer属性设置为true,默认为å—æ¯ç´¢å¼•è¡¨ã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <list class="listCss" indexer="{{['#','1','2','3','4','5','6','7','8']}}" > <list-item class="listItem" section="#" ></list-item> @@ -95,8 +95,8 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container{ flex-direction: column; background-color: #F1F3F5; @@ -110,7 +110,7 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项,  ->  **说明:** +> **说明:** > - indexer属性生效需è¦flex-direction属性é…åˆè®¾ç½®ä¸ºcolumn,且columns属性设置为1。 > > - indexerå¯ä»¥è‡ªå®šä¹‰ç´¢å¼•è¡¨ï¼Œè‡ªå®šä¹‰æ—¶"\#"å¿…é¡»è¦å˜åœ¨ã€‚ @@ -118,10 +118,10 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, ## 实现列表折å 和展开 -为Listç»„ä»¶æ·»åŠ groupcollapseå’Œgroupexpand事件实现列表的折å 和展开。 +为listç»„ä»¶æ·»åŠ groupcollapseå’Œgroupexpand事件实现列表的折å 和展开。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="doc-page"> <list style="width: 100%;" id="mylist"> <list-item-group for="listgroup in list" id="{{listgroup.value}}" ongroupcollapse="collapse" ongroupexpand="expand"> @@ -140,8 +140,8 @@ List是用æ¥æ˜¾ç¤ºåˆ—表的组件,包å«ä¸€ç³»åˆ—相åŒå®½åº¦çš„列表项, </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .doc-page { flex-direction: column; background-color: #F1F3F5; @@ -160,7 +160,7 @@ margin-top:30px; } ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -193,7 +193,7 @@ export default {  ->  **说明:** +> **说明:** > > - groupcollapseå’Œgroupexpand事件仅支æŒlist-item-group组件使用。 @@ -203,8 +203,8 @@ export default { 在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥æ ¹æ®å—æ¯ç´¢å¼•è¡¨æŸ¥æ‰¾å¯¹åº”è”系人。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="doc-page"> <text style="font-size: 35px; font-weight: 500; text-align: center; margin-top: 20px; margin-bottom: 20px;"> <span>Contacts</span> @@ -228,8 +228,8 @@ export default { ``` -``` -/* index.css */ +```css +/* xxx.css */ .doc-page { width: 100%; height: 100%; @@ -265,7 +265,7 @@ export default { ``` -``` +```js // xxx.js export default { data: { @@ -312,6 +312,6 @@ export default { ## 相关实例 -针对Listå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对listå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`JsList`:商å“列表(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsList) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-marquee.md b/zh-cn/application-dev/ui/ui-js-components-marquee.md index aac425fa09ec1f376df47809d26a775dfe140627..f711b61e755f78da710ee8d41f987845a4b78fe8 100644 --- a/zh-cn/application-dev/ui/ui-js-components-marquee.md +++ b/zh-cn/application-dev/ui/ui-js-components-marquee.md @@ -1,15 +1,15 @@ -# Marqueeå¼€å‘指导 +# marqueeå¼€å‘指导 -Marquee为跑马ç¯ç»„件,用于展示一段å•è¡Œæ»šåŠ¨çš„æ–‡å—。具体用法请å‚考[marquee](../reference/arkui-js/js-components-basic-marquee.md)。 +marquee为跑马ç¯ç»„件,用于展示一段å•è¡Œæ»šåŠ¨çš„æ–‡å—。具体用法请å‚考[marquee](../reference/arkui-js/js-components-basic-marquee.md)。 -## 创建Marquee组件 +## 创建marquee组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªMarquee组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªmarquee组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <marquee style="width: 100%;height: 80px; color: #ffffff; background-color: #0820ef;padding-left: 200px;">This is a marquee.</marquee> @@ -17,7 +17,7 @@ Marquee为跑马ç¯ç»„件,用于展示一段å•è¡Œæ»šåŠ¨çš„æ–‡å—。具体用 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -34,18 +34,18 @@ Marquee为跑马ç¯ç»„件,用于展示一段å•è¡Œæ»šåŠ¨çš„æ–‡å—。具体用 ## è®¾ç½®å±žæ€§å’Œæ ·å¼ -Marquee通过colorå’Œfont-weight属性设置跑马ç¯ä¸æ–‡æœ¬çš„颜色ã€å—ä½“ç²—ç»†å’Œè¾¹æ¡†æ ·å¼ã€‚ +marquee通过colorå’Œfont-weight属性设置跑马ç¯ä¸æ–‡æœ¬çš„颜色ã€å—ä½“ç²—ç»†å’Œè¾¹æ¡†æ ·å¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> - <marquee class="customMarquee">It's a racing lamp.</marquee> + <marquee class="custommarquee">It's a racing lamp.</marquee> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -55,7 +55,7 @@ Marquee通过colorå’Œfont-weight属性设置跑马ç¯ä¸æ–‡æœ¬çš„颜色ã€å—体 align-items: center; background-color: #F1F3F5; } -.customMarquee { +.custommarquee { width: 100%; height: 80px; padding: 10px; @@ -74,7 +74,7 @@ Marquee通过colorå’Œfont-weight属性设置跑马ç¯ä¸æ–‡æœ¬çš„颜色ã€å—体 通过scrollamountã€loopå’Œdirection属性实现跑马ç¯æ»šåŠ¨æ—¶ç§»åŠ¨çš„最大长度ã€æ»šåŠ¨æ¬¡æ•°å’Œæ–‡å—滚动方å‘。 -``` +```html <!-- xxx.hml --> <div class="tutorial-page"> <div class="mymarquee"> @@ -90,7 +90,7 @@ Marquee通过colorå’Œfont-weight属性设置跑马ç¯ä¸æ–‡æœ¬çš„颜色ã€å—体 ``` -``` +```css /* xxx.css */ .tutorial-page { width: 750px; @@ -124,7 +124,7 @@ button{ ``` -``` +```js // xxx.js export default { private: { @@ -144,7 +144,7 @@ export default { } ``` ->  **说明:** +> **说明:** > 当loop的值å°äºŽç‰äºŽé›¶æ—¶ï¼Œè·‘马ç¯marquee将连ç»æ»šåŠ¨ã€‚如果loop未指定,则默认为-1。  @@ -157,7 +157,7 @@ export default { 跑马ç¯çš„次数设置为1,在结æŸçš„时候触å‘finish事件使跑马ç¯çš„æ¬¡æ•°åŠ 1,å—体颜色å˜ä¸ºéšæœºé¢œè‰²ï¼Œè°ƒç”¨start方法使跑马ç¯å†æ¬¡å¼€å§‹æ»šåŠ¨ã€‚ -``` +```html <!-- xxx.hml --> <div class="tutorial-page"> <div class="mymarquee"> @@ -174,7 +174,7 @@ export default { ``` -``` +```css /* xxx.css */ .tutorial-page { width: 750px; @@ -204,7 +204,7 @@ button{ ``` -``` +```js // xxx.js export default { private: { diff --git a/zh-cn/application-dev/ui/ui-js-components-menu.md b/zh-cn/application-dev/ui/ui-js-components-menu.md index 5f30f662d8b8b15cd4e41fba230ba359474bcae2..94fd6501423e43f0b4e79b5e56968cc02f7f01aa 100644 --- a/zh-cn/application-dev/ui/ui-js-components-menu.md +++ b/zh-cn/application-dev/ui/ui-js-components-menu.md @@ -1,15 +1,15 @@ -# Menu +# menuå¼€å‘指导 -æä¾›èœå•ç»„件,作为临时性弹出窗å£ï¼Œç”¨äºŽå±•ç¤ºç”¨æˆ·å¯æ‰§è¡Œçš„æ“作,具体用法请å‚考[Menu](../reference/arkui-js/js-components-basic-menu.md)。 +æä¾›èœå•ç»„件,作为临时性弹出窗å£ï¼Œç”¨äºŽå±•ç¤ºç”¨æˆ·å¯æ‰§è¡Œçš„æ“作,具体用法请å‚考[menu](../reference/arkui-js/js-components-basic-menu.md)。 -## 创建Menu组件 +## 创建menu组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªMenuç»„ä»¶ï¼Œæ·»åŠ targetã€typeã€title属性。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªmenuç»„ä»¶ï¼Œæ·»åŠ targetã€typeã€title属性。 -``` +```html <!-- xxx.hml--> <div class="container"> <text class="title-text" id="textId">show menu</text> @@ -22,7 +22,7 @@ ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -40,10 +40,10 @@  ->  **说明:** -> - Menu仅支æŒ[option](../reference/arkui-js/js-components-basic-option.md)å组件。 -> -> - Menu组件ä¸æ”¯æŒfocusableã€disabled属性。 +> **说明:** +> - menu仅支æŒ[option](../reference/arkui-js/js-components-basic-option.md)å组件。 +> +> - menu组件ä¸æ”¯æŒfocusableã€disabled属性。 ## è®¾ç½®æ ·å¼ @@ -51,7 +51,7 @@ 为menuç»„ä»¶è®¾ç½®æ ·å¼ï¼Œä¾‹å¦‚å—体颜色ã€å¤§å°ã€å—符间è·ç‰ã€‚ -``` +```html <!-- xxx.hml--> <div class="container"> <text class="title-text" id="textId">show menu</text> @@ -64,7 +64,7 @@ ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -103,7 +103,7 @@ option{ 为menu组件绑定onselected事件(èœå•ä¸æŸä¸ªå€¼è¢«ç‚¹å‡»é€‰ä¸æ—¶è§¦å‘)和oncancel事件(å–消æ“作时触å‘),点击text组件调用show方法å¯è®¾ç½®menu组件的åæ ‡ã€‚ -``` +```html <!-- xxx.hml--> <div class="container"> <text class="title-text" id="textId" onclick="textClick">show menu</text> @@ -116,7 +116,7 @@ option{ ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -148,8 +148,8 @@ option{ ``` -``` -// index.js +```js +// xxx.js import prompt from '@system.prompt'; export default { select(e) { @@ -176,7 +176,7 @@ export default { 本场景ä¸å¼€å‘者å¯ç‚¹å‡»toggle组件修改文å—颜色,选择menu组件修改æ¸å˜è‰²å—大å°ã€‚ -``` +```html <!-- xxx.hml--> <div class="container"> <div class="contentToggle"> @@ -192,7 +192,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -240,8 +240,8 @@ option{ ``` -``` -// index.js +```js +// xxx.js import prompt from '@system.prompt'; export default { data:{ @@ -281,6 +281,6 @@ export default { ## 相关实例 -针对Menuå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对menuå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`JSMenu`:èœå•ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSMenu) diff --git a/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md b/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md index f645c710a356f4a369c8bda538eccea9649b2ea9..e6fd3a0e2f16ec6fb9dd088ea96188e7e08084c7 100644 --- a/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md +++ b/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md @@ -4,7 +4,7 @@ 以下示例创建了一个OffscreenCanvas画布,å†åœ¨ç”»å¸ƒä¸Šåˆ›å»ºä¸€ä¸ªgetContext2d对象,并设置filter属性改å˜å›¾ç‰‡æ ·å¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas1"></canvas> @@ -23,7 +23,7 @@ </div> ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -45,7 +45,7 @@ select{ } ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -89,7 +89,7 @@ export default { 使用isPointInPath判æ–åæ ‡ç‚¹æ˜¯å¦åœ¨è·¯å¾„的区域内,使用isPointInStroke判æ–åæ ‡ç‚¹æ˜¯å¦åœ¨è·¯å¾„的边缘线上,并在页é¢ä¸Šæ˜¾ç¤ºè¿”回结果。 -``` +```html <!-- xxx.hml --> <div class="container"> <div class="content"> @@ -103,7 +103,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -136,7 +136,7 @@ button{ ``` -``` +```js // xxx.js export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-components-path2d.md b/zh-cn/application-dev/ui/ui-js-components-path2d.md index f5e8690de8ab83fbecaf8ba481c2af6313fcb7b5..da7e1bc8c413d116b1e31a3459ea5abf2ce014ad 100644 --- a/zh-cn/application-dev/ui/ui-js-components-path2d.md +++ b/zh-cn/application-dev/ui/ui-js-components-path2d.md @@ -8,14 +8,14 @@ 创建Path2D,使用多æ¡çº¿æ®µç»„åˆå›¾å½¢ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas"></canvas> </div> ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -32,7 +32,7 @@ canvas{ } ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -81,7 +81,7 @@ export default { 先使用createPath2D创建出路径对象,åªå¯¹path1路径进行æ边,所以画布上就åªä¼šå‡ºçŽ°path1的路径图形。点击text组件触å‘addPath方法会把path2路径对象当å‚æ•°ä¼ å…¥path1ä¸ï¼Œå†å¯¹path1对象进行æ边(stroke)æ“作åŽç”»å¸ƒå‡ºçŽ°path1å’Œpath2两个图形。点击change文本改å˜setTransform属性值为setTransform(2, 0.1, 0.1, 2, 0,0),图形å˜å¤§å¹¶å‘左倾斜。 -``` +```html <!-- xxx.hml --> <div class="container"> <canvas ref="canvas"></canvas> @@ -93,7 +93,7 @@ export default { ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -128,7 +128,7 @@ text{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -162,7 +162,8 @@ export default { this.isAdd = "clearPath2" }else{ this.ctx.clearRect(0,0,600,600) - this.ctx.stroke(this.path1); this.isAdd = "addPath2" + this.ctx.stroke(this.path1); + this.isAdd = "addPath2" } }, setTransform(){ @@ -170,10 +171,16 @@ export default { this.ctx.clearRect(0,0,600,600) this.path3 = this.ctx.createPath2D(); this.path3.arc(150, 150, 100, 0, 6.28) - this.path3.setTransform(2, 0.1, 0.1, 2, 0,0); this.ctx.stroke(this.path3); this.isChange = !this.isChange; this.textName = "back" + this.path3.setTransform(2, 0.1, 0.1, 2, 0,0); + this.ctx.stroke(this.path3); + this.isChange = !this.isChange; + this.textName = "back" }else{ this.ctx.clearRect(0,0,600,600) - this.path3.setTransform(0.5, -0.1, -0.1, 0.5, 0,0);this.ctx.stroke(this.path3);this.isChange = !this.isChange; this.textName = "change" + this.path3.setTransform(0.5, -0.1, -0.1, 0.5, 0,0); + this.ctx.stroke(this.path3); + this.isChange = !this.isChange; + this.textName = "change" } }, } diff --git a/zh-cn/application-dev/ui/ui-js-components-picker.md b/zh-cn/application-dev/ui/ui-js-components-picker.md index eea53de79480a2ed54a58a4fdcb20dc3d5be06e4..2f8397377b8cd3456668c459f15aaeb704685ab8 100644 --- a/zh-cn/application-dev/ui/ui-js-components-picker.md +++ b/zh-cn/application-dev/ui/ui-js-components-picker.md @@ -1,21 +1,21 @@ -# Picker +# pickerå¼€å‘指导 -Picker是滑动选择器组件,类型支æŒæ™®é€šé€‰æ‹©å™¨ã€æ—¥æœŸé€‰æ‹©å™¨ã€æ—¶é—´é€‰æ‹©å™¨ã€æ—¶é—´æ—¥æœŸé€‰æ‹©å™¨å’Œå¤šåˆ—文本选择器。具体用法请å‚考[Picker API](../reference/arkui-js/js-components-basic-picker.md)。 +picker是滑动选择器组件,类型支æŒæ™®é€šé€‰æ‹©å™¨ã€æ—¥æœŸé€‰æ‹©å™¨ã€æ—¶é—´é€‰æ‹©å™¨ã€æ—¶é—´æ—¥æœŸé€‰æ‹©å™¨å’Œå¤šåˆ—文本选择器。具体用法请å‚考[picker API](../reference/arkui-js/js-components-basic-picker.md)。 -## 创建Picker组件 +## 创建picker组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªPicker组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªpicker组件。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <picker> picker </picker> <div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width: 100%; height: 100%; @@ -29,20 +29,20 @@ Picker是滑动选择器组件,类型支æŒæ™®é€šé€‰æ‹©å™¨ã€æ—¥æœŸé€‰æ‹©å™¨  -## 设置Picker类型 +## 设置picker类型 -通过设置Pickerçš„type属性æ¥é€‰æ‹©æ»‘动选择器类型,如定义Picker为日期选择器。 +通过设置pickerçš„type属性æ¥é€‰æ‹©æ»‘动选择器类型,如定义picker为日期选择器。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <picker id="picker_text" type="text" value="{{textvalue}}"range="{{rangetext}}" class="pickertext" ></picker> <picker id="picker_date" type="date" value="{{datevalue}}" lunarswitch="true" start="2002-2-5" end="2030-6-5" class="pickerdate"></picker> </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width: 100%; height: 100%; @@ -56,7 +56,7 @@ Picker是滑动选择器组件,类型支æŒæ™®é€šé€‰æ‹©å™¨ã€æ—¥æœŸé€‰æ‹©å™¨ } ``` -``` +```js // xxx.js export default { data: { @@ -69,25 +69,25 @@ export default {  ->  **说明:** +> **说明:** > > 普通选择器设置å–值范围时,需è¦ä½¿ç”¨æ•°æ®ç»‘定的方å¼ã€‚ ## è®¾ç½®æ—¶é—´å±•çŽ°æ ¼å¼ -Pickerçš„hourså±žæ€§å®šä¹‰æ—¶é—´çš„å±•çŽ°æ ¼å¼ï¼Œå¯é€‰ç±»åž‹æœ‰12å°æ—¶åˆ¶å’Œ24å°æ—¶åˆ¶ã€‚ +pickerçš„hourså±žæ€§å®šä¹‰æ—¶é—´çš„å±•çŽ°æ ¼å¼ï¼Œå¯é€‰ç±»åž‹æœ‰12å°æ—¶åˆ¶å’Œ24å°æ—¶åˆ¶ã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <picker id="picker_time" type="time" value="12-hour format" hours="12" onchange="timeonchange" class="pickertime"></picker> <picker id="picker_time" type="time" value="24-hour format" hours="24" onchange="timeonchange" class="pickertime"></picker> </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width: 100%; height: 100%; @@ -105,7 +105,7 @@ Pickerçš„hourså±žæ€§å®šä¹‰æ—¶é—´çš„å±•çŽ°æ ¼å¼ï¼Œå¯é€‰ç±»åž‹æœ‰12å°æ—¶åˆ¶å’Œ2  ->  **说明:** +> **说明:** > - hours属性为12:按照12å°æ—¶åˆ¶æ˜¾ç¤ºï¼Œç”¨ä¸Šåˆå’Œä¸‹åˆè¿›è¡ŒåŒºåˆ†ï¼› > > - hours属性为24:按照24å°æ—¶åˆ¶æ˜¾ç¤ºã€‚ @@ -113,18 +113,18 @@ Pickerçš„hourså±žæ€§å®šä¹‰æ—¶é—´çš„å±•çŽ°æ ¼å¼ï¼Œå¯é€‰ç±»åž‹æœ‰12å°æ—¶åˆ¶å’Œ2 ## æ·»åŠ å“应事件 -对Pickeræ·»åŠ changeå’Œcancel事件,æ¥å¯¹é€‰æ‹©çš„内容进行确定和å–消。 +对pickeræ·»åŠ changeå’Œcancel事件,æ¥å¯¹é€‰æ‹©çš„内容进行确定和å–消。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <picker id="picker_multi" type="multi-text" value="{{multitextvalue}}" columns="3" range="{{multitext}}" selected=" {{multitextselect}}" onchange="multitextonchange" oncancel="multitextoncancel" class="pickermuitl"></picker> </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width: 100%; height: 100%; @@ -142,7 +142,7 @@ Pickerçš„hourså±žæ€§å®šä¹‰æ—¶é—´çš„å±•çŽ°æ ¼å¼ï¼Œå¯é€‰ç±»åž‹æœ‰12å°æ—¶åˆ¶å’Œ2 } ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -170,8 +170,8 @@ export default { 在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥è‡ªå®šä¹‰å¡«å†™å½“å‰çš„å¥åº·æƒ…况æ¥è¿›è¡Œæ‰“å¡ã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="doc-page"> <text class="title">Health check-in</text> <div class="out-container"> @@ -201,8 +201,8 @@ export default { ``` -``` -/* index.css */ +```css +/* xxx.css */ .doc-page { flex-direction: column; background-color: #F1F3F5; @@ -244,7 +244,7 @@ export default { ``` -``` +```js // xxx.js import pmt from '@system.prompt' export default { @@ -299,6 +299,6 @@ export default { ## 相关实例 -针对Pickerå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对pickerå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Picker`:滑动选择器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Picker) diff --git a/zh-cn/application-dev/ui/ui-js-components-qrcode.md b/zh-cn/application-dev/ui/ui-js-components-qrcode.md index 785099137910d685d0e635f98291ee030cfc6382..6bae160089cf914b5f3e5c37c1b9d3378a4948a6 100644 --- a/zh-cn/application-dev/ui/ui-js-components-qrcode.md +++ b/zh-cn/application-dev/ui/ui-js-components-qrcode.md @@ -1,15 +1,15 @@ -# Qrcode +# qrcodeå¼€å‘指导 -生æˆå¹¶æ˜¾ç¤ºäºŒç»´ç ,具体用法请å‚考[Qrcode](../reference/arkui-js/js-components-basic-qrcode.md)。 +生æˆå¹¶æ˜¾ç¤ºäºŒç»´ç ,具体用法请å‚考[qrcode](../reference/arkui-js/js-components-basic-qrcode.md)。 -## 创建Qrcode组件 +## 创建qrcode组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªQrcode组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªqrcode组件。 -``` +```html <!-- xxx.hml--> <div class="container"> <qrcode value="Hello"></qrcode> @@ -17,7 +17,7 @@ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -31,16 +31,16 @@  ->  **说明:** -> Qrcode组件在创建的时候value的值为必填项。 +> **说明:** +> qrcode组件在创建的时候value的值为必填项。 ## 设置组件类型 -通过设置Qrcodeçš„type属性æ¥é€‰æ‹©æŒ‰é’®ç±»åž‹ï¼Œå¦‚定义Qrcode为矩形二维ç ã€åœ†å½¢äºŒç»´ç 。 +通过设置qrcodeçš„type属性æ¥é€‰æ‹©æŒ‰é’®ç±»åž‹ï¼Œå¦‚定义qrcode为矩形二维ç ã€åœ†å½¢äºŒç»´ç 。 -``` +```html <!-- xxx.hml--> <div class="container"> <select onchange="settype"> @@ -51,7 +51,7 @@ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -68,7 +68,7 @@ select{ ``` -``` +```js // index.js export default { data: { @@ -89,7 +89,7 @@ export default { 通过colorå’Œbackground-coloræ ·å¼ä¸ºäºŒç»´ç 设置显示颜色和背景颜色。 -``` +```html <!-- xxx.hml--> <div class="container"> <qrcode value="Hello" type="rect"></qrcode> @@ -97,7 +97,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -116,11 +116,11 @@ qrcode{  ->  **说明:** +> **说明:** > - widthå’Œheightä¸ä¸€è‡´æ—¶ï¼Œå–二者较å°å€¼ä½œä¸ºäºŒç»´ç 的边长,且最终生æˆçš„二维ç å±…ä¸æ˜¾ç¤ºã€‚ -> +> > - widthå’Œheightåªè®¾ç½®ä¸€ä¸ªæ—¶ï¼Œå–设置的值作为二维ç 的边长。都ä¸è®¾ç½®æ—¶ï¼Œä½¿ç”¨200px作为默认边长。 -> +> ## 场景示例 @@ -128,7 +128,7 @@ qrcode{ 在本场景ä¸å°†äºŒç»´ç 与输入框绑定,通过改å˜è¾“入框的内容改å˜äºŒç»´ç 。 -``` +```html <!-- xxx.hml--> <div class="container"> <input style="margin-bottom: 100px;" onchange="change"></input> @@ -137,7 +137,7 @@ qrcode{ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -154,7 +154,7 @@ qrcode{ ``` -``` +```js // index.js export default{ data: { diff --git a/zh-cn/application-dev/ui/ui-js-components-rating.md b/zh-cn/application-dev/ui/ui-js-components-rating.md index a6f5b4434823b3b1375c6451a5d4aa9f22369551..bb7387651e652e94902e9e925529b2219e0b2f3c 100644 --- a/zh-cn/application-dev/ui/ui-js-components-rating.md +++ b/zh-cn/application-dev/ui/ui-js-components-rating.md @@ -1,15 +1,15 @@ -# Ratingå¼€å‘指导 +# ratingå¼€å‘指导 -Rating为评分æ¡ç»„件,表示用户使用感å—çš„è¡¡é‡æ ‡å‡†æ¡ã€‚具体用法请å‚考[Rating](../reference/arkui-js/js-components-basic-rating.md)。 +rating为评分æ¡ç»„件,表示用户使用感å—çš„è¡¡é‡æ ‡å‡†æ¡ã€‚具体用法请å‚考[rating](../reference/arkui-js/js-components-basic-rating.md)。 -## 创建Rating组件 +## 创建rating组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªRating组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªrating组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <rating></rating> @@ -17,7 +17,7 @@ Rating为评分æ¡ç»„件,表示用户使用感å—çš„è¡¡é‡æ ‡å‡†æ¡ã€‚具体 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -38,10 +38,10 @@ rating { ## 设置评分星级 -Rating组件通过设置numstarså’Œrating属性设置评分æ¡çš„星级总数和当å‰è¯„星数。 +rating组件通过设置numstarså’Œrating属性设置评分æ¡çš„星级总数和当å‰è¯„星数。 -``` +```html <!-- xxx.hml --> <div class="container"> <rating numstars="6" rating="5"> @@ -50,7 +50,7 @@ Rating组件通过设置numstarså’Œrating属性设置评分æ¡çš„星级总数和 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -71,10 +71,10 @@ rating { ## è®¾ç½®è¯„åˆ†æ ·å¼ -Rating组件通过star-backgroundã€star-foregroundå’Œstar-secondary属性设置å•ä¸ªæ˜Ÿçº§æœªé€‰æ‹©ã€é€‰ä¸å’Œé€‰ä¸çš„次级背景图片。 +rating组件通过star-backgroundã€star-foregroundå’Œstar-secondary属性设置å•ä¸ªæ˜Ÿçº§æœªé€‰æ‹©ã€é€‰ä¸å’Œé€‰ä¸çš„次级背景图片。 -``` +```html <!-- xxx.hml --> <div class="container"> <div style="width: 500px;height: 500px;align-items: center;justify-content: center;flex-direction: column;;"> @@ -86,7 +86,7 @@ Rating组件通过star-backgroundã€star-foregroundå’Œstar-secondary属性设置 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -99,8 +99,8 @@ Rating组件通过star-backgroundã€star-foregroundå’Œstar-secondary属性设置 ``` -``` -/* index.js */ +```js +// index.js export default { data: { backstar: 'common/love.png', @@ -116,18 +116,18 @@ export default {  ->  **说明:** +> **说明:** > - star-backgroundã€star-secondaryã€star-foreground属性的星级图æºå¿…须全部设置,å¦åˆ™é»˜è®¤çš„星级颜色为ç°è‰²ï¼Œæ示图æºè®¾ç½®é”™è¯¯ã€‚ -> +> > - star-backgroundã€star-secondaryã€star-foreground属性åªæ”¯æŒæœ¬åœ°è·¯å¾„å›¾ç‰‡ï¼Œå›¾ç‰‡æ ¼å¼ä¸ºpngå’Œjpg。 ## 绑定事件 -å‘Ratingç»„ä»¶æ·»åŠ change事件,打å°å½“å‰è¯„分。 +å‘ratingç»„ä»¶æ·»åŠ change事件,打å°å½“å‰è¯„分。 -``` +```html <!-- xxx.hml --> <div class="container"> <rating numstars="5" rating="0" onchange="showrating"></rating> @@ -135,7 +135,8 @@ export default { ``` -``` +```css +/* xxx.css */ .container { width: 100%; height: 100%; @@ -151,7 +152,8 @@ rating { ``` -``` +```js +// xxx.js import prompt from '@system.prompt'; export default { showrating(e) { @@ -170,7 +172,7 @@ export default { å¼€å‘者å¯ä»¥é€šè¿‡æ”¹å˜å¼€å…³çŠ¶æ€åˆ‡æ¢æ˜Ÿçº§èƒŒæ™¯å›¾ï¼Œé€šè¿‡æ”¹å˜æ»‘动æ¡çš„值调整星级总数。 -``` +```html <!-- xxx.hml --> <div style="width: 100%;height:100%;flex-direction: column;align-items: center;background-color: #F1F3F5;"> <div style="width: 500px;height: 500px;align-items: center;justify-content: center;flex-direction: column;;"> @@ -197,7 +199,7 @@ export default { ``` -``` +```css /* xxx.css */ .myrating:active { width: 500px; @@ -209,8 +211,8 @@ switch{ ``` -``` -/* index.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { data: { diff --git a/zh-cn/application-dev/ui/ui-js-components-search.md b/zh-cn/application-dev/ui/ui-js-components-search.md index d0bf4297262cb677fd27a1191e34462af8558769..5c712126e14d8c24c396dd84808e4bdcae395564 100644 --- a/zh-cn/application-dev/ui/ui-js-components-search.md +++ b/zh-cn/application-dev/ui/ui-js-components-search.md @@ -1,15 +1,15 @@ -# Search +# search -æä¾›æœç´¢æ¡†ç»„件,用于æ供用户æœç´¢å†…容的输入区域,具体用法请å‚考[Search](../reference/arkui-js/js-components-basic-search.md)。 +æä¾›æœç´¢æ¡†ç»„件,用于æ供用户æœç´¢å†…容的输入区域,具体用法请å‚考[search](../reference/arkui-js/js-components-basic-search.md)。 -## 创建Search组件 +## 创建search组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªSearch组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªsearch组件。 -``` +```html <!-- xxx.hml--> <div class="container"> <search></search> @@ -17,7 +17,7 @@ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -37,7 +37,7 @@ 通过设置hintã€iconå’Œsearchbutton属性设置æœç´¢æ¡†çš„æ示文å—ã€å›¾æ ‡å’Œæœ«å°¾æœç´¢æŒ‰é’®çš„内容。 -``` +```html <!-- xxx.hml--> <div class="container"> <search hint="Please enter the search content" searchbutton="search" icon="/common/search1.png"></search> @@ -45,7 +45,7 @@ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -65,7 +65,7 @@ 通过colorã€placeholderå’Œcaret-coloræ ·å¼æ¥è®¾ç½®æœç´¢æ¡†çš„文本颜色ã€æç¤ºæ–‡æœ¬é¢œè‰²å’Œå…‰æ ‡é¢œè‰²ã€‚ -``` +```html <!-- xxx.hml--> <div class="container"> <search hint="Please enter the search content" searchbutton="search" ></search> @@ -73,7 +73,7 @@ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -93,10 +93,10 @@ search{ ## 绑定事件 -å‘Searchç»„ä»¶æ·»åŠ changeã€searchã€submitã€shareå’Œtranslate事件,对输入信æ¯è¿›è¡Œæ“作。 +å‘searchç»„ä»¶æ·»åŠ changeã€searchã€submitã€shareå’Œtranslate事件,对输入信æ¯è¿›è¡Œæ“作。 -``` +```html <!-- xxx.hml--> <div class="container"> <text style="margin-left: -7px;"> @@ -109,7 +109,7 @@ search{ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -128,7 +128,7 @@ text{ ``` -``` +```js // index.js import prompt from '@system.prompt' export default { @@ -170,14 +170,14 @@ export default { ## 场景示例 -在本场景ä¸é€šè¿‡ä¸‹æ‹‰èœå•é€‰æ‹©Searchã€Textareaå’ŒInput组件æ¥å®žçŽ°æœç´¢å’Œè¾“入效果。 +在本场景ä¸é€šè¿‡ä¸‹æ‹‰èœå•é€‰æ‹©searchã€Textareaå’ŒInput组件æ¥å®žçŽ°æœç´¢å’Œè¾“入效果。 -``` +```html <!-- xxx.hml--> <div style="flex-direction: column;align-items: center;justify-content: center; width: 100%;"> <select class="slt1" id="slt1" onchange="setfield"> - <option value="search">Search</option> + <option value="search">search</option> <option value="textarea">Textarea</option> <option value="input">Input</option> </select> @@ -197,7 +197,7 @@ export default { ``` -``` +```css /* xxx.css */ .field { width: 80%; @@ -214,7 +214,7 @@ export default { ``` -``` +```js // index.js import prompt from '@system.prompt'; export default { diff --git a/zh-cn/application-dev/ui/ui-js-components-slider.md b/zh-cn/application-dev/ui/ui-js-components-slider.md index 99bd1e3fda6630b6d02157cde16fe74e4f30aefe..abac0828428567207a22929ee5a4bfb0912343d8 100644 --- a/zh-cn/application-dev/ui/ui-js-components-slider.md +++ b/zh-cn/application-dev/ui/ui-js-components-slider.md @@ -1,23 +1,23 @@ -# Sliderå¼€å‘指导 +# sliderå¼€å‘指导 -Slider为滑动æ¡ç»„件,用æ¥å¿«é€Ÿè°ƒèŠ‚音é‡ã€äº®åº¦ç‰ã€‚具体用法请å‚考[Slider](../reference/arkui-js/js-components-basic-slider.md)。 +slider为滑动æ¡ç»„件,用æ¥å¿«é€Ÿè°ƒèŠ‚音é‡ã€äº®åº¦ç‰ã€‚具体用法请å‚考[slider](../reference/arkui-js/js-components-basic-slider.md)。 -## 创建Slider组件 +## 创建slider组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªSlider组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªslider组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <slider></slider> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -35,10 +35,10 @@ Slider为滑动æ¡ç»„件,用æ¥å¿«é€Ÿè°ƒèŠ‚音é‡ã€äº®åº¦ç‰ã€‚具体用法 ## è®¾ç½®æ ·å¼å’Œå±žæ€§ -Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘动æ¡è®¾ç½®èƒŒæ™¯é¢œè‰²ã€å·²é€‰æ‹©é¢œè‰²å’Œæ»‘å—颜色。 +slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘动æ¡è®¾ç½®èƒŒæ™¯é¢œè‰²ã€å·²é€‰æ‹©é¢œè‰²å’Œæ»‘å—颜色。 -``` +```html <!-- xxx.hml --> <div class="container"> <slider class= "sli"></slider> @@ -46,7 +46,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -68,7 +68,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ é€šè¿‡æ·»åŠ mixã€maxã€valueã€stepã€mode属性分别为滑动æ¡è®¾ç½®æœ€å°å€¼ã€æœ€å¤§å€¼ã€åˆå§‹å€¼ã€æ»‘动æ¥é•¿å’Œæ»‘动æ¡æ ·å¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <slider min="0" max="100" value="1" step="2" mode="inset" showtips="true"></slider> @@ -76,7 +76,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -90,7 +90,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡  ->  **说明:** +> **说明:** > mode属性为滑动æ¡æ ·å¼ï¼Œå¯é€‰å€¼ä¸ºï¼š > > - outset:滑å—在滑æ†ä¸Šï¼› @@ -103,7 +103,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ å‘Ratingç»„ä»¶æ·»åŠ changeäº‹ä»¶ï¼Œæ·»åŠ æ—¶éœ€è¦ä¼ å…¥ChangeEventå‚数。 -``` +```html <!-- xxx.hml --> <div class="container"> <text>slider start value is {{startValue}}</text> @@ -114,7 +114,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -127,7 +127,7 @@ Slider组件通过colorã€selected-colorã€block-coloræ ·å¼åˆ†åˆ«ä¸ºæ»‘åŠ¨æ¡ ``` -``` +```js // xxx.js export default { data: { @@ -159,7 +159,7 @@ export default { å¼€å‘者å¯ä»¥é€šè¿‡è°ƒæ•´æ»‘动æ¡çš„值æ¥æ”¹å˜å›¾ç‰‡å¤§å°ï¼Œå¹¶ä¸”动æ€æ‰“å°å½“å‰å›¾ç‰‡çš„宽和高。 -``` +```html <!-- xxx.hml --> <div class="container"> <image src="common/landscape3.jpg" style=" width: {{WidthVal}}px;height:{{HeightVal}}px;margin-top: -150px;"></image> @@ -172,7 +172,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -195,7 +195,7 @@ text{ ``` -``` +```js // xxx.js export default{ data: { @@ -215,8 +215,8 @@ export default{ ## 相关实例 -针对Sliderå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对sliderå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Slider`:滑动æ¡ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Slider) -- [slider(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SliderApplication) \ No newline at end of file +- [slider(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/SliderApplication) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-js-components-stepper.md b/zh-cn/application-dev/ui/ui-js-components-stepper.md index 0c3489679485b33cd3f54c5a274cc9dda4b1479a..73e53835e900f45a95307676935570c64a9d6dd4 100644 --- a/zh-cn/application-dev/ui/ui-js-components-stepper.md +++ b/zh-cn/application-dev/ui/ui-js-components-stepper.md @@ -1,18 +1,18 @@ -# Stepper +# stepperå¼€å‘指导 -当一个任务需è¦å¤šä¸ªæ¥éª¤æ—¶ï¼Œå¯ä»¥ä½¿ç”¨stepper组件展示当å‰è¿›å±•ã€‚具体用法请å‚考[Stepper API](../reference/arkui-js/js-components-container-stepper.md)。 +当一个任务需è¦å¤šä¸ªæ¥éª¤æ—¶ï¼Œå¯ä»¥ä½¿ç”¨stepper组件展示当å‰è¿›å±•ã€‚具体用法请å‚考[stepper API](../reference/arkui-js/js-components-container-stepper.md)。 ->  **说明:** +> **说明:** > 从API Version 5 开始支æŒã€‚ -## 创建Stepper组件 +## 创建stepper组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªStepper组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªstepper组件。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <stepper> <stepper-item> @@ -25,7 +25,7 @@ </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -49,8 +49,8 @@ text{ 页é¢é»˜è®¤æ˜¾ç¤ºç´¢å¼•å€¼ä¸ºindexçš„æ¥éª¤ã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <stepper index="2"> <stepper-item> @@ -66,8 +66,8 @@ text{ </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width:100%; height:100%; @@ -85,8 +85,8 @@ text{ 通过设置label属性,自定义stepper-itemçš„æ示按钮。 -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container"> <stepper index="1"> <stepper-item label="{{label_1}}"> @@ -105,8 +105,8 @@ text{ </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width:100%; height:100%; @@ -120,8 +120,8 @@ text{ } ``` -``` -/* index.js */ +```js +// xxx.js export default { data: { label_1:{ @@ -147,9 +147,9 @@ export default { ## è®¾ç½®æ ·å¼ -Stepper组件默认填充父容器,通过borderå’Œbackground-color设置边框ã€èƒŒæ™¯è‰²ã€‚ -``` -<!-- index.hml --> +stepper组件默认填充父容器,通过borderå’Œbackground-color设置边框ã€èƒŒæ™¯è‰²ã€‚ +```html +<!-- xxx.hml --> <div class="container" > <div class="stepperContent"> <stepper class="stepperClass"> @@ -161,8 +161,8 @@ Stepper组件默认填充父容器,通过borderå’Œbackground-color设置边框 </div> ``` -``` -/* index.css */ +```css +/* xxx.css */ .container { width:100%; height:100%; @@ -191,14 +191,14 @@ text{ ## æ·»åŠ äº‹ä»¶ -Stepperåˆ†åˆ«æ·»åŠ finish,change,next,back,skip事件。 +stepperåˆ†åˆ«æ·»åŠ finish,change,next,back,skip事件。 - 当change与next或backåŒæ—¶å˜åœ¨æ—¶ï¼Œä¼šå…ˆæ‰§è¡Œnext或back事件å†åŽ»æ‰§è¡Œchange事件。 - é‡æ–°è®¾ç½®index属性值时è¦å…ˆæ¸…除index的值å†é‡æ–°è®¾ç½®ï¼Œå¦åˆ™æ£€æµ‹ä¸åˆ°å€¼çš„改å˜ã€‚ -``` -<!-- index.hml --> +```html +<!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;"> <div > <stepper onfinish="stepperFinish" onchange="stepperChange" onnext="stepperNext" onback="stepperBack" onskip="stepperSkip" id="stepperId" index="{{index}}"> @@ -218,7 +218,7 @@ Stepperåˆ†åˆ«æ·»åŠ finish,change,next,back,skip事件。 </div> ``` -``` +```css /* xxx.css */ .doc-page { width:100%; @@ -246,8 +246,8 @@ button{ } ``` -``` -/* index.js */ +```js +// xxx.js import prompt from '@system.prompt'; export default { data: { @@ -294,9 +294,10 @@ export default { 在本场景ä¸ï¼Œå¼€å‘者å¯ä»¥åœ¨ç•Œé¢ä¸Šç‚¹å‡»é€‰æ‹©å¹¶å®žæ—¶æ˜¾ç¤ºé€‰æ‹©ç»“果,点击下一æ¥æŒ‰é’®åŽå¯åŠ¨æ€ä¿®æ”¹é¡µé¢çš„å—体颜色和å—体大å°ã€‚ -用Stepper组件实现分æ¥ï¼Œå†åˆ›å»º[Toggle](../reference/arkui-js/js-components-basic-toggle.md)组件实现选择显示功能,å†ä½¿ç”¨[Select](../reference/arkui-js/js-components-basic-select.md)组件实现改å˜é€‰ä¸å€¼åŠ¨æ€ä¿®æ”¹å—体颜色或大å°ã€‚ +用stepper组件实现分æ¥ï¼Œå†åˆ›å»º[Toggle](../reference/arkui-js/js-components-basic-toggle.md)组件实现选择显示功能,å†ä½¿ç”¨[Select](../reference/arkui-js/js-components-basic-select.md)组件实现改å˜é€‰ä¸å€¼åŠ¨æ€ä¿®æ”¹å—体颜色或大å°ã€‚ -``` +```html +<!-- xxx.hml --> <div class="container"> <stepper id="mystep" index="0" onfinish="back" style="text-color: indigo;"> <stepper-item label="{{label1}}"> @@ -337,7 +338,7 @@ export default { </div> ``` -``` +```css /* xxx.css */ .container { width:100%; @@ -358,8 +359,8 @@ export default { } ``` -``` -/* index.js */ +```js +// xxx.js import prompt from '@system.prompt'; import router from '@system.router'; let myset = new Set(); @@ -405,6 +406,6 @@ export default { ## 相关实例 -针对Stepperå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对stepperå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`StepNavigator`:æ¥éª¤å¯¼èˆªå™¨ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/StepNavigator) diff --git a/zh-cn/application-dev/ui/ui-js-components-svg-graphics.md b/zh-cn/application-dev/ui/ui-js-components-svg-graphics.md index 9cb7f7c3ab1bf6253476bf1fcaa33c273fd521a4..eecf7d5acc3a6cb4a381b4ceeeaef3b53ee92e26 100644 --- a/zh-cn/application-dev/ui/ui-js-components-svg-graphics.md +++ b/zh-cn/application-dev/ui/ui-js-components-svg-graphics.md @@ -6,8 +6,8 @@ Svg组件å¯ä»¥ç”¨æ¥ç»˜åˆ¶å¸¸è§å›¾å½¢å’Œçº¿æ®µï¼Œå¦‚矩形(<rect>) 在本场景ä¸ï¼Œç»˜åˆ¶å„ç§å›¾å½¢æ‹¼æŽ¥ç»„æˆä¸€ä¸ªå°æˆ¿å。 - -``` + +```html <!-- xxx.hml --> <div class="container"> <svg width="1000" height="1000"> @@ -25,8 +25,8 @@ Svg组件å¯ä»¥ç”¨æ¥ç»˜åˆ¶å¸¸è§å›¾å½¢å’Œçº¿æ®µï¼Œå¦‚矩形(<rect>) </div> ``` - -``` + +```css /* xxx.css */ .container { width: 100%; diff --git a/zh-cn/application-dev/ui/ui-js-components-svg-overview.md b/zh-cn/application-dev/ui/ui-js-components-svg-overview.md index aa13c248a854c5864de1e5c504a198bd38bd0415..601ff8c6d62e4d4ac08e005adfe3d14a969feef6 100644 --- a/zh-cn/application-dev/ui/ui-js-components-svg-overview.md +++ b/zh-cn/application-dev/ui/ui-js-components-svg-overview.md @@ -4,9 +4,9 @@ Svg组件主è¦ä½œä¸ºsvgç”»å¸ƒçš„æ ¹èŠ‚ç‚¹ä½¿ç”¨ï¼Œä¹Ÿå¯ä»¥åœ¨svgä¸åµŒå¥—使用。具体用法请å‚考[Svg](../reference/arkui-js/js-components-svg.md)。 ->  **说明:** +> **说明:** > - 从API version 7开始支æŒã€‚ -> +> > - svg父组件或者svg组件需è¦å®šä¹‰å®½é«˜å€¼ï¼Œå¦åˆ™ä¸è¿›è¡Œç»˜åˆ¶ã€‚ @@ -15,7 +15,7 @@ Svg组件主è¦ä½œä¸ºsvgç”»å¸ƒçš„æ ¹èŠ‚ç‚¹ä½¿ç”¨ï¼Œä¹Ÿå¯ä»¥åœ¨svgä¸åµŒå¥—使 在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªSvg组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <svg width="400" height="400"> </svg> @@ -23,7 +23,7 @@ Svg组件主è¦ä½œä¸ºsvgç”»å¸ƒçš„æ ¹èŠ‚ç‚¹ä½¿ç”¨ï¼Œä¹Ÿå¯ä»¥åœ¨svgä¸åµŒå¥—使 ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -46,15 +46,18 @@ svg{ 通过设置widthã€heightã€xã€yå’ŒviewBox属性为Svg设置宽度ã€é«˜åº¦ã€xè½´åæ ‡ã€yè½´åæ ‡å’ŒSvg视å£ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> - <svg width="400" height="400" viewBox="0 0 100 100"> <svg class="rect" width="100" height="100" x="20" y="10"> </svg> </svg> + <svg width="400" height="400" viewBox="0 0 100 100"> + <svg class="rect" width="100" height="100" x="20" y="10"> + </svg> + </svg> </div> ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -74,9 +77,9 @@ svg{  ->  **说明:** +> **说明:** > - xå’Œy设置的的是当å‰Svgçš„xè½´å’Œyè½´åæ ‡ï¼Œå¦‚æžœå½“å‰Svgä¸ºæ ¹èŠ‚ç‚¹ï¼Œxè½´å’Œyè½´å±žæ€§æ— æ•ˆã€‚ -> +> > - viewBox的宽高和svg的宽高ä¸ä¸€è‡´ï¼Œä¼šä»¥ä¸å¿ƒå¯¹é½è¿›è¡Œç¼©æ”¾ã€‚ diff --git a/zh-cn/application-dev/ui/ui-js-components-svg-path.md b/zh-cn/application-dev/ui/ui-js-components-svg-path.md index 80770f6543997e18d2d386764e5fb63f9a0e9fbb..5597fc284f079a830381b8ef9daa8cea358fea00 100644 --- a/zh-cn/application-dev/ui/ui-js-components-svg-path.md +++ b/zh-cn/application-dev/ui/ui-js-components-svg-path.md @@ -3,16 +3,19 @@ Svg组件绘制路径时,通过Pathä¸çš„M(起点)ã€H(水平线)ã€a(绘制弧形到指定ä½ç½®ï¼‰è·¯å¾„控制指令,并填充颜色实现 饼状图效果。 -``` +```html <!-- xxx.hml --> <div class="container"> <svg fill="#00FF00" x="100" y="400"> - <path d="M300,200 h-150 a150 150 0 1 0 150 -150 z" fill="red" stroke="blue" stroke-width="5" > </path> <path d="M275,175 v-150 a150 150 0 0 0 -150 150 z" fill="yellow" stroke="blue" stroke-width="5"> </path> + <path d="M300,200 h-150 a150 150 0 1 0 150 -150 z" fill="red" stroke="blue" stroke-width="5" > + </path> + <path d="M275,175 v-150 a150 150 0 0 0 -150 150 z" fill="yellow" stroke="blue" stroke-width="5"> + </path> </svg> </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: row; @@ -28,23 +31,23 @@ Svg组件绘制路径时,通过Pathä¸çš„M(起点)ã€H(水平线)ã€a(  ->  **说明:** +> **说明:** > - M/m = moveto å‚æ•°xå’Œy表示需è¦ç§»åŠ¨åˆ°ç‚¹çš„xè½´å’Œyè½´çš„åæ ‡ã€‚åœ¨ä½¿ç”¨M命令移动画笔åŽï¼Œåªä¼šç§»åŠ¨ç”»ç¬”,但ä¸ä¼šåœ¨ä¸¤ç‚¹ä¹‹é—´ç”»çº¿ã€‚所以M命令ç»å¸¸å‡ºçŽ°åœ¨è·¯å¾„的开始处,用æ¥æŒ‡æ˜Žä»Žä½•å¤„开始画。 -> +> > - L/l = lineto å‚æ•°xå’Œy表示一个点的xè½´å’Œyè½´åæ ‡ï¼ŒL命令将会在当å‰ä½ç½®å’Œæ–°ä½ç½®ï¼ˆLå‰é¢ç”»ç¬”所在的点)之间画一æ¡çº¿æ®µã€‚ -> +> > - H/h = horizontal lineto 绘制平行线。 -> +> > - V/v = vertical lineto 绘制垂直线。 -> +> > - C/c = curveto 三次è´å¡žå°”曲线 设置三组åæ ‡å‚数: x1 y1, x2 y2, x y。 -> +> > - S/s = smooth curveto 三次è´å¡žå°”曲线命令 设置两组åæ ‡å‚数: x2 y2, x y。 -> +> > - Q/q = quadratic Belzier curve 二次è´å¡žå°”曲线 设置两组åæ ‡å‚数: x1 y1, x y。 -> +> > - T/t = smooth quadratic Belzier curveto 二次è´å¡žå°”曲线命令 设置å‚数: x y。 -> +> > - A/a = elliptical Arc 弧形命令 设置å‚数: rx ry x-axis-rotation(旋转角度)large-arc-flag(角度大å°ï¼‰ sweep-flag(弧线方å‘) x y。large-arc-flag决定弧线是大于还是å°äºŽ180度,0表示å°è§’度弧,1表示大角度弧。sweep-flag表示弧线的方å‘,0表示从起点到终点沿逆时针画弧,1表示从起点到终点沿顺时针画弧。 -> +> > - Z/z = closepath 从当å‰ç‚¹ç”»ä¸€æ¡ç›´çº¿åˆ°è·¯å¾„的起点。 diff --git a/zh-cn/application-dev/ui/ui-js-components-svg-text.md b/zh-cn/application-dev/ui/ui-js-components-svg-text.md index c5e0d18c7ef6031074ed59ee37758a89c8c9b2e5..4663070c8fa2ba2005047db0e31d2ff8827980ca 100644 --- a/zh-cn/application-dev/ui/ui-js-components-svg-text.md +++ b/zh-cn/application-dev/ui/ui-js-components-svg-text.md @@ -6,17 +6,17 @@ Svg组件还å¯ä»¥ç»˜åˆ¶æ–‡æœ¬ã€‚ ## 文本 ->  **说明:** +> **说明:** > - 文本的展示内容需è¦å†™åœ¨å…ƒç´ æ ‡ç¾text内,å¯åµŒå¥—tspanåå…ƒç´ æ ‡ç¾åˆ†æ®µã€‚ -> +> > - åªæ”¯æŒè¢«çˆ¶å…ƒç´ æ ‡ç¾svg嵌套。 -> +> > - åªæ”¯æŒé»˜è®¤å—体sans-serif。 通过设置x(xè½´åæ ‡ï¼‰ã€y(yè½´åæ ‡ï¼‰ã€dx(文本xè½´å移)ã€dy(文本yè½´å移)ã€fill(å—体填充颜色)ã€stroke(文本边框颜色)ã€stroke-width(文本边框宽度)ç‰å±žæ€§å®žçŽ°æ–‡æœ¬çš„ä¸åŒå±•ç¤ºæ ·å¼ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <svg> @@ -36,7 +36,7 @@ Svg组件还å¯ä»¥ç»˜åˆ¶æ–‡æœ¬ã€‚ textpath文本内容沿ç€å±žæ€§pathä¸çš„路径绘制文本。 -``` +```html <!-- xxx.hml --> <div class="container"> <svg fill="#00FF00" x="100" y="400"> diff --git a/zh-cn/application-dev/ui/ui-js-components-swiper.md b/zh-cn/application-dev/ui/ui-js-components-swiper.md index 96cff3844a12a75cc5cba38f6ac3af4129e61ed4..af41ada3d1fa375720723e8f8de83ac2d0009bc8 100644 --- a/zh-cn/application-dev/ui/ui-js-components-swiper.md +++ b/zh-cn/application-dev/ui/ui-js-components-swiper.md @@ -1,14 +1,14 @@ -# Swiperå¼€å‘指导 +# swiperå¼€å‘指导 -Swiper为滑动容器,æ供切æ¢æ˜¾ç¤ºå组件的能力。具体用法请å‚考[Swiper](../reference/arkui-js/js-components-container-swiper.md)。 +swiper为滑动容器,æ供切æ¢æ˜¾ç¤ºå组件的能力。具体用法请å‚考[swiper](../reference/arkui-js/js-components-container-swiper.md)。 -## 创建Swiper组件 +## 创建swiper组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªSwiper组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªswiper组件。 -``` +```html <!-- xxx.hml--> <div class="container"> <swiper> @@ -25,7 +25,7 @@ Swiper为滑动容器,æ供切æ¢æ˜¾ç¤ºå组件的能力。具体用法请 </div> ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -56,16 +56,16 @@ text{  ->  **说明:** -> Swiper组件支æŒé™¤<list>之外的å组件。 +> **说明:** +> swiper组件支æŒé™¤<list>之外的å组件。 ## æ·»åŠ å±žæ€§ -Swiper组件当ä¸å¼€å¯å¾ªçŽ¯æ’放(loop="false"ï¼‰æ—¶æ·»åŠ è‡ªåŠ¨æ’放属性(autoplay),设置自动æ’放时æ’放时间间隔(interval),页é¢ä¼šè‡ªåŠ¨åˆ‡æ¢å¹¶åœç•™åœ¨æœ€åŽä¸€ä¸ªå组件页é¢ã€‚æ·»åŠ digital属性å¯ç”¨æ•°å—导航点,设置切æ¢æ—¶ä¸ºæ¸éšæ»‘动效果(scrolleffect="fade"))。 +swiper组件当ä¸å¼€å¯å¾ªçŽ¯æ’放(loop="false"ï¼‰æ—¶æ·»åŠ è‡ªåŠ¨æ’放属性(autoplay),设置自动æ’放时æ’放时间间隔(interval),页é¢ä¼šè‡ªåŠ¨åˆ‡æ¢å¹¶åœç•™åœ¨æœ€åŽä¸€ä¸ªå组件页é¢ã€‚æ·»åŠ digital属性å¯ç”¨æ•°å—导航点,设置切æ¢æ—¶ä¸ºæ¸éšæ»‘动效果(scrolleffect="fade"))。 -``` +```html <!-- xxx.hml--> <div class="container"> <swiper index="1" autoplay="true" interval="2000" indicator="true" digital="true" duration="500" @@ -87,7 +87,7 @@ Swiper组件当ä¸å¼€å¯å¾ªçŽ¯æ’放(loop="false"ï¼‰æ—¶æ·»åŠ è‡ªåŠ¨æ’放属 ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -115,20 +115,20 @@ text{  ->  **说明:** +> **说明:** > - 设置indicator(是å¦å¯ç”¨å¯¼èˆªç‚¹æŒ‡ç¤ºå™¨ï¼‰å±žæ€§ä¸ºtrueæ—¶digital(是å¦å¯ç”¨æ•°å—导航点)属性æ‰ä¼šç”Ÿæ•ˆã€‚ -> -> - Swiperå组件的个数大于ç‰äºŽ2时设置的loop属性æ‰ä¼šç”Ÿæ•ˆã€‚ -> +> +> - swiperå组件的个数大于ç‰äºŽ2时设置的loop属性æ‰ä¼šç”Ÿæ•ˆã€‚ +> > - scrolleffect属性仅在loop属性值为false时生效。 ## è®¾ç½®æ ·å¼ -设置Swiper组件的宽高,导航点指示器的直径大å°ï¼ˆindicator-size)ã€é¢œè‰²ï¼ˆindicator-color)ã€ç›¸å¯¹ä½ç½®ï¼ˆndicator-top)åŠé€‰ä¸æ—¶çš„颜色(indicator-selected-color)。 +设置swiper组件的宽高,导航点指示器的直径大å°ï¼ˆindicator-size)ã€é¢œè‰²ï¼ˆindicator-color)ã€ç›¸å¯¹ä½ç½®ï¼ˆndicator-top)åŠé€‰ä¸æ—¶çš„颜色(indicator-selected-color)。 -``` +```html <!-- xxx.hml--> <div class="container"> <swiper index="1" autoplay="true" interval="2000" duration="500" > @@ -146,7 +146,7 @@ text{ ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -184,10 +184,10 @@ text{ ## 绑定事件 -创建两个textç»„ä»¶æ·»åŠ ç‚¹å‡»äº‹ä»¶ï¼Œå½“ç‚¹å‡»åŽå°±è°ƒç”¨showPrevious(显示上一个å组件)或showNext(显示下一个åç»„ä»¶ï¼‰æ–¹æ³•ã€‚æ·»åŠ select组件下拉选择时触å‘change事件åŽè°ƒç”¨swiperTo方法跳转到指定轮æ’页é¢ã€‚Swiper组件绑定change(当å‰æ˜¾ç¤ºçš„组件索引å˜åŒ–时触å‘)和finish(切æ¢åŠ¨ç”»ç»“æŸæ—¶è§¦å‘)事件。 +创建两个textç»„ä»¶æ·»åŠ ç‚¹å‡»äº‹ä»¶ï¼Œå½“ç‚¹å‡»åŽå°±è°ƒç”¨showPrevious(显示上一个å组件)或showNext(显示下一个åç»„ä»¶ï¼‰æ–¹æ³•ã€‚æ·»åŠ select组件下拉选择时触å‘change事件åŽè°ƒç”¨swiperTo方法跳转到指定轮æ’页é¢ã€‚swiper组件绑定change(当å‰æ˜¾ç¤ºçš„组件索引å˜åŒ–时触å‘)和finish(切æ¢åŠ¨ç”»ç»“æŸæ—¶è§¦å‘)事件。 -``` +```html <!-- xxx.hml--> <div class="container"> <swiper interval="2000" onchange="change" loop="false" onanimationfinish="finish" id="swiper"> @@ -218,7 +218,7 @@ text{ ``` -``` +```css /* xxx.css */ .container{ width: 100%; @@ -259,7 +259,8 @@ select{ ``` -``` +```js +// xxx.js import prompt from '@system.prompt'; export default{ change(e){ @@ -285,10 +286,10 @@ export default{ ## 场景示例 -本场景ä¸ä½¿ç”¨Swiper创建一个轮æ’图,在轮æ’图底部制作一个缩略图,点击缩略图åŽè°ƒç”¨swipeTo方法切æ¢åˆ°å¯¹åº”çš„è½®æ’图。 +本场景ä¸ä½¿ç”¨swiper创建一个轮æ’图,在轮æ’图底部制作一个缩略图,点击缩略图åŽè°ƒç”¨swipeTo方法切æ¢åˆ°å¯¹åº”çš„è½®æ’图。 -``` +```html <!-- xxx.hml--> <div class="container"> <swiper duration="500" indicator="false" id="swiper" onchange="change"> @@ -305,7 +306,7 @@ export default{ ``` -``` +```css /* xxx.css */ .container{ flex-direction: column; @@ -340,8 +341,8 @@ swiper{ ``` -``` -// index.js +```js +// xxx.js import prompt from '@system.prompt'; export default { data:{ @@ -367,6 +368,6 @@ export default { ## 相关实例 -针对Swiperå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对swiperå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Swiper`:内容滑动容器(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Swiper) diff --git a/zh-cn/application-dev/ui/ui-js-components-switch.md b/zh-cn/application-dev/ui/ui-js-components-switch.md index aa7e7e71cb4f1e7d7e9a1b850fa5cff7c533bc46..9430f6e94215b5d88a0a10374076598663cbba3c 100644 --- a/zh-cn/application-dev/ui/ui-js-components-switch.md +++ b/zh-cn/application-dev/ui/ui-js-components-switch.md @@ -1,22 +1,23 @@ -# Switchå¼€å‘指导 +# switchå¼€å‘指导 -Switch为开关选择器,切æ¢å¼€å¯æˆ–å…³é—状æ€ã€‚具体用法请å‚考[Switch](../reference/arkui-js/js-components-basic-switch.md)。 +switch为开关选择器,切æ¢å¼€å¯æˆ–å…³é—状æ€ã€‚具体用法请å‚考[switch](../reference/arkui-js/js-components-basic-switch.md)。 -## 创建Switch组件 +## 创建switch组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªSwitch组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªswitch组件。 -``` +```html +<!-- xxx.hml --> <div class="container"> <switch></switch> </div> ``` -``` +```css /* xxx.css */ .container { flex-direction: column; @@ -33,7 +34,7 @@ Switch为开关选择器,切æ¢å¼€å¯æˆ–å…³é—状æ€ã€‚具体用法请å‚考[S witch组件通过textoffå’Œshowtext属性设置文本选ä¸å’Œæœªé€‰ä¸æ—¶çš„状æ€ã€‚设置checked属性值为true(组件为打开状æ€ï¼‰ã€‚æ·»åŠ change事件,当组件状æ€æ”¹å˜æ—¶è§¦å‘,触å‘åŽæ‰§è¡ŒswitchChange函数获å–组件当å‰çŠ¶æ€ï¼ˆå…³é—/打开)。 -``` +```html <!-- xxx.hml --> <div class="container"> <switch showtext="true" texton="open" textoff="close" checked="true" @change="switchChange"></switch> @@ -41,7 +42,7 @@ Switch为开关选择器,切æ¢å¼€å¯æˆ–å…³é—状æ€ã€‚具体用法请å‚考[S ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -62,7 +63,7 @@ switch{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -84,7 +85,7 @@ export default {  ->  **说明:** +> **说明:** > 当showtext属性值设置为true时,textonå’Œtextoff设置的文本æ‰ä¼šç”Ÿæ•ˆã€‚ @@ -92,9 +93,9 @@ export default { 在下é¢ç¤ºä¾‹ä¸è®¾ç½®å¼€å…³ä¸ºæ‰“开状æ€ï¼ˆä½¿ç”¨é»˜è®¤æ”¶è´§åœ°å€ï¼‰ï¼Œå…³é—开关åŽé¡µé¢æ˜¾ç¤ºé€‰æ‹©åœ°å€æŒ‰é’®ï¼Œç‚¹å‡»æŒ‰é’®å³å¯æ”¹å˜æ”¶è´§åœ°å€ã€‚ - 实现方法:创建Switch开关,设置checked属性为true,通过数æ®ç»‘定改å˜æ”¶è´§åœ°å€ã€‚设置display属性(默认为none),当关é—开关改å˜display属性值为flexåŽæ˜¾ç¤ºåœ°å€æ¨¡å—,点击按钮改å˜é¢œè‰²ã€‚ + 实现方法:创建switch开关,设置checked属性为true,通过数æ®ç»‘定改å˜æ”¶è´§åœ°å€ã€‚设置display属性(默认为none),当关é—开关改å˜display属性值为flexåŽæ˜¾ç¤ºåœ°å€æ¨¡å—,点击按钮改å˜é¢œè‰²ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <div class="change"> @@ -113,7 +114,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -168,7 +169,7 @@ switch{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { diff --git a/zh-cn/application-dev/ui/ui-js-components-text.md b/zh-cn/application-dev/ui/ui-js-components-text.md index 091d3507356076328dad2794aa539135ed324d40..807d43c11da95140f390f2799696e8a539ab29f3 100644 --- a/zh-cn/application-dev/ui/ui-js-components-text.md +++ b/zh-cn/application-dev/ui/ui-js-components-text.md @@ -1,20 +1,20 @@ -# Text +# textå¼€å‘指导 -Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Text API](../reference/arkui-js/js-components-basic-text.md)。 +text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[text API](../reference/arkui-js/js-components-basic-text.md)。 -## 创建Text组件 +## 创建text组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªText组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªtext组件。 -``` +```html <!-- xxx.hml --> <div class="container" style="text-align: center;justify-content: center; align-items: center;"> <text>Hello World</text> </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -29,13 +29,13 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex  -## 设置Textç»„ä»¶æ ·å¼å’Œå±žæ€§ +## 设置textç»„ä»¶æ ·å¼å’Œå±žæ€§ - æ·»åŠ æ–‡æœ¬æ ·å¼ è®¾ç½®colorã€font-sizeã€allow-scaleã€word-spacingã€text-valignå±žæ€§åˆ†åˆ«ä¸ºæ–‡æœ¬æ·»åŠ é¢œè‰²ã€å¤§å°ã€ç¼©æ”¾ã€æ–‡æœ¬ä¹‹é—´çš„é—´è·å’Œæ–‡æœ¬åœ¨åž‚ç›´æ–¹å‘的对é½æ–¹å¼ã€‚ - ``` + ```html <!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;flex-direction: column;justify-content: center; align-items: center;"> <text style="color: blueviolet; font-size: 40px; allow-scale:true"> @@ -47,7 +47,7 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex </div> ``` - ``` + ```css /* xxx.css */ .container { width: 100%; @@ -65,9 +65,9 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex - æ·»åŠ åˆ’çº¿ - 设置text-decorationå’Œtext-decoration-coloå±žæ€§ä¸ºæ–‡æœ¬æ·»åŠ åˆ’çº¿å’Œåˆ’çº¿é¢œè‰²ï¼Œtext-decoration枚举值请å‚考 Textè‡ªæœ‰æ ·å¼ã€‚ + 设置text-decorationå’Œtext-decoration-coloå±žæ€§ä¸ºæ–‡æœ¬æ·»åŠ åˆ’çº¿å’Œåˆ’çº¿é¢œè‰²ï¼Œtext-decoration枚举值请å‚考 textè‡ªæœ‰æ ·å¼ã€‚ - ``` + ```html <!-- xxx.hml --> <div class="container" style="background-color:#F1F3F5;"> <text style="text-decoration:underline"> @@ -79,7 +79,7 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex </div> ``` - ``` + ```css /* xxx.css */ .container { width: 100%; @@ -101,7 +101,7 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex 当文本内容过多而显示ä¸å…¨æ—¶ï¼Œæ·»åŠ text-overflow属性将éšè—内容以çœç•¥å·çš„å½¢å¼å±•çŽ°ã€‚ - ``` + ```html <!-- xxx.hml --> <div class="container"> <text class="text"> @@ -110,7 +110,7 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex </div> ``` - ``` + ```css /* xxx.css */ .container { width: 100%; @@ -136,9 +136,9 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex - 设置文本折行 - 设置word-break属性对文本内容åšæ–行处ç†ï¼Œword-break枚举值请å‚考Textè‡ªæœ‰æ ·å¼ã€‚ + 设置word-break属性对文本内容åšæ–行处ç†ï¼Œword-break枚举值请å‚考textè‡ªæœ‰æ ·å¼ã€‚ - ``` + ```html <!-- xxx.hml --> <div class="container"> <div class="content"> @@ -152,7 +152,7 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex </div> ``` - ``` + ```css /* xxx.css */ .container { width: 100%; @@ -190,9 +190,9 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex ​  -- Text组件支æŒ[Span](../reference/arkui-js/js-components-basic-span.md)å组件 +- text组件支æŒ[Span](../reference/arkui-js/js-components-basic-span.md)å组件 - ``` + ```html <!-- xxx.hml --> <div class="container" style="justify-content: center; align-items: center;flex-direction: column;background-color: #F1F3F5; width: 100%;height: 100%;"> <text style="font-size: 45px;"> @@ -208,17 +208,17 @@ Text是文本组件,用于呈现一段文本信æ¯ã€‚具体用法请å‚考[Tex ```  - >  **说明:** + > **说明:** > - 当使用Spanå组件组æˆæ–‡æœ¬æ®µè½æ—¶ï¼Œå¦‚æžœSpanå±žæ€§æ ·å¼å¼‚常(例如:font-weight设置为1000),将导致文本段è½æ˜¾ç¤ºå¼‚常。 > - > - 在使用Spanå组件时,注æ„Text组件内ä¸èƒ½å˜åœ¨æ–‡æœ¬å†…容,如果å˜åœ¨æ–‡æœ¬å†…容也åªä¼šæ˜¾ç¤ºå组件Span里的内容。 + > - 在使用Spanå组件时,注æ„text组件内ä¸èƒ½å˜åœ¨æ–‡æœ¬å†…容,如果å˜åœ¨æ–‡æœ¬å†…容也åªä¼šæ˜¾ç¤ºå组件Span里的内容。 ## 场景示例 -Text组件通过数æ®ç»‘定展示文本内容,Span组件通过设置show属性æ¥å®žçŽ°æ–‡æœ¬å†…容的éšè—和显示。 +text组件通过数æ®ç»‘定展示文本内容,Span组件通过设置show属性æ¥å®žçŽ°æ–‡æœ¬å†…容的éšè—和显示。 -``` +```html <!-- xxx.hml --> <div class="container"> <div style="align-items: center;justify-content: center;"> @@ -237,7 +237,7 @@ Text组件通过数æ®ç»‘定展示文本内容,Span组件通过设置show属 </div> ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -255,7 +255,7 @@ Text组件通过数æ®ç»‘定展示文本内容,Span组件通过设置show属 } ``` -``` +```js // xxx.js export default { data: { @@ -274,6 +274,6 @@ export default { ## 相关实例 -针对Textå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对textå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [`JsTextComponents`:基础组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsBasicComponents) +- [`JstextComponents`:基础组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsBasicComponents) diff --git a/zh-cn/application-dev/ui/ui-js-components-toolbar.md b/zh-cn/application-dev/ui/ui-js-components-toolbar.md index 6d71893d1d35313aae2528622eb4694d96cbf889..cf277d075e8d666a84f4ea2d23d278d39b6c30d8 100644 --- a/zh-cn/application-dev/ui/ui-js-components-toolbar.md +++ b/zh-cn/application-dev/ui/ui-js-components-toolbar.md @@ -1,15 +1,15 @@ -# Toolbarå¼€å‘指导 +# toolbarå¼€å‘指导 -Toolbar为页é¢å·¥å…·æ 组件,用于展示针对当å‰ç•Œé¢çš„æ“作选项,å¯ä½œä¸ºé¡µé¢çš„一级导航。具体用法请å‚考[Toolbar](../reference/arkui-js/js-components-basic-toolbar.md)。 +toolbar为页é¢å·¥å…·æ 组件,用于展示针对当å‰ç•Œé¢çš„æ“作选项,å¯ä½œä¸ºé¡µé¢çš„一级导航。具体用法请å‚考[toolbar](../reference/arkui-js/js-components-basic-toolbar.md)。 -## 创建Toolbar组件 +## 创建toolbar组件 -在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªToolbar组件。 +在pages/index目录下的hml文件ä¸åˆ›å»ºä¸€ä¸ªtoolbar组件。 -``` +```html <!-- xxx.hml --> <div class="container"> <toolbar style="background-color: #F1F3F5;"> @@ -20,7 +20,7 @@ Toolbar为页é¢å·¥å…·æ 组件,用于展示针对当å‰ç•Œé¢çš„æ“作选项 ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -40,9 +40,9 @@ toolbar-item{ ## æ·»åŠ å组件 - Toolbar组件仅支æŒtoolbar-item为å组件,页é¢æœ€å¤šå¯ä»¥å±•ç¤º5个toolbar-itemå组件,如果å˜åœ¨6个åŠä»¥ä¸Štoolbar-item,则ä¿ç•™å‰é¢4个,åŽç»çš„将收纳到工具æ 上的更多项ä¸ï¼Œé€šè¿‡ç‚¹å‡»æ›´å¤šé¡¹å¼¹çª—è¿›è¡Œå±•ç¤ºã€‚å¹¶ä¸”æ›´å¤šé¡¹å±•ç¤ºçš„ç»„ä»¶æ ·å¼é‡‡ç”¨ç³»ç»Ÿé»˜è®¤æ ·å¼ï¼Œtoolbar-itemä¸Šè®¾ç½®çš„è‡ªå®šä¹‰æ ·å¼ä¸ç”Ÿæ•ˆã€‚ + toolbar组件仅支æŒtoolbar-item为å组件,页é¢æœ€å¤šå¯ä»¥å±•ç¤º5个toolbar-itemå组件,如果å˜åœ¨6个åŠä»¥ä¸Štoolbar-item,则ä¿ç•™å‰é¢4个,åŽç»çš„将收纳到工具æ 上的更多项ä¸ï¼Œé€šè¿‡ç‚¹å‡»æ›´å¤šé¡¹å¼¹çª—è¿›è¡Œå±•ç¤ºã€‚å¹¶ä¸”æ›´å¤šé¡¹å±•ç¤ºçš„ç»„ä»¶æ ·å¼é‡‡ç”¨ç³»ç»Ÿé»˜è®¤æ ·å¼ï¼Œtoolbar-itemä¸Šè®¾ç½®çš„è‡ªå®šä¹‰æ ·å¼ä¸ç”Ÿæ•ˆã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <toolbar> @@ -57,7 +57,7 @@ toolbar-item{ ``` -``` +```css /* xxx.css */ .container { width: 100%; @@ -77,11 +77,11 @@ toolbar-item{ ## è®¾ç½®æ ·å¼ -设置positionæ ·å¼æŽ§åˆ¶Toolbar组件的ä½ç½®ï¼Œå¹¶è®¾ç½®å组件toolbar-itemçš„å—体颜色ã€å¤§å°åŠèƒŒæ™¯è‰²ã€‚ +设置positionæ ·å¼æŽ§åˆ¶toolbar组件的ä½ç½®ï¼Œå¹¶è®¾ç½®å组件toolbar-itemçš„å—体颜色ã€å¤§å°åŠèƒŒæ™¯è‰²ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <toolbar style="position: fixed;bottom: 5%;width: 100%;background-color: #F1F3F5;"> @@ -95,7 +95,7 @@ toolbar-item{ -``` +```css /* xxx.css */ .container { background-color: #F1F3F5; @@ -123,7 +123,7 @@ toolbar-item{ 分别给toolbar-item绑定å•å‡»äº‹ä»¶å’Œé•¿æŒ‰äº‹ä»¶ï¼Œå•å‡»åŽæ–‡æœ¬å˜çº¢ï¼Œé•¿æŒ‰æ—¶æ–‡æœ¬å˜è“。 -``` +```html <!-- xxx.hml --> <div class="container"> <toolbar style="position: fixed;top: 50%;width: 100%;background-color: #F1F3F5;"> @@ -135,7 +135,7 @@ toolbar-item{ ``` -``` +```css /* xxx.css */ .container { background-color: #F1F3F5; @@ -151,7 +151,7 @@ toolbar-item{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -171,8 +171,8 @@ export default {  ->  **说明:** -> Toolbar组件ä¸æ”¯æŒæ·»åŠ 事件和方法,但其å组件toolbar-item支æŒã€‚ +> **说明:** +> toolbar组件ä¸æ”¯æŒæ·»åŠ 事件和方法,但其å组件toolbar-item支æŒã€‚ ## 场景示例 @@ -181,7 +181,7 @@ export default { 使用for循环创建toolbar-itemç»„ä»¶å¹¶æ·»åŠ ç‚¹å‡»äº‹ä»¶ï¼Œç‚¹å‡»åŽèŽ·å¾—索引值进行å˜å‚¨ã€‚设置文本颜色时,判æ–当å‰ç´¢å¼•å€¼æ˜¯å¦ä¸ºå‚¨å˜çš„值,若相åŒåˆ™è®¾ç½®ä¸ºçº¢è‰²ï¼Œä¸åŒåˆ™ä½¿ç”¨é»˜è®¤é¢œè‰²ã€‚ -``` +```html <!-- xxx.hml --> <div class="container"> <image src="{{imgList[active]}}"></image> @@ -193,7 +193,7 @@ export default { ``` -``` +```css /* xxx.css */ .container { background-color: #F1F3F5; @@ -208,7 +208,7 @@ toolbar-item{ ``` -``` +```js // xxx.js import prompt from '@system.prompt'; export default { @@ -233,6 +233,6 @@ export default { ## 相关实例 -针对Toolbarå¼€å‘,有以下相关实例å¯ä¾›å‚考: +针对toolbarå¼€å‘,有以下相关实例å¯ä¾›å‚考: - [`Toolbar`:工具æ (JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Toolbar) diff --git a/zh-cn/application-dev/ui/ui-js-custom-components.md b/zh-cn/application-dev/ui/ui-js-custom-components.md index 3537724b05e0b34b3bdc789bc891dedfc85fb376..ee18744f78afe32fd1150662abe67fe7f8b650cd 100755 --- a/zh-cn/application-dev/ui/ui-js-custom-components.md +++ b/zh-cn/application-dev/ui/ui-js-custom-components.md @@ -4,7 +4,7 @@ - 构建自定义组件 - ``` + ```html <!-- comp.hml --> <div class="item"> <text class="title-style">{{title}}</text> @@ -13,7 +13,7 @@ </div> ``` - ``` + ```css /* comp.css */ .item { width: 700px; @@ -37,7 +37,7 @@ } ``` - ``` + ```js // comp.js export default { props: { @@ -59,7 +59,7 @@ ``` - 引入自定义组件 - ``` + ```html <!-- xxx.hml --> <element name='comp' src='../../common/component/comp.hml'></element> <div class="container"> @@ -68,7 +68,7 @@ </div> ``` - ``` + ```css /* xxx.css */ .container { background-color: #f8f8ff; @@ -78,7 +78,7 @@ } ``` - ``` + ```js // xxx.js export default { data: { @@ -105,4 +105,4 @@ - [`JSUICustomComponent`:自定义组件(JS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSUICustomComponent) -- [自定义组件(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/JSCanvasComponet) +- [自定义组件(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/JSCanvasComponet) diff --git a/zh-cn/application-dev/ui/ui-js-overview.md b/zh-cn/application-dev/ui/ui-js-overview.md index c94a28c66b7c6f45c80a8ed2b30a422de5f0450a..178416ba17362d3246441578cab30fc0bfaa8b4e 100755 --- a/zh-cn/application-dev/ui/ui-js-overview.md +++ b/zh-cn/application-dev/ui/ui-js-overview.md @@ -52,4 +52,4 @@ - [`Badge`ï¼šäº‹ä»¶æ ‡è®°æŽ§ä»¶ï¼ˆJS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge) -- [è´ç‰©åº”用(JS)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ShoppingOpenHarmony) +- [è´ç‰©åº”用(JS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/ShoppingOpenHarmony) diff --git a/zh-cn/application-dev/ui/ui-ts-basic-components-button.md b/zh-cn/application-dev/ui/ui-ts-basic-components-button.md index 47be13c7c5cce9df7e055ce770e523b96c6eb377..9983e643f1015dd8e4ecf4fe1449c6876b191565 100644 --- a/zh-cn/application-dev/ui/ui-ts-basic-components-button.md +++ b/zh-cn/application-dev/ui/ui-ts-basic-components-button.md @@ -12,7 +12,6 @@ Button通过调用接å£æ¥åˆ›å»ºï¼ŒæŽ¥å£è°ƒç”¨æœ‰ä»¥ä¸‹ä¸¤ç§å½¢å¼ï¼š `Button(options?: {type?: ButtonType, stateEffect?: boolean})`,该接å£ç”¨äºŽåˆ›å»ºåŒ…å«å组件的按钮,其ä¸type用于设置Button类型,stateEffect属性设置Button是å¦å¼€å¯ç‚¹å‡»æ•ˆæžœã€‚ - ``` Button({ type: ButtonType.Normal, stateEffect: true }) { Row() { @@ -22,13 +21,13 @@ Button通过调用接å£æ¥åˆ›å»ºï¼ŒæŽ¥å£è°ƒç”¨æœ‰ä»¥ä¸‹ä¸¤ç§å½¢å¼ï¼š }.borderRadius(8).backgroundColor(0x317aff).width(90) ``` +  - 创建ä¸åŒ…å«å组件的按钮 `Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean })`,该接å£ç”¨äºŽåˆ›å»ºä¸åŒ…å«å组件的按钮,其ä¸label确定所创建的Button是å¦åŒ…å«å组件。 - ``` Button('Ok', { type: ButtonType.Normal, stateEffect: true }) .borderRadius(8) @@ -36,6 +35,7 @@ Button通过调用接å£æ¥åˆ›å»ºï¼ŒæŽ¥å£è°ƒç”¨æœ‰ä»¥ä¸‹ä¸¤ç§å½¢å¼ï¼š .width(90) ``` +  @@ -45,7 +45,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 - 胶囊按钮(默认类型) - ``` + ```ts Button('Disable', { type: ButtonType.Capsule, stateEffect: false }) .backgroundColor(0x317aff) .width(90) @@ -55,7 +55,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 - 圆形按钮 - ``` + ```ts Button('Circle', { type: ButtonType.Circle, stateEffect: false }) .backgroundColor(0x317aff) .width(90) @@ -71,7 +71,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 一般使用通用属性æ¥è‡ªå®šä¹‰æŒ‰é’®æ ·å¼ã€‚例如通过borderRadius属性设置按钮的边框弧度。 - ``` + ```ts Button('circle border', { type: ButtonType.Normal }) .borderRadius(20) ``` @@ -82,7 +82,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 é€šè¿‡æ·»åŠ æ–‡æœ¬æ ·å¼è®¾ç½®æŒ‰é’®æ–‡æœ¬çš„å±•ç¤ºæ ·å¼ã€‚ - ``` + ```ts Button('font style', { type: ButtonType.Normal }) .fontSize(20) .fontColor(Color.Red) @@ -95,7 +95,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 æ·»åŠ backgroundColor属性设置按钮的背景颜色。 - ``` + ```ts Button('background color').backgroundColor(0xF55A42) ``` @@ -105,7 +105,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 ä¸ºåˆ é™¤æ“作创建一个按钮。 - ``` + ```ts Button({ type: ButtonType.Circle, stateEffect: true }) { Image($r('app.media.ic_public_delete_filled')).width(30).height(30) }.width(55).height(55).margin({ left: 20 }).backgroundColor(0xF55A42) @@ -119,7 +119,7 @@ Button有三ç§å¯é€‰ç±»åž‹ï¼Œåˆ†åˆ«ä¸ºCapsule(胶囊类型)ã€Circle(圆 Button组件通常用于触å‘æŸäº›æ“作,å¯ä»¥åœ¨ç»‘定onClick事件æ¥å“应点击æ“作åŽçš„自定义行为。 -``` +```ts Button('Ok', { type: ButtonType.Normal, stateEffect: true }) .onClick(()=>{ console.info('Button onClick') @@ -133,7 +133,8 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) å¯ä»¥å°†æŒ‰é’®ç”¨äºŽå¯åŠ¨æ“作的任何用户界é¢å…ƒç´ ã€‚æŒ‰é’®ä¼šæ ¹æ®ç”¨æˆ·çš„æ“作触å‘相应的事件。如,在List容器里边通过点击按钮进行页é¢è·³è½¬ï¼š - ``` + ```ts + // xxx.js import router from '@ohos.router' @Entry @@ -173,8 +174,9 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true }) 在用户登录/注册页é¢ï¼Œç”¨æˆ·çš„登录或注册的æ交æ“作会用按钮。 - ``` - @Entry + ```ts +// xxx.js +@Entry @Component struct ButtonCase2 { build() { diff --git a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md b/zh-cn/application-dev/ui/ui-ts-basic-resource-file-categories.md similarity index 68% rename from zh-cn/application-dev/quick-start/basic-resource-file-categories.md rename to zh-cn/application-dev/ui/ui-ts-basic-resource-file-categories.md index e15c49af5f6d2636c212ec794b8063d5439eed98..8f704f9f69a725690f39e855e38a51477c6cfe1e 100644 --- a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md +++ b/zh-cn/application-dev/ui/ui-ts-basic-resource-file-categories.md @@ -71,11 +71,62 @@ base目录与é™å®šè¯ç›®å½•ä¸‹é¢å¯ä»¥åˆ›å»ºèµ„æºç»„目录(包括element〠**表3** 资æºç»„目录说明 -| 资æºç»„目录 | 目录说明 | 资æºæ–‡ä»¶ | -| --------- | ---------------------------------------- | ---------------------------------------- | -| element | è¡¨ç¤ºå…ƒç´ èµ„æºï¼Œä»¥ä¸‹æ¯ä¸€ç±»æ•°æ®éƒ½é‡‡ç”¨ç›¸åº”çš„JSON文件æ¥è¡¨å¾ã€‚<br/>- boolean,布尔型<br/>- color,颜色<br/>- float,浮点型<br/>- intarray,整型数组<br/>- integer,整型<br/>- patternï¼Œæ ·å¼<br/>- plural,å¤æ•°å½¢å¼<br/>- strarray,å—符串数组<br/>- string,å—符串 | element目录ä¸çš„文件å称建议与下é¢çš„文件åä¿æŒä¸€è‡´ã€‚æ¯ä¸ªæ–‡ä»¶ä¸åªèƒ½åŒ…å«åŒä¸€ç±»åž‹çš„æ•°æ®ã€‚<br/>- boolean.json<br/>- color.json<br/>- float.json<br/>- intarray.json<br/>- integer.json<br/>- pattern.json<br/>- plural.json<br/>- strarray.json<br/>- string.json | -| media | 表示媒体资æºï¼ŒåŒ…括图片ã€éŸ³é¢‘ã€è§†é¢‘ç‰éžæ–‡æœ¬æ ¼å¼çš„文件。 | 文件åå¯è‡ªå®šä¹‰ï¼Œä¾‹å¦‚:icon.png。 | -| animation | 表示动画资æºï¼Œé‡‡ç”¨XMLæ–‡ä»¶æ ¼å¼ã€‚ | 文件åå¯è‡ªå®šä¹‰ï¼Œä¾‹å¦‚:zoom_in.xml。 | -| layout | 表示布局资æºï¼Œé‡‡ç”¨XMLæ–‡ä»¶æ ¼å¼ã€‚ | 文件åå¯è‡ªå®šä¹‰ï¼Œä¾‹å¦‚:home_layout.xml。 | -| graphic | 表示å¯ç»˜åˆ¶èµ„æºï¼Œé‡‡ç”¨XMLæ–‡ä»¶æ ¼å¼ã€‚ | 文件åå¯è‡ªå®šä¹‰ï¼Œä¾‹å¦‚:notifications_dark.xml。 | -| profile | 表示其他类型文件,以原始文件形å¼ä¿å˜ã€‚ | 文件åå¯è‡ªå®šä¹‰ã€‚ | +| 资æºç»„目录 | 目录说明 | 资æºæ–‡ä»¶ | +| ------- | ---------------------------------------- | ---------------------------------------- | +| element | è¡¨ç¤ºå…ƒç´ èµ„æºï¼Œä»¥ä¸‹æ¯ä¸€ç±»æ•°æ®éƒ½é‡‡ç”¨ç›¸åº”çš„JSON文件æ¥è¡¨å¾ã€‚<br/>- boolean,布尔型<br/>- color,颜色<br/>- float,浮点型<br/>- intarray,整型数组<br/>- integer,整型<br/>- patternï¼Œæ ·å¼<br/>- plural,å¤æ•°å½¢å¼<br/>- strarray,å—符串数组<br/>- string,å—符串 | element目录ä¸çš„文件å称建议与下é¢çš„文件åä¿æŒä¸€è‡´ã€‚æ¯ä¸ªæ–‡ä»¶ä¸åªèƒ½åŒ…å«åŒä¸€ç±»åž‹çš„æ•°æ®ã€‚<br/>- boolean.json<br/>- color.json<br/>- float.json<br/>- intarray.json<br/>- integer.json<br/>- pattern.json<br/>- plural.json<br/>- strarray.json<br/>- string.json | +| media | 表示媒体资æºï¼ŒåŒ…括图片ã€éŸ³é¢‘ã€è§†é¢‘ç‰éžæ–‡æœ¬æ ¼å¼çš„文件。 | 文件åå¯è‡ªå®šä¹‰ï¼Œä¾‹å¦‚:icon.png。 | +| profile | 表示其他类型文件,以原始文件形å¼ä¿å˜ã€‚ | 文件åå¯è‡ªå®šä¹‰ã€‚ | + +### 媒体资æºç±»åž‹è¯´æ˜Ž + +表1 图片资æºç±»åž‹è¯´æ˜Ž + +| æ ¼å¼ | 文件åŽç¼€å | +| ---- | ----- | +| JPEG | .jpg | +| PNG | .png | +| GIF | .gif | +| SVG | .svg | +| WEBP | .webp | +| BMP | .bmp | + +表2 音视频资æºç±»åž‹è¯´æ˜Ž + +| æ ¼å¼ | 支æŒçš„文件类型 | +| ------------------------------------ | --------------- | +| H.263 | .3gp <br>.mp4 | +| H.264 AVC <br> Baseline Profile (BP) | .3gp <br>.mp4 | +| MPEG-4 SP | .3gp | +| VP8 | .webm <br> .mkv | + +## 创建资æºæ–‡ä»¶ + +在resources目录下,å¯æŒ‰ç…§é™å®šè¯ç›®å½•å’Œèµ„æºç»„目录的说明创建å目录和目录内的文件。 + +åŒæ—¶ï¼ŒDevEco Studio也æ供了创建资æºç›®å½•å’Œèµ„æºæ–‡ä»¶çš„ç•Œé¢ã€‚ + +- 创建资æºç›®å½•åŠèµ„æºæ–‡ä»¶ + + 在resources目录å³é”®èœå•é€‰æ‹©â€œNew > Resource Fileâ€ï¼Œæ¤æ—¶å¯åŒæ—¶åˆ›å»ºç›®å½•å’Œæ–‡ä»¶ã€‚ + + 文件默认创建在base目录的对应资æºç»„下。如果选择了é™å®šè¯ï¼Œåˆ™ä¼šæŒ‰ç…§å‘½å规范自动生æˆé™å®šè¯+资æºç»„目录,并将文件创建在目录ä¸ã€‚ + + 目录å自动生æˆï¼Œæ ¼å¼å›ºå®šä¸ºâ€œé™å®šè¯.资æºç»„â€ï¼Œä¾‹å¦‚创建一个é™å®šè¯ä¸ºæ¨ªç«–å±ç±»åˆ«ä¸‹çš„ç«–å±ï¼Œèµ„æºç»„为绘制资æºçš„目录,自动生æˆçš„目录å称为“vertical.graphicâ€ã€‚ + +  + +- 创建资æºç›®å½• + + 在resources目录å³é”®èœå•é€‰æ‹©â€œNew > Resource Directoryâ€ï¼Œæ¤æ—¶å¯åˆ›å»ºèµ„æºç›®å½•ã€‚ + + 选择资æºç»„类型,设置é™å®šè¯ï¼Œåˆ›å»ºåŽè‡ªåŠ¨ç”Ÿæˆç›®å½•å称。目录åç§°æ ¼å¼å›ºå®šä¸ºâ€œé™å®šè¯.资æºç»„â€ï¼Œä¾‹å¦‚创建一个é™å®šè¯ä¸ºæ¨ªç«–å±ç±»åˆ«ä¸‹çš„ç«–å±ï¼Œèµ„æºç»„为绘制资æºçš„目录,自动生æˆçš„目录å称为“vertical.graphicâ€ã€‚ + +  + +- 创建资æºæ–‡ä»¶ + + 在资æºç›®å½•çš„å³é”®èœå•é€‰æ‹©â€œNew > XXX Resource Fileâ€ï¼Œå³å¯åˆ›å»ºå¯¹åº”资æºç»„目录的资æºæ–‡ä»¶ã€‚ + + 例如,在element目录下å¯æ–°å»ºElement Resource File。 + +  \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md index 876ab9c8f4d4915b10e0e8f84f9f0c69c4c05c05..51ee15b3e6c18b9b51340a51c0b54f133ce6700d 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md +++ b/zh-cn/application-dev/ui/ui-ts-building-category-grid-layout.md @@ -6,12 +6,12 @@ 1. å°†Category枚举类型引入FoodCategoryList页é¢ã€‚ - ``` + ```ts import { Category, FoodData } from '../model/FoodData' ``` 2. 创建FoodCategoryListå’ŒFoodCategory组件,其ä¸FoodCategoryList作为新的页é¢å…¥å£ç»„件,在入å£ç»„件调用initializeOnStartup方法。 - ``` + ```ts @Component struct FoodList { private foodItems: FoodData[] @@ -19,7 +19,7 @@ ...... } } - + @Component struct FoodCategory { private foodItems: FoodData[] @@ -27,7 +27,7 @@ ...... } } - + @Entry @Component struct FoodCategoryList { @@ -39,13 +39,13 @@ ``` 3. 在FoodCategoryList组件内创建showListæˆå‘˜å˜é‡ï¼Œç”¨äºŽæŽ§åˆ¶List布局和Grid布局的渲染切æ¢ã€‚需è¦ç”¨åˆ°æ¡ä»¶æ¸²æŸ“è¯å¥if...else...。 - ``` + ```ts @Entry @Component struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() private showList: boolean = false - + build() { Stack() { if (this.showList) { @@ -59,13 +59,13 @@ ``` 4. 在页é¢å³ä¸Šè§’创建切æ¢List/Gridå¸ƒå±€çš„å›¾æ ‡ã€‚è®¾ç½®Stack对é½æ–¹å¼ä¸ºé¡¶éƒ¨å°¾éƒ¨å¯¹é½TopEnd,创建Image组件,设置其点击事件,å³showListå–å。 - ``` + ```ts @Entry @Component struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() private showList: boolean = false - + build() { Stack({ alignContent: Alignment.TopEnd }) { if (this.showList) { @@ -86,13 +86,13 @@ ``` 5. æ·»åŠ \@State装饰器。点击å³ä¸Šè§’çš„switchæ ‡ç¾åŽï¼Œé¡µé¢æ²¡æœ‰ä»»ä½•å˜åŒ–ï¼Œè¿™æ˜¯å› ä¸ºshowListä¸æ˜¯æœ‰çŠ¶æ€æ•°æ®ï¼Œå®ƒçš„改å˜ä¸ä¼šè§¦å‘页é¢çš„刷新。需è¦ä¸ºå…¶æ·»åŠ \@State装饰器,使其æˆä¸ºçŠ¶æ€æ•°æ®ï¼Œå®ƒçš„改å˜ä¼šå¼•èµ·å…¶æ‰€åœ¨ç»„件的é‡æ–°æ¸²æŸ“。 - ``` + ```ts @Entry @Component struct FoodCategoryList { private foodItems: FoodData[] = initializeOnStartup() @State private showList: boolean = false - + build() { Stack({ alignContent: Alignment.TopEnd }) { if (this.showList) { @@ -110,7 +110,7 @@ }.height('100%') } } - + ``` 点击切æ¢å›¾æ ‡ï¼ŒFoodList组件出现,å†æ¬¡ç‚¹å‡»ï¼ŒFoodList组件消失。 @@ -118,7 +118,7 @@  6. 创建显示所有食物的页ç¾ï¼ˆAll)。在FoodCategory组件内创建Tabs组件和其å组件TabContent,设置tabBar为All。设置TabBars的宽度为280,布局模å¼ä¸ºScrollable,å³è¶…过总长度åŽå¯ä»¥æ»‘动。Tabs是一ç§å¯ä»¥é€šè¿‡é¡µç¾è¿›è¡Œå†…容视图切æ¢çš„容器组件,æ¯ä¸ªé¡µç¾å¯¹åº”一个内容视图TabContent。 - ``` + ```ts @Component struct FoodCategory { private foodItems: FoodData[] @@ -137,13 +137,13 @@  7. 创建FoodGrid组件,作为TabContentçš„å组件。 - ``` + ```ts @Component struct FoodGrid { private foodItems: FoodData[] build() {} } - + @Component struct FoodCategory { private foodItems: FoodData[] @@ -162,7 +162,7 @@ ``` 8. 实现2 \* 6çš„ç½‘æ ¼å¸ƒå±€ï¼ˆä¸€å…±12个食物数æ®èµ„æºï¼‰ã€‚创建Grid组件,设置列数columnsTemplate('1fr 1fr'),行数rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr'),行间è·å’Œåˆ—é—´è·rowsGapå’ŒcolumnsGap为8。创建Scroll组件,使其å¯ä»¥æ»‘动。 - ``` + ```ts @Component struct FoodGrid { private foodItems: FoodData[] @@ -185,7 +185,7 @@ ``` 9. 创建FoodGridItem组件,展示食物图片ã€å称和å¡è·¯é‡Œï¼Œå®žçŽ°å…¶UI布局,为GridItemçš„å组件。æ¯ä¸ªFoodGridItem高度为184,行间è·ä¸º8,设置Grid总高度为(184 + 8) \* 6 - 8 = 1144。 - ``` + ```ts @Component struct FoodGridItem { private foodItem: FoodData @@ -214,7 +214,7 @@ .width('100%') } } - + @Component struct FoodGrid { private foodItems: FoodData[] @@ -242,48 +242,48 @@  10. 创建展示蔬èœï¼ˆCategory.Vegetable)ã€æ°´æžœï¼ˆCategory.Fruit)ã€åšæžœï¼ˆCategory.Nut)ã€æµ·é²œï¼ˆCategory.SeaFood)和甜å“(Category.Dessert)分类的页ç¾ã€‚ - ``` - @Component - struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() { - FoodGrid({ foodItems: this.foodItems }) - }.tabBar('All') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) - }.tabBar('Vegetable') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) - }.tabBar('Fruit') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) - }.tabBar('Nut') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) - }.tabBar('Seafood') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) - }.tabBar('Dessert') - } - .barWidth(280) - .barMode(BarMode.Scrollable) - } - } - } - ``` + ```ts + @Component + struct FoodCategory { + private foodItems: FoodData[] + build() { + Stack() { + Tabs() { + TabContent() { + FoodGrid({ foodItems: this.foodItems }) + }.tabBar('All') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) + }.tabBar('Vegetable') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) + }.tabBar('Fruit') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) + }.tabBar('Nut') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) + }.tabBar('Seafood') + + TabContent() { + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) + }.tabBar('Dessert') + } + .barWidth(280) + .barMode(BarMode.Scrollable) + } + } + } + ``` 11. 设置ä¸åŒé£Ÿç‰©åˆ†ç±»çš„Gridçš„è¡Œæ•°å’Œé«˜åº¦ã€‚å› ä¸ºä¸åŒåˆ†ç±»çš„食物数é‡ä¸åŒï¼Œæ‰€ä»¥ä¸èƒ½ç”¨'1fr 1fr 1fr 1fr 1fr 1fr '常é‡æ¥ç»Ÿä¸€è®¾ç½®æˆ6行。 创建gridRowTemplateå’ŒHeightValueæˆå‘˜å˜é‡ï¼Œé€šè¿‡æˆå‘˜å˜é‡è®¾ç½®Grid行数和高度。 - ``` + ```ts @Component struct FoodGrid { private foodItems: FoodData[] @@ -312,7 +312,7 @@ 调用aboutToAppear接å£è®¡ç®—行数(gridRowTemplate )和高度(heightValue)。 - ``` + ```ts aboutToAppear() { var rows = Math.round(this.foodItems.length / 2); this.gridRowTemplate = '1fr '.repeat(rows); @@ -324,7 +324,7 @@  - ``` + ```ts @Component struct FoodGrid { private foodItems: FoodData[] diff --git a/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md b/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md index 8a75c1334e56cabf94fc1879814ab70adc6be9f3..bb5ab8da2f5078e85109101f3f0a07257e609f40 100644 --- a/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md +++ b/zh-cn/application-dev/ui/ui-ts-building-category-list-layout.md @@ -6,7 +6,7 @@ 1. 在pages目录新建页é¢FoodCategoryList.ets,将index.ets改å为FoodDetail.etsï¼Œå¹¶å°†å…¶æ·»åŠ åˆ°config.json文件下的pagesæ ‡ç¾ï¼Œä½äºŽç¬¬ä¸€åºä½çš„页é¢ä¸ºé¦–页。 - ``` + ```json "js": [ { "pages": [ @@ -22,7 +22,7 @@ struct FoodListItem { build() {} } - + @Entry @Component struct FoodList { @@ -46,13 +46,13 @@ ``` import { FoodData } from '../model/FoodData' import { initializeOnStartup } from '../model/FoodDataModels' - + @Component struct FoodListItem { private foodItem: FoodData build() {} } - + @Entry @Component struct FoodList { @@ -71,7 +71,7 @@ ``` import { FoodData } from '../model/FoodData' import { initializeOnStartup } from '../model/FoodDataModels' - + @Component struct FoodListItem { private foodItem: FoodData @@ -93,7 +93,7 @@ .margin({ right: 24, left:32 }) } } - + @Entry @Component struct FoodList { @@ -114,7 +114,7 @@ ``` import { FoodData } from '../model/FoodData' import { initializeOnStartup } from '../model/FoodDataModels' - + @Component struct FoodListItem { private foodItem: FoodData @@ -136,7 +136,7 @@ .margin({ right: 24, left:32 }) } } - + @Entry @Component struct FoodList { @@ -182,7 +182,7 @@ ``` import { FoodData } from '../model/FoodData' import { initializeOnStartup } from '../model/FoodDataModels' - + @Component struct FoodListItem { private foodItem: FoodData @@ -204,7 +204,7 @@ .margin({ right: 24, left:32 }) } } - + @Entry @Component struct FoodList { diff --git a/zh-cn/application-dev/ui/ui-ts-components-web.md b/zh-cn/application-dev/ui/ui-ts-components-web.md index 8d223f77587c83475f2720b8b62d11776af7e507..0386a7108587acaca55c42f5e07624fa2115a974 100644 --- a/zh-cn/application-dev/ui/ui-ts-components-web.md +++ b/zh-cn/application-dev/ui/ui-ts-components-web.md @@ -6,7 +6,7 @@ Web是æ供网页显示能力的组件,具体用法请å‚考 [Web API](../ref 在main/ets/MainAbility/pages目录下的ets文件ä¸åˆ›å»ºä¸€ä¸ªWeb组件。在web组件ä¸é€šè¿‡src指定引用的网页路径,controller为组件的控制器,通过controller绑定Web组件,用于调用Web组件的方法。 - ``` + ```ts // xxx.ets @Entry @Component @@ -24,7 +24,7 @@ Web是æ供网页显示能力的组件,具体用法请å‚考 [Web API](../ref Web组件的使用需è¦æ·»åŠ 丰富的页é¢æ ·å¼å’ŒåŠŸèƒ½å±žæ€§ã€‚设置heightã€paddingæ ·å¼å¯ä¸ºWebç»„ä»¶æ·»åŠ é«˜å’Œå†…è¾¹è·ï¼Œè®¾ç½®fileAccess属性å¯ä¸ºWebç»„ä»¶æ·»åŠ æ–‡ä»¶è®¿é—®æƒé™ï¼Œè®¾ç½®javaScriptAccess属性为true使Web组件具有执行JavaScript代ç 的能力。 -``` +```ts // xxx.ets @Entry @Component @@ -52,7 +52,7 @@ struct WebComponent { 为Webç»„ä»¶æ·»åŠ onProgressChange事件,该事件回调Webå¼•æ“ŽåŠ è½½é¡µé¢çš„进度值。将该进度值赋值给Progress组件的value,控制Progress组件的状æ€ã€‚当进度为100%æ—¶éšè—Progress组件,Web页é¢åŠ 载完æˆã€‚ -``` +```ts // xxx.ets @Entry @Component @@ -91,7 +91,7 @@ struct WebComponent { ``` 在onPageEnd事件ä¸æ·»åŠ runJavaScript方法。onPageEndäº‹ä»¶æ˜¯ç½‘é¡µåŠ è½½å®Œæˆæ—¶çš„回调,runJavaScript方法å¯ä»¥æ‰§è¡ŒHTMLä¸çš„JavaScript脚本。当页é¢åŠ 载完æˆæ—¶ï¼Œè§¦å‘onPageEnd事件,调用HTML文件ä¸çš„test方法,在控制å°æ‰“å°ä¿¡æ¯ã€‚ -``` +```ts // xxx.ets @Entry @Component @@ -136,7 +136,7 @@ struct WebComponent { 在main/resources/rawfile目录下创建一个HTML文件。 -``` +```html <!-- index.html --> <!DOCTYPE html> <html> @@ -155,7 +155,7 @@ struct WebComponent { 该场景实现了Web组件ä¸è§†é¢‘的动æ€æ’放。首先在HTML页é¢å†…嵌入视频资æºï¼Œå†ä½¿ç”¨Web组件的控制器调用onActiveå’ŒonInactive方法激活和暂åœé¡µé¢æ¸²æŸ“。点击onInactive按钮,Web页é¢åœæ¢æ¸²æŸ“,视频暂åœæ’放;点击onActive按钮,激活Web组件,视频继ç»æ’放。 - ``` + ```ts // xxx.ets @Entry @Component @@ -180,7 +180,7 @@ struct WebComponent { } ``` - ``` + ```html <!-- index.html --> <!DOCTYPE html> <html> @@ -198,4 +198,6 @@ struct WebComponent { 针对Webå¼€å‘,有以下相关实例å¯ä¾›å‚考: -- [`Web`:Web(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Web) \ No newline at end of file +- [`Web`:Web(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Web) + +- [Webç»„ä»¶åŠ è½½æœ¬åœ°H5å°ç¨‹åºï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/WebComponent) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-ts-components.md b/zh-cn/application-dev/ui/ui-ts-components.md index a255554228a44cd2188e02c9aff0c1a9f27cbfa2..7712c3c67422daacbc299bd3b57d5253123f1afb 100644 --- a/zh-cn/application-dev/ui/ui-ts-components.md +++ b/zh-cn/application-dev/ui/ui-ts-components.md @@ -9,14 +9,14 @@ 自定义组件的声明方å¼ä¸ºï¼š -``` +```ts @Component struct MyComponent {} ``` 在IDE创建工程模æ¿ä¸ï¼ŒMyComponent就是一个å¯ä»¥å±…ä¸æ˜¾ç¤ºæ–‡å—的自定义组件。开å‘者å¯ä»¥åœ¨Componentçš„build方法里æ述自己的UI结构,但需è¦éµå¾ªBuilder的接å£çº¦æŸã€‚ -``` +```ts interface Builder { build: () => void } diff --git a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md index 2b3463b86220f42a37bcdd1101b9beb2a1f1cb7d..1a6c7469f65fc06056fed280aaebb3a3216e8c23 100644 --- a/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md +++ b/zh-cn/application-dev/ui/ui-ts-creating-simple-page.md @@ -440,9 +440,6 @@ .fontWeight(FontWeight.Bold) .layoutWeight(1) Flex({ alignItems: ItemAlign.Center }) { - Circle({width: 6, height: 6}) - .margin({right: 12}) - .fill(colorValue) Text(name) .fontSize(17.4) .flexGrow(1) diff --git a/zh-cn/application-dev/ui/ui-ts-layout-flex.md b/zh-cn/application-dev/ui/ui-ts-layout-flex.md index 7706637b7cd3f73395b027db4340fdb2f671c77a..2fe5474f2ac9a6ebee04cb63cb4ebe0311112758 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-flex.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-flex.md @@ -17,7 +17,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexDirection.Row(默认值):主轴为水平方å‘,å组件从起始端沿ç€æ°´å¹³æ–¹å‘开始排布。 - ``` + ```ts Flex({ direction: FlexDirection.Row }) { Text('1').width('33%').height(50).backgroundColor(0xF5DEB3) Text('2').width('33%').height(50).backgroundColor(0xD2B48C) @@ -33,7 +33,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexDirection.RowReverse:主轴为水平方å‘,å组件从终点端沿ç€FlexDirection.Row相åçš„æ–¹å‘开始排布。 - ``` + ```ts Flex({ direction: FlexDirection.RowReverse }) { Text('1').width('33%').height(50).backgroundColor(0xF5DEB3) Text('2').width('33%').height(50).backgroundColor(0xD2B48C) @@ -49,7 +49,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexDirection.Column:主轴为垂直方å‘,å组件从起始端沿ç€åž‚ç›´æ–¹å‘开始排布。 - ``` + ```ts Flex({ direction: FlexDirection.Column }) { Text('1').width('100%').height(50).backgroundColor(0xF5DEB3) Text('2').width('100%').height(50).backgroundColor(0xD2B48C) @@ -65,7 +65,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexDirection.ColumnReverse:主轴为垂直方å‘,å组件从终点端沿ç€FlexDirection.Column相åçš„æ–¹å‘开始排布。 - ``` + ```ts Flex({ direction: FlexDirection.ColumnReverse }) { Text('1').width('100%').height(50).backgroundColor(0xF5DEB3) Text('2').width('100%').height(50).backgroundColor(0xD2B48C) @@ -86,7 +86,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexWrap.NoWrap : ä¸æ¢è¡Œã€‚如果åå…ƒç´ çš„å®½åº¦æ€»å’Œå¤§äºŽçˆ¶å…ƒç´ çš„å®½åº¦ï¼Œåˆ™åå…ƒç´ ä¼šè¢«åŽ‹ç¼©å®½åº¦ã€‚ - ``` + ```ts Flex({ wrap: FlexWrap.NoWrap }) { Text('1').width('50%').height(50).backgroundColor(0xF5DEB3) Text('2').width('50%').height(50).backgroundColor(0xD2B48C) @@ -101,7 +101,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexWrap.Wrap:æ¢è¡Œã€‚ - ``` + ```ts Flex({ wrap: FlexWrap.Wrap }) { Text('1').width('50%').height(50).backgroundColor(0xF5DEB3) Text('2').width('50%').height(50).backgroundColor(0xD2B48C) @@ -116,7 +116,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexWrap.WrapReverse:æ¢è¡Œï¼Œä¸”与行排列方å‘相å。 - ``` + ```ts Flex({ wrap: FlexWrap.WrapReverse}) { Text('1').width('50%').height(50).backgroundColor(0xF5DEB3) Text('2').width('50%').height(50).backgroundColor(0xD2B48C) @@ -139,7 +139,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.Start: å…ƒç´ åœ¨ä¸»è½´æ–¹å‘首端对é½, ç¬¬ä¸€ä¸ªå…ƒç´ ä¸Žè¡Œé¦–å¯¹é½ï¼ŒåŒæ—¶åŽç»çš„å…ƒç´ ä¸Žå‰ä¸€ä¸ªå¯¹é½ã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.Start }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -154,7 +154,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.Center: å…ƒç´ åœ¨ä¸»è½´æ–¹å‘ä¸å¿ƒå¯¹é½ï¼Œç¬¬ä¸€ä¸ªå…ƒç´ 与行首的è·ç¦»ä¸Žæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾è·ç¦»ç›¸åŒã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.Center }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -169,7 +169,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.End: å…ƒç´ åœ¨ä¸»è½´æ–¹å‘尾部对é½, 最åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ï¼Œå…¶ä»–å…ƒç´ ä¸ŽåŽä¸€ä¸ªå¯¹é½ã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.End }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -184,7 +184,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.SpaceBetween: Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ ç¬¬ä¸€ä¸ªå…ƒç´ ä¸Žè¡Œé¦–å¯¹é½ï¼Œæœ€åŽä¸€ä¸ªå…ƒç´ 与行尾对é½ã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.SpaceBetween }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -199,7 +199,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.SpaceAround: Flex主轴方å‘å‡åŒ€åˆ†é…å¼¹æ€§å…ƒç´ ï¼Œç›¸é‚»å…ƒç´ ä¹‹é—´è·ç¦»ç›¸åŒã€‚ ç¬¬ä¸€ä¸ªå…ƒç´ åˆ°è¡Œé¦–çš„è·ç¦»å’Œæœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的è·ç¦»æ˜¯ç›¸é‚»å…ƒç´ 之间è·ç¦»çš„一åŠã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.SpaceAround }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -214,7 +214,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - FlexAlign.SpaceEvenly: Flex主轴方å‘å…ƒç´ ç‰é—´è·å¸ƒå±€ï¼Œ ç›¸é‚»å…ƒç´ ä¹‹é—´çš„é—´è·ã€ç¬¬ä¸€ä¸ªå…ƒç´ 与行首的间è·ã€æœ€åŽä¸€ä¸ªå…ƒç´ 到行尾的间è·éƒ½å®Œå…¨ä¸€æ ·ã€‚ - ``` + ```ts Flex({ justifyContent: FlexAlign.SpaceEvenly }) { Text('1').width('20%').height(50).backgroundColor(0xF5DEB3) Text('2').width('20%').height(50).backgroundColor(0xD2B48C) @@ -234,7 +234,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.Auto: 使用Flex容器ä¸é»˜è®¤é…置。 - ``` + ```ts Flex({ alignItems: ItemAlign.Auto }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -249,7 +249,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.Start: 交å‰è½´æ–¹å‘首部对é½ã€‚ - ``` + ```ts Flex({ alignItems: ItemAlign.Start }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -264,7 +264,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.Center: 交å‰è½´æ–¹å‘å±…ä¸å¯¹é½ã€‚ - ``` + ```ts Flex({ alignItems: ItemAlign.Center }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -279,7 +279,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.End:交å‰è½´æ–¹å‘底部对é½ã€‚ - ``` + ```ts Flex({ alignItems: ItemAlign.End }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -294,7 +294,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.Stretch:交å‰è½´æ–¹å‘拉伸填充,在未设置尺寸时,拉伸到容器尺寸。 - ``` + ```ts Flex({ alignItems: ItemAlign.Stretch }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -309,7 +309,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ - ItemAlign.Baseline:交å‰è½´æ–¹å‘文本基线对é½ã€‚ - ``` + ```ts Flex({ alignItems: ItemAlign.Baseline }) { Text('1').width('33%').height(30).backgroundColor(0xF5DEB3) Text('2').width('33%').height(40).backgroundColor(0xD2B48C) @@ -344,7 +344,7 @@ Flex组件用于创建弹性布局,开å‘者å¯ä»¥é€šè¿‡Flex的接å£åˆ›å»ºå®¹ å¯ä½¿ç”¨å¼¹æ€§å¸ƒå±€åšå‡ºåå…ƒç´ æŽ’åˆ—æ–¹å¼ä¸ºæ°´å¹³æ–¹å‘排列,且åå…ƒç´ çš„æ€»å®½åº¦è¶…å‡ºçˆ¶å…ƒç´ çš„å®½åº¦ä¸æ¢è¡Œï¼Œåå…ƒç´ åœ¨æ°´å¹³æ–¹å‘两端对é½ï¼Œä¸é—´é—´è·ç”±é™¤é¦–尾外的åå…ƒç´ å¹³åˆ†ï¼Œç«–ç›´æ–¹å‘上åå…ƒç´ å±…ä¸çš„效果。 -``` +```ts @Entry @Component struct FlexExample { @@ -374,4 +374,6 @@ struct FlexExample { 针对弹性布局开å‘,有以下相关实例å¯ä¾›å‚考: -- [弹性布局(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/FlowLayoutEts) +- [弹性布局(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/FlowLayoutEts) + +- [ArkUI常用布局容器对é½æ–¹å¼ï¼ˆeTS)(API9)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/LayoutAlignmentDemo) diff --git a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md index e32f4b0b2c140bd70006b4e0fdb2879812fadcfc..8fc5f5cfe572208bc16d23fe458c0e4074212fea 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md @@ -50,13 +50,13 @@ - å¯ä»¥é€šè¿‡å‚æ•°å®šä¹‰æ …æ ¼å¸ƒå±€çš„æ€»åˆ—æ•°ï¼ˆcolumns),间隔(gutter),两侧边è·ï¼ˆmargin)ã€‚ä¾‹å¦‚æ …æ ¼å®¹å™¨æ€»å…±åˆ†ä¸º6列,列与列间隔为10vp, 两侧边è·ä¸º20vp: - ``` + ```ts GridContainer({ columns: 6, gutter: 10, margin: 20 }) {} ``` æ …æ ¼å®¹å™¨ä¸è®¾ç½®å‚数,或者sizeType设置为SizeType.Autoæ—¶ä½¿ç”¨é»˜è®¤çš„æ …æ ¼ç³»ç»Ÿå®šä¹‰ï¼Œå¦‚ï¼š - ``` + ```ts GridContainer() {} ``` @@ -64,10 +64,9 @@ - 也å¯ä»¥é€šè¿‡å‚æ•°sizeType指定æ¤æ …æ ¼å®¹å™¨å†…çš„ç»„ä»¶ä½¿ç”¨æ¤è®¾å¤‡å®½åº¦ç±»åž‹çš„æ …æ ¼è®¾ç½®ï¼Œå¦‚ï¼š - ``` + ```ts GridContainer({ sizeType: SizeType.SM) { Row() { - Text('1') .useSizeType({ xs: { span: 2}, @@ -85,7 +84,7 @@ æ …æ ¼å®¹å™¨ä¸çš„组件使用通用属性useSizeType设置ä¸åŒçš„设备宽度类型的å 用列数和列å移。其ä¸spanè¡¨ç¤ºæ …æ ¼å®¹å™¨ç»„ä»¶å æ®columnsçš„æ•°é‡ï¼›offest表示列å移é‡ï¼ŒæŒ‡å°†ç»„件放置在哪一个columns上。 如: -``` +```ts GridContainer() { Row() { Text('1') @@ -103,7 +102,7 @@ GridContainer() { ä½¿ç”¨æ …æ ¼å¸ƒå±€å¯ä»¥çµæ´»åœ°åœ¨ä¸åŒçš„设备宽度类型下呈现åˆé€‚的效果,而ä¸å¿…书写大é‡çš„代ç 兼容ä¸åŒå®½åº¦ç±»åž‹çš„设备。 -``` +```ts @Entry @Component struct GridContainerExample { diff --git a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md index 11a08f36e61d599bc956732dce4019c26262fc80..85b9d19fd65520302a9889724eb4e69f86f915ab 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-mediaquery.md @@ -18,11 +18,11 @@ import mediaquery from '@ohos.mediaquery' ``` 然åŽé€šè¿‡matchMediaSync接å£è®¾ç½®åª’体查询æ¡ä»¶ï¼Œå¹¶ä¿å˜è¿”回的æ¡ä»¶ç›‘å¬å¥æŸ„,例如: -``` +```ts listener = mediaquery.matchMediaSync('(orientation: landscape)') ``` 最åŽé€šè¿‡ä¸Šé¢ä¿å˜çš„æ¡ä»¶ç›‘å¬å¥æŸ„listener去注册回调函数,在回调函数里更改页é¢å¸ƒå±€æˆ–者实现业务逻辑,当匹é…到媒体查询æ¡ä»¶æ—¶ä¼šè§¦å‘æ¤å›žè°ƒå‡½æ•°ï¼Œä¾‹å¦‚: -``` +```ts onPortrait(mediaQueryResult) { if (mediaQueryResult.matches) { // do something here @@ -63,8 +63,8 @@ listener.on('change', onPortrait) | 类型 | 说明 | | -------- | ---------------------------------------- | | and | 将多个媒体特å¾ï¼ˆMedia Feature)以“与â€çš„æ–¹å¼è¿žæŽ¥æˆä¸€ä¸ªåª’体查询,åªæœ‰å½“所有媒体特å¾éƒ½ä¸ºtrue,查询æ¡ä»¶æˆç«‹ã€‚å¦å¤–,它还å¯ä»¥å°†åª’体类型和媒体功能结åˆèµ·æ¥ã€‚<br/>例如:screen and (device-type: wearable) and (max-height: 600) 表示当设备类型是智能穿戴åŒæ—¶åº”用的最大高度å°äºŽç‰äºŽ600个åƒç´ å•ä½æ—¶æˆç«‹ã€‚ | -| not | å–å媒体查询结果,媒体查询结果ä¸æˆç«‹æ—¶è¿”回true,å¦åˆ™è¿”回false。在媒体查询列表ä¸åº”用not,则notä»…å–å应用它的媒体查询。<br/>例如:not screen and (min-height: 50) and (max-height: 600) 表示当应用高度å°äºŽ50个åƒç´ å•ä½æˆ–者大于600个åƒç´ å•ä½æ—¶æˆç«‹ã€‚<br/>>  **说明:**<br/>> 使用notè¿ç®—符时必须指定媒体类型。 | -| only | 当整个表达å¼éƒ½åŒ¹é…时,æ‰ä¼šåº”ç”¨é€‰æ‹©çš„æ ·å¼ï¼Œå¯ä»¥åº”用在防æ¢æŸäº›è¾ƒæ—©çš„版本的æµè§ˆå™¨ä¸Šäº§ç”Ÿæ§ä¹‰çš„场景。一些较早版本的æµè§ˆå™¨å¯¹äºŽåŒæ—¶åŒ…å«äº†åª’体类型和媒体特å¾çš„è¯å¥ä¼šäº§ç”Ÿæ§ä¹‰ï¼Œæ¯”如:<br/>screen and (min-height: 50)<br/>è€ç‰ˆæœ¬æµè§ˆå™¨ä¼šå°†è¿™å¥è¯ç†è§£æˆscreen,从而导致仅仅匹é…到媒体类型(screenï¼‰ï¼Œå°±åº”ç”¨äº†æŒ‡å®šæ ·å¼ï¼Œä½¿ç”¨onlyå¯ä»¥å¾ˆå¥½åœ°è§„é¿è¿™ç§æƒ…况。<br/>>  **说明:**<br/>> 使用only时必须指定媒体类型。 | +| not | å–å媒体查询结果,媒体查询结果ä¸æˆç«‹æ—¶è¿”回true,å¦åˆ™è¿”回false。在媒体查询列表ä¸åº”用not,则notä»…å–å应用它的媒体查询。<br/>例如:not screen and (min-height: 50) and (max-height: 600) 表示当应用高度å°äºŽ50个åƒç´ å•ä½æˆ–者大于600个åƒç´ å•ä½æ—¶æˆç«‹ã€‚<br/>使用notè¿ç®—符时必须指定媒体类型。 | +| only | 当整个表达å¼éƒ½åŒ¹é…时,æ‰ä¼šåº”ç”¨é€‰æ‹©çš„æ ·å¼ï¼Œå¯ä»¥åº”用在防æ¢æŸäº›è¾ƒæ—©çš„版本的æµè§ˆå™¨ä¸Šäº§ç”Ÿæ§ä¹‰çš„场景。一些较早版本的æµè§ˆå™¨å¯¹äºŽåŒæ—¶åŒ…å«äº†åª’体类型和媒体特å¾çš„è¯å¥ä¼šäº§ç”Ÿæ§ä¹‰ï¼Œæ¯”如:<br/>screen and (min-height: 50)<br/>è€ç‰ˆæœ¬æµè§ˆå™¨ä¼šå°†è¿™å¥è¯ç†è§£æˆscreen,从而导致仅仅匹é…到媒体类型(screenï¼‰ï¼Œå°±åº”ç”¨äº†æŒ‡å®šæ ·å¼ï¼Œä½¿ç”¨onlyå¯ä»¥å¾ˆå¥½åœ°è§„é¿è¿™ç§æƒ…况。<br/>使用only时必须指定媒体类型。 | | ,(comma) | 将多个媒体特å¾ä»¥â€œæˆ–â€çš„æ–¹å¼è¿žæŽ¥æˆä¸€ä¸ªåª’体查询,如果å˜åœ¨ç»“果为true的媒体特å¾ï¼Œåˆ™æŸ¥è¯¢æ¡ä»¶æˆç«‹ã€‚其效果ç‰åŒäºŽorè¿ç®—符。<br/>例如:screen and (min-height: 1000), (round-screen:true) 表示当应用高度大于ç‰äºŽ1000个åƒç´ å•ä½æˆ–者设备å±å¹•æ˜¯åœ†å½¢æ—¶ï¼Œæ¡ä»¶æˆç«‹ã€‚ | | or | 将多个媒体特å¾ä»¥â€œæˆ–â€çš„æ–¹å¼è¿žæŽ¥æˆä¸€ä¸ªåª’体查询,如果å˜åœ¨ç»“果为true的媒体特å¾ï¼Œåˆ™æŸ¥è¯¢æ¡ä»¶æˆç«‹ã€‚<br/>例如:screen and (max-height: 1000) or (round-screen:true)表示当应用高度å°äºŽç‰äºŽ1000个åƒç´ å•ä½æˆ–者设备å±å¹•æ˜¯åœ†å½¢æ—¶ï¼Œæ¡ä»¶æˆç«‹ã€‚ | @@ -142,10 +142,12 @@ listener.on('change', onPortrait) } } ``` -横å±ä¸‹æ–‡æœ¬å†…容为Landscape,颜色为#FFD700。<br/> +横å±ä¸‹æ–‡æœ¬å†…容为Landscape,颜色为#FFD700。 +  -éžæ¨ªå±ä¸‹æ–‡æœ¬å†…容为Portrait,颜色为#DB7093。<br/> +éžæ¨ªå±ä¸‹æ–‡æœ¬å†…容为Portrait,颜色为#DB7093。 +  ## 相关实例 diff --git a/zh-cn/application-dev/ui/ui-ts-local-storage.md b/zh-cn/application-dev/ui/ui-ts-local-storage.md index 901c78f8b61108feb61685d7d8fa1d1fd5ea8ca8..9fb55fdaa18b4a90cc7f563dec0da43ddfac0533 100644 --- a/zh-cn/application-dev/ui/ui-ts-local-storage.md +++ b/zh-cn/application-dev/ui/ui-ts-local-storage.md @@ -20,7 +20,7 @@ Ability: 一个应用程åºå¯ä»¥æ‹¥æœ‰å¤šä¸ªAbility,一个Abilityä¸çš„所 > **说明:** 创建LocalStorage实例时如未定义åˆå§‹å€¼ï¼Œå¯ä»¥ä½¿ç”¨ç»„件内@LocalStorageLinkå’Œ@LocalStoragePropçš„åˆå§‹å€¼ã€‚如果定义时给定了åˆå§‹å€¼ï¼Œé‚£ä¹ˆä¸ä¼šå†ä½¿ç”¨@LocalStorageLinkå’Œ@LocalStoragePropçš„åˆå§‹å€¼ã€‚ -## LocalStorageæŽ¥å£ +## LocalStorage ### constructor @@ -30,9 +30,25 @@ constructor(initializingProperties?: Object) **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| ---------------------- | ------ | :--: | ------ | ------------------------------------------------------------ | -| initializingProperties | Object | å¦ | - | object.keys(obj)返回的所有对象属性åŠå…¶å€¼éƒ½å°†æ·»åŠ 到LocalStorage。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ---------------------- | ------ | :--: | ---- | ---------------------------------------- | +| initializingProperties | Object | å¦ | - | object.keys(obj)返回的所有对象属性åŠå…¶å€¼éƒ½å°†æ·»åŠ 到LocalStorage。 | + + + +### GetShared + +static GetShared(): LocalStorage + +获å–当å‰çš„共享的LocalStorage对象。 + +æ¤æŽ¥å£ä»…å¯åœ¨Stage模型下使用。 + +**返回值:** + +| 类型 | æè¿° | +| ----------------------------- | ----------------- | +| [LocalStorage](#localstorage) | 返回LocalStorage对象。 | @@ -44,14 +60,14 @@ has(propName: string): boolean **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | -------------- | -| propName | string | 是 | - | 属性的属性值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ------- | +| propName | string | 是 | - | 属性的属性值。 | **返回值:** -| 类型 | æè¿° | -| ------- | -------------------------- | +| 类型 | æè¿° | +| ------- | ------------- | | boolean | 返回属性的属性值是å¦å˜åœ¨ã€‚ | @@ -64,14 +80,14 @@ get\<T>(propName: string): T **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | ------------------- | -| propName | string | 是 | - | è¦èŽ·å–对应的key值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ----------- | +| propName | string | 是 | - | è¦èŽ·å–对应的key值。 | **返回值:** -| 类型 | æè¿° | -| -------------- | ------------------------------------------------------- | +| 类型 | æè¿° | +| -------------- | ---------------------------------------- | | T \| undefined | 当keyvalueå˜åœ¨æ—¶ï¼Œè¿”回keyvalue值。ä¸å˜åœ¨è¿”回undefined。 | @@ -84,15 +100,15 @@ set\<T>(propName: string, newValue: T): boolean **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | ----------------- | -| propName | string | 是 | - | è¦è®¾ç½®çš„key值。 | -| newValue | T | 是 | - | è¦è®¾ç½®çš„value值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ----------- | +| propName | string | 是 | - | è¦è®¾ç½®çš„key值。 | +| newValue | T | 是 | - | è¦è®¾ç½®çš„value值。 | **返回值:** -| 类型 | æè¿° | -| ------- | ----------------------------------------------------- | +| 类型 | æè¿° | +| ------- | ----------------------------------- | | boolean | 如果å˜åœ¨key值,设置value值并返回true,å¦åˆ™è¿”回false。 | @@ -105,15 +121,15 @@ setOrCreate\<T>(propName: string, newValue: T): boolean **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | ----------------------- | -| propName | string | 是 | - | è¦æ›´æ–°æˆ–者创建的key值。 | -| newValue | T | 是 | - | è¦æ›´æ–°æˆ–创建的value值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | -------------- | +| propName | string | 是 | - | è¦æ›´æ–°æˆ–者创建的key值。 | +| newValue | T | 是 | - | è¦æ›´æ–°æˆ–创建的value值。 | **返回值:** -| 类型 | æè¿° | -| ------- | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------- | ---------------------------------------- | | boolean | 如果已å˜åœ¨ä¸Žç»™å®šé”®åå—相åŒçš„属性,更新其值且返回true。如果ä¸å˜åœ¨å…·æœ‰ç»™å®šå称的属性,在LocalStorageä¸åˆ›å»ºå…·æœ‰ç»™å®šé»˜è®¤å€¼çš„新属性,默认值必须是T类型。ä¸å…许undefined 或 null 返回true。 | @@ -126,14 +142,14 @@ link\<T>(propName: string): T **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | ---------------------- | -| propName | string | 是 | - | è¦åŒå‘绑定的属性å称。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ----------- | +| propName | string | 是 | - | è¦åŒå‘绑定的属性å称。 | **返回值:** -| 类型 | æè¿° | -| ---- | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ---- | ---------------------------------------- | | T | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„属性,返回到æ¤å±žæ€§çš„åŒå‘绑定,该åŒå‘绑定æ„味ç€å˜é‡æˆ–者组件对数æ®çš„更改将åŒæ¥åˆ°LocalStorage,然åŽé€šè¿‡LocalStorage实例åŒæ¥åˆ°ä»»ä½•å˜é‡æˆ–组件。如果ä¸å˜åœ¨ç»™å®šé”®çš„属性,返回undefined。 | @@ -146,15 +162,15 @@ setAndLink\<T>(propName: string, defaultValue: T): T **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| ------------ | ------ | :--: | ------ | -------------------- | -| propName | string | 是 | - | è¦è¿›è¡Œåˆ›å»ºçš„key值。 | -| defaultValue | T | 是 | - | è¦è¿›è¡Œè®¾ç½®çš„默认值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------ | ------ | :--: | ---- | ----------- | +| propName | string | 是 | - | è¦è¿›è¡Œåˆ›å»ºçš„key值。 | +| defaultValue | T | 是 | - | è¦è¿›è¡Œè®¾ç½®çš„默认值。 | **返回值:** -| 类型 | æè¿° | -| ------------------------------------- | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------------------------------------- | ---------------------------------------- | | [@Link](ts-component-states-link.md ) | 与Link接å£ç±»ä¼¼ï¼Œå¦‚果当å‰çš„keyä¿å˜äºŽLocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValueçš„Link返回。 | @@ -167,14 +183,14 @@ prop\<T>(propName: string): T **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | ----------------------- | -| propName | string | 是 | - | è¦å•å‘æ•°æ®ç»‘定的key值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ------------- | +| propName | string | 是 | - | è¦å•å‘æ•°æ®ç»‘定的key值。 | **返回值:** -| 类型 | æè¿° | -| ------------------------------------ | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------------------------------------ | ---------------------------------------- | | [@Prop](ts-component-states-prop.md) | 如果å˜åœ¨å…·æœ‰ç»™å®šé”®çš„属性,返回æ¤å±žæ€§çš„å•å‘æ•°æ®ç»‘定。该å•å‘绑定æ„味ç€åªèƒ½é€šè¿‡LocalStorage将属性的更改åŒæ¥åˆ°å˜é‡æˆ–组件。该方法返回的å˜é‡ä¸ºä¸å¯å˜å˜é‡ï¼Œé€‚用于å¯å˜å’Œä¸å¯å˜çš„状æ€å˜é‡ã€‚如果æ¤é”®çš„属性ä¸å˜åœ¨åˆ™è¿”回undefined。 | @@ -187,15 +203,15 @@ setAndProp\<T>(propName: string, defaultValue: T): T **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| ------------ | ------ | :--: | ------ | --------------------------- | -| propName | string | 是 | - | è¦ä¿å˜çš„的键值对ä¸çš„key值。 | -| defaultValue | T | 是 | - | 创建的默认值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| ------------ | ------ | :--: | ---- | --------------- | +| propName | string | 是 | - | è¦ä¿å˜çš„的键值对ä¸çš„key值。 | +| defaultValue | T | 是 | - | 创建的默认值。 | **返回值:** -| 类型 | æè¿° | -| ------------------------------------ | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------------------------------------ | ---------------------------------------- | | [@Prop](ts-component-states-prop.md) | 如果当å‰çš„keyä¿å˜ä¸ŽLocalStorage,返回该key值对应的value值。如果该key值未被创建,则创建一个对应的defaultValueçš„Prop返回。 | @@ -208,14 +224,14 @@ delete(propName: string): boolean **å‚数:** -| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | -| -------- | ------ | :--: | ------ | --------------------- | -| propName | string | 是 | - | è¦åˆ 除的属性的key值。 | +| å‚æ•°å | 类型 | å¿…å¡« | 默认值 | å‚æ•°æè¿° | +| -------- | ------ | :--: | ---- | ------------ | +| propName | string | 是 | - | è¦åˆ 除的属性的key值。 | **返回值:** -| 类型 | æè¿° | -| ------- | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------- | ---------------------------------------- | | boolean | åˆ é™¤key指定的键值对,如果å˜åœ¨ä¸”åˆ é™¤æˆåŠŸè¿”回true,ä¸å˜åœ¨æˆ–åˆ é™¤å¤±è´¥è¿”å›žfalse。 | @@ -228,8 +244,8 @@ keys(): IterableIterator\<string> **返回值:** -| 类型 | æè¿° | -| ------------- | ---------------------------- | +| 类型 | æè¿° | +| -------------- | -------------- | | array\<string> | 返回包å«æ‰€æœ‰é”®çš„å—符串数组。 | @@ -242,8 +258,8 @@ size(): number **返回值:** -| 类型 | æè¿° | -| ------ | ------------------ | +| 类型 | æè¿° | +| ------ | --------- | | number | 返回键值对的数é‡ã€‚ | @@ -256,8 +272,8 @@ clear(): boolean **返回值:** -| 类型 | æè¿° | -| ------- | ------------------------------------------------------------ | +| 类型 | æè¿° | +| ------- | --------------------------------- | | boolean | åˆ é™¤æ‰€æœ‰çš„å±žæ€§ï¼Œå¦‚æžœå½“å‰æœ‰çŠ¶æ€å˜é‡ä¾æ—§å¼•ç”¨æ¤å±žæ€§ï¼Œè¿”回false。 | ### 示例1(在一个Ability创建的LocalStorage) @@ -292,7 +308,7 @@ export default class MainAbility extends Ability { @Component组件获å–æ•°æ® -``` +```ts let storage = LocalStorage.GetShared() @Entry(storage) @Component @@ -314,7 +330,7 @@ struct LocalStorageComponent { ### 示例2(在Entry页é¢å®šä¹‰LocalStorage) -``` +```ts let storage = new LocalStorage({"PropA":47}); @Entry(storage) @Component diff --git a/zh-cn/application-dev/ui/ui-ts-overview.md b/zh-cn/application-dev/ui/ui-ts-overview.md index c1c2f3bcf2de96e6948d6e62b0e8f70f6d73770d..4bec8a1c14aada55c870218b046f87debb2ae319 100644 --- a/zh-cn/application-dev/ui/ui-ts-overview.md +++ b/zh-cn/application-dev/ui/ui-ts-overview.md @@ -75,22 +75,38 @@ - [`BringApp`:拉起系统应用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/BringApp) +- [`Chat`:èŠå¤©ç¤ºä¾‹åº”用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/AppSample/Chat) + +- [`Shopping`:è´ç‰©ç¤ºä¾‹åº”用(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/AppSample/Shopping) + +- [`Lottie`:Lottie(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Lottie) + - [`Clock`:简å•æ—¶é’Ÿï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/Preset/Clock) - [`Flybird`:å°é¸Ÿé¿éšœæ¸¸æˆï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/Flybird) - [`News`:新闻æµè§ˆï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ResourcesSchedule/News) -- [æžç®€å£°æ˜Žå¼UI范å¼ï¼ˆeTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SimpleGalleryEts) +- [`AdaptiveCapabilities`:多设备自适应能力(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/MultiDeviceAppDev/AdaptiveCapabilities) + +- [`Game2048`:2048游æˆï¼ˆeTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Game2048) + +- [`TransitionAnimation`:转场动画(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/TransitionAnimation) + +- [`PatternLock`:图案密ç é”组件(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/PatternLock) + +- [`Search`:Search组件(eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/Search) + +- [`QRCode`:二维ç (eTS)(API9)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/QRCode) -- [è´ç‰©åº”用(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/ShoppingEts) +- [æžç®€å£°æ˜Žå¼UI范å¼ï¼ˆeTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SimpleGalleryEts) -- [转场动画的使用(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/TransitionAnimtaionEts) +- [è´ç‰©åº”用(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/ShoppingEts) -- [基础组件Slider的使用(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SliderApplicationEts) +- [转场动画的使用(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/TransitionAnimtaionEts) -- [弹窗(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/CustomDialogEts) +- [基础组件Slider的使用(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/SliderApplicationEts) -- [一次开å‘多端部署(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/MultiDeploymentEts) +- [弹窗(eTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/ETSUI/CustomDialogEts) - [CustomComponent:组件化(eTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/CustomComponent) \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md index 02db871f12db11b97be6d30f1bb23d21a86e2e30..95d0a3133396bcc367618d1c84646fb291d31716 100644 --- a/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md +++ b/zh-cn/application-dev/ui/ui-ts-page-redirection-data-transmission.md @@ -19,7 +19,7 @@ 下é¢æˆ‘们就分别å¦ä¹ 这两ç§è·³è½¬æœºåˆ¶æ¥å®žçŽ°é£Ÿç‰©åˆ†ç±»åˆ—表页é¢å’Œé£Ÿç‰©è¯¦æƒ…页的链接。 1. 点击FoodListItemåŽè·³è½¬åˆ°FoodDetail页é¢ã€‚在FoodListItem内创建Navigator组件,使其åç»„ä»¶éƒ½å…·æœ‰è·¯ç”±åŠŸèƒ½ï¼Œç›®æ ‡é¡µé¢target为'pages/FoodDetail'。 - ``` + ```ts @Component struct FoodListItem { private foodItem: FoodData @@ -48,7 +48,7 @@  2. 点击FoodGridItemåŽè·³è½¬åˆ°FoodDetail页é¢ã€‚调用页é¢è·¯ç”±router模å—çš„push接å£ï¼Œå°†FoodDetail页é¢æŽ¨åˆ°è·¯ç”±æ ˆä¸ï¼Œå®žçŽ°é¡µé¢è·³è½¬ã€‚使用router路由API接å£ï¼Œéœ€è¦å…ˆå¼•å…¥router。 - ``` + ```ts import router from '@system.router' @Component @@ -70,7 +70,7 @@  3. 在FoodDetail页é¢å¢žåŠ 回到食物列表页é¢çš„å›¾æ ‡ã€‚åœ¨resources > base > media文件夹下å˜å…¥å›žé€€å›¾æ ‡Back.png。新建自定义组件PageTitle,包å«åŽé€€çš„å›¾æ ‡å’ŒFood Detail的文本,调用路由的router.back()接å£ï¼Œå¼¹å‡ºè·¯ç”±æ ˆæœ€ä¸Šé¢çš„页é¢ï¼Œå³è¿”回上一级页é¢ã€‚ - ``` + ```ts // FoodDetail.ets import router from '@system.router' @@ -96,7 +96,7 @@ ``` 4. 在FoodDetail组件内创建Stack组件,包å«å组件FoodImageDisplayå’ŒPageTitleå组件,设置其对é½æ–¹å¼ä¸ºå·¦ä¸Šå¯¹é½TopStart。 - ``` + ```ts @Entry @Component struct FoodDetail { @@ -121,7 +121,7 @@ 我们已ç»å®Œæˆäº†FoodCategoryList页é¢å’ŒFoodDetail页é¢çš„跳转和回退,但是点击ä¸åŒçš„FoodListItem/FoodGridItem,跳转的FoodDetail页é¢éƒ½æ˜¯è¥¿çº¢æŸ¿Tomato的详细介ç»ï¼Œè¿™æ˜¯å› 为没有构建起两个页é¢çš„æ•°æ®ä¼ 递,需è¦ç”¨åˆ°æºå¸¦å‚数(parameter)路由。 1. 在FoodListItem组件的Navigator设置其params属性,params属性接å—key-valueçš„Object。 - ``` + ```ts // FoodList.ets @Component struct FoodListItem { @@ -137,7 +137,7 @@ FoodGridItem调用的routerAPIåŒæ ·æœ‰æºå¸¦å‚数跳转的能力,使用方法和Navigator类似。 - ``` + ```ts router.push({ uri: 'pages/FoodDetail', params: { foodData: this.foodItem } @@ -145,7 +145,7 @@ ``` 2. FoodDetail页é¢å¼•å…¥FoodData类,在FoodDetailç»„ä»¶å†…æ·»åŠ foodItemæˆå‘˜å˜é‡ã€‚ - ``` + ```ts // FoodDetail.ets import { FoodData } from '../model/FoodData' @@ -160,7 +160,7 @@ ``` 3. 获å–foodData对应的value。调用router.getParams().foodDataæ¥èŽ·å–到FoodCategoryList页é¢è·³è½¬æ¥æ—¶æºå¸¦çš„foodDate对应的数æ®ã€‚ - ``` + ```ts @Entry @Component struct FoodDetail { @@ -173,7 +173,7 @@ ``` 4. é‡æž„FoodDetail页é¢çš„组件。在构建视图时,FoodDetail页é¢çš„食物信æ¯éƒ½æ˜¯ç›´æŽ¥å£°æ˜Žçš„常é‡ï¼ŒçŽ°åœ¨è¦ç”¨ä¼ 递æ¥çš„FoodDataæ•°æ®æ¥å¯¹å…¶è¿›è¡Œé‡æ–°èµ‹å€¼ã€‚整体的FoodDetail.ets代ç 如下。 - ``` + ```ts @Component struct PageTitle { build() { diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 2e458bc5ee479c197ca853d7fa15576ff7b43fa9..30d39ae55f5ec9ab7cb6d5d8ae142e971ad07862 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -4,16 +4,15 @@ - 快速入门 - [å¼€å‘准备](quick-start/start-overview.md) - - [使用eTSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](quick-start/start-with-ets.md) - - [使用eTSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](quick-start/start-with-ets-low-code.md) - - [使用JSè¯è¨€å¼€å‘ï¼ˆä¼ ç»Ÿä»£ç æ–¹å¼ï¼‰](quick-start/start-with-js.md) - - [使用JSè¯è¨€å¼€å‘(低代ç æ–¹å¼ï¼‰](quick-start/start-with-js-low-code.md) + - [使用eTSè¯è¨€å¼€å‘(Stage模型)](quick-start/start-with-ets-stage.md) + - [使用eTSè¯è¨€å¼€å‘(FA模型)](quick-start/start-with-ets-fa.md) + - [使用JSè¯è¨€å¼€å‘(FA模型)](quick-start/start-with-js-fa.md) - å¼€å‘基础知识 - [应用包结构说明(FA模型)](quick-start/package-structure.md) - [应用包结构说明(Stage模型)](quick-start/stage-structure.md) - - [资æºæ–‡ä»¶çš„分类](quick-start/basic-resource-file-categories.md) - [SysCap说明](quick-start/syscap.md) + - [HarmonyAppProvisioné…置文件](quick-start/app-provision-structure.md) - å¼€å‘ - Abilityå¼€å‘ - [Ability框架概述](ability/ability-brief.md) @@ -37,6 +36,77 @@ - [测试框架使用指导](ability/ability-delegator.md) - UIå¼€å‘ - [方舟开å‘框架(ArkUI)概述](ui/arkui-overview.md) + - 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ + - [概述](ui/ui-ts-overview.md) + - 框架说明 + - 文件组织 + - [目录结构](ui/ts-framework-directory.md) + - [应用代ç 文件访问规则](ui/ts-framework-file-access-rules.md) + - [jsæ ‡ç¾é…ç½®](ui/ts-framework-js-tag.md) + - 资æºç®¡ç† + - [资æºæ–‡ä»¶çš„分类](ui/ui-ts-basic-resource-file-categories.md) + - [资æºè®¿é—®](ui/ts-resource-access.md) + - [åƒç´ å•ä½](ui/ts-pixel-units.md) + - [类型定义](ui/ts-types.md) + - 声明å¼è¯æ³• + - [æ述规范使用说明](ui/ts-syntax-intro.md) + - 通用UIæ述规范 + - [基本概念](ui/ts-general-ui-concepts.md) + - 声明å¼UIæ述规范 + - [æ— æž„é€ å‚æ•°é…ç½®](ui/ts-parameterless-configuration.md) + - [必选å‚æ•°æž„é€ é…ç½®](ui/ts-configuration-with-mandatory-parameters.md) + - [属性é…ç½®](ui/ts-attribution-configuration.md) + - [事件é…ç½®](ui/ts-event-configuration.md) + - [å组件é…ç½®](ui/ts-child-component-configuration.md) + - 组件化 + - [@Component](ui/ts-component-based-component.md) + - [@Entry](ui/ts-component-based-entry.md) + - [@Preview](ui/ts-component-based-preview.md) + - [@Builder](ui/ts-component-based-builder.md) + - [@Extend](ui/ts-component-based-extend.md) + - [@CustomDialog](ui/ts-component-based-customdialog.md) + - [@Styles](ui/ts-component-based-styles.md) + - UI状æ€ç®¡ç† + - [基本概念](ui/ts-ui-state-mgmt-concepts.md) + - 管ç†ç»„ä»¶æ‹¥æœ‰çš„çŠ¶æ€ + - [@State](ui/ts-component-states-state.md) + - [@Prop](ui/ts-component-states-prop.md) + - [@Link](ui/ts-component-states-link.md) + - 管ç†åº”用程åºçš„çŠ¶æ€ + - [应用程åºçš„æ•°æ®å˜å‚¨](ui/ts-application-states-appstorage.md) + - [Abilityæ•°æ®å˜å‚¨](ui/ui-ts-local-storage.md) + - [æŒä¹…化数æ®ç®¡ç†](ui/ts-application-states-apis-persistentstorage.md) + - [环境å˜é‡](ui/ts-application-states-apis-environment.md) + - 其他类目的状æ€ç®¡ç† + - [Observedå’ŒObjectLinkæ•°æ®ç®¡ç†](ui/ts-other-states-observed-objectlink.md) + - [@Consumeå’Œ@Provideæ•°æ®ç®¡ç†](ui/ts-other-states-consume-provide.md) + - [@Watch](ui/ts-other-states-watch.md) + - 渲染控制è¯æ³• + - [æ¡ä»¶æ¸²æŸ“](ui/ts-rending-control-syntax-if-else.md) + - [循环渲染](ui/ts-rending-control-syntax-foreach.md) + - [æ•°æ®æ‡’åŠ è½½](ui/ts-rending-control-syntax-lazyforeach.md) + - 深入ç†è§£ç»„件化 + - [build函数](ui/ts-function-build.md) + - [自定义组件åˆå§‹åŒ–](ui/ts-custom-component-initialization.md) + - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) + - [组件创建和é‡æ–°åˆå§‹åŒ–示例](ui/ts-component-creation-re-initialization.md) + - [è¯æ³•ç³–](ui/ts-syntactic-sugar.md) + - 常è§ç»„件开å‘指导 + - [Buttonå¼€å‘指导](ui/ui-ts-basic-components-button.md) + - [Webå¼€å‘指导](ui/ui-ts-components-web.md) + - 常è§å¸ƒå±€å¼€å‘指导 + - [弹性布局](ui/ui-ts-layout-flex.md) + - [æ …æ ¼å¸ƒå±€](ui/ui-ts-layout-grid-container.md) + - [媒体查询](ui/ui-ts-layout-mediaquery.md) + - 体验声明å¼UI + - [创建声明å¼UI工程](ui/ui-ts-creating-project.md) + - [åˆè¯†Component](ui/ui-ts-components.md) + - [创建简å•è§†å›¾](ui/ui-ts-creating-simple-page.md) + - 页é¢å¸ƒå±€ä¸Žè¿žæŽ¥ + - [构建食物数æ®æ¨¡åž‹](ui/ui-ts-building-data-model.md) + - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) + - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) + - [页é¢è·³è½¬ä¸Žæ•°æ®ä¼ 递](ui/ui-ts-page-redirection-data-transmission.md) - 基于JS扩展的类Webå¼€å‘èŒƒå¼ - [概述](ui/ui-js-overview.md) - 框架说明 @@ -60,7 +130,7 @@ - [æ·»åŠ å®¹å™¨](ui/ui-js-building-ui-layout-external-container.md) - [æ·»åŠ äº¤äº’](ui/ui-js-building-ui-interactions.md) - [动画](ui/ui-js-building-ui-animation.md) - - [事件](ui/ui-js-building-ui-event.md) + - [手势事件](ui/ui-js-building-ui-event.md) - [页é¢è·¯ç”±](ui/ui-js-building-ui-routes.md) - 常è§ç»„件开å‘指导 - 容器组件 @@ -109,90 +179,20 @@ - [动画动效](ui/ui-js-animate-dynamic-effects.md) - [动画帧](ui/ui-js-animate-frame.md) - [自定义组件](ui/ui-js-custom-components.md) - - 基于TS扩展的声明å¼å¼€å‘èŒƒå¼ - - [概述](ui/ui-ts-overview.md) - - 框架说明 - - 文件组织 - - [目录结构](ui/ts-framework-directory.md) - - [应用代ç 文件访问规则](ui/ts-framework-file-access-rules.md) - - [jsæ ‡ç¾é…ç½®](ui/ts-framework-js-tag.md) - - 资æºè®¿é—® - - [访问应用资æº](ui/ts-application-resource-access.md) - - [访问系统资æº](ui/ts-system-resource-access.md) - - [媒体资æºç±»åž‹è¯´æ˜Ž](ui/ts-media-resource-type.md) - - [åƒç´ å•ä½](ui/ts-pixel-units.md) - - [类型定义](ui/ts-types.md) - - 声明å¼è¯æ³• - - [æ述规范使用说明](ui/ts-syntax-intro.md) - - 通用UIæ述规范 - - [基本概念](ui/ts-general-ui-concepts.md) - - 声明å¼UIæ述规范 - - [æ— æž„é€ å‚æ•°é…ç½®](ui/ts-parameterless-configuration.md) - - [必选å‚æ•°æž„é€ é…ç½®](ui/ts-configuration-with-mandatory-parameters.md) - - [属性é…ç½®](ui/ts-attribution-configuration.md) - - [事件é…ç½®](ui/ts-event-configuration.md) - - [å组件é…ç½®](ui/ts-child-component-configuration.md) - - 组件化 - - [@Component](ui/ts-component-based-component.md) - - [@Entry](ui/ts-component-based-entry.md) - - [@Preview](ui/ts-component-based-preview.md) - - [@Builder](ui/ts-component-based-builder.md) - - [@Extend](ui/ts-component-based-extend.md) - - [@CustomDialog](ui/ts-component-based-customdialog.md) - - [@Styles](ui/ts-component-based-styles.md) - - UI状æ€ç®¡ç† - - [基本概念](ui/ts-ui-state-mgmt-concepts.md) - - 管ç†ç»„ä»¶æ‹¥æœ‰çš„çŠ¶æ€ - - [@State](ui/ts-component-states-state.md) - - [@Prop](ui/ts-component-states-prop.md) - - [@Link](ui/ts-component-states-link.md) - - 管ç†åº”用程åºçš„çŠ¶æ€ - - [应用程åºçš„æ•°æ®å˜å‚¨](ui/ts-application-states-appstorage.md) - - [Abilityæ•°æ®å˜å‚¨](ui/ui-ts-local-storage) - - [æŒä¹…化数æ®ç®¡ç†](ui/ts-application-states-apis-persistentstorage.md) - - [环境å˜é‡](ui/ts-application-states-apis-environment.md) - - 其他类目的状æ€ç®¡ç† - - [Observedå’ŒObjectLinkæ•°æ®ç®¡ç†](ui/ts-other-states-observed-objectlink.md) - - [@Consumeå’Œ@Provideæ•°æ®ç®¡ç†](ui/ts-other-states-consume-provide.md) - - [@Watch](ui/ts-other-states-watch.md) - - 渲染控制è¯æ³• - - [æ¡ä»¶æ¸²æŸ“](ui/ts-rending-control-syntax-if-else.md) - - [循环渲染](ui/ts-rending-control-syntax-foreach.md) - - [æ•°æ®æ‡’åŠ è½½](ui/ts-rending-control-syntax-lazyforeach.md) - - 深入ç†è§£ç»„件化 - - [build函数](ui/ts-function-build.md) - - [自定义组件åˆå§‹åŒ–](ui/ts-custom-component-initialization.md) - - [自定义组件生命周期回调函数](ui/ts-custom-component-lifecycle-callbacks.md) - - [组件创建和é‡æ–°åˆå§‹åŒ–示例](ui/ts-component-creation-re-initialization.md) - - [è¯æ³•ç³–](ui/ts-syntactic-sugar.md) - - 常è§ç»„件开å‘指导 - - [Buttonå¼€å‘指导](ui/ui-ts-basic-components-button.md) - - [Webå¼€å‘指导](ui/ui-ts-components-web.md) - - 常è§å¸ƒå±€å¼€å‘指导 - - [弹性布局](ui/ui-ts-layout-flex.md) - - [æ …æ ¼å¸ƒå±€](ui/ui-ts-layout-grid-container.md) - - [媒体查询](ui/ui-ts-layout-mediaquery.md) - - 体验声明å¼UI - - [创建声明å¼UI工程](ui/ui-ts-creating-project.md) - - [åˆè¯†Component](ui/ui-ts-components.md) - - [创建简å•è§†å›¾](ui/ui-ts-creating-simple-page.md) - - 页é¢å¸ƒå±€ä¸Žè¿žæŽ¥ - - [构建食物数æ®æ¨¡åž‹](ui/ui-ts-building-data-model.md) - - [构建食物列表List布局](ui/ui-ts-building-category-list-layout.md) - - [构建食物分类Grid布局](ui/ui-ts-building-category-grid-layout.md) - - [页é¢è·³è½¬ä¸Žæ•°æ®ä¼ 递](ui/ui-ts-page-redirection-data-transmission.md) - 公共事件与通知 - [公共事件与通知概述](notification/notification-brief.md) - [公共事件开å‘指导](notification/common-event.md) - - [通知开å‘指导](notification/notification.md) - - åŽå°ä»£ç†æ醒 - - [åŽå°ä»£ç†æ¦‚è¿°](background-agent-scheduled-reminder/background-agent-scheduled-reminder-overview.md) - - [åŽå°ä»£ç†å¼€å‘指导](background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md) + - [通知开å‘指导](notification/notification-guidelines.md) + - åŽå°æ醒 + - [åŽå°æ醒开å‘概述](notification/background-agent-scheduled-reminder-overview.md) + - [åŽå°æ醒开å‘指导](notification/background-agent-scheduled-reminder-guide.md) - [调试助手使用指导](notification/assistant-guidelines.md) - 窗å£ç®¡ç† - çª—å£ - [窗å£å¼€å‘概述](windowmanager/window-overview.md) - - [窗å£å¼€å‘指导](windowmanager/window-guidelines.md) + - [管ç†åº”用窗å£ï¼ˆStage模型)](windowmanager/application-window-stage.md) + - [管ç†åº”用窗å£ï¼ˆFA模型)](windowmanager/application-window-fa.md) + - [管ç†ç³»ç»Ÿçª—å£ï¼ˆä»…Stage模型支æŒï¼‰](windowmanager/system-window-stage.md) - å±å¹•å±žæ€§ - [å±å¹•å±žæ€§å¼€å‘概述](windowmanager/display-overview.md) - [å±å¹•å±žæ€§å¼€å‘指导](windowmanager/display-guidelines.md) @@ -209,12 +209,21 @@ - [音频录制开å‘指导](media/audio-recorder.md) - [音频渲染开å‘指导](media/audio-renderer.md) - [音频采集开å‘指导](media/audio-capturer.md) + - [OpenSL ESæ’放开å‘指导](media/opensles-playback.md) + - [OpenSL ES录音开å‘指导](media/opensles-capture.md) + - [音频焦点模å¼å¼€å‘指导](media/audio-interruptmode.md) - 视频 - [视频æ’放开å‘指导](media/video-playback.md) - [视频录制开å‘指导](media/video-recorder.md) - 图片 - [图片开å‘指导](media/image.md) + - 相机 + - [相机开å‘指导](media/camera.md) - 安全 + - 访问控制 + - [访问控制开å‘概述](security/accesstoken-overview.md) + - [访问控制开å‘指导](security/accesstoken-guidelines.md) + - [æƒé™å®šä¹‰åˆ—表](security/permission-list.md) - ç”¨æˆ·è®¤è¯ - [用户认è¯å¼€å‘概述](security/userauth-overview.md) - [用户认è¯å¼€å‘指导](security/userauth-guidelines.md) @@ -222,10 +231,8 @@ - [HUKSå¼€å‘概述](security/huks-overview.md) - [HUKSå¼€å‘指导](security/huks-guidelines.md) - Hap包ç¾å工具 - - [Hap包ç¾å工具开å‘指导](security/hapsigntool-guidelines.md) - - 访问控制 - - [访问控制开å‘概述](security/accesstoken-overview.md) - - [访问控制开å‘指导](security/accesstoken-guidelines.md) + - [Hap包ç¾å工具概述](security/hapsigntool-overview.md) + - [Hap包ç¾å工具指导](security/hapsigntool-guidelines.md) - 网络与连接 - ç½‘ç»œç®¡ç† - [网络管ç†å¼€å‘概述](connectivity/net-mgmt-overview.md) @@ -247,9 +254,9 @@ - 关系型数æ®åº“ - [关系型数æ®åº“概述](database/database-relational-overview.md) - [关系型数æ®åº“å¼€å‘指导](database/database-relational-guidelines.md) - - è½»é‡çº§æ•°æ®å˜å‚¨ - - [è½»é‡çº§æ•°æ®å˜å‚¨æ¦‚è¿°](database/database-preference-overview.md) - - [è½»é‡çº§æ•°æ®å˜å‚¨å¼€å‘指导](database/database-preference-guidelines.md) + - 首选项 + - [首选项概述](database/database-preference-overview.md) + - [首选项开å‘指导](database/database-preference-guidelines.md) - 分布å¼æ•°æ®å¯¹è±¡ - [分布å¼æ•°æ®å¯¹è±¡æ¦‚è¿°](database/database-distributedobject-overview.md) - [分布å¼æ•°æ®å¯¹è±¡å¼€å‘指导](database/database-distributedobject-guidelines.md) @@ -293,254 +300,217 @@ - 分布å¼è·Ÿè¸ª - [分布å¼è·Ÿè¸ªæ¦‚è¿°](dfx/hitracechain-overview.md) - [分布å¼è·Ÿè¸ªå¼€å‘指导](dfx/hitracechain-guidelines.md) + - é”™è¯¯ç®¡ç† + - [错误管ç†å¼€å‘指导](dfx/errormanager-guidelines.md) - 国际化 - [国际化开å‘概述](internationalization/international-overview.md) - [Intlå¼€å‘指导](internationalization/intl-guidelines.md) - [I18nå¼€å‘指导](internationalization/i18n-guidelines.md) + - 一次开å‘,多端部署 + - [å‰è¨€](key-features/multi-device-app-dev/about-this-document.md) + - [简介](key-features/multi-device-app-dev/introduction.md) + - 应用UX设计 + - [设计原则和è¦ç‚¹](key-features/multi-device-app-dev/design-principles.md) + - 应用架构设计 + - [应用导航结构设计è¦æ±‚](key-features/multi-device-app-dev/navigation-design.md) + - [应用页é¢ç»“构设计](key-features/multi-device-app-dev/page-design.md) + - ç•Œé¢å¸ƒå±€ + - [概述](key-features/multi-device-app-dev/layout-design-intro.md) + - 布局基础 + - [æ …æ ¼ç³»ç»Ÿ](key-features/multi-device-app-dev/layout-grid.md) + - [自适应布局](key-features/multi-device-app-dev/layout-adaptive.md) + - [å“应å¼å¸ƒå±€](key-features/multi-device-app-dev/layout-responsive.md) + - [布局基础è¿ç”¨æ¡ˆä¾‹](key-features/multi-device-app-dev/layout-design-cases.md) + - 人机交互 + - [交互基础](key-features/multi-device-app-dev/interaction-basics.md) + - [常è§è¾“入方å¼](key-features/multi-device-app-dev/common-input-modes.md) + - [交互事件归一](key-features/multi-device-app-dev/design-interaction-events-unification.md) + - è§†è§‰é£Žæ ¼ + - [视觉基础](key-features/multi-device-app-dev/visual-style-basics.md) + - [色彩](key-features/multi-device-app-dev/visual-style-color.md) + - [å—体](key-features/multi-device-app-dev/visual-style-font.md) + - [å›¾æ ‡](key-features/multi-device-app-dev/visual-style-icon.md) + - [多æ€æŽ§ä»¶](key-features/multi-device-app-dev/design-polymorphic-components.md) + - [设计自检表](key-features/multi-device-app-dev/design-checklist.md) + - [资æº](key-features/multi-device-app-dev/resource.md) + - [IDE使用](key-features/multi-device-app-dev/ide-usage.md) + - 一多能力的页é¢å¼€å‘ä»‹ç» + - 布局能力 + - [布局能力简介](key-features/multi-device-app-dev/layout-intro.md) + - 自适应布局 + - [自适应布局简介](key-features/multi-device-app-dev/adaptive-layout-intro.md) + - [拉伸能力](key-features/multi-device-app-dev/adaptive-layout-stretching.md) + - [å‡åˆ†èƒ½åŠ›](key-features/multi-device-app-dev/adaptive-layout-equalization.md) + - [å 比能力](key-features/multi-device-app-dev/adaptive-layout-proportion.md) + - [缩放能力](key-features/multi-device-app-dev/adaptive-layout-scaling.md) + - [延伸能力](key-features/multi-device-app-dev/adaptive-layout-extension.md) + - [éšè—能力](key-features/multi-device-app-dev/adaptive-layout-hiding.md) + - [折行能力](key-features/multi-device-app-dev/adaptive-layout-wrapping.md) + - å“应å¼å¸ƒå±€ + - [æ …æ ¼æ–点系统](key-features/multi-device-app-dev/grid-breakpoint.md) + - [媒体查询](key-features/multi-device-app-dev/media-query.md) + - [典型场景](key-features/multi-device-app-dev/responsive-layout-cases.md) + - [交互归一](key-features/multi-device-app-dev/interaction-events-unification.md) + - [多æ€ç»„件](key-features/multi-device-app-dev/polymorphic-components.md) + - [资æºä½¿ç”¨](key-features/multi-device-app-dev/resource-usage.md) + - [一多能力的功能开å‘介ç»](key-features/multi-device-app-dev/development-intro.md) + - 案例应用 + - çŸä¿¡åº”用 + - [概览](key-features/multi-device-app-dev/sms-intro.md) + - 会è¯è¯¦æƒ…é¡µé¢ + - [页é¢ç»“æž„](key-features/multi-device-app-dev/sms-session-page-structure.md) + - [é¡¶éƒ¨æ ‡é¢˜æ ](key-features/multi-device-app-dev/sms-session-page-title-bar.md) + - [底部输入æ ](key-features/multi-device-app-dev/sms-session-page-input-field.md) + - [ä¿¡æ¯åˆ—表](key-features/multi-device-app-dev/sms-session-page-message-list.md) + - [组åˆæˆåž‹](key-features/multi-device-app-dev/sms-session-page-combined.md) + - [总结](key-features/multi-device-app-dev/sms-session-summary.md) + - [æ¡Œé¢åº”用](key-features/multi-device-app-dev/cases-home-screen.md) + - [常è§é—®é¢˜](key-features/multi-device-app-dev/faqs.md) - [IDLå·¥å…·è§„æ ¼åŠä½¿ç”¨è¯´æ˜Žä¹¦](IDL/idl-guidelines.md) - Native API的相关指导 - [Native API在应用工程ä¸çš„使用指导](napi/napi-guidelines.md) - [Drawingå¼€å‘指导](napi/drawing-guidelines.md) - [Rawfileå¼€å‘指导](napi/rawfile-guidelines.md) + - [Windowå¼€å‘指导](napi/native-window-guidelines.md) - 工具 - [DevEco Studio(OpenHarmony)使用指å—](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 - [示例代ç ](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - APIå‚考 - - 组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰ - - 组件 - - 通用 - - [通用属性](reference/arkui-js/js-components-common-attributes.md) - - [é€šç”¨æ ·å¼](reference/arkui-js/js-components-common-styles.md) - - [通用事件](reference/arkui-js/js-components-common-events.md) - - [通用方法](reference/arkui-js/js-components-common-methods.md) - - [åŠ¨ç”»æ ·å¼](reference/arkui-js/js-components-common-animation.md) - - [æ¸å˜æ ·å¼](reference/arkui-js/js-components-common-gradient.md) - - [è½¬åœºæ ·å¼](reference/arkui-js/js-components-common-transition.md) - - [媒体查询](reference/arkui-js/js-components-common-mediaquery.md) - - [自定义å—ä½“æ ·å¼](reference/arkui-js/js-components-common-customizing-font.md) - - [原å布局](reference/arkui-js/js-components-common-atomic-layout.md) - - 容器组件 - - [badge](reference/arkui-js/js-components-container-badge.md) - - [dialog](reference/arkui-js/js-components-container-dialog.md) - - [div](reference/arkui-js/js-components-container-div.md) - - [form](reference/arkui-js/js-components-container-form.md) - - [list](reference/arkui-js/js-components-container-list.md) - - [list-item](reference/arkui-js/js-components-container-list-item.md) - - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) - - [panel](reference/arkui-js/js-components-container-panel.md) - - [popup](reference/arkui-js/js-components-container-popup.md) - - [refresh](reference/arkui-js/js-components-container-refresh.md) - - [stack](reference/arkui-js/js-components-container-stack.md) - - [stepper](reference/arkui-js/js-components-container-stepper.md) - - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) - - [swiper](reference/arkui-js/js-components-container-swiper.md) - - [tabs](reference/arkui-js/js-components-container-tabs.md) - - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) - - [tab-content](reference/arkui-js/js-components-container-tab-content.md) - - 基础组件 - - [button](reference/arkui-js/js-components-basic-button.md) - - [chart](reference/arkui-js/js-components-basic-chart.md) - - [divider](reference/arkui-js/js-components-basic-divider.md) - - [image](reference/arkui-js/js-components-basic-image.md) - - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) - - [input](reference/arkui-js/js-components-basic-input.md) - - [label](reference/arkui-js/js-components-basic-label.md) - - [marquee](reference/arkui-js/js-components-basic-marquee.md) - - [menu](reference/arkui-js/js-components-basic-menu.md) - - [option](reference/arkui-js/js-components-basic-option.md) - - [picker](reference/arkui-js/js-components-basic-picker.md) - - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) - - [piece](reference/arkui-js/js-components-basic-piece.md) - - [progress](reference/arkui-js/js-components-basic-progress.md) - - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) - - [rating](reference/arkui-js/js-components-basic-rating.md) - - [richtext](reference/arkui-js/js-components-basic-richtext.md) - - [search](reference/arkui-js/js-components-basic-search.md) - - [select](reference/arkui-js/js-components-basic-select.md) - - [slider](reference/arkui-js/js-components-basic-slider.md) - - [span](reference/arkui-js/js-components-basic-span.md) - - [switch](reference/arkui-js/js-components-basic-switch.md) - - [text](reference/arkui-js/js-components-basic-text.md) - - [textarea](reference/arkui-js/js-components-basic-textarea.md) - - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) - - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) - - [toggle](reference/arkui-js/js-components-basic-toggle.md) - - [web](reference/arkui-js/js-components-basic-web.md) - - 媒体组件 - - [video](reference/arkui-js/js-components-media-video.md) - - 画布组件 - - [canvas组件](reference/arkui-js/js-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) - - [Image对象](reference/arkui-js/js-components-canvas-image.md) - - [CanvasGradient对象](reference/arkui-js/js-components-canvas-canvasgradient.md) - - [ImageData对象](reference/arkui-js/js-components-canvas-imagedata.md) - - [Path2D对象](reference/arkui-js/js-components-canvas-path2d.md) - - [ImageBitmap对象](reference/arkui-js/js-components-canvas-imagebitmap.md) - - [OffscreenCanvas对象](reference/arkui-js/js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D对象](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) - - æ …æ ¼ç»„ä»¶ - - [基本概念](reference/arkui-js/js-components-grid-basic-concepts.md) - - [grid-container](reference/arkui-js/js-components-grid-container.md) - - [grid-row](reference/arkui-js/js-components-grid-row.md) - - [grid-col](reference/arkui-js/js-components-grid-col.md) - - svg组件 - - [通用属性](reference/arkui-js/js-components-svg-common-attributes.md) - - [svg](reference/arkui-js/js-components-svg.md) - - [rect](reference/arkui-js/js-components-svg-rect.md) - - [circle](reference/arkui-js/js-components-svg-circle.md) - - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) - - [path](reference/arkui-js/js-components-svg-path.md) - - [line](reference/arkui-js/js-components-svg-line.md) - - [polyline](reference/arkui-js/js-components-svg-polyline.md) - - [polygon](reference/arkui-js/js-components-svg-polygon.md) - - [text](reference/arkui-js/js-components-svg-text.md) - - [tspan](reference/arkui-js/js-components-svg-tspan.md) - - [textPath](reference/arkui-js/js-components-svg-textpath.md) - - [animate](reference/arkui-js/js-components-svg-animate.md) - - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) - - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) - - 自定义组件 - - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) - - [自定义事件](reference/arkui-js/js-components-custom-events.md) - - [Props](reference/arkui-js/js-components-custom-props.md) - - [事件å‚æ•°](reference/arkui-js/js-components-custom-event-parameter.md) - - [slotæ’槽](reference/arkui-js/js-components-custom-slot.md) - - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) - - 附录 - - [类型说明](reference/arkui-js/js-appendix-types.md) - 组件å‚考(基于TS扩展的声明å¼å¼€å‘范å¼ï¼‰ - - 组件 - - 通用 - - 通用事件 - - [点击事件](reference/arkui-ts/ts-universal-events-click.md) - - [触摸事件](reference/arkui-ts/ts-universal-events-touch.md) - - [挂载å¸è½½äº‹ä»¶](reference/arkui-ts/ts-universal-events-show-hide.md) - - [拖拽事件](reference/arkui-ts/ts-universal-events-drag-drop.md) - - [按键事件](reference/arkui-ts/ts-universal-events-key.md) - - [焦点事件](reference/arkui-ts/ts-universal-focus-event.md) - - [é¼ æ ‡äº‹ä»¶](reference/arkui-ts/ts-universal-mouse-key.md) - - [组件区域å˜åŒ–事件](reference/arkui-ts/ts-universal-component-area-change-event.md) - - 通用属性 - - [尺寸设置](reference/arkui-ts/ts-universal-attributes-size.md) - - [ä½ç½®è®¾ç½®](reference/arkui-ts/ts-universal-attributes-location.md) - - [布局约æŸ](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - - [Flex布局](reference/arkui-ts/ts-universal-attributes-flex-layout.md) - - [边框设置](reference/arkui-ts/ts-universal-attributes-border.md) - - [背景设置](reference/arkui-ts/ts-universal-attributes-background.md) - - [é€æ˜Žåº¦è®¾ç½®](reference/arkui-ts/ts-universal-attributes-opacity.md) - - [显éšæŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-visibility.md) - - [ç¦ç”¨æŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-enable.md) - - [浮层](reference/arkui-ts/ts-universal-attributes-overlay.md) - - [ZåºæŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-z-order.md) - - [图形å˜æ¢](reference/arkui-ts/ts-universal-attributes-transformation.md) - - [图åƒæ•ˆæžœ](reference/arkui-ts/ts-universal-attributes-image-effect.md) - - [形状è£å‰ª](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) - - [æ–‡æœ¬æ ·å¼è®¾ç½®](reference/arkui-ts/ts-universal-attributes-text-style.md) - - [æ …æ ¼è®¾ç½®](reference/arkui-ts/ts-universal-attributes-grid.md) - - [颜色æ¸å˜](reference/arkui-ts/ts-universal-attributes-gradient-color.md) - - [Popup控制](reference/arkui-ts/ts-universal-attributes-popup.md) - - [Menu控制](reference/arkui-ts/ts-universal-attributes-menu.md) - - [点击控制](reference/arkui-ts/ts-universal-attributes-click.md) - - [焦点控制](reference/arkui-ts/ts-universal-attributes-focus.md) - - [悬浮æ€æ•ˆæžœ](reference/arkui-ts/ts-universal-attributes-hover-effect.md) - - [ç»„ä»¶æ ‡è¯†](reference/arkui-ts/ts-universal-attributes-component-id.md) - - [触摸çƒåŒºè®¾ç½®](reference/arkui-ts/ts-universal-attributes-touch-target.md) - - [多æ€æ ·å¼](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) - - æ‰‹åŠ¿å¤„ç† - - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) - - 基础手势 - - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) - - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) - - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) - - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) - - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) - - [组åˆæ‰‹åŠ¿](reference/arkui-ts/ts-combined-gestures.md) - - 基础组件 - - [Blank](reference/arkui-ts/ts-basic-components-blank.md) - - [Button](reference/arkui-ts/ts-basic-components-button.md) - - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) - - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) - - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) - - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) - - [Divider](reference/arkui-ts/ts-basic-components-divider.md) - - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) - - [Image](reference/arkui-ts/ts-basic-components-image.md) - - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) - - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) - - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) - - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) - - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) - - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) - - [Progress](reference/arkui-ts/ts-basic-components-progress.md) - - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) - - [Radio](reference/arkui-ts/ts-basic-components-radio.md) - - [Rating](reference/arkui-ts/ts-basic-components-rating.md) - - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) - - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) - - [Search](reference/arkui-ts/ts-basic-components-search.md) - - [Select](reference/arkui-ts/ts-basic-components-select.md) - - [Slider](reference/arkui-ts/ts-basic-components-slider.md) - - [Span](reference/arkui-ts/ts-basic-components-span.md) - - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) - - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) - - [Text](reference/arkui-ts/ts-basic-components-text.md) - - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) - - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) - - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) - - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) - - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) - - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) - - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) - - [Web](reference/arkui-ts/ts-basic-components-web.md) - - [Xcomponent](reference/arkui-ts/ts-basic-components-xcomponent.md) - - 容器组件 - - [AbilityComponent](reference/arkui-ts/ts-container-ability-component.md) - - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) - - [Badge](reference/arkui-ts/ts-container-badge.md) - - [Column](reference/arkui-ts/ts-container-column.md) - - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) - - [Counter](reference/arkui-ts/ts-container-counter.md) - - [Flex](reference/arkui-ts/ts-container-flex.md) - - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) - - [Grid](reference/arkui-ts/ts-container-grid.md) - - [GridItem](reference/arkui-ts/ts-container-griditem.md) - - [List](reference/arkui-ts/ts-container-list.md) - - [ListItem](reference/arkui-ts/ts-container-listitem.md) - - [Navigator](reference/arkui-ts/ts-container-navigator.md) - - [Panel](reference/arkui-ts/ts-container-panel.md) - - [Refresh](reference/arkui-ts/ts-container-refresh.md) - - [RelativeContainer](reference/arkui-ts/ts-container-relativecontainer.md) - - [Row](reference/arkui-ts/ts-container-row.md) - - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) - - [Scroll](reference/arkui-ts/ts-container-scroll.md) - - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) - - [Stack](reference/arkui-ts/ts-container-stack.md) - - [Swiper](reference/arkui-ts/ts-container-swiper.md) - - [Tabs](reference/arkui-ts/ts-container-tabs.md) - - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) - - 媒体组件 - - [Video](reference/arkui-ts/ts-media-components-video.md) - - 绘制组件 - - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) - - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) - - [Line](reference/arkui-ts/ts-drawing-components-line.md) - - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) - - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) - - [Path](reference/arkui-ts/ts-drawing-components-path.md) - - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) - - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) - - 画布组件 - - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](reference/arkui-ts/ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D对象](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) - - [Path2D对象](reference/arkui-ts/ts-components-canvas-path2d.md) - - [CanvasGradient对象](reference/arkui-ts/ts-components-canvas-canvasgradient.md) - - [ImageBitmap对象](reference/arkui-ts/ts-components-canvas-imagebitmap.md) - - [ImageData对象](reference/arkui-ts/ts-components-canvas-imagedata.md) + - ç»„ä»¶é€šç”¨ä¿¡æ¯ + - 通用事件 + - [点击事件](reference/arkui-ts/ts-universal-events-click.md) + - [触摸事件](reference/arkui-ts/ts-universal-events-touch.md) + - [挂载å¸è½½äº‹ä»¶](reference/arkui-ts/ts-universal-events-show-hide.md) + - [拖拽事件](reference/arkui-ts/ts-universal-events-drag-drop.md) + - [按键事件](reference/arkui-ts/ts-universal-events-key.md) + - [焦点事件](reference/arkui-ts/ts-universal-focus-event.md) + - [é¼ æ ‡äº‹ä»¶](reference/arkui-ts/ts-universal-mouse-key.md) + - [组件区域å˜åŒ–事件](reference/arkui-ts/ts-universal-component-area-change-event.md) + - [组件å¯è§åŒºåŸŸå˜åŒ–事件](reference/arkui-ts/ts-universal-component-visible-area-change-event.md) + - 通用属性 + - [尺寸设置](reference/arkui-ts/ts-universal-attributes-size.md) + - [ä½ç½®è®¾ç½®](reference/arkui-ts/ts-universal-attributes-location.md) + - [布局约æŸ](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + - [Flex布局](reference/arkui-ts/ts-universal-attributes-flex-layout.md) + - [边框设置](reference/arkui-ts/ts-universal-attributes-border.md) + - [图片边框设置](reference/arkui-ts/ts-universal-attributes-border-image.md) + - [背景设置](reference/arkui-ts/ts-universal-attributes-background.md) + - [é€æ˜Žåº¦è®¾ç½®](reference/arkui-ts/ts-universal-attributes-opacity.md) + - [显éšæŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-visibility.md) + - [ç¦ç”¨æŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-enable.md) + - [浮层](reference/arkui-ts/ts-universal-attributes-overlay.md) + - [ZåºæŽ§åˆ¶](reference/arkui-ts/ts-universal-attributes-z-order.md) + - [图形å˜æ¢](reference/arkui-ts/ts-universal-attributes-transformation.md) + - [图åƒæ•ˆæžœ](reference/arkui-ts/ts-universal-attributes-image-effect.md) + - [形状è£å‰ª](reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + - [æ–‡æœ¬æ ·å¼è®¾ç½®](reference/arkui-ts/ts-universal-attributes-text-style.md) + - [æ …æ ¼è®¾ç½®](reference/arkui-ts/ts-universal-attributes-grid.md) + - [颜色æ¸å˜](reference/arkui-ts/ts-universal-attributes-gradient-color.md) + - [Popup控制](reference/arkui-ts/ts-universal-attributes-popup.md) + - [Menu控制](reference/arkui-ts/ts-universal-attributes-menu.md) + - [点击控制](reference/arkui-ts/ts-universal-attributes-click.md) + - [焦点控制](reference/arkui-ts/ts-universal-attributes-focus.md) + - [悬浮æ€æ•ˆæžœ](reference/arkui-ts/ts-universal-attributes-hover-effect.md) + - [ç»„ä»¶æ ‡è¯†](reference/arkui-ts/ts-universal-attributes-component-id.md) + - [触摸çƒåŒºè®¾ç½®](reference/arkui-ts/ts-universal-attributes-touch-target.md) + - [多æ€æ ·å¼](reference/arkui-ts/ts-universal-attributes-polymorphic-style.md) + - æ‰‹åŠ¿å¤„ç† + - [绑定手势方法](reference/arkui-ts/ts-gesture-settings.md) + - 基础手势 + - [TapGesture](reference/arkui-ts/ts-basic-gestures-tapgesture.md) + - [LongPressGesture](reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + - [PanGesture](reference/arkui-ts/ts-basic-gestures-pangesture.md) + - [PinchGesture](reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + - [RotationGesture](reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](reference/arkui-ts/ts-basic-gestures-swipegesture.md) + - [组åˆæ‰‹åŠ¿](reference/arkui-ts/ts-combined-gestures.md) + - 基础组件 + - [Blank](reference/arkui-ts/ts-basic-components-blank.md) + - [Button](reference/arkui-ts/ts-basic-components-button.md) + - [Checkbox](reference/arkui-ts/ts-basic-components-checkbox.md) + - [CheckboxGroup](reference/arkui-ts/ts-basic-components-checkboxgroup.md) + - [DataPanel](reference/arkui-ts/ts-basic-components-datapanel.md) + - [DatePicker](reference/arkui-ts/ts-basic-components-datepicker.md) + - [Divider](reference/arkui-ts/ts-basic-components-divider.md) + - [Gauge](reference/arkui-ts/ts-basic-components-gauge.md) + - [Image](reference/arkui-ts/ts-basic-components-image.md) + - [ImageAnimator](reference/arkui-ts/ts-basic-components-imageanimator.md) + - [LoadingProgress](reference/arkui-ts/ts-basic-components-loadingprogress.md) + - [Marquee](reference/arkui-ts/ts-basic-components-marquee.md) + - [Navigation](reference/arkui-ts/ts-basic-components-navigation.md) + - [PatternLock](reference/arkui-ts/ts-basic-components-patternlock.md) + - [PluginComponent](reference/arkui-ts/ts-basic-components-plugincomponent.md) + - [Progress](reference/arkui-ts/ts-basic-components-progress.md) + - [QRCode](reference/arkui-ts/ts-basic-components-qrcode.md) + - [Radio](reference/arkui-ts/ts-basic-components-radio.md) + - [Rating](reference/arkui-ts/ts-basic-components-rating.md) + - [RemoteWindow](reference/arkui-ts/ts-basic-components-remotewindow.md) + - [RichText](reference/arkui-ts/ts-basic-components-richtext.md) + - [ScrollBar](reference/arkui-ts/ts-basic-components-scrollbar.md) + - [Search](reference/arkui-ts/ts-basic-components-search.md) + - [Select](reference/arkui-ts/ts-basic-components-select.md) + - [Slider](reference/arkui-ts/ts-basic-components-slider.md) + - [Span](reference/arkui-ts/ts-basic-components-span.md) + - [Stepper](reference/arkui-ts/ts-basic-components-stepper.md) + - [StepperItem](reference/arkui-ts/ts-basic-components-stepperitem.md) + - [Text](reference/arkui-ts/ts-basic-components-text.md) + - [TextArea](reference/arkui-ts/ts-basic-components-textarea.md) + - [TextClock](reference/arkui-ts/ts-basic-components-textclock.md) + - [TextInput](reference/arkui-ts/ts-basic-components-textinput.md) + - [TextPicker](reference/arkui-ts/ts-basic-components-textpicker.md) + - [TextTimer](reference/arkui-ts/ts-basic-components-texttimer.md) + - [TimePicker](reference/arkui-ts/ts-basic-components-timepicker.md) + - [Toggle](reference/arkui-ts/ts-basic-components-toggle.md) + - [Web](reference/arkui-ts/ts-basic-components-web.md) + - [XComponent](reference/arkui-ts/ts-basic-components-xcomponent.md) + - 容器组件 + - [AbilityComponent](reference/arkui-ts/ts-container-ability-component.md) + - [AlphabetIndexer](reference/arkui-ts/ts-container-alphabet-indexer.md) + - [Badge](reference/arkui-ts/ts-container-badge.md) + - [Column](reference/arkui-ts/ts-container-column.md) + - [ColumnSplit](reference/arkui-ts/ts-container-columnsplit.md) + - [Counter](reference/arkui-ts/ts-container-counter.md) + - [Flex](reference/arkui-ts/ts-container-flex.md) + - [GridContainer](reference/arkui-ts/ts-container-gridcontainer.md) + - [Grid](reference/arkui-ts/ts-container-grid.md) + - [GridItem](reference/arkui-ts/ts-container-griditem.md) + - [List](reference/arkui-ts/ts-container-list.md) + - [ListItem](reference/arkui-ts/ts-container-listitem.md) + - [Navigator](reference/arkui-ts/ts-container-navigator.md) + - [Panel](reference/arkui-ts/ts-container-panel.md) + - [Refresh](reference/arkui-ts/ts-container-refresh.md) + - [RelativeContainer](reference/arkui-ts/ts-container-relativecontainer.md) + - [Row](reference/arkui-ts/ts-container-row.md) + - [RowSplit](reference/arkui-ts/ts-container-rowsplit.md) + - [Scroll](reference/arkui-ts/ts-container-scroll.md) + - [SideBarContainer](reference/arkui-ts/ts-container-sidebarcontainer.md) + - [Stack](reference/arkui-ts/ts-container-stack.md) + - [Swiper](reference/arkui-ts/ts-container-swiper.md) + - [Tabs](reference/arkui-ts/ts-container-tabs.md) + - [TabContent](reference/arkui-ts/ts-container-tabcontent.md) + - 媒体组件 + - [Video](reference/arkui-ts/ts-media-components-video.md) + - 绘制组件 + - [Circle](reference/arkui-ts/ts-drawing-components-circle.md) + - [Ellipse](reference/arkui-ts/ts-drawing-components-ellipse.md) + - [Line](reference/arkui-ts/ts-drawing-components-line.md) + - [Polyline](reference/arkui-ts/ts-drawing-components-polyline.md) + - [Polygon](reference/arkui-ts/ts-drawing-components-polygon.md) + - [Path](reference/arkui-ts/ts-drawing-components-path.md) + - [Rect](reference/arkui-ts/ts-drawing-components-rect.md) + - [Shape](reference/arkui-ts/ts-drawing-components-shape.md) + - 画布组件 + - [Canvas](reference/arkui-ts/ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-ts/ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D对象](reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](reference/arkui-ts/ts-components-canvas-lottie.md) + - [Path2D对象](reference/arkui-ts/ts-components-canvas-path2d.md) + - [CanvasGradient对象](reference/arkui-ts/ts-components-canvas-canvasgradient.md) + - [ImageBitmap对象](reference/arkui-ts/ts-components-canvas-imagebitmap.md) + - [ImageData对象](reference/arkui-ts/ts-components-canvas-imagedata.md) - 动画 - [属性动画](reference/arkui-ts/ts-animatorproperty.md) - [显å¼åŠ¨ç”»](reference/arkui-ts/ts-explicit-animation.md) @@ -561,51 +531,167 @@ - [文本选择弹窗](reference/arkui-ts/ts-methods-textpicker-dialog.md) - [èœå•](reference/arkui-ts/ts-methods-menu.md) - [文档ä¸æ¶‰åŠåˆ°çš„内置枚举值](reference/arkui-ts/ts-appendix-enums.md) + - 组件å‚考(基于JS扩展的类Webå¼€å‘范å¼ï¼‰ + - ç»„ä»¶é€šç”¨ä¿¡æ¯ + - [通用属性](reference/arkui-js/js-components-common-attributes.md) + - [é€šç”¨æ ·å¼](reference/arkui-js/js-components-common-styles.md) + - [通用事件](reference/arkui-js/js-components-common-events.md) + - [通用方法](reference/arkui-js/js-components-common-methods.md) + - [åŠ¨ç”»æ ·å¼](reference/arkui-js/js-components-common-animation.md) + - [æ¸å˜æ ·å¼](reference/arkui-js/js-components-common-gradient.md) + - [è½¬åœºæ ·å¼](reference/arkui-js/js-components-common-transition.md) + - [媒体查询](reference/arkui-js/js-components-common-mediaquery.md) + - [自定义å—ä½“æ ·å¼](reference/arkui-js/js-components-common-customizing-font.md) + - [原å布局](reference/arkui-js/js-components-common-atomic-layout.md) + - 容器组件 + - [badge](reference/arkui-js/js-components-container-badge.md) + - [dialog](reference/arkui-js/js-components-container-dialog.md) + - [div](reference/arkui-js/js-components-container-div.md) + - [form](reference/arkui-js/js-components-container-form.md) + - [list](reference/arkui-js/js-components-container-list.md) + - [list-item](reference/arkui-js/js-components-container-list-item.md) + - [list-item-group](reference/arkui-js/js-components-container-list-item-group.md) + - [panel](reference/arkui-js/js-components-container-panel.md) + - [popup](reference/arkui-js/js-components-container-popup.md) + - [refresh](reference/arkui-js/js-components-container-refresh.md) + - [stack](reference/arkui-js/js-components-container-stack.md) + - [stepper](reference/arkui-js/js-components-container-stepper.md) + - [stepper-item](reference/arkui-js/js-components-container-stepper-item.md) + - [swiper](reference/arkui-js/js-components-container-swiper.md) + - [tabs](reference/arkui-js/js-components-container-tabs.md) + - [tab-bar](reference/arkui-js/js-components-container-tab-bar.md) + - [tab-content](reference/arkui-js/js-components-container-tab-content.md) + - 基础组件 + - [button](reference/arkui-js/js-components-basic-button.md) + - [chart](reference/arkui-js/js-components-basic-chart.md) + - [divider](reference/arkui-js/js-components-basic-divider.md) + - [image](reference/arkui-js/js-components-basic-image.md) + - [image-animator](reference/arkui-js/js-components-basic-image-animator.md) + - [input](reference/arkui-js/js-components-basic-input.md) + - [label](reference/arkui-js/js-components-basic-label.md) + - [marquee](reference/arkui-js/js-components-basic-marquee.md) + - [menu](reference/arkui-js/js-components-basic-menu.md) + - [option](reference/arkui-js/js-components-basic-option.md) + - [picker](reference/arkui-js/js-components-basic-picker.md) + - [picker-view](reference/arkui-js/js-components-basic-picker-view.md) + - [piece](reference/arkui-js/js-components-basic-piece.md) + - [progress](reference/arkui-js/js-components-basic-progress.md) + - [qrcode](reference/arkui-js/js-components-basic-qrcode.md) + - [rating](reference/arkui-js/js-components-basic-rating.md) + - [richtext](reference/arkui-js/js-components-basic-richtext.md) + - [search](reference/arkui-js/js-components-basic-search.md) + - [select](reference/arkui-js/js-components-basic-select.md) + - [slider](reference/arkui-js/js-components-basic-slider.md) + - [span](reference/arkui-js/js-components-basic-span.md) + - [switch](reference/arkui-js/js-components-basic-switch.md) + - [text](reference/arkui-js/js-components-basic-text.md) + - [textarea](reference/arkui-js/js-components-basic-textarea.md) + - [toolbar](reference/arkui-js/js-components-basic-toolbar.md) + - [toolbar-item](reference/arkui-js/js-components-basic-toolbar-item.md) + - [toggle](reference/arkui-js/js-components-basic-toggle.md) + - [web](reference/arkui-js/js-components-basic-web.md) + - [xcomponent](reference/arkui-js/js-components-basic-xcomponent.md) + - 媒体组件 + - [video](reference/arkui-js/js-components-media-video.md) + - 画布组件 + - [canvas组件](reference/arkui-js/js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](reference/arkui-js/js-components-canvas-image.md) + - [CanvasGradient对象](reference/arkui-js/js-components-canvas-canvasgradient.md) + - [ImageData对象](reference/arkui-js/js-components-canvas-imagedata.md) + - [Path2D对象](reference/arkui-js/js-components-canvas-path2d.md) + - [ImageBitmap对象](reference/arkui-js/js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](reference/arkui-js/js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + - æ …æ ¼ç»„ä»¶ + - [基本概念](reference/arkui-js/js-components-grid-basic-concepts.md) + - [grid-container](reference/arkui-js/js-components-grid-container.md) + - [grid-row](reference/arkui-js/js-components-grid-row.md) + - [grid-col](reference/arkui-js/js-components-grid-col.md) + - svg组件 + - [通用属性](reference/arkui-js/js-components-svg-common-attributes.md) + - [svg](reference/arkui-js/js-components-svg.md) + - [rect](reference/arkui-js/js-components-svg-rect.md) + - [circle](reference/arkui-js/js-components-svg-circle.md) + - [ellipse](reference/arkui-js/js-components-svg-ellipse.md) + - [path](reference/arkui-js/js-components-svg-path.md) + - [line](reference/arkui-js/js-components-svg-line.md) + - [polyline](reference/arkui-js/js-components-svg-polyline.md) + - [polygon](reference/arkui-js/js-components-svg-polygon.md) + - [text](reference/arkui-js/js-components-svg-text.md) + - [tspan](reference/arkui-js/js-components-svg-tspan.md) + - [textPath](reference/arkui-js/js-components-svg-textpath.md) + - [animate](reference/arkui-js/js-components-svg-animate.md) + - [animateMotion](reference/arkui-js/js-components-svg-animatemotion.md) + - [animateTransform](reference/arkui-js/js-components-svg-animatetransform.md) + - 自定义组件 + - [基本用法](reference/arkui-js/js-components-custom-basic-usage.md) + - [ç»§æ‰¿æ ·å¼](reference/arkui-js/js-components-custom-style.md) + - [自定义事件](reference/arkui-js/js-components-custom-events.md) + - [Props](reference/arkui-js/js-components-custom-props.md) + - [事件å‚æ•°](reference/arkui-js/js-components-custom-event-parameter.md) + - [slotæ’槽](reference/arkui-js/js-components-custom-slot.md) + - [生命周期定义](reference/arkui-js/js-components-custom-lifecycle.md) + - [æ•°æ®ç±»åž‹è¯´æ˜Ž](reference/arkui-js/js-appendix-types.md) - 接å£å‚考(JSåŠTS API) + - [å¼€å‘说明](reference/apis/development-intro.md) - Ability框架 - - [@ohos.ability.dataUriUtils (DataUriUtils模å—)](reference/apis/js-apis-DataUriUtils.md) - - [@ohos.ability.errorCode (ErrorCode)](reference/apis/js-apis-ability-errorCode.md) - - [@ohos.ability.wantConstant (wantConstant)](reference/apis/js-apis-ability-wantConstant.md) - - [@ohos.application.Ability (Ability)](reference/apis/js-apis-application-ability.md) - - [@ohos.application.AbilityConstant (AbilityConstant)](reference/apis/js-apis-application-abilityConstant.md) - - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.md) - - [@ohos.application.AbilityStage (AbilityStage)](reference/apis/js-apis-application-abilitystage.md) - - [@ohos.application.appManager (appManager)](reference/apis/js-apis-appmanager.md) - - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-configuration.md) - - [@ohos.application.DataShareExtensionAbility (æ•°æ®å…±äº«æ‰©å±•èƒ½åŠ›)](reference/apis/js-apis-application-DataShareExtensionAbility.md) - - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-configurationconstant.md) - - [@ohos.ability.featureAbility (FeatureAbility模å—)](reference/apis/js-apis-featureAbility.md) - - [@ohos.application.formBindingData (å¡ç‰‡æ•°æ®ç»‘定类)](reference/apis/js-apis-formbindingdata.md) - - [@ohos.application.FormExtension (FormExtension)](reference/apis/js-apis-formextension.md) - - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) - - [@ohos.application.formHost (FormHost)](reference/apis/js-apis-formhost.md) - - [@ohos.application.formInfo (FormInfo)](reference/apis/js-apis-formInfo.md) - - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) - - [@ohos.application.formProvider (FormProvider)](reference/apis/js-apis-formprovider.md) - - [@ohos.ability.particleAbility (particleAbility模å—)](reference/apis/js-apis-particleAbility.md) - - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](reference/apis/js-apis-service-extension-ability.md) - - [@ohos.application.StartOptions (StartOptions)](reference/apis/js-apis-application-StartOptions.md) - - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](reference/apis/js-apis-application-staticSubscriberExtensionAbility.md) - - [@ohos.application.uriPermissionManager (uriPermissionManager)](reference/apis/js-apis-uripermissionmanager.md) - - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) - - [@ohos.wantAgent (WantAgent模å—)](reference/apis/js-apis-wantAgent.md) - - [dataAbilityHelper (DataAbilityHelper模å—)](reference/apis/js-apis-dataAbilityHelper.md) - - [context (Context模å—)](reference/apis/js-apis-Context.md) - - [AbilityContext (AbilityContext)](reference/apis/js-apis-ability-context.md) - - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) - - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) - - [abilityMonitor (AbilityMonitor)](reference/apis/js-apis-application-abilityMonitor.md) - - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) - - [AbilityStageContext (AbilityStageContext)](reference/apis/js-apis-abilitystagecontext.md) - - [Context (Context)](reference/apis/js-apis-application-context.md) - - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) - - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) - - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) - - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) - - [PermissionRequestResult (PermissionRequestResult)](reference/apis/js-apis-permissionrequestresult.md) - - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) - - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) - - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) + - FA模型 + - [@ohos.ability.featureAbility (FeatureAbility模å—)](reference/apis/js-apis-featureAbility.md) + - [@ohos.ability.particleAbility (particleAbility模å—)](reference/apis/js-apis-particleAbility.md) + - [dataAbilityHelper (DataAbilityHelper模å—)](reference/apis/js-apis-dataAbilityHelper.md) + - [context (Context模å—)](reference/apis/js-apis-Context.md) + - Stage模型 + - [@ohos.application.Ability (Ability)](reference/apis/js-apis-application-ability.md) + - [@ohos.application.AbilityConstant (AbilityConstant)](reference/apis/js-apis-application-abilityConstant.md) + - [@ohos.application.AbilityStage (AbilityStage)](reference/apis/js-apis-application-abilitystage.md) + - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](reference/apis/js-apis-application-abilityLifecycleCallback.md) + - [@ohos.application.DataShareExtensionAbility (æ•°æ®å…±äº«æ‰©å±•èƒ½åŠ›)](reference/apis/js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.FormExtension (FormExtension)](reference/apis/js-apis-formextension.md) + - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](reference/apis/js-apis-service-extension-ability.md) + - [@ohos.application.StartOptions (StartOptions)](reference/apis/js-apis-application-StartOptions.md) + - [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](reference/apis/js-apis-application-staticSubscriberExtensionAbility.md) + - [@ohos.application.WindowExtensionAbility (窗å£æ‰©å±•èƒ½åŠ›)](reference/apis/js-apis-application-WindowExtensionAbility.md) + - [AbilityContext (AbilityContext)](reference/apis/js-apis-ability-context.md) + - [ApplicationContext (ApplicationContext)](reference/apis/js-apis-application-applicationContext.md) + - [AbilityStageContext (AbilityStageContext)](reference/apis/js-apis-abilitystagecontext.md) + - [Context (Context)](reference/apis/js-apis-application-context.md) + - [ExtensionContext (ExtensionContext)](reference/apis/js-apis-extension-context.md) + - [FormExtensionContext (FormExtensionContext)](reference/apis/js-apis-formextensioncontext.md) + - [PermissionRequestResult (PermissionRequestResult)](reference/apis/js-apis-permissionrequestresult.md) + - [ServiceExtensionContext (ServiceExtensionContext)](reference/apis/js-apis-service-extension-context.md) + - 通用 + - [@ohos.ability.dataUriUtils (DataUriUtils模å—)](reference/apis/js-apis-DataUriUtils.md) + - [@ohos.ability.errorCode (ErrorCode)](reference/apis/js-apis-ability-errorCode.md) + - [@ohos.ability.wantConstant (wantConstant)](reference/apis/js-apis-ability-wantConstant.md) + - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](reference/apis/js-apis-abilityDelegatorRegistry.md) + - [@ohos.application.abilityManager (AbilityManager)](reference/apis/js-apis-application-abilityManager.md) + - [@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionContext)](reference/apis/js-apis-accessibility-extension-context.md) + - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](reference/apis/js-apis-application-AccessibilityExtensionAbility.md) + - [@ohos.application.appManager (appManager)](reference/apis/js-apis-appmanager.md) + - [@ohos.application.Configuration (Configuration)](reference/apis/js-apis-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](reference/apis/js-apis-configurationconstant.md) + - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](reference/apis/js-apis-application-EnvironmentCallback.md) + - [@ohos.application.errorManager (ErrorManager)](reference/apis/js-apis-errorManager.md) + - [@ohos.application.formBindingData (å¡ç‰‡æ•°æ®ç»‘定类)](reference/apis/js-apis-formbindingdata.md) + - [@ohos.application.formError (FormError)](reference/apis/js-apis-formerror.md) + - [@ohos.application.formHost (FormHost)](reference/apis/js-apis-formhost.md) + - [@ohos.application.formInfo (FormInfo)](reference/apis/js-apis-formInfo.md) + - [@ohos.application.formProvider (FormProvider)](reference/apis/js-apis-formprovider.md) + - [@ohos.application.missionManager (missionManager)](reference/apis/js-apis-missionManager.md) + - [@ohos.application.Want (Want)](reference/apis/js-apis-application-Want.md) + - [@ohos.continuation.continuationManager (ContinuationExtraParams)](reference/apis/js-apis-continuation-continuationExtraParams.md) + - [@ohos.continuation.continuationManager (continuationManager)](reference/apis/js-apis-continuation-continuationManager.md) + - [@ohos.wantAgent (WantAgent模å—)](reference/apis/js-apis-wantAgent.md) + - [abilityDelegator (AbilityDelegator)](reference/apis/js-apis-application-abilityDelegator.md) + - [abilityDelegatorArgs (AbilityDelegatorArgs)](reference/apis/js-apis-application-abilityDelegatorArgs.md) + - [abilityMonitor (AbilityMonitor)](reference/apis/js-apis-application-abilityMonitor.md) + - [AbilityRunningInfo (AbilityRunningInfo)](reference/apis/js-apis-abilityrunninginfo.md) + - [ExtensionRunningInfo (ExtensionRunningInfo)](reference/apis/js-apis-extensionrunninginfo.md) + - [MissionSnapshot (MissionSnapshot)](reference/apis/js-apis-application-MissionSnapshot.md) + - [ProcessRunningInfo (ProcessRunningInfo)](reference/apis/js-apis-processrunninginfo.md) + - [shellCmdResult (ShellCmdResult)](reference/apis/js-apis-application-shellCmdResult.md) + - [ContinuationResult (ContinuationResult)](reference/apis/js-apis-continuation-continuationResult.md) - 公共事件与通知 - [@ohos.commonEvent (公共事件模å—)](reference/apis/js-apis-commonEvent.md) - [@ohos.events.emitter (Emitter)](reference/apis/js-apis-emitter.md) @@ -614,20 +700,42 @@ - [EventHub (EventHub)](reference/apis/js-apis-eventhub.md) - 应用程åºåŒ…ç®¡ç† - [@ohos.bundle (Bundle模å—)](reference/apis/js-apis-Bundle.md) + - [@ohos.bundle.defaultAppManager (Bundle模å—)](reference/apis/js-apis-bundle-defaultAppManager.md) + - [@ohos.bundle.innerBundleManager (innerBundleManager模å—(JS端SDK接å£))](reference/apis/js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundleState (设备使用信æ¯ç»Ÿè®¡)](reference/apis/js-apis-deviceUsageStatistics.md) + - [@ohos.distributedBundle (distributedBundle模å—(JS端SDK接å£))](reference/apis/js-apis-Bundle-distributedBundle.md) - [@ohos.zlib (Zip模å—)](reference/apis/js-apis-zlib.md) + - [AbilityInfo (AbilityInfo)](reference/apis/js-apis-bundle-AbilityInfo.md) + - [ApplicationInfo (ApplicationInfo)](reference/apis/js-apis-bundle-ApplicationInfo.md) + - [BundleInfo (BundleInfo)](reference/apis/js-apis-bundle-BundleInfo.md) + - [BundleInstaller (BundleInstaller)](reference/apis/js-apis-bundle-BundleInstaller.md) + - [CustomizeData (CustomizeData)](reference/apis/js-apis-bundle-CustomizeData.md) + - [DispatchInfo (DispatchInfo)](reference/apis/js-apis-dispatchInfo.md) + - [ElementName (ElementName)](reference/apis/js-apis-bundle-ElementName.md) + - [ExtensionAbilityInfo (ExtensionAbilityInfo)](reference/apis/js-apis-bundle-ExtensionAbilityInfo.md) + - [HapModuleInfo (HapModuleInfo)](reference/apis/js-apis-bundle-HapModuleInfo.md) + - [LauncherAbilityInfo (LauncherAbilityInfo)](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) + - [Metadata (Metadata)](reference/apis/js-apis-bundle-Metadata.md) + - [ModuleInfo (ModuleInfo)](reference/apis/js-apis-bundle-ModuleInfo.md) + - [PermissionDef (PermissionDef)](reference/apis/js-apis-bundle-PermissionDef.md) + - [RemoteAbilityInfo (RemoteAbilityInfo)](reference/apis/js-apis-bundle-remoteAbilityInfo.md) + - [ShortcutInfo (ShortcutInfo)](reference/apis/js-apis-bundle-ShortcutInfo.md) - UIç•Œé¢ - [@ohos.animator (动画)](reference/apis/js-apis-animator.md) - [@ohos.mediaquery (媒体查询)](reference/apis/js-apis-mediaquery.md) - [@ohos.prompt (弹窗)](reference/apis/js-apis-prompt.md) - [@ohos.router (页é¢è·¯ç”±)](reference/apis/js-apis-router.md) + - [@ohos.uiAppearance(用户界é¢å¤–观)](reference/apis/js-apis-uiappearance.md) - å›¾å½¢å›¾åƒ + - [@ohos.animation.windowAnimationManager (窗å£åŠ¨ç”»ç®¡ç†)](reference/apis/js-apis-windowAnimationManager.md) - [@ohos.display (å±å¹•å±žæ€§)](reference/apis/js-apis-display.md) + - [@ohos.effectKit (图åƒæ•ˆæžœ)](reference/apis/js-apis-effectKit.md) + - [@ohos.screen (å±å¹•)](reference/apis/js-apis-screen.md) - [@ohos.screenshot (å±å¹•æˆªå›¾)](reference/apis/js-apis-screenshot.md) - [@ohos.window (窗å£)](reference/apis/js-apis-window.md) - [webgl (WebGL)](reference/apis/js-apis-webgl.md) - [webgl2 (WebGL2)](reference/apis/js-apis-webgl2.md) - - 媒体 + - 媒体 - [@ohos.multimedia.audio (音频管ç†)](reference/apis/js-apis-audio.md) - [@ohos.multimedia.camera (相机管ç†)](reference/apis/js-apis-camera.md) - [@ohos.multimedia.image (图片处ç†)](reference/apis/js-apis-image.md) @@ -639,13 +747,16 @@ - [@ohos.resourceManager (资æºç®¡ç†)](reference/apis/js-apis-resource-manager.md) - 资æºè°ƒåº¦ - [@ohos.backgroundTaskManager (åŽå°ä»»åŠ¡ç®¡ç†)](reference/apis/js-apis-backgroundTaskManager.md) + - [@ohos.distributedMissionManager (分布å¼ä»»åŠ¡ç®¡ç†)](reference/apis/js-apis-distributedMissionManager.md) - [@ohos.workScheduler (延迟任务调度)](reference/apis/js-apis-workScheduler.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](reference/apis/js-apis-WorkSchedulerExtensionAbility.md) - å®šåˆ¶ç®¡ç† - [@ohos.configPolicy (é…ç½®ç–ç•¥)](reference/apis/js-apis-config-policy.md) - [@ohos.enterpriseDeviceManager (ä¼ä¸šè®¾å¤‡ç®¡ç†)](reference/apis/js-apis-enterprise-device-manager.md) + - [@ohos.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](reference/apis/js-apis-EnterpriseAdminExtensionAbility.md) - 安全 - [@ohos.abilityAccessCtrl (访问控制管ç†)](reference/apis/js-apis-abilityAccessCtrl.md) + - [@ohos.privacyManager (éšç§ç®¡ç†)](reference/apis/js-apis-privacyManager.md) - [@ohos.security.huks (通用密钥库系统)](reference/apis/js-apis-huks.md) - [@ohos.userIAM.userAuth (用户认è¯)](reference/apis/js-apis-useriam-userauth.md) - [@system.cipher (åŠ å¯†ç®—æ³•)](reference/apis/js-apis-system-cipher.md) @@ -659,7 +770,6 @@ - [@ohos.data.preferences (首选项)](reference/apis/js-apis-data-preferences.md) - [@ohos.data.rdb (关系型数æ®åº“)](reference/apis/js-apis-data-rdb.md) - [@ohos.data.ValuesBucket (æ•°æ®é›†)](reference/apis/js-apis-data-ValuesBucket.md) - - [@ohos.settings (设置数æ®é¡¹å称)](reference/apis/js-apis-settings.md) - [resultSet (结果集)](reference/apis/js-apis-data-resultset.md) - æ–‡ä»¶ç®¡ç† - [@ohos.document (文件交互)](reference/apis/js-apis-document.md) @@ -669,6 +779,7 @@ - [@ohos.statfs (statfs)](reference/apis/js-apis-statfs.md) - [@ohos.storageStatistics (应用空间统计)](reference/apis/js-apis-storage-statistics.md) - [@ohos.volumeManager (å·ç®¡ç†)](reference/apis/js-apis-volumemanager.md) + - [@ohos.securityLabel (æ•°æ®æ ‡ç¾)](reference/apis/js-apis-securityLabel.md) - 电è¯æœåŠ¡ - [@ohos.contact (è”系人)](reference/apis/js-apis-contact.md) - [@ohos.telephony.call (拨打电è¯)](reference/apis/js-apis-call.md) @@ -686,6 +797,9 @@ - 通信与连接 - [@ohos.bluetooth (è“牙)](reference/apis/js-apis-bluetooth.md) - [@ohos.connectedTag (有æºæ ‡ç¾)](reference/apis/js-apis-connectedTag.md) + - [@ohos.nfc.cardEmulation (æ ‡å‡†NFC-cardEmulation)](reference/apis/js-apis-cardEmulation.md) + - [@ohos.nfc.controller (æ ‡å‡†NFC)](reference/apis/js-apis-nfcController.md) + - [@ohos.nfc.tag (æ ‡å‡†NFC-Tag)](reference/apis/js-apis-nfcTag.md) - [@ohos.rpc (RPC通信)](reference/apis/js-apis-rpc.md) - [@ohos.wifi (WLAN)](reference/apis/js-apis-wifi.md) - [@ohos.wifiext (WLAN)](reference/apis/js-apis-wifiext.md) @@ -696,6 +810,7 @@ - [@ohos.hichecker (检测模å¼)](reference/apis/js-apis-hichecker.md) - [@ohos.hidebug (Debug调试)](reference/apis/js-apis-hidebug.md) - [@ohos.hilog (日志打å°)](reference/apis/js-apis-hilog.md) + - [@ohos.hiSysEvent (系统事件打点)](reference/apis/js-apis-hisysevent.md) - [@ohos.hiTraceChain (分布å¼è·Ÿè¸ª)](reference/apis/js-apis-hitracechain.md) - [@ohos.hiTraceMeter (性能打点)](reference/apis/js-apis-hitracemeter.md) - [@ohos.inputMethod (输入法框架)](reference/apis/js-apis-inputmethod.md) @@ -704,6 +819,7 @@ - [@ohos.screenLock (é”å±ç®¡ç†)](reference/apis/js-apis-screen-lock.md) - [@ohos.systemTime (设置系统时间)](reference/apis/js-apis-system-time.md) - [@ohos.wallpaper (å£çº¸)](reference/apis/js-apis-wallpaper.md) + - [@ohos.systemTimer(设置系统时间)](js-apis-system-timer.md) - [Timer (定时器)](reference/apis/js-apis-timer.md) - è®¾å¤‡ç®¡ç† - [@ohos.batteryInfo (电é‡ä¿¡æ¯)](reference/apis/js-apis-battery-info.md) @@ -713,16 +829,17 @@ - [@ohos.geolocation (ä½ç½®æœåŠ¡)](reference/apis/js-apis-geolocation.md) - [@ohos.multimodalInput.inputConsumer (组åˆæŒ‰é”®)](reference/apis/js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](reference/apis/js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputEvent (输入事件)](reference/apis/js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient (注入按键)](reference/apis/js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (输入监å¬)](reference/apis/js-apis-inputmonitor.md) - - [@ohos.multimodalInput.inputEvent (输入事件)](reference/apis/js-apis-inputevent.md) - [@ohos.multimodalInput.keyCode (键值)](reference/apis/js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (按键输入事件)](reference/apis/js-apis-keyevent.md) - [@ohos.multimodalInput.mouseEvent (é¼ æ ‡è¾“å…¥äº‹ä»¶)](reference/apis/js-apis-mouseevent.md) - - [@ohos.multimodalInput.ToucEvent (触摸输入事件)](reference/apis/js-apis-touchevent.md) + - [@ohos.multimodalInput.touchEvent (触摸输入事件)](reference/apis/js-apis-touchevent.md) - [@ohos.power (系统电æºç®¡ç†)](reference/apis/js-apis-power.md) - [@ohos.runningLock (Runninglocké”)](reference/apis/js-apis-runninglock.md) - [@ohos.sensor (ä¼ æ„Ÿå™¨)](reference/apis/js-apis-sensor.md) + - [@ohos.settings (设置数æ®é¡¹å称)](reference/apis/js-apis-settings.md) - [@ohos.systemParameter (系统属性)](reference/apis/js-apis-system-parameter.md) - [@ohos.thermal (çƒç®¡ç†)](reference/apis/js-apis-thermal.md) - [@ohos.update (å‡çº§)](reference/apis/js-apis-update.md) @@ -781,36 +898,43 @@ - [@system.vibrator (振动)](reference/apis/js-apis-system-vibrate.md) - [console (日志打å°)](reference/apis/js-apis-logs.md) - 接å£å‚考(Native API) - - OpenHarmony Native API - - MyProject - - [Native XComponent](reference/native-apis/_o_h___native_x_component.md) - - [Native_Bundle](reference/native-apis/_native___bundle.md) - - [HiLog](reference/native-apis/_hi_log.md) - - [NativeWindow](reference/native-apis/_native_window.md) - - [Drawing](reference/native-apis/_drawing.md) - - [Rawfile](reference/native-apis/rawfile.md) - - 头文件 - - [drawing_bitmap.h](reference/native-apis/drawing__bitmap_8h.md) - - [drawing_brush.h](reference/native-apis/drawing__brush_8h.md) - - [drawing_canvas.h](reference/native-apis/drawing__canvas_8h.md) - - [drawing_color.h](reference/native-apis/drawing__color_8h.md) - - [drawing_font_collection.h](reference/native-apis/drawing__font__collection_8h.md) - - [drawing_path.h](reference/native-apis/drawing__path_8h.md) - - [drawing_pen.h](reference/native-apis/drawing__pen_8h.md) - - [drawing_text_declaration.h](reference/native-apis/drawing__text__declaration_8h.md) - - [drawing_text_typography.h](reference/native-apis/drawing__text__typography_8h.md) - - [drawing_types.h](reference/native-apis/drawing__types_8h.md) - - [external_window.h](reference/native-apis/external__window_8h.md) - - [log.h](reference/native-apis/log_8h.md) - - [native_interface_bundle.h](reference/native-apis/native__interface__bundle_8h.md) - - [native_interface_xcomponent.h](reference/native-apis/native__interface__xcomponent_8h.md) - - [raw_dir.h](reference/native-apis/raw__dir_8h.md) - - [raw_file.h](reference/native-apis/raw__file_8h.md) - - 结构体 - - [OH_Drawing_BitmapFormat](reference/native-apis/_o_h___drawing___bitmap_format.md) - - [OH_NativeXComponent_Callback](reference/native-apis/_o_h___native_x_component___callback.md) - - [OH_NativeXComponent_TouchEvent](reference/native-apis/_o_h___native_x_component___touch_event.md) - - [OH_NativeXComponent_TouchPoint](reference/native-apis/_o_h___native_x_component___touch_point.md) - - [RawFileDescriptor](reference/native-apis/_raw_file_descriptor.md) - - [Native APIæ ‡å‡†åº“](reference/native-lib/third_party_libc/musl.md) - - [Node_API](reference/native-lib/third_party_napi/napi.md) \ No newline at end of file + - æ¨¡å— + - [Native XComponent](reference/native-apis/_o_h___native_x_component.md) + - [Native_Bundle](reference/native-apis/_native___bundle.md) + - [HiLog](reference/native-apis/_hi_log.md) + - [NativeWindow](reference/native-apis/_native_window.md) + - [Drawing](reference/native-apis/_drawing.md) + - [Rawfile](reference/native-apis/rawfile.md) + - 头文件 + - [drawing_bitmap.h](reference/native-apis/drawing__bitmap_8h.md) + - [drawing_brush.h](reference/native-apis/drawing__brush_8h.md) + - [drawing_canvas.h](reference/native-apis/drawing__canvas_8h.md) + - [drawing_color.h](reference/native-apis/drawing__color_8h.md) + - [drawing_font_collection.h](reference/native-apis/drawing__font__collection_8h.md) + - [drawing_path.h](reference/native-apis/drawing__path_8h.md) + - [drawing_pen.h](reference/native-apis/drawing__pen_8h.md) + - [drawing_text_declaration.h](reference/native-apis/drawing__text__declaration_8h.md) + - [drawing_text_typography.h](reference/native-apis/drawing__text__typography_8h.md) + - [drawing_types.h](reference/native-apis/drawing__types_8h.md) + - [external_window.h](reference/native-apis/external__window_8h.md) + - [log.h](reference/native-apis/log_8h.md) + - [native_interface_bundle.h](reference/native-apis/native__interface__bundle_8h.md) + - [native_interface_xcomponent.h](reference/native-apis/native__interface__xcomponent_8h.md) + - [raw_dir.h](reference/native-apis/raw__dir_8h.md) + - [raw_file.h](reference/native-apis/raw__file_8h.md) + - 结构体 + - [OH_Drawing_BitmapFormat](reference/native-apis/_o_h___drawing___bitmap_format.md) + - [OH_NativeXComponent_Callback](reference/native-apis/_o_h___native_x_component___callback.md) + - [OH_NativeXComponent_TouchEvent](reference/native-apis/_o_h___native_x_component___touch_event.md) + - [OH_NativeXComponent_TouchPoint](reference/native-apis/_o_h___native_x_component___touch_point.md) + - [RawFileDescriptor](reference/native-apis/_raw_file_descriptor.md) + - æ ‡å‡†åº“ + - [Node_API](reference/native-lib/third_party_napi/napi.md) + - [libuv](reference/native-lib/third_party_libuv/libuv.md) + - [支æŒçš„æ ‡å‡†åº“ä»‹ç»](reference/native-lib/third_party_libc/musl.md) + - 附录 + - [Native apiä¸æ²¡æœ‰å¯¼å‡ºçš„符å·åˆ—表](reference/native-lib/third_party_libc/musl-peculiar-symbol.md) + - [Native apiä¸å¯¼å‡ºçš„EGL符å·åˆ—表](reference/native-lib/third_party_opengl/egl-symbol.md) + - [Native apiä¸å¯¼å‡ºçš„OpenGL ES 3.0符å·åˆ—表](reference/native-lib/third_party_opengl/openglesv3-symbol.md) +- 常è§é—®é¢˜ + - [full-SDK替æ¢æŒ‡å—](quick-start/full-sdk-switch-guide.md) \ No newline at end of file diff --git a/zh-cn/application-dev/windowmanager/Readme-CN.md b/zh-cn/application-dev/windowmanager/Readme-CN.md index fcfb79f31d426720360b787f9efba03f1be16849..fff76b863d6b9198dec861f7cffaf7e9025009d2 100644 --- a/zh-cn/application-dev/windowmanager/Readme-CN.md +++ b/zh-cn/application-dev/windowmanager/Readme-CN.md @@ -1,12 +1,16 @@ # 窗å£ç®¡ç† -* çª—å£ - * [窗å£å¼€å‘概述](window-overview.md) - * [窗å£å¼€å‘指导](window-guidelines.md) -* å±å¹•å±žæ€§ - * [å±å¹•å±žæ€§å¼€å‘概述](display-overview.md) - * [å±å¹•å±žæ€§å¼€å‘指导](display-guidelines.md) -* å±å¹•æˆªå›¾ - * [å±å¹•æˆªå›¾å¼€å‘概述](screenshot-overview.md) - * [å±å¹•æˆªå›¾å¼€å‘指导](screenshot-guidelines.md) +- çª—å£ + - [窗å£å¼€å‘概述](window-overview.md) + - [管ç†åº”用窗å£ï¼ˆStage模型)](application-window-stage.md) + - [管ç†åº”用窗å£ï¼ˆFA模型)](application-window-fa.md) + - [管ç†ç³»ç»Ÿçª—å£ï¼ˆä»…Stage模型支æŒï¼‰](system-window-stage.md) + +- å±å¹•å±žæ€§ + - [å±å¹•å±žæ€§å¼€å‘概述](display-overview.md) + - [å±å¹•å±žæ€§å¼€å‘指导](display-guidelines.md) + +- å±å¹•æˆªå›¾ + - [å±å¹•æˆªå›¾å¼€å‘概述](screenshot-overview.md) + - [å±å¹•æˆªå›¾å¼€å‘指导](screenshot-guidelines.md) \ No newline at end of file diff --git a/zh-cn/application-dev/windowmanager/application-window-fa.md b/zh-cn/application-dev/windowmanager/application-window-fa.md new file mode 100644 index 0000000000000000000000000000000000000000..20f2f1d3e00c5c44eaa520e8f3bf8a33d05e6771 --- /dev/null +++ b/zh-cn/application-dev/windowmanager/application-window-fa.md @@ -0,0 +1,260 @@ +# 管ç†åº”用窗å£ï¼ˆFA模型) + +## 基本概念 + +窗å£æ²‰æµ¸å¼èƒ½åŠ›ï¼šæŒ‡å¯¹çŠ¶æ€æ ã€å¯¼èˆªæ ç‰ç³»ç»Ÿçª—å£è¿›è¡ŒæŽ§åˆ¶ï¼Œå‡å°‘状æ€æ 导航æ ç‰ç³»ç»Ÿç•Œé¢çš„çªå…€æ„Ÿï¼Œä»Žè€Œä½¿ç”¨æˆ·èŽ·å¾—最佳体验的能力。 +沉浸å¼èƒ½åŠ›åªåœ¨åº”用主窗å£ä½œä¸ºå…¨å±çª—å£æ—¶ç”Ÿæ•ˆã€‚通常情况下,应用å窗å£ï¼ˆå¼¹çª—ã€æ‚¬æµ®çª—å£ç‰è¾…助窗å£ï¼‰å’Œå¤„于自由窗å£ä¸‹çš„应用主窗å£æ— 法使用沉浸å¼èƒ½åŠ›ã€‚ + +## åœºæ™¯ä»‹ç» + +在FA模型下,管ç†åº”用窗å£çš„典型场景有: + +- 设置应用å窗å£å±žæ€§åŠç›®æ ‡é¡µé¢ + +- 体验窗å£æ²‰æµ¸å¼èƒ½åŠ› + +以下分别介ç»å…·ä½“å¼€å‘æ–¹å¼ã€‚ + + +## 接å£è¯´æ˜Ž + +上述场景涉åŠçš„常用接å£å¦‚下表所示。更多API说明请å‚è§[APIå‚考](../reference/apis/js-apis-window.md)。 + +| 实例å | 接å£å | æè¿° | +| -------- | -------- | -------- | +| windowé™æ€æ–¹æ³• | create(id:string,type:WindowType,callback:AsyncCallback]<Window>):void | 创建å窗å£ã€‚<br>æ¤æŽ¥å£ä»…å¯åœ¨`FA`模型下使用。 | +| windowé™æ€æ–¹æ³• | getTopWindow(callback:AsyncCallback<Window>):void | 获å–当å‰åº”用内最åŽæ˜¾ç¤ºçš„窗å£ã€‚<br/>æ¤æŽ¥å£ä»…å¯åœ¨`FA`模型下使用。 | +| windowé™æ€æ–¹æ³• | find(id:string,callback:AsyncCallback<Window>):void | 查找`id`所对应的窗å£ã€‚ | +| Window | loadContent(path:string,callback:AsyncCallback<void>):void | 为当å‰çª—å£åŠ 载具体页é¢å†…容。 | +| Window | moveTo(x:number,y:number,callback:AsyncCallback<void>):void | 移动当å‰çª—å£ã€‚ | +| Window | setBackgroundColor(color:string,callback:AsyncCallback<void>):void | 设置窗å£çš„背景色 | +| Window | setBrightness(brightness:number,callback:AsyncCallback<void>):void | 设置å±å¹•äº®åº¦å€¼ã€‚ | +| Window | resetSize(width:number,height:number,callback:AsyncCallback<void>):void | 改å˜å½“å‰çª—å£å¤§å°ã€‚ | +| Window | setFullScreen(isFullScreen:boolean,callback:AsyncCallback<void>):void | 设置窗å£æ˜¯å¦å…¨å±æ˜¾ç¤ºã€‚ | +| Window | setLayoutFullScreen(isLayoutFullScreen:boolean,callback:AsyncCallback<void>):void | 设置窗å£å¸ƒå±€æ˜¯å¦ä¸ºå…¨å±å¸ƒå±€ã€‚ | +| Window | setSystemBarEnable(names:Array<'status'\|'navigation'>):Promise<void> | 设置导航æ ã€çŠ¶æ€æ 是å¦æ˜¾ç¤ºã€‚ | +| Window | setSystemBarProperties(systemBarProperties:SystemBarProperties,callback:AsyncCallback<void>):void | 设置窗å£å†…导航æ ã€çŠ¶æ€æ 属性。<br/>`systemBarProperties`:导航æ ã€çŠ¶æ€æ 的属性集åˆã€‚ | +| Window | show(callback: AsyncCallback\<void>): void | 显示当å‰çª—å£ã€‚ | +| Window | on(type:'touchOutside',callback:Callback<void>):void | å¼€å¯æœ¬çª—å£åŒºåŸŸå¤–的点击事件的监å¬ã€‚ | +| Window | destroy(callback: AsyncCallback<void>):void | 销æ¯å½“å‰çª—å£ã€‚ | + + +## 设置应用åçª—å£ + +å¼€å‘者å¯ä»¥æŒ‰éœ€åˆ›å»ºåº”用å窗å£ï¼Œå¦‚弹窗ç‰ï¼Œå¹¶å¯¹å…¶è¿›è¡Œå±žæ€§è®¾ç½®ç‰æ“作。 + + +### å¼€å‘æ¥éª¤ + +1. 创建/获å–å窗å£å¯¹è±¡ã€‚ + + - å¯ä»¥é€šè¿‡`window.create`接å£åˆ›å»ºå窗å£ã€‚ + - å¯ä»¥é€šè¿‡`window.getTopWindow`æ¥èŽ·å–最åŽæ˜¾ç¤ºçš„窗å£å¾—到å窗å£ã€‚ + - 也å¯ä»¥é€šè¿‡`window.find`接å£æ¥æŸ¥æ‰¾å·²ç»åˆ›å»ºçš„窗å£ä»Žè€Œå¾—到å窗å£ã€‚ + + ```js + import window from '@ohos.window'; + + var windowClass = null; + // 1.æ–¹å¼ä¸€ï¼šåˆ›å»ºå窗å£ã€‚ + window.create("subWindow", window.WindowType.TYPE_APP, (err, data) => { + if (err.code) { + console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in creating subWindow. Data: ' + JSON.stringify(data)); + windowClass = data; + }); + // 1.æ–¹å¼äºŒï¼šèŽ·å–å窗å£ã€‚ + window.getTopWindow((err, data) => { + if (err.code) { + console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting subWindow. Data: ' + JSON.stringify(data)); + windowClass = data; + }); + // 1.æ–¹å¼ä¸‰ï¼šæŸ¥æ‰¾å¾—到å窗å£ã€‚ + window.find("subWindow", (err, data) => { + if (err.code) { + console.error('Failed to find the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in finding subWindow. Data: ' + JSON.stringify(data)); + windowClass = data; + }); + ``` + +2. 设置å窗å£å±žæ€§ã€‚ + + å窗å£åˆ›å»ºæˆåŠŸåŽï¼Œå¯ä»¥æ”¹å˜å…¶å¤§å°ã€ä½ç½®ç‰ï¼Œè¿˜å¯ä»¥æ ¹æ®åº”用需è¦è®¾ç½®çª—å£èƒŒæ™¯è‰²ã€äº®åº¦ç‰å±žæ€§ã€‚ + + + ```js + // 2.移动å窗å£ä½ç½®ã€‚ + windowClass.moveTo(300, 300, (err, data) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }); + // 2.改å˜å窗å£å¤§å°ã€‚ + windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }); + ``` + +3. åŠ è½½æ˜¾ç¤ºå窗å£çš„具体内容。 + + 使用`loadContent`å’Œ`show`接å£åŠ 载显示å窗å£çš„具体内容。 + + + ```js + // 3.为å窗å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + windowClass.loadContent("pages/page2", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 3.显示å窗å£ã€‚ + windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + ``` + +4. 销æ¯å窗å£ã€‚ + + 当ä¸å†éœ€è¦æŸäº›å窗å£æ—¶ï¼Œå¯æ ¹æ®åœºæ™¯çš„具体实现逻辑,使用`destroy`接å£é”€æ¯å窗å£ã€‚ + + + ```js + // 4.销æ¯å窗å£ã€‚当ä¸å†éœ€è¦æŸäº›å窗å£æ—¶ï¼Œå¯æ ¹æ®åœºæ™¯çš„具体实现逻辑,使用destroy接å£é”€æ¯å窗å£ï¼Œæ¤å¤„以监å¬çª—å£åŒºåŸŸå¤–的点击事件实现å窗å£çš„销æ¯ã€‚ + windowClass.on('touchOutside', () => { + console.info('touch outside'); + windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the subwindow. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the subwindow. Data: ' + JSON.stringify(data)); + }); + }); + ``` + + +## 体验窗å£æ²‰æµ¸å¼èƒ½åŠ› + +在看视频ã€çŽ©æ¸¸æˆç‰åœºæ™¯ä¸‹ï¼Œç”¨æˆ·å¾€å¾€å¸Œæœ›éšè—状æ€æ ã€å¯¼èˆªæ ç‰ä¸å¿…è¦çš„系统窗å£ï¼Œä»Žè€ŒèŽ·å¾—更佳的沉浸å¼ä½“验。æ¤æ—¶å¯ä»¥å€ŸåŠ©çª—å£æ²‰æµ¸å¼èƒ½åŠ›ï¼ˆçª—å£æ²‰æµ¸å¼èƒ½åŠ›éƒ½æ˜¯é’ˆå¯¹åº”用主窗å£è€Œè¨€çš„),达到预期效果。 + + +### å¼€å‘æ¥éª¤ + +1. 获å–主窗å£å¯¹è±¡ã€‚ + + 沉浸å¼èƒ½åŠ›éœ€è¦åœ¨æˆåŠŸèŽ·å–应用主窗å£å¯¹è±¡çš„å‰æ下进行。使用`window.getTopWindow`接å£æ¥èŽ·å–得到主窗å£ã€‚ + + + ```js + import window from '@ohos.window'; + + var mainWindowClass = null; + // 1.获å–ä¸»çª—å£ + window.getTopWindow((err, data) => { + if (err.code) { + console.error('Failed to get the subWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting subWindow. Data: ' + JSON.stringify(data)); + mainWindowClass = data; + }); + ``` + +2. 实现沉浸å¼æ•ˆæžœã€‚有以下三ç§æ–¹å¼ï¼š + + - æ–¹å¼ä¸€ï¼šè°ƒç”¨`setFullScreen`接å£ï¼Œè®¾ç½®åº”用主窗å£ä¸ºå…¨å±æ˜¾ç¤ºï¼Œæ¤æ—¶å¯¼èˆªæ ã€çŠ¶æ€æ å°†éšè—,从而达到沉浸å¼æ•ˆæžœã€‚ + - æ–¹å¼äºŒï¼šè°ƒç”¨`setSystemBarEnable`接å£ï¼Œè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ ä¸æ˜¾ç¤ºï¼Œä»Žè€Œè¾¾åˆ°æ²‰æµ¸å¼æ•ˆæžœã€‚ + - æ–¹å¼ä¸‰ï¼šè°ƒç”¨`setLayoutFullScreen`接å£ï¼Œè®¾ç½®åº”用主窗å£ä¸ºå…¨å±å¸ƒå±€ï¼›ç„¶åŽè°ƒç”¨`setSystemPropertites`接å£ï¼Œè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ çš„é€æ˜Žåº¦ã€èƒŒæ™¯/æ–‡å—颜色以åŠé«˜äº®å›¾æ ‡ç‰å±žæ€§ï¼Œä½¿ä¹‹ä¿æŒä¸Žä¸»çª—å£æ˜¾ç¤ºå调一致,从而达到沉浸å¼æ•ˆæžœã€‚ + + ```js + // 2.实现沉浸å¼æ•ˆæžœã€‚æ–¹å¼ä¸€ï¼šè®¾ç½®çª—å£å…¨å±æ˜¾ç¤ºã€‚ + var isFullScreen = true; + mainWindowClass.setFullScreen(isFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); + }); + // 2.实现沉浸å¼æ•ˆæžœã€‚æ–¹å¼äºŒï¼šè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ ä¸æ˜¾ç¤ºã€‚ + var names = null; + mainWindowClass.setSystemBarEnable(names, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); + }); + // 2.实现沉浸å¼æ•ˆæžœã€‚ + //æ–¹å¼ä¸‰ï¼šè®¾ç½®çª—å£ä¸ºå…¨å±å¸ƒå±€ï¼Œé…åˆè®¾ç½®çŠ¶æ€æ ã€å¯¼èˆªæ çš„é€æ˜Žåº¦ã€èƒŒæ™¯/æ–‡å—颜色åŠé«˜äº®å›¾æ ‡ç‰å±žæ€§ï¼Œä¸Žä¸»çª—å£æ˜¾ç¤ºä¿æŒå调一致。 + var isLayoutFullScreen = true; + mainWindowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); + }); + var SystemBarProperties = { + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + //以下两个属性从API Version7å¼€å§‹æ”¯æŒ + isStatusBarLightIcon: false, + isNavigationBarLightIcon: false, + //以下两个属性从API Version8å¼€å§‹æ”¯æŒ + statusBarContentColor: '#ffffff', + navigationBarContentColor: '#ffffff' + }; + mainWindowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); + }); + ``` + +3. åŠ è½½æ˜¾ç¤ºæ²‰æµ¸å¼çª—å£çš„具体内容。 + + 使用`loadContent`å’Œ`show`接å£åŠ 载显示沉浸å¼çª—å£çš„具体内容。 + + + ```js + // 3.为沉浸å¼çª—å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + mainWindowClass.loadContent("pages/page3", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 3.显示沉浸å¼çª—å£ã€‚ + mainWindowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + ``` + diff --git a/zh-cn/application-dev/windowmanager/application-window-stage.md b/zh-cn/application-dev/windowmanager/application-window-stage.md new file mode 100644 index 0000000000000000000000000000000000000000..33fe1385b290ea4b51630d9152f6c3a8341db84d --- /dev/null +++ b/zh-cn/application-dev/windowmanager/application-window-stage.md @@ -0,0 +1,406 @@ +# 管ç†åº”用窗å£ï¼ˆStage模型) + + +## 基本概念 + +- 窗å£æ²‰æµ¸å¼èƒ½åŠ›ï¼šæŒ‡å¯¹çŠ¶æ€æ ã€å¯¼èˆªæ ç‰ç³»ç»Ÿçª—å£è¿›è¡ŒæŽ§åˆ¶ï¼Œå‡å°‘状æ€æ 导航æ ç‰ç³»ç»Ÿç•Œé¢çš„çªå…€æ„Ÿï¼Œä»Žè€Œä½¿ç”¨æˆ·èŽ·å¾—最佳体验的能力。 + 沉浸å¼èƒ½åŠ›åªåœ¨åº”用主窗å£ä½œä¸ºå…¨å±çª—å£æ—¶ç”Ÿæ•ˆã€‚通常情况下,应用å窗å£ï¼ˆå¼¹çª—ã€æ‚¬æµ®çª—å£ç‰è¾…助窗å£ï¼‰å’Œå¤„于自由窗å£ä¸‹çš„应用主窗å£æ— 法使用沉浸å¼èƒ½åŠ›ã€‚ + +- 悬浮窗:全局悬浮窗å£æ˜¯ä¸€ç§ç‰¹æ®Šçš„应用窗å£ï¼Œå…·å¤‡åœ¨åº”用主窗å£å’Œå¯¹åº”Ability退至åŽå°åŽä»ç„¶å¯ä»¥åœ¨å‰å°æ˜¾ç¤ºçš„能力。 + 悬浮窗å£å¯ä»¥ç”¨äºŽåº”用退至åŽå°åŽï¼Œä½¿ç”¨å°çª—继ç»æ’放视频,或者为特定的应用创建悬浮çƒç‰å¿«é€Ÿå…¥å£ã€‚应用在创建悬浮窗å£å‰ï¼Œéœ€è¦ç”³è¯·å¯¹åº”çš„æƒé™ã€‚ + + +## åœºæ™¯ä»‹ç» + +在`Stage`模型下,管ç†åº”用窗å£çš„典型场景有: + +- 设置应用主窗å£å±žæ€§åŠç›®æ ‡é¡µé¢ + +- 设置应用å窗å£å±žæ€§åŠç›®æ ‡é¡µé¢ + +- 体验窗å£æ²‰æµ¸å¼èƒ½åŠ› + +- 设置悬浮窗 + +以下分别介ç»å…·ä½“å¼€å‘æ–¹å¼ã€‚ + + +## 接å£è¯´æ˜Ž + +上述场景涉åŠçš„常用接å£å¦‚下表所示。更多API说明请å‚è§[APIå‚考](../reference/apis/js-apis-window.md)。 + +| 实例å | 接å£å | æè¿° | +| -------- | -------- | -------- | +| WindowStage | getMainWindow(callback:AsyncCallback<Window>):void | 获å–`WindowStage`实例下的主窗å£ã€‚<br/>æ¤æŽ¥å£ä»…å¯åœ¨`Stage`模型下使用。 | +| WindowStage | loadContent(path:string,callback:AsyncCallback<void>):void | 为当å‰`WindowStage`的主窗å£åŠ 载具体页é¢ã€‚<br/>æ¤æŽ¥å£ä»…å¯åœ¨`Stage`模型下使用。 | +| WindowStage | createSubWindow(name:string,callback:AsyncCallback<Window>):void | 创建å窗å£ã€‚<br/>æ¤æŽ¥å£ä»…å¯åœ¨`Stage`模型下使用。 | +| windowé™æ€æ–¹æ³• | create(ctx:Context,id:string,type:WindowType,callback:AsyncCallback<Window>):void | 创建å窗å£ã€‚<br/>-`ctx`:为应用上下文信æ¯ã€‚<br/>-`type`:为创建的窗å£ç±»åž‹ã€‚ | +| Window | loadContent(path:string,callback:AsyncCallback<void>):void | 为当å‰çª—å£åŠ 载具体页é¢ã€‚ | +| Window | setBackgroundColor(color:string,callback:AsyncCallback<void>):void | 设置窗å£çš„背景色。 | +| Window | setBrightness(brightness:number,callback:AsyncCallback<void>):void | 设置å±å¹•äº®åº¦å€¼ã€‚ | +| Window | setTouchable(isTouchable:boolean,callback:AsyncCallback<void>):void | 设置窗å£æ˜¯å¦ä¸ºå¯è§¦çŠ¶æ€ã€‚ | +| Window | moveTo(x:number,y:number,callback:AsyncCallback<void>):void | 移动当å‰çª—å£ä½ç½®ã€‚ | +| Window | resetSize(width:number,height:number,callback:AsyncCallback<void>):void | 改å˜å½“å‰çª—å£å¤§å°ã€‚ | +| Window | setFullScreen(isFullScreen:boolean,callback:AsyncCallback<void>):void | 设置窗å£æ˜¯å¦å…¨å±æ˜¾ç¤ºã€‚ | +| Window | setLayoutFullScreen(isLayoutFullScreen:boolean,callback:AsyncCallback<void>):void | 设置窗å£å¸ƒå±€æ˜¯å¦ä¸ºå…¨å±å¸ƒå±€ã€‚ | +| Window | setSystemBarEnable(names:Array<'status'\|'navigation'>):Promise<void> | 设置导航æ ã€çŠ¶æ€æ 是å¦æ˜¾ç¤ºã€‚ | +| Window | setSystemBarProperties(systemBarProperties:SystemBarProperties,callback:AsyncCallback<void>):void | 设置窗å£å†…导航æ ã€çŠ¶æ€æ 属性。<br/>`systemBarProperties`:导航æ ã€çŠ¶æ€æ 的属性集åˆã€‚ | +| Window | show(callback: AsyncCallback\<void>): void | 显示当å‰çª—å£ã€‚ | +| Window | on(type:'touchOutside',callback:Callback<void>):void | å¼€å¯æœ¬çª—å£åŒºåŸŸå¤–的点击事件的监å¬ã€‚ | +| Window | destroy(callback: AsyncCallback<void>):void | 销æ¯å½“å‰çª—å£ã€‚ | + + +## è®¾ç½®åº”ç”¨ä¸»çª—å£ + +在`Stage`模型下,应用主窗å£ç”±`Ability`创建并维护生命周期。在`Ability`çš„`onWindowStageCreate`回调ä¸ï¼Œé€šè¿‡`WindowStage`获å–应用主窗å£ï¼Œå³å¯å¯¹å…¶è¿›è¡Œå±žæ€§è®¾ç½®ç‰æ“作 + + +### å¼€å‘æ¥éª¤ + +1. 获å–应用主窗å£ã€‚ + 通过`getMainWindow`接å£èŽ·å–应用主窗å£ã€‚ + +2. 设置主窗å£å±žæ€§ã€‚ + å¯è®¾ç½®ä¸»çª—å£çš„背景色ã€äº®åº¦å€¼ã€æ˜¯å¦å¯è§¦ç‰å¤šä¸ªå±žæ€§ï¼Œå¼€å‘者å¯æ ¹æ®éœ€è¦é€‰æ‹©å¯¹åº”的接å£ã€‚本示例以设置“是å¦å¯è§¦â€å±žæ€§ä¸ºä¾‹ã€‚ + +3. 为主窗å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + 通过`loadContent`接å£åŠ 载主窗å£çš„ç›®æ ‡é¡µé¢ã€‚ + + +```ts +import Ability from '@ohos.application.Ability' + +class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + // 1.获å–应用主窗å£ã€‚ + var windowClass = null; + windowStage.getMainWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + // 2.设置主窗å£å±žæ€§ã€‚以设置"是å¦å¯è§¦"属性为例。 + var isTouchable = true; + windowClass.setTouchable(isTouchable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); + }) + }) + // 3.为主窗å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + windowStage.loadContent("pages/page2", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + }); + } +}; +``` + + +## 设置应用åçª—å£ + +å¼€å‘者å¯ä»¥æŒ‰éœ€åˆ›å»ºåº”用å窗å£ï¼Œå¦‚弹窗ç‰ï¼Œå¹¶å¯¹å…¶è¿›è¡Œå±žæ€§è®¾ç½®ç‰æ“作。 + + +### å¼€å‘æ¥éª¤ + +1. 创建/获å–应用å窗å£ã€‚ + 通过`createSubWindow`接å£åˆ›å»ºåº”用å窗å£ã€‚ + + 通过`getSubWindow`接å£èŽ·å–已创建的应用å窗å£ã€‚ + +2. 设置å窗å£å±žæ€§ã€‚ + å窗å£åˆ›å»ºæˆåŠŸåŽï¼Œå¯ä»¥æ”¹å˜å…¶å¤§å°ã€ä½ç½®ç‰ï¼Œè¿˜å¯ä»¥æ ¹æ®åº”用需è¦è®¾ç½®çª—å£èƒŒæ™¯è‰²ã€äº®åº¦ç‰å±žæ€§ã€‚ + +3. åŠ è½½æ˜¾ç¤ºå窗å£çš„具体内容。 + 通过`loadContent`å’Œ`show`接å£åŠ 载显示å窗å£çš„具体内容。 + +4. 销æ¯å窗å£ã€‚ + 当ä¸å†éœ€è¦æŸäº›å窗å£æ—¶ï¼Œå¯æ ¹æ®å…·ä½“实现逻辑,使用`destroy`接å£é”€æ¯å窗å£ã€‚ + + + ```ts + import Ability from '@ohos.application.Ability' + + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + // 1.创建应用å窗å£ã€‚ + var sub_windowClass = null; + windowStage.createSubWindow("mySubWindow", (err, data) => { + if (err.code) { + console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); + return; + } + sub_windowClass = data; + console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); + // 1.获å–已创建的应用å窗å£ã€‚ + windowStage.getSubWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the subWindow. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in obtaining the subWindow. Data: ' + JSON.stringify(data)); + sub_windowClass = data; + }); + // 2.å窗å£åˆ›å»ºæˆåŠŸåŽï¼Œè®¾ç½®å窗å£çš„ä½ç½®ã€å¤§å°åŠç›¸å…³å±žæ€§ç‰ã€‚ + sub_windowClass.moveTo(300, 300, (err, data) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }); + sub_windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }); + // 3.为å窗å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + sub_windowClass.loadContent("pages/page3", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 3.显示å窗å£ã€‚ + sub_windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + // 4.销æ¯å窗å£ã€‚当ä¸å†éœ€è¦å窗å£æ—¶ï¼Œå¯æ ¹æ®å…·ä½“实现逻辑,使用destroy对其进行销æ¯ï¼Œæ¤å¤„以监å¬çª—å£åŒºåŸŸå¤–的点击事件为例实现å窗å£çš„销æ¯ã€‚ + sub_windowClass.on('touchOutside', () => { + console.info('touch outside'); + sub_windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); + }); + }); + }) + } + }; + ``` + + +## 体验窗å£æ²‰æµ¸å¼èƒ½åŠ› + +在看视频ã€çŽ©æ¸¸æˆç‰åœºæ™¯ä¸‹ï¼Œç”¨æˆ·å¾€å¾€å¸Œæœ›éšè—状æ€æ ã€å¯¼èˆªæ ç‰ä¸å¿…è¦çš„系统窗å£ï¼Œä»Žè€ŒèŽ·å¾—更佳的沉浸å¼ä½“验。æ¤æ—¶å¯ä»¥å€ŸåŠ©çª—å£æ²‰æµ¸å¼èƒ½åŠ›ï¼ˆçª—å£æ²‰æµ¸å¼èƒ½åŠ›éƒ½æ˜¯é’ˆå¯¹åº”用主窗å£è€Œè¨€çš„),达到预期效果。 + + +### å¼€å‘æ¥éª¤ + +1. 获å–应用主窗å£ã€‚ + 通过`getMainWindow`接å£èŽ·å–应用主窗å£ã€‚ + +2. 实现沉浸å¼æ•ˆæžœã€‚有以下三ç§æ–¹å¼ï¼š + - æ–¹å¼ä¸€ï¼šè°ƒç”¨`setFullScreen`接å£ï¼Œè®¾ç½®åº”用主窗å£ä¸ºå…¨å±æ˜¾ç¤ºï¼Œæ¤æ—¶å¯¼èˆªæ ã€çŠ¶æ€æ å°†éšè—,从而达到沉浸å¼æ•ˆæžœã€‚ + - æ–¹å¼äºŒï¼šè°ƒç”¨`setSystemBarEnable`接å£ï¼Œè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ ä¸æ˜¾ç¤ºï¼Œä»Žè€Œè¾¾åˆ°æ²‰æµ¸å¼æ•ˆæžœã€‚ + - æ–¹å¼ä¸‰ï¼šè°ƒç”¨`setLayoutFullScreen`接å£ï¼Œè®¾ç½®åº”用主窗å£ä¸ºå…¨å±å¸ƒå±€ï¼›ç„¶åŽè°ƒç”¨`setSystemPropertites`接å£ï¼Œè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ çš„é€æ˜Žåº¦ã€èƒŒæ™¯/æ–‡å—颜色以åŠé«˜äº®å›¾æ ‡ç‰å±žæ€§ï¼Œä½¿ä¹‹ä¿æŒä¸Žä¸»çª—å£æ˜¾ç¤ºå调一致,从而达到沉浸å¼æ•ˆæžœã€‚ + +3. åŠ è½½æ˜¾ç¤ºæ²‰æµ¸å¼çª—å£çš„具体内容。 + 通过`loadContent`å’Œ`show`接å£åŠ 载显示沉浸å¼çª—å£çš„具体内容。 + + + ```ts + import Ability from '@ohos.application.Ability' + + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + // 1.获å–应用主窗å£ã€‚ + var windowClass = null; + windowStage.getMainWindow((err, data) => { + if (err.code) { + console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); + return; + } + windowClass = data; + console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); + + // 2.实现沉浸å¼æ•ˆæžœã€‚æ–¹å¼ä¸€ï¼šè®¾ç½®åº”用主窗å£ä¸ºå…¨å±æ˜¾ç¤ºã€‚ + var isFullScreen = true; + windowClass.setFullScreen(isFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); + }); + // 2.实现沉浸å¼æ•ˆæžœã€‚æ–¹å¼äºŒï¼šè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ ä¸æ˜¾ç¤ºã€‚ + var names = null; + windowClass.setSystemBarEnable(names, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); + }); + // 2.实现沉浸å¼æ•ˆæžœã€‚æ–¹å¼ä¸‰ï¼šè®¾ç½®çª—å£ä¸ºå…¨å±å¸ƒå±€ï¼Œé…åˆè®¾ç½®å¯¼èˆªæ ã€çŠ¶æ€æ çš„é€æ˜Žåº¦ã€èƒŒæ™¯/æ–‡å—颜色åŠé«˜äº®å›¾æ ‡ç‰å±žæ€§ï¼Œä¸Žä¸»çª—å£æ˜¾ç¤ºä¿æŒå调一致。 + var isLayoutFullScreen = true; + windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + if (err.code) { + console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); + }); + var SystemBarProperties = { + statusBarColor: '#ff00ff', + navigationBarColor: '#00ff00', + // 以下两个属性从API Version 7å¼€å§‹æ”¯æŒ + isStatusBarLightIcon: false, + isNavigationBarLightIcon: false, + // 以下两个属性从API Version 8å¼€å§‹æ”¯æŒ + statusBarContentColor: '#ffffff', + navigationBarContentColor: '#ffffff' + }; + windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + if (err.code) { + console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)); + }); + }) + // 3.为沉浸å¼çª—å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + windowStage.loadContent("pages/page2", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 3.显示沉浸å¼çª—å£ã€‚ + windowStage.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + } + }; + ``` + + +## 设置悬浮窗 + +悬浮窗å¯ä»¥åœ¨å·²æœ‰çš„任务基础上,创建一个始终在å‰å°æ˜¾ç¤ºçš„窗å£ã€‚å³ä½¿åˆ›å»ºæ‚¬æµ®çª—的任务退至åŽå°ï¼Œæ‚¬æµ®çª—ä»ç„¶å¯ä»¥åœ¨å‰å°æ˜¾ç¤ºã€‚å¼€å‘者å¯ä»¥åˆ›å»ºæ‚¬æµ®çª—,并对悬浮窗进行属性设置ç‰æ“作。 + + +### å¼€å‘æ¥éª¤ + +1. 申请æƒé™ã€‚ + 创建`WindowType.TYPE_FLOAT`å³æ‚¬æµ®çª—类型的窗å£ï¼Œéœ€è¦åœ¨`module.json5`文件的`requestPermissions`对象ä¸é…ç½®`ohos.permission.SYSTEM_FLOAT_WINDOW`æƒé™ã€‚更多é…置信æ¯è¯¦è§[应用包结构é…置文件的说明](../quick-start/stage-structure.md)。 + + > **说明:** + > 虽然悬浮窗具备始终在å‰å°æ˜¾ç¤ºçš„能力,但如果创建悬浮窗的应用任务被系统回收,ä»ç„¶ä¼šå¯¼è‡´æ‚¬æµ®çª—从界é¢ç§»é™¤ã€‚如果想è¦ä¿æŒæ‚¬æµ®çª—å£å§‹ç»ˆåœ¨å‰å°æ˜¾ç¤ºï¼Œè¯·ç”³è¯·[长时任务](../task-management/background-task-overview.md)。 + + + ```json + { + "module": { + "requestPermissions":[ + { + "name" : "ohos.permission.SYSTEM_FLOAT_WINDOW", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when":"inuse" + } + } + ] + } + } + ``` + +2. 创建悬浮窗。 + 通过`window.create`接å£åˆ›å»ºæ‚¬æµ®çª—类型的窗å£ã€‚ + +3. 对悬浮窗进行属性设置ç‰æ“作。 + 悬浮窗窗å£åˆ›å»ºæˆåŠŸåŽï¼Œå¯ä»¥æ”¹å˜å…¶å¤§å°ã€ä½ç½®ç‰ï¼Œè¿˜å¯ä»¥æ ¹æ®åº”用需è¦è®¾ç½®æ‚¬æµ®çª—背景色ã€äº®åº¦ç‰å±žæ€§ã€‚ + +4. åŠ è½½æ˜¾ç¤ºæ‚¬æµ®çª—çš„å…·ä½“å†…å®¹ã€‚ + 通过`loadContent`å’Œ`show`接å£åŠ 载显示悬浮窗的具体内容。 + +5. 销æ¯æ‚¬æµ®çª—。 + + 当ä¸å†éœ€è¦æ‚¬æµ®çª—时,å¯æ ¹æ®å…·ä½“实现逻辑,使用`destroy`接å£é”€æ¯æ‚¬æµ®çª—。 + + ```ts + import Ability from '@ohos.application.Ability' + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + import window from '@ohos.window'; + + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + // 2. 创建悬浮窗。 + var windowClass = null; + window.create(this.context, "floatWindow", window.WindowType.TYPE_FlOAT, (err, data) => { + if (err.code) { + console.error('Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in creating the floatWindow. Data: ' + JSON.stringify(data)); + windowClass = data; + // 3.悬浮窗窗å£åˆ›å»ºæˆåŠŸåŽï¼Œè®¾ç½®æ‚¬æµ®çª—çš„ä½ç½®ã€å¤§å°åŠç›¸å…³å±žæ€§ç‰ã€‚ + windowClass.moveTo(300, 300, (err, data) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }); + windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }); + // 4.ä¸ºæ‚¬æµ®çª—åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + windowClass.loadContent("pages/page4", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 4.显示悬浮窗。 + windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + //5.销æ¯æ‚¬æµ®çª—。当ä¸å†éœ€è¦æ‚¬æµ®çª—时,å¯æ ¹æ®å…·ä½“实现逻辑,使用destroy对其进行销æ¯ï¼Œæ¤å¤„以监å¬çª—å£åŒºåŸŸå¤–的点击事件为例实现悬浮窗的销æ¯ã€‚ + windowClass.on('touchOutside', () => { + console.info('touch outside'); + windowClass.destroy((err, data) => { + if (err.code) { + console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)); + }); + }); + }); + } + }; + ``` diff --git a/zh-cn/application-dev/windowmanager/display-guidelines.md b/zh-cn/application-dev/windowmanager/display-guidelines.md index 01840842a262aef9b62ebebb216cd6636569768c..ef1ef4abb5c15e2711eb69cab51658809efd037a 100644 --- a/zh-cn/application-dev/windowmanager/display-guidelines.md +++ b/zh-cn/application-dev/windowmanager/display-guidelines.md @@ -22,4 +22,7 @@ display.getDefaultDisplay().then((disp) => { console.log('display.getDefaultDisplay failed, error : ' + JSON.stringify(err)); }) ``` +## 相关实例 +针对å±å¹•å±žæ€§å¼€å‘,有以下相关实例å¯ä¾›å‚考: +- [`Screen`:å±å¹•å±žæ€§ï¼ˆeTS)(API8)](https://gitee.com/openharmony/app_samples/tree/master/device/Screen) diff --git a/zh-cn/application-dev/windowmanager/figures/windowMode.png b/zh-cn/application-dev/windowmanager/figures/windowMode.png new file mode 100644 index 0000000000000000000000000000000000000000..6d4b793d46343ff33efec41ce90c7418ba2fe779 Binary files /dev/null and b/zh-cn/application-dev/windowmanager/figures/windowMode.png differ diff --git a/zh-cn/application-dev/windowmanager/system-window-stage.md b/zh-cn/application-dev/windowmanager/system-window-stage.md new file mode 100644 index 0000000000000000000000000000000000000000..d602dad84a919ff9a0823616f5b808b6980e3008 --- /dev/null +++ b/zh-cn/application-dev/windowmanager/system-window-stage.md @@ -0,0 +1,112 @@ +# 管ç†ç³»ç»Ÿçª—å£ï¼ˆä»…Stage模型支æŒï¼‰ + +## 管ç†ç³»ç»Ÿçª—å£æ¦‚è¿° + +在`Stage`模型下, å…许系统应用创建和管ç†ç³»ç»Ÿçª—å£ï¼ŒåŒ…括音é‡æ¡ã€å£çº¸ã€é€šçŸ¥æ ã€çŠ¶æ€æ ã€å¯¼èˆªæ ç‰ã€‚具体支æŒçš„系统窗å£ç±»åž‹è§[APIå‚考-WindowType](../reference/apis/js-apis-window.md)。 + + +## 接å£è¯´æ˜Ž + +更多API说明请å‚è§[APIå‚考](../reference/apis/js-apis-window.md)。 + +| 实例å | 接å£å | æè¿° | +| -------- | -------- | -------- | +| windowé™æ€æ–¹æ³• | create(ctx:Context,id:string,type:WindowType,callback:AsyncCallback<Window>):void | 创建窗å£ã€‚<br/>-`ctx`:为应用上下文信æ¯ã€‚当`Context`为[ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md)时,创建系统窗å£ã€‚<br/>-`type`:为创建的窗å£ç±»åž‹ã€‚ | +| Window | resetSize(width:number,height:number,callback:AsyncCallback<void>):void | 改å˜å½“å‰çª—å£å¤§å°ã€‚ | +| Window | moveTo(x:number,y:number,callback:AsyncCallback<void>):void | 移动当å‰çª—å£ä½ç½®ã€‚ | +| Window | loadContent(path:string,callback:AsyncCallback<void>):void | 为当å‰çª—å£åŠ 载具体页é¢ã€‚ | +| Window | show(callback: AsyncCallback\<void>): void | 显示当å‰çª—å£ã€‚ | +| Window | on(type:'touchOutside',callback:Callback<void>):void | å¼€å¯æœ¬çª—å£åŒºåŸŸå¤–的点击事件的监å¬ã€‚ | +| Window | hide (callback: AsyncCallback\<void>): void | éšè—当å‰çª—å£ã€‚æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ | +| Window | destroy(callback: AsyncCallback<void>):void | 销æ¯å½“å‰çª—å£ã€‚ | + + +## å¼€å‘æ¥éª¤ + + +本文以音é‡æ¡çª—å£ä¸ºä¾‹ï¼Œä»‹ç»ç³»ç»Ÿçª—å£çš„基本开å‘和管ç†æ¥éª¤ã€‚ + + +1. 创建系统窗å£ã€‚ + + 在[ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md)下,使用`window.create`接å£åˆ›å»ºéŸ³é‡æ¡ç³»ç»Ÿçª—å£ã€‚ + +2. æ“作或设置系统窗å£çš„属性。 + + 系统窗å£åˆ›å»ºæˆåŠŸåŽï¼Œå¯ä»¥æ”¹å˜å…¶å¤§å°ã€ä½ç½®ç‰ï¼Œè¿˜å¯ä»¥æ ¹æ®éœ€è¦è®¾ç½®ç³»ç»Ÿçª—å£çš„背景色ã€äº®åº¦ç‰å±žæ€§ã€‚ + +3. åŠ è½½æ˜¾ç¤ºç³»ç»Ÿçª—å£çš„具体内容。 + + 通过`loadContent`å’Œ`show`接å£åŠ 载显示音é‡æ¡çª—å£çš„具体内容。 + +4. éšè—/销æ¯ç³»ç»Ÿçª—å£ã€‚ + + 当ä¸å†éœ€è¦éŸ³é‡æ¡çª—å£æ—¶ï¼Œå¯æ ¹æ®å…·ä½“实现逻辑,使用`hide`接å£æˆ–`destroy`接å£å¯¹å…¶è¿›è¡Œéšè—或销æ¯ã€‚ + +```ts +import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; +import window from '@ohos.window'; + +var windowClass = null; + +export default class ServiceExtensionAbility1 extends ExtensionContext { + onCreate(want) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + // 1.创建音é‡æ¡çª—å£ã€‚ + var windowClass = null; + window.create(this.context, "volume", window.WindowType.TYPE_VOLUME_OVERLAY, (err, data) => { + if (err.code) { + console.error('Failed to create the volume window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in creating the volume window.') + windowClass = data; + // 2.创建音é‡æ¡çª—å£æˆåŠŸä¹‹åŽï¼Œå¯ä»¥æ”¹å˜å…¶å¤§å°ã€ä½ç½®æˆ–设置背景色ã€äº®åº¦ç‰å±žæ€§ã€‚ + windowClass.moveTo(300, 300, (err, data) => { + if (err.code) { + console.error('Failed to move the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in moving the window. Data: ' + JSON.stringify(data)); + }); + windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { + console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in changing the window size. Data: ' + JSON.stringify(data)); + }); + // 3.为音é‡æ¡çª—å£åŠ è½½å¯¹åº”çš„ç›®æ ‡é¡µé¢ã€‚ + windowClass.loadContent("pages/page_volume", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)); + // 3.显示音é‡æ¡çª—å£ã€‚ + windowClass.show((err, data) => { + if (err.code) { + console.error('Failed to show the window. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)); + }); + }); + // 4.éšè—/销æ¯éŸ³é‡æ¡çª—å£ã€‚当ä¸å†éœ€è¦éŸ³é‡æ¡æ—¶ï¼Œå¯æ ¹æ®å…·ä½“实现逻辑,对其进行éšè—或销æ¯ã€‚ + // æ¤å¤„以监å¬éŸ³é‡æ¡åŒºåŸŸå¤–的点击事件为例实现音é‡æ¡çª—å£çš„éšè—。 + windowClass.on('touchOutside', () => { + console.info('touch outside'); + windowClass.hide((err, data) => { + if (err.code) { + console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in hidinging the window. Data: ' + JSON.stringify(data)); + }); + }); + }); + } +}; +``` + diff --git a/zh-cn/application-dev/windowmanager/window-guidelines.md b/zh-cn/application-dev/windowmanager/window-guidelines.md deleted file mode 100644 index 721edb94d5680828cc42457979dfd13e2a75d598..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/windowmanager/window-guidelines.md +++ /dev/null @@ -1,105 +0,0 @@ -# 窗å£å¼€å‘指导 - -## åœºæ™¯ä»‹ç» -窗å£çš„接å£å±‚在应用进程è¿è¡Œï¼Œè´Ÿè´£å¯¹é¡µé¢å¸ƒå±€çš„åŠ è½½ï¼Œå’Œæ供应用程åºæŽ¥å£ã€‚ -通过调用窗å£æŽ¥å£å¯ä»¥å®žçŽ°çª—å£åˆ›å»ºä¸Žé”€æ¯ï¼Œçª—å£çš„ä½ç½®ã€å¤§å°å¸ƒå±€ï¼Œä»¥åŠè¿›å…¥æ²‰æµ¸å¼ç‰ã€‚ - -## 接å£è¯´æ˜Ž -窗å£å¼€æ”¾çš„能力如下:Window类,具体的API详è§[接å£æ–‡æ¡£](../reference/apis/js-apis-window.md)。 - -**表1** 窗å£ä¸»è¦æŽ¥å£API - -| 接å£å | æè¿° | -| :----------------------------------------------------------- | :--------------------------------------------- | -| create(id: string, type: WindowType, callback: AsyncCallback\<Window>): void | 创建å窗å£ã€‚ | -| moveTo(x: number, y: number): Promise\<void> | 移动窗å£ä½ç½®ï¼Œx值为æ£è¡¨ç¤ºå³ç§»ï¼Œy为æ£è¡¨ç¤ºä¸‹ç§»ã€‚ | -| resetSize(width: number, height: number): Promise\<void> | 改å˜å½“å‰çª—å£å¤§å°ã€‚ | -| hide(): Promise\<void> | éšè—当å‰çª—å£ã€‚ | -| destroy(): Promise\<void> | 销æ¯å½“å‰çª—å£ã€‚ | - -## å¼€å‘æ¥éª¤ - -### åˆ›å»ºä¸»çª—å£ - -在当å‰æ¨¡åž‹ä¸‹ï¼Œåº”用å¯åŠ¨æ—¶ä¼šè‡ªåŠ¨åˆ›å»ºä¸»çª—å£ï¼Œç”±åº”用管ç†çª—å£çš„生命周期,éšè—åŠé”€æ¯ç”±åº”用管ç†ã€‚ -### 创建åçª—å£ -当å‰å¯ä»¥é€šè¿‡`create`接å£åˆ›å»ºå窗å£ã€‚具体示例代ç 如下: - -```js - import window from '@ohos.window'; - var windowClass = null; - let promise = window.create("subWindow", window.WindowType.TYPE_APP); - promise.then((data)=> { - windowClass = data; - console.info('SubWindow created. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); - }); -``` - -### 获å–窗å£å¯¹è±¡ - -- 应用内å¯ä»¥é€šè¿‡`getTopWindow`æ¥èŽ·å–当å‰åº”用内最åŽæ˜¾ç¤ºçš„窗å£ã€‚具体示例代ç 如下: - -```js - var windowClass = null; - let promise = window.getTopWindow(); - promise.then((data)=> { - windowClass = data; - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); - }) -``` - -- 应用内也å¯ä»¥é€šè¿‡`Find`æ¥èŽ·å–å·²ç»åˆ›å»ºçš„å窗å£ã€‚具体示例代ç 如下: - -```js - var windowClass = null; - let promise = window.find("subWindow"); - promise.then((data)=> { - windowClass = data; - console.info('window found. Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); - }); -``` - -### 窗å£çš„éšè—å’Œé”€æ¯ - -在已ç»èŽ·å–到窗å£å¯¹è±¡çš„å‰æ下,å¯ä»¥è°ƒç”¨`hide`ã€`destroy`æ¥éšè—和销æ¯å·²ç»åˆ›å»ºçš„窗å£å¯¹è±¡ã€‚具体示例代ç 如下: - -```js - let promise = windowClass.hide(); - promise.then((data)=> { - console.info('window hidden. Data: ' + JSON.stringify(data)) - windowClass.destroy((err, data) => { - if (err.code) { - console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); - return; - } - console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) - }) - }).catch((err)=>{ - console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); - }) -``` - -### 设置沉浸å¼çª—å£ - -在已ç»èŽ·å–到应用窗å£å¯¹è±¡çš„å‰æ下,调用`setFullScreen`æ¥è®¾ç½®çª—å£è¿›å…¥å…¨å±æ²‰æµ¸å¼ã€‚ - -示例代ç 如下: - -```js -import window from '@ohos.window'; -try { - const win = await window.getTopWindow() - await win.setFullScreen(true) -} catch (err) { - console.log(`setFullScreen fail, code = ${err.code}`) -} -``` - -完整[示例工程](https://gitee.com/openharmony/windowmanager/tree/master/AppDemo/window/immersive)。 - diff --git a/zh-cn/application-dev/windowmanager/window-overview.md b/zh-cn/application-dev/windowmanager/window-overview.md index 72f7a17f350a53dc5e56eb3203aa383c1263a306..f3e2ba39243ce42c7052249b967d9467550f8715 100644 --- a/zh-cn/application-dev/windowmanager/window-overview.md +++ b/zh-cn/application-dev/windowmanager/window-overview.md @@ -1,13 +1,75 @@ # 窗å£å¼€å‘概述 -**窗å£å系统**æ供窗å£ç®¡ç†çš„基础能力,是系统图形界é¢æ˜¾ç¤ºæ‰€éœ€çš„基础å系统。 -窗å£ç³»ç»Ÿçš„作用,是æ供一ç§æœºåˆ¶ï¼Œè®©å¤šä¸ªåº”用界é¢å¤ç”¨åŒä¸€å—物ç†å±å¹•è¿›è¡Œæ˜¾ç¤ºå’Œäº¤äº’。æ¯ä¸ªåº”用程åºä¸ï¼Œéœ€è¦å®žçŽ°å›ºå®šçª—å£åŒºåŸŸå†…的交互界é¢è®¾è®¡ï¼Œçª—å£ä½œç”¨åº”用界é¢çš„显示容器,而窗å£ç³»ç»Ÿè´Ÿè´£å°†è¿™äº›äº¤äº’ç•Œé¢ç»„织æˆæœ€ç»ˆç”¨æˆ·è§åˆ°çš„å½¢æ€ã€‚ + +## 窗å£æ¨¡å—的定义 + +窗å£æ¨¡å—用于在åŒä¸€å—物ç†å±å¹•ä¸Šï¼Œæ供多个应用界é¢æ˜¾ç¤ºã€äº¤äº’的机制。 + +- 对应用开å‘者而言,窗å£æ¨¡å—æ供了界é¢æ˜¾ç¤ºå’Œäº¤äº’能力。 + +- 对终端用户而言,窗å£æ¨¡å—æ供了控制应用界é¢çš„æ–¹å¼ã€‚ + +- 对整个æ“作系统而言,窗å£æ¨¡å—æ供了ä¸åŒåº”用界é¢çš„组织管ç†é€»è¾‘。 + + +## 窗å£æ¨¡å—的用途 + +在OpenHarmonyä¸ï¼Œçª—å£æ¨¡å—主è¦è´Ÿè´£ä»¥ä¸‹èŒè´£ï¼š + +- æ供应用和系统界é¢çš„窗å£å¯¹è±¡ã€‚应用开å‘者通过窗å£åŠ è½½UIç•Œé¢ï¼Œå®žçŽ°ç•Œé¢æ˜¾ç¤ºåŠŸèƒ½ã€‚ + +- 组织ä¸åŒçª—å£çš„显示关系,å³ç»´æŠ¤ä¸åŒçª—å£é—´çš„å åŠ å±‚æ¬¡å’Œä½ç½®å±žæ€§ã€‚应用和系统的窗å£å…·æœ‰å¤šç§ç±»åž‹ï¼Œä¸åŒç±»åž‹çš„窗å£å…·æœ‰ä¸åŒçš„默认ä½ç½®å’Œå åŠ å±‚æ¬¡ï¼ˆZ轴高度)。åŒæ—¶ï¼Œç”¨æˆ·æ“作也å¯ä»¥åœ¨ä¸€å®šèŒƒå›´å†…对窗å£çš„ä½ç½®å’Œå åŠ å±‚æ¬¡è¿›è¡Œè°ƒæ•´ã€‚ + +- æ供窗å£è£…饰。窗å£è£…饰指窗å£æ ‡é¢˜æ 和窗å£è¾¹æ¡†ã€‚窗å£æ ‡é¢˜æ 通常包括窗å£æœ€å¤§åŒ–ã€æœ€å°åŒ–åŠå…³é—按钮ç‰ç•Œé¢å…ƒç´ ,具有默认的点击行为,方便用户进行æ“作;窗å£è¾¹æ¡†åˆ™æ–¹ä¾¿ç”¨æˆ·å¯¹çª—å£è¿›è¡Œæ‹–拽缩放ç‰è¡Œä¸ºã€‚窗å£è£…饰是系统的默认行为,开å‘者å¯é€‰æ‹©å¯ç”¨/ç¦ç”¨ï¼Œæ— 需关注UI代ç 层é¢çš„实现。 + +- æ供窗å£åŠ¨æ•ˆã€‚在窗å£æ˜¾ç¤ºã€éšè—åŠçª—å£é—´åˆ‡æ¢æ—¶ï¼Œçª—å£æ¨¡å—é€šå¸¸ä¼šæ·»åŠ åŠ¨ç”»æ•ˆæžœï¼Œä»¥ä½¿å„ä¸ªäº¤äº’è¿‡ç¨‹æ›´åŠ è¿žè´¯æµç•…。在OpenHarmonyä¸ï¼Œåº”用窗å£çš„动效为默认行为,ä¸éœ€è¦å¼€å‘者进行设置或者修改。 + +- 指导输入事件分å‘。å³æ ¹æ®å½“å‰çª—å£çš„状æ€æˆ–焦点,进行事件的分å‘ã€‚è§¦æ‘¸å’Œé¼ æ ‡äº‹ä»¶æ ¹æ®çª—å£çš„ä½ç½®å’Œå°ºå¯¸è¿›è¡Œåˆ†å‘,而键盘事件会被分å‘至焦点窗å£ã€‚应用开å‘者å¯ä»¥é€šè¿‡çª—å£æ¨¡å—æ供的接å£è®¾ç½®çª—å£æ˜¯å¦å¯ä»¥è§¦æ‘¸å’Œæ˜¯å¦å¯ä»¥èŽ·ç„¦ã€‚ + ## 基本概念 -**沉浸å¼**:应用窗å£è·ŸçŠ¶æ€æ 与导航æ 颜色一致,视觉上èžåˆã€‚ +### 窗å£ç±»åž‹ + +OpenHarmony的窗å£æ¨¡å—将窗å£ç•Œé¢åˆ†ä¸ºç³»ç»Ÿçª—å£ã€åº”用窗å£ä¸¤ç§åŸºæœ¬ç±»åž‹ã€‚ + +- ç³»ç»Ÿçª—å£ + 系统窗å£æŒ‡å®Œæˆç³»ç»Ÿç‰¹å®šåŠŸèƒ½çš„窗å£ã€‚如音é‡æ¡ã€å£çº¸ã€é€šçŸ¥æ ã€çŠ¶æ€æ ã€å¯¼èˆªæ ç‰ã€‚ + +- åº”ç”¨çª—å£ + 应用窗å£åŒºåˆ«äºŽç³»ç»Ÿçª—å£ï¼ŒæŒ‡ä¸Žåº”用显示相关的窗å£ã€‚æ ¹æ®æ˜¾ç¤ºå†…容的ä¸åŒï¼Œåº”用窗å£åˆåˆ†ä¸ºåº”用主窗å£ã€åº”用å窗å£ä¸¤ç§ç±»åž‹ã€‚ + + - åº”ç”¨ä¸»çª—å£ + 应用主窗å£ç”¨äºŽæ˜¾ç¤ºåº”用界é¢ï¼Œä¼šåœ¨"任务管ç†ç•Œé¢"显示。 + - 应用åçª—å£ + 应用å窗å£ç”¨äºŽæ˜¾ç¤ºåº”用的弹窗ã€æ‚¬æµ®çª—ç‰è¾…助窗å£ï¼Œä¸ä¼šåœ¨"任务管ç†ç•Œé¢"显示。 + + +### 应用窗å£æ¨¡å¼ + +应用窗å£æ¨¡å¼æŒ‡åº”用主窗å£å¯åŠ¨æ—¶çš„显示方å¼ã€‚OpenHarmonyç›®å‰æ”¯æŒå…¨å±ã€åˆ†å±ã€è‡ªç”±çª—å£ä¸‰ç§åº”用窗å£æ¨¡å¼ã€‚è¿™ç§å¯¹å¤šç§åº”用窗å£æ¨¡å¼çš„支æŒèƒ½åŠ›ï¼Œä¹Ÿç§°ä¸ºæ“作系统的“多窗å£èƒ½åŠ›â€ã€‚ + + +- å…¨å±ï¼šåº”用主窗å£å¯åŠ¨æ—¶é“ºæ»¡æ•´ä¸ªå±å¹•ã€‚ + +- 分å±ï¼šåº”用主窗å£å¯åŠ¨æ—¶å æ®å±å¹•çš„æŸä¸ªéƒ¨åˆ†ï¼Œå½“å‰æ”¯æŒäºŒåˆ†å±ã€‚两个分å±çª—å£ä¹‹é—´å…·æœ‰åˆ†ç•Œçº¿ï¼Œå¯é€šè¿‡æ‹–拽分界线调整两个部分的窗å£å°ºå¯¸ã€‚ + +- 自由窗å£ï¼šè‡ªç”±çª—å£çš„大å°å’Œä½ç½®å¯è‡ªç”±æ”¹å˜ã€‚åŒä¸€ä¸ªå±å¹•ä¸Šå¯åŒæ—¶æ˜¾ç¤ºå¤šä¸ªè‡ªç”±çª—å£ï¼Œè¿™äº›è‡ªç”±çª—å£æŒ‰ç…§æ‰“开或者获å–焦点的顺åºåœ¨Z轴排布。当自由窗å£è¢«ç‚¹å‡»æˆ–触摸时,将导致其Z轴高度æå‡ï¼Œå¹¶èŽ·å–焦点。 + + + + + +## å®žçŽ°åŽŸç† + +当å‰çª—å£çš„实现和开å‘与应用开å‘模型相关è”,ä¸åŒæ¨¡åž‹ä¸‹çš„接å£åŠŸèƒ½ç•¥æœ‰åŒºåˆ«ã€‚当å‰åº”用开å‘模型分为FA模型和Stage模型。 + +两个模型的整体架构和设计æ€æƒ³ï¼Œè¯¦è§[FA模型综述](../ability/fa-brief.md)å’Œ[Stage模型综述](../ability/stage-brief.md)。 + +针对窗å£å¼€å‘,推è使用Stage模型进行相关开å‘。 + -## è¿ä½œæœºåˆ¶ +## 约æŸä¸Žé™åˆ¶ -为了将图形界é¢æ˜¾ç¤ºåœ¨å±å¹•ä¸Šï¼Œåº”用和系统需è¦å‘窗å£ç³»ç»Ÿç”³è¯·çª—å£å¯¹è±¡ï¼Œè¿™é€šå¸¸ä»£è¡¨äº†å±å¹•ä¸Šä¸€å—矩形区域,具有ä½ç½®ã€å®½é«˜ã€å’Œå åŠ å±‚æ¬¡ç‰å±žæ€§ã€‚åŒæ—¶ï¼Œçª—å£å¯¹è±¡ä¹Ÿè´Ÿè´£åŠ 载界é¢ä¸UIæ¡†æž¶çš„æ ¹èŠ‚ç‚¹ï¼Œåº”ç”¨ç¨‹åºçš„UIç•Œé¢å°±é€šè¿‡è¿™ä¸ªæ ¹èŠ‚点在窗å£ä¸åŠ 载显示。 \ No newline at end of file +在FA模型下,ä¸æ”¯æŒç³»ç»Ÿçª—å£çš„相关开å‘。 diff --git a/zh-cn/contribute/style-guide/style-guide-content-elements.md b/zh-cn/contribute/style-guide/style-guide-content-elements.md index 9c37acd761509c61be5f8d0db3dc1002b7429fdc..b984629d236de6c4015dd4b7769077b4a6842011 100755 --- a/zh-cn/contribute/style-guide/style-guide-content-elements.md +++ b/zh-cn/contribute/style-guide/style-guide-content-elements.md @@ -144,11 +144,11 @@ ã€è§„则】将链接URL写入内容,而ä¸æ˜¯ç›´æŽ¥åœ¨é¡µé¢ä¸æš´éœ²URL地å€ã€‚ -- 链接到其他手册ã€é¡µé¢å†…容:\[术è¯](glossary/glossary.md) +- 链接到其他手册ã€é¡µé¢å†…容:\[术è¯]\(glossary/glossary.md) -- 链接到本页é¢å†…其他内容段è½ï¼š\[FAQ](#faq) +- 链接到本页é¢å†…其他内容段è½ï¼š\[FAQ]\(#faq) -- 链接到其他站点:\[示例](www.example.com) +- 链接到其他站点:\[示例]\(www.example.com) | **æ£ä¾‹** | **å例** | | -------- | -------- | diff --git a/zh-cn/contribute/template/guide-template.md b/zh-cn/contribute/template/guide-template.md index 9e6581f02f345229e04e5e36a870581171e522b8..fefe1359814200857ff975c45e75bde193658251 100644 --- a/zh-cn/contribute/template/guide-template.md +++ b/zh-cn/contribute/template/guide-template.md @@ -2,18 +2,19 @@ > **注æ„:** -> _1ã€æœ¬æ¨¡æ¿æ供推èçš„å¼€å‘指å—文档框架ã€å…¸åž‹çŸ¥è¯†ç‚¹å†™ä½œè¦æ±‚åŠå†™ä½œæŒ‡å¯¼ã€‚实际写作ä¸ï¼Œåº”视具体__方案/特性/功能/模å—__情况,先完æˆå¼€å‘者任务场景分æžä¸Žå¼€å‘指å—大纲设计,然åŽå‚照本模æ¿å†™ä½œå…·ä½“内容。_ > -> _2ã€æ–‡æ¡£å†™ä½œæ—¶ï¼Œä¸¤çº§æ ‡é¢˜ä¹‹é—´çš„ä½ç½®ä¸å…è®¸æ·»åŠ å†…å®¹ã€‚_ +> _1ã€æœ¬æ¨¡æ¿æ供推èçš„å¼€å‘指å—文档框架ã€å…¸åž‹çŸ¥è¯†ç‚¹å†™ä½œè¦æ±‚åŠå†™ä½œæŒ‡å¯¼ã€‚实际写作ä¸ï¼Œåº”视具体**方案/特性/功能/模å—**情况,先完æˆå¼€å‘者任务场景分æžä¸Žå¼€å‘指å—大纲设计,然åŽå‚照本模æ¿å†™ä½œå…·ä½“内容。_ +> +> _2ã€æ–‡æ¡£å†™ä½œæ—¶ï¼Œä¸€çº§æ ‡é¢˜ä¸ŽäºŒçº§æ ‡é¢˜ä¹‹é—´çš„ä½ç½®ä¸å…è®¸æ·»åŠ å†…å®¹ã€‚_ > > _3ã€æ‰€æœ‰æ–œä½“为写作指导,æ£å¼æ–‡æ¡£ä¸æ³¨æ„å…¨éƒ¨åˆ é™¤ã€‚_ ## xxx概述 -_å¿…é€‰ã€‚æ ¹æ®å…·ä½“__方案/特性/功能/模å—__的场景划分情况,æ¤å¤„的“xxx概述â€ä¸Žå…·ä½“任务场景下的“任务场景n概述â€æŒ‰éœ€æ供一处或共å˜ï¼Œå…·ä½“的:_ +_å¿…é€‰ã€‚æ ¹æ®å…·ä½“**方案/特性/功能/模å—**情况的场景划分情况,æ¤å¤„的“xxx概述â€ä¸Žå…·ä½“任务场景下的“任务场景n概述â€æŒ‰éœ€æ供一处或共å˜ï¼Œå…·ä½“的:_ -_1ã€æ¤å¤„的“xxx概述â€":用于承载开å‘者需è¦äº†è§£çš„ã€æœ¬ç‰¹æ€§å„ä»»åŠ¡åœºæ™¯é€šç”¨çš„æ¦‚è¿°å†…å®¹ã€‚å¦‚æ— ï¼Œåˆ™åˆ é™¤ã€‚_ +_1ã€æ¤å¤„的“xxx概述â€ï¼šç”¨äºŽæ‰¿è½½å¼€å‘者需è¦äº†è§£çš„ã€æœ¬ç‰¹æ€§å„ä»»åŠ¡åœºæ™¯é€šç”¨çš„æ¦‚è¿°å†…å®¹ã€‚å¦‚æ— ï¼Œåˆ™åˆ é™¤ã€‚_ _2ã€â€œä»»åŠ¡åœºæ™¯n概述â€ï¼šç”¨äºŽæ‰¿è½½ä»»åŠ¡åœºæ™¯n直接相关的概述内容,知识点构æˆåŠå†™ä½œè¦ç‚¹ä¸Žâ€œxxx概述â€ç›¸åŒï¼ŒåŒ…括任务场景n简介ã€ä»»åŠ¡åœºæ™¯n直接相关的基本概念ã€ä»»åŠ¡åœºæ™¯n直接相关的实现原ç†ã€ä»»åŠ¡åœºæ™¯n直接相关的约æŸä¸Žé™åˆ¶ã€ä»»åŠ¡åœºæ™¯nç›´æŽ¥ç›¸å…³çš„ç›¸å…³å®žä¾‹ã€‚å¦‚æ— ï¼Œåˆ™åˆ é™¤ã€‚_ @@ -21,11 +22,11 @@ _2ã€â€œä»»åŠ¡åœºæ™¯n概述â€ï¼šç”¨äºŽæ‰¿è½½ä»»åŠ¡åœºæ™¯n直接相关的概述 **_1ã€ç›®æ ‡å¯¹è±¡ï¼š_**_é¢å‘内ã€å¤–部开å‘者(å«äº§å“ç»ç†ã€å¼€å‘人员)。é¢å‘UX设计师的指导文档通常由专门的UX设计规范承载,ä¸åœ¨å¼€å‘指å—范畴。本文如需æåŠï¼Œä»¥è¶…链接方å¼æŒ‡å‘对应UX规范å³å¯ã€‚_ -_**2ã€å†…容定ä½ï¼š**介ç»__方案/特性/功能/模å—__是什么(What)ã€èƒ½åšä»€ä¹ˆï¼ˆWhy),以åŠå¦‚何进行相关应用程åº/设备的设计ã€å¼€å‘ã€å‘布上架(How)。支撑开å‘者å¦ä¹ å¿…è¦çŸ¥è¯†ï¼Œæœ€ç»ˆåœ¨å®žé™…å¼€å‘活动ä¸å®Œæˆæ—¢å®šä»»åŠ¡ç›®æ ‡ã€‚_ +**_2ã€å†…容定ä½ï¼š_**_介ç»**方案/特性/功能/模å—**是什么(What)ã€èƒ½åšä»€ä¹ˆï¼ˆWhy),以åŠå¦‚何进行相关应用程åº/设备的设计ã€å¼€å‘ã€å‘布上架(How)。支撑开å‘者å¦ä¹ å¿…è¦çŸ¥è¯†ï¼Œæœ€ç»ˆåœ¨å®žé™…å¼€å‘活动ä¸å®Œæˆæ—¢å®šä»»åŠ¡ç›®æ ‡ã€‚_ -_**3ã€ç”¨æˆ·è§†è§’:**å˜èº«å¼€å‘者,始终以开å‘者视角,æ供开å‘者关注的ã€å¯æ„ŸçŸ¥å’Œä½¿ç”¨çš„内容。_ +**_3ã€ç”¨æˆ·è§†è§’:_**_å˜èº«å¼€å‘者,始终以开å‘者视角,æ供开å‘者关注的ã€å¯æ„ŸçŸ¥å’Œä½¿ç”¨çš„内容。_ -_**4ã€é¢å‘任务:**èšç„¦å¼€å‘者实际任务,完整ã€æ£ç¡®ã€æ˜“用,具备æƒå¨æŒ‡å¯¼æ€§ã€‚_ +**_4ã€é¢å‘任务:_**_èšç„¦å¼€å‘者实际任务,完整ã€æ£ç¡®ã€æ˜“用,具备æƒå¨æŒ‡å¯¼æ€§ã€‚_ _5ã€ä¸è¦å—é™ï¼šæ¨¡æ¿åªæ˜¯åŸºç¡€æ¡†æž¶ï¼Œä¸è¦åƒµåŒ–。_ @@ -40,7 +41,7 @@ _这个方案/特性/功能/模å—是什么(定义-whatï¼‰ï¼Ÿæˆ‘ä¸ºä»€ä¹ˆè¦ _**ã€å†™ä½œè¦ç‚¹ã€‘**_ -- _æ供易ç†è§£çš„场景化æ述。__å¯å‚考如下SCQAæ–¹å¼ä»‹ç»æ–¹æ¡ˆ/特性/功能/模å—客户é¢çš„功能场景ã€ç‰¹ç‚¹ã€‚_ +- _æ供易ç†è§£çš„场景化æ述。_ _å¯å‚考如下SCQAæ–¹å¼ä»‹ç»æ–¹æ¡ˆ/特性/功能/模å—客户é¢çš„功能场景ã€ç‰¹ç‚¹ã€‚_ - _S:situation(情景),由大家都熟悉的的情景ã€äº‹å®žå¼•å…¥ã€‚_ - _C:complication(冲çªï¼‰ï¼Œä½†æ˜¯å®žé™…情况往往和我们的è¦æ±‚有冲çªã€‚_ - _Q:question(疑问),怎么办?_ @@ -71,7 +72,7 @@ _è¦ä½¿ç”¨è¯¥æ–¹æ¡ˆ/特性/功能/模å—,有哪些独有概念是我需è¦äº† - _è¿ä½œæœºåˆ¶ã€çº¦æŸé™åˆ¶ã€å¼€å‘过程ç‰å¤šä¸ªç« 节相关的概念在æ¤ä»‹ç»ï¼Œä»…æŸä¸ªç« èŠ‚ç”¨åˆ°çš„æ¦‚å¿µåœ¨å¯¹åº”ç« èŠ‚ä¸ä»‹ç»ã€‚_ -- _业界通用的概念ä¸ç”¨åœ¨æ¤èµ˜è¿°ã€‚__注æ„使用业界通用术è¯æ¥è¡¨è¾¾ï¼Œä¸ç”¨åŽä¸ºç ”å‘内部è¯è¨€ã€‚_ +- _业界通用的概念ä¸ç”¨åœ¨æ¤èµ˜è¿°ã€‚_ _注æ„使用业界通用术è¯æ¥è¡¨è¾¾ï¼Œä¸ç”¨åŽä¸ºç ”å‘内部è¯è¨€ã€‚_ - _概念之间如有逻辑关系,推è使用图形æ述。_ @@ -141,7 +142,7 @@ _å¯é€‰ã€‚æ¤å¤„放置以下å„任务场景通用的约æŸä¸Žé™åˆ¶ã€‚_ _**ã€å¼€å‘者关注点】**_ -_我è¦__使用该方案/特性/功能/模å—,有什么约æŸæ¡ä»¶å—?__该方案/特性/功能/模å—__实现的程度如何,能满足我的需求å—?_ +_我è¦ä½¿ç”¨è¯¥æ–¹æ¡ˆ/特性/功能/模å—,有什么约æŸæ¡ä»¶å—?该方案/特性/功能/模å—实现的程度如何,能满足我的需求å—?_ **_ã€å†™ä½œè¦ç‚¹ã€‘_** @@ -174,7 +175,7 @@ _有哪些Sample codeã€Codelabsã€Demo工程å¯ä¾›å¦ä¹ ã€å‚考。_ **_ã€å†™ä½œè¦ç‚¹ã€‘_** -_å·²å‘布的Sample codeã€Codelabsã€Demo工程包,请在æ¤å¤„æ供链接(一般为Gitee链接)。__注æ„:ä¸å…许将工程包ç‰ä½œä¸ºé™„件æ’入到文档ä¸ã€‚_ +_å·²å‘布的Sample codeã€Codelabsã€Demo工程包,请在æ¤å¤„æ供链接(一般为Gitee链接)。_ _注æ„:ä¸å…许将工程包ç‰ä½œä¸ºé™„件æ’入到文档ä¸ã€‚_ **ã€å†™ä½œæ ·ä¾‹ã€‘** @@ -189,7 +190,7 @@ _å¯é€‰ã€‚_ _æ ¹æ®å…·ä½“çš„å¼€å‘场景分æžåˆ†è§£æƒ…况,本节内容å¯æŒ‰éœ€æ”¾å…¥â€œå¼€å‘指导â€ä¸‹ï¼Œä½œä¸ºâ€œå‰ææ¡ä»¶â€æˆ–“开å‘准备â€ä¸Žå…·ä½“场景的“开å‘æ¥éª¤â€å°±è¿‘放置。_ -_明确如何准备开å‘环境(如软硬件é…ç½®è¦æ±‚ã€å·¥å…·è¦æ±‚ã€è®¾å¤‡è¦æ±‚ç‰ï¼‰__。_ +_明确如何准备开å‘环境(如软硬件é…ç½®è¦æ±‚ã€å·¥å…·è¦æ±‚ã€è®¾å¤‡è¦æ±‚ç‰ï¼‰ã€‚_ _如果ä¸æ¶‰åŠä¸Šè¿°ç‰¹æ®Šè¦æ±‚,æ¤ç« èŠ‚åˆ é™¤ã€‚_ @@ -256,7 +257,7 @@ _è´´è¿‘å¼€å‘者实际开å‘场景:_ - _å¼€å‘者需è¦é€šè¿‡å“ªäº›ä»»åŠ¡æ¥è¾¾æˆå¼€å‘ç›®æ ‡ï¼Œè¿™å°±æ˜¯ä»»åŠ¡åœºæ™¯ã€‚_ -- _任务场景å¯ä»¥æœ‰1个或多个,__å¯æŒ‰éœ€æ·»åŠ 多个“开å‘指导â€ç« 节。__åŒæ—¶è¦éµå¾ªåˆ†å±‚分级逻辑,å³å¤§åœºæ™¯ï¼ˆä»»åŠ¡åœºæ™¯n)->å°åœºæ™¯ï¼ˆå任务场景n-x)->任务逻辑(对应“开å‘æµç¨‹â€ï¼‰->æ“作æ¥éª¤ï¼ˆä¸€ä¸ªä¸ªstep)。_ +- _任务场景å¯ä»¥æœ‰1个或多个,å¯æŒ‰éœ€æ·»åŠ 多个“开å‘指导â€ç« 节。åŒæ—¶è¦éµå¾ªåˆ†å±‚分级逻辑,å³å¤§åœºæ™¯ï¼ˆä»»åŠ¡åœºæ™¯n)->å°åœºæ™¯ï¼ˆå任务场景n-x)->任务逻辑(对应“开å‘æµç¨‹â€ï¼‰->æ“作æ¥éª¤ï¼ˆä¸€ä¸ªä¸ªstep)。_ ### 任务场景n概述 @@ -380,9 +381,8 @@ _æè¿°å¼€å‘过程é‡åˆ°çš„å„类问题以åŠè§£å†³æ–¹æ¡ˆï¼Œä»¥æ高开å‘效 - _å¦‚æžœæ— å¸¸è§é—®é¢˜ï¼Œåˆ 除æ¤ç« 节。_ -- _如果有常è§é—®é¢˜ï¼Œå»ºè®®å•ç‹¬ç« 节,åŽç»å…·å¤‡æ‰©å±•æ€§ã€‚_ +- _å„任务场景通用的常è§é—®é¢˜ï¼Œå»ºè®®ä»¥å•ç‹¬ç« 节呈现;å•ä¸ªä»»åŠ¡åœºæ™¯ç›¸å…³çš„常è§é—®é¢˜ï¼Œæ”¾åœ¨å¯¹åº”ä»»åŠ¡åœºæ™¯çš„ç« èŠ‚ä¸‹å³å¯ã€‚_ -- _如果有常è§é—®é¢˜ï¼Œé—®é¢˜å°‘于1å±ä¸”未æ¥æ‰©å……å¯èƒ½æ€§ä¸å¤§ï¼Œå¯æ”¾åœ¨â€œå¼€å‘指导â€ã€‚_ ### 1.XX问题(简å•é—®é¢˜ï¼‰ diff --git a/zh-cn/contribute/template/js-template.md b/zh-cn/contribute/template/js-template.md index ccb96104956321a6a1ecefb76aa7cdbd02c6044d..5a38bc05af08e7d08ff96938d3ee4f4567f63a83 100644 --- a/zh-cn/contribute/template/js-template.md +++ b/zh-cn/contribute/template/js-template.md @@ -74,7 +74,7 @@ ArrayListå’ŒLinkedList相比,ArrayListçš„éšæœºè®¿é—®æ•ˆçŽ‡æ›´é«˜ã€‚但由于A > 1. æ ¹æ®å®žé™…情况填写导入模å—。采用代ç æ®µçš„æ ·å¼ï¼Œç»™å‡ºimportè¯å¥ã€‚ > > 2. 如果没有导入模å—,将“导入模å—â€ä¿®æ”¹ä¸ºâ€œä½¿ç”¨è¯´æ˜Žâ€ã€‚<br/>使用说明案例:<br/> -> 在使用AbilityContext的功能å‰ï¼Œéœ€è¦é€šè¿‡[getContext()](链接到对应的接å£è¯´æ˜Žæ–‡ä»¶ä¸.md)先获å–Context对象。 +> 在使用AbilityContext的功能å‰ï¼Œéœ€è¦é€šè¿‡\[getContext()]\(链接到对应的接å£è¯´æ˜Žæ–‡ä»¶ä¸.md)先获å–Context对象。 > > ```js > import ability_featureAbility from '@ohos.ability.featureAbility'; diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" index dfcd8a51758adb85cfabaf70b1adc26025f77b68..a5a9bd99d8f20247f68efa03b5e067ee65f2f76c 100755 --- "a/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" +++ "b/zh-cn/contribute/\350\264\241\347\214\256\346\226\207\346\241\243.md" @@ -63,8 +63,8 @@ 鼓励开å‘者在å¦ä¹ ã€å¼€å‘过程ä¸ï¼Œæ€»ç»“ç»éªŒå¹¶åˆ›å»ºæŠ€æœ¯å†…容帮助更多开å‘者快速上手。推è输出å„ç±»How to教程ã€å¸¸è§é—®é¢˜FAQç‰ã€‚请å‚考如下写作模æ¿ï¼š -- [How to教程](template/tutorial-template.md):贡献至`contribute/tutorial`文件夹下。 -- [FAQ](template/faq-template.md):贡献至`contribute/faqs`文件夹下。 +- [How to教程](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/template/tutorial-template.md):贡献至`contribute/tutorial`文件夹下。 +- [FAQ](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/template/faq-template.md):贡献至`contribute/faqs`文件夹下。 内容写作模æ¿å½’档在Docs文档仓下contribute文件夹ä¸ã€‚ diff --git a/zh-cn/design/figures/API-Category.png b/zh-cn/design/figures/API-Category.png index 22813ba83cd97c5017cb79b468bdcc416886022a..263d76da6de621a7e2a4ad23fbb907426b334dce 100644 Binary files a/zh-cn/design/figures/API-Category.png and b/zh-cn/design/figures/API-Category.png differ diff --git a/zh-cn/design/hdi-design-specifications.md b/zh-cn/design/hdi-design-specifications.md index a6f410f136870ef1b954c67f640789abbdb96c4c..036d191fa13983763271425d39187296306c39b4 100644 --- a/zh-cn/design/hdi-design-specifications.md +++ b/zh-cn/design/hdi-design-specifications.md @@ -24,6 +24,7 @@ | 版本 | å˜æ›´è¯´æ˜Ž | | --- | --------------------- | | v1.0 Beta | åˆå§‹è¯•è¡Œç‰ˆæœ¬ | +| v1.0 | å‘布æ£å¼ç‰ˆæœ¬ | ## 范围与定义 @@ -60,7 +61,7 @@ interface IVibrator { 当对原有接å£è¿›è¡Œä¸ç ´åå‘åŽå…¼å®¹çš„修改时,如在最åŽè¿½åŠ 新增接å£ã€æ–°å¢žæžšä¸¾å®šä¹‰ã€ä¿®æ”¹å˜é‡å称ç‰ï¼Œåªéœ€è¦å¢žåŠ `minor`版本å·ï¼Œæ–°çš„包å为`ohos.hdi.vibrator.v1_1`。如: ```cpp -package ohos.hdi.vibrator.v1_0; +package ohos.hdi.vibrator.v1_1; interface IVibrator { ... SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int freq); @@ -71,7 +72,7 @@ interface IVibrator { 如果对原有接å£è¿›è¡Œæ›´åã€ä¿®æ”¹å˜é‡åˆ—表ç‰ä¸å‘åŽå…¼å®¹ä¿®æ”¹æ—¶ï¼Œéœ€è¦å¢žåŠ `major`版本å·ï¼Œæ–°çš„包å为`ohos.hdi.vibrator.v2_0`。如: ```cpp -package ohos.hdi.vibrator.v1_0; +package ohos.hdi.vibrator.v2_0; interface IVibrator { ... SetModulationParameter([in] unsigned int vibrationPeriod, [in] int intensity, [in] int frequency, [int] time); @@ -85,13 +86,13 @@ interface IVibrator { Table 1 接å£è¯„审&管控角色 -| **涉åŠè§’色** | **APIæ²»ç†ä¸çš„èŒè´£** | +| **涉åŠè§’色** | **HDI接å£æ²»ç†ä¸çš„èŒè´£** | | ----------- | ------------------------------------------------ | -| Contributor | API的设计和交付主体,负责API相关的代ç 与设计文档æ交。 | -| Committer | API相关的代ç 评审,涉åŠAPIæ交预审。 | -| 领域SIG | 新增API相关的代ç æ交评审,领域SIG评审通过å³å¯åˆå…¥ã€‚<br>å˜æ›´API相关的代ç æ交预审。 | -| Driver SIG | å˜æ›´API相关的代ç æ交评审。 | -| PMC | API Version计划å‘布ã€APIæ²»ç†ç« 程修订评审å‘布ç‰ã€‚ | +| Contributor | HDI的设计和交付主体,负责HDI相关的代ç 与设计文档æ交。 | +| Committer | HDI相关的代ç 评审,涉åŠHDIæ交预审。 | +| 领域SIG | 新增/å˜æ›´HDI相关的代ç æ交,本领域SIG首先进行评审。 | +| Driver SIG | 新增/å˜æ›´HDI相关的代ç æ交评审。 | +| PMC | HDI设计规范修订评审å‘布ç‰ã€‚ | #### 设备接å£å‘布 @@ -101,8 +102,8 @@ Table 1 接å£è¯„审&管控角色 主è¦è¿‡ç¨‹è¯´æ˜Žï¼š - 1. HDI评审申请ã€ä»£ç æ交(Owner:Contributor),所有涉åŠHDI新增或å˜æ›´éœ€åŒæ¥æ交相应的API评审文档,详细说明API的需求æ¥æºã€åœºæ™¯ä¸Žä½¿ç”¨æ–¹æ³•ã€æƒé™è®¾è®¡ã€éšç§ä¿æŠ¤æ¾„清ç‰ï¼Œè¯¦è§åŽé¢çš„API评审申请è¦ç´ 。为é¿å…åŽç»çš„返工,Contributorå¯ä»¥åœ¨æ£å¼çš„API评审申请ã€ä»£ç æ交之å‰ï¼Œå…ˆé€šè¿‡é‚®ä»¶æ–¹å¼å°†API设计文档æ交Committerã€é¢†åŸŸSIGã€API SIGç‰ç›¸å…³äººå‘˜é¢„审。 - 2. 代ç 评审(Owner:Committer),代ç 评审和API预审,涉åŠAPIæ交Code Review通过åŽï¼Œè¿˜éœ€è¦è¿›ä¸€æ¥é¢†åŸŸSIG评审。 + 1. HDI评审申请ã€ä»£ç æ交(Owner:Contributor),所有涉åŠHDI新增或å˜æ›´éœ€åŒæ¥æ交相应的HDI评审文档,详细说明HDI的需求æ¥æºã€åœºæ™¯ä¸Žä½¿ç”¨æ–¹æ³•ã€æƒé™è®¾è®¡ã€éšç§ä¿æŠ¤æ¾„清ç‰ï¼Œè¯¦è§åŽé¢çš„评审申请è¦ç´ 。为é¿å…åŽç»çš„返工,Contributorå¯ä»¥åœ¨æ£å¼çš„HDI评审申请ã€ä»£ç æ交之å‰ï¼Œå…ˆé€šè¿‡é‚®ä»¶æ–¹å¼å°†HDI相关设计文档æ交Committerã€é¢†åŸŸSIGã€Driver SIGç‰ç›¸å…³äººå‘˜é¢„审。 + 2. 代ç 评审(Owner:Committer),代ç 评审和接å£é¢„审,涉åŠHDIçš„æ交Code Review通过åŽï¼Œè¿˜éœ€è¦è¿›ä¸€æ¥é¢†åŸŸSIG评审。 3. 领域SIG评审(Owner:领域SIG),涉åŠæ–°å¢ž/å˜æ›´HDI相关接å£çš„代ç æ交,领域SIG评审通过åŽï¼Œè¿˜éœ€è¦è¿›ä¸€æ¥æ交Driver SIG。 4. HDI评审(Owner:Driver SIG),对新增/å˜æ›´HDI相关的代ç æ交进行接å£è¯„审,评审通过å³å¯åˆå…¥ä»£ç 。 5. 评审完æˆã€‚ @@ -131,7 +132,7 @@ Table 1 接å£è¯„审&管控角色 - 对废弃接å£å¢žåŠ æ ‡è¯†åºŸå¼ƒæ ‡è®°ã€‚ - - 废弃API至少ä¿ç•™4个OpenHarmony API版本 + - 废弃HDI至少ä¿ç•™4个OpenHarmony API版本 ## 接å£è®¾è®¡çº¦æŸ @@ -484,7 +485,3 @@ GetExecutorInfo([out] struct ExecutorInfo executorInfo); | ------- | ------- | ------ | | struct | struct | struct | | enum | enum | enum | - - -## 其他说明 -本文档Beta期为自å‘布日起1个月,用于接纳社区æ„è§ï¼Œæ¬¢è¿Žç§¯æžå‚与讨论。 \ No newline at end of file diff --git a/zh-cn/device-dev/dev-board-on-the-master.md b/zh-cn/device-dev/dev-board-on-the-master.md index dff638dceb0bc12dc4a22294dbe645606083a2b1..20237f39f24e9563bbe0210a2a23b5b9af766d4a 100644 --- a/zh-cn/device-dev/dev-board-on-the-master.md +++ b/zh-cn/device-dev/dev-board-on-the-master.md @@ -5,32 +5,32 @@ ## æ ‡å‡†ç³»ç»Ÿå¼€å‘æ¿ -| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ› | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | +| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ›åŠé€‚é…案例 | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | | ---------- | -------- | -------- | ------------ | -------------------------------------- | -|润和HH-SCDAYU200| RK3568 |润和HH-SCDAYU200å¼€å‘æ¿åŸºäºŽRockchip RK3568å¹³å°ï¼Œé›†æˆåŒæ ¸æž¶æž„GPU以åŠé«˜æ•ˆèƒ½NPUï¼Œå››æ ¸64ä½Cortex-A55 处ç†å™¨é‡‡ç”¨22nm工艺,主频高达2.0GHz;支æŒè“牙ã€Wi-Fiã€éŸ³é¢‘ã€è§†é¢‘和摄åƒå¤´ç‰åŠŸèƒ½ï¼Œæ‹¥æœ‰ä¸°å¯Œçš„扩展接å£ï¼Œæ”¯æŒå¤šç§è§†é¢‘输入输出接å£ï¼Œé…ç½®åŒåƒå…†è‡ªé€‚应RJ45以太网å£ï¼Œå¯æ»¡è¶³NVRã€å·¥ä¸šç½‘å…³ç‰å¤šç½‘å£äº§å“需求。|影音娱ä¹ã€æ™ºæ…§å‡ºè¡Œã€æ™ºèƒ½å®¶å±…,如烟机ã€çƒ¤ç®±ã€è·‘æ¥æœºç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | -|Hispark_Phoenix|Hi3751V351|å…¨çƒåˆ¶å¼FHD(全高清)智能电视主处ç†èŠ¯ç‰‡ï¼Œå†…ç½®é«˜æ€§èƒ½å¤šæ ¸ ARM A53 CPUï¼Œå¤šæ ¸MALI T450 GPU,支æŒNTSC/PAL/SECAM制å¼è§£è°ƒï¼Œæ”¯æŒDTMB/DVB-C/ATSC/ISDB-Tç‰å…¨çƒæ•°å—Demod,å¯ä»¥æ‰©å±•DVB-T/T2/S/S2,支æŒUSBæ’放,支æŒä¸»æµçš„è§†é¢‘æ ¼å¼åŒ…括MPEG2ã€H.264ã€H.265ã€RMVBã€AVS+ç‰ï¼Œæ”¯æŒä¸»æµéŸ³é¢‘解ç åŠéŸ³æ•ˆå¤„ç†ï¼Œä»¥åŠæµ·æ€è‡ªç ”çš„SWS音效处ç†ï¼Œæ”¯æŒCVBS/YPbPr/VGA/HDMI 1.4/USB接å£ï¼Œå†…ç½®1GB DDR,支æŒLVDSå’ŒminiLVDS接å£ï¼Œæ”¯æŒä¸»æµçš„Tconlesså±ã€‚|智能电视ã€æ™ºèƒ½å®¶å±…ä¸æŽ§å±ã€æ™ºèƒ½æ˜¾ç¤ºå™¨ã€å•†æ˜¾å¹¿å‘Šå±ã€äº¤äº’白æ¿ã€å·¥ä¸šæŽ§åˆ¶å±ã€æ‰“å°æœºå±ã€ç™½ç”µå±ã€å¥èº«å™¨æ˜¾ç¤ºå±ç‰ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|Unionpi Tiger|Amlogic A311D|Unionpi Tiger是一款应用于图åƒå¤„ç†ï¼ŒéŸ³è§†é¢‘处ç†å’Œæ·±åº¦å¦ä¹ ç‰åœºæ™¯çš„智能硬件,其主芯片采用Amlogic A311D芯片方案。 A311D支æŒGPU和神ç»ç½‘ç»œåŠ é€Ÿå系统,支æŒ4K视频编解ç 器引擎和一æµçš„HDR图åƒå¤„ç†ï¼Œå¹¶é›†æˆäº†æ‰€æœ‰æ ‡å‡†éŸ³é¢‘/视频输入/输出接å£ã€‚主系统的CPU采用大å°æ ¸è®¾è®¡ï¼Œä¸»é¢‘高达2.2GHz,集æˆäº†å››ä¸ªCortex-A73æ ¸å¿ƒå’Œä¸¤Cortex-A53æ ¸å¿ƒ ,集æˆç‹¬ç«‹çš„5.0T NPU处ç†å™¨ã€‚|智能家居ã€AI人脸识别ã€å·¥ä¸šæŽ§åˆ¶ã€æ™ºæ…§è½¦è½½ã€å¤šåª’体处ç†ã€AI边缘计算ç‰ã€‚|代ç 仓:<br/>[device_soc_amlogic](https://gitee.com/openharmony/device_soc_amlogic)<br/>[device_board_unionman](https://gitee.com/openharmony/device_board_unionman)<br/>[vendor_unionman](https://gitee.com/openharmony/vendor_unionman)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|MILOS_Standard0|NXP i.MX8M Mini|基于 NXP i.MX8M Mini处ç†å™¨ï¼Œ1.8G Hz主频。接â¼å¤–设丰富:LVDS显⽰ã€MIPI-DSIä¿¡å·å¼•å‡ºã€ MIPI-CSIæ‘„åƒå¤´æŽ¥â¼ã€â½€æŒâ¾³é¢‘输⼊输出ã€åƒå…†â½¹ã€å¤šè·¯USBã€å¤šä¸²â¼ã€ç‰å¤šç§é€šä¿¡æŽ¥â¼|⾼性能仪器仪表(⼯业åŠåŒ»ç–—)ã€â¼¯ä¸šæŽ§åˆ¶åŠâ¼ˆæœºäº’动装置ã€æ™ºèƒ½äº¤é€šã€æ™ºæ…§æ¶ˆé˜²ã€æ™ºæ…§æ¥¼å®‡ç‰ã€‚|代ç 仓:<br/>[device_soc_nxp](https://gitee.com/openharmony/device_soc_nxp)<br/>[device_board_osware](https://gitee.com/openharmony/device_board_osware)<br/>[vendor_osware](https://gitee.com/openharmony/vendor_osware)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|扬帆开å‘æ¿|RK3399|扬帆开å‘æ¿åŸºäºŽRK3399芯片平å°ï¼›RK3399çš„CPU采用big.LITTLEæ ¸å¿ƒæž¶æž„ï¼Œé‡‡ç”¨åŒæ ¸Cortex-A72å¤§æ ¸+å››æ ¸Cortex-A53å°æ ¸ç»“构。在整数,浮点数,内å˜ï¼Œæ•´ä½“æ€§èƒ½ï¼ŒåŠŸè€—å’Œæ ¸å¿ƒé¢ç§¯æ–¹é¢éƒ½è¿›è¡Œäº†é‡å¤§æ”¹è¿›ã€‚RK3399çš„GPUé‡‡ç”¨å››æ ¸ARM的新一代高端图åƒå¤„ç†å™¨Mali-T860,集æˆäº†æ›´å¤šçš„带宽压缩技术(如智能å åŠ ï¼ŒASTC和本地åƒç´ å˜å‚¨ï¼‰ï¼Œå¹¶æ”¯æŒæ›´å¤šçš„图形和计算接å£ã€‚|互动广告机ã€äº’动数å—æ ‡ç‰Œã€æ™ºèƒ½è‡ªåŠ©ç»ˆç«¯ã€æ™ºèƒ½é›¶å”®ç»ˆç«¯ã€å·¥æŽ§ä¸»æœºã€æœºå™¨äººè®¾å¤‡ç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_isoftstone](https://gitee.com/openharmony/device_board_isoftstone)<br/>[vendor_isoftstone](https://gitee.com/openharmony/vendor_isoftstone)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|致远开å‘æ¿|T507|致远开å‘æ¿æ载了全志工业级T507芯片,该芯片集æˆå››æ ¸CortexTM – A53 CPUã€G31 MP2 GPUã€å¤šè·¯è§†é¢‘输出接å£ï¼ˆRGB/2*LVDS/HDMI/CVBS OUT)ã€å¤šè·¯è§†é¢‘输入接å£ï¼ˆMIPI CSI/BT656/BT1120),支æŒ4K@60fps H.265解ç ,4K@25fps H.264解ç ,DI,3Dé™å™ªï¼Œè‡ªåŠ¨è°ƒè‰²ç³»ç»Ÿå’Œæ¢¯å½¢æ ¡æ£æ¨¡å—å¯ä»¥æä¾›æä¾›æµç•…的用户体验和专业的视觉效果|工业控制ã€æ™ºèƒ½é©¾èˆ±ã€æ™ºæ…§å®¶å±…ã€æ™ºæ…§ç”µåŠ›ã€åœ¨çº¿æ•™è‚²ç‰ã€‚|代ç 仓:<br/>[device_soc_allwinner](https://gitee.com/openharmony/device_soc_allwinner)<br/>[device_board_isoftstone](https://gitee.com/openharmony/device_board_isoftstone)<br/>[vendor_isoftstone](https://gitee.com/openharmony/vendor_isoftstone)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|润和HH-SCDAYU200| RK3568 |主è¦èƒ½åŠ›ï¼š<br/>基于Rockchip RK3568å¹³å°ï¼Œé›†æˆåŒæ ¸æž¶æž„GPU以åŠé«˜æ•ˆèƒ½NPUï¼Œå››æ ¸64ä½Cortex-A55 处ç†å™¨é‡‡ç”¨22nm工艺,主频高达2.0GHz;支æŒè“牙ã€Wi-Fiã€éŸ³é¢‘ã€è§†é¢‘和摄åƒå¤´ç‰åŠŸèƒ½ï¼Œæ‹¥æœ‰ä¸°å¯Œçš„扩展接å£ï¼Œæ”¯æŒå¤šç§è§†é¢‘输入输出接å£ï¼Œé…ç½®åŒåƒå…†è‡ªé€‚应RJ45以太网å£ï¼Œå¯æ»¡è¶³NVRã€å·¥ä¸šç½‘å…³ç‰å¤šç½‘å£äº§å“需求。<br/>适é…案例:<br/>[DAYU200适é…案例](porting/porting-dayu200-on_standard-demo.md)|影音娱ä¹ã€æ™ºæ…§å‡ºè¡Œã€æ™ºèƒ½å®¶å±…,如烟机ã€çƒ¤ç®±ã€è·‘æ¥æœºç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|Hispark_Phoenix|Hi3751V351|主è¦èƒ½åŠ›ï¼š<br/>å…¨çƒåˆ¶å¼FHD(全高清)智能电视主处ç†èŠ¯ç‰‡ï¼Œå†…ç½®é«˜æ€§èƒ½å¤šæ ¸ ARM A53 CPUï¼Œå¤šæ ¸MALI T450 GPU,支æŒNTSC/PAL/SECAM制å¼è§£è°ƒï¼Œæ”¯æŒDTMB/DVB-C/ATSC/ISDB-Tç‰å…¨çƒæ•°å—Demod,å¯ä»¥æ‰©å±•DVB-T/T2/S/S2,支æŒUSBæ’放,支æŒä¸»æµçš„è§†é¢‘æ ¼å¼åŒ…括MPEG2ã€H.264ã€H.265ã€RMVBã€AVS+ç‰ï¼Œæ”¯æŒä¸»æµéŸ³é¢‘解ç åŠéŸ³æ•ˆå¤„ç†ï¼Œä»¥åŠæµ·æ€è‡ªç ”çš„SWS音效处ç†ï¼Œæ”¯æŒCVBS/YPbPr/VGA/HDMI 1.4/USB接å£ï¼Œå†…ç½®1GB DDR,支æŒLVDSå’ŒminiLVDS接å£ï¼Œæ”¯æŒä¸»æµçš„Tconlesså±ã€‚|智能电视ã€æ™ºèƒ½å®¶å±…ä¸æŽ§å±ã€æ™ºèƒ½æ˜¾ç¤ºå™¨ã€å•†æ˜¾å¹¿å‘Šå±ã€äº¤äº’白æ¿ã€å·¥ä¸šæŽ§åˆ¶å±ã€æ‰“å°æœºå±ã€ç™½ç”µå±ã€å¥èº«å™¨æ˜¾ç¤ºå±ç‰ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|Unionpi Tiger|Amlogic A311D|主è¦èƒ½åŠ›ï¼š<br/>Unionpi Tiger是一款应用于图åƒå¤„ç†ï¼ŒéŸ³è§†é¢‘处ç†å’Œæ·±åº¦å¦ä¹ ç‰åœºæ™¯çš„智能硬件,其主芯片采用Amlogic A311D芯片方案。 A311D支æŒGPU和神ç»ç½‘ç»œåŠ é€Ÿå系统,支æŒ4K视频编解ç 器引擎和一æµçš„HDR图åƒå¤„ç†ï¼Œå¹¶é›†æˆäº†æ‰€æœ‰æ ‡å‡†éŸ³é¢‘/视频输入/输出接å£ã€‚主系统的CPU采用大å°æ ¸è®¾è®¡ï¼Œä¸»é¢‘高达2.2GHz,集æˆäº†å››ä¸ªCortex-A73æ ¸å¿ƒå’Œä¸¤Cortex-A53æ ¸å¿ƒ ,集æˆç‹¬ç«‹çš„5.0T NPU处ç†å™¨ã€‚|智能家居ã€AI人脸识别ã€å·¥ä¸šæŽ§åˆ¶ã€æ™ºæ…§è½¦è½½ã€å¤šåª’体处ç†ã€AI边缘计算ç‰ã€‚|代ç 仓:<br/>[device_soc_amlogic](https://gitee.com/openharmony/device_soc_amlogic)<br/>[device_board_unionman](https://gitee.com/openharmony/device_board_unionman)<br/>[vendor_unionman](https://gitee.com/openharmony/vendor_unionman)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|MILOS_Standard0|NXP i.MX8M Mini|主è¦èƒ½åŠ›ï¼š<br/>基于 NXP i.MX8M Mini处ç†å™¨ï¼Œ1.8G Hz主频。接â¼å¤–设丰富:LVDS显⽰ã€MIPI-DSIä¿¡å·å¼•å‡ºã€ MIPI-CSIæ‘„åƒå¤´æŽ¥â¼ã€â½€æŒâ¾³é¢‘输⼊输出ã€åƒå…†â½¹ã€å¤šè·¯USBã€å¤šä¸²â¼ã€ç‰å¤šç§é€šä¿¡æŽ¥â¼|⾼性能仪器仪表(⼯业åŠåŒ»ç–—)ã€â¼¯ä¸šæŽ§åˆ¶åŠâ¼ˆæœºäº’动装置ã€æ™ºèƒ½äº¤é€šã€æ™ºæ…§æ¶ˆé˜²ã€æ™ºæ…§æ¥¼å®‡ç‰ã€‚|代ç 仓:<br/>[device_soc_nxp](https://gitee.com/openharmony/device_soc_nxp)<br/>[device_board_osware](https://gitee.com/openharmony/device_board_osware)<br/>[vendor_osware](https://gitee.com/openharmony/vendor_osware)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|扬帆开å‘æ¿|RK3399|主è¦èƒ½åŠ›ï¼š<br/>扬帆开å‘æ¿åŸºäºŽRK3399芯片平å°ï¼›RK3399çš„CPU采用big.LITTLEæ ¸å¿ƒæž¶æž„ï¼Œé‡‡ç”¨åŒæ ¸Cortex-A72å¤§æ ¸+å››æ ¸Cortex-A53å°æ ¸ç»“构。在整数,浮点数,内å˜ï¼Œæ•´ä½“æ€§èƒ½ï¼ŒåŠŸè€—å’Œæ ¸å¿ƒé¢ç§¯æ–¹é¢éƒ½è¿›è¡Œäº†é‡å¤§æ”¹è¿›ã€‚RK3399çš„GPUé‡‡ç”¨å››æ ¸ARM的新一代高端图åƒå¤„ç†å™¨Mali-T860,集æˆäº†æ›´å¤šçš„带宽压缩技术(如智能å åŠ ï¼ŒASTC和本地åƒç´ å˜å‚¨ï¼‰ï¼Œå¹¶æ”¯æŒæ›´å¤šçš„图形和计算接å£ã€‚|互动广告机ã€äº’动数å—æ ‡ç‰Œã€æ™ºèƒ½è‡ªåŠ©ç»ˆç«¯ã€æ™ºèƒ½é›¶å”®ç»ˆç«¯ã€å·¥æŽ§ä¸»æœºã€æœºå™¨äººè®¾å¤‡ç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_isoftstone](https://gitee.com/openharmony/device_board_isoftstone)<br/>[vendor_isoftstone](https://gitee.com/openharmony/vendor_isoftstone)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|致远开å‘æ¿|T507|主è¦èƒ½åŠ›ï¼š<br/>致远开å‘æ¿æ载了全志工业级T507芯片,该芯片集æˆå››æ ¸CortexTM – A53 CPUã€G31 MP2 GPUã€å¤šè·¯è§†é¢‘输出接å£ï¼ˆRGB/2*LVDS/HDMI/CVBS OUT)ã€å¤šè·¯è§†é¢‘输入接å£ï¼ˆMIPI CSI/BT656/BT1120),支æŒ4K@60fps H.265解ç ,4K@25fps H.264解ç ,DI,3Dé™å™ªï¼Œè‡ªåŠ¨è°ƒè‰²ç³»ç»Ÿå’Œæ¢¯å½¢æ ¡æ£æ¨¡å—å¯ä»¥æä¾›æä¾›æµç•…的用户体验和专业的视觉效果|工业控制ã€æ™ºèƒ½é©¾èˆ±ã€æ™ºæ…§å®¶å±…ã€æ™ºæ…§ç”µåŠ›ã€åœ¨çº¿æ•™è‚²ç‰ã€‚|代ç 仓:<br/>[device_soc_allwinner](https://gitee.com/openharmony/device_soc_allwinner)<br/>[device_board_isoftstone](https://gitee.com/openharmony/device_board_isoftstone)<br/>[vendor_isoftstone](https://gitee.com/openharmony/vendor_isoftstone)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| ## å°åž‹ç³»ç»Ÿå¼€å‘æ¿ -| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ› | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | +| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ›åŠé€‚é…案例 | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | | ---------- | -------- | -------- | ------------ | -------------------------------------- | -|Hispark_Taurus|Hi3516DV300|Hi3516DV300是新一代Smart HD IPæ‘„åƒæœºSOC,集æˆæ–°ä¸€ä»£ISP(Image Signal Processor)ã€H.265视频压缩编ç 器ã€é«˜æ€§èƒ½NNIE引擎,在低ç 率ã€é«˜ç”»è´¨ã€æ™ºèƒ½å¤„ç†å’Œåˆ†æžã€ä½ŽåŠŸè€—ç‰æ–¹é¢æœ‰è¾ƒå¥½çš„性能。|带å±æ™ºèƒ½è®¾å¤‡ï¼Œå¦‚带å±å†°ç®±ã€è½¦æœºç‰ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|BearPi-HM Micro|STM32MP157A|BearPi-HM Microå¼€å‘æ¿æ˜¯ä¸€å—高度集æˆå¹¶å¯è¿è¡ŒOpenHarmony系统的开å‘æ¿ï¼Œæ¿è½½é«˜æ€§èƒ½çš„工业级处ç†å™¨STM32MP157芯片,æé…4.3寸LCD电容å¼è§¦æ‘¸å±ï¼Œå¹¶æ¿è½½wifi电路åŠæ ‡å‡†çš„E53接å£ï¼Œæ ‡å‡†çš„E53接å£å¯æ‰©å±•æ™ºèƒ½åŠ 湿器ã€æ™ºèƒ½å°ç¯ã€æ™ºèƒ½å®‰é˜²ã€æ™ºèƒ½çƒŸæ„Ÿç‰æ¡ˆä¾‹ã€‚|智慧家居ã€æ™ºèƒ½ç¡¬ä»¶ã€ä¸æŽ§å±ç‰ã€‚|代ç 仓:<br/>[device_soc_st](https://gitee.com/openharmony/device_soc_st)<br/>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br/>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|Hispark_Taurus|Hi3516DV300|主è¦èƒ½åŠ›ï¼š<br/>Hi3516DV300是新一代Smart HD IPæ‘„åƒæœºSOC,集æˆæ–°ä¸€ä»£ISP(Image Signal Processor)ã€H.265视频压缩编ç 器ã€é«˜æ€§èƒ½NNIE引擎,在低ç 率ã€é«˜ç”»è´¨ã€æ™ºèƒ½å¤„ç†å’Œåˆ†æžã€ä½ŽåŠŸè€—ç‰æ–¹é¢æœ‰è¾ƒå¥½çš„性能。|带å±æ™ºèƒ½è®¾å¤‡ï¼Œå¦‚带å±å†°ç®±ã€è½¦æœºç‰ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)<br/>[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|BearPi-HM Micro|STM32MP157A|主è¦èƒ½åŠ›ï¼š<br/>BearPi-HM Microå¼€å‘æ¿åŸºäºŽSTM32MP157芯片,æé…4.3寸LCD电容å¼è§¦æ‘¸å±ï¼Œå¹¶æ¿è½½wifi电路åŠæ ‡å‡†çš„E53接å£ï¼Œæ ‡å‡†çš„E53接å£å¯æ‰©å±•æ™ºèƒ½åŠ 湿器ã€æ™ºèƒ½å°ç¯ã€æ™ºèƒ½å®‰é˜²ã€æ™ºèƒ½çƒŸæ„Ÿç‰æ¡ˆä¾‹ã€‚<br/>适é…案例:<br/>[BearPi-HM Mircro适é…案例](porting/porting-stm32mp15xx-on-smallsystem.md)|智慧家居ã€æ™ºèƒ½ç¡¬ä»¶ã€ä¸æŽ§å±ç‰ã€‚|代ç 仓:<br/>[device_soc_st](https://gitee.com/openharmony/device_soc_st)<br/>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br/>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | ## è½»é‡ç³»ç»Ÿå¼€å‘æ¿ -| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ› | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | +| å¼€å‘æ¿åž‹å· | èŠ¯ç‰‡åž‹å· | 主è¦èƒ½åŠ›åŠé€‚é…案例 | 典型应用场景 | å¼€å‘æ¿ä»£ç 仓åŠç¤¾åŒºæ¯æ—¥æž„建版本获å–åœ°å€ | | ---------- | -------- | -------- | ------------ | -------------------------------------- | -|å°ç†Šæ´¾BearPi-HM Nano|Hi3861|BearPi-HM_Nanoå¼€å‘æ¿æ˜¯ä¸€å—专门为OpenHarmony设计的开å‘æ¿ï¼Œæ¿è½½é«˜åº¦é›†æˆçš„2.4GHz WiFi SoC芯片Hi3861,并æ¿è½½NFC电路åŠæ ‡å‡†çš„E53接å£ï¼Œæ ‡å‡†çš„E53接å£å¯æ‰©å±•æ™ºèƒ½åŠ 湿器ã€æ™ºèƒ½å°ç¯ã€æ™ºèƒ½å®‰é˜²ã€æ™ºèƒ½çƒŸæ„Ÿç‰æ¡ˆä¾‹ã€‚|智慧路ç¯ã€æ™ºæ…§ç‰©æµã€äººä½“红外ç‰è¿žæŽ¥ç±»è®¾å¤‡ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br/>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|欧智通V200ZR|BES2600|Multi-modal V200Z-Rå¼€å‘æ¿æ˜¯åŸºäºŽæ’玄科技BES2600WM芯片的一款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”AIoT SoCå¼€å‘æ¿ï¼›å¼€å‘æ¿å•æ¨¡ç»„集æˆå››æ ¸ARM处ç†å™¨ï¼ˆæœ€é«˜ä¸»é¢‘1GHz),集æˆåŒé¢‘WiFi + åŒæ¨¡è“牙,支æŒæ ‡å‡†çš„802.11 a/b/g/n/å议,支æŒBT/BLE 5.2å议,内建多ç§å®¹é‡çš„RAM(最大42MB)和Flash(最大32MB),支æŒMIPI DSIåŠCSI,适用于å„ç§AIoT多模æ€VUI + GUI交互硬件场景。|智能硬件ã€å¸¦å±ç±»æ¨¡ç»„产å“,如音箱ã€æ‰‹è¡¨ç‰ã€‚|代ç 仓:<br/>[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br/>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br/>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|朗国LANGO200|ASR582X|LANGO200 IOTå¼€å‘æ¿ï¼Œé›†æˆäº†é«˜æ€§èƒ½çš„WIFI-BLEåŒæ¨¡èŠ¯ç‰‡ASR5822ã€å¤–部å˜å‚¨èŠ¯ç‰‡ã€è¯éŸ³æ’放芯片以åŠæ¨¡æ•°è½¬æ¢ç‰ï¼ŒåŒæ—¶æ”¯æŒSPIç‰IOT设备常用外设接å£ï¼Œå¯å¤–扩OLED显示å±ã€çº¢å¤–é¥æŽ§ç‰ã€‚|智能家居ã€è¿žæŽ¥ç±»æ¨¡ç»„。|代ç 仓:<br/>[device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)<br/>[device_board_lango](https://gitee.com/openharmony/device_board_lango)<br/>[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|汇顶GR5515-STARTER-KIT|GR5515|支æŒBluetooth 5.1çš„å•æ¨¡ä½ŽåŠŸè€—è“牙SoC,多功能按键和LED指示ç¯ã€‚|智能硬件,如手表ã€æ‰‹çŽ¯ã€ä»·æ ¼ç±»æ ‡ç¾ã€‚|代ç 仓:<br/>[device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)<br/>[device_board_goodix](https://gitee.com/openharmony/device_board_goodix)<br/>[vendor_goodix](https://gitee.com/openharmony/vendor_goodix)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|Niobe407|STM32F407IGT6|Niobe407å¼€å‘æ¿åŸºäºŽSTM32F407芯片,该芯片集æˆArm Cortex-M4 CPU,带 FPUï¼Œè‡ªé€‚åº”å®žæ—¶åŠ é€Ÿå™¨ï¼Œé¢‘çŽ‡é«˜è¾¾ 168 MHz。|智慧交通ã€å·¥ä¸šæŽ§åˆ¶ç‰ã€‚|代ç 仓:<br/>[device_soc_st](https://gitee.com/openharmony/device_soc_st)<br/>[device_board_talkweb](https://gitee.com/openharmony/device_board_talkweb)<br/>[vendor_talkweb](https://gitee.com/openharmony/vendor_talkweb)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|B91 Generic Starter Kit|TLSR9x|泰凌微公å¸çš„B91 Generic Starter Kit是一个å¯ç”¨äºŽè¯„ä¼°TLSR9系列芯片组的硬件平å°ï¼ŒBLE,BLE Mesh,Zigbee 3.0, Threadå’Œ2.4GHzç§æœ‰åè®®ç‰å¤šç§é€‚用于2.4GHz接å£æ ‡å‡†çš„应用程åºéƒ½å¯ä»¥ç”¨å®ƒæ¥è¿›è¡Œå¼€å‘。|智能家居ã€è¿žæŽ¥ç±»æ¨¡ç»„。|代ç 仓:<br/>[device_soc_telink](https://gitee.com/openharmony/device_soc_telink)<br/>[device_board_telink](https://gitee.com/openharmony/device_board_telink)<br/>[vendor_telink](https://gitee.com/openharmony/vendor_telink)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|cst85_wblink|cst85f01|cst85_wblinkå¼€å‘æ¿æ˜¯åŸºäºŽèŠ¯æµ·ç§‘技cst85f01芯片,由芯海科技出å“的一款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”AIoT SoCå¼€å‘æ¿ã€‚cst85_wblinkå¼€å‘æ¿ï¼Œé›†æˆåŒé¢‘WiFi + åŒæ¨¡è“牙,支æŒæ ‡å‡†çš„802.11 a/b/g/n/å议,支æŒBT/BLE 5.0å议,内建多ç§å®¹é‡çš„RAM(最大992KB)和Flash(最大16MB),支æŒMIPI DSIåŠCSI,适用于快速开å‘物è”网(IOT)åŠæ™ºèƒ½è®¾å¤‡çš„Wi-Fiã€è“牙的应用。|物è”网ã€æ™ºèƒ½å®¶å±…ç‰ã€‚|代ç 仓:<br/>[device_soc_chipsea](https://gitee.com/openharmony/device_soc_chipsea)<br/>[device_board_chipsea](https://gitee.com/openharmony/device_board_chipsea)<br/>[vendor_chipsea](https://gitee.com/openharmony/vendor_chipsea)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| -|Neptune100| W800 |润和 Neptune100å¼€å‘æ¿åŸºäºŽè”盛德W800芯片,是一款Wi-Fi &è“牙åŒæ¨¡SoCå¼€å‘æ¿ï¼Œæ”¯æŒæ ‡å‡†çš„802.11 b/g/nå议,内置完整的TCP/IPåè®®æ ˆï¼Œé›†æˆè“牙基带处ç†å™¨ï¼Œæ”¯æŒBT/BLE4.2å议;具备丰富的数å—接å£ï¼Œå†…ç½®QFlashã€SPIã€UARTã€GPIOã€I2Cã€I2Sã€7816ç‰ï¼›å…·å¤‡å¼ºå¤§çš„安全特性,支æŒå¤šç§ç¡¬ä»¶åŠ 解密算法,内置DSPã€æµ®ç‚¹è¿ç®—å•å…ƒä¸Žå®‰å…¨å¼•æ“Žï¼Œæ”¯æŒä»£ç 安全æƒé™è®¾ç½®ï¼Œå†…ç½®2MBFlashå˜å‚¨å™¨ï¼Œæ”¯æŒå›ºä»¶åŠ 密å˜å‚¨ã€å›ºä»¶ç¾åã€å®‰å…¨è°ƒè¯•ã€å®‰å…¨å‡çº§ç‰å¤šé¡¹å®‰å…¨æŽªæ–½ã€‚|物è”网ã€æ™ºèƒ½å®¶å±…ã€è¿žæŽ¥ç±»äº§å“。|代ç 仓:<br/>[device_soc_winnermicro](https://gitee.com/openharmony/device_soc_winnermicro)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | -|å°å‡Œæ´¾-RK2206| RK2206 |å°å‡Œæ´¾-RK2206å¼€å‘æ¿ä¸»æŽ§å™¨ä¸ºç‘žèŠ¯å¾®é«˜æ€§èƒ½ã€é«˜æ€§ä»·æ¯”çš„RK2206芯片,æè½½OpenHarmonyè½»é‡çº§æ“作系统,内置WiFi/AP功能ã€NFC功能ã€æ¶²æ™¶æ˜¾ç¤ºæŽ¥å£ä»¥åŠE53接å£ï¼ŒE53接å£å…¼å®¹å„ç±»ä¼ æ„Ÿå™¨æ¨¡å—ï¼Œä¾¿äºŽå¤šæ ·åŒ–çš„IoT物è”网应用;目å‰å°å‡Œæ´¾-RK2006å¼€å‘æ¿å·²ç»æ‹¥æœ‰20+个æˆç†Ÿçš„应用案例,以åŠå®Œå–„çš„æ•™å¦è¯¾ç¨‹ã€‚|智慧城市ã€æ™ºèƒ½å®¶å±…ã€æ™ºæ…§æ•™å¦ã€æ™ºæ…§è½¦è½½ä»¥åŠæ™ºæ…§åŒ»ç–—ç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_lockzhiner](https://gitee.com/openharmony/device_board_lockzhiner)<br/>[vendor_lockzhiner](https://gitee.com/openharmony/vendor-lockzhiner)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | \ No newline at end of file +|å°ç†Šæ´¾BearPi-HM Nano|Hi3861|主è¦èƒ½åŠ›ï¼š<br/>BearPi-HM_Nanoå¼€å‘æ¿æ˜¯ä¸€å—专门为OpenHarmony设计的开å‘æ¿ï¼Œæ¿è½½é«˜åº¦é›†æˆçš„2.4GHz WiFi SoC芯片Hi3861,并æ¿è½½NFC电路åŠæ ‡å‡†çš„E53接å£ï¼Œæ ‡å‡†çš„E53接å£å¯æ‰©å±•æ™ºèƒ½åŠ 湿器ã€æ™ºèƒ½å°ç¯ã€æ™ºèƒ½å®‰é˜²ã€æ™ºèƒ½çƒŸæ„Ÿç‰æ¡ˆä¾‹ã€‚|智慧路ç¯ã€æ™ºæ…§ç‰©æµã€äººä½“红外ç‰è¿žæŽ¥ç±»è®¾å¤‡ã€‚|代ç 仓:<br/>[device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)<br/>[device_board_bearpi](https://gitee.com/openharmony/device_board_bearpi)<br/>[vendor_bearpi](https://gitee.com/openharmony/vendor_bearpi)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|Multi-modal V200Z-R|BES2600|主è¦èƒ½åŠ›ï¼š<br/>Multi-modal V200Z-Rå¼€å‘æ¿æ˜¯åŸºäºŽæ’玄科技BES2600WM芯片的一款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”AIoT SoCå¼€å‘æ¿ï¼›å¼€å‘æ¿å•æ¨¡ç»„集æˆå››æ ¸ARM处ç†å™¨ï¼ˆæœ€é«˜ä¸»é¢‘1GHz),集æˆåŒé¢‘WiFi + åŒæ¨¡è“牙,支æŒæ ‡å‡†çš„802.11 a/b/g/n/å议,支æŒBT/BLE 5.2å议,内建多ç§å®¹é‡çš„RAM(最大42MB)和Flash(最大32MB),支æŒMIPI DSIåŠCSI,适用于å„ç§AIoT多模æ€VUI + GUI交互硬件场景。<br/>适é…案例:<br/>[Multi-modal V200Z-R适é…案例](porting/porting-bes2600w-on-minisystem-display-demo.md)|智能硬件ã€å¸¦å±ç±»æ¨¡ç»„产å“,如音箱ã€æ‰‹è¡¨ç‰ã€‚|代ç 仓:<br/>[device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)<br/>[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)<br/>[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|朗国LANGO200|ASR582X|主è¦èƒ½åŠ›ï¼š<br/>LANGO200 IOTå¼€å‘æ¿ï¼Œé›†æˆäº†é«˜æ€§èƒ½çš„WIFI-BLEåŒæ¨¡èŠ¯ç‰‡ASR5822ã€å¤–部å˜å‚¨èŠ¯ç‰‡ã€è¯éŸ³æ’放芯片以åŠæ¨¡æ•°è½¬æ¢ç‰ï¼ŒåŒæ—¶æ”¯æŒSPIç‰IOT设备常用外设接å£ï¼Œå¯å¤–扩OLED显示å±ã€çº¢å¤–é¥æŽ§ç‰ã€‚<br/>适é…案例:<br/>[LANGO200适é…案例](porting/porting-asr582x-combo-demo.md)|智能家居ã€è¿žæŽ¥ç±»æ¨¡ç»„。|代ç 仓:<br/>[device_soc_asrmicro](https://gitee.com/openharmony/device_soc_asrmicro)<br/>[device_board_lango](https://gitee.com/openharmony/device_board_lango)<br/>[vendor_asrmicro](https://gitee.com/openharmony/vendor_asrmicro)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|汇顶GR5515-STARTER-KIT|GR5515|主è¦èƒ½åŠ›ï¼š<br/>支æŒBluetooth 5.1çš„å•æ¨¡ä½ŽåŠŸè€—è“牙SoC,多功能按键和LED指示ç¯ã€‚|智能硬件,如手表ã€æ‰‹çŽ¯ã€ä»·æ ¼ç±»æ ‡ç¾ã€‚|代ç 仓:<br/>[device_soc_goodix](https://gitee.com/openharmony/device_soc_goodix)<br/>[device_board_goodix](https://gitee.com/openharmony/device_board_goodix)<br/>[vendor_goodix](https://gitee.com/openharmony/vendor_goodix)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|Niobe407|STM32F407IGT6|主è¦èƒ½åŠ›ï¼š<br/>Niobe407å¼€å‘æ¿åŸºäºŽSTM32F407芯片,该芯片集æˆArm Cortex-M4 CPU,带 FPUï¼Œè‡ªé€‚åº”å®žæ—¶åŠ é€Ÿå™¨ï¼Œé¢‘çŽ‡é«˜è¾¾ 168 MHz。<br/>适é…案例:<br/>[Niobe407适é…案例](porting/porting-stm32f407-on-minisystem-eth.md)|智慧交通ã€å·¥ä¸šæŽ§åˆ¶ç‰ã€‚|代ç 仓:<br/>[device_soc_st](https://gitee.com/openharmony/device_soc_st)<br/>[device_board_talkweb](https://gitee.com/openharmony/device_board_talkweb)<br/>[vendor_talkweb](https://gitee.com/openharmony/vendor_talkweb)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|B91 Generic Starter Kit|TLSR9x|主è¦èƒ½åŠ›ï¼š<br/>泰凌微公å¸çš„B91 Generic Starter Kit是一个å¯ç”¨äºŽè¯„ä¼°TLSR9系列芯片组的硬件平å°ï¼ŒBLE,BLE Mesh,Zigbee 3.0, Threadå’Œ2.4GHzç§æœ‰åè®®ç‰å¤šç§é€‚用于2.4GHz接å£æ ‡å‡†çš„应用程åºéƒ½å¯ä»¥ç”¨å®ƒæ¥è¿›è¡Œå¼€å‘。|智能家居ã€è¿žæŽ¥ç±»æ¨¡ç»„。|代ç 仓:<br/>[device_soc_telink](https://gitee.com/openharmony/device_soc_telink)<br/>[device_board_telink](https://gitee.com/openharmony/device_board_telink)<br/>[vendor_telink](https://gitee.com/openharmony/vendor_telink)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds| +|cst85_wblink|cst85f01|主è¦èƒ½åŠ›ï¼š<br/>cst85_wblinkå¼€å‘æ¿æ˜¯åŸºäºŽèŠ¯æµ·ç§‘技cst85f01芯片,由芯海科技出å“的一款高性能ã€å¤šåŠŸèƒ½ã€é«˜æ€§ä»·æ¯”AIoT SoCå¼€å‘æ¿ã€‚cst85_wblinkå¼€å‘æ¿ï¼Œé›†æˆåŒé¢‘WiFi + åŒæ¨¡è“牙,支æŒæ ‡å‡†çš„802.11 a/b/g/n/å议,支æŒBT/BLE 5.0å议,内建多ç§å®¹é‡çš„RAM(最大992KB)和Flash(最大16MB),支æŒMIPI DSIåŠCSI,适用于快速开å‘物è”网(IOT)åŠæ™ºèƒ½è®¾å¤‡çš„Wi-Fiã€è“牙的应用。<br/>适é…案例:<br/>[cst85_wblink适é…案例](porting/porting-cst85f01-combo-demo.md)|物è”网ã€æ™ºèƒ½å®¶å±…ç‰ã€‚|代ç 仓:<br/>[device_soc_chipsea](https://gitee.com/openharmony/device_soc_chipsea)<br/>[device_board_chipsea](https://gitee.com/openharmony/device_board_chipsea)<br/>[vendor_chipsea](https://gitee.com/openharmony/vendor_chipsea)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|Neptune100| W800 |主è¦èƒ½åŠ›ï¼š<br/>润和 Neptune100å¼€å‘æ¿åŸºäºŽè”盛德W800芯片,是一款Wi-Fi &è“牙åŒæ¨¡SoCå¼€å‘æ¿ï¼Œæ”¯æŒæ ‡å‡†çš„802.11 b/g/nå议,内置完整的TCP/IPåè®®æ ˆï¼Œé›†æˆè“牙基带处ç†å™¨ï¼Œæ”¯æŒBT/BLE4.2å议;具备丰富的数å—接å£ï¼Œå†…ç½®QFlashã€SPIã€UARTã€GPIOã€I2Cã€I2Sã€7816ç‰ï¼›å…·å¤‡å¼ºå¤§çš„安全特性,支æŒå¤šç§ç¡¬ä»¶åŠ 解密算法,内置DSPã€æµ®ç‚¹è¿ç®—å•å…ƒä¸Žå®‰å…¨å¼•æ“Žï¼Œæ”¯æŒä»£ç 安全æƒé™è®¾ç½®ï¼Œå†…ç½®2MBFlashå˜å‚¨å™¨ï¼Œæ”¯æŒå›ºä»¶åŠ 密å˜å‚¨ã€å›ºä»¶ç¾åã€å®‰å…¨è°ƒè¯•ã€å®‰å…¨å‡çº§ç‰å¤šé¡¹å®‰å…¨æŽªæ–½ã€‚<br/>适é…案例:<br/>[Neptune100适é…案例](porting/porting-w800-combo-demo.md)|物è”网ã€æ™ºèƒ½å®¶å±…ã€è¿žæŽ¥ç±»äº§å“。|代ç 仓:<br/>[device_soc_winnermicro](https://gitee.com/openharmony/device_soc_winnermicro)<br/>[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)<br/>[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | +|å°å‡Œæ´¾-RK2206| RK2206 |主è¦èƒ½åŠ›ï¼š<br/>å°å‡Œæ´¾-RK2206å¼€å‘æ¿ä¸»æŽ§å™¨ä¸ºç‘žèŠ¯å¾®é«˜æ€§èƒ½ã€é«˜æ€§ä»·æ¯”çš„RK2206芯片,æè½½OpenHarmonyè½»é‡çº§æ“作系统,内置WiFi/AP功能ã€NFC功能ã€æ¶²æ™¶æ˜¾ç¤ºæŽ¥å£ä»¥åŠE53接å£ï¼ŒE53接å£å…¼å®¹å„ç±»ä¼ æ„Ÿå™¨æ¨¡å—ï¼Œä¾¿äºŽå¤šæ ·åŒ–çš„IoT物è”网应用;目å‰å°å‡Œæ´¾-RK2006å¼€å‘æ¿å·²ç»æ‹¥æœ‰20+个æˆç†Ÿçš„应用案例,以åŠå®Œå–„çš„æ•™å¦è¯¾ç¨‹ã€‚|智慧城市ã€æ™ºèƒ½å®¶å±…ã€æ™ºæ…§æ•™å¦ã€æ™ºæ…§è½¦è½½ä»¥åŠæ™ºæ…§åŒ»ç–—ç‰ã€‚|代ç 仓:<br/>[device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)<br/>[device_board_lockzhiner](https://gitee.com/openharmony/device_board_lockzhiner)<br/>[vendor_lockzhiner](https://gitee.com/openharmony/vendor-lockzhiner)<br/>社区æ¯æ—¥æž„建版本获å–地å€ï¼š<br/>http://ci.openharmony.cn/dailys/dailybuilds | \ No newline at end of file diff --git a/zh-cn/device-dev/device-dev-guide.md b/zh-cn/device-dev/device-dev-guide.md index 4e2cf46d41894b7fa621dedded37f2a0da539d23..3203ed3ce6a79e5c6d0a580805c21b03bb2bfa39 100644 --- a/zh-cn/device-dev/device-dev-guide.md +++ b/zh-cn/device-dev/device-dev-guide.md @@ -39,7 +39,7 @@ OpenHarmony也æ供了一系列å¯é€‰çš„系统组件,方便设备开å‘者按 | 快速入门 | 快速熟悉OpenHarmony环境æ建ã€ç¼–译ã€çƒ§å½•ã€è°ƒæµ‹ã€è¿è¡Œ | - [è½»é‡å’Œå°åž‹ç³»ç»Ÿå¿«é€Ÿå…¥é—¨](quick-start/quickstart-ide-lite-overview.md) | | 基础能力使用 | 使用OpenHarmonyæ供的基础能力 | - [è½»é‡ç³»ç»Ÿå†…æ ¸å¼€å‘指å—](kernel/kernel-mini-overview.md)<br/>- [å°åž‹ç³»ç»Ÿå†…æ ¸å¼€å‘指å—](kernel/kernel-small-overview.md)<br/>- [驱动开å‘指å—](driver/driver-hdf-overview.md)<br/>- [å系统开å‘指å—](subsystems/subsys-build-mini-lite.md)<br/>- [安全指å—](security/security-guidelines-overall.md)<br/>- [éšç§ä¿æŠ¤](security/security-privacy-protection.md) | | è¿›é˜¶å¼€å‘ | 结åˆç³»ç»Ÿèƒ½åŠ›å¼€å‘智能设备 | - [WLAN连接类产å“](guide/device-wlan-led-control.md)<br/>- [æ— å±æ‘„åƒå¤´ç±»äº§å“](guide/device-iotcamera-control-overview.md)<br/>- [带å±æ‘„åƒå¤´ç±»äº§å“](guide/device-camera-control-overview.md) | -| 移æ¤é€‚é… | - 针对特定芯片åšç§»æ¤é€‚é…<br/>- 对三方库进行移æ¤é€‚é…<br/>- 三方厂商移æ¤æ¡ˆä¾‹<br/> | - [è½»é‡ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æŒ‡å¯¼](porting/porting-minichip.md)<br/>- [å°åž‹ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æŒ‡å¯¼](porting/porting-smallchip-prepare-needs.md)<br/>- [è½»é‡å’Œå°åž‹ç³»ç»Ÿä¸‰æ–¹åº“移æ¤æŒ‡å¯¼](porting/porting-thirdparty-overview.md)<br/> - [带å±è§£å†³æ–¹æ¡ˆä¹‹æ’玄芯片移æ¤æ¡ˆä¾‹](porting-bes2600w-on-minisystem-display-demo.md)<br/> - [Combo解决方案之ASR芯片移æ¤æ¡ˆä¾‹](porting-asr582x-combo-demo.md)<br/> - [物è”网解决方案之芯海cst85芯片移æ¤æ¡ˆä¾‹](porting-cst85f01-combo-demo.md)<br/> - [è½»é‡ç³»ç»ŸSTM32F407芯片移æ¤æ¡ˆä¾‹](porting-stm32f407-on-minisystem-eth.md)<br/> - [Combo解决方案之W800芯片移æ¤æ¡ˆä¾‹](porting-w800-combo-demo.md)<br/> - [å°åž‹è®¾å¤‡STM32MP1芯片移æ¤æ¡ˆä¾‹](porting-stm32mp15xx-on-smallsystem.md)| +| 移æ¤é€‚é… | - 针对特定芯片åšç§»æ¤é€‚é…<br/>- 对三方库进行移æ¤é€‚é…<br/>- 三方厂商移æ¤æ¡ˆä¾‹<br/> | - [è½»é‡ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æŒ‡å¯¼](porting/porting-minichip.md)<br/>- [å°åž‹ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æŒ‡å¯¼](porting/porting-smallchip-prepare-needs.md)<br/>- [è½»é‡å’Œå°åž‹ç³»ç»Ÿä¸‰æ–¹åº“移æ¤æŒ‡å¯¼](porting/porting-thirdparty-overview.md)<br/> - [带å±è§£å†³æ–¹æ¡ˆä¹‹æ’玄芯片移æ¤æ¡ˆä¾‹](porting/porting-bes2600w-on-minisystem-display-demo.md)<br/> - [Combo解决方案之ASR芯片移æ¤æ¡ˆä¾‹](porting/porting-asr582x-combo-demo.md)<br/> - [物è”网解决方案之芯海cst85芯片移æ¤æ¡ˆä¾‹](porting/porting-cst85f01-combo-demo.md)<br/> - [è½»é‡ç³»ç»ŸSTM32F407芯片移æ¤æ¡ˆä¾‹](porting/porting-stm32f407-on-minisystem-eth.md)<br/> - [Combo解决方案之W800芯片移æ¤æ¡ˆä¾‹](porting/porting-w800-combo-demo.md)<br/> - [å°åž‹è®¾å¤‡STM32MP1芯片移æ¤æ¡ˆä¾‹](porting/porting-stm32mp15xx-on-smallsystem.md)| | 贡献组件 | 为OpenHarmony贡献功能组件 | - [HPM Part 介ç»](hpm-part/hpm-part-about.md)<br/>- [HPM Part å¼€å‘指导](hpm-part/hpm-part-development.md)<br/>- [HPM Part å‚考](hpm-part/hpm-part-reference.md) | | å‚考 | å¼€å‘å‚考 | [常è§é—®é¢˜](faqs/faqs-overview.md) diff --git a/zh-cn/device-dev/driver/Readme-CN.md b/zh-cn/device-dev/driver/Readme-CN.md index 3ee6c11799a477f3f9b9178545d23d518ba9c006..4118cdf0596261ee5c53161a6855cc7eecbfb544 100755 --- a/zh-cn/device-dev/driver/Readme-CN.md +++ b/zh-cn/device-dev/driver/Readme-CN.md @@ -46,6 +46,7 @@ - [Audio](driver-peripherals-audio-des.md) - [Camera](driver-peripherals-camera-des.md) - [Face_auth](driver-peripherals-face_auth-des.md) + - [Fingerprint_auth](driver-peripherals-fingerprint_auth-des.md) - [LCD](driver-peripherals-lcd-des.md) - [Light](driver-peripherals-light-des.md) - [Pin_auth](driver-peripherals-pinauth-des.md) diff --git a/zh-cn/device-dev/driver/driver-hdf-development.md b/zh-cn/device-dev/driver/driver-hdf-development.md index 49bd0a14ab56cf5d63b6268a61949d95a4805f2d..c1abcd7db00abc914a482303583e2ac49520c597 100755 --- a/zh-cn/device-dev/driver/driver-hdf-development.md +++ b/zh-cn/device-dev/driver/driver-hdf-development.md @@ -3,7 +3,7 @@ ## é©±åŠ¨æ¨¡åž‹ä»‹ç» -HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒè®¾è®¡æ€è·¯ï¼Œä¸ºå¼€å‘者æ供更精细化的驱动管ç†ï¼Œè®©é©±åŠ¨å¼€å‘å’Œéƒ¨ç½²æ›´åŠ è§„èŒƒã€‚HDF框架将一类设备驱动放在åŒä¸€ä¸ªhost里é¢ï¼Œå¼€å‘者也å¯ä»¥å°†é©±åŠ¨åŠŸèƒ½åˆ†å±‚独立开å‘和部署,支æŒä¸€ä¸ªé©±åŠ¨å¤šä¸ªnode。HDF驱动模型如下图所示: +HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒè®¾è®¡æ€è·¯ï¼Œä¸ºå¼€å‘者æ供更精细化的驱动管ç†ï¼Œè®©é©±åŠ¨å¼€å‘å’Œéƒ¨ç½²æ›´åŠ è§„èŒƒã€‚HDF框架将一类设备驱动放在åŒä¸€ä¸ªHost里é¢ï¼Œå¼€å‘者也å¯ä»¥å°†é©±åŠ¨åŠŸèƒ½åˆ†å±‚独立开å‘和部署,支æŒä¸€ä¸ªé©±åŠ¨å¤šä¸ªNode。HDF驱动模型如下图所示: **图1** HDF驱动模型 @@ -12,28 +12,28 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ ## 驱动开å‘æ¥éª¤ -基于HDF框架进行驱动的开å‘主è¦åˆ†ä¸ºä¸¤ä¸ªéƒ¨åˆ†ï¼Œé©±åŠ¨å®žçŽ°å’Œé©±åŠ¨é…置。详细开å‘æµç¨‹å¦‚下所示: +基于HDF框架的驱动开å‘主è¦åˆ†ä¸ºä¸‰ä¸ªéƒ¨åˆ†ï¼šé©±åŠ¨å®žçŽ°ã€é©±åŠ¨ç¼–译和驱动é…置。详细开å‘æµç¨‹å¦‚下所示: 1. 驱动实现 - 驱动实现包å«é©±åŠ¨ä¸šåŠ¡ä»£ç 和驱动入å£æ³¨å†Œï¼Œå…·ä½“写法如下: + 驱动实现包å«é©±åŠ¨ä¸šåŠ¡ä»£ç 实现和驱动入å£æ³¨å†Œï¼Œå…·ä½“写法如下: - 驱动业务代ç ``` - #include "hdf_device_desc.h" // HDF框架对驱动开å‘相关能力接å£çš„头文件 - #include "hdf_log.h" // HDF框架æ供的日志接å£å¤´æ–‡ä»¶ + #include "hdf_device_desc.h" // HDF框架对驱动开å‘相关能力接å£çš„头文件 + #include "hdf_log.h" // HDF框架æ供的日志接å£å¤´æ–‡ä»¶ - #define HDF_LOG_TAG "sample_driver" // 打å°æ—¥å¿—所包å«çš„æ ‡ç¾ï¼Œå¦‚æžœä¸å®šä¹‰åˆ™ç”¨é»˜è®¤å®šä¹‰çš„HDF_TAGæ ‡ç¾ + #define HDF_LOG_TAG "sample_driver" // 打å°æ—¥å¿—所包å«çš„æ ‡ç¾ï¼Œå¦‚æžœä¸å®šä¹‰åˆ™ç”¨é»˜è®¤å®šä¹‰çš„HDF_TAGæ ‡ç¾ã€‚ - // 驱动对外æ供的æœåŠ¡èƒ½åŠ›ï¼Œå°†ç›¸å…³çš„æœåŠ¡æŽ¥å£ç»‘定到HDF框架 + // 驱动对外æ供的æœåŠ¡èƒ½åŠ›ï¼Œå°†ç›¸å…³çš„æœåŠ¡æŽ¥å£ç»‘定到HDF框架。 int32_t HdfSampleDriverBind(struct HdfDeviceObject *deviceObject) { HDF_LOGD("Sample driver bind success"); return 0; } - // 驱动自身业务åˆå§‹çš„æŽ¥å£ + // 驱动自身业务åˆå§‹åŒ–çš„æŽ¥å£ int32_t HdfSampleDriverInit(struct HdfDeviceObject *deviceObject) { HDF_LOGD("Sample driver Init success"); @@ -50,7 +50,7 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ - 驱动入å£æ³¨å†Œåˆ°HDF框架 ``` - // 定义驱动入å£çš„对象,必须为HdfDriverEntry(在hdf_device_desc.hä¸å®šä¹‰ï¼‰ç±»åž‹çš„全局å˜é‡ + // 定义驱动入å£çš„对象,必须为HdfDriverEntry(在hdf_device_desc.hä¸å®šä¹‰ï¼‰ç±»åž‹çš„全局å˜é‡ã€‚ struct HdfDriverEntry g_sampleDriverEntry = { .moduleVersion = 1, .moduleName = "sample_driver", @@ -59,93 +59,94 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ .Release = HdfSampleDriverRelease, }; - // 调用HDF_INIT将驱动入å£æ³¨å†Œåˆ°HDF框架ä¸ï¼Œåœ¨åŠ 载驱动时HDF框架会先调用Bind函数,å†è°ƒç”¨Initå‡½æ•°åŠ è½½è¯¥é©±åŠ¨ï¼Œå½“Init调用异常时,HDF框架会调用Release释放驱动资æºå¹¶é€€å‡º + // 调用HDF_INIT将驱动入å£æ³¨å†Œåˆ°HDF框架ä¸ã€‚åœ¨åŠ è½½é©±åŠ¨æ—¶HDF框架会先调用Bind函数,å†è°ƒç”¨Initå‡½æ•°åŠ è½½è¯¥é©±åŠ¨ï¼›å½“Init调用异常时,HDF框架会调用Release释放驱动资æºå¹¶é€€å‡ºã€‚ HDF_INIT(g_sampleDriverEntry); ``` 2. 驱动编译 - - liteos - 涉åŠmakefileå’ŒBUILD.gn修改: + - LiteOS - - makefile部分: + 涉åŠMakefileå’ŒBUILD.gn修改: - 驱动代ç 的编译必须è¦ä½¿ç”¨HDF框架æ供的Makefile模æ¿è¿›è¡Œç¼–译。 + - Makefile部分: - - ``` - include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk #导入hdf预定义内容,必需 - MODULE_NAME := #生æˆçš„结果文件 - LOCAL_INCLUDE := #本驱动的头文件目录 - LOCAL_SRCS := #本驱动的æºä»£ç 文件 - LOCAL_CFLAGS := #自定义的编译选项 - include $(HDF_DRIVER) #导入Makefile模æ¿å®Œæˆç¼–译 - ``` + 驱动代ç 的编译必须è¦ä½¿ç”¨HDF框架æ供的Makefile模æ¿è¿›è¡Œç¼–译。 + + + ``` + include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk # ã€å¿…需】导入hdf预定义内容 + MODULE_NAME := #生æˆçš„结果文件 + LOCAL_INCLUDE := #本驱动的头文件目录 + LOCAL_SRCS := #本驱动的æºä»£ç 文件 + LOCAL_CFLAGS := #自定义的编译选项 + include $(HDF_DRIVER) #导入Makefile模æ¿å®Œæˆç¼–译 + ``` - ç¼–è¯‘ç»“æžœæ–‡ä»¶é“¾æŽ¥åˆ°å†…æ ¸é•œåƒï¼Œæ·»åŠ 到drivers/adapter/khdf/liteos目录下的hdf_lite.mk里é¢ï¼Œç¤ºä¾‹å¦‚下: + ç¼–è¯‘ç»“æžœæ–‡ä»¶é“¾æŽ¥åˆ°å†…æ ¸é•œåƒï¼Œæ·»åŠ 到**drivers/adapter/khdf/liteos**目录下的**hdf_lite.mk**里é¢ï¼Œç¤ºä¾‹å¦‚下: - ``` - LITEOS_BASELIB += -lxxx #链接生æˆçš„é™æ€åº“ - LIB_SUBDIRS += #驱动代ç Makefile的目录 - ``` + ``` + LITEOS_BASELIB += -lxxx #链接生æˆçš„é™æ€åº“ + LIB_SUBDIRS += #驱动代ç Makefile的目录 + ``` - - BUILD.gn部分: + - BUILD.gn部分: - æ·»åŠ æ¨¡å—BUILD.gnå‚考定义如下内容: + æ·»åŠ æ¨¡å—BUILD.gnå‚考定义如下内容: - ``` - import("//build/lite/config/component/lite_component.gni") - import("//drivers/adapter/khdf/liteos/hdf.gni") - module_switch = defined(LOSCFG_DRIVERS_HDF_xxx) - module_name = "xxx" - hdf_driver(module_name) { - sources = [ - "xxx/xxx/xxx.c", #模å—è¦ç¼–译的æºç 文件 - ] - public_configs = [ ":public" ] #使用ä¾èµ–的头文件é…ç½® - } - config("public") { #定义ä¾èµ–的头文件é…ç½® - include_dirs = [ - "xxx/xxx/xxx", #ä¾èµ–的头文件目录 - ] - } - ``` - - 把新增模å—çš„BUILD.gnæ‰€åœ¨çš„ç›®å½•æ·»åŠ åˆ°/drivers/adapter/khdf/liteos/BUILD.gn里é¢ï¼š + ``` + import("//build/lite/config/component/lite_component.gni") + import("//drivers/adapter/khdf/liteos/hdf.gni") + module_switch = defined(LOSCFG_DRIVERS_HDF_xxx) + module_name = "xxx" + hdf_driver(module_name) { + sources = [ + "xxx/xxx/xxx.c", #模å—è¦ç¼–译的æºç 文件 + ] + public_configs = [ ":public" ] #使用ä¾èµ–的头文件é…ç½® + } + config("public") { #定义ä¾èµ–的头文件é…ç½® + include_dirs = [ + "xxx/xxx/xxx", #ä¾èµ–的头文件目录 + ] + } + ``` + + 把新增模å—çš„BUILD.gnæ‰€åœ¨çš„ç›®å½•æ·»åŠ åˆ°**/drivers/adapter/khdf/liteos/BUILD.gn**里é¢ï¼š - ``` - group("liteos") { - public_deps = [ ":$module_name" ] - deps = [ - "xxx/xxx", #新增模å—BUILD.gn所在的目录,目录结构相对于/drivers/adapter/khdf/liteos - ] - } - ``` - - linux - - 如果需è¦å®šä¹‰æ¨¡å—控制å®ï¼Œéœ€è¦åœ¨æ¨¡å—目录xxx里é¢æ·»åŠ Kconfig文件,并把Kconfigæ–‡ä»¶è·¯å¾„æ·»åŠ åˆ°drivers/adapter/khdf/linux/Kconfig里é¢ï¼š + ``` + group("liteos") { + public_deps = [ ":$module_name" ] + deps = [ + "xxx/xxx", #新增模å—BUILD.gn所在的目录,目录结构相对于/drivers/adapter/khdf/liteos + ] + } + ``` + - Linux + + 如果需è¦å®šä¹‰æ¨¡å—控制å®ï¼Œéœ€è¦åœ¨æ¨¡å—目录xxx里é¢æ·»åŠ Kconfig文件,并把Kconfigæ–‡ä»¶è·¯å¾„æ·»åŠ åˆ°**drivers/adapter/khdf/linux/Kconfig**里é¢ï¼š - ``` - source "drivers/hdf/khdf/xxx/Kconfig" #目录为hdf模å—软链接到kernel里é¢çš„目录 - ``` + ``` + source "drivers/hdf/khdf/xxx/Kconfig" #目录为hdf模å—软链接到kernel里é¢çš„目录 + ``` - æ·»åŠ æ¨¡å—目录到drivers/adapter/khdf/linux/Makefile: + æ·»åŠ æ¨¡å—目录到**drivers/adapter/khdf/linux/Makefile**: - ``` - obj-$(CONFIG_DRIVERS_HDF) += xxx/ - ``` + ``` + obj-$(CONFIG_DRIVERS_HDF) += xxx/ + ``` - 在模å—目录xxx里é¢æ·»åŠ Makefile文件,在Makefile文件里é¢æ·»åŠ 模å—代ç 编译规则: + 在模å—目录xxx里é¢æ·»åŠ Makefile文件,在Makefile文件里é¢æ·»åŠ 模å—代ç 编译规则: - ``` - obj-y += xxx.o - ``` + ``` + obj-y += xxx.o + ``` 3. 驱动é…ç½® @@ -155,19 +156,19 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ - 驱动设备æ述(必选) - HDFæ¡†æž¶åŠ è½½é©±åŠ¨æ‰€éœ€è¦çš„ä¿¡æ¯æ¥æºäºŽHDF框架定义的驱动设备æè¿°ï¼Œå› æ¤åŸºäºŽHDF框架开å‘的驱动必须è¦åœ¨HDF框架定义的device_info.hcsé…置文件ä¸æ·»åŠ 对应的设备æ述,驱动的设备æ述填写如下所示: + HDFæ¡†æž¶åŠ è½½é©±åŠ¨æ‰€éœ€è¦çš„ä¿¡æ¯æ¥æºäºŽHDF框架定义的驱动设备æè¿°ï¼Œå› æ¤åŸºäºŽHDF框架开å‘的驱动必须è¦åœ¨HDF框架定义的device_info.hcsé…置文件ä¸æ·»åŠ 对应的设备æ述。驱动的设备æ述填写如下所示: ``` root { device_info { match_attr = "hdf_manager"; - template host { // host模æ¿ï¼Œç»§æ‰¿è¯¥æ¨¡æ¿çš„节点(如下sample_host)如果使用模æ¿ä¸çš„默认值,则节点å—段å¯ä»¥ç¼ºçœ + template host { // host模æ¿ï¼Œç»§æ‰¿è¯¥æ¨¡æ¿çš„节点(如下sample_host)如果使用模æ¿ä¸çš„默认值,则节点å—段å¯ä»¥ç¼ºçœã€‚ hostName = ""; priority = 100; - uid = ""; // 用户æ€è¿›ç¨‹uid,缺çœä¸ºç©ºï¼Œä¼šè¢«é…置为hostName的定义值,å³æ™®é€šç”¨æˆ· - gid = ""; // 用户æ€è¿›ç¨‹gid,缺çœä¸ºç©ºï¼Œä¼šè¢«é…置为hostName的定义值,å³æ™®é€šç”¨æˆ·ç»„ - caps = [""]; // 用户æ€è¿›ç¨‹Linux capabilitiesé…置,缺çœä¸ºç©ºï¼Œéœ€è¦ä¸šåŠ¡æ¨¡å—按照业务需è¦è¿›è¡Œé…ç½® + uid = ""; // 用户æ€è¿›ç¨‹uid,缺çœä¸ºç©ºï¼Œä¼šè¢«é…置为hostName的定义值,å³æ™®é€šç”¨æˆ·ã€‚ + gid = ""; // 用户æ€è¿›ç¨‹gid,缺çœä¸ºç©ºï¼Œä¼šè¢«é…置为hostName的定义值,å³æ™®é€šç”¨æˆ·ç»„。 + caps = [""]; // 用户æ€è¿›ç¨‹Linux capabilitiesé…置,缺çœä¸ºç©ºï¼Œéœ€è¦ä¸šåŠ¡æ¨¡å—按照业务需è¦è¿›è¡Œé…置。 template device { template deviceNode { policy = 0; @@ -181,39 +182,41 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ } } sample_host :: host{ - hostName = "host0"; // hostå称,host节点是用æ¥å˜æ”¾æŸä¸€ç±»é©±åŠ¨çš„容器 - priority = 100; // hostå¯åŠ¨ä¼˜å…ˆçº§ï¼ˆ0-200),值越大优先级越低,建议默认é…100,优先级相åŒåˆ™ä¸ä¿è¯hostçš„åŠ è½½é¡ºåº - caps = ["DAC_OVERRIDE", "DAC_READ_SEARCH"]; // 用户æ€è¿›ç¨‹Linux capabilitiesé…ç½® + hostName = "host0"; // hostå称,host节点是用æ¥å˜æ”¾æŸä¸€ç±»é©±åŠ¨çš„容器。 + priority = 100; // hostå¯åŠ¨ä¼˜å…ˆçº§ï¼ˆ0-200),值越大优先级越低,建议默认é…100,优先级相åŒåˆ™ä¸ä¿è¯hostçš„åŠ è½½é¡ºåºã€‚ + caps = ["DAC_OVERRIDE", "DAC_READ_SEARCH"]; // 用户æ€è¿›ç¨‹Linux capabilitiesé…置。 device_sample :: device { // sample设备节点 device0 :: deviceNode { // sample驱动的DeviceNode节点 - policy = 1; // policyå—段是驱动æœåŠ¡å‘布的ç–略,在驱动æœåŠ¡ç®¡ç†ç« èŠ‚æœ‰è¯¦ç»†ä»‹ç» - priority = 100; // 驱动å¯åŠ¨ä¼˜å…ˆçº§ï¼ˆ0-200),值越大优先级越低,建议默认é…100,优先级相åŒåˆ™ä¸ä¿è¯deviceçš„åŠ è½½é¡ºåº - preload = 0; // é©±åŠ¨æŒ‰éœ€åŠ è½½å—æ®µï¼Œåœ¨æœ¬ç« èŠ‚æœ€åŽçš„è¯´æ˜Žæœ‰è¯¦ç»†ä»‹ç» + policy = 1; // policyå—段是驱动æœåŠ¡å‘布的ç–略,在驱动æœåŠ¡ç®¡ç†ç« 节有详细介ç»ã€‚ + priority = 100; // 驱动å¯åŠ¨ä¼˜å…ˆçº§ï¼ˆ0-200),值越大优先级越低,建议默认é…100,优先级相åŒåˆ™ä¸ä¿è¯deviceçš„åŠ è½½é¡ºåºã€‚ + preload = 0; // é©±åŠ¨æŒ‰éœ€åŠ è½½å—æ®µï¼Œåœ¨æœ¬ç« èŠ‚æœ€åŽçš„说明有详细介ç»ã€‚ permission = 0664; // 驱动创建设备节点æƒé™ - moduleName = "sample_driver"; // 驱动å称,该å—段的值必须和驱动入å£ç»“æž„çš„moduleName值一致 - serviceName = "sample_service"; // 驱动对外å‘布æœåŠ¡çš„å称,必须唯一 - deviceMatchAttr = "sample_config"; // 驱动ç§æœ‰æ•°æ®åŒ¹é…的关键å—,必须和驱动ç§æœ‰æ•°æ®é…置表ä¸çš„match_attrå€¼ç›¸ç‰ + moduleName = "sample_driver"; // 驱动å称,该å—段的值必须和驱动入å£ç»“æž„çš„moduleName值一致。 + serviceName = "sample_service"; // 驱动对外å‘布æœåŠ¡çš„å称,必须唯一。 + deviceMatchAttr = "sample_config"; // 驱动ç§æœ‰æ•°æ®åŒ¹é…的关键å—,必须和驱动ç§æœ‰æ•°æ®é…置表ä¸çš„match_attr值相ç‰ã€‚ } } } } } ``` - 说明: - - uidã€gidã€capsç‰é…置项是用户æ€é©±åŠ¨çš„å¯åŠ¨é…ç½®ï¼Œå†…æ ¸æ€ä¸ç”¨é…置。 - - æ ¹æ®è¿›ç¨‹æƒé™æœ€å°åŒ–设计原则,业务模å—uidã€gidä¸ç”¨é…置,如上é¢çš„sample_host,使用普通用户æƒé™ï¼Œå³uidå’Œgid被定义为hostName的定义值。 - - 如果普通用户æƒé™ä¸èƒ½æ»¡è¶³ä¸šåŠ¡è¦æ±‚,需è¦æŠŠuidã€gid定义为system或者rootæƒé™æ—¶ï¼Œè¯·æ‰¾å®‰å…¨ä¸“家进行评审。 - - 进程的uid在文件base/startup/init_lite/services/etc/passwdä¸é…置,进程的gid在文件base/startup/init_lite/services/etc/groupä¸é…置,进程uidå’Œgidé…ç½®å‚考:[系统æœåŠ¡ç”¨æˆ·ç»„æ·»åŠ æ–¹æ³•](https://gitee.com/openharmony/startup_init_lite/wikis)。 + + >  **说明:**<br> + > + > - uidã€gidã€capsç‰é…置项是用户æ€é©±åŠ¨çš„å¯åŠ¨é…ç½®ï¼Œå†…æ ¸æ€ä¸ç”¨é…置。 + > + > - æ ¹æ®è¿›ç¨‹æƒé™æœ€å°åŒ–设计原则,业务模å—uidã€gidä¸ç”¨é…置,如上é¢çš„sample_host,使用普通用户æƒé™ï¼Œå³uidå’Œgid被定义为hostName的定义值。 + > + > - 如果普通用户æƒé™ä¸èƒ½æ»¡è¶³ä¸šåŠ¡è¦æ±‚,需è¦æŠŠuidã€gid定义为system或者rootæƒé™æ—¶ï¼Œè¯·æ‰¾å®‰å…¨ä¸“家进行评审。 + > + > - 进程的uid在文件**base/startup/init_lite/services/etc/passwd**ä¸é…置,进程的gid在文件**base/startup/init_lite/services/etc/group**ä¸é…置,进程uidå’Œgidé…ç½®å‚考:[系统æœåŠ¡ç”¨æˆ·ç»„æ·»åŠ æ–¹æ³•](https://gitee.com/openharmony/startup_init_lite/wikis)。 + > + > - caps值:比如业务模å—è¦é…ç½®CAP_DAC_OVERRIDE,æ¤å¤„需è¦å¡«å†™caps = ["DAC_OVERRIDE"],ä¸èƒ½å¡«å†™ä¸ºcaps = ["CAP_DAC_OVERRIDE"]。 - caps值:比如业务模å—è¦é…ç½®CAP_DAC_OVERRIDE,æ¤å¤„需è¦å¡«å†™ caps = ["DAC_OVERRIDE"],ä¸èƒ½å¡«å†™ä¸ºcaps = ["CAP_DAC_OVERRIDE"]。 - 驱动ç§æœ‰é…置信æ¯ï¼ˆå¯é€‰ï¼‰ - 如果驱动有ç§æœ‰é…置,则å¯ä»¥æ·»åŠ 一个驱动的é…置文件,用æ¥å¡«å†™ä¸€äº›é©±åŠ¨çš„默认é…置信æ¯ï¼ŒHDFæ¡†æž¶åœ¨åŠ è½½é©±åŠ¨çš„æ—¶å€™ï¼Œä¼šå°†å¯¹åº”çš„é…置信æ¯èŽ·å–并ä¿å˜åœ¨HdfDeviceObjectä¸çš„property里é¢ï¼Œé€šè¿‡Bindå’ŒInit(å‚考æ¥éª¤1ï¼‰ä¼ é€’ç»™é©±åŠ¨ï¼Œé©±åŠ¨çš„é…置信æ¯ç¤ºä¾‹å¦‚下: + 如果驱动有ç§æœ‰é…置,则å¯ä»¥æ·»åŠ 一个驱动的é…置文件,用æ¥å¡«å†™ä¸€äº›é©±åŠ¨çš„默认é…置信æ¯ã€‚HDFæ¡†æž¶åœ¨åŠ è½½é©±åŠ¨çš„æ—¶å€™ï¼Œä¼šå°†å¯¹åº”çš„é…置信æ¯èŽ·å–并ä¿å˜åœ¨HdfDeviceObjectä¸çš„property里é¢ï¼Œé€šè¿‡Bindå’ŒInit(å‚考æ¥éª¤1ï¼‰ä¼ é€’ç»™é©±åŠ¨ã€‚é©±åŠ¨çš„é…置信æ¯ç¤ºä¾‹å¦‚下: ``` @@ -249,7 +252,12 @@ HDF(Hardware Driver Foundationï¼‰æ¡†æž¶ä»¥ç»„ä»¶åŒ–çš„é©±åŠ¨æ¨¡åž‹ä½œä¸ºæ ¸å¿ƒ > } DevicePreload; > ``` > -> é…置文件ä¸preloadå—段é…æˆ0(DEVICE_PRELOAD_ENABLE),则系统å¯åŠ¨è¿‡ç¨‹ä¸é»˜è®¤åŠ 载;é…æˆ1(DEVICE_PRELOAD_ENABLE_STEP2),当系统支æŒå¿«å¯çš„时候,则在系统完æˆä¹‹åŽå†åŠ 载这一类驱动,å¦åˆ™å’ŒDEVICE_PRELOAD_ENABLEå«ä¹‰ç›¸åŒï¼›é…æˆ2(DEVICE_PRELOAD_DISABLE),则系统å¯åŠ¨è¿‡ç¨‹ä¸é»˜è®¤ä¸åŠ 载,支æŒåŽç»åŠ¨æ€åŠ 载,当用户æ€èŽ·å–驱动æœåŠ¡ï¼ˆå‚考[消æ¯æœºåˆ¶](../driver/driver-hdf-message-management.md))时,如果驱动æœåŠ¡ä¸å˜åœ¨ï¼ŒHDF框架会å°è¯•åŠ¨æ€åŠ 载该驱动。 +> - é…置文件ä¸preloadå—段é…æˆ0(DEVICE_PRELOAD_ENABLE),则系统å¯åŠ¨è¿‡ç¨‹ä¸é»˜è®¤åŠ 载。 +> +> - é…æˆ1(DEVICE_PRELOAD_ENABLE_STEP2),当系统支æŒå¿«å¯çš„时候,则在系统完æˆä¹‹åŽå†åŠ 载这一类驱动,å¦åˆ™å’ŒDEVICE_PRELOAD_ENABLEå«ä¹‰ç›¸åŒã€‚ +> +> - é…æˆ2(DEVICE_PRELOAD_DISABLE),则系统å¯åŠ¨è¿‡ç¨‹ä¸é»˜è®¤ä¸åŠ 载,支æŒåŽç»åŠ¨æ€åŠ 载,当用户æ€èŽ·å–驱动æœåŠ¡ï¼ˆå‚考[消æ¯æœºåˆ¶](../driver/driver-hdf-message-management.md))时,如果驱动æœåŠ¡ä¸å˜åœ¨ï¼ŒHDF框架会å°è¯•åŠ¨æ€åŠ 载该驱动。 > > - 按åºåŠ 载(需è¦é©±åŠ¨ä¸ºé»˜è®¤åŠ 载) +> > é…置文件ä¸çš„priority(å–值范围为整数0到200)是用æ¥è¡¨ç¤ºhost和驱动的优先级。ä¸åŒçš„host内的驱动,hostçš„priority值越å°ï¼Œé©±åŠ¨åŠ 载优先级越高;åŒä¸€ä¸ªhost内驱动的priority值越å°ï¼ŒåŠ 载优先级越高。 diff --git a/zh-cn/device-dev/driver/driver-hdf-overview.md b/zh-cn/device-dev/driver/driver-hdf-overview.md index 601e10ee75cf3617d235f8d6a440edf984eb7b22..c5f99925f10b8992392e85d7e5a6ad0e1832b586 100755 --- a/zh-cn/device-dev/driver/driver-hdf-overview.md +++ b/zh-cn/device-dev/driver/driver-hdf-overview.md @@ -11,9 +11,11 @@ HDF(Hardware Driver Foundation)驱动框架,为驱动开å‘者æ供驱动 HDFé©±åŠ¨åŠ è½½åŒ…æ‹¬æŒ‰éœ€åŠ è½½å’ŒæŒ‰åºåŠ 载。 - æŒ‰éœ€åŠ è½½ + HDF框架支æŒé©±åŠ¨åœ¨ç³»ç»Ÿå¯åŠ¨è¿‡ç¨‹ä¸é»˜è®¤åŠ 载,或者在系统å¯åŠ¨ä¹‹åŽåŠ¨æ€åŠ 载。 - 按åºåŠ è½½ + HDF框架支æŒé©±åŠ¨åœ¨ç³»ç»Ÿå¯åŠ¨çš„过程ä¸æŒ‰ç…§é©±åŠ¨çš„ä¼˜å…ˆçº§è¿›è¡ŒåŠ è½½ã€‚ diff --git a/zh-cn/device-dev/driver/driver-hdf-servicemanage.md b/zh-cn/device-dev/driver/driver-hdf-servicemanage.md index 66ea6eaa54a3470268f5e1598ae713e343c42334..37f57ad77dbd05f9e2aaea70096b408c012eb57e 100755 --- a/zh-cn/device-dev/driver/driver-hdf-servicemanage.md +++ b/zh-cn/device-dev/driver/driver-hdf-servicemanage.md @@ -4,7 +4,7 @@ 驱动æœåŠ¡æ˜¯HDF驱动设备对外æ供能力的对象,由HDF框架统一管ç†ã€‚驱动æœåŠ¡ç®¡ç†ä¸»è¦åŒ…å«é©±åŠ¨æœåŠ¡çš„å‘布和获å–。 -HDF框架定义了驱动对外å‘布æœåŠ¡çš„ç–略,是由é…置文件ä¸çš„policyå—段æ¥æŽ§åˆ¶ï¼Œpolicyå—段的å–值范围以åŠå«ä¹‰å¦‚下: +HDF框架定义了驱动对外å‘布æœåŠ¡çš„ç–略,由é…置文件ä¸çš„policyå—段æ¥æŽ§åˆ¶ï¼Œpolicyå—段的å–值范围以åŠå«ä¹‰å¦‚下: @@ -39,26 +39,26 @@ typedef enum { | 方法 | æè¿° | | -------- | -------- | -| int32_t (\*Bind)(struct HdfDeviceObject \*deviceObject); | 需è¦é©±åŠ¨å¼€å‘者实现Bind函数,将自己的æœåŠ¡æŽ¥å£ç»‘定到HDF框架ä¸ã€‚ | -| const struct HdfObject \*DevSvcManagerClntGetService(const char \*svcName); | 获å–驱动的æœåŠ¡ã€‚ | -| int HdfDeviceSubscribeService(<br/>struct HdfDeviceObject \*deviceObject, const char \*serviceName, struct SubscriberCallback callback); | 订阅驱动的æœåŠ¡ã€‚ | +| int32_t (\*Bind)(struct HdfDeviceObject \*deviceObject) | 需è¦é©±åŠ¨å¼€å‘者实现Bind函数,将自己的æœåŠ¡æŽ¥å£ç»‘定到HDF框架ä¸ã€‚ | +| const struct HdfObject \*DevSvcManagerClntGetService(const char \*svcName)| 获å–驱动的æœåŠ¡ã€‚ | +|int HdfDeviceSubscribeService(<br/>struct HdfDeviceObject \*deviceObject, const char \*serviceName, struct SubscriberCallback callback) | 订阅驱动的æœåŠ¡ã€‚ | ## å¼€å‘æ¥éª¤ 驱动æœåŠ¡ç®¡ç†çš„å¼€å‘包括驱动æœåŠ¡çš„编写ã€ç»‘定ã€èŽ·å–或者订阅,详细æ¥éª¤å¦‚下。 -1. 驱动æœåŠ¡å‘布。 +1. 驱动æœåŠ¡ç¼–写。 ``` - 驱动æœåŠ¡ç»“构的定义 + // 驱动æœåŠ¡ç»“构的定义 struct ISampleDriverService { - struct IDeviceIoService ioService; // æœåŠ¡ç»“构的首个æˆå‘˜å¿…须是IDeviceIoService类型的æˆå‘˜ - int32_t (*ServiceA)(void); // 驱动的第一个æœåŠ¡æŽ¥å£ - int32_t (*ServiceB)(uint32_t inputCode); // 驱动的第二个æœåŠ¡æŽ¥å£ï¼Œæœ‰å¤šä¸ªå¯ä»¥ä¾æ¬¡å¾€ä¸‹ç´¯åŠ + struct IDeviceIoService ioService; // æœåŠ¡ç»“构的首个æˆå‘˜å¿…须是IDeviceIoService类型的æˆå‘˜ã€‚ + int32_t (*ServiceA)(void); // 驱动的第一个æœåŠ¡æŽ¥å£ã€‚ + int32_t (*ServiceB)(uint32_t inputCode); // 驱动的第二个æœåŠ¡æŽ¥å£ï¼Œæœ‰å¤šä¸ªå¯ä»¥ä¾æ¬¡å¾€ä¸‹ç´¯åŠ 。 }; - 驱动æœåŠ¡æŽ¥å£çš„实现 + // 驱动æœåŠ¡æŽ¥å£çš„实现 int32_t SampleDriverServiceA(void) { // 驱动开å‘者实现业务逻辑 @@ -77,7 +77,7 @@ typedef enum { ``` int32_t SampleDriverBind(struct HdfDeviceObject *deviceObject) { - // deviceObject为HDF框架给æ¯ä¸€ä¸ªé©±åŠ¨åˆ›å»ºçš„设备对象,用æ¥ä¿å˜è®¾å¤‡ç›¸å…³çš„ç§æœ‰æ•°æ®å’ŒæœåŠ¡æŽ¥å£ + // deviceObject为HDF框架给æ¯ä¸€ä¸ªé©±åŠ¨åˆ›å»ºçš„设备对象,用æ¥ä¿å˜è®¾å¤‡ç›¸å…³çš„ç§æœ‰æ•°æ®å’ŒæœåŠ¡æŽ¥å£ã€‚ if (deviceObject == NULL) { HDF_LOGE("Sample device object is null!"); return -1; @@ -92,10 +92,11 @@ typedef enum { ``` 3. 驱动æœåŠ¡èŽ·å–。 - 驱动æœåŠ¡çš„获å–有两ç§æ–¹å¼ï¼ŒHDF框架æ供接å£ç›´æŽ¥èŽ·å–å’ŒHDF框架æ供订阅机制获å–。 + 驱动æœåŠ¡çš„获å–有两ç§æ–¹å¼ï¼ŒHDF框架æ供接å£ç›´æŽ¥èŽ·å–和订阅机制获å–。 - 通过HDF接å£ç›´æŽ¥èŽ·å– - 当明确驱动已ç»åŠ 载完æˆæ—¶ï¼ŒèŽ·å–该驱动的æœåŠ¡å¯ä»¥é€šè¿‡HDF框架æ供的能力接å£ç›´æŽ¥èŽ·å–,如下所示: + + 当明确驱动已ç»åŠ 载完æˆæ—¶ï¼ŒèŽ·å–该驱动的æœåŠ¡å¯ä»¥é€šè¿‡HDF框架æ供的能力接å£ç›´æŽ¥èŽ·å–,如下所示: ``` @@ -108,7 +109,8 @@ typedef enum { sampleService->ServiceB(5); ``` - 通过HDFæä¾›çš„è®¢é˜…æœºåˆ¶èŽ·å– - å½“å†…æ ¸æ€å¯¹é©±åŠ¨ï¼ˆåŒä¸€ä¸ªhostï¼‰åŠ è½½çš„æ—¶æœºä¸æ„ŸçŸ¥æ—¶ï¼Œå¯ä»¥é€šè¿‡HDF框架æ供的订阅机制æ¥è®¢é˜…è¯¥é©±åŠ¨ï¼Œå½“è¯¥é©±åŠ¨åŠ è½½å®Œæˆæ—¶ï¼ŒHDF框架会将被订阅的驱动æœåŠ¡å‘布给订阅者,实现方å¼å¦‚下所示: + + å½“å†…æ ¸æ€å¯¹é©±åŠ¨ï¼ˆåŒä¸€ä¸ªhostï¼‰åŠ è½½çš„æ—¶æœºä¸æ„ŸçŸ¥æ—¶ï¼Œå¯ä»¥é€šè¿‡HDF框架æ供的订阅机制æ¥è®¢é˜…è¯¥é©±åŠ¨ã€‚å½“è¯¥é©±åŠ¨åŠ è½½å®Œæˆæ—¶ï¼ŒHDF框架会将被订阅的驱动æœåŠ¡å‘布给订阅者,实现方å¼å¦‚下所示: ``` diff --git a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md index a531d05d658dfbc00f47cbffad15220746a97222..94704359fc2492e9ddc456669e3827b4ca0f3d19 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md @@ -52,7 +52,7 @@ Camera模å—主è¦ç”¨ä»¥ç›¸æœºé¢„览ã€æ‹ç…§ã€è§†é¢‘æµç‰åœºæ™¯ä¸‹å¯¹ç›¸æœº | 功能æè¿° | 接å£å称 | | ---------------------------- | ------------------------------------------------------------ | | 获å–æµæŽ§åˆ¶å™¨ | CamRetCode GetStreamOperator(<br>const OHOS::sptr<IStreamOperatorCallback> &callback,<br>OHOS::sptr<IStreamOperator> &streamOperator) | - | 更新设备控制å‚æ•° | CamRetCode UpdateSettings(const std::shared_ptr<CameraSetting> &settingss) | + | 更新设备控制å‚æ•° | CamRetCode UpdateSettings(const std::shared_ptr<CameraSetting> &settings) | | 设置Result回调模å¼å’Œå›žè°ƒå‡½æ•° | CamRetCode SetResultMode(const ResultCallbackMode &mode) | | 获å–使能的ResultMeta | CamRetCode GetEnabledResults(std::vector<MetaType> &results) | | 使能具体的ResultMeta | CamRetCode EnableResult(const std::vector<MetaType> &results) | @@ -730,7 +730,7 @@ Camera驱动的开å‘过程主è¦åŒ…å«ä»¥ä¸‹æ¥éª¤ï¼š "-o | --offline stream offline test\n" "-c | --capture capture one picture\n" "-w | --set WB Set white balance Cloudy\n" - "-v | --video capture Viedeo of 10s\n" + "-v | --video capture Video of 10s\n" "-a | --Set AE Set Auto exposure\n" "-f | --Set Flashlight Set flashlight ON 5s OFF\n" "-q | --quit stop preview and quit this app\n"); diff --git a/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md b/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md index 4ae5304c6e6ad49648d23e5b7834770faa2fc326..04dfe33a0f2735bd355b6dea4b3c24da14410310 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-lcd-des.md @@ -319,7 +319,7 @@ static struct PanelInfo g_panelInfo = { .vsw = VERTICAL_SYNC_WIDTH, /* vertical sync width */ .frameRate = FRAME_RATE, /* frame rate */ .intfType = MIPI_DSI, /* panel interface type */ - .intfSync = OUTPUT_USER, /* output timming type */ + .intfSync = OUTPUT_USER, /* output timing type */ /* mipi config info */ .mipi = { DSI_2_LANES, DSI_VIDEO_MODE, VIDEO_BURST_MODE, FORMAT_RGB_24_BIT }, /* backlight config info */ diff --git a/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md b/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md index 7b819df8c65a115577af3ee3af3817dc6f75413b..26620ea9c30f099379e0312d8fbcb20566d4a53e 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-sensor-des.md @@ -1,5 +1,5 @@ # Sensor - + ## 概述 @@ -8,7 +8,7 @@ Sensor驱动模型å±è”½ç¡¬ä»¶å™¨ä»¶å·®å¼‚,为上层SensoræœåŠ¡ç³»ç»Ÿæ供稳定的Sensor基础能力接å£ï¼ŒåŒ…括Sensor列表查询ã€Sensorå¯åœã€Sensor订阅åŠå–消订阅,Sensorå‚æ•°é…ç½®ç‰åŠŸèƒ½ã€‚Sensor设备驱动的开å‘是基于HDF驱动框架基础上,结åˆæ“作系统适é…层(OSAL)和平å°é©±åŠ¨æŽ¥å£ï¼ˆæ¯”如I2C/SPI/UART总线ç‰å¹³å°èµ„æºï¼‰èƒ½åŠ›ï¼Œå±è”½ä¸åŒæ“作系统和平å°æ€»çº¿èµ„æºå·®å¼‚,实现Sensor驱动“一次开å‘,多系统部署â€çš„ç›®æ ‡ã€‚Sensor驱动模型如图1所示。 **图 1** Sensor驱动模型图 - +  ### 基本概念 @@ -64,16 +64,16 @@ Sensor驱动模型对外开放的API接å£èƒ½åŠ›çš„具体实现请å‚考: **表 1** 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(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æ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ï¼Œç³»ç»Ÿä¼šå°†èŽ·å–åˆ°çš„ä¼ æ„Ÿå™¨æ•°æ®ä¸ŠæŠ¥ç»™è®¢é˜…者。 | -| int32_t Unregister(int32_t groupId, RecordDataCallback cb) | è®¢é˜…è€…æ ¹æ®groupIdå’Œå›žè°ƒå‡½æ•°æ³¨é”€å¯¹åº”è®¢é˜…è€…çš„ä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ã€‚ | +| int32_t Enable(int32_t sensorId) | ä½¿èƒ½æŒ‡å®šä¼ æ„Ÿå™¨è®¾å¤‡ï¼Œåªæœ‰æ•°æ®è®¢é˜…è€…ä½¿èƒ½ä¼ æ„Ÿå™¨åŽï¼Œæ‰èƒ½èŽ·å–è®¢é˜…çš„ä¼ æ„Ÿå™¨æ•°æ®ã€‚ | +| int32_t Disable(int32_t sensorId) | åŽ»ä½¿èƒ½æŒ‡å®šä¼ æ„Ÿå™¨è®¾å¤‡ã€‚ | +| 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æ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ï¼Œç³»ç»Ÿä¼šå°†èŽ·å–åˆ°çš„ä¼ æ„Ÿå™¨æ•°æ®ä¸ŠæŠ¥ç»™è®¢é˜…者。 | +| int32_t Unregister(int32_t groupId, RecordDataCallback cb) | è®¢é˜…è€…æ ¹æ®groupIdå’Œå›žè°ƒå‡½æ•°æ³¨é”€å¯¹åº”è®¢é˜…è€…çš„ä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ã€‚ | @@ -81,7 +81,7 @@ Sensor驱动模型对驱动开å‘者开放的功能接å£ï¼Œé©±åŠ¨å¼€å‘è€…æ— **表2** Sensor驱动模型对驱动开å‘者开放的功能接å£åˆ—表 -| 接å£å | 功能æè¿° | +| 接å£å | 功能æè¿° | | ----- | -------- | | int32_t AddSensorDevice(const struct SensorDeviceInfo *deviceInfo) | æ·»åŠ å½“å‰ç±»åž‹çš„ä¼ æ„Ÿå™¨è®¾å¤‡åˆ°ä¼ æ„Ÿå™¨è®¾å¤‡ç®¡ç†ã€‚ | | int32_t DeleteSensorDevice(const struct SensorBasicInfo *sensorBaseInfo) | åˆ é™¤ä¼ æ„Ÿå™¨è®¾å¤‡ç®¡ç†é‡ŒæŒ‡å®šçš„ä¼ æ„Ÿå™¨è®¾å¤‡ã€‚ | @@ -101,7 +101,7 @@ Sensor驱动模型è¦æ±‚驱动开å‘者实现的接å£åŠŸèƒ½ï¼Œè¯·å‚考: **表 3** Sensor驱动模型è¦æ±‚驱动开å‘者实现的接å£åˆ—表 -| 接å£å | 功能æè¿° | +| 接å£å | 功能æè¿° | | ----- | -------- | | int32_t init(void) | ä¼ æ„Ÿå™¨è®¾å¤‡æŽ¢æµ‹æˆåŠŸåŽï¼Œéœ€è¦å¯¹ä¼ 感器设备åˆå§‹åŒ–é…置。 | | int32_t Enable(void) | æ ¹æ®å½“å‰ä¼ 感器设备的HCSé…置,下å‘ä¼ æ„Ÿå™¨è®¾å¤‡ä½¿èƒ½æ“作组的寄å˜å™¨é…置。 | @@ -545,7 +545,7 @@ void HdfSensorTest::SetUpTestCase() { g_sensorDev = NewSensorInterfaceInstance(); if (g_sensorDev == nullptr) { - printf("test sensorHdi get Module instance failed\n\r"); + printf("test sensor get module instance failed\n\r"); } } /* 用例资æºé‡Šæ”¾ */ diff --git a/zh-cn/device-dev/driver/driver-peripherals-usb-des.md b/zh-cn/device-dev/driver/driver-peripherals-usb-des.md index cfe37f34088f73fa7bba2541fc1a478712fff200..5292ee054ba428f785fdb8a9cef3197e407fd121 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-usb-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-usb-des.md @@ -468,7 +468,7 @@ static int AcmAllocNotifyRequest(struct AcmDevice *acm) return HDF_SUCCESS; error: - AcmFreeNotifyReqeust(acm); + AcmFreeNotifyRequest(acm); return ret; } @@ -592,7 +592,7 @@ static void AcmFreeRequests(struct AcmDevice *acm) g_syncRequest = NULL; } AcmFreeReadRequests(acm); - AcmFreeNotifyReqeust(acm); + AcmFreeNotifyRequest(acm); AcmFreeWriteRequests(acm); AcmWriteBufFree(acm); } @@ -631,7 +631,7 @@ static int32_t AcmAllocRequests(struct AcmDevice *acm) return HDF_SUCCESS; error_alloc_read_req: - AcmFreeNotifyReqeust(acm); + AcmFreeNotifyRequest(acm); error_alloc_int_req: AcmFreeWriteRequests(acm); error_alloc_write_req: @@ -1112,7 +1112,7 @@ err_submit_req: err_start_io: UsbFreeReadRequests(acm); err_alloc_read_reqs: - UsbFreeNotifyReqeust(acm); + UsbFreeNotifyRequest(acm); err_alloc_notify_req: UsbFreeWriteRequests(acm); err_alloc_write_reqs: @@ -1144,7 +1144,7 @@ static void UsbSerialRelease(struct AcmDevice *acm) g_syncRequest = NULL; } UsbFreeReadRequests(acm); - UsbFreeNotifyReqeust(acm); + UsbFreeNotifyRequest(acm); UsbFreeWriteRequests(acm); AcmWriteBufFree(acm); (void)UsbRawCloseDevice(acm->devHandle); diff --git a/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md b/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md index f4b2cd8874a6425b8ae8335de2f48bbfb409f92b..af09963c38ba1d415c4529b0610e16894276d016 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-vibrator-des.md @@ -57,9 +57,11 @@ | 接å£å | 功能æè¿° | | -------------------------------------- | ------------------------------------------------ | -| int32_t StartOnce(uint32_t duration) | 按照指定æŒç»æ—¶é—´è§¦å‘振动马达,duration为振动æŒç»æ—¶é•¿ã€‚ | -| int32_t Start(const char *effectType) | 按照指定预置效果å¯åŠ¨é©¬è¾¾ï¼ŒeffectType表示预置的预置效果。 | -| int32_t Stop(enum VibratorMode mode) | 按照指定的振动模å¼åœæ¢é©¬è¾¾æŒ¯åŠ¨ã€‚ | +| int32_t StartOnce(uint32_t duration) | 按照指定æŒç»æ—¶é—´è§¦å‘振动马达,duration为振动æŒç»æ—¶é•¿ã€‚ | +| int32_t Start(const char *effectType) | 按照指定预置效果å¯åŠ¨é©¬è¾¾ï¼ŒeffectType表示预置的预置效果。 | +| int32_t Stop(enum VibratorMode mode) | 按照指定的振动模å¼åœæ¢é©¬è¾¾æŒ¯åŠ¨ã€‚ | +| int32_t EnableVibratorModulation(uint32_t duration, int32_t intensity, int32_t frequency) | 按照指定振幅ã€é¢‘率ã€æŒç»æ—¶é—´è§¦å‘振动马达。duration为振动æŒç»æ—¶é•¿ï¼Œintensity为振动强度,frequency为振动频率。 | +| int32_t GetVibratorInfo(struct VibratorInfo **vibratorInfo); | 获å–马达信æ¯ï¼ŒåŒ…括是å¦æ”¯æŒæŒ¯å¹…和频率的设置åŠæŒ¯å¹…和频率的设置范围 。 | ### å¼€å‘æ¥éª¤ @@ -90,13 +92,13 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 int32_t cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { int32_t loop; - + for (loop = 0; loop < sizeof(g_vibratorCmdHandle) / sizeof(g_vibratorCmdHandle[0]); ++loop) { if ((cmd == g_vibratorCmdHandle[loop].cmd) && (g_vibratorCmdHandle[loop].func != NULL)) { return g_vibratorCmdHandle[loop].func(data, reply); } } - + return HDF_SUCCESS; } @@ -105,34 +107,34 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 { struct VibratorDriverData *drvData = NULL; CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(device, HDF_FAILURE); - + drvData = (struct VibratorDriverData *)OsalMemCalloc(sizeof(*drvData)); CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_ERR_MALLOC_FAIL); - + drvData->ioService.Dispatch = DispatchVibrator; drvData->device = device; device->service = &drvData->ioService; g_vibratorDrvData = drvData; - + return HDF_SUCCESS; } - + /* 马达驱动åˆå§‹åŒ–å…¥å£å‡½æ•°*/ int32_t InitVibratorDriver(struct HdfDeviceObject *device) { struct VibratorDriverData *drvData = NULL; - + drvData->mode = VIBRATOR_MODE_BUTT; drvData->state = VIBRATOR_STATE_IDLE; ...... if (CreateVibratorHaptic(device) != HDF_SUCCESS) { - HDF_LOGE("%s: init workQueue fail!", __func__); + HDF_LOGE("%s: init workQueue failed!", __func__); return HDF_FAILURE; } - + return HDF_SUCCESS; } - + /* 释放马达驱动åˆå§‹åŒ–时分é…çš„èµ„æº */ void ReleaseVibratorDriver(struct HdfDeviceObject *device) { @@ -168,7 +170,7 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 - 创建马达效果模型。 - ```hcs + ```c /* 创建马达效果模型,分é…资æºï¼Œè§£æžé©¬è¾¾æ•ˆæžœHCSé…ç½® */ int32_t CreateVibratorHaptic(struct HdfDeviceObject *device) { @@ -181,7 +183,7 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 hapticData->supportHaptic = false; if (OsalMutexInit(&hapticData->mutex) != HDF_SUCCESS) { - HDF_LOGE("%s: fail to init mutex", __func__); + HDF_LOGE("%s: failed to init mutex", __func__); goto EXIT; } @@ -189,7 +191,7 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 /* 解æžé©¬è¾¾æ•ˆæžœHCSé…ç½® */ if (ParserVibratorHapticConfig(device->property) != HDF_SUCCESS) { - HDF_LOGE("%s: parser haptic config fail!", __func__); + HDF_LOGE("%s: parser haptic config failed!", __func__); goto EXIT; } @@ -235,7 +237,7 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 马达硬件æœåŠ¡è°ƒç”¨StartOnce接å£åŠ¨æ€é…ç½®æŒç»æŒ¯åŠ¨æ—¶é—´ï¼›è°ƒç”¨StartEffect接å£å¯åŠ¨é™æ€é…置的振动效果,为驱动开å‘者æ供抽象的é…置接å£èƒ½åŠ›ã€‚ ```c - /* 按照指定æŒç»æ—¶é—´è§¦å‘振动马达,duration为振动æŒç»æ—¶é•¿ */ + /* 按照指定æŒç»æ—¶é—´è§¦å‘振动马达,duration为振动æŒç»æ—¶é•¿ã€‚ */ static int32_t StartOnce(struct HdfSBuf *data, struct HdfSBuf *reply) { uint32_t duration; @@ -250,14 +252,14 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 /* æ ¹æ®æŒ¯åŠ¨æ•ˆæžœçš„模å¼åˆ›å»ºå®šæ—¶å™¨ */ ret = StartHaptic(&config); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: start haptic fail!", __func__); + HDF_LOGE("%s: start haptic failed!", __func__); return ret; } return HDF_SUCCESS; } - /* 按照预置效果å¯åŠ¨é©¬è¾¾ï¼ŒeffectType表示预置的预置效果 */ + /* 按照预置效果å¯åŠ¨é©¬è¾¾ï¼ŒeffectType表示预置的预置效果。 */ static int32_t StartEffect(struct HdfSBuf *data, struct HdfSBuf *reply) { int32_t ret; @@ -272,7 +274,7 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 ret = StartHaptic(&config); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: start haptic fail!", __func__); + HDF_LOGE("%s: start haptic failed!", __func__); return ret; } @@ -287,10 +289,10 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 struct VibratorDriverData *drvData = GetVibratorDrvData(); (void)reply; ...... - /* åœæ¢é©¬è¾¾æ•ˆæžœæŒ¯åŠ¨ï¼Œé”€æ¯é©¬è¾¾å®šæ—¶å™¨ */ + /* åœæ¢é©¬è¾¾æ•ˆæžœæŒ¯åŠ¨ï¼Œé”€æ¯é©¬è¾¾å®šæ—¶å™¨ã€‚ */ ret = StopHaptic(); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: stop haptic fail!", __func__); + HDF_LOGE("%s: stop haptic failed!", __func__); return ret; } @@ -300,6 +302,58 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 return HDF_SUCCESS; } + + /* 按照指定振幅ã€é¢‘率ã€æŒç»æ—¶é—´è§¦å‘振动马达。duration为振动æŒç»æ—¶é•¿ï¼Œintensity为振动强度,frequency为振动频率。 */ + static int32_t EnableModulationParameter(struct HdfSBuf *data, struct HdfSBuf *reply) + { + (void)reply; + struct VibratorEffectCfg config; + struct VibratorDriverData *drvData; + uint32_t duration; + int32_t intensity; + int32_t frequency; + int32_t ret; + ..... + (void)OsalMutexLock(&drvData->mutex); + drvData->mode = VIBRATOR_MODE_ONCE; + (void)OsalMutexUnlock(&drvData->mutex); + /* 设置振幅和频率 */ + ret = drvData->ops.SetParameter(intensity, frequency); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set parameter failed", __func__); + return HDF_FAILURE; + } + + config.cfgMode = VIBRATOR_MODE_ONCE; + config.duration = duration; + config.effect = NULL; + + ret = StartHaptic(&config); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: start haptic failed", __func__); + return HDF_FAILURE; + } + + return HDF_SUCCESS; + } + + /* 获å–马达信æ¯ï¼ŒåŒ…括是å¦æ”¯æŒæŒ¯å¹…和频率的设置åŠæŒ¯å¹…和频率的设置范围。 */ + static int32_t GetVibratorInfo(struct HdfSBuf *data, struct HdfSBuf *reply) + { + (void)data; + struct VibratorDriverData *drvData; + + drvData = GetVibratorDrvData(); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_ERR_INVALID_PARAM); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(reply, HDF_ERR_INVALID_PARAM); + + if (!HdfSbufWriteBuffer(reply, &drvData->vibratorInfo, sizeof(drvData->vibratorInfo))) { + HDF_LOGE("%s: write sbuf failed", __func__); + return HDF_FAILURE; + } + + return HDF_SUCCESS; + } ``` 4. 马达驱动模型æ供给开å‘者马达驱动差异化接å£ï¼Œå¼€å‘者实现差异化接å£ã€‚ @@ -319,50 +373,181 @@ Vibrator驱动模型为上层马达硬件æœåŠ¡å±‚æ供稳定的马达控制能 drvData->ops.Start = ops->Start; drvData->ops.StartEffect = ops->StartEffect; drvData->ops.Stop = ops->Stop; + drvData->ops.SetParameter = ops->SetParameter; + (void)OsalMutexUnlock(&drvData->mutex); + + return HDF_SUCCESS; + } + + /* 注册马达信æ¯æŽ¥å£ */ + int32_t RegisterVibratorInfo(struct VibratorInfo *vibratorInfo) + { + struct VibratorDriverData *drvData = GetVibratorDrvData(); + + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(vibratorInfo, HDF_FAILURE); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); + + (void)OsalMutexLock(&drvData->mutex); + if (memcpy_s(&drvData->vibratorInfo, sizeof(drvData->vibratorInfo), vibratorInfo, sizeof(*vibratorInfo)) != EOK) { + HDF_LOGE("%s: Memcpy vibrator config failed", __func__); + return HDF_FAILURE; + } (void)OsalMutexUnlock(&drvData->mutex); return HDF_SUCCESS; } ``` + + - 马达驱动模型æ供给开å‘者马达驱动差异化接å£ï¼Œå…·ä½“实现如下: ```c - /* 按照指定æŒç»æ—¶é—´è§¦å‘线性马达的振动 */ - static int32_t StartLinearVibrator() + /* 按照指定的振动模å¼åœæ¢é©¬è¾¾çš„振动 */ + static int32_t StopModulationParameter() { - int32_t ret; - struct VibratorLinearDriverData *drvData = GetLinearVibratorData(); - CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); - ...... - ret = GpioWrite(drvData->gpioNum, GPIO_VAL_LOW); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: pull gpio%d to %d level failed", __func__, drvData->gpioNum, GPIO_VAL_LOW); - return ret; + uint8_t value[DRV2605L_VALUE_BUTT]; + struct Drv2605lDriverData *drvData = NULL; + drvData = GetDrv2605lDrvData(); + + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData->drv2605lCfgData, HDF_FAILURE); + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_MODE; + value[DRV2605L_VALUE_INDEX] = (uint8_t)DRV2605_MODE_STANDBY; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return HDF_FAILURE; + } + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_RTPIN; + value[DRV2605L_VALUE_INDEX] = (uint8_t)&drvData->drv2605lCfgData->vibratorAttr.defaultIntensity; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + } + + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_LRARESON; + value[DRV2605L_VALUE_INDEX] = (uint8_t)&drvData->drv2605lCfgData->vibratorAttr.defaultFrequency; + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); } - return HDF_SUCCESS; - } - /* 按照预置振动效果触å‘线性马达的振动 */ - static int32_t StartEffectLinearVibrator(uint32_t effectType) - { - (void)effectType; - HDF_LOGE("%s: vibrator set build-in effect no support!", __func__); return HDF_SUCCESS; } - /* 按照指定的振动模å¼åœæ¢çº¿æ€§é©¬è¾¾çš„振动 */ - static int32_t StopLinearVibrator() + /* 设置马达振幅和频率 */ + static void SetModulationParameter(int32_t intensity, int32_t frequency) { - int32_t ret; - struct VibratorLinearDriverData *drvData = GetLinearVibratorData(); + uint8_t value[DRV2605L_VALUE_BUTT]; + struct Drv2605lDriverData *drvData = NULL; + drvData = GetDrv2605lDrvData(); + CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(drvData, HDF_FAILURE); - ...... - ret = GpioWrite(drvData->gpioNum, GPIO_VAL_HIGH); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: pull gpio%d to %d level failed", __func__, drvData->gpioNum, GPIO_VAL_HIGH); - return ret; + + if (intensity != 0) { + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_RTPIN; + value[DRV2605L_VALUE_INDEX] = (uint8_t)INTENSITY_MAPPING_VALUE(intensity); + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return; + } + } else { + HDF_LOGD("%s: the setting of intensity 0 is not supported and \ + will be set as the system default intensity", __func__); + } + + if (frequency != 0) { + value[DRV2605L_ADDR_INDEX] = (uint8_t)DRV2605_REG_LRARESON; + value[DRV2605L_VALUE_INDEX] = (uint8_t)FREQUENCY_MAPPING_VALUE(frequency); + if (WriteDrv2605l(&drvData->drv2605lCfgData->vibratorBus.i2cCfg, value, sizeof(value)) != HDF_SUCCESS) { + HDF_LOGE("%s: i2c addr [%0X] write failed", __func__, value[DRV2605L_ADDR_INDEX]); + return; + } + } else { + HDF_LOGD("%s: the setting of frequency 0 is not supported and \ + will be set as the system default frequency", __func__); } - return HDF_SUCCESS; } - ``` \ No newline at end of file + ``` + +### è°ƒæµ‹éªŒè¯ + +驱动开å‘完æˆåŽï¼Œåœ¨ä¼ 感器å•å…ƒæµ‹è¯•é‡Œé¢å¼€å‘自测试用例,验è¯é©±åŠ¨åŸºæœ¬åŠŸèƒ½ã€‚测试环境采用开å‘者自测试平å°ã€‚ + +``` +/* 用例执行å‰ï¼Œåˆå§‹åŒ–马达接å£å®žä¾‹ã€‚ */ +void HdfVibratorTest::SetUpTestCase() +{ + g_vibratorDev = NewVibratorInterfaceInstance(); +} +/* 用例资æºé‡Šæ”¾ */ +void HdfVibratorTest::TearDownTestCase() +{ + if(g_vibratorDev != nullptr){ + FreeVibratorInterfaceInstance(); + g_vibratorDev = nullptr; + } +} + +/* 测试å•æ¬¡æŒ¯åŠ¨ */ +HWTEST_F(HdfVibratorTest, PerformOneShotVibratorDuration_001, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->StartOnce(g_duration); + EXPECT_EQ(startRet, HDF_SUCCESS); + + OsalMSleep(g_sleepTime1); + + int32_t endRet = g_vibratorDev->Stop(VIBRATOR_MODE_ONCE); + EXPECT_EQ(endRet, HDF_SUCCESS); +} +/* 测试预置效果振动 */ +HWTEST_F(HdfVibratorTest, ExecuteVibratorEffect_002, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->Start(g_builtIn); + EXPECT_EQ(startRet, HDF_SUCCESS); + + OsalMSleep(g_sleepTime1); + + int32_t endRet = g_vibratorDev->Stop(VIBRATOR_MODE_PRESET); + EXPECT_EQ(endRet, HDF_SUCCESS); +} +/* 获å–马达信æ¯ï¼ŒåŒ…括是å¦æ”¯æŒæŒ¯å¹…和频率的设置åŠæŒ¯å¹…和频率的设置范围。 */ +HWTEST_F(HdfVibratorTest, GetVibratorInfo_001, TestSize.Level1) +{ + ASSERT_NE(nullptr, g_vibratorDev); + + int32_t startRet = g_vibratorDev->GetVibratorInfo(&g_vibratorInfo); + EXPECT_EQ(startRet, HDF_SUCCESS); + EXPECT_NE(g_vibratorInfo, nullptr); + + printf("intensity = %d, intensityMaxValue = %d, intensityMinValue = %d\n\t", + g_vibratorInfo->isSupportIntensity, g_vibratorInfo->intensityMaxValue, g_vibratorInfo->intensityMinValue); + printf("frequency = %d, frequencyMaxValue = %d, frequencyMinValue = %d\n\t", + g_vibratorInfo->isSupportFrequency, g_vibratorInfo->frequencyMaxValue, g_vibratorInfo->frequencyMinValue); +} +/* 按照指定振幅ã€é¢‘率ã€æŒç»æ—¶é—´è§¦å‘振动马达。duration为振动æŒç»æ—¶é•¿ï¼Œintensity为振动强度,frequency为振动频率。 */ +HWTEST_F(HdfVibratorTest, EnableVibratorModulation_001, TestSize.Level1) +{ + int32_t startRet; + ASSERT_NE(nullptr, g_vibratorDev); + EXPECT_GT(g_duration, 0); + + if ((g_vibratorInfo->isSupportIntensity == 1) || (g_vibratorInfo->isSupportFrequency == 1)) { + EXPECT_GE(g_intensity1, g_vibratorInfo->intensityMinValue); + EXPECT_LE(g_intensity1, g_vibratorInfo->intensityMaxValue); + EXPECT_GE(g_frequency1, g_vibratorInfo->frequencyMinValue); + EXPECT_LE(g_frequency1, g_vibratorInfo->frequencyMaxValue); + + startRet = g_vibratorDev->EnableVibratorModulation(g_duration, g_intensity1, g_frequency1); + EXPECT_EQ(startRet, HDF_SUCCESS); + OsalMSleep(g_sleepTime1); + startRet = g_vibratorDev->Stop(VIBRATOR_MODE_ONCE); + EXPECT_EQ(startRet, HDF_SUCCESS); + } +} +``` + diff --git a/zh-cn/device-dev/driver/driver-platform-hdmi-develop.md b/zh-cn/device-dev/driver/driver-platform-hdmi-develop.md index fd127d7c13956bca29197a015d8438b579ac6b40..5f3d7c47d7287f8ff33e8b5abc550f81141e6f75 100755 --- a/zh-cn/device-dev/driver/driver-platform-hdmi-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-hdmi-develop.md @@ -100,7 +100,7 @@ struct HdmiCntlrOps { | phyOutputSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**cfg**: é…ç½®ä¿¡æ¯ | æ— | æ— | 设置物ç†å±‚é…ç½®ä¿¡æ¯ | | blackDataSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能 | æ— | æ— | è®¾ç½®é»‘å± | | videoMuteEnable | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能 | æ— | æ— | 使能/去使能videoé™éŸ³ | -| videoPathSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**attr**:é…置信æ¯| æ— | æ— | 设置viedo通路é…ç½®ä¿¡æ¯ | +| videoPathSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**attr**:é…置信æ¯| æ— | æ— | 设置video通路é…ç½®ä¿¡æ¯ | |audioMuteEnable | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能 | æ— | æ— | 使能/去使能audioé™éŸ³ | | avmuteSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能| æ— | æ— | 使能/去使能声音图åƒæ¶ˆéš | | ddcTransfer | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**ddcCfg**:DDCé…ç½®å‚æ•° |**ddcCfg**:DDCé…ç½®å‚æ•° |HDF_STATUSç›¸å…³çŠ¶æ€ | 读写DDCæ•°æ® | @@ -108,9 +108,9 @@ struct HdmiCntlrOps { | scdcSourceScrambleSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能 | æ— | HDF_STATUSç›¸å…³çŠ¶æ€ | 使能/去使能sourceç«¯çš„åŠ æ‰° | | frlEnable | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**enable**: bool,使能/去使能 | æ— | HDF_STATUSç›¸å…³çŠ¶æ€ | 使能/去使能FRL | | audioNctsSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**cfg**:N/CTSé…ç½®å‚æ•° | æ— | HDF_STATUSç›¸å…³çŠ¶æ€ | 设置audioçš„N/CTSä¿¡æ¯ | -| frlTrainingConfigSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**cfg**:FRL Traningé…ç½®å‚æ•° | æ— | æ— | 设置FRL Traningé…ç½®ä¿¡æ¯ | -| frlTrainingStart | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | æ— | æ— | 开始FRL Traningæµç¨‹ | -| frlGetTriningRslt | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | **rslt**:FRL Traning结果 | æ— | 获å–FRL Traning结果 | +| frlTrainingConfigSet | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**cfg**:FRL Trainingé…ç½®å‚æ•° | æ— | æ— | 设置FRL Trainingé…ç½®ä¿¡æ¯ | +| frlTrainingStart | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | æ— | æ— | 开始FRL Trainingæµç¨‹ | +| frlGetTriningRslt | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | **rslt**:FRL Training结果 | æ— | 获å–FRL Training结果 | | hdcpRegInit | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | æ— | æ— | åˆå§‹åŒ–HDCPæµç¨‹ç›¸å…³çš„寄å˜å™¨ | |hdcpGenerateAksvAndAn |**cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器 | æ— | HDF_STATUSç›¸å…³çŠ¶æ€ | HDCPæµç¨‹ä¸ç”Ÿæˆaksvå’Œan | | hdcpOptReg | **cntlr**ï¼šç»“æž„ä½“æŒ‡é’ˆï¼Œæ ¸å¿ƒå±‚HDMI控制器<br />**type**: æ“作类型<br />**data**: 寄å˜å™¨æ•°æ®<br />**len**: æ•°æ®é•¿åº¦ | **data**: 寄å˜å™¨æ•°æ® | HDF_STATUSç›¸å…³çŠ¶æ€ | HDCPæµç¨‹ä¸è¯»å†™ç›¸å…³å¯„å˜å™¨ | @@ -412,4 +412,4 @@ HDMI模å—适é…的三个环节是é…置属性文件,实例化驱动入å£ä»¥ ``` >  **说明:**<br> - > 所有强制转æ¢èŽ·å–相应对象的æ“作å‰æ是在Init函数ä¸å…·å¤‡å¯¹åº”赋值的æ“作。 \ No newline at end of file + > 所有强制转æ¢èŽ·å–相应对象的æ“作å‰æ是在Init函数ä¸å…·å¤‡å¯¹åº”赋值的æ“作。 diff --git a/zh-cn/device-dev/driver/driver-platform-i3c-des.md b/zh-cn/device-dev/driver/driver-platform-i3c-des.md index 5ead2c6ef21e842f8099560166c0b51c8b2e71a1..24d7f0bd02a15e1942680cd80a19556bbdc2d0f3 100755 --- a/zh-cn/device-dev/driver/driver-platform-i3c-des.md +++ b/zh-cn/device-dev/driver/driver-platform-i3c-des.md @@ -268,7 +268,7 @@ int32_t I3cTestRequestIbi(void) } ret = I3cRequestIbi(i3cHandle, 0x3F, TestI3cIbiFunc, 16); if (ret != 0) { - HDF_LOGE("%s: Requset IBI failed!", __func__); + HDF_LOGE("%s: Request IBI failed!", __func__); return -1; } @@ -447,4 +447,4 @@ static int32_t TestCaseI3c(void) return 0; } -``` \ No newline at end of file +``` diff --git a/zh-cn/device-dev/driver/driver-platform-uart-develop.md b/zh-cn/device-dev/driver/driver-platform-uart-develop.md index d33491b40f4da5a80d90548d85f25e3dd63860ce..0a2abe456278938fe723ef09076f43f6045b9e87 100755 --- a/zh-cn/device-dev/driver/driver-platform-uart-develop.md +++ b/zh-cn/device-dev/driver/driver-platform-uart-develop.md @@ -188,7 +188,7 @@ UART模å—适é…HDF框架的三个环节是é…置属性文件,实例化驱动 #define UART_STATE_NOT_OPENED 0 #define UART_STATE_OPENING 1 #define UART_STATE_USEABLE 2 - #define UART_STATE_SUSPENED 3 + #define UART_STATE_SUSPENDED 3 uint32_t flags; // 状æ€æ ‡å¿— #define UART_FLG_DMA_RX (1 << 0) #define UART_FLG_DMA_TX (1 << 1) diff --git a/zh-cn/device-dev/get-code/sourcecode-acquire.md b/zh-cn/device-dev/get-code/sourcecode-acquire.md index a75e79c97397f982b94c356d3172d74570d245ca..537e80b50862e7f5f431b33f9353cbc67786c036 100644 --- a/zh-cn/device-dev/get-code/sourcecode-acquire.md +++ b/zh-cn/device-dev/get-code/sourcecode-acquire.md @@ -195,12 +195,12 @@ OpenHarmony是由开放原åå¼€æºåŸºé‡‘会(OpenAtom Foundation)åµåŒ–åŠ | 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æ ¡éªŒç ** | -| å…¨é‡ä»£ç 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 | [站点](../../release-notes/OpenHarmony-v3.2-beta1.md) | - | +| å…¨é‡ä»£ç Betaç‰ˆæœ¬ï¼ˆæ ‡å‡†ã€è½»é‡å’Œå°åž‹ç³»ç»Ÿï¼‰ | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256) | +| RK3568æ ‡å‡†ç³»ç»Ÿè§£å†³æ–¹æ¡ˆï¼ˆäºŒè¿›åˆ¶ï¼‰ | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz.sha256) | +| Hi3861解决方案(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) | +| Hi3516解决方案-LiteOS(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256) | +| Hi3516解决方案-Linux(二进制) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256) | +| RELEASE-NOTES | 3.2 Beta2 | [站点](../../release-notes/OpenHarmony-v3.2-beta2.md) | - | | **编译工具链** | **版本信æ¯** | **下载站点** | **SHA256æ ¡éªŒç ** | | 编译工具链获å–æ¸…å• | - | [站点](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/) | - | diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 4f32b8e9e9822ea707a23a10f9e378c5f9b97e69..fdeb7b452e6580d5db0f55d9959528bacc4e740a 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -6,10 +6,7 @@ - åŸºç¡€å†…æ ¸ - [ä¸æ–管ç†](kernel-mini-basic-interrupt.md) - [任务管ç†](kernel-mini-basic-task.md) - - 内å˜ç®¡ç† - - [基本概念](kernel-mini-basic-memory-basic.md) - - [é™æ€å†…å˜](kernel-mini-basic-memory-static.md) - - [动æ€å†…å˜](kernel-mini-basic-memory-dynamic.md) + - [内å˜ç®¡ç†](kernel-mini-basic-memory.md) - å†…æ ¸é€šä¿¡æœºåˆ¶ - [事件](kernel-mini-basic-ipc-event.md) - [互斥é”](kernel-mini-basic-ipc-mutex.md) @@ -21,23 +18,16 @@ - [C++支æŒ](kernel-mini-extend-support.md) - [CPUå 用率](kernel-mini-extend-cpup.md) - [动æ€åŠ è½½](kernel-mini-extend-dynamic-loading.md) - - 文件系统 - - [FAT](kernel-mini-extend-file-fat.md) - - [LittleFS](kernel-mini-extend-file-lit.md) + - [文件系统](kernel-mini-extend-file.md) - å†…æ ¸è°ƒæµ‹ - - 内å˜è°ƒæµ‹ - - [内å˜ä¿¡æ¯ç»Ÿè®¡](kernel-mini-memory-debug-mes.md) - - [内å˜æ³„æ¼æ£€æµ‹](kernel-mini-memory-debug-det.md) - - [踩内å˜æ£€æµ‹](kernel-mini-memory-debug-cet.md) + - [内å˜è°ƒæµ‹](kernel-mini-memory-debug.md) - [异常调测](kernel-mini-memory-exception.md) - [Trace调测](kernel-mini-memory-trace.md) - [LMS调测](kernel-mini-memory-lms.md) - 附录 - [å†…æ ¸ç¼–ç 规范](kernel-mini-appx-code.md) - [åŒå‘链表](kernel-mini-appx-data-list.md) - - æ ‡å‡†åº“æ”¯æŒ - - [CMSIS支æŒ](kernel-mini-appx-lib-cmsis.md) - - [POSIX支æŒ](kernel-mini-appx-lib-posix.md) + - [æ ‡å‡†åº“æ”¯æŒ](kernel-mini-appx-lib.md) - å°åž‹ç³»ç»Ÿå†…æ ¸ - [å†…æ ¸æ¦‚è¿°](kernel-small-overview.md) - å†…æ ¸å¯åŠ¨ @@ -71,13 +61,9 @@ - [虚拟动æ€å…±äº«åº“](kernel-small-bundles-share.md) - [è½»é‡çº§è¿›ç¨‹é—´é€šä¿¡](kernel-small-bundles-ipc.md) - 文件系统 + - [文件系统概述](kernel-small-bundles-fs.md) - [虚拟文件系统](kernel-small-bundles-fs-virtual.md) - - 支æŒçš„文件系统 - - [FAT](kernel-small-bundles-fs-support-fat.md) - - [JFFS2](kernel-small-bundles-fs-support-jffs2.md) - - [NFS](kernel-small-bundles-fs-support-nfs.md) - - [Ramfs](kernel-small-bundles-fs-support-ramfs.md) - - [Procfs](kernel-small-bundles-fs-support-procfs.md) + - [支æŒçš„文件系统](kernel-small-bundles-fs-support.md) - [适é…新的文件系统](kernel-small-bundles-fs-new.md) - 调测与工具 - Shell @@ -155,15 +141,7 @@ - [内å˜ä¿¡æ¯ç»Ÿè®¡](kernel-small-debug-memory-info.md) - [内å˜æ³„æ¼æ£€æµ‹](kernel-small-debug-memory-leak.md) - [踩内å˜æ£€æµ‹](kernel-small-debug-memory-corrupt.md) - - 用户æ€å†…å˜è°ƒæµ‹ - - [基本概念](kernel-small-debug-user-concept.md) - - [è¿è¡Œæœºåˆ¶](kernel-small-debug-user-function.md) - - 使用指导 - - [接å£è¯´æ˜Ž](kernel-small-debug-user-guide-api.md) - - [使用说明](kernel-small-debug-user-guide-use.md) - - [接å£è°ƒç”¨æ–¹å¼](kernel-small-debug-user-guide-use-api.md) - - [命令行å‚æ•°æ–¹å¼](kernel-small-debug-user-guide-use-cli.md) - - [常è§é—®é¢˜](kernel-small-debug-user-faqs.md) + - [用户æ€å†…å˜è°ƒæµ‹](kernel-small-debug-user.md) - å…¶ä»–å†…æ ¸è°ƒæµ‹æ‰‹æ®µ - [临终é—言](kernel-small-debug-trace-other-lastwords.md) - [常è§é—®é¢˜](kernel-small-debug-trace-other-faqs.md) diff --git a/zh-cn/device-dev/kernel/kernel-mini-appx-lib.md b/zh-cn/device-dev/kernel/kernel-mini-appx-lib.md index 8ce3db5c735a90579bb5693248740808c0664419..d2f4b54be58063e23b8f7fc145e96c555b4e27ca 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-appx-lib.md +++ b/zh-cn/device-dev/kernel/kernel-mini-appx-lib.md @@ -1,7 +1,500 @@ # æ ‡å‡†åº“æ”¯æŒ +## CMSISæ”¯æŒ -- **[CMSIS支æŒ](kernel-mini-appx-lib-cmsis.md)** -- **[POSIX支æŒ](kernel-mini-appx-lib-posix.md)** \ No newline at end of file +### 基本概念 + +[CMSIS](https://developer.arm.com/tools-and-software/embedded/cmsis)是Cortex Microcontroller Software Interface Standard(Cortex微控制器软件接å£æ ‡å‡†ï¼‰çš„缩写,是对于那些基于ARM Cortex处ç†å™¨çš„微控制器独立于供应商的硬件抽象层。它包å«å¤šä¸ªç»„件层,其ä¸ä¹‹ä¸€æ˜¯RTOS层,该层定义了一套通用åŠæ ‡å‡†åŒ–çš„RTOS API接å£ï¼Œå‡å°‘了应用开å‘者对特定RTOSçš„ä¾èµ–,方便用户软件的移æ¤é‡ç”¨ã€‚该套API有2个版本,分别为版本1(CMSIS-RTOS v1)和版本2(CMSIS-RTOS v2),OpenHarmony LiteOS-Mä»…æ供其版本2的实现。 + + +### å¼€å‘指导 + + +#### 接å£è¯´æ˜Ž + +CMSIS-RTOS v2æ供下é¢å‡ ç§åŠŸèƒ½ï¼ŒæŽ¥å£è¯¦ç»†ä¿¡æ¯å¯ä»¥æŸ¥çœ‹APIå‚考。 + + **表1** å†…æ ¸ä¿¡æ¯ä¸ŽæŽ§åˆ¶ + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osKernelGetInfo | 获å–RTOSå†…æ ¸ä¿¡æ¯ã€‚ | +| osKernelGetState | 获å–当å‰çš„RTOSå†…æ ¸çŠ¶æ€ã€‚ | +| osKernelGetSysTimerCount | 获å–RTOSå†…æ ¸ç³»ç»Ÿè®¡æ—¶å™¨è®¡æ•°ã€‚ | +| osKernelGetSysTimerFreq | 获å–RTOSå†…æ ¸ç³»ç»Ÿè®¡æ—¶å™¨é¢‘çŽ‡ã€‚ | +| osKernelInitialize | åˆå§‹åŒ–RTOSå†…æ ¸ã€‚ | +| osKernelLock | é”定RTOSå†…æ ¸è°ƒåº¦ç¨‹åºã€‚ | +| osKernelUnlock | 解é”RTOSå†…æ ¸è°ƒåº¦ç¨‹åºã€‚ | +| osKernelRestoreLock | æ¢å¤RTOSå†…æ ¸è°ƒåº¦ç¨‹åºé”定状æ€ã€‚ | +| osKernelResume | æ¢å¤RTOSå†…æ ¸è°ƒåº¦ç¨‹åºã€‚(暂未实现) | +| osKernelStart | å¯åŠ¨RTOSå†…æ ¸è°ƒåº¦ç¨‹åºã€‚ | +| osKernelSuspend | 挂起RTOSå†…æ ¸è°ƒåº¦ç¨‹åºã€‚(暂未实现) | +| osKernelGetTickCount | 获å–RTOSå†…æ ¸æ»´ç”计数。 | +| osKernelGetTickFreq | 获å–RTOSå†…æ ¸æ»´ç”频率。 | + + **表2** çº¿ç¨‹ç®¡ç† + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osThreadDetach | 分离线程(线程终æ¢æ—¶å¯ä»¥å›žæ”¶çº¿ç¨‹å˜å‚¨ï¼‰ã€‚(暂未实现) | +| osThreadEnumerate | 枚举活动线程。(暂未实现) | +| osThreadExit | 终æ¢å½“å‰æ£åœ¨è¿è¡Œçš„线程的执行。 | +| osThreadGetCount | 获å–活动线程的数é‡ã€‚ | +| osThreadGetId | 返回当å‰æ£åœ¨è¿è¡Œçš„线程的线程ID。 | +| osThreadGetName | 获å–线程的å称。 | +| osThreadGetPriority | 获å–线程的当å‰ä¼˜å…ˆçº§ã€‚ | +| osThreadGetStackSize | 获å–çº¿ç¨‹çš„å †æ ˆå¤§å°ã€‚ | +| osThreadGetStackSpace | æ ¹æ®æ‰§è¡ŒæœŸé—´çš„å †æ ˆæ°´å°è®°å½•èŽ·å–线程的å¯ç”¨å †æ ˆç©ºé—´ã€‚ | +| osThreadGetState | 获å–线程的当å‰çº¿ç¨‹çŠ¶æ€ã€‚ | +| osThreadJoin | ç‰å¾…指定线程终æ¢ã€‚(暂未实现) | +| osThreadNew | åˆ›å»ºä¸€ä¸ªçº¿ç¨‹å¹¶å°†å…¶æ·»åŠ åˆ°æ´»åŠ¨çº¿ç¨‹ä¸ã€‚ | +| osThreadResume | æ¢å¤çº¿ç¨‹çš„执行。 | +| osThreadSetPriority | 更改线程的优先级。 | +| osThreadSuspend | æš‚åœæ‰§è¡Œçº¿ç¨‹ã€‚ | +| osThreadTerminate | 终æ¢çº¿ç¨‹çš„执行。 | +| osThreadYield | 将控制æƒä¼ 递给处于就绪状æ€çš„下一个线程。 | + + **表3** çº¿ç¨‹æ ‡å¿— + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osThreadFlagsSet | è®¾ç½®çº¿ç¨‹çš„æŒ‡å®šçº¿ç¨‹æ ‡å¿—ã€‚ï¼ˆæš‚æœªå®žçŽ°ï¼‰ | +| osThreadFlagsClear | 清除当å‰æ£åœ¨è¿è¡Œçš„çº¿ç¨‹çš„æŒ‡å®šçº¿ç¨‹æ ‡å¿—ã€‚ï¼ˆæš‚æœªå®žçŽ°ï¼‰ | +| osThreadFlagsGet | 获å–当å‰æ£åœ¨è¿è¡Œçš„线程的当å‰çº¿ç¨‹æ ‡å¿—。(暂未实现) | +| osThreadFlagsWait | ç‰å¾…当å‰æ£åœ¨è¿è¡Œçš„çº¿ç¨‹çš„ä¸€ä¸ªæˆ–å¤šä¸ªçº¿ç¨‹æ ‡å¿—å‘出信å·ã€‚(暂未实现) | + + **表4** äº‹ä»¶æ ‡å¿— + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osEventFlagsGetName | 获å–äº‹ä»¶æ ‡å¿—å¯¹è±¡çš„å称。(暂未实现) | +| osEventFlagsNew | 创建并åˆå§‹åŒ–äº‹ä»¶æ ‡å¿—å¯¹è±¡ã€‚ | +| osEventFlagsDelete | åˆ é™¤äº‹ä»¶æ ‡å¿—å¯¹è±¡ã€‚ | +| osEventFlagsSet | è®¾ç½®æŒ‡å®šçš„äº‹ä»¶æ ‡å¿—ã€‚ | +| osEventFlagsClear | æ¸…é™¤æŒ‡å®šçš„äº‹ä»¶æ ‡å¿—ã€‚ | +| osEventFlagsGet | 获å–当å‰äº‹ä»¶æ ‡å¿—。 | +| osEventFlagsWait | ç‰å¾…ä¸€ä¸ªæˆ–å¤šä¸ªäº‹ä»¶æ ‡å¿—è¢«å‘出信å·ã€‚ | + + **表5** 通用ç‰å¾…函数 + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osDelay | ç‰å¾…超时(时间延迟)。 | +| osDelayUntil | ç‰åˆ°æŒ‡å®šæ—¶é—´ã€‚ | + + **表6** è®¡æ—¶å™¨ç®¡ç† + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osTimerDelete | åˆ é™¤è®¡æ—¶å™¨ã€‚ | +| osTimerGetName | 获å–计时器的å称。(暂未实现) | +| osTimerIsRunning | 检查计时器是å¦æ£åœ¨è¿è¡Œã€‚ | +| osTimerNew | 创建和åˆå§‹åŒ–计时器。 | +| osTimerStart | å¯åŠ¨æˆ–é‡æ–°å¯åŠ¨è®¡æ—¶å™¨ã€‚ | +| osTimerStop | åœæ¢è®¡æ—¶å™¨ã€‚ | + + **表7** äº’æ–¥ç®¡ç† + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osMutexAcquire | 获å–互斥或超时(如果已é”定)。 | +| osMutexDelete | åˆ é™¤äº’æ–¥å¯¹è±¡ã€‚ | +| osMutexGetName | 获å–互斥对象的å称。(暂未实现) | +| osMutexGetOwner | 获å–拥有互斥对象的线程。 | +| osMutexNew | 创建并åˆå§‹åŒ–Mutex对象。 | +| osMutexRelease | 释放由osMutexAcquire获å–çš„Mutex。 | + + **表8** ä¿¡å·é‡ + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osSemaphoreAcquire | 获å–ä¿¡å·é‡ä»¤ç‰Œæˆ–超时(如果没有å¯ç”¨çš„令牌)。 | +| osSemaphoreDelete | åˆ é™¤ä¸€ä¸ªä¿¡å·é‡å¯¹è±¡ã€‚ | +| osSemaphoreGetCount | 获å–当å‰ä¿¡å·é‡ä»¤ç‰Œè®¡æ•°ã€‚ | +| osSemaphoreGetName | 获å–ä¿¡å·é‡å¯¹è±¡çš„å称。(暂未实现) | +| osSemaphoreNew | 创建并åˆå§‹åŒ–一个信å·é‡å¯¹è±¡ã€‚ | +| osSemaphoreRelease | 释放信å·é‡ä»¤ç‰Œï¼Œç›´åˆ°åˆå§‹æœ€å¤§è®¡æ•°ã€‚ | + + **表9** 内å˜æ± + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osMemoryPoolAlloc | 从内å˜æ± 分é…一个内å˜å—。 | +| osMemoryPoolDelete | åˆ é™¤å†…å˜æ± 对象。 | +| osMemoryPoolFree | 将分é…的内å˜å—返回到内å˜æ± 。 | +| osMemoryPoolGetBlockSize | 获å–内å˜æ± ä¸çš„内å˜å—大å°ã€‚ | +| osMemoryPoolGetCapacity | 获å–内å˜æ± ä¸æœ€å¤§çš„内å˜å—数。 | +| osMemoryPoolGetCount | 获å–内å˜æ± ä¸ä½¿ç”¨çš„内å˜å—数。 | +| osMemoryPoolGetName | 获å–内å˜æ± 对象的å称。 | +| osMemoryPoolGetSpace | 获å–内å˜æ± ä¸å¯ç”¨çš„内å˜å—数。 | +| osMemoryPoolNew | 创建并åˆå§‹åŒ–一个内å˜æ± 对象。 | + + **表10** 消æ¯é˜Ÿåˆ— + +| 接å£å | 接å£æè¿° | +| -------- | -------- | +| osMessageQueueDelete | åˆ é™¤æ¶ˆæ¯é˜Ÿåˆ—对象。 | +| osMessageQueueGet | 从队列获å–消æ¯ï¼Œæˆ–者如果队列为空,则从超时获å–消æ¯ã€‚ | +| osMessageQueueGetCapacity | 获å–消æ¯é˜Ÿåˆ—ä¸çš„最大消æ¯æ•°ã€‚ | +| osMessageQueueGetCount | 获å–消æ¯é˜Ÿåˆ—ä¸æŽ’队的消æ¯æ•°ã€‚ | +| osMessageQueueGetMsgSize | 获å–内å˜æ± ä¸çš„最大消æ¯å¤§å°ã€‚ | +| osMessageQueueGetName | 获å–消æ¯é˜Ÿåˆ—对象的å称。(暂未实现) | +| osMessageQueueGetSpace | 获å–消æ¯é˜Ÿåˆ—ä¸æ¶ˆæ¯çš„å¯ç”¨æ’槽数。 | +| osMessageQueueNew | 创建和åˆå§‹åŒ–消æ¯é˜Ÿåˆ—对象。 | +| osMessageQueuePut | 如果队列已满,则将消æ¯æ”¾å…¥é˜Ÿåˆ—或超时。 | +| osMessageQueueReset | 将消æ¯é˜Ÿåˆ—é‡ç½®ä¸ºåˆå§‹ç©ºçŠ¶æ€ã€‚(暂未实现) | + + +#### å¼€å‘æµç¨‹ + +CMSIS-RTOS2组件å¯ä»¥ä½œä¸ºåº“或æºä»£ç æä¾›ï¼ˆä¸‹å›¾æ˜¾ç¤ºäº†åº“ï¼‰ã€‚é€šè¿‡æ·»åŠ CMSIS-RTOS2组件(通常是一些é…置文件),å¯ä»¥å°†åŸºäºŽCMSIS的应用程åºæ‰©å±•ä¸ºå…·æœ‰RTOS功能。åªéœ€åŒ…å«cmsis_os2.h头文件就å¯ä»¥è®¿é—®RTOS API函数,这使用户应用程åºèƒ½å¤Ÿå¤„ç†RTOSå†…æ ¸ç›¸å…³äº‹ä»¶ï¼Œè€Œåœ¨æ›´æ¢å†…æ ¸æ—¶æ— éœ€é‡æ–°ç¼–译æºä»£ç 。 + +é™æ€å¯¹è±¡åˆ†é…需è¦è®¿é—®RTOS对象控制å—定义。特定于实现的头文件(下图ä¸çš„os_xx .h)æ供对æ¤ç±»æŽ§åˆ¶å—定义的访问。对于OpenHarmony LiteOS-Må†…æ ¸ï¼Œç”±æ–‡ä»¶å以los_开头的头文件æ供,这些文件包å«OpenHarmony LiteOS-Må†…æ ¸çš„è¿™äº›å®šä¹‰ã€‚ + + + + +#### 编程实例 + + +``` +#include ... +#include "cmsis_os2.h" + +/*---------------------------------------------------------------------------- + * 应用程åºä¸»çº¿ç¨‹ + *---------------------------------------------------------------------------*/ +void app_main (void *argument) { + // ... + for (;;) {} +} + +int main (void) { + // 系统åˆå§‹åŒ– + MySystemInit(); + // ... + + osKernelInitialize(); // åˆå§‹åŒ–CMSIS-RTOS + osThreadNew(app_main, NULL, NULL); // 创建应用程åºä¸»çº¿ç¨‹ + osKernelStart(); // 开始执行线程 + for (;;) {} +} +``` + +## POSIXæ”¯æŒ + + +### 基本概念 + +OpenHarmonyå†…æ ¸ä½¿ç”¨**musl libc**库以åŠè‡ªç ”接å£ï¼Œæ”¯æŒéƒ¨åˆ†æ ‡å‡†POSIX接å£ï¼Œå¼€å‘者å¯åŸºäºŽPOSIXæ ‡å‡†æŽ¥å£å¼€å‘å†…æ ¸ä¹‹ä¸Šçš„ç»„ä»¶åŠåº”用。 + + +### å¼€å‘指导 + + +#### 接å£è¯´æ˜Ž + + **表1** process + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <stdlib.h> | void abort(void); | ä¸æ¢çº¿ç¨‹æ‰§è¡Œ | +| \#include <assert.h> | void assert(scalar expression); | æ–言为å‡ç»ˆæ¢çº¿ç¨‹ | +| \#include <pthread.h> | int pthread_cond_destroy(pthread_cond_t \*cond); | 销æ¯æ¡ä»¶å˜é‡ | +| \#include <pthread.h> | int pthread_cond_init(pthread_cond_t \*restrict co<br/>nd, const pthread_condattr_t \*restrict attr); | åˆå§‹åŒ–æ¡ä»¶å˜é‡ | +| \#include <pthread.h> | int pthread_cond_timedwait(pthread_cond_t \*restr<br/>ict cond, pthread_mutex_t \*restrict mutex, const st<br/>ruct timespec \*restrict abstime); | ç‰å¾…æ¡ä»¶ | +| \#include <pthread.h> | int pthread_condattr_init(pthread_condattr_t \*attr); | åˆå§‹åŒ–æ¡ä»¶å˜é‡å±žæ€§å¯¹è±¡ | +| \#include <pthread.h> | int pthread_mutex_unlock(pthread_mutex_t \*mutex); | 解é”äº’æ–¥é” | +| \#include <pthread.h> | int pthread_create(pthread_t \*thread, const pthread_<br/>attr_t \*attr, void \*(\*start_routine)(void \*), void \*arg); | 创建一个新的线程 | +| \#include <pthread.h> | int pthread_join(pthread_t thread, void \*\*retval); | ç‰å¾…æŒ‡å®šçš„çº¿ç¨‹ç»“æŸ | +| \#include <pthread.h> | pthread_t pthread_self(void); | 获å–当å‰çº¿ç¨‹çš„ID | +| \#include <pthread.h> | int pthread_getschedparam(pthread_t thread, int \*<br/>policy, struct sched_param \*param); | 获å–线程的调度ç–略和å‚æ•° | +| \#include <pthread.h> | int pthread_setschedparam(pthread_t thread, int<br/>policy, const struct sched_param \*param); | 设置线程的调度ç–略和å‚æ•° | +| \#include <pthread.h> | int pthread_mutex_init(pthread_mutex_t \*__restrict m<br/>, const pthread_mutexattr_t \*__restrict a); | åˆå§‹åŒ–äº’æ–¥é” | +| \#include <pthread.h> | int pthread_mutex_lock(pthread_mutex_t \*m); | 互斥é”åŠ é”æ“作 | +| \#include <pthread.h> | int pthread_mutex_trylock(pthread_mutex_t \*m); | 互斥é”å°è¯•åŠ é”æ“作 | +| \#include <pthread.h> | int pthread_mutex_destroy(pthread_mutex_t \*m); | 销æ¯äº’æ–¥é” | +| \#include <pthread.h> | int pthread_attr_init(pthread_attr_t \*attr); | åˆå§‹åŒ–线程属性对象 | +| \#include <pthread.h> | int pthread_attr_destroy(pthread_attr_t \*attr); | 销æ¯çº¿ç¨‹å±žæ€§å¯¹è±¡ | +| \#include <pthread.h> | int pthread_attr_getstacksize(const pthread_attr<br/>_t \*attr, size_t \*stacksize); | 获å–çº¿ç¨‹å±žæ€§å¯¹è±¡çš„å †æ ˆå¤§å° | +| \#include <pthread.h> | int pthread_attr_setstacksize(pthread_attr_t \*attr<br/>, size_t stacksize); | è®¾ç½®çº¿ç¨‹å±žæ€§å¯¹è±¡çš„å †æ ˆå¤§å° | +| \#include <pthread.h> | int pthread_attr_getschedparam(const pthread_<br/>attr_t \*attr, struct sched_param \*param); | 获å–线程属性对象的调度å‚数属性 | +| \#include <pthread.h> | int pthread_attr_setschedparam(pthread_attr_t \*<br/>attr, const struct sched_param \*param); | 设置线程属性对象的调度å‚数属性 | +| \#include <pthread.h> | int pthread_getname_np(pthread_t pthread, char<br/>\*name, size_t len); | 获å–线程å称 | +| \#include <pthread.h> | int pthread_setname_np(pthread_t pthread, const<br/>char \*name); | 设置线程å称 | +| \#include <pthread.h> | int pthread_cond_broadcast(pthread_cond_t \*c); | 解除若干已被ç‰å¾…æ¡ä»¶é˜»å¡žçš„线程 | +| \#include <pthread.h> | int pthread_cond_signal(pthread_cond_t \*c); | 解除被阻塞的线程 | +| \#include <pthread.h> | int pthread_cond_wait(pthread_cond_t \*__restrict<br/>c, pthread_mutex_t \*__restrict m); | ç‰å¾…æ¡ä»¶ | + + **表2** fs + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <libgen.h> | char \*dirname(char \*path); | 获å–目录å | +| \#include <dirent.h> | struct dirent \*readdir(DIR \*dirp); | 读目录 | +| \#include <sys/stat.h> | int stat(const char \*restrict path, struct stat \*restrict buf); | 获å–æ–‡ä»¶ä¿¡æ¯ | +| \#include <unistd.h> | int unlink(const char \*pathname); | åˆ é™¤æ–‡ä»¶ | +| \#include <fcntl.h | int open(const char \*path, int oflags, ...); | 用于打开文件,如文件ä¸å˜åœ¨ï¼Œåˆ›å»ºæ–‡ä»¶å¹¶æ‰“å¼€ | +| \#include <nistd.h> | int close(int fd); | å…³é—文件 | +| \#include <stdio.h> | int rename(const char \*oldpath, const char \*newpath); | é‡å‘½å指定的文件 | +| \#include <dirent.h> | DIR \*opendir(const char \*dirname); | 打开指定目录 | +| \#include <dirent.h> | int closedir(DIR \*dir); | å…³é—指定目录 | +| \#include <sys/mount.h> | int mount(const char \*source, const char \*target, con<br/>st char \*filesystemtype, unsigned long mountflags, c<br/>onst void \*data); | 挂载文件系统 | +| \#include <sys/mount.h> | int umount(const char \*target); | å¸è½½æ–‡ä»¶ç³»ç»Ÿ | +| \#include <sys/mount.h> | int umount2(const char \*target, int flag); | å¸è½½æ–‡ä»¶ç³»ç»Ÿ | +| \#include <sys/stat.h> | int fsync(int fd); | 将与指定文件æ述符关è”的文件åŒæ¥åˆ°å˜å‚¨è®¾å¤‡ | +| \#include <sys/stat.h> | int mkdir(const char \*pathname, mode_t mode); | 创建目录 | +| \#include <unistd.h> | int rmdir(const char \*path); | åˆ é™¤ç›®å½• | +| \#include <sys/stat.h> | int fstat(int fd, struct stat \*buf); | 获å–文件状æ€ä¿¡æ¯ | +| \#include <sys/statfs.h> | int statfs(const char \*path, struct statfs \*buf); | 获å–æŒ‡å®šè·¯å¾„ä¸‹æ–‡ä»¶çš„æ–‡ä»¶ç³»ç»Ÿä¿¡æ¯ | + + **表3** time + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <sys/time.h> | int gettimeofday(struct timeval \*tv, struct timezone \*tz); | 获å–时间。当å‰æš‚æ— æ—¶åŒºæ¦‚å¿µ,tz返回为空 | +| \#include <time.h> | struct tm \*gmtime(const time_t \*timep); | 将日期和时间转æ¢ä¸ºç»†åˆ†æ—¶é—´æˆ–ASCII | +| \#include <time.h> | struct tm \*localtime(const time_t \*timep); | 获å–时间 | +| \#include <time.h> | struct tm \*localtime_r(const time_t \*timep, struct tm \*result); | 获å–时间 | +| \#include <time.h> | time_t mktime(struct tm \*tm); | 将日期和时间转æ¢ä¸ºç»†åˆ†æ—¶é—´æˆ–ASCII | +| \#include <time.h> | size_t strftime(char \*s, size_t max, const char \*<br/>format,const struct tm \*tm); | æ ¼å¼åŒ–日期和时间å—符串 | +| \#include <time.h> | time_t time(time_t \*tloc); | 获得日历时间 | +| \#include <sys/times.h> | clock_t times(struct tms \*buf); | 获å–线程时间 | +| \#include <unistd.h> | int usleep(useconds_t usec); | ä¼‘çœ ï¼ˆå¾®ç§’å•ä½ï¼‰ | +| \#include <time.h> | int nanosleep(const struct timespec \*tspec1, struct<br/>timespec \*tspec2); | æš‚åœå½“å‰çº¿ç¨‹ç›´åˆ°æŒ‡å®šçš„时间到达 | +| \#include <time.h> | int clock_gettime(clockid_t id, struct timespec \*tspec); | 获å–时钟的时间 | +| \#include <time.h> | int timer_create(clockid_t id, struct sigevent \*__<br/>restrict evp, timer_t \*__restrict t); | 为线程创建计时器 | +| \#include <time.h> | int timer_delete(timer_t t); | ä¸ºçº¿ç¨‹åˆ é™¤è®¡æ—¶å™¨ | +| \#include <time.h> | int timer_settime(timer_t t, int flags, const struct<br/>itimerspec \*__restrict val, struct itimerspec \*__restrict old); | 为线程设置计时器 | +| \#include <time.h> | time_t time (time_t \*t); | 获å–时间 | +| \#include <time.h> | char \*strptime(const char \*s, const char \*format, struct tm \*tm); | 将时间的å—符串表示形å¼è½¬æ¢ä¸ºæ—¶é—´tm结构 | + + **表4** util + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <stdlib.h> | int atoi(const char \*nptr); | å—符串转æ¢æ•´åž‹ï¼ˆint) | +| \#include <stdlib.h> | long atol(const char \*nptr); | å—符串转æ¢æ•´åž‹ï¼ˆlong) | +| \#include <stdlib.h> | long long atoll(const char \*nptr); | å—符串转æ¢æ•´åž‹ï¼ˆlong long) | +| \#include <ctype.h> | int isalnum(int c); | 检查å—æ¯æ•°å—å—符 | +| \#include <ctype.h> | int isascii(int c); | 检查ASCII | +| \#include <ctype.h> | int isdigit(int c); | 检查数å—å—符 | +| \#include <ctype.h> | int islower(int c); | 检查å°å†™å—符 | +| \#include <ctype.h> | int isprint(int c); | 检查任何å¯æ‰“å°å—ç¬¦ï¼ŒåŒ…æ‹¬ç©ºæ ¼ | +| \#include <ctype.h> | int isspace(int c); | æ£€æŸ¥ç©ºæ ¼å—符 | +| \#include <ctype.h> | int isupper(int c); | æ£€æŸ¥æ‰€ä¼ çš„å—符是å¦æ˜¯å¤§å†™å—æ¯ | +| \#include <ctype.h> | int isxdigit(int c); | 判æ–å—符是å¦ä¸ºåå…进制数 | +| \#include <stdlib.h> | long int random (void); | 生æˆä¼ªéšæœºæ•° | +| \#include <stdlib.h> | void srandom(unsigned int seed); | åˆå§‹åŒ–éšæœºæ•°ç”Ÿæˆå™¨ | +| \#include <ctype.h> | int tolower(int c); | å—æ¯è½¬æ¢æˆå°å†™ | +| \#include <ctype.h> | int toupper(int c); | å—æ¯è½¬æ¢æˆå¤§å†™ | +| \#include <stdarg.h> | type va_arg(va_list ap, type); | 获å–å¯å˜å‚数的当å‰å‚数,返回指定类型并将指针指å‘下一å‚æ•° | +| \#include <stdarg.h> | void va_copy(va_list dest, va_list src); | å¤åˆ¶å‚æ•° | +| \#include <stdarg.h> | void va_end(va_list ap); | 清空va_listå¯å˜å‚数列表 | +| \#include <stdarg.h> | void va_start(va_list ap, last); | 定义å˜é•¿å‚数列表的起始ä½ç½® | +| \#include <string.h> | char \*strchr(const char \*s, int c); | 在å—符串ä¸å®šä½å—符 | +| \#include <string.h> | int strcmp(const char \*s1, const char \*s2); | 比较å—符串 | +| \#include <string.h> | size_t strcspn(const char \*s, const char \*reject); | 获å–å‰ç¼€å串的长度 | +| \#include <string.h> | char \*strdup(const char \*s); | å—符串拷è´åˆ°æ–°å»ºçš„ä½ç½®å¤„ | +| \#include <string.h> | size_t strlen(const char \*s); | 计算å—符串长度 | +| \#include <strings.h> | int strncasecmp(const char \*s1, const char \*s2, size_t n); | 比较固定长度å—符串(忽略大å°å†™ï¼‰ | +| \#include <strings.h> | int strcasecmp(const char \*s1, const char \*s2); | 比较å—符串(忽略大å°å†™ï¼‰ | +| \#include <string.h> | int strncmp(const char \*s1, const char \*s2, size_t n); | 比较å—符串(指定长度) | +| \#include <string.h> | char \*strrchr(const char \*s, int c); | 在å—符串ä¸å®šä½å—符 | +| \#include <string.h> | char \*strstr(const char \*haystack, const char \*needle); | 寻找指定的å串 | +| \#include <stdlib.h> | long int strtol(const char \*nptr, char \*\*endptr, int base); | å°†å—符串转æ¢ä¸ºlongåž‹æ•´æ•° | +| \#include <stdlib.h> | unsigned long int strtoul(const char \*nptr, char<br/>\*\*endptr, int base); | å°†å—符串转æ¢ä¸ºunsigned longåž‹æ•´æ•° | +| \#include <stdlib.h> | unsigned long long int strtoull(const char \*nptr,<br/>char \*\*endptr,int base); | å°†å—符串转æ¢ä¸ºunsigned long longåž‹æ•´æ•° | +| \#include <regex.h> | int regcomp(regex_t \*preg, const char \*regex,<br/>int cflags); | 编译æ£åˆ™è¡¨è¾¾å¼ | +| \#include <regex.h> | int regexec(const regex_t \*preg, const char \*<br/>string, size_t nmatch,regmatch_t pmatch[], int eflags); | 匹é…æ£åˆ™è¡¨è¾¾å¼ | +| \#include <regex.h> | void regfree(regex_t \*preg); | 释放æ£åˆ™è¡¨è¾¾å¼ | +| \#include <string.h> | char \*strerror(int errnum); | 返回æ述错误å·çš„å—符串 | + + **表5** math + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <stdlib.h> | int abs(int i); | å–ç»å¯¹å€¼ | +| \#include <math.h> | double log(double x); | 自然对数函数 | +| \#include <math.h> | double pow(double x, double y); | 求x的指数y次幂 | +| \#include <math.h> | double round(double x); | 从零开始,èˆå…¥åˆ°æœ€æŽ¥è¿‘çš„æ•´æ•° | +| \#include <math.h> | double sqrt(double x); | å¹³æ–¹æ ¹ | + + **表6** IO + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <stdio.h> | void clearerr(FILE \*stream); | 清除æµçš„文件结尾和错误指示 | +| \#include <stdio.h> | int fclose(FILE \*stream); | å…³é—æ–‡ä»¶æµ | +| \#include <stdio.h> | FILE \*fdopen(int fd, const char \*mode); | 通过文件æè¿°ç¬¦æ‰“å¼€æ–‡ä»¶æµ | +| \#include <stdio.h> | int feof(FILE \*stream); | æ£€æµ‹è¿”å›žæ–‡ä»¶æœ«å°¾æŒ‡ç¤ºä½ | +| \#include <stdio.h> | int fflush(FILE \*stream); | åˆ·æ–°æµ | +| \#include <stdio.h> | char \*fgets(char \*s, int size, FILE \*stream); | 读å–æµçš„下一行 | +| \#include <stdio.h> | int fileno(FILE \*stream); | 返回æµçš„文件æ述符 | +| \#include <stdio.h> | FILE \*fopen(const char \*path, const char \*mode); | æ‰“å¼€æµ | +| \#include <stdio.h> | int fputs(const char \*s, FILE \*stream); | å‘指定æµå†™å…¥ä¸€è¡Œ | +| \#include <stdio.h> | size_t fread(void \*ptr, size_t size, size_t nmemb,<br/>FILE \*stream); | è¯»ä¸€ä¸ªæµ | +| \#include <stdio.h> | int fseek(FILE \*stream, long offset, int whence); | 设置æµæŒ‡é’ˆçš„ä½ç½® | +| \#include <stdio.h> | long ftell(FILE \*stream); | 获å–æµæŒ‡é’ˆçš„ä½ç½® | +| \#include <stdio.h> | size_t fwrite(const void \*ptr, size_t size, size_t<br/>nmemb,FILE \*stream); | å‘æµå†™å…¥ | +| \#include <stdio.h> | void perror(const char \*s); | 打å°ç³»ç»Ÿé”™è¯¯ä¿¡æ¯ | +| \#include <stdio.h> | void rewind(FILE \*stream); | é‡æ–°å®šä½æµ | +| \#include <unistd.h> | ssize_t write(int fd, const void \*buf, size_t size); | 写文件内容 | +| \#include <unistd.h> | ssize_t read(int fd, void \*buf, size_t size); | 读文件内容 | + + **表7** net + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <sys/socket.h> | void freeaddrinfo(struct addrinfo \*res); | 释放调用getaddrinfo所分é…的动æ€å†…å˜ | +| \#include <sys/socket.h> | int getaddrinfo(const char \*restrict nodename,const<br/>char \*restrict servname,const struct addrinfo \*restrict<br/>hints,struct addrinfo \*\*restrict res); | 网络地å€å’ŒæœåŠ¡è½¬æ¢ | +| \#include <sys/socket.h> | int getnameinfo(const struct sockaddr \*restrict sa,<br/>socklen_t salen,char \*restrict node, socklen_t nodelen<br/>, char \*restrict service,socklen_t servicelen, int flags); | 以åè®®æ— å…³çš„æ–¹å¼è¿›è¡Œåœ°å€åˆ°åç§°çš„è½¬æ¢ | +| \#include <net/if.h> | unsigned int if_nametoindex(const char \*ifname); | 通过网络接å£å得到索引 | +| \#include <arpa/inet.h> | in_addr_t inet_addr(const char \*cp); | 网络主机地å€ç‚¹åˆ†å进制形å¼è½¬æ¢ä½äºŒè¿›åˆ¶å½¢å¼ | +| \#include <arpa/inet.h> | char \*inet_ntoa(struct in_addr in); | 网络主机地å€äºŒè¿›åˆ¶å½¢å¼è½¬æ¢ä½ç‚¹åˆ†åè¿›åˆ¶å½¢å¼ | +| \#include <arpa/inet.h> | const char \*inet_ntop(int af, const void \*src,char \*dst,<br/>socklen_t size); | 网络地å€è½¬æ¢ | +| \#include <arpa/inet.h> | int inet_pton(int af, const char \*src, void \*dst); | 网络地å€è½¬æ¢ | +| \#include <sys/socket.h> | int listen(int sockfd, int backlog); | 监å¬å¥—æŽ¥å— | +| \#include <sys/socket.h> | ssize_t recvmsg(int sockfd, struct msghdr \*msg, int flags); | 从套接å—接收消æ¯.åªæ”¯æŒiov大å°ä¸º1的场景,且ä¸æ”¯æŒancillaryæ¶ˆæ¯ | +| \#include <sys/socket.h> | ssize_t send(int sockfd, const void \*buf, size_t len, int flags); | 从socketå‘é€æ¶ˆæ¯ | +| \#include <sys/socket.h> | ssize_t sendmsg(int sockfd, const struct msghdr \*msg, int flags); | 从socketå‘é€æ¶ˆæ¯ã€‚ä¸æ”¯æŒancillaryæ¶ˆæ¯ | +| \#include <sys/socket.h> | ssize_t sendto(int sockfd, const void \*buf, size_t len, int<br/>flags,const struct sockaddr \*dest_addr, socklen_t addrlen); | 从socketå‘é€æ¶ˆæ¯ | +| \#include <sys/socket.h> | int setsockopt(int sockfd, int level, int optname,const<br/>void \*optval, socklen_t optlen); | 设置与套接å—å…³è”的选项 | + + **表8** mem + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <string.h> | int memcmp(const void \*s1, const void \*s2, size_t n); | 内å˜æ¯”较 | +| \#include <string.h> | void \*memcpy(void \*dest, const void \*src, size_t n); | 内å˜æ‹·è´ | +| \#include <string.h> | void \*memset(void \*s, int c, size_t n); | 内å˜åˆå§‹åŒ– | +| \#include <stdlib.h> | void \*realloc(void \*ptr, size_t size); | é‡åˆ†é…å†…å˜ | +| \#include <stdlib.h> | void \*malloc(size_t size); | 动æ€åˆ†é…内å˜å—å¤§å° | +| \#include <stdlib.h> | void free(void \*ptr); | 释放ptr所指å‘的内å˜ç©ºé—´ | + + **表9** IPC + +| 需è¦åŒ…å«çš„头文件 | 接å£å | æè¿° | +| -------- | -------- | -------- | +| \#include <semaphore.h> | int sem_timedwait(sem_t \*sem, const struct<br/> timespec \*abs_timeout); | 计时é”定信å·é‡ | +| \#include <semaphore.h> | int sem_destroy(sem_t \*sem); | 销æ¯æŒ‡å®šçš„æ— åä¿¡å·é‡ | +| \#include <semaphore.h> | int sem_init(sem_t \*sem, int pshared<br/>, unsigned int value); | 创建并åˆå§‹åŒ–ä¸€ä¸ªæ— åä¿¡å·é‡ | +| \#include <semaphore.h> | int sem_post(sem_t \*sem); | å¢žåŠ ä¿¡å·é‡è®¡æ•° | +| \#include <semaphore.h> | int sem_wait(sem_t \*sem); | 获å–ä¿¡å·é‡ | +| \#include <mqueue.h> | mqd_t mq_open(const char \*mqName,<br/> int openFlag, ...); | æ¤API用于打开一个具有指定å称的已有消æ¯é˜Ÿåˆ—或创建一个新的消æ¯é˜Ÿåˆ— | +| \#include <mqueue.h> | int mq_close(mqd_t personal); | æ¤API用于关é—具有指定æ述符的消æ¯é˜Ÿåˆ— | +| \#include <mqueue.h> | int mq_unlink(const char \*mqName); | æ¤APIç”¨äºŽåˆ é™¤å…·æœ‰æŒ‡å®šå称的消æ¯é˜Ÿåˆ— | +| \#include <mqueue.h> | int mq_send(mqd_t personal, const<br/> char \*msg,size_t msgLen, unsigned int msgPrio); | æ¤API用于将具有指定内容和长度的消æ¯æ”¾å…¥å…·æœ‰æŒ‡å®šæ述符的消æ¯é˜Ÿåˆ—ä¸ | +| \#include <mqueue.h> | ssize_t mq_receive(mqd_t personal, char \*msg,<br/>size_t msgLen, unsigned int \*msgPrio); | æ¤API用于从具有指定æ述符的消æ¯é˜Ÿåˆ—ä¸åˆ 除最è€çš„消æ¯ï¼Œå¹¶å°†å…¶æ”¾å…¥msg_ptr所指å‘çš„ç¼“å†²åŒºä¸ | +| \#include <mqueue.h> | int mq_timedsend(mqd_t personal, const char<br/>\*msg, size_t msgLen, unsigned int msgPrio, c<br/>onst struct timespec \*absTimeout) | æ¤API用于在预定时间将具有指定内容和长度的消æ¯æ”¾å…¥å…·æœ‰æ述符的消æ¯é˜Ÿåˆ—ä¸ | +| \#include <mqueue.h> | ssize_t mq_timedreceive(mqd_t personal, char<br/>\*msg, size_t msgLen, unsigned int \*msgPrio,<br/>const struct timespec \*absTimeout); | æ¤API用于从具有指定æ述符的消æ¯é˜Ÿåˆ—消æ¯ä¸èŽ·å–具有指定消æ¯å†…å®¹å’Œé•¿åº¦çš„æ¶ˆæ¯ | +| \#include <mqueue.h> | int mq_setattr(mqd_t mqdes, const struct mq_<br/>attr \*__restrict newattr, struct mq_attr \*__restrict oldattr); | 设置æ述符指定的消æ¯é˜Ÿåˆ—属性 | +| \#include <libc.h> | const char \*libc_get_version_string(void); | 获å–libc版本å—符串 | +| \#include <libc.h> | int libc_get_version(void); | 获å–libcç‰ˆæœ¬å· | + + +#### 注æ„事项 + +常用错误ç 对照表: + +| 错误ç | 值 | æè¿° | å«ä¹‰ | +| -------- | -------- | -------- | -------- | +| ENOERR | 0 | Success | æˆåŠŸ | +| EPERM | 1 | Operation not permitted | æ“作ä¸å…许 | +| ENOENT | 2 | No such file or directory | æ²¡æœ‰è¿™æ ·çš„æ–‡ä»¶æˆ–ç›®å½• | +| ESRCH | 3 | No such process | æ²¡æœ‰è¿™æ ·çš„è¿›ç¨‹(æš‚ä¸æ”¯æŒ) | +| EINTR | 4 | Interrupted system call | 系统调用被ä¸æ– | +| EIO | 5 | I/O error | I/O错误 | +| ENXIO | 6 | No such device or address | æ²¡æœ‰è¿™æ ·çš„è®¾å¤‡æˆ–åœ°å€ | +| E2BIG | 7 | Arg list too long | å‚数列表太长 | +| ENOEXEC | 8 | Exec format error | æ‰§è¡Œæ ¼å¼é”™è¯¯ | +| EBADF | 9 | Bad file number | å的文件æ述符 | +| ECHILD | 10 | No child processes | 没有å进程(æš‚ä¸æ”¯æŒ) | +| EAGAIN | 11 | Try again | 资æºæš‚æ—¶ä¸å¯ç”¨ | +| ENOMEM | 12 | Out of memory | 内å˜æº¢å‡º | +| EACCES | 13 | Permission denied | æ‹’ç»è®¸å¯ | +| EFAULT | 14 | Bad address | é”™è¯¯çš„åœ°å€ | +| ENOTBLK | 15 | Block device required | å—设备请求 | +| EBUSY | 16 | Device or resource busy | 设备或资æºå¿™ | +| EEXIST | 17 | File exists | 文件å˜åœ¨ | +| EXDEV | 18 | Cross-device link | æ— æ•ˆçš„äº¤å‰é“¾æŽ¥ | +| ENODEV | 19 | No such device | 设备ä¸å˜åœ¨ | +| ENOTDIR | 20 | Not a directory | ä¸æ˜¯ä¸€ä¸ªç›®å½• | +| EISDIR | 21 | Is a directory | 是一个目录 | +| EINVAL | 22 | Invalid argument | æ— æ•ˆçš„å‚æ•° | +| ENFILE\* | 23 | File table overflow | 打开太多的文件系统 | +| EMFILE | 24 | Too many open files | 打开的文件过多 | +| EFBIG | 27 | File too large | 文件太大 | +| ENOSPC | 28 | No space left on device | 设备上没有空间 | +| ESPIPE | 29 | Illegal seek | éžæ³•ç§»ä½ | +| EROFS | 30 | Read-only file system | åªè¯»æ–‡ä»¶ç³»ç»Ÿ | +| EMLINK | 31 | Too many links | 太多的链接 | +| EDOM | 33 | Math argument out of domain | 数值结果超出范围 | +| ERANGE | 34 | Math result not representable | 数值结果ä¸å…·ä»£è¡¨æ€§ | +| EDEADLK | 35 | Resource deadlock would occur | 资æºæ»é”错误 | +| ENAMETOOLONG | 36 | Filename too long | 文件å太长 | +| ENOLCK | 37 | No record locks available | 没有å¯ç”¨é” | +| ENOSYS | 38 | Function not implemented | 功能没有实现 | +| ENOTEMPTY | 39 | Directory not empty | 目录ä¸ç©º | +| ELOOP | 40 | Too many symbolic links encountered | 符å·é“¾æŽ¥å±‚次太多 | +| ENOMSG | 42 | No message of desired type | æ²¡æœ‰æœŸæœ›ç±»åž‹çš„æ¶ˆæ¯ | +| EIDRM | 43 | Identifier removed | æ ‡è¯†ç¬¦åˆ é™¤ | +| ELNRNG | 48 | Link number out of range | 链接数超出范围 | +| EBADR | 53 | Invalid request descriptor | 请求æè¿°ç¬¦æ— æ•ˆ | +| EBADRQC | 56 | Invalid request code | æ— æ•ˆçš„è¯·æ±‚ä»£ç | +| ENOSTR | 60 | Device not a stream | 设备ä¸æ˜¯å—ç¬¦æµ | +| ENODATA | 61 | No data available | æ— å¯ç”¨æ•°æ® | +| ETIME | 62 | Timer expired | 计时器过期 | +| EPROTO | 71 | Protocol error | å议错误 | +| EBADMSG | 74 | Not a data message | éžæ•°æ®æ¶ˆæ¯ | +| EOVERFLOW | 75 | Value too large for defined data type | 值太大,对于定义数æ®ç±»åž‹ | +| EMSGSIZE | 90 | Message too long | 消æ¯å¤ªé•¿ | + + +#### 编程实例 + +demo功能: + +创建一个线程并将父线程ä¸çš„ä¿¡æ¯ä¼ 递给å线程,在å线程ä¸æ‰“å°ä¼ 递过æ¥çš„ä¿¡æ¯å’Œè‡ªèº«çº¿ç¨‹id值。 + + +``` +#include <stdio.h> +#include <pthread.h> + +pthread_t ntid; + +void *ThreadFn(void *arg) +{ + pthread_t tid; + while(1) { + tid = pthread_self(); + printf("\n++++++++++++++ %s %s tid = %d ++++++++++++++\n", (char*)arg, __FUNCTION__, tid); + } + return ((void *)0); +} + +void DemoForTest() +{ + int err; + char* str = "Hello world"; + err = pthread_create(&ntid, NULL, ThreadFn, (void*)str); + if(err != 0) { + printf("can't create thread\n"); + } +} + +``` + +执行DemoForTestè¿è¡Œç»“果如下: + + +``` +++++++++++++++ Hello world ThreadFn tid = 48 ++++++++++++++ + +++++++++++++++ Hello world ThreadFn tid = 48 ++++++++++++++ + +++++++++++++++ Hello world ThreadFn tid = 48 ++++++++++++++ +``` diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md index 8ee81f8ae61a503796f4710da3d7602c1fd3631f..16178ecadabea0217f49780744c8d272bc39d590 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-ipc-queue.md @@ -215,7 +215,7 @@ UINT32 ExampleQueue(VOID) printf("create queue failure, error: %x\n", ret); } - printf("create the queue succes.\n"); + printf("create the queue success.\n"); LOS_TaskUnlock(); return ret; } diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-memory.md b/zh-cn/device-dev/kernel/kernel-mini-basic-memory.md index afc518c52ce6037e598cad7b54a883c0f8c7e6eb..5071ddf325680c7d939907b5bb2fd8d8f1368e77 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-memory.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-memory.md @@ -1,9 +1,322 @@ # 内å˜ç®¡ç† +## 基本概念 +内å˜ç®¡ç†æ¨¡å—管ç†ç³»ç»Ÿçš„内å˜èµ„æºï¼Œå®ƒæ˜¯æ“ä½œç³»ç»Ÿçš„æ ¸å¿ƒæ¨¡å—之一,主è¦åŒ…括内å˜çš„åˆå§‹åŒ–ã€åˆ†é…以åŠé‡Šæ”¾ã€‚ -- **[基本概念](kernel-mini-basic-memory-basic.md)** -- **[é™æ€å†…å˜](kernel-mini-basic-memory-static.md)** +在系统è¿è¡Œè¿‡ç¨‹ä¸ï¼Œå†…å˜ç®¡ç†æ¨¡å—通过对内å˜çš„申请/释放æ¥ç®¡ç†ç”¨æˆ·å’ŒOS对内å˜çš„使用,使内å˜çš„利用率和使用效率达到最优,åŒæ—¶æœ€å¤§é™åº¦åœ°è§£å†³ç³»ç»Ÿçš„内å˜ç¢Žç‰‡é—®é¢˜ã€‚ -- **[动æ€å†…å˜](kernel-mini-basic-memory-dynamic.md)** \ No newline at end of file + +OpenHarmony LiteOS-M的内å˜ç®¡ç†åˆ†ä¸ºé™æ€å†…å˜ç®¡ç†å’ŒåŠ¨æ€å†…å˜ç®¡ç†ï¼Œæ供内å˜åˆå§‹åŒ–ã€åˆ†é…ã€é‡Šæ”¾ç‰åŠŸèƒ½ã€‚ + + +- 动æ€å†…å˜ï¼šåœ¨åŠ¨æ€å†…å˜æ± ä¸åˆ†é…用户指定大å°çš„内å˜å—。 + - 优点:按需分é…。 + - 缺点:内å˜æ± ä¸å¯èƒ½å‡ºçŽ°ç¢Žç‰‡ã€‚ + +- é™æ€å†…å˜ï¼šåœ¨é™æ€å†…å˜æ± ä¸åˆ†é…用户åˆå§‹åŒ–时预设(固定)大å°çš„内å˜å—。 + - 优点:分é…和释放效率高,é™æ€å†…å˜æ± ä¸æ— 碎片。 + - 缺点:åªèƒ½ç”³è¯·åˆ°åˆå§‹åŒ–预设大å°çš„内å˜å—,ä¸èƒ½æŒ‰éœ€ç”³è¯·ã€‚ +## é™æ€å†…å˜ + + +### è¿è¡Œæœºåˆ¶ + +é™æ€å†…å˜å®žè´¨ä¸Šæ˜¯ä¸€ä¸ªé™æ€æ•°ç»„,é™æ€å†…å˜æ± 内的å—大å°åœ¨åˆå§‹åŒ–时设定,åˆå§‹åŒ–åŽå—大å°ä¸å¯å˜æ›´ã€‚ + +é™æ€å†…å˜æ± 由一个控制å—LOS_MEMBOX_INFO和若干相åŒå¤§å°çš„内å˜å—LOS_MEMBOX_NODEæž„æˆã€‚控制å—ä½äºŽå†…å˜æ± 头部,用于内å˜å—管ç†ï¼ŒåŒ…å«å†…å˜å—大å°uwBlkSize,内å˜å—æ•°é‡uwBlkNum,已分é…使用的内å˜å—æ•°é‡uwBlkCnt和空闲内å˜å—链表stFreeList。内å˜å—的申请和释放以å—大å°ä¸ºç²’度,æ¯ä¸ªå†…å˜å—包å«æŒ‡å‘下一个内å˜å—的指针pstNext。 + + **图1** é™æ€å†…å˜ç¤ºæ„图 +  + + +### å¼€å‘指导 + + +#### 使用场景 + +当用户需è¦ä½¿ç”¨å›ºå®šé•¿åº¦çš„内å˜æ—¶ï¼Œå¯ä»¥é€šè¿‡é™æ€å†…å˜åˆ†é…çš„æ–¹å¼èŽ·å–内å˜ï¼Œä¸€æ—¦ä½¿ç”¨å®Œæ¯•ï¼Œé€šè¿‡é™æ€å†…å˜é‡Šæ”¾å‡½æ•°å½’还所å 用内å˜ï¼Œä½¿ä¹‹å¯ä»¥é‡å¤ä½¿ç”¨ã€‚ + + +#### 接å£è¯´æ˜Ž + +OpenHarmony LiteOS-Mçš„é™æ€å†…å˜ç®¡ç†ä¸»è¦ä¸ºç”¨æˆ·æ供以下功能,接å£è¯¦ç»†ä¿¡æ¯å¯ä»¥æŸ¥çœ‹APIå‚考。 + + **表1** é™æ€å†…å˜æ¨¡å—æŽ¥å£ + +| 功能分类 | 接å£å | +| -------- | -------- | +| åˆå§‹åŒ–é™æ€å†…å˜æ± | LOS_MemboxInit:åˆå§‹åŒ–一个é™æ€å†…å˜æ± ï¼Œæ ¹æ®å…¥å‚设定其起始地å€ã€æ€»å¤§å°åŠæ¯ä¸ªå†…å˜å—大å°ã€‚ | +| 清除é™æ€å†…å˜å—内容 | LOS_MemboxClr:清零从é™æ€å†…å˜æ± ä¸ç”³è¯·çš„é™æ€å†…å˜å—的内容。 | +| 申请ã€é‡Šæ”¾é™æ€å†…å˜ | - LOS_MemboxAlloc:从指定的é™æ€å†…å˜æ± ä¸ç”³è¯·ä¸€å—é™æ€å†…å˜å—。<br/>- LOS_MemboxFree:释放从é™æ€å†…å˜æ± ä¸ç”³è¯·çš„一å—é™æ€å†…å˜å—。 | +| 获å–ã€æ‰“å°é™æ€å†…å˜æ± ä¿¡æ¯ | - LOS_MemboxStatisticsGet:获å–指定é™æ€å†…å˜æ± çš„ä¿¡æ¯ï¼ŒåŒ…括内å˜æ± ä¸æ€»å†…å˜å—æ•°é‡ã€å·²ç»åˆ†é…出去的内å˜å—æ•°é‡ã€æ¯ä¸ªå†…å˜å—的大å°ã€‚<br/>- LOS_ShowBox:打å°æŒ‡å®šé™æ€å†…å˜æ± 所有节点信æ¯ï¼ˆæ‰“å°ç‰çº§æ˜¯LOS_INFO_LEVEL),包括内å˜æ± 起始地å€ã€å†…å˜å—大å°ã€æ€»å†…å˜å—æ•°é‡ã€æ¯ä¸ªç©ºé—²å†…å˜å—的起始地å€ã€æ‰€æœ‰å†…å˜å—的起始地å€ã€‚ | + +>  **说明:** +> åˆå§‹åŒ–åŽçš„内å˜æ± 的内å˜å—æ•°é‡ï¼Œä¸ç‰äºŽæ€»å¤§å°é™¤äºŽå†…å˜å—大å°ï¼Œå› 为内å˜æ± 的控制å—å’Œæ¯ä¸ªå†…å˜å—的控制头,都å˜åœ¨å†…å˜å¼€é”€ï¼Œè®¾ç½®æ€»å¤§å°æ—¶ï¼Œéœ€è¦å°†è¿™äº›å› ç´ è€ƒè™‘è¿›åŽ»ã€‚ + + +#### å¼€å‘æµç¨‹ + +本节介ç»ä½¿ç”¨é™æ€å†…å˜çš„典型场景开å‘æµç¨‹ã€‚ + +1. 规划一片内å˜åŒºåŸŸä½œä¸ºé™æ€å†…å˜æ± 。 + +2. 调用LOS_MemboxInitåˆå§‹åŒ–é™æ€å†…å˜æ± 。 + åˆå§‹åŒ–会将入å‚指定的内å˜åŒºåŸŸåˆ†å‰²ä¸ºNå—(N值å–决于é™æ€å†…å˜æ€»å¤§å°å’Œå—大å°ï¼‰ï¼Œå°†æ‰€æœ‰å†…å˜å—挂到空闲链表,在内å˜èµ·å§‹å¤„放置控制头。 + +3. 调用LOS_MemboxAlloc接å£åˆ†é…é™æ€å†…å˜ã€‚ + 系统将会从空闲链表ä¸èŽ·å–第一个空闲å—,并返回该内å˜å—的起始地å€ã€‚ + +4. 调用LOS_MemboxClr接å£ã€‚ + 将入å‚地å€å¯¹åº”的内å˜å—清零。 + +5. 调用LOS_MemboxFree接å£ã€‚ + 将该内å˜å—åŠ å…¥ç©ºé—²é“¾è¡¨ã€‚ + + +#### 编程实例 + +本实例执行以下æ¥éª¤ï¼š + +1. åˆå§‹åŒ–一个é™æ€å†…å˜æ± 。 + +2. 从é™æ€å†…å˜æ± ä¸ç”³è¯·ä¸€å—é™æ€å†…å˜ã€‚ + +3. 在内å˜å—å˜æ”¾ä¸€ä¸ªæ•°æ®ã€‚ + +4. 打å°å‡ºå†…å˜å—ä¸çš„æ•°æ®ã€‚ + +5. 清除内å˜å—ä¸çš„æ•°æ®ã€‚ + +6. 释放该内å˜å—。 + 示例代ç 如下: + + +``` +#include "los_membox.h" + +VOID Example_StaticMem(VOID) +{ + UINT32 *mem = NULL; + UINT32 blkSize = 10; + UINT32 boxSize = 100; + UINT32 boxMem[1000]; + UINT32 ret; + + /*内å˜æ± åˆå§‹åŒ–*/ + ret = LOS_MemboxInit(&boxMem[0], boxSize, blkSize); + if(ret != LOS_OK) { + printf("Membox init failed!\n"); + return; + } else { + printf("Membox init success!\n"); + } + + /*申请内å˜å—*/ + mem = (UINT32 *)LOS_MemboxAlloc(boxMem); + if (NULL == mem) { + printf("Mem alloc failed!\n"); + return; + } + printf("Mem alloc success!\n"); + + /*赋值*/ + *mem = 828; + printf("*mem = %d\n", *mem); + + /*清除内å˜å†…容*/ + LOS_MemboxClr(boxMem, mem); + printf("Mem clear success \n *mem = %d\n", *mem); + + /*释放内å˜*/ + ret = LOS_MemboxFree(boxMem, mem); + if (LOS_OK == ret) { + printf("Mem free success!\n"); + } else { + printf("Mem free failed!\n"); + } + + return; +} +``` + + +#### ç»“æžœéªŒè¯ + +输出结果如下: + + +``` +Membox init success! +Mem alloc success! +*mem = 828 +Mem clear success +*mem = 0 +Mem free success! +``` +## 动æ€å†…å˜ + + +### è¿è¡Œæœºåˆ¶ + +动æ€å†…å˜ç®¡ç†ï¼Œå³åœ¨å†…å˜èµ„æºå……è¶³çš„æƒ…å†µä¸‹ï¼Œæ ¹æ®ç”¨æˆ·éœ€æ±‚,从系统é…置的一å—比较大的连ç»å†…å˜ï¼ˆå†…å˜æ± ï¼Œä¹Ÿæ˜¯å †å†…å˜ï¼‰ä¸åˆ†é…ä»»æ„大å°çš„内å˜å—。当用户ä¸éœ€è¦è¯¥å†…å˜å—时,åˆå¯ä»¥é‡Šæ”¾å›žç³»ç»Ÿä¾›ä¸‹ä¸€æ¬¡ä½¿ç”¨ã€‚与é™æ€å†…å˜ç›¸æ¯”,动æ€å†…å˜ç®¡ç†çš„优点是按需分é…,缺点是内å˜æ± ä¸å®¹æ˜“出现碎片。 + +OpenHarmony LiteOS-M动æ€å†…å˜åœ¨TLSF算法的基础上,对区间的划分进行了优化,获得更优的性能,é™ä½Žäº†ç¢Žç‰‡çŽ‡ã€‚动æ€å†…å˜æ ¸å¿ƒç®—法框图如下: + + **图1** è½»é‡ç³»ç»ŸåŠ¨æ€å†…å˜æ ¸å¿ƒç®—法 +  + +æ ¹æ®ç©ºé—²å†…å˜å—的大å°ï¼Œä½¿ç”¨å¤šä¸ªç©ºé—²é“¾è¡¨æ¥ç®¡ç†ã€‚æ ¹æ®å†…å˜ç©ºé—²å—大å°åˆ†ä¸ºä¸¤ä¸ªéƒ¨åˆ†ï¼š[4, 127]å’Œ[2<sup>7</sup>, 2<sup>31</sup>],如上图size class所示: + +1. 对[4,127]区间的内å˜è¿›è¡Œç‰åˆ†ï¼Œå¦‚上图下åŠéƒ¨åˆ†æ‰€ç¤ºï¼Œåˆ†ä¸º31个å°åŒºé—´ï¼Œæ¯ä¸ªå°åŒºé—´å¯¹åº”内å˜å—大å°ä¸º4å—节的å€æ•°ã€‚æ¯ä¸ªå°åŒºé—´å¯¹åº”一个空闲内å˜é“¾è¡¨å’Œç”¨äºŽæ ‡è®°å¯¹åº”空闲内å˜é“¾è¡¨æ˜¯å¦ä¸ºç©ºçš„一个比特ä½ï¼Œå€¼ä¸º1时,空闲链表éžç©ºã€‚[4,127]区间的31个å°åŒºé—´å†…å˜å¯¹åº”31个比特ä½è¿›è¡Œæ ‡è®°é“¾è¡¨æ˜¯å¦ä¸ºç©ºã€‚ + +2. 大于127å—节的空闲内å˜å—,按照2的次幂区间大å°è¿›è¡Œç©ºé—²é“¾è¡¨ç®¡ç†ã€‚总共分为24个å°åŒºé—´ï¼Œæ¯ä¸ªå°åŒºé—´åˆç‰åˆ†ä¸º8个二级å°åŒºé—´ï¼Œè§ä¸Šå›¾ä¸ŠåŠéƒ¨åˆ†çš„Size Classå’ŒSize SubClass部分。æ¯ä¸ªäºŒçº§å°åŒºé—´å¯¹åº”ä¸€ä¸ªç©ºé—²é“¾è¡¨å’Œç”¨äºŽæ ‡è®°å¯¹åº”ç©ºé—²å†…å˜é“¾è¡¨æ˜¯å¦ä¸ºç©ºçš„一个比特ä½ã€‚总共24\*8=192个二级å°åŒºé—´ï¼Œå¯¹åº”192个空闲链表和192个比特ä½è¿›è¡Œæ ‡è®°é“¾è¡¨æ˜¯å¦ä¸ºç©ºã€‚ + +例如,当有40å—节的空闲内å˜éœ€è¦æ’入空闲链表时,对应å°åŒºé—´[40,43],第10个空闲链表,ä½å›¾æ ‡è®°çš„第10比特ä½ã€‚把40å—节的空闲内å˜æŒ‚载第10个空闲链表上,并判æ–是å¦éœ€è¦æ›´æ–°ä½å›¾æ ‡è®°ã€‚当需è¦ç”³è¯·40å—节的内å˜æ—¶ï¼Œæ ¹æ®ä½å›¾æ ‡è®°èŽ·å–å˜åœ¨æ»¡è¶³ç”³è¯·å¤§å°çš„内å˜å—的空闲链表,从空闲链表上获å–空闲内å˜èŠ‚点。如果分é…的节点大于需è¦ç”³è¯·çš„内å˜å¤§å°ï¼Œè¿›è¡Œåˆ†å‰²èŠ‚点æ“作,剩余的节点é‡æ–°æŒ‚载到相应的空闲链表上。当有580å—节的空闲内å˜éœ€è¦æ’入空闲链表时,对应二级å°åŒºé—´[2^9,2^9+2^6],第31+2\*8=47个空闲链表,并使用ä½å›¾çš„第47个比特ä½æ¥æ ‡è®°é“¾è¡¨æ˜¯å¦ä¸ºç©ºã€‚把580å—节的空闲内å˜æŒ‚载第47个空闲链表上,并判æ–是å¦éœ€è¦æ›´æ–°ä½å›¾æ ‡è®°ã€‚当需è¦ç”³è¯·580å—节的内å˜æ—¶ï¼Œæ ¹æ®ä½å›¾æ ‡è®°èŽ·å–å˜åœ¨æ»¡è¶³ç”³è¯·å¤§å°çš„内å˜å—的空闲链表,从空闲链表上获å–空闲内å˜èŠ‚点。如果分é…的节点大于需è¦ç”³è¯·çš„内å˜å¤§å°ï¼Œè¿›è¡Œåˆ†å‰²èŠ‚点æ“作,剩余的节点é‡æ–°æŒ‚载到相应的空闲链表上。如果对应的空闲链表为空,则å‘更大的内å˜åŒºé—´åŽ»æŸ¥è¯¢æ˜¯å¦æœ‰æ»¡è¶³æ¡ä»¶çš„空闲链表,实际计算时,会一次性查找到满足申请大å°çš„空闲链表。 + +内å˜ç®¡ç†ç»“构如下图所示: + + **图2** è½»é‡ç³»ç»ŸåŠ¨æ€å†…å˜ç®¡ç†ç»“构图 +  + +- 内å˜æ± æ± å¤´éƒ¨åˆ† + 内å˜æ± æ± å¤´éƒ¨åˆ†åŒ…å«å†…å˜æ± ä¿¡æ¯ã€ä½å›¾æ ‡è®°æ•°ç»„和空闲链表数组。内å˜æ± ä¿¡æ¯åŒ…å«å†…å˜æ± 起始地å€åŠå †åŒºåŸŸæ€»å¤§å°ï¼Œå†…å˜æ± 属性。ä½å›¾æ ‡è®°æ•°ç»„有7个32ä½æ— 符å·æ•´æ•°ç»„æˆï¼Œæ¯ä¸ªæ¯”特ä½æ ‡è®°å¯¹åº”的空闲链表是å¦æŒ‚载空闲内å˜å—节点。空闲内å˜é“¾è¡¨åŒ…å«223个空闲内å˜å¤´èŠ‚点信æ¯ï¼Œæ¯ä¸ªç©ºé—²å†…å˜å¤´èŠ‚点信æ¯ç»´æŠ¤å†…å˜èŠ‚点头和空闲链表ä¸çš„å‰é©±ã€åŽç»§ç©ºé—²å†…å˜èŠ‚点。 + +- 内å˜æ± 节点部分 + 包å«3ç§ç±»åž‹èŠ‚点:未使用空闲内å˜èŠ‚点,已使用内å˜èŠ‚点和尾节点。æ¯ä¸ªå†…å˜èŠ‚点维护一个å‰åºæŒ‡é’ˆï¼ŒæŒ‡å‘内å˜æ± ä¸ä¸Šä¸€ä¸ªå†…å˜èŠ‚点,还维护内å˜èŠ‚点的大å°å’Œä½¿ç”¨æ ‡è®°ã€‚空闲内å˜èŠ‚点和已使用内å˜èŠ‚点åŽé¢çš„内å˜åŒºåŸŸæ˜¯æ•°æ®åŸŸï¼Œå°¾èŠ‚点没有数æ®åŸŸã€‚ + +一些芯片片内RAM大å°æ— 法满足è¦æ±‚,需è¦ä½¿ç”¨ç‰‡å¤–物ç†å†…å˜è¿›è¡Œæ‰©å……ã€‚å¯¹äºŽè¿™æ ·çš„å¤šæ®µéžè¿žç»æ€§å†…å˜ï¼Œ LiteOS-Må†…æ ¸æ”¯æŒæŠŠå¤šä¸ªéžè¿žç»æ€§å†…å˜é€»è¾‘上åˆä¸€ï¼Œç”¨æˆ·ä¸æ„ŸçŸ¥åº•å±‚的多段éžè¿žç»æ€§å†…å˜åŒºåŸŸã€‚ LiteOS-Må†…æ ¸å†…å˜æ¨¡å—把ä¸è¿žç»çš„内å˜åŒºåŸŸä½œä¸ºç©ºé—²å†…å˜ç»“点æ’入到空闲内å˜èŠ‚点链表,把ä¸åŒå†…å˜åŒºåŸŸé—´çš„ä¸è¿žç»éƒ¨åˆ†æ ‡è®°ä¸ºè™šæ‹Ÿçš„已使用内å˜èŠ‚点,从逻辑上把多个éžè¿žç»æ€§å†…å˜åŒºåŸŸå®žçŽ°ä¸ºä¸€ä¸ªç»Ÿä¸€çš„内å˜æ± 。下é¢é€šè¿‡ç¤ºæ„图说明下多段éžè¿žç»æ€§å†…å˜çš„è¿è¡Œæœºåˆ¶ï¼š + + **图3** éžè¿žç»æ€§å†…å˜åˆä¸€ç¤ºæ„图 +  + +结åˆä¸Šè¿°ç¤ºæ„图,éžè¿žç»æ€§å†…å˜åˆå¹¶ä¸ºä¸€ä¸ªç»Ÿä¸€çš„内å˜æ± çš„æ¥éª¤å¦‚下: + +1. 把多段éžè¿žç»æ€§å†…å˜åŒºåŸŸçš„第一å—内å˜åŒºåŸŸé€šè¿‡è°ƒç”¨LOS_MemInit接å£è¿›è¡Œåˆå§‹åŒ–。 + +2. 获å–下一个内å˜åŒºåŸŸçš„开始地å€å’Œé•¿åº¦ï¼Œè®¡ç®—该内å˜åŒºåŸŸå’Œä¸Šä¸€å—内å˜åŒºåŸŸçš„间隔大å°gapSize。 + +3. 把内å˜åŒºåŸŸé—´éš”部分视为虚拟的已使用节点,使用上一个内å˜åŒºåŸŸçš„尾节点,设置其大å°ä¸ºgapSize+ OS_MEM_NODE_HEAD_SIZE。 + +4. 把当å‰å†…å˜åŒºåŸŸåˆ’分为一个空闲内å˜èŠ‚点和一个尾节点,把空闲内å˜èŠ‚点æ’入到空闲链表,并设置å„个节点的å‰åŽé“¾æŽ¥å…³ç³»ã€‚ + +5. 如果有更多的éžè¿žç»å†…å˜åŒºåŸŸï¼Œé‡å¤ä¸Šè¿°æ¥éª¤2-4。 + + +### å¼€å‘指导 + + +#### 使用场景 + +动æ€å†…å˜ç®¡ç†çš„主è¦å·¥ä½œæ˜¯åŠ¨æ€åˆ†é…并管ç†ç”¨æˆ·ç”³è¯·åˆ°çš„内å˜åŒºé—´ã€‚动æ€å†…å˜ç®¡ç†ä¸»è¦ç”¨äºŽç”¨æˆ·éœ€è¦ä½¿ç”¨å¤§å°ä¸ç‰çš„内å˜å—的场景,当用户需è¦ä½¿ç”¨å†…å˜æ—¶ï¼Œå¯ä»¥é€šè¿‡æ“作系统的动æ€å†…å˜ç”³è¯·å‡½æ•°ç´¢å–指定大å°çš„内å˜å—,一旦使用完毕,通过动æ€å†…å˜é‡Šæ”¾å‡½æ•°å½’还所å 用内å˜ï¼Œä½¿ä¹‹å¯ä»¥é‡å¤ä½¿ç”¨ã€‚ + + +#### 接å£è¯´æ˜Ž + +OpenHarmony LiteOS-M的动æ€å†…å˜ç®¡ç†ä¸»è¦ä¸ºç”¨æˆ·æ供以下功能,接å£è¯¦ç»†ä¿¡æ¯å¯ä»¥æŸ¥çœ‹APIå‚考。 + + **表1** 动æ€å†…å˜æ¨¡å—æŽ¥å£ + +| 功能分类 | 接å£æè¿° | +| -------- | -------- | +| åˆå§‹åŒ–å’Œåˆ é™¤å†…å˜æ± | - LOS_MemInit:åˆå§‹åŒ–一å—指定的动æ€å†…å˜æ± ,大å°ä¸ºsize。<br/>- LOS_MemDeInit:åˆ é™¤æŒ‡å®šå†…å˜æ± ,仅打开LOSCFG_MEM_MUL_POOL时有效。 | +| 申请ã€é‡Šæ”¾åŠ¨æ€å†…å˜ | - LOS_MemAlloc:从指定动æ€å†…å˜æ± ä¸ç”³è¯·size长度的内å˜ã€‚<br/>- LOS_MemFree:释放从指定动æ€å†…å˜ä¸ç”³è¯·çš„内å˜ã€‚<br/>- LOS_MemRealloc:释放从指定动æ€å†…å˜ä¸ç”³è¯·çš„内å˜ã€‚ | +| 获å–内å˜æ± ä¿¡æ¯ | - LOS_MemPoolSizeGet:获å–指定动æ€å†…å˜æ± 的总大å°ã€‚<br/>- LOS_MemTotalUsedGet:获å–指定动æ€å†…å˜æ± 的总使用é‡å¤§å°ã€‚<br/>- LOS_MemInfoGet:获å–指定内å˜æ± 的内å˜ç»“æž„ä¿¡æ¯ï¼ŒåŒ…括空闲内å˜å¤§å°ã€å·²ä½¿ç”¨å†…å˜å¤§å°ã€ç©ºé—²å†…å˜å—æ•°é‡ã€å·²ä½¿ç”¨çš„内å˜å—æ•°é‡ã€æœ€å¤§çš„空闲内å˜å—大å°ã€‚<br/>- LOS_MemPoolList:打å°ç³»ç»Ÿä¸å·²åˆå§‹åŒ–的所有内å˜æ± ,包括内å˜æ± 的起始地å€ã€å†…å˜æ± 大å°ã€ç©ºé—²å†…å˜æ€»å¤§å°ã€å·²ä½¿ç”¨å†…å˜æ€»å¤§å°ã€æœ€å¤§çš„空闲内å˜å—大å°ã€ç©ºé—²å†…å˜å—æ•°é‡ã€å·²ä½¿ç”¨çš„内å˜å—æ•°é‡ã€‚仅打开LOSCFG_MEM_MUL_POOL时有效。 | +| 获å–内å˜å—ä¿¡æ¯ | - LOS_MemFreeNodeShow:打å°æŒ‡å®šå†…å˜æ± 的空闲内å˜å—的大å°åŠæ•°é‡ã€‚<br/>- LOS_MemUsedNodeShow:打å°æŒ‡å®šå†…å˜æ± 的已使用内å˜å—的大å°åŠæ•°é‡ã€‚ | +| 检查指定内å˜æ± 的完整性 | LOS_MemIntegrityCheck:对指定内å˜æ± åšå®Œæ•´æ€§æ£€æŸ¥ï¼Œä»…打开LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK时有效。 | +| å¢žåŠ éžè¿žç»æ€§å†…å˜åŒºåŸŸ | LOS_MemRegionsAdd:支æŒå¤šæ®µéžè¿žç»æ€§å†…å˜åŒºåŸŸï¼ŒæŠŠéžè¿žç»æ€§å†…å˜åŒºåŸŸé€»è¾‘上整åˆä¸ºä¸€ä¸ªç»Ÿä¸€çš„内å˜æ± 。仅打开LOSCFG_MEM_MUL_REGIONS时有效。如果内å˜æ± 指针å‚æ•°pool为空,则使用多段内å˜çš„第一个åˆå§‹åŒ–为内å˜æ± ,其他内å˜åŒºåŸŸï¼Œä½œä¸ºç©ºé—²èŠ‚点æ’入;如果内å˜æ± 指针å‚æ•°poolä¸ä¸ºç©ºï¼Œåˆ™æŠŠå¤šæ®µå†…å˜ä½œä¸ºç©ºé—²èŠ‚点,æ’入到指定的内å˜æ± 。 | + +>  **说明:** +> - 由于动æ€å†…å˜ç®¡ç†éœ€è¦ç®¡ç†æŽ§åˆ¶å—æ•°æ®ç»“æž„æ¥ç®¡ç†å†…å˜ï¼Œè¿™äº›æ•°æ®ç»“构会é¢å¤–消耗内å˜ï¼Œæ•…实际用户å¯ä½¿ç”¨å†…å˜æ€»é‡å°äºŽé…置项OS_SYS_MEM_SIZE的大å°ã€‚ +> +> - 对é½åˆ†é…内å˜æŽ¥å£LOS_MemAllocAlign/LOS_MemMallocAlignå› ä¸ºè¦è¿›è¡Œåœ°å€å¯¹é½ï¼Œå¯èƒ½ä¼šé¢å¤–消耗部分内å˜ï¼Œæ•…å˜åœ¨ä¸€äº›é—失内å˜ï¼Œå½“系统释放该对é½å†…å˜æ—¶ï¼ŒåŒæ—¶å›žæ”¶ç”±äºŽå¯¹é½å¯¼è‡´çš„é—失内å˜ã€‚ +> +> - éžè¿žç»æ€§å†…å˜åŒºåŸŸæŽ¥å£LOS_MemRegionsAddçš„LosMemRegion数组å‚æ•°ä¼ å…¥çš„éžè¿žç»æ€§å†…å˜åŒºåŸŸéœ€è¦æŒ‰å„个内å˜åŒºåŸŸçš„内å˜å¼€å§‹åœ°å€å‡åºï¼Œä¸”内å˜åŒºåŸŸä¸èƒ½é‡å 。 + + +#### å¼€å‘æµç¨‹ + +本节介ç»ä½¿ç”¨åŠ¨æ€å†…å˜çš„典型场景开å‘æµç¨‹ã€‚ + +1. åˆå§‹åŒ–LOS_MemInit。 + åˆå§‹ä¸€ä¸ªå†…å˜æ± åŽç”Ÿæˆä¸€ä¸ªå†…å˜æ± 控制头ã€å°¾èŠ‚点EndNode,剩余的内å˜è¢«æ ‡è®°ä¸ºFreeNode内å˜èŠ‚点。注:EndNode作为内å˜æ± 末尾的节点,size为0。 + +1. 申请任æ„大å°çš„动æ€å†…å˜LOS_MemAlloc。 + 判æ–动æ€å†…å˜æ± ä¸æ˜¯å¦å˜åœ¨å¤§äºŽç”³è¯·é‡å¤§å°çš„空闲内å˜å—空间,若å˜åœ¨ï¼Œåˆ™åˆ’出一å—内å˜å—,以指针形å¼è¿”回,若ä¸å˜åœ¨ï¼Œè¿”回NULL。如果空闲内å˜å—大于申请é‡ï¼Œéœ€è¦å¯¹å†…å˜å—进行分割,剩余的部分作为空闲内å˜å—挂载到空闲内å˜é“¾è¡¨ä¸Šã€‚ + +1. 释放动æ€å†…å˜LOS_MemFree。 + 回收内å˜å—,供下一次使用。调用LOS_MemFree释放内å˜å—,则会回收内å˜å—ï¼Œå¹¶ä¸”å°†å…¶æ ‡è®°ä¸ºFreeNode。在回收内å˜å—时,相邻的FreeNode会自动åˆå¹¶ã€‚ + + +#### 编程实例 + +本实例执行以下æ¥éª¤ï¼š + +1. åˆå§‹åŒ–一个动æ€å†…å˜æ± 。 + +2. 从动æ€å†…å˜æ± ä¸ç”³è¯·ä¸€ä¸ªå†…å˜å—。 + +3. 在内å˜å—ä¸å˜æ”¾ä¸€ä¸ªæ•°æ®ã€‚ + +4. 打å°å‡ºå†…å˜å—ä¸çš„æ•°æ®ã€‚ + +5. 释放该内å˜å—。 + +示例代ç 如下: + + +``` +#include "los_memory.h" +#define TEST_POOL_SIZE (2*1024) +__attribute__((aligned(4))) UINT8 g_testPool[TEST_POOL_SIZE]; +VOID Example_DynMem(VOID) +{ + UINT32 *mem = NULL; + UINT32 ret; + + /*åˆå§‹åŒ–内å˜æ± */ + ret = LOS_MemInit(g_testPool, TEST_POOL_SIZE); + if (LOS_OK == ret) { + printf("Mem init success!\n"); + } else { + printf("Mem init failed!\n"); + return; + } + + /*分é…内å˜*/ + mem = (UINT32 *)LOS_MemAlloc(g_testPool, 4); + if (NULL == mem) { + printf("Mem alloc failed!\n"); + return; + } + printf("Mem alloc success!\n"); + + /*赋值*/ + *mem = 828; + printf("*mem = %d\n", *mem); + + /*释放内å˜*/ + ret = LOS_MemFree(g_testPool, mem); + if (LOS_OK == ret) { + printf("Mem free success!\n"); + } else { + printf("Mem free failed!\n"); + } + + return; +} +``` + + +#### ç»“æžœéªŒè¯ + +输出结果如下: + + +``` +Mem init success! +Mem alloc success! +*mem = 828 +Mem free success! +``` diff --git a/zh-cn/device-dev/kernel/kernel-mini-extend-file.md b/zh-cn/device-dev/kernel/kernel-mini-extend-file.md index 65e95f800c497f322f28bc990c0665978e7580bf..e0df347da27479ec128062a02c44d458cf6cd9b7 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-extend-file.md +++ b/zh-cn/device-dev/kernel/kernel-mini-extend-file.md @@ -40,7 +40,292 @@ Mæ ¸çš„æ–‡ä»¶ç³»ç»Ÿå系统当å‰æ”¯æŒçš„文件系统有FATFS与LittleFSã€‚åŒ | umount2 | 分区å¸è½½ï¼Œå¯é€šè¿‡MNT_FORCEå‚数进行强制å¸è½½ | æ”¯æŒ | ä¸æ”¯æŒ | | statfs | 获å–åˆ†åŒºä¿¡æ¯ | æ”¯æŒ | ä¸æ”¯æŒ | +## FAT -- **[FAT](kernel-mini-extend-file-fat.md)** -- **[LittleFS](kernel-mini-extend-file-lit.md)** \ No newline at end of file +### 基本概念 + +FAT文件系统是File Allocation Table(文件é…置表)的简称,主è¦åŒ…括DBR区ã€FAT区ã€DATA区三个区域。其ä¸ï¼ŒFAT区å„个表项记录å˜å‚¨è®¾å¤‡ä¸å¯¹åº”簇的信æ¯ï¼ŒåŒ…括簇是å¦è¢«ä½¿ç”¨ã€æ–‡ä»¶ä¸‹ä¸€ä¸ªç°‡çš„ç¼–å·ã€æ˜¯å¦æ–‡ä»¶ç»“å°¾ç‰ã€‚FAT文件系统有FAT12ã€FAT16ã€FAT32ç‰å¤šç§æ ¼å¼ï¼Œå…¶ä¸ï¼Œ12ã€16ã€32è¡¨ç¤ºå¯¹åº”æ ¼å¼ä¸FAT表项的比特数。FAT文件系统支æŒå¤šç§ä»‹è´¨ï¼Œç‰¹åˆ«åœ¨å¯ç§»åŠ¨å˜å‚¨ä»‹è´¨ï¼ˆU盘ã€SDå¡ã€ç§»åŠ¨ç¡¬ç›˜ç‰ï¼‰ä¸Šå¹¿æ³›ä½¿ç”¨ï¼Œä½¿åµŒå…¥å¼è®¾å¤‡å’ŒWindowsã€Linuxç‰æ¡Œé¢ç³»ç»Ÿä¿æŒå¾ˆå¥½çš„兼容性,方便用户管ç†æ“作文件。 + +OpenHarmonyå†…æ ¸æ”¯æŒFAT12ã€FAT16与FAT32三ç§æ ¼å¼çš„FAT文件系统,具有代ç é‡å°ã€èµ„æºå 用å°ã€å¯è£åˆ‡ã€æ”¯æŒå¤šç§ç‰©ç†ä»‹è´¨ç‰ç‰¹æ€§ï¼Œå¹¶ä¸”与Windowsã€Linuxç‰ç³»ç»Ÿä¿æŒå…¼å®¹ï¼Œæ”¯æŒå¤šè®¾å¤‡ã€å¤šåˆ†åŒºè¯†åˆ«ç‰åŠŸèƒ½ã€‚OpenHarmonyå†…æ ¸æ”¯æŒç¡¬ç›˜å¤šåˆ†åŒºï¼Œå¯ä»¥åœ¨ä¸»åˆ†åŒºä»¥åŠé€»è¾‘分区上创建FAT文件系统。 + + +### å¼€å‘指导 + + +#### é©±åŠ¨é€‚é… + +FAT文件系统的使用需è¦åº•å±‚MMC相关驱动的支æŒã€‚在一个带MMCå˜å‚¨è®¾å¤‡çš„æ¿å上è¿è¡ŒFATFS,需è¦ï¼š + +1ã€é€‚é…æ¿ç«¯EMMC驱动,实现disk_statusã€disk_initializeã€disk_readã€disk_writeã€disk_ioctl接å£ï¼› + +2ã€æ–°å¢žfs_config.h文件,é…ç½®FS_MAX_SS(å˜å‚¨è®¾å¤‡æœ€å¤§sector大å°ï¼‰ã€FF_VOLUME_STRS(分区å)ç‰ä¿¡æ¯ï¼Œä¾‹å¦‚: + + +``` +#define FF_VOLUME_STRS "system", "inner", "update", "user" +#define FS_MAX_SS 512 +#define FAT_MAX_OPEN_FILES 50 +``` + + +#### å¼€å‘æµç¨‹ + +>  **说明:** +> - FATFS文件与目录æ“作: +> - å•ä¸ªæ–‡ä»¶å¤§å°ä¸è¶…过4G。 +> - 支æŒåŒæ—¶æ‰“开的文件数最大为FAT_MAX_OPEN_FILES,文件夹数最大为FAT_MAX_OPEN_DIRS。 +> - æš‚ä¸æ”¯æŒæ ¹ç›®å½•ç®¡ç†ï¼Œæ–‡ä»¶/目录åå‡ä»¥åˆ†åŒºå开头,例如“user/testfileâ€å°±æ˜¯åœ¨â€œuserâ€åˆ†åŒºä¸‹å为“testfileâ€çš„文件或目录。 +> - 若需è¦åŒæ—¶å¤šæ¬¡æ‰“å¼€åŒä¸€æ–‡ä»¶ï¼Œå¿…须全部使用åªè¯»æ–¹å¼ï¼ˆO_RDONLY)。以å¯å†™æ–¹å¼ï¼ˆO_RDWRã€O_WRONLYç‰ï¼‰åªèƒ½æ‰“开一次。 +> - 读写指针未分离,例如以O_APPENDï¼ˆè¿½åŠ å†™ï¼‰æ–¹å¼æ‰“开文件åŽï¼Œè¯»æŒ‡é’ˆä¹Ÿåœ¨æ–‡ä»¶å°¾ï¼Œä»Žå¤´è¯»æ–‡ä»¶å‰éœ€è¦ç”¨æˆ·æ‰‹åŠ¨ç½®ä½ã€‚ +> - æš‚ä¸æ”¯æŒæ–‡ä»¶ä¸Žç›®å½•çš„æƒé™ç®¡ç†ã€‚ +> - statåŠfstat接å£æš‚ä¸æ”¯æŒæŸ¥è¯¢ä¿®æ”¹æ—¶é—´ã€åˆ›å»ºæ—¶é—´å’Œæœ€åŽè®¿é—®æ—¶é—´ã€‚微软FATåè®®ä¸æ”¯æŒ1980年以å‰çš„时间。 +> +> - FATFS分区挂载与å¸è½½ï¼š +> - 支æŒä»¥åªè¯»å±žæ€§æŒ‚载分区。当mount函数的入å‚为MS_RDONLY时,所有的带有写入的接å£ï¼Œå¦‚writeã€mkdirã€unlink,以åŠéžO_RDONLY属性的open,将å‡è¢«æ‹’ç»ã€‚ +> - mount支æŒé€šè¿‡MS_REMOUNTæ ‡è®°ä¿®æ”¹å·²æŒ‚è½½åˆ†åŒºçš„æƒé™ã€‚ +> - 在umountæ“作å‰ï¼Œéœ€ç¡®ä¿æ‰€æœ‰ç›®å½•åŠæ–‡ä»¶å…¨éƒ¨å…³é—。 +> - umount2支æŒé€šè¿‡MNT_FORCEå‚数强制关é—所有文件与文件夹并umount,但å¯èƒ½é€ æˆæ•°æ®ä¸¢å¤±ï¼Œè¯·è°¨æ…Žä½¿ç”¨ã€‚ +> +> - FATFS支æŒé‡æ–°åˆ’分å˜å‚¨è®¾å¤‡åˆ†åŒºã€æ ¼å¼åŒ–分区,对应接å£ä¸ºfatfs_fdisk与fatfs_format: +> - 在fatfs_formatæ“作之å‰ï¼Œè‹¥éœ€è¦æ ¼å¼åŒ–的分区已挂载,需确ä¿åˆ†åŒºä¸çš„所有目录åŠæ–‡ä»¶å…¨éƒ¨å…³é—,并且分区umount。 +> - 在fatfs_fdiskæ“作å‰ï¼Œéœ€è¦è¯¥è®¾å¤‡ä¸çš„所有分区å‡å·²umount。 +> - fatfs_fdisk与fatfs_formatä¼šé€ æˆè®¾å¤‡æ•°æ®ä¸¢å¤±ï¼Œè¯·è°¨æ…Žä½¿ç”¨ã€‚ + + +### 编程实例 + + +#### 实例æè¿° + +本实例实现以下功能: + +1. 创建目录“user/test†+ +2. 在“user/testâ€ç›®å½•ä¸‹åˆ›å»ºæ–‡ä»¶â€œfile.txt†+ +3. 在文件起始ä½ç½®å†™å…¥â€œHello OpenHarmony!†+ +4. å°†æ–‡ä»¶å†…å®¹åˆ·å…¥è®¾å¤‡ä¸ + +5. 设置å移到文件起始ä½ç½® + +6. 读å–文件内容 + +7. å…³é—文件 + +8. åˆ é™¤æ–‡ä»¶ + +9. åˆ é™¤ç›®å½• + + +#### 示例代ç + + **å‰ææ¡ä»¶ï¼š** + + 系统已将MMC设备分区挂载到user目录 + + **代ç 实现如下:** + + ``` + #include <stdio.h> + #include <string.h> + #include "sys/stat.h" + #include "fcntl.h" + #include "unistd.h" + + #define LOS_OK 0 + #define LOS_NOK -1 + + int FatfsTest(void) + { + int ret; + int fd = -1; + ssize_t len; + off_t off; + char dirName[20] = "user/test"; + char fileName[20] = "user/test/file.txt"; + char writeBuf[20] = "Hello OpenHarmony!"; + char readBuf[20] = {0}; + + /* 创建目录“user/test†*/ + ret = mkdir(dirName, 0777); + if (ret != LOS_OK) { + printf("mkdir failed.\n"); + return LOS_NOK; + } + + /* 创建å¯è¯»å†™æ–‡ä»¶"user/test/file.txt" */ + fd = open(fileName, O_RDWR | O_CREAT, 0777); + if (fd < 0) { + printf("open file failed.\n"); + return LOS_NOK; + } + + /* å°†writeBufä¸çš„内容写入文件 */ + len = write(fd, writeBuf, strlen(writeBuf)); + if (len != strlen(writeBuf)) { + printf("write file failed.\n"); + return LOS_NOK; + } + + /* 将文件内容刷入å˜å‚¨è®¾å¤‡ä¸ */ + ret = fsync(fd); + if (ret != LOS_OK) { + printf("fsync failed.\n"); + return LOS_NOK; + } + + /* 将读写指针å移至文件头 */ + off = lseek(fd, 0, SEEK_SET); + if (off != 0) { + printf("lseek failed.\n"); + return LOS_NOK; + } + + /* 将文件内容读出至readBufä¸ï¼Œè¯»å–长度为readBufå¤§å° */ + len = read(fd, readBuf, sizeof(readBuf)); + if (len != strlen(writeBuf)) { + printf("read file failed.\n"); + return LOS_NOK; + } + printf("%s\n", readBuf); + + /* å…³é—文件 */ + ret = close(fd); + if (ret != LOS_OK) { + printf("close failed.\n"); + return LOS_NOK; + } + + /* åˆ é™¤æ–‡ä»¶"user/test/file.txt" */ + ret = unlink(fileName); + if (ret != LOS_OK) { + printf("unlink failed.\n"); + return LOS_NOK; + } + + /* åˆ é™¤ç›®å½•â€œuser/test†*/ + ret = rmdir(dirName); + if (ret != LOS_OK) { + printf("rmdir failed.\n"); + return LOS_NOK; + } + + return LOS_OK; + } + ``` + + +#### ç»“æžœéªŒè¯ + +编译è¿è¡Œå¾—到的结果为: + + +``` +Hello OpenHarmony! +``` +## LittleFS + + +### 基本概念 + +LittleFS是一个å°åž‹çš„Flash文件系统,它结åˆæ—¥å¿—结构(log-structured)文件系统和COW(copy-on-write)文件系统的æ€æƒ³ï¼Œä»¥æ—¥å¿—结构å˜å‚¨å…ƒæ•°æ®ï¼Œä»¥COW结构å˜å‚¨æ•°æ®ã€‚è¿™ç§ç‰¹æ®Šçš„å˜å‚¨æ–¹å¼ï¼Œä½¿LittleFS具有强大的掉电æ¢å¤èƒ½åŠ›ï¼ˆpower-loss resilience)。分é…COWæ•°æ®å—æ—¶LittleFS采用了å为统计æŸè€—å‡è¡¡çš„动æ€æŸè€—å‡è¡¡ç®—法,使Flash设备的寿命得到有效ä¿éšœã€‚åŒæ—¶LittleFS针对资æºç´§ç¼ºçš„å°åž‹è®¾å¤‡è¿›è¡Œè®¾è®¡ï¼Œå…·æœ‰æžå…¶æœ‰é™çš„ROMå’ŒRAMå 用,并且所有RAM的使用都通过一个å¯é…置的固定大å°ç¼“冲区进行分é…,ä¸ä¼šéšæ–‡ä»¶ç³»ç»Ÿçš„扩大å æ®æ›´å¤šçš„系统资æºã€‚ + +当在一个资æºéžå¸¸ç´§ç¼ºçš„å°åž‹è®¾å¤‡ä¸Šï¼Œå¯»æ‰¾ä¸€ä¸ªå…·æœ‰æŽ‰ç”µæ¢å¤èƒ½åŠ›å¹¶æ”¯æŒæŸè€—å‡è¡¡çš„Flash文件系统时,LittleFS是一个比较好的选择。 + + +### å¼€å‘指导 + +移æ¤LittleFS到新硬件设备上,需è¦ç”³æ˜Žlfs_config: + + +``` +const struct lfs_config cfg = { + // block device operations + .read = user_provided_block_device_read, + .prog = user_provided_block_device_prog, + .erase = user_provided_block_device_erase, + .sync = user_provided_block_device_sync, + + // block device configuration + .read_size = 16, + .prog_size = 16, + .block_size = 4096, + .block_count = 128, + .cache_size = 16, + .lookahead_size = 16, + .block_cycles = 500, +}; +``` + +å…¶ä¸.read,.prog,.erase,.sync分别对应该硬件平å°ä¸Šçš„底层的读写\擦除\åŒæ¥ç‰æŽ¥å£ã€‚ + +read_size æ¯æ¬¡è¯»å–çš„å—节数,å¯ä»¥æ¯”物ç†è¯»å•å…ƒå¤§ä»¥æ”¹å–„性能,这个数值决定了读缓å˜çš„大å°ï¼Œä½†å€¼å¤ªå¤§ä¼šå¸¦æ¥æ›´å¤šçš„内å˜æ¶ˆè€—。 + +prog_size æ¯æ¬¡å†™å…¥çš„å—节数,å¯ä»¥æ¯”物ç†å†™å•å…ƒå¤§ä»¥æ”¹å–„性能,这个数值决定了写缓å˜çš„大å°ï¼Œå¿…须是read_sizeçš„æ•´æ•°å€ï¼Œä½†å€¼å¤ªå¤§ä¼šå¸¦æ¥æ›´å¤šçš„内å˜æ¶ˆè€—。 + +block_size æ¯ä¸ªæ“¦é™¤å—çš„å—节数,å¯ä»¥æ¯”物ç†æ“¦é™¤å•å…ƒå¤§ï¼Œä½†æ¤æ•°å€¼åº”å°½å¯èƒ½å°å› 为æ¯ä¸ªæ–‡ä»¶è‡³å°‘会å 用一个å—。必须是prog_sizeçš„æ•´æ•°å€ã€‚ + +block_count å¯ä»¥è¢«æ“¦é™¤çš„å—æ•°é‡ï¼Œè¿™å–决于å—设备的容é‡åŠæ“¦é™¤å—的大å°ã€‚ + + +### 示例代ç + + 代ç 实现如下: + +``` +#include "lfs.h" +#include "stdio.h" +lfs_t lfs; +lfs_file_t file; +const struct lfs_config cfg = { + // block device operations + .read = user_provided_block_device_read, + .prog = user_provided_block_device_prog, + .erase = user_provided_block_device_erase, + .sync = user_provided_block_device_sync, + // block device configuration + .read_size = 16, + .prog_size = 16, + .block_size = 4096, + .block_count = 128, + .cache_size = 16, + .lookahead_size = 16, + .block_cycles = 500, +}; +int main(void) { + // mount the filesystem + int err = lfs_mount(&lfs, &cfg); + // reformat if we can't mount the filesystem + // this should only happen on the first boot + if (err) { + lfs_format(&lfs, &cfg); + lfs_mount(&lfs, &cfg); + } + // read current count + uint32_t boot_count = 0; + lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT); + lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count)); + // update boot count + boot_count += 1; + lfs_file_rewind(&lfs, &file); + lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count)); + // remember the storage is not updated until the file is closed successfully + lfs_file_close(&lfs, &file); + // release any resources we were using + lfs_unmount(&lfs); + // print the boot count + printf("boot_count: %d\n", boot_count); +} +``` + + + **结果验è¯** + +首次编译è¿è¡Œå¾—到的结果为: + + +``` +Say hello 1 times. +``` \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-mini-memory-debug.md b/zh-cn/device-dev/kernel/kernel-mini-memory-debug.md index 625990100c08618f1beef05b71bf496e67f2d42a..fab4a6266dabae8db627379f1ffb8073961e6d37 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-memory-debug.md +++ b/zh-cn/device-dev/kernel/kernel-mini-memory-debug.md @@ -4,8 +4,336 @@ 内å˜è°ƒæµ‹æ–¹æ³•æ—¨åœ¨è¾…助定ä½åŠ¨æ€å†…å˜ç›¸å…³é—®é¢˜ï¼Œæ供了基础的动æ€å†…å˜æ± ä¿¡æ¯ç»Ÿè®¡æ‰‹æ®µï¼Œå‘用户呈现内å˜æ± 水线ã€ç¢Žç‰‡çŽ‡ç‰ä¿¡æ¯ï¼›æ供了内å˜æ³„æ¼æ£€æµ‹æ‰‹æ®µï¼Œæ–¹ä¾¿ç”¨æˆ·å‡†ç¡®å®šä½å˜åœ¨å†…å˜æ³„æ¼çš„代ç 行,也å¯ä»¥è¾…助分æžç³»ç»Ÿå„个模å—内å˜çš„使用情况;æ供了踩内å˜æ£€æµ‹æ‰‹æ®µï¼Œå¯ä»¥è¾…助定ä½è¶Šç•Œè¸©å†…å˜çš„场景。 -- **[内å˜ä¿¡æ¯ç»Ÿè®¡](kernel-mini-memory-debug-mes.md)** +## 内å˜ä¿¡æ¯ç»Ÿè®¡ -- **[内å˜æ³„æ¼æ£€æµ‹](kernel-mini-memory-debug-det.md)** -- **[踩内å˜æ£€æµ‹](kernel-mini-memory-debug-cet.md)** \ No newline at end of file +### 基础概念 + +内å˜ä¿¡æ¯åŒ…括内å˜æ± 大å°ã€å†…å˜ä½¿ç”¨é‡ã€å‰©ä½™å†…å˜å¤§å°ã€æœ€å¤§ç©ºé—²å†…å˜ã€å†…å˜æ°´çº¿ã€å†…å˜èŠ‚点数统计ã€ç¢Žç‰‡çŽ‡ç‰ã€‚ + +- 内å˜æ°´çº¿ï¼šå³å†…å˜æ± 的最大使用é‡ï¼Œæ¯æ¬¡ç”³è¯·å’Œé‡Šæ”¾æ—¶ï¼Œéƒ½ä¼šæ›´æ–°æ°´çº¿å€¼ï¼Œå®žé™…业务å¯æ ¹æ®è¯¥å€¼ï¼Œä¼˜åŒ–内å˜æ± 大å°ï¼› + +- 碎片率:衡é‡å†…å˜æ± 的碎片化程度,碎片率高表现为内å˜æ± 剩余内å˜å¾ˆå¤šï¼Œä½†æ˜¯æœ€å¤§ç©ºé—²å†…å˜å—很å°ï¼Œå¯ä»¥ç”¨å…¬å¼ï¼ˆfragment=100-100\*最大空闲内å˜å—大å°/剩余内å˜å¤§å°ï¼‰æ¥åº¦é‡ï¼› + +- 其他å‚数:通过调用接å£ï¼ˆè¯¦è§[内å˜ç®¡ç†](../kernel/kernel-mini-basic-memory-basic.md)ç« èŠ‚æŽ¥å£è¯´æ˜Žï¼‰ï¼Œæ‰«æ内å˜æ± 的节点信æ¯ï¼Œç»Ÿè®¡å‡ºç›¸å…³ä¿¡æ¯ã€‚ + + +### 功能é…ç½® + +LOSCFG_MEM_WATERLINE:开关å®ï¼Œé»˜è®¤æ‰“开;若关é—这个功能,在target_config.hä¸å°†è¿™ä¸ªå®å®šä¹‰ä¸º0。如需获å–内å˜æ°´çº¿ï¼Œéœ€è¦æ‰“开该é…置。 + + +### å¼€å‘指导 + + +#### å¼€å‘æµç¨‹ + +关键结构体介ç»ï¼š + + +``` +typedef struct { + UINT32 totalUsedSize; // 内å˜æ± 的内å˜ä½¿ç”¨é‡ + UINT32 totalFreeSize; // 内å˜æ± 的剩余内å˜å¤§å° + UINT32 maxFreeNodeSize; // 内å˜æ± 的最大空闲内å˜å—å¤§å° + UINT32 usedNodeNum; // 内å˜æ± çš„éžç©ºé—²å†…å˜å—个数 + UINT32 freeNodeNum; // 内å˜æ± 的空闲内å˜å—个数 +#if (LOSCFG_MEM_WATERLINE == 1) // 默认打开,如需关é—,在target_config.hä¸å°†è¯¥å®è®¾ç½®ä¸º0 + UINT32 usageWaterLine; // 内å˜æ± 的水线值 +#endif +} LOS_MEM_POOL_STATUS; +``` + +- 内å˜æ°´çº¿èŽ·å–:调用LOS_MemInfoGet接å£ï¼Œç¬¬1个å‚数是内å˜æ± 首地å€ï¼Œç¬¬2个å‚数是LOS_MEM_POOL_STATUS类型的å¥æŸ„,其ä¸å—段usageWaterLineå³æ°´çº¿å€¼ã€‚ + +- 内å˜ç¢Žç‰‡çŽ‡è®¡ç®—:åŒæ ·è°ƒç”¨LOS_MemInfoGet接å£ï¼Œå¯ä»¥èŽ·å–内å˜æ± 的剩余内å˜å¤§å°å’Œæœ€å¤§ç©ºé—²å†…å˜å—大å°ï¼Œç„¶åŽæ ¹æ®å…¬å¼ï¼ˆfragment=100-100\*最大空闲内å˜å—大å°/剩余内å˜å¤§å°ï¼‰å¾—出æ¤æ—¶çš„动æ€å†…å˜æ± 碎片率。 + + +#### 编程实例 + +本实例实现如下功能: + +1.创建一个监控任务,用于获å–内å˜æ± çš„ä¿¡æ¯ï¼› + +2.调用LOS_MemInfoGet接å£ï¼ŒèŽ·å–内å˜æ± 的基础信æ¯ï¼› + +3.利用公å¼ç®—出使用率åŠç¢Žç‰‡çŽ‡ã€‚ + + +#### 示例代ç + + 代ç 实现如下: + +``` +#include <stdio.h> +#include <string.h> +#include "los_task.h" +#include "los_memory.h" +#include "los_config.h" + + +void MemInfoTaskFunc(void) +{ + LOS_MEM_POOL_STATUS poolStatus = {0}; + + /* pool为è¦ç»Ÿè®¡ä¿¡æ¯çš„内å˜åœ°å€ï¼Œæ¤å¤„以OS_SYS_MEM_ADDR为例 */ + void *pool = OS_SYS_MEM_ADDR; + LOS_MemInfoGet(pool, &poolStatus); + /* 算出内å˜æ± 当å‰çš„碎片率百分比 */ + unsigned char fragment = 100 - poolStatus.maxFreeNodeSize * 100 / poolStatus.totalFreeSize; + /* 算出内å˜æ± 当å‰çš„使用率百分比 */ + unsigned char usage = LOS_MemTotalUsedGet(pool) * 100 / LOS_MemPoolSizeGet(pool); + printf("usage = %d, fragment = %d, maxFreeSize = %d, totalFreeSize = %d, waterLine = %d\n", usage, fragment, poolStatus.maxFreeNodeSize, + poolStatus.totalFreeSize, poolStatus.usageWaterLine); +} + +int MemTest(void) +{ + unsigned int ret; + unsigned int taskID; + TSK_INIT_PARAM_S taskStatus = {0}; + taskStatus.pfnTaskEntry = (TSK_ENTRY_FUNC)MemInfoTaskFunc; + taskStatus.uwStackSize = 0x1000; + taskStatus.pcName = "memInfo"; + taskStatus.usTaskPrio = 10; + ret = LOS_TaskCreate(&taskID, &taskStatus); + if (ret != LOS_OK) { + printf("task create failed\n"); + return -1; + } + return 0; +} +``` + + +#### ç»“æžœéªŒè¯ + +编译è¿è¡Œè¾“出的结果如下: + + +``` +usage = 22, fragment = 3, maxFreeSize = 49056, totalFreeSize = 50132, waterLine = 1414 +``` +## 内å˜æ³„æ¼æ£€æµ‹ + + +### 基础概念 + +内å˜æ³„æ¼æ£€æµ‹æœºåˆ¶ä½œä¸ºå†…æ ¸çš„å¯é€‰åŠŸèƒ½ï¼Œç”¨äºŽè¾…助定ä½åŠ¨æ€å†…å˜æ³„æ¼é—®é¢˜ã€‚å¼€å¯è¯¥åŠŸèƒ½ï¼ŒåŠ¨æ€å†…å˜æœºåˆ¶ä¼šè‡ªåŠ¨è®°å½•ç”³è¯·å†…å˜æ—¶çš„函数调用关系(下文简称LR)。如果出现泄æ¼ï¼Œå°±å¯ä»¥åˆ©ç”¨è¿™äº›è®°å½•çš„ä¿¡æ¯ï¼Œæ‰¾åˆ°å†…å˜ç”³è¯·çš„地方,方便进一æ¥ç¡®è®¤ã€‚ + + +### 功能é…ç½® + +1. LOSCFG_MEM_LEAKCHECK:开关å®ï¼Œé»˜è®¤å…³é—;若打开这个功能,在target_config.hä¸å°†è¿™ä¸ªå®å®šä¹‰ä¸º1。 + +2. LOSCFG_MEM_RECORD_LR_CNT:记录的LR层数,默认3层;æ¯å±‚LR消耗sizeof(void \*)å—节数的内å˜ã€‚ + +3. LOSCFG_MEM_OMIT_LR_CNT:忽略的LR层数,默认4层,å³ä»Žè°ƒç”¨LOS_MemAlloc的函数开始记录,å¯æ ¹æ®å®žé™…情况调整。为啥需è¦è¿™ä¸ªé…置?有3ç‚¹åŽŸå› å¦‚ä¸‹ï¼š + - LOS_MemAlloc接å£å†…部也有函数调用; + - 外部å¯èƒ½å¯¹LOS_MemAlloc接å£æœ‰å°è£…ï¼› + - LOSCFG_MEM_RECORD_LR_CNT é…置的LR层数有é™ï¼› + +æ£ç¡®é…置这个å®ï¼Œå°†æ— 效的LR层数忽略,就å¯ä»¥è®°å½•æœ‰æ•ˆçš„LR层数,节çœå†…å˜æ¶ˆè€—。 + + +### å¼€å‘指导 + + +#### å¼€å‘æµç¨‹ + +该调测功能å¯ä»¥åˆ†æžå…³é”®çš„代ç 逻辑ä¸æ˜¯å¦å˜åœ¨å†…å˜æ³„æ¼ã€‚å¼€å¯è¿™ä¸ªåŠŸèƒ½ï¼Œæ¯æ¬¡ç”³è¯·å†…å˜æ—¶ï¼Œä¼šè®°å½•LRä¿¡æ¯ã€‚在需è¦æ£€æµ‹çš„代ç 段å‰åŽï¼Œè°ƒç”¨LOS_MemUsedNodeShow接å£ï¼Œæ¯æ¬¡éƒ½ä¼šæ‰“å°æŒ‡å®šå†…å˜æ± 已使用的全部节点信æ¯ï¼Œå¯¹æ¯”å‰åŽä¸¤æ¬¡çš„节点信æ¯ï¼Œæ–°å¢žçš„节点信æ¯å°±æ˜¯ç–‘似泄æ¼çš„内å˜èŠ‚点。通过LR,å¯ä»¥æ‰¾åˆ°å…·ä½“申请的代ç ä½ç½®ï¼Œè¿›ä¸€æ¥ç¡®è®¤æ˜¯å¦æ³„æ¼ã€‚ + +调用LOS_MemUsedNodeShow接å£è¾“出的节点信æ¯æ ¼å¼å¦‚下:æ¯1行为一个节点信æ¯ï¼›ç¬¬1列为节点地å€ï¼Œå¯ä»¥æ ¹æ®è¿™ä¸ªåœ°å€ï¼Œä½¿ç”¨GDBç‰æ‰‹æ®µæŸ¥çœ‹èŠ‚点完整信æ¯ï¼›ç¬¬2列为节点的大å°ï¼Œç‰äºŽèŠ‚点头大å°+æ•°æ®åŸŸå¤§å°ï¼›ç¬¬3~5列为函数调用关系LR地å€ï¼Œå¯ä»¥æ ¹æ®è¿™ä¸ªå€¼ï¼Œç»“åˆæ±‡ç¼–文件,查看该节点具体申请的ä½ç½®ã€‚ + + +``` +node size LR[0] LR[1] LR[2] +0x10017320: 0x528 0x9b004eba 0x9b004f60 0x9b005002 +0x10017848: 0xe0 0x9b02c24e 0x9b02c246 0x9b008ef0 +0x10017928: 0x50 0x9b008ed0 0x9b068902 0x9b0687c4 +0x10017978: 0x24 0x9b008ed0 0x9b068924 0x9b0687c4 +0x1001799c: 0x30 0x9b02c24e 0x9b02c246 0x9b008ef0 +0x100179cc: 0x5c 0x9b02c24e 0x9b02c246 0x9b008ef0 +``` + +>  **注æ„:** +> å¼€å¯å†…å˜æ£€æµ‹ä¼šå½±å“内å˜ç”³è¯·çš„性能,且æ¯ä¸ªå†…å˜èŠ‚点都会记录LR地å€ï¼Œå†…å˜å¼€é”€ä¹ŸåŠ 大。 + + +#### 编程实例 + +本实例实现如下功能:构建内å˜æ³„æ¼ä»£ç 段。 + +1. 调用LOS_MemUsedNodeShow接å£ï¼Œè¾“出全部节点信æ¯æ‰“å°ï¼› + +2. 申请内å˜ï¼Œä½†æ²¡æœ‰é‡Šæ”¾ï¼Œæ¨¡æ‹Ÿå†…å˜æ³„æ¼ï¼› + +3. å†æ¬¡è°ƒç”¨LOS_MemUsedNodeShow接å£ï¼Œè¾“出全部节点信æ¯æ‰“å°ï¼› + +4. 将两次log进行对比,得出泄æ¼çš„节点信æ¯ï¼› + +5. 通过LR地å€ï¼Œæ‰¾å‡ºæ³„æ¼çš„代ç ä½ç½®ï¼› + + +#### 示例代ç + +代ç 实现如下: + + +``` +#include <stdio.h> +#include <string.h> +#include "los_memory.h" +#include "los_config.h" + +void MemLeakTest(void) +{ + LOS_MemUsedNodeShow(LOSCFG_SYS_HEAP_ADDR); + void *ptr1 = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, 8); + void *ptr2 = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, 8); + LOS_MemUsedNodeShow(LOSCFG_SYS_HEAP_ADDR); +} +``` + + +#### ç»“æžœéªŒè¯ + +编译è¿è¡Œè¾“出log如下: + + +``` +node size LR[0] LR[1] LR[2] +0x20001b04: 0x24 0x08001a10 0x080035ce 0x080028fc +0x20002058: 0x40 0x08002fe8 0x08003626 0x080028fc +0x200022ac: 0x40 0x08000e0c 0x08000e56 0x0800359e +0x20002594: 0x120 0x08000e0c 0x08000e56 0x08000c8a +0x20002aac: 0x56 0x08000e0c 0x08000e56 0x08004220 + +node size LR[0] LR[1] LR[2] +0x20001b04: 0x24 0x08001a10 0x080035ce 0x080028fc +0x20002058: 0x40 0x08002fe8 0x08003626 0x080028fc +0x200022ac: 0x40 0x08000e0c 0x08000e56 0x0800359e +0x20002594: 0x120 0x08000e0c 0x08000e56 0x08000c8a +0x20002aac: 0x56 0x08000e0c 0x08000e56 0x08004220 +0x20003ac4: 0x1d 0x08001458 0x080014e0 0x080041e6 +0x20003ae0: 0x1d 0x080041ee 0x08000cc2 0x00000000 +``` + +对比两次log,差异如下,这些内å˜èŠ‚点就是疑似泄æ¼çš„内å˜å—: + + +``` +0x20003ac4: 0x1d 0x08001458 0x080014e0 0x080041e6 +0x20003ae0: 0x1d 0x080041ee 0x08000cc2 0x00000000 +``` + +部分汇编文件如下: + + +``` + MemLeakTest: + 0x80041d4: 0xb510 PUSH {R4, LR} + 0x80041d6: 0x4ca8 LDR.N R4, [PC, #0x2a0] ; g_memStart + 0x80041d8: 0x0020 MOVS R0, R4 + 0x80041da: 0xf7fd 0xf93e BL LOS_MemUsedNodeShow ; 0x800145a + 0x80041de: 0x2108 MOVS R1, #8 + 0x80041e0: 0x0020 MOVS R0, R4 + 0x80041e2: 0xf7fd 0xfbd9 BL LOS_MemAlloc ; 0x8001998 + 0x80041e6: 0x2108 MOVS R1, #8 + 0x80041e8: 0x0020 MOVS R0, R4 + 0x80041ea: 0xf7fd 0xfbd5 BL LOS_MemAlloc ; 0x8001998 + 0x80041ee: 0x0020 MOVS R0, R4 + 0x80041f0: 0xf7fd 0xf933 BL LOS_MemUsedNodeShow ; 0x800145a + 0x80041f4: 0xbd10 POP {R4, PC} + 0x80041f6: 0x0000 MOVS R0, R0 +``` + +å…¶ä¸ï¼Œé€šè¿‡æŸ¥æ‰¾0x080041ee,就å¯ä»¥å‘现该内å˜èŠ‚点是在MemLeakTest接å£é‡Œç”³è¯·çš„且是没有释放的。 + +## 踩内å˜æ£€æµ‹ + + +### 基础概念 + +踩内å˜æ£€æµ‹æœºåˆ¶ä½œä¸ºå†…æ ¸çš„å¯é€‰åŠŸèƒ½ï¼Œç”¨äºŽæ£€æµ‹åŠ¨æ€å†…å˜æ± 的完整性。通过该机制,å¯ä»¥åŠæ—¶å‘现内å˜æ± 是å¦å‘生了踩内å˜é—®é¢˜ï¼Œå¹¶ç»™å‡ºé”™è¯¯ä¿¡æ¯ï¼Œä¾¿äºŽåŠæ—¶å‘现系统问题,æ高问题解决效率,é™ä½Žé—®é¢˜å®šä½æˆæœ¬ã€‚ + + +### 功能é…ç½® + +LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK:开关å®ï¼Œé»˜è®¤å…³é—;若打开这个功能,在target_config.hä¸å°†è¿™ä¸ªå®å®šä¹‰ä¸º1。 + +1. å¼€å¯è¿™ä¸ªåŠŸèƒ½ï¼Œæ¯æ¬¡ç”³è¯·å†…å˜ï¼Œä¼šå®žæ—¶æ£€æµ‹å†…å˜æ± 的完整性。 + +2. 如果ä¸å¼€å¯è¯¥åŠŸèƒ½ï¼Œä¹Ÿå¯ä»¥è°ƒç”¨LOS_MemIntegrityCheck接å£æ£€æµ‹ï¼Œä½†æ˜¯æ¯æ¬¡ç”³è¯·å†…å˜æ—¶ï¼Œä¸ä¼šå®žæ—¶æ£€æµ‹å†…å˜å®Œæ•´æ€§ï¼Œè€Œä¸”由于节点头没有é”鬼数å—(开å¯æ—¶æ‰æœ‰ï¼Œçœå†…å˜ï¼‰ï¼Œæ£€æµ‹çš„准确性也会相应é™ä½Žï¼Œä½†å¯¹äºŽç³»ç»Ÿçš„性能没有影å“ï¼Œæ•…æ ¹æ®å®žé™…情况开关该功能。 + +由于该功能åªä¼šæ£€æµ‹å‡ºå“ªä¸ªå†…å˜èŠ‚ç‚¹è¢«ç ´å了,并给出å‰èŠ‚点信æ¯ï¼ˆå› 为内å˜åˆ†å¸ƒæ˜¯è¿žç»çš„,当å‰èŠ‚点最有å¯èƒ½è¢«å‰èŠ‚ç‚¹ç ´å)。如果è¦è¿›ä¸€æ¥ç¡®è®¤å‰èŠ‚点在哪里申请的,需开å¯å†…å˜æ³„æ¼æ£€æµ‹åŠŸèƒ½ï¼Œé€šè¿‡LR记录,辅助定ä½ã€‚ + +>  **注æ„:** +> å¼€å¯è¯¥åŠŸèƒ½ï¼ŒèŠ‚点头多了é”鬼数å—å—段,会增大节点头大å°ã€‚由于实时检测完整性,故性能影å“较大;若性能æ•æ„Ÿçš„场景,å¯ä»¥ä¸å¼€å¯è¯¥åŠŸèƒ½ï¼Œä½¿ç”¨LOS_MemIntegrityCheck接å£æ£€æµ‹ã€‚ + + +### å¼€å‘指导 + + +#### å¼€å‘æµç¨‹ + +通过调用LOS_MemIntegrityCheck接å£æ£€æµ‹å†…å˜æ± 是å¦å‘生了踩内å˜ï¼Œå¦‚果没有踩内å˜é—®é¢˜ï¼Œé‚£ä¹ˆæŽ¥å£è¿”回0且没有log输出;如果å˜åœ¨è¸©å†…å˜é—®é¢˜ï¼Œé‚£ä¹ˆä¼šè¾“出相关log,详è§ä¸‹æ–‡ç¼–程实例的结果输出。 + + +#### 编程实例 + +本实例实现如下功能: + +1. 申请两个物ç†ä¸Šè¿žç»çš„内å˜å—ï¼› + +2. 通过memsetæž„é€ è¶Šç•Œè®¿é—®ï¼Œè¸©åˆ°ä¸‹ä¸ªèŠ‚ç‚¹çš„å¤´4个å—节; + +3. 调用LOS_MemIntegrityCheck检测是å¦å‘生踩内å˜ã€‚ + + +#### 示例代ç + +代ç 实现如下: + + +``` +#include <stdio.h> +#include <string.h> +#include "los_memory.h" +#include "los_config.h" + +void MemIntegrityTest(void) +{ + /* 申请两个物ç†è¿žç»çš„内å˜å— */ + void *ptr1 = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, 8); + void *ptr2 = LOS_MemAlloc(LOSCFG_SYS_HEAP_ADDR, 8); + /* 第一个节点内å˜å—大å°æ˜¯8å—节,那么12å—节的清零,会踩到第二个内å˜èŠ‚ç‚¹çš„èŠ‚ç‚¹å¤´ï¼Œæž„é€ è¸©å†…å˜åœºæ™¯ */ + memset(ptr1, 0, 8 + 4); + LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR); +} +``` + + +#### ç»“æžœéªŒè¯ + +编译è¿è¡Œè¾“出log如下: + + +``` +[ERR][OsMemMagicCheckPrint], 2028, memory check error! +memory used but magic num wrong, magic num = 0x00000000 /* æ示信æ¯ï¼Œæ£€æµ‹åˆ°å“ªä¸ªå—æ®µè¢«ç ´åäº†ï¼Œç”¨ä¾‹æž„é€ äº†å°†ä¸‹ä¸ªèŠ‚ç‚¹çš„å¤´4个å—节清零,å³é”鬼数å—å—段 */ + + broken node head: 0x20003af0 0x00000000 0x80000020, prev node head: 0x20002ad4 0xabcddcba 0x80000020 +/* è¢«ç ´å节点和其å‰èŠ‚点关键å—段信æ¯ï¼Œåˆ†åˆ«ä¸ºå…¶å‰èŠ‚点地å€ã€èŠ‚点的é”鬼数å—ã€èŠ‚点的sizeAndFlagï¼›å¯ä»¥çœ‹å‡ºè¢«ç ´å节点的é”鬼数å—å—段被清零,符åˆç”¨ä¾‹åœºæ™¯ */ + + broken node head LR info: /* 节点的LRä¿¡æ¯éœ€è¦å¼€å¯å†…å˜æ£€æµ‹åŠŸèƒ½æ‰æœ‰æœ‰æ•ˆè¾“出 */ + LR[0]:0x0800414e + LR[1]:0x08000cc2 + LR[2]:0x00000000 + + pre node head LR info: /* 通过LRä¿¡æ¯ï¼Œå¯ä»¥åœ¨æ±‡ç¼–文件ä¸æŸ¥æ‰¾å‰èŠ‚点是哪里申请,然åŽæŽ’查其使用的准确性 */ + LR[0]:0x08004144 + LR[1]:0x08000cc2 + LR[2]:0x00000000 +[ERR]Memory interity check error, cur node: 0x20003b10, pre node: 0x20003af0 /* è¢«ç ´å节点和其å‰èŠ‚ç‚¹çš„åœ°å€ */ +``` diff --git a/zh-cn/device-dev/kernel/kernel-small-apx-dll.md b/zh-cn/device-dev/kernel/kernel-small-apx-dll.md index f96563857060e2ef16b2397f22eb760bac77bbee..d13c006214da35581213e47da24e583cb16b861a 100644 --- a/zh-cn/device-dev/kernel/kernel-small-apx-dll.md +++ b/zh-cn/device-dev/kernel/kernel-small-apx-dll.md @@ -18,7 +18,7 @@ | å¢žåŠ é“¾è¡¨ | - LOS_ListAddList:将指定链表的头端æ’入到åŒå‘链表头端<br/>- LOS_ListHeadInsertList:将指定链表的头端æ’入到åŒå‘链表头端<br/>- LOS_ListTailInsertList:将指定链表的尾端æ’入到åŒå‘链表头端 | | åˆ é™¤èŠ‚ç‚¹ | - LOS_ListDelete:将指定节点从链表ä¸åˆ 除<br/>- LOS_ListDelInit:将指定节点从链表ä¸åˆ 除,并使用该节点åˆå§‹åŒ–链表 | | 判æ–åŒå‘链表 | - LOS_ListEmpty:判æ–链表是å¦ä¸ºç©º<br/>- LOS_DL_LIST_IS_END:判æ–指定链表节点是å¦ä¸ºé“¾è¡¨å°¾ç«¯ï¼šLOS_DL_LIST_IS_ON_QUEUE:判æ–链表节点是å¦åœ¨åŒå‘链表里 | -| 获å–ç»“æž„ä½“ä¿¡æ¯ | - LOS_OFF_SET_OF:获å–指定结构体内的æˆå‘˜ç›¸å¯¹äºŽç»“构体起始地å€çš„å移é‡<br/>- LOS_DL_LIST_ENTRY:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称<br/>- LOS_ListPeekHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListRemoveHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼Œå¹¶æŠŠç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点从链表ä¸åˆ 除。接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListNextType:获å–åŒå‘链表ä¸æŒ‡å®šé“¾è¡¨èŠ‚点的下一个节点所在的结构体地å€ã€‚接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是指定的链表节点,第三个入å‚是è¦èŽ·å–的结构体å称,第四个入å‚是链表在该结构体ä¸çš„å称。如果链表节点下一个为链表头结点为空,返回NULL。<br/>- LOS_OFF_SET_OF:获å–指定结构体内的æˆå‘˜ç›¸å¯¹äºŽç»“构体起始地å€çš„å移é‡<br/>- LOS_DL_LIST_ENTRY:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称<br/>- LOS_ListPeekHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListRemoveHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼Œå¹¶æŠŠç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点从链表ä¸åˆ 除。接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListNextType:获å–åŒå‘链表ä¸æŒ‡å®šé“¾è¡¨èŠ‚点的下一个节点所在的结构体地å€ã€‚接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是指定的链表节点,第三个入å‚是è¦èŽ·å–的结构体å称,第四个入å‚是链表在该结构体ä¸çš„å称。如果链表节点下一个为链表头结点为空,返回NULL。 | +| 获å–ç»“æž„ä½“ä¿¡æ¯ | - LOS_OFF_SET_OF:获å–指定结构体内的æˆå‘˜ç›¸å¯¹äºŽç»“构体起始地å€çš„å移é‡<br/>- LOS_DL_LIST_ENTRY:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称<br/>- LOS_ListPeekHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼ŒæŽ¥å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListRemoveHeadType:获å–åŒå‘链表ä¸ç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点所在的结构体地å€ï¼Œå¹¶æŠŠç¬¬ä¸€ä¸ªé“¾è¡¨èŠ‚点从链表ä¸åˆ 除。接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是è¦èŽ·å–的结构体å称,第三个入å‚是链表在该结构体ä¸çš„å称。如果链表为空,返回NULL。<br/>- LOS_ListNextType:获å–åŒå‘链表ä¸æŒ‡å®šé“¾è¡¨èŠ‚点的下一个节点所在的结构体地å€ã€‚接å£çš„第一个入å‚表示的是链表ä¸çš„头节点,第二个入å‚是指定的链表节点,第三个入å‚是è¦èŽ·å–的结构体å称,第四个入å‚是链表在该结构体ä¸çš„å称。如果链表节点下一个为链表头结点为空,返回NULL。| | é历åŒå‘链表 | - LOS_DL_LIST_FOR_EACH:é历åŒå‘链表<br/>- LOS_DL_LIST_FOR_EACH_SAFE:é历åŒå‘链表,并å˜å‚¨å½“å‰èŠ‚点的åŽç»§èŠ‚ç‚¹ç”¨äºŽå®‰å…¨æ ¡éªŒ | | é历包å«åŒå‘链表的结构体 | - LOS_DL_LIST_FOR_EACH_ENTRY:é历指定åŒå‘链表,获å–包å«è¯¥é“¾è¡¨èŠ‚点的结构体地å€<br/>- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE:é历指定åŒå‘链表,获å–包å«è¯¥é“¾è¡¨èŠ‚点的结构体地å€ï¼Œå¹¶å˜å‚¨åŒ…å«å½“å‰èŠ‚点的åŽç»§èŠ‚ç‚¹çš„ç»“æž„ä½“åœ°å€ | diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-signal.md b/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-signal.md index a2f3244ecbfe50f54b0eb9808f580a1afd716d22..aaa1f061537203ee243ba8ce14556ac89c4d52d0 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-signal.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-trans-user-signal.md @@ -44,7 +44,7 @@ > > å‘é€ä¿¡å·ï¼š > -> a. 进程接收信å·å˜åœ¨é»˜è®¤è¡Œä¸ºï¼Œå•ä¸æ”¯æŒPOSIXæ ‡å‡†æ‰€ç»™å‡ºçš„STOPåŠCOTINUEã€COREDUMP功能。 +> a. 进程接收信å·å˜åœ¨é»˜è®¤è¡Œä¸ºï¼Œå•ä¸æ”¯æŒPOSIXæ ‡å‡†æ‰€ç»™å‡ºçš„STOPåŠCONTINUEã€COREDUMP功能。 > > b. è¿›ç¨‹æ— æ³•å±è”½SIGSTOPã€SIGKILLã€SIGCONTä¿¡å·ã€‚ > diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md b/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md index a7090aa8cd25de4324897faaa8a89fea9bf36368..a5b14d4169aef58347e9fcc10cb4d894439a66bf 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support-nfs.md @@ -82,7 +82,7 @@ OpenHarmony LiteOS-Aå†…æ ¸çš„NFS文件系统指的是NFS的客户端,NFS客户 [2]Reply from 10.67.212.178: time=1ms TTL=63 [3]Reply from 10.67.212.178: time=1ms TTL=63 --- 10.67.212.178 ping statistics --- -3. packets transmitted, 4 received, 0 loss + packets transmitted, 4 received, 0 loss 客户端NFSåˆå§‹åŒ–,è¿è¡Œå‘½ä»¤ï¼š @@ -124,7 +124,7 @@ OpenHarmony LiteOS-Aå†…æ ¸çš„NFS文件系统指的是NFS的客户端,NFS客户 > > 至æ¤ï¼ŒNFS客户端设置完毕。NFS文件系统已æˆåŠŸæŒ‚载。 -4. 利用NFS共享文件 +3. 利用NFS共享文件 在NFSæœåŠ¡å™¨ä¸‹æ–°å»ºç›®å½•dir,并ä¿å˜ã€‚在OpenHarmonyå†…æ ¸ä¸‹è¿è¡Œls命令: diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support.md b/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support.md index 5f2ea549f7be468f4780dd7c4db0c96a8690b4e0..427cc10737c384630f2d0235131c5e7b7c8e5115 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-fs-support.md @@ -1,13 +1,424 @@ # 支æŒçš„文件系统 +## FAT +### 基本概念 -- **[FAT](kernel-small-bundles-fs-support-fat.md)** +FAT文件系统是File Allocation Table(文件é…置表)的简称,主è¦åŒ…括DBR区ã€FAT区ã€DATA区三个区域。其ä¸ï¼ŒFAT区å„个表项记录å˜å‚¨è®¾å¤‡ä¸å¯¹åº”簇的信æ¯ï¼ŒåŒ…括簇是å¦è¢«ä½¿ç”¨ã€æ–‡ä»¶ä¸‹ä¸€ä¸ªç°‡çš„ç¼–å·ã€æ˜¯å¦æ–‡ä»¶ç»“å°¾ç‰ã€‚FAT文件系统有FAT12ã€FAT16ã€FAT32ç‰å¤šç§æ ¼å¼ï¼Œå…¶ä¸ï¼Œ12ã€16ã€32è¡¨ç¤ºå¯¹åº”æ ¼å¼ä¸FAT表项的比特数,它们åŒæ—¶ä¹Ÿé™åˆ¶äº†æ–‡ä»¶ç³»ç»Ÿä¸çš„最大文件大å°ã€‚FAT文件系统支æŒå¤šç§ä»‹è´¨ï¼Œç‰¹åˆ«åœ¨å¯ç§»åŠ¨å˜å‚¨ä»‹è´¨ï¼ˆU盘ã€SDå¡ã€ç§»åŠ¨ç¡¬ç›˜ç‰ï¼‰ä¸Šå¹¿æ³›ä½¿ç”¨ï¼Œä½¿åµŒå…¥å¼è®¾å¤‡å’ŒWindowsã€Linuxç‰æ¡Œé¢ç³»ç»Ÿä¿æŒå¾ˆå¥½çš„兼容性,方便用户管ç†æ“作文件。 -- **[JFFS2](kernel-small-bundles-fs-support-jffs2.md)** +OpenHarmonyå†…æ ¸æ”¯æŒFAT12ã€FAT16与FAT32三ç§æ ¼å¼çš„FAT文件系统,具有代ç é‡å°ã€èµ„æºå 用å°ã€å¯è£åˆ‡ã€æ”¯æŒå¤šç§ç‰©ç†ä»‹è´¨ç‰ç‰¹æ€§ï¼Œå¹¶ä¸”与Windowsã€Linuxç‰ç³»ç»Ÿä¿æŒå…¼å®¹ï¼Œæ”¯æŒå¤šè®¾å¤‡ã€å¤šåˆ†åŒºè¯†åˆ«ç‰åŠŸèƒ½ã€‚OpenHarmonyå†…æ ¸æ”¯æŒç¡¬ç›˜å¤šåˆ†åŒºï¼Œå¯ä»¥åœ¨ä¸»åˆ†åŒºä»¥åŠé€»è¾‘分区上创建FAT文件系统。 -- **[NFS](kernel-small-bundles-fs-support-nfs.md)** -- **[Ramfs](kernel-small-bundles-fs-support-ramfs.md)** +### è¿è¡Œæœºåˆ¶ -- **[Procfs](kernel-small-bundles-fs-support-procfs.md)** \ No newline at end of file +FAT文件系统设计与物ç†å¸ƒå±€çš„相关文档在互è”网上éžå¸¸ä¸°å¯Œï¼Œè¯·å¼€å‘者自行æœç´¢æŸ¥çœ‹ã€‚ + +OpenHarmony LiteOS-Aå†…æ ¸é€šè¿‡Bcacheæå‡FAT文件系统性能,Bcache是block cache的简称。当å‘生读写时,Bcache会缓å˜è¯»å†™æ‰‡åŒºé™„近的扇区,以å‡å°‘I/O次数,æ高性能。Bcache的基本缓å˜å•ä½ä¸ºblock,æ¯ä¸ªblock大å°ä¸€è‡´ï¼ˆé»˜è®¤æœ‰28个block,æ¯ä¸ªblock缓å˜64个扇区的数æ®ï¼‰ã€‚当Bcacheè„å—率(è„扇区数/总扇区数)达到阈值时,会触å‘写回;如果è„å—率未达到阈值,则ä¸ä¼šå°†ç¼“å˜æ•°æ®å†™å›žç£ç›˜ã€‚如果需è¦ä¿è¯æ•°æ®å†™å›žï¼Œå¼€å‘者应当调用syncå’Œfsync触å‘写回。FAT文件系统的部分接å£ä¹Ÿä¼šè§¦å‘写回æ“作(如closeã€umountç‰ï¼‰ï¼Œä½†å¼€å‘者ä¸åº”当基于这些接å£è§¦å‘写回。 + + +### å¼€å‘指导 + + + **å¼€å‘æµç¨‹** + +基本使用æµç¨‹ä¸ºæŒ‚载→æ“作→å¸è½½ã€‚ + +SDå¡æˆ–MMC的设备å为mmcblk[x]p[y],文件系统类型为“vfatâ€ã€‚ + +示例: + + +``` +mount("/dev/mmcblk0p0", "/mnt", "vfat", 0, NULL); +``` + +>  **说明:** +> - FAT文件系统ä¸ï¼Œå•ä¸ªæ–‡ä»¶ä¸èƒ½å¤§äºŽ4 GiB。 +> +> - 当有两个SDå¡æ’槽时,å¡0å’Œå¡1ä¸å›ºå®šï¼Œå…ˆæ’上的为å¡0,åŽæ’上的为å¡1。 +> +> - 当多分区功能打开,å˜åœ¨å¤šåˆ†åŒºçš„情况下,å¡0注册的设备节点/dev/mmcblk0(主设备)å’Œ/dev/mmcblk0p0(次设备)是åŒä¸€ä¸ªè®¾å¤‡ï¼Œç¦æ¢å¯¹ä¸»è®¾å¤‡è¿›è¡Œæ“作。 +> +> - 为é¿å…SDå¡ä½¿ç”¨å¼‚常或内å˜æ³„æ¼ï¼ŒSDå¡ä½¿ç”¨è¿‡ç¨‹ä¸æ‹”å¡ï¼Œç”¨æˆ·å¿…须先关é—æ£å¤„于打开状æ€çš„文件和目录,并且å¸è½½æŒ‚载节点。 +> +> - 在formatæ“作之å‰ï¼Œéœ€è¦é¦–å…ˆumount挂载点。 +> +> - 当Bcache功能生效时,需è¦æ³¨æ„: +> - 当mount函数的入å‚为MS_NOSYNC时,FATä¸ä¼šä¸»åŠ¨å°†cache的内容写回å˜å‚¨å™¨ä»¶ã€‚FAT的如下接å£ï¼ˆopenã€close〠unlinkã€renameã€mkdirã€rmdirã€truncate)ä¸ä¼šè‡ªåŠ¨è¿›è¡Œsyncæ“作,速度å¯ä»¥æå‡ï¼Œä½†æ˜¯éœ€è¦ä¸Šå±‚主动调用syncæ¥è¿›è¡Œæ•°æ®åŒæ¥ï¼Œå¦åˆ™å¯èƒ½ä¼šæ•°æ®ä¸¢å¤±ã€‚ +> +> - Bcache有定时写回功能。在menuconfigä¸å¼€å¯LOSCFG_FS_FAT_CACHE_SYNC_THREAD选项,打开åŽç³»ç»Ÿä¼šåˆ›å»ºä¸€ä¸ªä»»åŠ¡å®šæ—¶å†™å›žBcacheä¸çš„æ•°æ®ï¼Œé»˜è®¤æ¯éš”5秒检查Bcacheä¸è„æ•°æ®å—比例,超过80%时进行syncæ“作,将Bcacheä¸çš„è„æ•°æ®å…¨éƒ¨å†™å›žç£ç›˜ã€‚任务优先级ã€åˆ·æ–°æ—¶é—´é—´éš”以åŠè„æ•°æ®å—比例的阈值å¯åˆ†åˆ«é€šè¿‡æŽ¥å£LOS_SetSyncThreadPrio〠LOS_SetSyncThreadIntervalå’ŒLOS_SetDirtyRatioThreshold设置。 +> - 当å‰cache的默认大å°ä¸º28个å—,æ¯ä¸ªå—64个扇区。 + +## JFFS2 + + +### 基本概念 + +JFFS2是Journalling Flash File System Version 2(日志文件系统)的缩写,是针对MTD设备的日志型文件系统。 + +OpenHarmonyå†…æ ¸çš„JFFS2主è¦åº”用于NOR FLASHé—ªå˜ï¼Œå…¶ç‰¹ç‚¹æ˜¯ï¼šå¯è¯»å†™ã€æ”¯æŒæ•°æ®åŽ‹ç¼©ã€æ供了崩溃/掉电安全ä¿æŠ¤ã€æ供“写平衡â€æ”¯æŒç‰ã€‚é—ªå˜ä¸Žç£ç›˜ä»‹è´¨æœ‰è®¸å¤šå·®å¼‚,直接将ç£ç›˜æ–‡ä»¶ç³»ç»Ÿè¿è¡Œåœ¨é—ªå˜è®¾å¤‡ä¸Šï¼Œä¼šå¯¼è‡´æ€§èƒ½å’Œå®‰å…¨é—®é¢˜ã€‚为解决这一问题,需è¦å®žçŽ°ä¸€ä¸ªç‰¹åˆ«é’ˆå¯¹é—ªå˜çš„文件系统,JFFS2å°±æ˜¯è¿™æ ·ä¸€ç§æ–‡ä»¶ç³»ç»Ÿã€‚ + + +### è¿è¡Œæœºåˆ¶ + +关于JFFS2文件系统的在å˜å‚¨è®¾å¤‡ä¸Šçš„实际物ç†å¸ƒå±€ï¼ŒåŠæ–‡ä»¶ç³»ç»Ÿæœ¬èº«çš„è§„æ ¼è¯´æ˜Žï¼Œè¯·å‚考JFFS2çš„[å®˜æ–¹è§„æ ¼è¯´æ˜Žæ–‡æ¡£](https://sourceware.org/jffs2/)。 + +è¿™é‡Œä»…åˆ—ä¸¾å‡ ä¸ªå¯¹å¼€å‘者和使用者会有一定影å“çš„JFFS2çš„é‡è¦æœºåˆ¶/特å¾ï¼š + +1. Mount机制åŠé€Ÿåº¦é—®é¢˜ï¼šæŒ‰ç…§JFFS2的设计,所有的文件会按照一定的规则,切分æˆå¤§å°ä¸ç‰çš„节点,ä¾æ¬¡å˜å‚¨åˆ°flash设备上。在mountæµç¨‹ä¸ï¼Œéœ€è¦èŽ·å–到所有的这些节点信æ¯å¹¶ç¼“å˜åˆ°å†…å˜é‡Œã€‚å› æ¤ï¼Œmount速度和flash设备的大å°å’Œæ–‡ä»¶æ•°é‡çš„多少æˆçº¿æ€§æ¯”例关系。这是JFFS2的原生设计问题,对于mount速度éžå¸¸ä»‹æ„的用户,å¯ä»¥åœ¨å†…æ ¸ç¼–è¯‘æ—¶å¼€å¯â€œEnable JFFS2 SUMMARYâ€é€‰é¡¹ï¼Œå¯ä»¥æžå¤§æå‡mount的速度。这个选项的原ç†æ˜¯å°†mount需è¦çš„ä¿¡æ¯æå‰å˜å‚¨åˆ°flash上,在mount时读å–并解æžè¿™å—内容,使得mount的速度å˜å¾—相对æ’定。这个实际是空间æ¢æ—¶é—´çš„åšæ³•ï¼Œä¼šæ¶ˆè€—8%å·¦å³çš„é¢å¤–空间。 + +2. 写平衡的支æŒï¼šç”±äºŽflash设备的物ç†å±žæ€§ï¼Œè¯»å†™éƒ½åªèƒ½åŸºäºŽæŸä¸ªç‰¹å®šå¤§å°çš„“å—â€è¿›è¡Œï¼Œä¸ºäº†é˜²æ¢æŸäº›ç‰¹å®šçš„å—磨æŸè¿‡äºŽä¸¥é‡ï¼Œåœ¨JFFS2ä¸éœ€è¦å¯¹å†™å…¥çš„å—进行“平衡â€çš„管ç†ï¼Œä¿è¯æ‰€æœ‰çš„å—的写入次数都是相对平å‡çš„,进而ä¿è¯flash设备的整体寿命。 + +3. GC(garbage collection)机制:在JFFS2里å‘ç”Ÿåˆ é™¤åŠ¨ä½œï¼Œå®žé™…çš„ç‰©ç†ç©ºé—´å¹¶ä¸ä¼šç«‹å³é‡Šæ”¾ï¼Œè€Œæ˜¯ç”±ç‹¬ç«‹çš„GC线程æ¥åšç©ºé—´æ•´ç†å’Œæ¬ç§»ç‰GC动作,和所有的GCæœºåˆ¶ä¸€æ ·ï¼Œåœ¨JFFS2里的GC会对瞬时的读写性能有一定影å“。å¦å¤–,为了有空间能被用æ¥åšç©ºé—´æ•´ç†ï¼ŒJFFS2会对æ¯ä¸ªåˆ†åŒºé¢„ç•™3å—å·¦å³çš„空间,这个空间是用户ä¸å¯è§çš„。 + +4. 压缩机制:当å‰ä½¿ç”¨çš„JFFS2,底层会自动的在æ¯æ¬¡è¯»/写时进行解压/压缩动作,实际IO的大å°å’Œç”¨æˆ·è¯·æ±‚读写的大å°å¹¶ä¸ä¼šä¸€æ ·ã€‚特别在写入时,ä¸èƒ½é€šè¿‡å†™å…¥å¤§å°æ¥å’Œflash剩余空间的大å°æ¥é¢„估写入一定会æˆåŠŸæˆ–者失败。 + +5. 硬链接机制:JFFS2支æŒç¡¬é“¾æŽ¥ï¼Œåº•å±‚实际å 用的物ç†ç©ºé—´æ˜¯ä¸€ä»½ï¼Œå¯¹äºŽåŒä¸€ä¸ªæ–‡ä»¶çš„多个硬连接,并ä¸ä¼šå¢žåŠ 空间的å 用;å之,åªæœ‰å½“åˆ é™¤äº†æ‰€æœ‰çš„ç¡¬é“¾æŽ¥æ—¶ï¼Œå®žé™…ç‰©ç†ç©ºé—´æ‰ä¼šè¢«é‡Šæ”¾ã€‚ + + +### å¼€å‘指导 + +对于基于JFFS2å’Œnor flashçš„å¼€å‘,总体而言,与其他文件系统éžå¸¸ç›¸ä¼¼ï¼Œå› 为都有VFS层æ¥å±è”½äº†å…·ä½“文件系统的差异,对外接å£ä½“çŽ°ä¹Ÿéƒ½æ˜¯æ ‡å‡†çš„POSIX接å£ã€‚ + +对于整个裸nor flash设备而言,没有集ä¸çš„地方æ¥ç®¡ç†å’Œè®°å½•åˆ†åŒºçš„ä¿¡æ¯ã€‚å› æ¤ï¼Œéœ€è¦é€šè¿‡å…¶ä»–çš„é…置方å¼æ¥ä¼ 递这部分信æ¯ï¼ˆå½“å‰ä½¿ç”¨çš„æ–¹å¼æ˜¯åœ¨çƒ§å†™é•œåƒçš„时候,使用bootargså‚æ•°é…置的),然åŽåœ¨ä»£ç ä¸è°ƒç”¨ç›¸åº”的接å£æ¥æ·»åŠ 分区,å†è¿›è¡ŒæŒ‚载动作。 + +**制作JFFS2文件系统镜åƒ** + +使用mkfs.jffs2工具,制作镜åƒé»˜è®¤å‘½ä»¤å¦‚下。页大å°é»˜è®¤ä¸º4KiB,eraseblock大å°é»˜è®¤64KiB。若实际å‚数与下é¢ä¸åŒæ—¶ï¼Œä¿®æ”¹ç›¸åº”å‚数。 + + +``` +./mkfs.jffs2 -d rootfs/ -o rootfs.jffs2 +``` + + **表1** 指令å«ä¹‰è¡¨ï¼ˆæ›´è¯¦ç»†çš„介ç»å¯ä»¥é€šè¿‡mkfs.jffs2 --helpæ¥æŸ¥çœ‹ï¼‰ + +| 指令 | å«ä¹‰ | +| -------- | -------- | +| -s | 页大å°ï¼Œä¸æŒ‡å®šé»˜è®¤ä¸º4KiB | +| -e | eraseblock大å°ï¼Œä¸æŒ‡å®šé»˜è®¤ä¸º64KiB | +| -p | é•œåƒå¤§å°ã€‚在镜åƒæ–‡ä»¶åŽé¢ï¼Œç”¨0xFF填充至指定大å°ï¼Œä¸æŒ‡å®šåˆ™ç”¨0xFF填充至eraseblock对é½ã€‚ | +| -d | è¦åˆ¶ä½œæˆæ–‡ä»¶ç³»ç»Ÿé•œåƒçš„æºç›®å½• | +| -o | è¦åˆ¶æˆçš„é•œåƒå称 | + +**挂载JFFS2分区** + +调用int mount(const char \*source, const char \*target, const char \*filesystemtype, unsigned long mountflags, const void \*data)函数实现设备节点和挂载点的挂载。 + +该函数有五个å‚数,第一个å‚æ•°const char \*source,表示设备节点,第二个å‚æ•°const char \*target表示挂载点。第三个å‚æ•° const char \*filesystemtype,表示文件系统类型。 + +最åŽä¸¤ä¸ªå‚æ•°unsigned long mountflagså’Œconst void \*dataè¡¨ç¤ºæŒ‚è½½æ ‡å¿—å’Œæ•°æ®ï¼Œé»˜è®¤ä¸º0å’ŒNULL;这一æ“作也å¯ä»¥åœ¨Shellä¸ä½¿ç”¨mount命令实现,最åŽä¸¤ä¸ªå‚æ•°ä¸éœ€è¦ç”¨æˆ·ç»™å‡ºã€‚ + +è¿è¡Œå‘½ä»¤ï¼š + + +``` +OHOS # mount /dev/spinorblk1 /jffs1 jffs2 +``` + +将从串å£å¾—到如下回应信æ¯ï¼Œè¡¨æ˜ŽæŒ‚è½½æˆåŠŸã€‚ + + +``` +OHOS # mount /dev/spinorblk1 /jffs1 jffs2 +mount OK +``` + +挂载æˆåŠŸåŽï¼Œç”¨æˆ·å°±èƒ½å¯¹norflash进行读写æ“作。 + +**å¸è½½JFFS2分区** + +调用int umount(const char \*target)函数å¸è½½åˆ†åŒºï¼Œåªéœ€è¦æ£ç¡®ç»™å‡ºæŒ‚载点å³å¯ã€‚ + +è¿è¡Œå‘½ä»¤ï¼š + + +``` +OHOS # umount /jffs1 +``` + +将从串å£å¾—到如下回应信æ¯ï¼Œè¡¨æ˜Žå¸è½½æˆåŠŸã€‚ + + +``` +OHOS # umount /jffs1 +umount ok +``` +## NFS + + +### 基本概念 + +NFS是Network File System(网络文件系统)的缩写。它最大的功能是å¯ä»¥é€šè¿‡ç½‘络,让ä¸åŒçš„机器ã€ä¸åŒçš„æ“作系统彼æ¤åˆ†äº«å…¶ä»–ç”¨æˆ·çš„æ–‡ä»¶ã€‚å› æ¤ï¼Œç”¨æˆ·å¯ä»¥ç®€å•åœ°å°†å®ƒçœ‹åšæ˜¯ä¸€ä¸ªæ–‡ä»¶ç³»ç»ŸæœåŠ¡ï¼Œåœ¨ä¸€å®šç¨‹åº¦ä¸Šç›¸å½“于Windows环境下的共享文件夹。 + + +### è¿è¡Œæœºåˆ¶ + +OpenHarmony LiteOS-Aå†…æ ¸çš„NFS文件系统指的是NFS的客户端,NFS客户端能够将远程的NFSæœåŠ¡ç«¯åˆ†äº«çš„目录挂载到本地的机器ä¸ï¼Œè¿è¡Œç¨‹åºå’Œå…±äº«æ–‡ä»¶ï¼Œä½†ä¸å 用当å‰ç³»ç»Ÿçš„å˜å‚¨ç©ºé—´ï¼Œåœ¨æœ¬åœ°ç«¯çš„机器看起æ¥ï¼Œè¿œç¨‹æœåŠ¡ç«¯çš„目录就好åƒæ˜¯è‡ªå·±çš„一个ç£ç›˜ä¸€æ ·ã€‚ + + +### å¼€å‘指导 + +1. æ建NFSæœåŠ¡å™¨ + + 这里以Ubuntuæ“作系统为例,说明æœåŠ¡å™¨ç«¯è®¾ç½®æ¥éª¤ã€‚ + + - 安装NFSæœåŠ¡å™¨è½¯ä»¶ã€‚ + + 设置好Ubuntu系统的下载æºï¼Œä¿è¯ç½‘络连接好的情况下执行: + + + ``` + sudo apt-get install nfs-kernel-server + ``` + + - 创建用于挂载的目录并设置完全æƒé™ + + + ``` + mkdir -p /home/sqbin/nfs + sudo chmod 777 /home/sqbin/nfs + ``` + + - 设置和å¯åŠ¨NFS server。 + + 修改NFSé…置文件/etc/exportsï¼Œæ·»åŠ å¦‚ä¸‹ä¸€è¡Œï¼š + + + ``` + /home/sqbin/nfs *(rw,no_root_squash,async) + ``` + + å…¶ä¸/home/sqbin/nfs是NFSå…±äº«çš„æ ¹ç›®å½•ã€‚ + + 执行以下命令å¯åŠ¨NFS server: + + + ``` + sudo /etc/init.d/nfs-kernel-server start + ``` + + 执行以下命令é‡å¯NFS server: + + + ``` + sudo /etc/init.d/nfs-kernel-server restart + ``` + +2. 设置å•æ¿ä¸ºNFS客户端 + + 本指导ä¸çš„NFS客户端指è¿è¡ŒOpenHarmonyå†…æ ¸çš„è®¾å¤‡ã€‚ + + - 硬件连接设置。 + + OpenHarmonyå†…æ ¸è®¾å¤‡è¿žæŽ¥åˆ°NFSæœåŠ¡å™¨çš„网络。设置两者IP,使其处于åŒä¸€ç½‘段。比如,设置NFSæœåŠ¡å™¨çš„IP为10.67.212.178/24,设置OpenHarmonyå†…æ ¸è®¾å¤‡IP为 + 10.67.212.3/24,注æ„:æ¤IP为内网ç§æœ‰IP地å€ï¼Œç”¨æˆ·ä½¿ç”¨æ—¶æœ‰å·®å¼‚,以用户实际IP为准。 + + OpenHarmonyå†…æ ¸è®¾å¤‡ä¸Šçš„IPä¿¡æ¯å¯é€šè¿‡ifconfig命令查看。 + + - å¯åŠ¨ç½‘络,确ä¿å•æ¿åˆ°NFSæœåŠ¡å™¨ä¹‹é—´çš„网络通畅。 + + å¯åŠ¨ä»¥å¤ªç½‘或者其他类型网络,使用ping命令检查到æœåŠ¡å™¨çš„网络是å¦é€šç•…。 + + + ``` + OHOS # ping 10.67.212.178 + [0]Reply from 10.67.212.178: time=1ms TTL=63 + [1]Reply from 10.67.212.178: time=0ms TTL=63 + [2]Reply from 10.67.212.178: time=1ms TTL=63 + [3]Reply from 10.67.212.178: time=1ms TTL=63 + --- 10.67.212.178 ping statistics --- + packets transmitted, 4 received, 0 loss + + 客户端NFSåˆå§‹åŒ–,è¿è¡Œå‘½ä»¤ï¼š + + + ``` + OHOS # mkdir /nfs + OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 + ``` + + 将从串å£å¾—到如下回应信æ¯ï¼Œè¡¨æ˜Žåˆå§‹åŒ–NFS客户端æˆåŠŸã€‚ + + + ``` + OHOS # mount 10.67.212.178:/home/sqbin/nfs /nfs nfs 1011 1000 + Mount nfs on 10.67.212.178:/home/sqbin/nfs, uid:1011, gid:1000 + Mount nfs finished. + ``` + + 该命令将æœåŠ¡å™¨10.67.212.178上的/home/sqbin/nfs目录挂载到OpenHarmonyå†…æ ¸è®¾å¤‡ä¸Šçš„/nfs上。 + + >  **说明:** + > 本例默认nfs serverå·²ç»é…ç½®å¯ç”¨ï¼Œå³ç¤ºä¾‹ä¸æœåŠ¡å™¨10.67.212.178上的/home/sqbin/nfså·²é…ç½®å¯è®¿é—®ã€‚ + > + > mountå‘½ä»¤çš„æ ¼å¼ä¸ºï¼š + > + > + > ``` + > mount <SERVER_IP:SERVER_PATH> <CLIENT_PATH> nfs + > ``` + > + > å…¶ä¸â€œSERVER_IPâ€è¡¨ç¤ºæœåŠ¡å™¨çš„IP地å€ï¼›â€œSERVER_PATHâ€è¡¨ç¤ºæœåŠ¡å™¨ç«¯NFS共享目录路径;“CLIENT_PATHâ€è¡¨ç¤ºè®¾å¤‡ä¸Šçš„NFS路径,“nfsâ€è¡¨ç¤ºå®¢æˆ·ç«¯è¦æŒ‚载的路径,å¯ä»¥æ ¹æ®è‡ªå·±éœ€è¦æ›¿æ¢ã€‚ + > + > 如果ä¸æƒ³æœ‰NFS访问æƒé™é™åˆ¶ï¼Œå¯ä»¥åœ¨Linux命令行将NFSæ ¹ç›®å½•æƒé™è®¾ç½®æˆ777: + > + > + > ``` + > chmod -R 777 /home/sqbin/nfs + > ``` + > + > 至æ¤ï¼ŒNFS客户端设置完毕。NFS文件系统已æˆåŠŸæŒ‚载。 + +3. 利用NFS共享文件 + + 在NFSæœåŠ¡å™¨ä¸‹æ–°å»ºç›®å½•dir,并ä¿å˜ã€‚在OpenHarmonyå†…æ ¸ä¸‹è¿è¡Œls命令: + + ``` + OHOS # ls /nfs + ``` + + 则å¯ä»Žä¸²å£å¾—到如下回应: + + + ``` + OHOS # ls /nfs + Directory /nfs: + drwxr-xr-x 0 u:0 g:0 dir + ``` + + å¯è§ï¼Œåˆšåˆšåœ¨NFSæœåŠ¡å™¨ä¸Šæ–°å»ºçš„dir目录已åŒæ¥åˆ°å®¢æˆ·ç«¯(OpenHarmonyå†…æ ¸ç³»ç»Ÿ)çš„/nfs目录,两者ä¿æŒåŒæ¥ã€‚ + + åŒæ ·åœ°ï¼Œåœ¨å®¢æˆ·ç«¯(OpenHarmonyå†…æ ¸ç³»ç»Ÿ)上创建文件和目录,在NFSæœåŠ¡å™¨ä¸Šä¹Ÿå¯ä»¥è®¿é—®ï¼Œè¯»è€…å¯è‡ªè¡Œä½“验。 + + >  **说明:** + > ç›®å‰ï¼ŒNFS客户端仅支æŒNFS v3部分规范è¦æ±‚ï¼Œå› æ¤å¯¹äºŽè§„范支æŒä¸å…¨çš„æœåŠ¡å™¨ï¼Œæ— 法完全兼容。在开å‘测试过程ä¸ï¼Œå»ºè®®ä½¿ç”¨Linuxçš„NFS server,其对NFS支æŒå¾ˆå®Œå–„。 + +## Ramfs + + +### 基本概念 + +RAMFS是一个å¯åŠ¨æ€è°ƒæ•´å¤§å°çš„基于RAM的文件系统。RAMFS没有åŽå¤‡å˜å‚¨æºã€‚å‘RAMFSä¸è¿›è¡Œçš„文件写æ“作也会分é…目录项和页缓å˜ï¼Œä½†æ˜¯æ•°æ®å¹¶ä¸å†™å›žåˆ°ä»»ä½•å…¶ä»–å˜å‚¨ä»‹è´¨ä¸Šï¼ŒæŽ‰ç”µåŽæ•°æ®ä¸¢å¤±ã€‚ +### è¿è¡Œæœºåˆ¶ +RAMFS文件系统把所有的文件都放在 RAM ä¸ï¼Œæ‰€ä»¥è¯»/写æ“作å‘生在RAMä¸ï¼Œå¯ä»¥ç”¨RAMFSæ¥å˜å‚¨ä¸€äº›ä¸´æ—¶æ€§æˆ–ç»å¸¸è¦ä¿®æ”¹çš„æ•°æ®ï¼Œä¾‹å¦‚/tmpå’Œ/varç›®å½•ï¼Œè¿™æ ·æ—¢é¿å…了对å˜å‚¨å™¨çš„读写æŸè€—,也æ高了数æ®è¯»å†™é€Ÿåº¦ã€‚ +### å¼€å‘指导 +挂载: +``` +mount(NULL, "/dev/shm", "ramfs", 0, NULL) +``` +创建目录: +``` +mkdir(pathname, mode) +``` +创建文件: +``` +open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, mode) +``` +读å–目录: +``` +dir = opendir(pathname) +ptr = readdir(dir) +closedir(dir) +``` +åˆ é™¤æ–‡ä»¶ï¼š +``` +unlink(pathname) +``` +åˆ é™¤ç›®å½•ï¼š +``` +rmdir(pathname) +``` +去挂载: +``` +umount("/dev/shm") +``` +>  **注æ„:** +> - RAMFSåªèƒ½æŒ‚载一次,一次挂载æˆåŠŸåŽï¼ŒåŽé¢ä¸èƒ½ç»§ç»æŒ‚载到其他目录。 +> +> - RAMFS属于调测功能,默认é…置为关é—,æ£å¼äº§å“ä¸ä¸è¦ä½¿ç”¨è¯¥åŠŸèƒ½ã€‚ + +## Procfs + + +### 基本概念 + +procfs是进程文件系统的简称,是一ç§è™šæ‹Ÿæ–‡ä»¶ç³»ç»Ÿï¼Œä»–用文件的形å¼ï¼Œå±•ç¤ºè¿›ç¨‹æˆ–其他系统信æ¯ã€‚相比调用接å£çš„æ–¹å¼èŽ·å–ä¿¡æ¯ï¼Œä»¥æ–‡ä»¶æ“作的方å¼èŽ·å–系统信æ¯æ›´ä¸ºæ–¹ä¾¿ã€‚ + + +### è¿è¡Œæœºåˆ¶ + +OpenHarmonyå†…æ ¸ä¸ï¼Œprocfs在开机时会自动挂载到/proc目录下,仅支æŒå†…æ ¸æ¨¡å—创建文件节点æ¥æ供查询æœåŠ¡ã€‚ + + +### å¼€å‘指导 + +procfsæ–‡ä»¶çš„åˆ›å»ºæ— æ³•ä½¿ç”¨ä¸€èˆ¬çš„æ–‡ä»¶ç³»ç»ŸæŽ¥å£ï¼Œéœ€è¦ä½¿ç”¨ProcMkdir接å£åˆ›å»ºç›®å½•ï¼Œä½¿ç”¨CreateProcEntry接å£åˆ›å»ºæ–‡ä»¶ã€‚文件节点功能的开å‘就是实现readå’Œwrite函数的钩å挂到CreateProcEntry创建的文件ä¸ã€‚当用户使用读写procfs的文件时,就会调用到钩å函数æ¥å®žçŽ°è‡ªå®šä¹‰çš„功能。 + + +编程实例 + +下é¢æˆ‘们以创建/proc/hello/world文件为例,实现如下功能: + +1.在/proc/hello/worldä½ç½®åˆ›å»ºä¸€ä¸ªæ–‡ä»¶ + +2.当读文件内容时,返回"HelloWorld!" + +3.当写文件内容时,打å°å†™å…¥çš„内容 + + +``` +#include "proc_fs.h" + +static int TestRead(struct SeqBuf *buf, void *arg) +{ + LosBufPrintf(buf, "Hello World!\n"); /* 将数æ®æ‰“å°åˆ°bufferä¸ï¼Œè¿™ä¸ªbufferä¸çš„æ•°æ®ä¼šè¿”回到readçš„ç»“æžœä¸ */ + return 0; +} + +static int TestWrite(struct ProcFile *pf, const char *buffer, size_t buflen, loff_t *ppos) +{ + if ((buffer == NULL) || (buflen <= 0)) { + return -EINVAL; + } + + PRINTK("your input is: %s\n", buffer); /* 注æ„和上é¢çš„read接å£åŒºåˆ«ï¼Œè¿™æ˜¯å¯¹write接å£è¾“入命令的å馈,这个打å°åªä¼šæ‰“å°åˆ°æŽ§åˆ¶å° */ + return buflen; +} +static const struct ProcFileOperations HELLO_WORLD_OPS = { + .read = TestRead, + .write = TestWrite, +}; + +void HelloWorldInit(void) +{ + /* 创建hello目录 */ + struct ProcDirEntry *dir = ProcMkdir("hello", NULL); + if (dir == NULL) { + PRINT_ERR("create dir failed!\n"); + return; + } + + /* 创建world文件 */ + struct ProcDirEntry *entry = CreateProcEntry("world", 0, dir); + if (entry == NULL) { + PRINT_ERR("create entry failed!\n"); + return; + } + + /* 将自定义的readå’Œwriteé’©åæŒ‚åˆ°æ–‡ä»¶ä¸ */ + entry->procFileOps = &HELLO_WORLD_OPS; +} +``` + +**结果验è¯** + +å¯åŠ¨åŽåœ¨shell输入如下命令 + + +``` +OHOS # cat /proc/hello/world +OHOS # Hello World! +OHOS # echo "yo" > /proc/hello/world +OHOS # your input is: yo +``` diff --git a/zh-cn/device-dev/kernel/kernel-small-bundles-system.md b/zh-cn/device-dev/kernel/kernel-small-bundles-system.md index 4b75ad05591aac01d8bdcf3957702469a4e70d2c..8037e5e81d9306b3cea7d0c2881be289a387ab9f 100644 --- a/zh-cn/device-dev/kernel/kernel-small-bundles-system.md +++ b/zh-cn/device-dev/kernel/kernel-small-bundles-system.md @@ -52,8 +52,8 @@ Syscall Handler的具体实现在kernel/liteos_a/syscall/los_syscall.cä¸OsArmA3 #define __NR_pthread_set_detach (__NR_OHOS_BEGIN + 0) #define __NR_pthread_join (__NR_OHOS_BEGIN + 1) #define __NR_pthread_deatch (__NR_OHOS_BEGIN + 2) - #define __NR_creat_user_thread (__NR_OHOS_BEGIN + 3) - #define __NR_processcreat (__NR_OHOS_BEGIN + 4) + #define __NR_create_user_thread (__NR_OHOS_BEGIN + 3) + #define __NR_processcreate (__NR_OHOS_BEGIN + 4) #define __NR_processtart (__NR_OHOS_BEGIN + 5) #define __NR_printf (__NR_OHOS_BEGIN + 6) #define __NR_dumpmemory (__NR_OHOS_BEGIN + 13) @@ -98,8 +98,8 @@ Syscall Handler的具体实现在kernel/liteos_a/syscall/los_syscall.cä¸OsArmA3 #define __NR_pthread_set_detach (__NR_OHOS_BEGIN + 0) #define __NR_pthread_join (__NR_OHOS_BEGIN + 1) #define __NR_pthread_deatch (__NR_OHOS_BEGIN + 2) - #define __NR_creat_user_thread (__NR_OHOS_BEGIN + 3) - #define __NR_processcreat (__NR_OHOS_BEGIN + 4) + #define __NR_create_user_thread (__NR_OHOS_BEGIN + 3) + #define __NR_processcreate (__NR_OHOS_BEGIN + 4) #define __NR_processtart (__NR_OHOS_BEGIN + 5) #define __NR_printf (__NR_OHOS_BEGIN + 6) #define __NR_dumpmemory (__NR_OHOS_BEGIN + 13) diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-sem.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-sem.md index 78725d748293c1818f84e1dfef14fe06d15983e2..bdcf23dbcf131ab20306089829c72c997cea2d45 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-sem.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-sem.md @@ -18,7 +18,7 @@ sem [_ID__ / fulldata_] | å‚æ•° | å‚数说明 | å–值范围 | | -------- | -------- | -------- | | ID | ä¿¡å·é‡ID。 | [0, 1023]或[0x0, 0x3FF] | -| fulldata | 查询所有在用的信å·é‡ä¿¡æ¯ï¼Œæ‰“å°ä¿¡æ¯åŒ…括如下:SemID, Count, Original Count, Creater TaskEntry, Last Access Time。 | N/A | +| fulldata | 查询所有在用的信å·é‡ä¿¡æ¯ï¼Œæ‰“å°ä¿¡æ¯åŒ…括如下:SemID, Count, Original Count, Creator TaskEntry, Last Access Time。 | N/A | ## ä½¿ç”¨æŒ‡å— @@ -84,7 +84,7 @@ OHOS # sem ``` OHOS # sem fulldata Used Semaphore List: - SemID Count OriginalCount Creater(TaskEntry) LastAccessTime + SemID Count OriginalCount Creator(TaskEntry) LastAccessTime ------ ------ ------------- ------------------ -------------- 0xb 0x0 0x0 0x404978fc 0xa1 0xc 0x0 0x0 0x404978fc 0xa1 @@ -120,5 +120,5 @@ Used Semaphore List: | SemID | ä¿¡å·é‡ID。 | | Count | ä¿¡å·é‡ä½¿ç”¨æ•°ã€‚ | | OriginalCount | ä¿¡å·é‡åŽŸå§‹è®¡æ•°ã€‚ | -| Creater | ä¿¡å·é‡çš„创建线程的入å£å‡½æ•°åœ°å€ã€‚ | +| Creator | ä¿¡å·é‡çš„创建线程的入å£å‡½æ•°åœ°å€ã€‚ | | LastAccessTime | 上次访问时间。 | diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-user.md b/zh-cn/device-dev/kernel/kernel-small-debug-user.md index 3a57c7c48ce1b8719a750f8b53bf2a01351b8e4f..cb61d4fe832b15e30df9d1f19963be0a811eb68d 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-user.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-user.md @@ -1,11 +1,552 @@ # 用户æ€å†…å˜è°ƒæµ‹ +## 基本概念 +Debug版本的musl-libc库为用户æ供内å˜æ³„æ¼æ£€æµ‹ã€å †å†…å˜ç»Ÿè®¡ã€è¸©å†…å˜åˆ†æžä»¥åŠbacktrace功能ç‰ç»´æµ‹æ‰‹æ®µï¼Œå¯ä»¥æ高用户æ€å†…å˜ç›¸å…³é—®é¢˜çš„定ä½æ•ˆçŽ‡ã€‚ -- **[基本概念](kernel-small-debug-user-concept.md)** -- **[è¿è¡Œæœºåˆ¶](kernel-small-debug-user-function.md)** +采用了对malloc/free接å£è¿›è¡Œæ’桩,ä¿å˜å…³é”®èŠ‚点信æ¯ï¼Œç„¶åŽç¨‹åºåœ¨ç”³è¯·å’Œé‡Šæ”¾å†…å˜æ—¶è¿›è¡Œå†…å˜èŠ‚ç‚¹å®Œæ•´æ€§æ ¡éªŒï¼Œæœ€åŽåœ¨ç¨‹åºç»“æŸæ—¶é€šè¿‡ç»Ÿè®¡èŠ‚点信æ¯å¾—到内å˜ç»Ÿè®¡ä¿¡æ¯å¹¶æ ¹æ®ç»Ÿè®¡ä¿¡æ¯åˆ¤æ–内å˜æ˜¯å¦æ³„æ¼çš„设计æ€æƒ³ -- **[使用指导](kernel-small-debug-user-guide.md)** +## è¿è¡Œæœºåˆ¶ + + +### 内å˜æ³„æ¼æ£€æŸ¥ + +对于æ¯ä¸ªè¿›ç¨‹ï¼Œå†…å˜è°ƒæµ‹æ¨¡å—维护了128个链表(当å‰ç³»ç»Ÿçš„线程最大数é‡ä¸º128个),æ¯ä¸ªé“¾è¡¨çš„索引为线程ID。 + +申请内å˜æ—¶ï¼šä¿å˜å…³é”®ä¿¡æ¯åˆ°å†…å˜èŠ‚点控制å—ï¼Œæ ¹æ®å½“å‰çº¿ç¨‹ID将内å˜èŠ‚点控制å—挂到对应链表; + +释放内å˜æ—¶ï¼šæ ¹æ®éœ€è¦é‡Šæ”¾çš„内å˜åœ°å€åŒ¹é…内å˜èŠ‚点控制å—并将该控制å—åˆ é™¤ã€‚ + + **图1** å †å†…å˜èŠ‚点信æ¯é“¾è¡¨ + +  + +申请内å˜æ—¶ï¼Œè¿”回地å€ä¼šè¢«ä¿å˜åˆ°LR寄å˜å™¨ä¸ã€‚进程è¿è¡Œè¿‡ç¨‹ä¸ï¼Œç³»ç»Ÿä¼šåœ¨å†…å˜èŠ‚点控制å—ä¸æ·»åŠ 疑似泄æ¼ç‚¹å¯¹åº”çš„lrç‰ä¿¡æ¯ã€‚如下图所示: + + **图2** å †å†…å˜èŠ‚ç‚¹ä¿¡æ¯ + +  + +å…¶ä¸ï¼ŒTID表示线程IDï¼›PID表示进程IDï¼›ptr表示申请的内å˜åœ°å€ï¼›size表示申请的内å˜å¤§å°ï¼›lr[n]è¡¨ç¤ºå‡½æ•°è°ƒç”¨æ ˆåœ°å€ï¼Œå˜é‡nå¯ä»¥æ ¹æ®å…·ä½“场景的需è¦è¿›è¡Œé…置。 + +释放内å˜æ—¶ï¼Œå°†freeç‰æŽ¥å£çš„å…¥å‚指针与nodeçš„ptrå—段进行匹é…,如果相åŒåˆ™åˆ 除该内å˜èŠ‚点控制å—ä¿¡æ¯ã€‚ + +用户通过串å£æˆ–文件ç‰æ–¹å¼ï¼Œå°†å„个进程内å˜è°ƒæµ‹ä¿¡æ¯å¯¼å‡ºï¼Œåˆ©ç”¨addr2line工具将导出的信æ¯è½¬æ¢æˆå¯¼è‡´å†…å˜æ³„æ¼çš„代ç 行,便å¯ä»¥è§£å†³å†…å˜æ³„露问题。 + + **图3** 泄æ¼ç‚¹ä»£ç 行定ä½æµç¨‹ + +  + + +### å †å†…å˜ç»Ÿè®¡ + +用户æ€çº¿ç¨‹å †å†…å˜ä½¿ç”¨ç»Ÿè®¡å…·æœ‰ä¸€å®šçš„实际æ„ä¹‰ï¼Œç»Ÿè®¡çº¿ç¨‹ç”³è¯·çš„å †å†…å˜å 比,为用户程åºçš„内å˜ä½¿ç”¨ä¼˜åŒ–æ供数æ®æ”¯æŒã€‚用户æ€å †å†…å˜ç»Ÿè®¡æ¨¡å—主è¦æ¶‰åŠçš„接å£ä¸ºmallocå’Œfree。如上图所示,æ¯ä¸ªè¿›ç¨‹ç»´æŠ¤128个链表,链表索引å³çº¿ç¨‹ID,申请内å˜æ—¶ç³»ç»Ÿå°†ptrå’Œsizeä¿¡æ¯è®°å½•åœ¨å†…å˜èŠ‚点控制å—ä¸å¹¶å°†èŠ‚点控制å—挂在以线程ID为头信æ¯çš„é“¾è¡¨ä¸Šï¼Œå †å†…å˜é‡Šæ”¾æ—¶æ ¹æ®pträ»Žå¯¹åº”çš„é“¾è¡¨ä¸Šç§»é™¤ç›¸åº”çš„å †å†…å˜å—ä¿¡æ¯ï¼›åŒæ—¶è®¡ç®—出当å‰çº¿ç¨‹æ‰€æŒæœ‰çš„å †å†…å˜æ€»çš„使用é‡ï¼Œå¹¶æ›´æ–°å½“å‰è¿›ç¨‹çš„å †å†…å˜ä½¿ç”¨é‡å’Œå †å†…å˜ä½¿ç”¨å³°å€¼ã€‚ + + +### 内å˜å®Œæ•´æ€§æ£€æŸ¥ + +- 使用malloc申请内å˜ï¼ˆå°äºŽç‰äºŽ0x1c000bytesæ—¶é€šè¿‡å †åˆ†é…算法分é…) + 用户程åºç”³è¯·å †å†…å˜æ—¶ï¼Œåœ¨å †å†…å˜èŠ‚ç‚¹å¤„æ·»åŠ æ ¡éªŒå€¼ç‰ä¿¡æ¯ï¼Œå¦‚æžœæ ¡éªŒå€¼å¼‚å¸¸ï¼Œåˆ™å¾ˆæœ‰å¯èƒ½æ˜¯å‰ä¸€å—å †å†…å˜ä½¿ç”¨è¶Šç•Œå¯¼è‡´çš„(目å‰æ— æ³•è¯†åˆ«æ ¡éªŒå€¼è¢«é‡ŽæŒ‡é’ˆç ´å的场景)。在内å˜ç”³è¯·ã€é‡Šæ”¾æ—¶æ ¡éªŒå†…å˜èŠ‚ç‚¹æ ¡éªŒå€¼çš„æ£ç¡®æ€§ï¼Œè‹¥å†…å˜èŠ‚ç‚¹è¢«ç ´åï¼Œæ ¡éªŒå¤±è´¥æ—¶åˆ™è¾“å‡ºtidã€pidåŠå½“å‰è¢«è¸©èŠ‚点å‰ä¸€å—å †å†…å˜ç”³è¯·æ—¶ä¿å˜çš„è°ƒç”¨æ ˆä¿¡æ¯ï¼Œé€šè¿‡addr2line工具å¯èŽ·å¾—具体的代ç 行信æ¯ï¼Œè¾…助用户解决问题。 + + **图4** node节点头信æ¯æ·»åŠ æ ¡éªŒå€¼ + +  + + freeå †å†…å˜æ—¶ï¼Œä¸ä¼šç«‹å³æŠŠè¯¥å†…å˜å—释放掉,而是在内å˜ä¸å†™å…¥é”术数å—0xFE,并放到free队列ä¸(ä¿è¯åœ¨ä¸€å®šæ—¶é—´å†…ä¸ä¼šå†è¢«malloc函数分é…),当有野指针或use-after-free的情况对该内å˜è¿›è¡Œè¯»å–çš„æ“作时,能够å‘现数æ®å¼‚常,但是对于写æ“ä½œåˆ™æ— æ³•åˆ¤æ–出æ¥ã€‚ + + **图5** freeæµç¨‹å›¾ + +  + +- 使用malloc申请内å˜ï¼ˆå¤§äºŽ0x1c000bytes时通过mmap申请) + 当malloc通过mmap申请大å—内å˜æ—¶ï¼Œåœ¨è¿”回给用户使用的内å˜åŒºé—´å¤´å’Œå°¾åˆ†åˆ«å¤šç”³è¯·ä¸€ä¸ªé¡µï¼Œä¸€ä¸ªé¡µPAGE_SIZE当å‰ä¸º0x1000,这两个页分别通过mprotect接å£è®¾ç½®æƒé™ä¸ºPROT_NONEï¼ˆæ— å¯è¯»å¯å†™æƒé™ï¼‰ï¼Œå¯ä»¥æœ‰æ•ˆé˜²æ¢å†…å˜è¶Šç•Œè¯»å†™é—®é¢˜ï¼šè¶Šç•Œè¯»å†™æ•°æ®æ—¶ç”±äºŽæ— 读写æƒé™è€Œå¯¼è‡´ç”¨æˆ·ç¨‹åºå¼‚å¸¸ï¼Œæ ¹æ®å¼‚å¸¸è°ƒç”¨æ ˆä¿¡æ¯å¯æ‰¾åˆ°ç›¸åº”的代ç 逻辑。 + + **图6** malloc通过mmap机制申请内å˜çš„内å˜å¸ƒå±€ + +  + +### 使用指导 +#### 接å£è¯´æ˜Ž + + + **表1** 内å˜è°ƒæµ‹åŠŸèƒ½ + +| 接å£å | æè¿° | +| -------- | -------- | +| mem_check_init | åˆå§‹åŒ–内å˜æ£€æµ‹æ¨¡å—。 | +| watch_mem | 获å–çº¿ç¨‹çº§å †å†…å˜ä½¿ç”¨ä¿¡æ¯ã€‚ | +| check_leak | 检查是å¦æœ‰å †å†…å˜æ³„æ¼ã€‚ | +| check_heap_integrity | æ£€æŸ¥å †å†…å˜çš„完整性。 | +| backtrace | 获å–è°ƒç”¨æ ˆåœ°å€ä¿¡æ¯ã€‚ | +| backtrace_symbols | æ ¹æ®åœ°å€ä¿¡æ¯èŽ·å–符å·ä¿¡æ¯ã€‚ | +| print_trace | è¾“å‡ºå‡½æ•°è°ƒç”¨æ ˆä¿¡æ¯ã€‚ | + + + **表2** è°ƒç”¨æ ˆå›žæº¯åŠŸèƒ½ + +| 接å£å | æè¿° | +| -------- | -------- | +| backtrace | 获å–è°ƒç”¨æ ˆåœ°å€ä¿¡æ¯ã€‚ | +| backtrace_symbols | æ ¹æ®åœ°å€ä¿¡æ¯èŽ·å–符å·ä¿¡æ¯ã€‚ | +| print_trace | è¾“å‡ºå‡½æ•°è°ƒç”¨æ ˆä¿¡æ¯ã€‚ | + +### 使用说明 + + +编译OpenHarmony工程时默认编译的是debug版本,å³libc库已ç»é›†æˆå†…å˜è°ƒæµ‹ç›¸å…³çš„接å£å®žçŽ°ï¼Œç”¨æˆ·å¯ä»¥æ ¹æ®å…·ä½“需è¦å†³å®šæ˜¯å¦ä½¿èƒ½å†…å˜è°ƒæµ‹åŠŸèƒ½ã€‚ + + +å †å†…å˜è°ƒæµ‹åŠŸèƒ½æ供两ç§æ–¹å¼ä¾›ç”¨æˆ·ä½¿ç”¨ï¼šæŽ¥å£è°ƒç”¨åŠå‘½ä»¤è¡Œå‚数。 + + +- 接å£è°ƒç”¨ï¼šä¼˜ç‚¹æ˜¯å¯ä»¥è¾ƒç²¾ç¡®çš„检查æŸä¸€æ®µä»£ç é€»è¾‘çš„å †å†…å˜ç›¸å…³ä¿¡æ¯ï¼Œç¼ºç‚¹æ˜¯éœ€è¦ä¿®æ”¹ç”¨æˆ·ä»£ç 。 + +- 命令行å‚æ•°ï¼šä¼˜ç‚¹æ˜¯æ— éœ€ä¿®æ”¹ç”¨æˆ·ä»£ç ï¼Œç¼ºç‚¹æ˜¯æ— æ³•ç²¾ç¡®çš„æ ¡éªŒæŸä¸€æ®µé€»è¾‘çš„å †å†…å˜ä¿¡æ¯ã€‚ + + +>  **说明:** +> 内å˜è°ƒæµ‹åŠŸèƒ½ä½¿èƒ½åŽï¼Œè¿›ç¨‹é€€å‡ºæ—¶ä¼šé»˜è®¤è¿›è¡Œä¸€æ¬¡å †å†…å˜æ³„æ¼å’Œå †å†…å˜å®Œæ•´æ€§æ£€æŸ¥ã€‚内å˜è°ƒæµ‹åŠŸèƒ½æœªä½¿èƒ½æ—¶ï¼Œå †å†…å˜ç»Ÿè®¡ã€å †å†…å˜æ³„æ¼æ£€æŸ¥ã€å †å†…å˜å®Œæ•´æ€§æ ¡éªŒåŠŸèƒ½ä¸ä¼šå¼€å¯ï¼Œè°ƒç”¨ç›¸å…³è°ƒæµ‹æŽ¥å£æ— å“应。 + + +- **[接å£è°ƒç”¨æ–¹å¼](kernel-small-debug-user-guide-use-api.md)** + +- **[命令行å‚æ•°æ–¹å¼](kernel-small-debug-user-guide-use-cli.md)** + + + + +#### 接å£è°ƒç”¨æ–¹å¼ + + +##### 示例代ç + +代ç 功能:显å¼è°ƒç”¨è°ƒæµ‹æ¨¡å—的相关接å£å¯¹ç”¨æˆ·ä»£ç 进行内å˜æ ¡éªŒã€‚ + + +``` +#include <pthread.h> +#include <stdlib.h> +#include <stdio.h> +#include <debug.h> // 包å«æ供内å˜è°ƒæµ‹æŽ¥å£å£°æ˜Žçš„头文件 + +#define MALLOC_LEAK_SIZE 0x300 + +void func(void) { + char *ptr = malloc(MALLOC_LEAK_SIZE); + memset(ptr, '3', MALLOC_LEAK_SIZE); +} + +int main() +{ + mem_check_init(NULL); // 通过串å£è¾“出内å˜è°ƒæµ‹ä¿¡æ¯ï¼Œå¿…须在用户程åºç¬¬ä¸€æ¬¡ç”³è¯·å †å†…å˜ä¹‹å‰è°ƒç”¨ï¼ˆä¸€èˆ¬åœ¨main函数入å£è°ƒç”¨ï¼‰ï¼Œå¦åˆ™è°ƒæµ‹ä¿¡æ¯ä¸å‡†ç¡®ã€‚ + // mem_check_init("/storage/mem_debug.txt"); // 内å˜è°ƒæµ‹ä¿¡æ¯è¾“出到/storage/mem_debug.txt文件ä¸ï¼Œå¦‚果该文件创建失败,则信æ¯é€šè¿‡ä¸²å£è¾“出。 + char *ptr = malloc(MALLOC_LEAK_SIZE); + memset(ptr, '1', MALLOC_LEAK_SIZE); + + watch_mem(); // 在当å‰ä»£ç 逻辑处查看线程级内å˜ç»Ÿè®¡ä¿¡æ¯ã€‚ + func(); + check_heap_integrity(); // æ£€æŸ¥å †å†…å˜èŠ‚点完整性。 + check_leak(); // 在当å‰ä»£ç é€»è¾‘å¤„æ£€æŸ¥å †å†…å˜æ˜¯å¦æ³„æ¼ï¼ˆä¸€èˆ¬åœ¨ç¨‹åºé€€å‡ºä¹‹å‰æ ¡éªŒæ¯”较准确,若在mallocå’Œfree调用逻辑之间åšæ ¡éªŒï¼Œåˆ™ç»“æžœä¸å‡†ç¡®ï¼‰ã€‚ + return 0; +} +``` + + +##### 编译 + + +``` +$ clang -o mem_check mem_check.c -funwind-tables -rdynamic -g -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos --sysroot=/home/<user-name>/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a) +``` + + +>  **说明:** +> - 本编译示例基于将编译器的路径写入环境å˜é‡ä¸ï¼Œå³.bashrc文件ä¸ã€‚ +> +> - 编译用户程åºåŠæ‰€éœ€çš„lib库时,需è¦æ·»åŠ 编译选项-funwind-tables,-rdynamic,-gï¼Œç”¨äºŽæ ˆå›žæº¯ã€‚ +> +> - -mfloat-abi=softfp,-mcpu=cortex-a7,-mfpu=neon-vfpv4编译选项用于指定具体的芯片架构ã€æµ®ç‚¹æ•°è®¡ç®—优化ã€fpu,与具体的libc库使用的编译选项ä¿æŒä¸€è‡´ï¼Œå¦åˆ™é“¾æŽ¥æ—¶å¯èƒ½å‡ºçŽ°æ‰¾ä¸åˆ°libc库文件。 +> +> - -target arm-liteos用于指定编译器相关库文件路径。 +> +> - --sysroot=/home/<user-name>/directory/out/hispark_taurus/ipcamera_hispark_taurus/sysroot用于指定编译器库文件æœç´¢æ ¹ç›®å½•ï¼Œå‡è®¾OpenHarmony工程代ç å˜æ”¾è·¯å¾„为/home/<user-name>/directory。其ä¸out/hispark_taurus/ipcamera_hispark_taurus路径为在编译时,hb set命令指定的具体产å“,本示例选择的是ipcamera_hispark_taurus产å“。 +> +> - $(clang -mfloat-abi=softfp -mcpu=cortex-a7 -mfpu=neon-vfpv4 -target arm-liteos -print-file-name=libunwind.a)用于指定相应的unwind库的路径。 + + +##### è°ƒæµ‹ä¿¡æ¯ + + +``` +OHOS # ./mem_check +OHOS # +==PID:4== Heap memory statistics(bytes): // å †å†…å˜ç»Ÿè®¡ä¿¡æ¯ + [Check point]: // checkç‚¹è°ƒç”¨æ ˆ + #00: <main+0x38>[0x86c] -> mem_check + #01: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + + [TID: 18, Used: 0x320] // 18å·çº¿ç¨‹å †å†…å˜å 用,当å‰è¿›ç¨‹ä»…一个线程 + +==PID:4== Total heap: 0x320 byte(s), Peak: 0x320 byte(s) + +Check heap integrity ok! // å †å†…å˜å®Œæ•´æ€§æ£€æŸ¥ + +==PID:4== Detected memory leak(s): // 内å˜æ³„æ¼ä¿¡æ¯åŠè°ƒç”¨æ ˆ + [Check point]: + #00: <check_leak+0x1c4>[0x2da4c] -> /lib/libc.so + #01: <main+0x44>[0x878] -> mem_check + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x1c>[0x850] -> mem_check + #01: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x810] -> mem_check + #01: <main+0x3c>[0x870] -> mem_check + #02: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + +==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + +==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2da4c] -> /lib/libc.so + #01: <exit+0x28>[0x111ec] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x1c>[0x850] -> mem_check + #01: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x810] -> mem_check + #01: <main+0x3c>[0x870] -> mem_check + #02: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + +==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + +Check heap integrity ok! +``` + + +##### è°ƒç”¨æ ˆè§£æž + +æä¾›parse_mem_info.sh脚本å¯ä»¥å¯¹è°ƒç”¨æ ˆè¿›è¡Œè§£æžï¼Œè§£æžè„šæœ¬å˜æ”¾çš„路径:kernel/liteos_a/tools/scripts/parse_memory/parse_mem_info.sh。利用脚本å¯ä»¥å°†ç›¸åº”的调测信æ¯è½¬æ¢æˆå…·ä½“çš„æºç è¡Œå·ï¼Œå¦‚下命令所示,mem_debug.txtä¿å˜çš„是内å˜è°ƒæµ‹ä¿¡æ¯ï¼Œelf1ã€elf2ç‰æ–‡ä»¶æ˜¯éœ€è¦è§£æžçš„elf文件。 + + +``` +$ ./parse_mem_info.sh mem_debug.txt elf1 elf2 elf3 ... +``` + +例如: + + +``` +$ ./parse_mem_info.sh mem_debug.txt mem_check +Compiler is [gcc/llvm]: llvm +Now using addr2line ... + +==PID:4== Heap memory statistics(bytes): + [Check point]: + #00: <main+0x38>[0x86c] at /usr1/xxx/TEST_ELF/mem_check.c:22 + #01: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + + [TID: 18, Used: 0x320] + +==PID:4== Total heap: 0x320 byte(s), Peak: 0x320 byte(s) + +Check heap integrity ok! + +==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2da4c] -> /lib/libc.so + #01: <main+0x44>[0x878] at /usr1/xxx/TEST_ELF/mem_check.c:28 + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x1c>[0x850] at /usr1/xxx/TEST_ELF/mem_check.c:17 + #01: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x810] at /usr1/xxx/TEST_ELF/mem_check.c:9 + #01: <main+0x3c>[0x870] at /usr1/xxx/TEST_ELF/mem_check.c:24 + #02: <(null)+0x24baf9dc>[0x219dc] -> /lib/libc.so + +==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). +``` + +#### 命令行å‚æ•°æ–¹å¼ + + +对用户æ€è¿›ç¨‹è¿›è¡Œå†…å˜ç›¸å…³çš„检查时,除了接å£è°ƒç”¨æ–¹å¼è¿˜å¯ä»¥é€šè¿‡å‘½ä»¤è¡Œæ–¹å¼è¿›è¡Œå†…å˜ç»Ÿè®¡ã€å†…å˜æ³„æ¼æˆ–内å˜å®Œæ•´æ€§æ£€æŸ¥ã€‚ + +``` +--mwatch:åˆå§‹åŒ–内å˜è°ƒæµ‹åŠŸèƒ½ï¼Œæ³¨å†Œä¿¡å·ã€‚内å˜è°ƒæµ‹ä¿¡æ¯å°†ä»Žä¸²å£è¾“出; +--mrecord <f_path>:åˆå§‹åŒ–内å˜è°ƒæµ‹åŠŸèƒ½ï¼Œæ³¨å†Œä¿¡å·ã€‚内å˜è°ƒæµ‹ä¿¡æ¯å°†ä¿å˜è‡³f_path文件,若f_path创建失败,则内å˜è°ƒæµ‹ä¿¡æ¯å°†ä»Žä¸²å£è¾“出 +``` + + +在待调测的进程未退出时å¯ä½¿ç”¨ä¿¡å·æœºåˆ¶èŽ·å–对应信æ¯: + +``` +kill -35 <pid> # æŸ¥çœ‹çº¿ç¨‹çº§å †å†…å˜å 用 +kill -36 <pid> # 检查是å¦å˜åœ¨å †å†…å˜æ³„æ¼ +kill -37 <pid> # æ£€æŸ¥å †å†…å˜å¤´èŠ‚点是å¦å®Œæ•´ +``` + + +##### 示例代ç + +代ç åŠŸèƒ½ï¼šæž„é€ å†…å˜é—®é¢˜åˆ©ç”¨å‘½ä»¤è¡Œæ–¹å¼è¿›è¡Œå†…å˜è°ƒæµ‹ã€‚ + + +``` +#include <pthread.h> +#include <stdlib.h> +#include <stdio.h> + +#define MALLOC_LEAK_SIZE 0x300 + +void func(void) { + char *ptr = malloc(MALLOC_LEAK_SIZE); + memset(ptr, '3', MALLOC_LEAK_SIZE); +} + +int main() +{ + char *ptr = malloc(MALLOC_LEAK_SIZE); + memset(ptr, '1', MALLOC_LEAK_SIZE); + func(); + while (1); +} +``` + + +##### 编译 + +å‚考[接å£è°ƒç”¨ä¸€èŠ‚](../kernel/kernel-small-debug-user-guide-use-api.md#编译)。 + + +##### 使用mwatchå‚数命令 + + +``` +OHOS # ./mem_check --mwatch // 利用task命令å¯ä»¥æŸ¥åˆ°mem_check进程的pid为4 +OHOS # +OHOS # kill -35 4 // æŸ¥çœ‹å †å†…å˜ç»Ÿè®¡ä¿¡æ¯ +OHOS # +==PID:4== Heap memory statistics(bytes): + [Check point]: + #00: <arm_signal_process+0x5c>[0x58dfc] -> /lib/libc.so + + [TID: 18, Used: 0x640] + +==PID:4== Total heap: 0x640 byte(s), Peak: 0x640 byte(s) + +OHOS # kill -36 4 // 检查是å¦å˜åœ¨å †å†…å˜æ³„æ¼ +OHOS # +==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2da4c] -> /lib/libc.so + #01: <arm_signal_process+0x5c>[0x58dfc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x14>[0x724] -> mem_check + #01: <(null)+0x2555a9dc>[0x219dc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x6ec] -> mem_check + #01: <main+0x30>[0x740] -> mem_check + #02: <(null)+0x2555a9dc>[0x219dc] -> /lib/libc.so + +==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + +OHOS # kill -37 4 // æ£€æŸ¥å †å†…å˜å¤´èŠ‚点的完整性 +OHOS # +Check heap integrity ok! +``` + + +##### è°ƒç”¨æ ˆè§£æž + +将调测信æ¯ä¿å˜è‡³test.txt文件ä¸ï¼Œåˆ©ç”¨è„šæœ¬è¿›è¡Œè§£æžï¼ŒèŽ·å–内å˜æ³„æ¼çš„具体行å·ã€‚ + + +``` +$ ./parse_mem_info.sh test.txt mem_check +Compiler is [gcc/llvm]: llvm +Now using addr2line ... + +==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2da4c] -> /lib/libc.so + #01: <arm_signal_process+0x5c>[0x58dfc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x14>[0x724] at /usr1/xxx/TEST_ELF/mem_check.c:14 + #01: <(null)+0x2555a9dc>[0x219dc] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x6ec] at /usr1/xxx/TEST_ELF/mem_check.c:8 + #01: <main+0x30>[0x740] at /usr1/xxx/TEST_ELF/mem_check.c:19 + #02: <(null)+0x2555a9dc>[0x219dc] -> /lib/libc.so + +==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). +``` + + +##### 使用mrecordå‚数命令 + +1. 执行用户程åºå¹¶æŒ‡å®šè®°å½•å†…å˜è°ƒæµ‹ä¿¡æ¯çš„文件路径 + + ``` + OHOS # ./mem_check --mrecord /storage/check.txt + ``` + +2. 利用kill -35 <pid>统计内å˜ä¿¡æ¯ï¼Œè¯¥ä¿¡æ¯å°†ä¼šè¾“出到文件ä¸ï¼Œä½¿ç”¨cat命令查看 + + ``` + OHOS # kill -35 4 + OHOS # Memory statistics information saved in /storage/pid(4)_check.txt + + OHOS # cat /storage/pid(4)_check.txt + + ==PID:4== Heap memory statistics(bytes): + [Check point]: + #00: <arm_signal_process+0x5c>[0x5973c] -> /lib/libc.so + + [TID: 18, Used: 0x640] + + ==PID:4== Total heap: 0x640 byte(s), Peak: 0x640 byte(s) + ``` + +3. 利用kill -36 <pid>æ ¡éªŒå†…å˜å®Œæ•´æ€§ï¼Œè¯¥ä¿¡æ¯å°†ä¼šè¾“出到文件ä¸ï¼Œä½¿ç”¨cat命令查看 + + ``` + OHOS # kill -36 4 + OHOS # Leak check information saved in /storage/pid(4)_check.txt + + OHOS # cat /storage/pid(4)_check.txt + + ==PID:4== Heap memory statistics(bytes): + [Check point]: + #00: <arm_signal_process+0x5c>[0x5973c] -> /lib/libc.so + + [TID: 18, Used: 0x640] + + ==PID:4== Total heap: 0x640 byte(s), Peak: 0x640 byte(s) + + ==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2e38c] -> /lib/libc.so + #01: <arm_signal_process+0x5c>[0x5973c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x14>[0x724] -> mem_check + #01: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x6ec] -> mem_check + #01: <main+0x30>[0x740] -> mem_check + #02: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + ==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + ``` + +4. 利用kill -9 <pid>æ€æŽ‰å½“å‰è¿›ç¨‹ï¼Œè¿›ç¨‹é€€å‡ºåŽä¼šé»˜è®¤æ ¡éªŒå†…å˜å®Œæ•´æ€§ï¼Œè¯¥ä¿¡æ¯å°†ä¼šè¾“出到文件ä¸ï¼Œä½¿ç”¨cat命令查看 + + ``` + OHOS # kill -9 4 + OHOS # Leak check information saved in /storage/pid(4)_check.txt + + Check heap integrity ok! + + OHOS # cat /storage/pid(4)_check.txt + OHOS # + ==PID:4== Heap memory statistics(bytes): + [Check point]: + #00: <arm_signal_process+0x5c>[0x5973c] -> /lib/libc.so + + [TID: 18, Used: 0x640] + + ==PID:4== Total heap: 0x640 byte(s), Peak: 0x640 byte(s) + + ==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2e38c] -> /lib/libc.so + #01: <arm_signal_process+0x5c>[0x5973c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x14>[0x724] -> mem_check + #01: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x6ec] -> mem_check + #01: <main+0x30>[0x740] -> mem_check + #02: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + ==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + + ==PID:4== Detected memory leak(s): + [Check point]: + #00: <check_leak+0x1c4>[0x2e38c] -> /lib/libc.so + #01: <exit+0x28>[0x11b2c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <main+0x14>[0x724] -> mem_check + #01: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + [TID:18 Leak:0x320 byte(s)] Allocated from: + #00: <func+0x14>[0x6ec] -> mem_check + #01: <main+0x30>[0x740] -> mem_check + #02: <(null)+0x1fdd231c>[0x2231c] -> /lib/libc.so + + ==PID:4== SUMMARY: 0x640 byte(s) leaked in 2 allocation(s). + ``` + +>  **说明:** +> 上述连ç»è®°å½•çš„ä¿¡æ¯ä¼šé€æ¥è¿½åŠ 到åˆå§‹åŒ–时所指定的文件ä¸ï¼Œæ•…最åŽcat文件时,文件ä¸è¿˜åŒ…å«åŽ†å²è®°å½•çš„ä¿¡æ¯å†…容。 +## 常è§é—®é¢˜ + + +### UAF(Use after free) + +- 申请å°å—内å˜ï¼ˆä¸å¤§äºŽ0x1c000å—节) + free之åŽï¼š + + 读æ“作:读å–free之åŽçš„内å˜å¤§æ¦‚率是é”术数å—(0xFEFEFEFE) + + >  **说明:** + > free之åŽçš„å †å†…å˜ä¸ä¼šç«‹å³é‡Šæ”¾è¿›å †å†…å˜æ± ,会先放至固定长度的队列ä¸ï¼Œå¹¶ç½®é”术数å—0xFE,队列满åŽä¼šå°†å…ˆæ”¾è‡³é˜Ÿåˆ—ä¸çš„内å˜å—é‡Šæ”¾è¿›å †å†…å˜æ± + + 写æ“ä½œï¼šæ— æ³•æ ¡éªŒã€‚ + + +- 申请大å—内å˜ï¼ˆå¤§äºŽ0x1c000) + å †å†…å˜ç”±malloc通过调用mmap接å£ç”³è¯·ï¼Œfree之åŽè‹¥ä»è®¿é—®è¯¥å†…å˜ï¼Œåˆ™ç”¨æˆ·ç¨‹åºå¼‚常(该内å˜åŒºé—´å·²è¢«unmap)。 + + +### Double free + +Double free时,用户程åºå°†ä¼šå¼‚常退出。 + + +### å †å†…å˜èŠ‚点被踩 + +- 申请å°å—内å˜ï¼ˆä¸å¤§äºŽ0x1c000) + å †å†…å˜èŠ‚点被踩时,用户程åºå°†ä¼šå¼‚å¸¸é€€å‡ºï¼Œå¹¶è¾“å‡ºç ´å被踩节点的å¯èƒ½çš„å †å†…å˜ç”³è¯·è°ƒç”¨æ ˆï¼Œå¯¹äºŽé‡ŽæŒ‡é’ˆè¸©å†…å˜æƒ…å†µæ— æ³•æ ¡éªŒå‡ºæ¥ã€‚例如用户程åºmem_checkä¸å˜åœ¨å †å†…å˜è¶Šç•Œè¸©çš„情况,利用命令行方å¼å¯ä»¥èŽ·å¾—踩内å˜çš„å¯èƒ½çš„具体ä½ç½®ã€‚ + + + ``` + OHOS # ./mem_check --mwatch + OHOS # + ==PID:6== Memory integrity information: + [TID:28 allocated addr: 0x272e1ea0, size: 0x120] The possible attacker was allocated from: + #00: <malloc+0x808>[0x640e8] -> /lib/libc.so + #01: <threadFunc1+0x7c>[0x21d0] -> mem_check + ``` + + å¯ä»¥é€šè¿‡è°ƒç”¨æ ˆè§£æžè„šæœ¬å¯¹è°ƒç”¨æ ˆä¿¡æ¯è¿›è¡Œè§£æžã€‚ + +- 申请大å—内å˜ï¼ˆå¤§äºŽ0x1c000) + + å †å†…å˜ç”±malloc通过mmap接å£ç”³è¯·ï¼Œç”³è¯·å¾—åˆ°çš„å †å†…å˜å—å‰åŽå„置一个size为PAGE_SIZE大å°çš„åŒºé—´ï¼Œè®¾ç½®æ— è¯»å†™æƒé™ï¼Œè¯»å†™æ“作会触å‘用户程åºå¼‚常。 -- **[常è§é—®é¢˜](kernel-small-debug-user-faqs.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-small-memory-lms.md b/zh-cn/device-dev/kernel/kernel-small-memory-lms.md index 145f6c59875a01312bbbd1a2a34fd5b029810a8e..f818c3bdf349ca14ddf83ba3bf6fdae3ce314436 100644 --- a/zh-cn/device-dev/kernel/kernel-small-memory-lms.md +++ b/zh-cn/device-dev/kernel/kernel-small-memory-lms.md @@ -366,7 +366,7 @@ int main(int argc, char * const * argv) Heap buffer overflow error detected! Illegal READ address at: [0x1f8b3edf] Shadow memory address: [0x3d34d3ed : 6] Shadow memory value: [2] -Accessable heap addr 0 +Accessible heap addr 0 Heap red zone 2 Heap freed buffer 3 Dump info around address [0x1f8b3edf]: @@ -391,7 +391,7 @@ Backtrace() returned 5 addresses Use after free error detected! Illegal Double free address at: [0x1f8b3ee0] Shadow memory address: [0x3d34d3ee : 0] Shadow memory value: [3] -Accessable heap addr 0 +Accessible heap addr 0 Heap red zone 2 Heap freed buffer 3 Dump info around address [0x1f8b3ee0]: diff --git a/zh-cn/device-dev/kernel/kernel-small-overview.md b/zh-cn/device-dev/kernel/kernel-small-overview.md index 5e17f13da79dbf801185ace1e8fe6be946d94c2f..0762afe70e21fa2020f287b687fb091c14eee61c 100644 --- a/zh-cn/device-dev/kernel/kernel-small-overview.md +++ b/zh-cn/device-dev/kernel/kernel-small-overview.md @@ -76,7 +76,7 @@ OpenHarmony è½»é‡çº§å†…æ ¸æ˜¯åŸºäºŽIoT领域轻é‡çº§ç‰©è”网æ“作系统Huawe **网络åè®®** -è½»é‡çº§å†…æ ¸ç½‘ç»œå议基于开æºLWIP构建,对LWIPçš„RAMå 用进行优化,åŒæ—¶æ高LWIPçš„ä¼ è¾“æ€§èƒ½ã€‚ +è½»é‡çº§å†…æ ¸ç½‘ç»œå议基于开æºlwIP(lightweight IP)构建,对lwIPçš„RAMå 用进行优化,åŒæ—¶æ高lwIPçš„ä¼ è¾“æ€§èƒ½ã€‚ - å议: IPã€IPv6〠ICMP〠NDã€MLD〠UDP〠TCPã€IGMPã€ARPã€PPPoSã€PPPoE diff --git a/zh-cn/device-dev/porting/Readme-CN.md b/zh-cn/device-dev/porting/Readme-CN.md index ae54c69dc6597106a1d5e8a3cc23d0235bdba6da..8d2c217aee92178f6eb562066e5bcac3465bb7f5 100644 --- a/zh-cn/device-dev/porting/Readme-CN.md +++ b/zh-cn/device-dev/porting/Readme-CN.md @@ -67,3 +67,5 @@ repo init -u https://gitee.com/openharmony-sig/manifest.git -b master -m devboar - [Combo解决方案之W800芯片移æ¤æ¡ˆä¾‹](porting-w800-combo-demo.md) - å°åž‹ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æ¡ˆä¾‹ - [å°åž‹è®¾å¤‡STM32MP1芯片移æ¤æ¡ˆä¾‹](porting-stm32mp15xx-on-smallsystem.md) +- æ ‡å‡†ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æ¡ˆä¾‹ + - [æ ‡å‡†ç³»ç»Ÿæ–¹æ¡ˆä¹‹ç‘žèŠ¯å¾®RK3568移æ¤æ¡ˆä¾‹](porting-dayu200-on_standard-demo.md) diff --git a/zh-cn/device-dev/porting/porting-chip-board-bundle.md b/zh-cn/device-dev/porting/porting-chip-board-bundle.md index 6c40374e471a03939674b66328c2b74c28dfa0ac..1fd6ca469bbdf2529b3bbe4d01ccf7f3648755b9 100644 --- a/zh-cn/device-dev/porting/porting-chip-board-bundle.md +++ b/zh-cn/device-dev/porting/porting-chip-board-bundle.md @@ -10,7 +10,7 @@ 1. æ‹·è´include/mbedtls/config.h到ports目录下,并修改打开MBEDTLS_ENTROPY_HARDWARE_ALT开关。 2. 在ports目录下创建entropy_poll_alt.c文件include并实现entropy_poll.hä¸çš„硬件éšæœºæ•°æŽ¥å£ 3. 在BUILD.gnä¸çš„mbedtls_sourcesä¸å¢žåŠ 刚æ‰é€‚é…çš„entropy_poll_alt.c的路径 - 4. 在BIULD.gnä¸çš„lite_library("mbedtls_static")ä¸å¢žåŠ 一行MBEDTLS_CONFIG_FILE指定新é…置文件的ä½ç½® + 4. 在BUILD.gnä¸çš„lite_library("mbedtls_static")ä¸å¢žåŠ 一行MBEDTLS_CONFIG_FILE指定新é…置文件的ä½ç½® ``` lite_library("mbedtks_static") { diff --git a/zh-cn/device-dev/porting/porting-chip-prepare-knows.md b/zh-cn/device-dev/porting/porting-chip-prepare-knows.md index 528ce6fc4262a09b827c057faa24147705f0cc81..6ab7e3d1032baf227f068b279266f9a869753124 100644 --- a/zh-cn/device-dev/porting/porting-chip-prepare-knows.md +++ b/zh-cn/device-dev/porting/porting-chip-prepare-knows.md @@ -18,7 +18,7 @@ OpenHarmony整体工程较为å¤æ‚,目录åŠå®žçŽ°ä¸ºç³»ç»Ÿæœ¬èº«åŠŸèƒ½ï¼Œå¦‚ | /build/lite | OpenHarmony基础编译构建框架 | | /kernel/liteos_m | åŸºç¡€å†…æ ¸ï¼Œå…¶ä¸èŠ¯ç‰‡æž¶æž„相关实现在arch目录下 | | /device | æ¿çº§ç›¸å…³å®žçŽ°ï¼Œå„个三方厂商按照OpenHarmony规范适é…实现,device下具体目录结构åŠç§»æ¤è¿‡ç¨‹å‚è§[æ¿çº§ç³»ç»Ÿç§»æ¤](../porting/porting-chip-board-overview.md) | -| /vendor | 产å“级相关实现,主è¦ç”±åŽä¸ºæˆ–者产å“厂商贡献 | +| /vendor | 产å“级相关实现,主è¦ç”±äº§å“厂商贡献 | device目录规则:device/{芯片解决方案厂商}/{å¼€å‘æ¿}。以hisiliconçš„hispark_taurus为例: @@ -37,7 +37,7 @@ device ``` -vendor目录规则:vendor/{产å“解决方案厂商}/{产å“å称}。以åŽä¸ºçš„wifiiot产å“为例: +vendor目录规则:vendor/{产å“解决方案厂商}/{产å“å称}。以wifiiot产å“为例: diff --git a/zh-cn/device-dev/porting/porting-chip-prepare-process.md b/zh-cn/device-dev/porting/porting-chip-prepare-process.md index 503972d4e72da5945b93d678c71140707d70f6be..eee8899860e35df47baad80ef1697cf9d04b26f3 100644 --- a/zh-cn/device-dev/porting/porting-chip-prepare-process.md +++ b/zh-cn/device-dev/porting/porting-chip-prepare-process.md @@ -44,7 +44,7 @@ # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. board_toolchain = "gcc-arm-none-eabi" - # The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc. + # The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc. board_toolchain_path = rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin", root_build_dir) diff --git a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md index 9fe8e43aff7baef85f9054fd49f5899d17c0a351..1a5c4104231706bbf1e1d133e18ae82504cac47f 100644 --- a/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md +++ b/zh-cn/device-dev/porting/porting-smallchip-prepare-building.md @@ -86,7 +86,7 @@ sudo apt-get install gcc-arm-linux-gnueabi # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. board_toolchain = "mips-linux-gnu-gcc" - # The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc. + # The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc. board_toolchain_path = rebase_path("//prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/bin", root_build_dir) diff --git a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md index 043e797410d3c3b92a775af0c410d53ab7826f62..94b137955ecd3608b9d1e3ab31ee257d2a0d4d64 100644 --- a/zh-cn/device-dev/porting/porting-thirdparty-cmake.md +++ b/zh-cn/device-dev/porting/porting-thirdparty-cmake.md @@ -219,7 +219,7 @@ CMakeæ–¹å¼å¯é€šè¿‡æŒ‡å®šå·¥å…·é“¾è¿›è¡Œäº¤å‰ç¼–译,修改并编译该库, #toolchain:follow up-layer,depend on $ohos_build_compiler if (ohos_build_compiler == "clang") { - CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + CMAKE_TOOLCHAIN_FLAG = "-DOHOS_SYSROOT_PATH=${root_out_dir}sysroot" } else { CMAKE_TOOLCHAIN_FLAG = "" } diff --git a/zh-cn/device-dev/porting/porting-thirdparty-makefile.md b/zh-cn/device-dev/porting/porting-thirdparty-makefile.md index 5d01193f8c7cf62e190cbbf7e326e4ab776d2f2b..1a068c62af7a74c9db2591b9112577685d236dd7 100644 --- a/zh-cn/device-dev/porting/porting-thirdparty-makefile.md +++ b/zh-cn/device-dev/porting/porting-thirdparty-makefile.md @@ -173,9 +173,9 @@ if (ohos_build_thirdparty_migrated_from_fuchisa == true) { TEST_ENABLE = "YES" if (TEST_ENABLE == "YES") { - MAKE_COMMAND = "make test OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + MAKE_COMMAND = "make test OHOS_SYSROOT_PATH=${root_out_dir}sysroot/" } else { - MAKE_COMMAND = "make OHOS_SYSROOT_PATH=${ohos_root_path}prebuilts/lite/sysroot/" + MAKE_COMMAND = "make OHOS_SYSROOT_PATH=${root_out_dir}sysroot/" } ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-build.md b/zh-cn/device-dev/quick-start/quickstart-build.md index 0cc4275aabdaf7e000ffd04c181ab7cbf43aa3db..4e2363163cbd3c5577fd3d245e29279dc042564c 100644 --- a/zh-cn/device-dev/quick-start/quickstart-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-build.md @@ -1,41 +1,40 @@ # 编译形æ€æ•´ä½“说明 - -**编译构建支æŒçš„产å“列表** +**编译构建支æŒçš„产å“列表** (点击链接å¯çŸ¥é“具体产å“é…ç½®åŠå…¶ç›¸å…³å·®å¼‚) | ç¼–è¯‘å½¢æ€ | å¼€å‘æ¿ | 主芯片 | å†…æ ¸ | 系统类型 | | ----------------------------- | --------------- | ----------- | ----------- | ----------- | -| neptune100 | neptune100 | winnermicro | liteos_m | mini | -| rk3568 | rk3568 | rockchip | linux | standard | -| rk3568_mini_system | rk3568 | rockchip | linux | standard | -| bearpi_hm_micro | bearpi_hm_micro | stm32mp1xx | liteos_a | small | -| bearpi_hm_nano | bearpi_hm_nano | hi3861v100 | liteos_m | mini | -| wifiiot_hispark_pegasus | hispark_pegasus | hi3861v100 | liteos_m | mini | -| ipcamera_hispark_aries | hispark_aries | hi3518ev300 | liteos_a | small | -| ipcamera_hispark_taurus | hispark_taurus | hi3516dv300 | liteos_a | small | -| ipcamera_hispark_taurus_linux | hispark_taurus | hi3516dv300 | linux | small | -| hispark_taurus_standard | hispark_taurus | hi3516dv300 | linux | standard | -| watchos | hispark_taurus | hi3516dv300 | linux | standard | -| hispark_phoenix | hispark_phoenix | hi3751v350 | linux | standard | -| hispark_taurus_mini_system | hispark_taurus | hi3516dv300 | liteos_a | mini | -| hispark_pegasus_mini_system | hispark_pegasus | hi3861v100 | liteos_m | mini | -| gr5515_sk_iotlink_demo | gr5515_sk | gr551x | liteos_m | mini | -| gr5515_sk_xts_demo | gr5515_sk | gr551x | liteos_m | mini | -| wifi_demo | dev_wifi_a | asr582x | liteos_m | mini | -| xts_demo | dev_wifi_a | asr582x | liteos_m | mini | -| display_demo | v200zr | bes2600 | liteos_m | mini | -| xts_demo | v200zr | bes2600 | liteos_m | mini | -| iotlink_demo | v200zr | bes2600 | liteos_m | mini | -| mini_distributed_music_player | v200zr | bes2600 | liteos_m | mini | -| niobe407 | niobe407 | stm32f4xx | liteos_m | mini | -| qemu_mini_system_demo | arm_mps2_an386 | qemu | liteos_m | mini | -| qemu_cksy_mini_system_demo | SmartL_E802 | qemu | liteos_m | mini | -| qemu_cm55_mini_system_demo | arm_mps3_an547 | qemu | liteos_m | mini | -| qemu_xtensa_mini_system_demo | esp32 | qemu | liteos_m | mini | -| qemu_riscv_mini_system_demo | ricsv32_virt | qemu | liteos_m | mini | -| qemu_ca7_mini_system_demo | arm_virt | qemu | liteos_a | small | -| qemu_small_system_demo | arm_virt | qemu | liteos_a | small | -| qemu-arm-linux-min | qemu-arm-linux | qemu | linux | standard | -| qemu-arm-linux-headless | qemu-arm-linux | qemu | linux | standard | -| iotlink_demo | cst85_wblink | chipsea | liteos_m | mini | -| dsoftbus_demo | cst85_wblink | chipsea | liteos_m | mini | -| xts_demo | cst85_wblink | chipsea | liteos_m | mini | +| [neptune100](https://gitee.com/openharmony/vendor_hihope/blob/master/neptune_iotlink_demo/config.json) | neptune100 | winnermicro | liteos_m | mini | +| [rk3568](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/config.json) | rk3568 | rockchip | linux | standard | +| [rk3568_mini_system](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568_mini_system/config.json) | rk3568 | rockchip | linux | standard | +| [bearpi_hm_micro](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_micro/config.json) | bearpi_hm_micro | stm32mp1xx | liteos_a | small | +| [bearpi_hm_nano](https://gitee.com/openharmony/vendor_bearpi/blob/master/bearpi_hm_nano/config.json) | bearpi_hm_nano | hi3861v100 | liteos_m | mini | +| [wifiiot_hispark_pegasus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | +| [ipcamera_hispark_aries](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_aries/config.json) | hispark_aries | hi3518ev300 | liteos_a | small | +| [ipcamera_hispark_taurus](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus/config.json) | hispark_taurus | hi3516dv300 | liteos_a | small | +| [ipcamera_hispark_taurus_linux](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_linux/config.json) | hispark_taurus | hi3516dv300 | linux | small | +| [hispark_taurus_standard](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_standard/config.json) | hispark_taurus | hi3516dv300 | linux | standard | +| [watchos](https://gitee.com/openharmony/vendor_hisilicon/blob/master/watchos/config.json) | hispark_taurus | hi3516dv300 | linux | standard | +| [hispark_phoenix](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_phoenix/config.json) | hispark_phoenix | hi3751v350 | linux | standard | +| [hispark_taurus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_taurus_mini_system/config.json) | hispark_taurus | hi3516dv300 | liteos_a | mini | +| [hispark_pegasus_mini_system](https://gitee.com/openharmony/vendor_hisilicon/blob/master/hispark_pegasus_mini_system/config.json) | hispark_pegasus | hi3861v100 | liteos_m | mini | +| [gr5515_sk_iotlink_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_iotlink_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | +| [gr5515_sk_xts_demo](https://gitee.com/openharmony/vendor_goodix/blob/master/gr5515_sk_xts_demo/config.json) | gr5515_sk | gr551x | liteos_m | mini | +| [wifi_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/wifi_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_asrmicro/blob/master/xts_demo/config.json) | dev_wifi_a | asr582x | liteos_m | mini | +| [display_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/display_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/xts_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [iotlink_demo](https://gitee.com/openharmony/vendor_bestechnic/blob/master/iotlink_demo/config.json) | v200zr | bes2600 | liteos_m | mini | +| [mini_distributed_music_player](https://gitee.com/openharmony/vendor_bestechnic/blob/master/mini_distributed_music_player/config.json) | v200zr | bes2600 | liteos_m | mini | +| [niobe407](https://gitee.com/openharmony/vendor_talkweb/blob/master/niobe407/config.json) | niobe407 | stm32f4xx | liteos_m | mini | +| [qemu_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_mini_system_demo/config.json) | arm_mps2_an386 | qemu | liteos_m | mini | +| [qemu_cksy_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_csky_mini_system_demo/config.json) | SmartL_E802 | qemu | liteos_m | mini | +| [qemu_cm55_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_cm55_mini_system_demo/config.json) | arm_mps3_an547 | qemu | liteos_m | mini | +| [qemu_xtensa_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_xtensa_mini_system_demo/config.json) | esp32 | qemu | liteos_m | mini | +| [qemu_riscv_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_riscv32_mini_system_demo/config.json) | ricsv32_virt | qemu | liteos_m | mini | +| [qemu_ca7_mini_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_ca7_mini_system_demo/config.json) | arm_virt | qemu | liteos_a | small | +| [qemu_small_system_demo](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_small_system_demo/config.json) | arm_virt | qemu | liteos_a | small | +| [qemu_arm_linux_min](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_min/config.json) | qemu-arm-linux | qemu | linux | standard | +| [qemu_arm_linux_headless](https://gitee.com/openharmony/vendor_ohemu/blob/master/qemu_arm_linux_headless/config.json) | qemu-arm-linux | qemu | linux | standard | +| [iotlink_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/iotlink_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | +| [dsoftbus_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/dsoftbus_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | +| [xts_demo](https://gitee.com/openharmony/vendor_chipsea/blob/master/xts_demo/config.json) | cst85_wblink | chipsea | liteos_m | mini | diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md index 79b49ce5480cdd4de7fad23c3ef8f273ac7fa04b..ceef078f3194ff55fc38d0d5e72c186fca77e2d2 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md @@ -387,18 +387,19 @@ bash build/prebuilts_download.sh ### 安装LLVM(ä»…OpenHarmony_v1.x分支/æ ‡ç¾éœ€è¦) >  **须知:** -> 如果下载的æºç 为OpenHarmony_v1.x分支/æ ‡ç¾ï¼Œè¯·æŒ‰ä¸‹é¢çš„æ¥éª¤å®‰è£…9.0.0版本的llvm。 +> 如果下载的æºç 为OpenHarmony_v1.x分支/æ ‡ç¾ï¼Œè¯·æŒ‰ä¸‹é¢çš„æ¥éª¤å®‰è£…12.0.1版本的llvm。 > > 如果下载的æºç 为MasteråŠéžOpenHarmony_v1.x分支/æ ‡ç¾ï¼Œå¯ç›´æŽ¥è·³è¿‡æœ¬å°èŠ‚,hb会自动下载最新的llvm。 1. 打开Linux编译æœåŠ¡å™¨ç»ˆç«¯ã€‚ -2. [下载LLVM工具](https://repo.huaweicloud.com/harmonyos/compiler/clang/9.0.0-36191/linux/llvm-linux-9.0.0-36191.tar)。 +2. [下载LLVM工具](https://repo.huaweicloud.com/openharmony/compiler/clang/12.0.1-530132/linux/clang-530132-linux-x86_64.tar.bz2)。 3. 解压LLVM安装包至~/llvm路径下。 ``` - tar -zxvf llvm.tar -C ~/ + tar -jxvf clang.tar.bz2 -C ~/ + mv ~/clang-530132/ ~/llvm ``` 4. 设置环境å˜é‡ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md b/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..98c7de011fef755a118ea6dc9e3f4ef10d1bae4c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/Readme-CN.md @@ -0,0 +1,225 @@ +# HDI 接å£å‚考 + +- æ¨¡å— + - [Audio](_audio.md) + - [Battery](battery.md) + - [Camera](_camera.md) + - [Codec](_codec.md) + - [Display](_display.md) + - [HdfFaceAuth](_hdf_face_auth.md) + - [Input](_input.md) + - [Light](_light.md) + - [HdfPinAuth](_hdf_pin_auth.md) + - [Power](power.md) + - [Sensor](_sensor.md) + - [Thermal](thermal.md) + - [USB](_u_s_b.md) + - [HdfUserAuth](_hdf_user_auth.md) + - [Vibrator](_vibrator.md) + - [WLAN](_w_l_a_n.md) +- 头文件和结构体 + - 头文件 + - [audio_adapter.h](audio__adapter_8h.md) + - [audio_attribute.h](audio__attribute_8h.md) + - [audio_capture.h](audio__capture_8h.md) + - [audio_control.h](audio__control_8h.md) + - [audio_manager.h](audio__manager_8h.md) + - [audio_render.h](audio__render_8h.md) + - [audio_scene.h](audio__scene_8h.md) + - [audio_types.h](audio__types_8h.md) + - [audio_volume.h](audio__volume_8h.md) + - [codec_callback_if.h](codec__callback__if_8h.md) + - [codec_common_type.h](codec__common__type_8h.md) + - [codec_component_if.h](codec__component__if_8h.md) + - [codec_component_manager.h](codec__component__manager_8h.md) + - [codec_component_type.h](codec__component__type_8h.md) + - [display_device.h](display__device_8h.md) + - [display_gfx.h](display__gfx_8h.md) + - [display_gralloc.h](display__gralloc_8h.md) + - [display_layer.h](display__layer_8h.md) + - [display_type.h](display__type_8h.md) + - [icamera_device_callback.h](icamera__device__callback_8h.md) + - [icamera_device.h](icamera__device_8h.md) + - [icamera_host_callback.h](icamera__host__callback_8h.md) + - [icamera_host.h](icamera__host_8h.md) + - [input_controller.h](input__controller_8h.md) + - [input_manager.h](input__manager_8h.md) + - [input_reporter.h](input__reporter_8h.md) + - [input_type.h](input__type_8h.md) + - [ioffline_stream_operator.h](ioffline__stream__operator_8h.md) + - [istream_operator_callback.h](istream__operator__callback_8h.md) + - [istream_operator.h](istream__operator_8h.md) + - [light_if.h](light__if_8h.md) + - [light_type.h](light_8typeh.md) + - [sensor_if.h](sensor__if_8h.md) + - [sensor_type.h](sensor__type_8h.md) + - [types.h](types_8h.md) + - [usb_info.h](usb__info_8h.md) + - [usbd_client.h](usbd__client_8h.md) + - [usbd_subscriber.h](usbd__subscriber_8h.md) + - [usbd_type.h](usbd__type_8h.md) + - [vibrator_if.h](vibrator__if_8h.md) + - [vibrator_type.h](vibrator__type_8h.md) + - [wifi_hal_ap_feature.h](wifi__hal__ap__feature_8h.md) + - [wifi_hal_base_feature.h](wifi__hal__base__feature_8h.md) + - [wifi_hal_sta_feature.h](wifi__hal__sta__feature_8h.md) + - [wifi_hal.h](wifi__hal_8h.md) + - [IExecutor.idl](face__auth_2_i_executor_8idl.md) + - [IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md) + - [FaceAuthTypes.idl](_face_auth_types_8idl.md) + - [PinAuthTypes.idl](_pin_auth_types_8idl.md) + - [IBatteryCallback.idl](_i_battery_callback_8idl.md) + - [IBatteryInterface.idl](_i_battery_interface_8idl.md) + - [IExecutor.idl](pin__auth_2_i_executor_8idl.md) + - [IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md) + - [IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md) + - [IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md) + - [IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md) + - [IPowerInterface.idl](_i_power_interface_8idl.md) + - [IThermalInterface.idl](_i_thermal_interface_8idl.md) + - [IThermalCallback.idl](_i_thermal_callback_8idl.md) + - [IUserAuthInterface.idl](_i_user_auth_interface_8idl.md) + - [PowerTypes.idl](_power_types_8idl.md) + - [ThermalTypes.idl](_thermal_types_8idl.md) + - [Types.idl](_types_8idl.md) + - [UserAuthTypes.idl](_user_auth_types_8idl.md) + - 结构体 + - [__attribute__](____attribute____.md) + - [Alignment](_alignment.md) + - [AllocInfo](_alloc_info.md) + - [AudioAdapter](_audio_adapter.md) + - [AudioAdapterDescriptor](_audio_adapter_descriptor.md) + - [AudioAttribute](_audio_attribute.md) + - [AudioCapture](_audio_capture.md) + - [AudioControl](_audio_control.md) + - [AudioDevExtInfo](_audio_dev_ext_info.md) + - [AudioDeviceDescriptor](_audio_device_descriptor.md) + - [AudioManager](_audio_manager.md) + - [AudioMixExtInfo](_audio_mix_ext_info.md) + - [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) + - [AudioPort](_audio_port.md) + - [AudioPortCap](_audio_port_cap.md) + - [AudioPortCapability](_audio_port_capability.md) + - [AudioRender](_audio_render.md) + - [AudioRoute](_audio_route.md) + - [AudioRouteNode](_audio_route_node.md) + - [AudioSampleAttributes](_audio_sample_attributes.md) + - [AudioScene](_audio_scene.md) + - [AudioSceneDescriptor](_audio_scene_descriptor.md) + - [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) + - [AudioSessionExtInfo](_audio_session_ext_info.md) + - [AudioSubPortCapability](_audio_sub_port_capability.md) + - [AudioTimeStamp](_audio_time_stamp.md) + - [AudioVolume](_audio_volume.md) + - [AuthResultInfo](_auth_result_info.md) + - [AuthSolution](_auth_solution.md) + - [BatteryInfo](_battery_info.md) + - [BufferData](_buffer_data.md) + - [CodecCallbackType](_codec_callback_type.md) + - [CodecCompCapability](_codec_comp_capability.md) + - [CodecComponentManager](_codec_component_manager.md) + - [CodecComponentType](_codec_component_type.md) + - [CompVerInfo](_comp_ver_info.md) + - [CredentialInfo](_credential_info.md) + - [DeviceFuncs](_device_funcs.md) + - [DisplayCapability](_display_capability.md) + - [DisplayInfo](_display_info.md) + - [DisplayModeInfo](_display_mode_info.md) + - [EnrolledInfo](_enrolled_info.md) + - [EnrollParam](_enroll_param.md) + - [EnrollResultInfo](_enroll_resultinfo.md) + - [EventInfo](_event_info.md) + - [ExecutorInfo](_executor_info.md) + - [ExecutorInfo](_user_executor_info.md) + - [ExecutorRegisterInfo](_executor_register_info.md) + - [ExecutorSendMsg](_executor_send_msg.md) + - [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) + - [GfxFuncs](_gfx_funcs.md) + - [GfxOpt](_gfx_opt.md) + - [GrallocFuncs](_gralloc_funcs.md) + - [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) + - [HDRCapability](_h_d_r_capability.md) + - [HDRMetaData](_h_d_r_meta_data.md) + - [IBatteryCallback](interface_i_battery_callback.md) + - [IBatteryInterface](interface_i_battery_interface.md) + - [ICircle](_i_circle.md) + - [IdentifyResultInfo](_identify_result_info.md) + - [IExecutor](interface_i_executor.md) + - [IExecutor](interface_pin_i_executor.md) + - [IExecutorCallback](interface_i_executor_callback.md) + - [IExecutorCallback](interface_pin_i_executor_callback.md) + - [IFaceAuthInterface](interface_i_face_auth_interface.md) + - [IInputInterface](_i_input_interface.md) + - [ILine](_i_line.md) + - [InputController](_input_controller.md) + - [InputDevAbility](_input_dev_ability.md) + - [InputDevAttr](_input_dev_attr.md) + - [InputDevDesc](_input_dev_desc.md) + - [InputDevIdentify](_input_dev_identify.md) + - [InputDeviceInfo](_device_info.md) + - [InputDimensionInfo](_input_dimension_info.md) + - [InputEventCb](_input_report_event_cb.md) + - [InputEventPackage](_event_package.md) + - [InputExtraCmd](_input_extra_cmd.md) + - [InputHostCb](_input_host_cb.md) + - [InputHotPlugEvent](_input_hotplug_event.md) + - [InputManager](_input_manager.md) + - [InputReporter](_input_reporter.md) + - [IPinAuthInterface](interface_i_pin_auth_interface.md) + - [IPowerHdiCallback](interface_i_power_hdi_callback.md) + - [IPowerInterface](interface_i_power_interface.md) + - [IRect](_i_rect.md) + - [ISurface](_i_surface.md) + - [IThermalCallback](interface_i_thermal_callback.md) + - [IThermalInterface](interface_i_thermal_interface.md) + - [IUserAuthInterface](interface_i_user_auth_interface.md) + - [IWiFi](_i_wi_fi.md) + - [IWiFiAp](_i_wi_fi_ap.md) + - [IWiFiBaseFeature](_i_wi_fi_base_feature.md) + - [IWiFiSta](_i_wi_fi_sta.md) + - [LayerAlpha](_layer_alpha.md) + - [LayerBuffer](_layer_buffer.md) + - [LayerFuncs](_layer_funcs.md) + - [LayerInfo](_layer_info.md) + - [LightEffect](_light_effect.md) + - [LightFlashEffect](_light_flash_effect.md) + - [LightInfo](_light_info.md) + - [LightInterface](_light_interface.md) + - [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) + - [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) + - [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) + - [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) + - [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) + - [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) + - [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) + - [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) + - [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) + - [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) + - [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) + - [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) + - [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) + - [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) + - [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) + - [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) + - [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) + - [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) + - [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) + - [OmxCodecBuffer](_omx_codec_buffer.md) + - [PortCap](union_port_cap.md) + - [PresentTimestamp](_present_timestamp.md) + - [PropertyObject](_property_object.md) + - [RangeValue](_range_value.md) + - [Rect](_rect.md) + - [Rectangle](_rectangle.md) + - [ScheduleInfo](_schedule_info.md) + - [SensorEvents](_sensor_events.md) + - [SensorInformation](_sensor_information.md) + - [SensorInterface](_sensor_interface.md) + - [StaInfo](_sta_info.md) + - [SupportBufferType](_support_buffer_type.md) + - [TemplateInfo](_template_info.md) + - [ThermalZoneInfo](_thermal_zone_info.md) + - [UseBufferType](_use_buffer_type.md) + - [VerifyAllocInfo](_verify_alloc_info.md) + - [VibratorInterface](_vibrator_interface.md) + - [VideoPortCap](_video_port_cap.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/____attribute____.md b/zh-cn/device-dev/reference/hdi-apis/____attribute____.md new file mode 100644 index 0000000000000000000000000000000000000000..c271b05bee1f5f6ab32382c00e2c125470c6da91 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/____attribute____.md @@ -0,0 +1,34 @@ +# __attribute__ + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [fd](_display.md#fd) | å¥æŸ„ fd, -1代表ä¸æ”¯æŒã€‚ | +| [reserveInts](_display.md#reserveints) | reserve数组的个数。 | +| [reserve](_display.md#reserve) [0] | reserve数组。 | +| [baseAddr](_display.md#baseaddr) | 内å˜çš„åˆå§‹åœ°å€ã€‚ | +| [yOffset](_display.md#yoffset) | Yçš„å移é‡ã€‚ | +| [uOffset](_display.md#uoffset) | Uçš„å移é‡ã€‚ | +| [vOffset](_display.md#voffset) | Vçš„å移é‡ã€‚ | +| [yStride](_display.md#ystride) | Yçš„strideä¿¡æ¯ã€‚ | +| [uvStride](_display.md#uvstride) | UVçš„strideä¿¡æ¯ã€‚ | +| [uvStep](_display.md#uvstep) | UVçš„stepä¿¡æ¯ã€‚ | + + +## **详细æè¿°** + +扩展数æ®å¥æŸ„结构体定义。 + +YUVæè¿°ä¿¡æ¯ç»“构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_alignment.md b/zh-cn/device-dev/reference/hdi-apis/_alignment.md new file mode 100644 index 0000000000000000000000000000000000000000..fe001f65e7ca31fea14d7d5ae3bf63ba18b28d62 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_alignment.md @@ -0,0 +1,51 @@ +# Alignment + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [widthAlignment](#widthalignment) | 宽的对é½å€¼ã€‚ | +| [heightAlignment](#heightalignment) | 高的对é½å€¼ã€‚ | + + +## **详细æè¿°** + +对é½ç»“构定义,包å«å®½é«˜çš„对é½å€¼ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### heightAlignment + + +``` +int32_t Alignment::heightAlignment +``` + +**æ述:** + +高的对é½å€¼ã€‚ + + +### widthAlignment + + +``` +int32_t Alignment::widthAlignment +``` + +**æ述:** + +宽的对é½å€¼ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md b/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md new file mode 100644 index 0000000000000000000000000000000000000000..6873294ab8b4518a09450b67b7ff209e41102503 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_alloc_info.md @@ -0,0 +1,27 @@ +# AllocInfo + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](_display.md#width-67) | 申请内å˜å®½åº¦ | +| [height](_display.md#height-67) | 申请内å˜é«˜åº¦ | +| [usage](_display.md#usage-12) | 申请内å˜çš„使用场景 | +| [format](_display.md#format-12) | 申请内å˜æ ¼å¼ | +| [expectedSize](_display.md#expectedsize) | 申请内å˜å¤§å° | + + +## **详细æè¿°** + +定义关于è¦åˆ†é…的内å˜çš„ä¿¡æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio.md b/zh-cn/device-dev/reference/hdi-apis/_audio.md new file mode 100644 index 0000000000000000000000000000000000000000..554eb44177de3dd16d2f72091eb23972324c3a5c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio.md @@ -0,0 +1,1319 @@ +# Audio + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [audio_adapter.h](audio__adapter_8h.md) | Audio适é…器的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_attribute.h](audio__attribute_8h.md) | Audio属性的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_capture.h](audio__capture_8h.md) | Audio录音的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_control.h](audio__control_8h.md) | Audio控制的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_manager.h](audio__manager_8h.md) | Audio适é…器管ç†åŠåŠ 载的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_render.h](audio__render_8h.md) | Audioæ’放的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_scene.h](audio__scene_8h.md) | Audio场景的接å£å®šä¹‰æ–‡ä»¶ | +| [audio_types.h](audio__types_8h.md) | Audio模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ | +| [audio_volume.h](audio__volume_8h.md) | Audio音é‡çš„接å£å®šä¹‰æ–‡ä»¶ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适é…å™¨æŽ¥å£ [更多...](_audio_adapter.md) | +| [AudioAttribute](_audio_attribute.md) | AudioAttributeéŸ³é¢‘å±žæ€§æŽ¥å£ [更多...](_audio_attribute.md) | +| [AudioCapture](_audio_capture.md) | AudioCaptureéŸ³é¢‘å½•éŸ³æŽ¥å£ [更多...](_audio_capture.md) | +| [AudioControl](_audio_control.md) | AudioControléŸ³é¢‘æŽ§åˆ¶æŽ¥å£ [更多...](_audio_control.md) | +| [AudioManager](_audio_manager.md) | AudioManager音频适é…器管ç†æŽ¥å£ [更多...](_audio_manager.md) | +| [AudioRender](_audio_render.md) | AudioRender音频æ’æ”¾æŽ¥å£ [更多...](_audio_render.md) | +| [AudioScene](_audio_scene.md) | AudioSceneéŸ³é¢‘åœºæ™¯æŽ¥å£ [更多...](_audio_scene.md) | +| [AudioPort](_audio_port.md) | éŸ³é¢‘ç«¯å£ [更多...](_audio_port.md) | +| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适é…器æ述符 [更多...](_audio_adapter_descriptor.md) | +| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备æ述符 [更多...](_audio_device_descriptor.md) | +| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景æ述符 [更多...](_audio_scene_descriptor.md) | +| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景æè¿° [更多...](union_audio_scene_descriptor_1_1_scene_desc.md) | +| [AudioSampleAttributes](_audio_sample_attributes.md) | éŸ³é¢‘é‡‡æ ·å±žæ€§ [更多...](_audio_sample_attributes.md) | +| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 [更多...](_audio_time_stamp.md) | +| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频å端å£çš„支æŒèƒ½åŠ› [更多...](_audio_sub_port_capability.md) | +| [AudioPortCapability](_audio_port_capability.md) | 音频端å£çš„支æŒèƒ½åŠ› [更多...](_audio_port_capability.md) | +| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区æ述符 [更多...](_audio_mmap_buffer_descripter.md) | +| [AudioDevExtInfo](_audio_dev_ext_info.md) | éŸ³é¢‘è®¾å¤‡æ‹“å±•ä¿¡æ¯ [更多...](_audio_dev_ext_info.md) | +| [AudioMixExtInfo](_audio_mix_ext_info.md) | éŸ³è½¨æ‹“å±•ä¿¡æ¯ [更多...](_audio_mix_ext_info.md) | +| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会è¯æ‹“å±•ä¿¡æ¯ [更多...](_audio_session_ext_info.md) | +| [AudioRouteNode](_audio_route_node.md) | 音频路由节点 [更多...](_audio_route_node.md) | +| [AudioRoute](_audio_route.md) | éŸ³é¢‘è·¯ç”±ä¿¡æ¯ [更多...](_audio_route.md) | +| [AudioVolume](_audio_volume.md) | AudioVolume音频音é‡æŽ¥å£ [更多...](_audio_volume.md) | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| AudioHandle | 音频å¥æŸ„ | +| ([RenderCallback](#rendercallback)) (enum [AudioCallbackType](#audiocallbacktype), void \*reserved, void \*cookie) | 回调函数指针 [更多...](#rendercallback) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AudioPortDirection](#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端å£çš„类型 [更多...](#audioportdirection) | +| [AudioPortPin](#audioportpin) { PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u, PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u, PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适é…器端å£çš„PINè„š [更多...](#audioportpin) | +| [AudioCategory](#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) [更多...](#audiocategory) | +| [AudioFormat](#audioformat) { AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u, AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u, AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u, AUDIO_FORMAT_G726 = 0x2000003u } | éŸ³é¢‘æ ¼å¼ [更多...](#audioformat) | +| [AudioChannelMask](#audiochannelmask) { AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通é“掩ç (mask) [更多...](#audiochannelmask) | +| [AudioSampleRatesMask](#audiosampleratesmask) { AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u, AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u, AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡MASK [更多...](#audiosampleratesmask) | +| [AudioPortPassthroughMode](#audioportpassthroughmode) { PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端å£çš„æ•°æ®é€ä¼ æ¨¡å¼ [更多...](#audioportpassthroughmode) | +| [AudioSampleFormat](#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P, AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P, AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P, AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P, AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P, AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P, AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT, AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P, AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | åŽŸå§‹éŸ³é¢‘æ ·æœ¬æ ¼å¼ [更多...](#audiosampleformat) | +| [AudioChannelMode](#audiochannelmode) { AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE, AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频æ’放的通é“æ¨¡å¼ [更多...](#audiochannelmode) | +| [AudioDrainNotifyType](#audiodrainnotifytype) { AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结æŸç±»åž‹ [更多...](#audiodrainnotifytype) | +| [AudioCallbackType](#audiocallbacktype) { AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL, AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 [更多...](#audiocallbacktype) | +| [AudioPortRole](#audioportrole) { AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端å£è§’色 [更多...](#audioportrole) | +| [AudioPortType](#audioporttype) { AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端å£ç±»åž‹ [更多...](#audioporttype) | +| [AudioSessionType](#audiosessiontype) { AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端å£ä¼šè¯ç±»åž‹ [更多...](#audiosessiontype) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GetAudioManagerFuncs](#getaudiomanagerfuncs) (void) | 获å–音频适é…器管ç†æŽ¥å£çš„æ“作函数列表,详情å‚考[AudioManager](_audio_manager.md)[更多...](#getaudiomanagerfuncs) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| [AudioPort::dir](#dir) | 音频端å£çš„类型。 | +| [AudioPort::portId](#portid-14) | 音频端å£çš„ID。 | +| [AudioPort::portName](#portname) | 音频端å£çš„å称。 | +| [AudioAdapterDescriptor::adapterName](#adaptername) | 音频适é…器的å称。 | +| [AudioAdapterDescriptor::portNum](#portnum) | 一个音频适é…器支æŒçš„端å£æ•°ç›®ã€‚ | +| [AudioAdapterDescriptor::ports](#ports) | 一个音频适é…器支æŒçš„端å£åˆ—表。 | +| [AudioDeviceDescriptor::portId](#portid-24) | 音频端å£ID。 | +| [AudioDeviceDescriptor::pins](#pins) | 音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入)。 | +| [AudioDeviceDescriptor::desc](#desc-15) | 以å—符串命å的音频设备。 | +| [AudioSceneDescriptor::SceneDesc::id](#id) | 音频场景的ID。 | +| [AudioSceneDescriptor::SceneDesc::desc](#desc-35) | 以å—符串命å的音频场景。 | +| [AudioSceneDescriptor::scene](#scene) | 音频场景的å称。 | +| [AudioSceneDescriptor::desc](#desc-25) | 音频设备æ述符。 | +| [AudioSampleAttributes::type](#type-13) | 音频类型。 | +| [AudioSampleAttributes::interleaved](#interleaved) | 音频数æ®äº¤ç»‡çš„æ ‡è®°ã€‚ | +| [AudioSampleAttributes::format](#format) | 音频数æ®æ ¼å¼ã€‚ | +| [AudioSampleAttributes::sampleRate](#samplerate) | éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ã€‚ | +| [AudioSampleAttributes::channelCount](#channelcount-12) | 音频通é“数目,如å•é€šé“(mono)为1ã€ç«‹ä½“声(stereo)为2。 | +| [AudioSampleAttributes::period](#period) | éŸ³é¢‘é‡‡æ ·å‘¨æœŸã€‚ | +| [AudioSampleAttributes::frameSize](#framesize) | 音频数æ®çš„帧大å°ã€‚ | +| [AudioSampleAttributes::isBigEndian](#isbigendian) | 音频数æ®çš„å¤§ç«¯æ ‡å¿—ã€‚ | +| [AudioSampleAttributes::isSignedData](#issigneddata) | 音频数æ®çš„有符å·æˆ–æ— ç¬¦å·æ ‡å¿—。 | +| [AudioSampleAttributes::startThreshold](#startthreshold) | 音频渲染开始阈值。 | +| [AudioSampleAttributes::stopThreshold](#stopthreshold) | 音频渲染åœæ¢é˜ˆå€¼ã€‚ | +| [AudioSampleAttributes::silenceThreshold](#silencethreshold) | 音频æ•èŽ·ç¼“冲区阈值。 | +| [AudioSampleAttributes::streamId](#streamid-12) | 渲染或æ•èŽ·çš„éŸ³é¢‘æ ‡è¯†ç¬¦ã€‚ | +| [AudioTimeStamp::tvSec](#tvsec) | tvSec时间,å•ä½ï¼šç§’。 | +| [AudioTimeStamp::tvNSec](#tvnsec) | tvNSec时间,å•ä½ï¼šçº³ç§’。 | +| [AudioSubPortCapability::portId](#portid-34) | å端å£ID。 | +| [AudioSubPortCapability::desc](#desc-45) | 以å—符串命åçš„å端å£ã€‚ | +| [AudioSubPortCapability::mask](#mask) | æ•°æ®é€ä¼ 模å¼ã€‚ | +| [AudioPortCapability::deviceType](#devicetype) | 设备输出ã€è¾“入类型。 | +| [AudioPortCapability::deviceId](#deviceid) | 绑定(bind)设备ID,唯一的设备识别符。 | +| [AudioPortCapability::hardwareMode](#hardwaremode) | 是å¦æ”¯æŒè®¾å¤‡ç»‘定处ç†ã€‚ | +| [AudioPortCapability::formatNum](#formatnum) | 支æŒçš„éŸ³é¢‘æ ¼å¼æ•°ç›®ã€‚ | +| [AudioPortCapability::formats](#formats) | 支æŒçš„éŸ³é¢‘æ ¼å¼ã€‚ | +| [AudioPortCapability::sampleRateMasks](#sampleratemasks) | 支æŒçš„éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ï¼ˆ8kã€16kã€32kã€48k)。 | +| [AudioPortCapability::channelMasks](#channelmasks) | 设备的声é“布局掩ç (mask)。 | +| [AudioPortCapability::channelCount](#channelcount-22) | 支æŒçš„最大声é“总数。 | +| [AudioPortCapability::subPortsNum](#subportsnum) | 支æŒçš„å端å£æ•°ç›®ï¼ˆä»…用于输出设备)。 | +| [AudioPortCapability::subPorts](#subports) | 支æŒçš„å端å£åˆ—表。 | +| [AudioPortCapability::supportSampleFormatNum](#supportsampleformatnum) | 支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼æ•°é‡ã€‚ | +| [AudioPortCapability::supportSampleFormats](#supportsampleformats) | 支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼ã€‚ | +| [AudioMmapBufferDescripter::memoryAddress](#memoryaddress) | 指å‘mmap缓冲区的指针。 | +| [AudioMmapBufferDescripter::memoryFd](#memoryfd) | mmap缓冲区的文件æ述符。 | +| [AudioMmapBufferDescripter::totalBufferFrames](#totalbufferframes) | 缓冲区总大å°ï¼Œå•ä½ï¼šå¸§ã€‚ | +| [AudioMmapBufferDescripter::transferFrameSize](#transferframesize) | ä¼ è¾“å¤§å°ï¼Œå•ä½ï¼šå¸§ã€‚ | +| [AudioMmapBufferDescripter::isShareable](#isshareable) | mmap缓冲区是å¦å¯ä»¥åœ¨è¿›ç¨‹é—´å…±äº«ã€‚ | +| [AudioDevExtInfo::moduleId](#moduleid-12) | 音频æµç»‘定的模å—ID。 | +| [AudioDevExtInfo::type](#type-23) | 音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入)。 | +| [AudioDevExtInfo::desc](#desc-55) | 地å€æ述。 | +| [AudioMixExtInfo::moduleId](#moduleid-22) | æµæ‰€å±žæ¨¡å—æ ‡è¯†ç¬¦ã€‚ | +| [AudioMixExtInfo::streamId](#streamid-22) | ç”±è°ƒç”¨è€…ä¼ é€’çš„Render或Captureæ ‡è¯†ç¬¦ã€‚ | +| [AudioSessionExtInfo::sessionType](#sessiontype) | 音频会è¯ç±»åž‹ã€‚ | +| [AudioRouteNode::portId](#portid-44) | 音频端å£ID。 | +| [AudioRouteNode::role](#role) | 指定端å£è§’色为sink或source。 | +| [AudioRouteNode::type](#type-33) | 指定端å£ç±»åž‹ã€‚ | +| [AudioRouteNode::device](#device) | 设备特定信æ¯ã€‚ | +| [AudioRouteNode::mix](#mix) | 音轨特定信æ¯ã€‚ | +| [AudioRouteNode::session](#session) | 会è¯ç‰¹å®šä¿¡æ¯ã€‚ | +| [AudioRoute::sourcesNum](#sourcesnum) | å‘é€ç«¯èŠ‚点数é‡ã€‚ | +| [AudioRoute::sources](#sources) | å‘é€ç«¯åˆ—表。 | +| [AudioRoute::sinksNum](#sinksnum) | 接å—端节点数é‡ã€‚ | +| [AudioRoute::sinks](#sinks) | 接å—端列表。 | + + +## **详细æè¿°** + +Audio模å—接å£å®šä¹‰ã€‚ + +音频接å£æ¶‰åŠè‡ªå®šä¹‰ç±»åž‹ã€é©±åŠ¨åŠ 载接å£ã€é©±åŠ¨é€‚é…器接å£ã€éŸ³é¢‘æ’放(render)接å£ã€éŸ³é¢‘录音(capture)接å£ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **类型定义说明** + + +### RenderCallback + + +``` +typedef int32_t(* RenderCallback) (enum AudioCallbackType, void *reserved, void *cookie) +``` + +**æ述:** + +回调函数指针。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| AudioCallbackType | 回调函数å“应类型 | +| reserved | ä¿ç•™å—段 | +| cookie | ç”¨äºŽä¼ é€’æ•°æ® | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +RegCallback + + +## **枚举类型说明** + + +### AudioCallbackType + + +``` +enum AudioCallbackType +``` + +**æ述:** + +回调函数通知事件类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_NONBLOCK_WRITE_COMPELETED | éžé˜»å¡žå¼å†™å®Œæˆ | +| AUDIO_DRAIN_COMPELETED | DrainBufferå®Œæˆ | +| AUDIO_FLUSH_COMPLETED | Flushå®Œæˆ | +| AUDIO_RENDER_FULL | Render缓冲区已满 | +| AUDIO_ERROR_OCCUR | å‘生了错误 | + + +### AudioCategory + + +``` +enum AudioCategory +``` + +**æ述:** + +音频类型(category)。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_IN_MEDIA | 媒体 | +| AUDIO_IN_COMMUNICATION | 通信 | +| AUDIO_IN_RINGTONE | 铃声 | +| AUDIO_IN_CALL | å‘¼å« | + + +### AudioChannelMask + + +``` +enum AudioChannelMask +``` + +**æ述:** + +音频通é“掩ç (mask)。 + +定义音频声é“çš„ä½ç½®ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_CHANNEL_FRONT_LEFT | 声é“布局å‰å·¦ | +| AUDIO_CHANNEL_FRONT_RIGHT | 声é“布局å‰å³ | +| AUDIO_CHANNEL_MONO | å•å£°é“ | +| AUDIO_CHANNEL_STEREO | 立体声,由左å³å£°é“组æˆï¼ˆFRONT_LEFT \| FRONT_RIGHT) | + + +### AudioChannelMode + + +``` +enum AudioChannelMode +``` + +**æ述:** + +音频æ’放的通é“模å¼ã€‚ + +>  **须知:** +> 下é¢çš„模å¼æ˜¯é’ˆå¯¹åŒé€šé“立体声的音频æ’放而设置,其他ä¸æ”¯æŒã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_CHANNEL_NORMAL | æ£å¸¸æ¨¡å¼ï¼Œä¸åšå¤„ç† | +| AUDIO_CHANNEL_BOTH_LEFT | 两个声é“全部为左声é“声音 | +| AUDIO_CHANNEL_BOTH_RIGHT | 两个声é“全部为å³å£°é“声音 | +| AUDIO_CHANNEL_EXCHANGE | å·¦å³å£°é“æ•°æ®äº’æ¢ï¼Œå·¦å£°é“为å³å£°é“声音,å³å£°é“为左声é“声音 | +| AUDIO_CHANNEL_MIX | å·¦å³ä¸¤ä¸ªå£°é“输出为左å³å£°é“ç›¸åŠ ï¼ˆæ··éŸ³ï¼‰ | +| AUDIO_CHANNEL_LEFT_MUTE | 左声é“é™éŸ³ï¼Œå³å£°é“æ’放原å³å£°é“声音 | +| AUDIO_CHANNEL_RIGHT_MUTE | å³å£°é“é™éŸ³ï¼Œå·¦å£°é“æ’放原左声é“声音 | +| AUDIO_CHANNEL_BOTH_MUTE | å·¦å³å£°é“å‡é™éŸ³ | + + +### AudioDrainNotifyType + + +``` +enum AudioDrainNotifyType +``` + +**æ述:** + +DrainBuffer函数结æŸç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_DRAIN_NORMAL_MODE | DrainBuffer在所有数æ®æ’放结æŸåŽè¿”回 | +| AUDIO_DRAIN_EARLY_MODE | DrainBuffer()在当å‰æ›²ç›®çš„所有数æ®æ’放完之å‰è¿”回,以便留出时间给音频æœåŠ¡åšè¿žç»æ€§æ›²ç›®åˆ‡æ¢ | + + +### AudioFormat + + +``` +enum AudioFormat +``` + +**æ述:** + +éŸ³é¢‘æ ¼å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_FORMAT_PCM_8_BIT | 8bitä½å®½pcmæ ¼å¼ | +| AUDIO_FORMAT_PCM_16_BIT | 16bitä½å®½pcmæ ¼å¼ | +| AUDIO_FORMAT_PCM_24_BIT | 24bitä½å®½pcmæ ¼å¼ | +| AUDIO_FORMAT_PCM_32_BIT | 32bitä½å®½pcmæ ¼å¼ | +| AUDIO_FORMAT_AAC_MAIN | AAC MAINæ ¼å¼ | +| AUDIO_FORMAT_AAC_LC | AAC LCæ ¼å¼ | +| AUDIO_FORMAT_AAC_LD | AAC LDæ ¼å¼ | +| AUDIO_FORMAT_AAC_ELD | AAC ELDæ ¼å¼ | +| AUDIO_FORMAT_AAC_HE_V1 | AAC HE_V1æ ¼å¼ | +| AUDIO_FORMAT_AAC_HE_V2 | AAC HE_V2æ ¼å¼ | +| AUDIO_FORMAT_G711A | G711Aæ ¼å¼ | +| AUDIO_FORMAT_G711U | G711uæ ¼å¼ | +| AUDIO_FORMAT_G726 | G726æ ¼å¼ | + + +### AudioPortDirection + + +``` +enum AudioPortDirection +``` + +**æ述:** + +音频端å£çš„类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| PORT_OUT | 音频输出端å£ã€‚ | +| PORT_IN | 音频输入端å£ã€‚ | +| PORT_OUT_IN | 音频输出/入端å£ï¼ŒåŒæ—¶æ”¯æŒè¾“出和输入能力(OUT \| IN)。 | + + +### AudioPortPassthroughMode + + +``` +enum AudioPortPassthroughMode +``` + +**æ述:** + +音频端å£çš„æ•°æ®é€ä¼ 模å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PORT_PASSTHROUGH_LPCM | 立体声pcm | +| PORT_PASSTHROUGH_RAW | HDMIé€ä¼ | +| PORT_PASSTHROUGH_HBR2LBR | è“光次世代音频é™è§„æ ¼è¾“å‡º | +| PORT_PASSTHROUGH_AUTO | æ ¹æ®HDMI EDIDèƒ½åŠ›è‡ªåŠ¨åŒ¹é… | + + +### AudioPortPin + + +``` +enum AudioPortPin +``` + +**æ述:** + +音频适é…器端å£çš„PIN脚。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIN_NONE | æ— æ•ˆPIN | +| PIN_OUT_SPEAKER | å–‡å输出 | +| PIN_OUT_HEADSET | 有线耳机输出 | +| PIN_OUT_LINEOUT | Lineout输出 | +| PIN_OUT_HDMI | HDMI输出 | +| PIN_OUT_USB | USB设备输出 | +| PIN_OUT_USB_EXT | 扩展 USB 设备输出 | +| PIN_IN_MIC | Mic输入 | +| PIN_IN_HS_MIC | 有线耳机Mic输入 | +| PIN_IN_LINEIN | Linein输入 | +| PIN_IN_USB_EXT | 扩展 USB 设备输入 | + + +### AudioPortRole + + +``` +enum AudioPortRole +``` + +**æ述:** + +音频端å£è§’色。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_PORT_UNASSIGNED_ROLE | 未指定端å£è§’色 | +| AUDIO_PORT_SOURCE_ROLE | 指定端å£ä¸ºå‘é€ç«¯è§’色 | +| AUDIO_PORT_SINK_ROLE | 指定端å£ä¸ºæŽ¥å—端角色 | + + +### AudioPortType + + +``` +enum AudioPortType +``` + +**æ述:** + +音频端å£ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_PORT_UNASSIGNED_TYPE | 未指定端å£ç±»åž‹ | +| AUDIO_PORT_DEVICE_TYPE | 指定端å£ä¸ºè®¾å¤‡ç±»åž‹ | +| AUDIO_PORT_MIX_TYPE | 指定端å£ç±»åž‹ä¸ºå¤åˆç±»åž‹ | +| AUDIO_PORT_SESSION_TYPE | 指定端å£ä¸ºä¼šè¯ç±»åž‹ | + + +### AudioSampleFormat + + +``` +enum AudioSampleFormat +``` + +**æ述:** + +åŽŸå§‹éŸ³é¢‘æ ·æœ¬æ ¼å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_SAMPLE_FORMAT_S8 | 8bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S8P | 8bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U8 | 8bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U8P | 8bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S16 | 16bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S16P | 16bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U16 | 16bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U16P | 16bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S24 | 24bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S24P | 24bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U24 | 24bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U24P | 24bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S32 | 32bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S32P | 32bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U32 | 32bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U32P | 32bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S64 | 64bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_S64P | 64bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U64 | 64bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_U64P | 64bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_F32 | 32bitä½å®½æµ®ç‚¹åž‹äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_F32P | 64bitä½å®½æµ®ç‚¹åž‹éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_F64 | 64bitä½å®½åŒç²¾åº¦æµ®ç‚¹åž‹äº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FORMAT_F64P | 64bitä½å®½åŒç²¾åº¦æµ®ç‚¹åž‹éžäº¤ç»‡æ ·æœ¬ | +| AUDIO_SAMPLE_FMT_U8 | æ— ç¬¦å·8ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ | +| AUDIO_SAMPLE_FMT_S16 | 带符å·16ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ | +| AUDIO_SAMPLE_FMT_S32 | 带符å·32ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ | +| AUDIO_SAMPLE_FMT_FLOAT | æµ®ç‚¹åž‹ï¼Œæ‰“åŒ…æ ¼å¼ | +| AUDIO_SAMPLE_FMT_DOUBLE | åŒç²¾åº¦æµ®ç‚¹åž‹ï¼Œæ‰“åŒ…æ ¼å¼ | +| AUDIO_SAMPLE_FMT_U8P | æ— ç¬¦å·8ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ | +| AUDIO_SAMPLE_FMT_S16P | 带符å·16ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ | +| AUDIO_SAMPLE_FMT_S32P | 带符å·32ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ | +| AUDIO_SAMPLE_FMT_FLOATP | 浮点型,平é¢æ ¼å¼ | +| AUDIO_SAMPLE_FMT_DOUBLEP | åŒç²¾åº¦æµ®ç‚¹åž‹ï¼Œå¹³é¢æ ¼å¼ | +| AUDIO_SAMPLE_FMT_INVALID | æ— æ•ˆé‡‡æ ·æ ¼å¼ | + + +### AudioSampleRatesMask + + +``` +enum AudioSampleRatesMask +``` + +**æ述:** + +éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡MASK。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_SAMPLE_RATE_MASK_8000 | 8K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_12000 | 12K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_11025 | 11.025K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_16000 | 16K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_22050 | 22.050K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_24000 | 24K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_32000 | 32K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_44100 | 44.1K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_48000 | 48K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_64000 | 64K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_96000 | 96K é‡‡æ ·é¢‘çŽ‡ | +| AUDIO_SAMPLE_RATE_MASK_INVALID | æ— æ•ˆçš„é‡‡æ ·é¢‘çŽ‡ | + + +### AudioSessionType + + +``` +enum AudioSessionType +``` + +**æ述:** + +端å£ä¼šè¯ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_OUTPUT_STAGE_SESSION | 会è¯ç»‘å®šåˆ°æŒ‡å®šè¾“å‡ºæµ | +| AUDIO_OUTPUT_MIX_SESSION | 会è¯ç»‘定到特定音轨 | +| AUDIO_ALLOCATE_SESSION | 会è¯ID需é‡æ–°ç”³è¯· | +| AUDIO_INVALID_SESSION | æ— æ•ˆä¼šè¯ç±»åž‹ | + + +## **函数说明** + + +### GetAudioManagerFuncs() + + +``` +struct AudioManager* GetAudioManagerFuncs (void ) +``` + +**æ述:** + +获å–音频适é…器管ç†æŽ¥å£çš„æ“作函数列表,详情å‚考[AudioManager](_audio_manager.md)。 + +**返回:** + +æˆåŠŸè¿”回一个音频适é…器管ç†æŽ¥å£çš„对象,失败返回NULL。 + + +## **å˜é‡è¯´æ˜Ž** + + +### adapterName + + +``` +const char* AudioAdapterDescriptor::adapterName +``` + +**æ述:** + +音频适é…器的å称。 + + +### channelCount [1/2] + + +``` +uint32_t AudioSampleAttributes::channelCount +``` + +**æ述:** + +音频通é“数目,如å•é€šé“(mono)为1ã€ç«‹ä½“声(stereo)为2。 + + +### channelCount [2/2] + + +``` +unsigned int AudioPortCapability::channelCount +``` + +**æ述:** + +支æŒçš„最大声é“总数。 + + +### channelMasks + + +``` +enum AudioChannelMask AudioPortCapability::channelMasks +``` + +**æ述:** + +设备的声é“布局掩ç (mask),详情å‚考[AudioChannelMask](#audiochannelmask)。 + + +### desc [1/5] + + +``` +const char* AudioDeviceDescriptor::desc +``` + +**æ述:** + +以å—符串命å的音频设备。 + + +### desc [2/5] + + +``` +struct AudioDeviceDescriptor AudioSceneDescriptor::desc +``` + +**æ述:** + +音频设备æ述符。 + + +### desc [3/5] + + +``` +const char* AudioSceneDescriptor::SceneDesc::desc +``` + +**æ述:** + +以å—符串命å的音频场景。 + + +### desc [4/5] + + +``` +const char* AudioSubPortCapability::desc +``` + +**æ述:** + +以å—符串命åçš„å端å£ã€‚ + + +### desc [5/5] + + +``` +const char* AudioDevExtInfo::desc +``` + +**æ述:** + +地å€æ述。 + + +### deviceId + + +``` +unsigned int AudioPortCapability::deviceId +``` + +**æ述:** + +绑定(bind)设备ID,唯一的设备识别符。 + + +### deviceType + + +``` +unsigned int AudioPortCapability::deviceType +``` + +**æ述:** + +设备输出ã€è¾“入类型。 + + +### dir + + +``` +enum AudioPortDirection AudioPort::dir +``` + +**æ述:** + +音频端å£çš„类型,详情å‚考[AudioPortDirection](#audioportdirection)。 + + +### format + + +``` +enum AudioFormat AudioSampleAttributes::format +``` + +**æ述:** + +音频数æ®æ ¼å¼ï¼Œè¯¦æƒ…å‚考[AudioFormat](#audioformat)。 + + +### formatNum + + +``` +unsigned int AudioPortCapability::formatNum +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘æ ¼å¼æ•°ç›®ã€‚ + + +### formats + + +``` +enum AudioFormat* AudioPortCapability::formats +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘æ ¼å¼ï¼Œè¯¦æƒ…å‚考[AudioFormat](#audioformat)。 + + +### frameSize + + +``` +uint32_t AudioSampleAttributes::frameSize +``` + +**æ述:** + +音频数æ®çš„帧大å°ã€‚ + + +### hardwareMode + + +``` +bool AudioPortCapability::hardwareMode +``` + +**æ述:** + +是å¦æ”¯æŒè®¾å¤‡ç»‘定处ç†ã€‚ + + +### id + + +``` +unsigned int AudioSceneDescriptor::SceneDesc::id +``` + +**æ述:** + +音频场景的ID。 + + +### interleaved + + +``` +bool AudioSampleAttributes::interleaved +``` + +**æ述:** + +音频数æ®äº¤ç»‡çš„æ ‡è®°ã€‚ + + +### isBigEndian + + +``` +bool AudioSampleAttributes::isBigEndian +``` + +**æ述:** + +音频数æ®çš„å¤§ç«¯æ ‡å¿—ã€‚ + + +### isShareable + + +``` +int32_t AudioMmapBufferDescripter::isShareable +``` + +**æ述:** + +mmap缓冲区是å¦å¯ä»¥åœ¨è¿›ç¨‹é—´å…±äº«ã€‚ + + +### isSignedData + + +``` +bool AudioSampleAttributes::isSignedData +``` + +**æ述:** + +音频数æ®çš„有符å·æˆ–æ— ç¬¦å·æ ‡å¿— + + +### mask + + +``` +enum AudioPortPassthroughMode AudioSubPortCapability::mask +``` + +**æ述:** + +æ•°æ®é€ä¼ 模å¼ï¼Œè¯¦æƒ…å‚考[AudioPortPassthroughMode](#audioportpassthroughmode)。 + + +### memoryAddress + + +``` +void* AudioMmapBufferDescripter::memoryAddress +``` + +**æ述:** + +指å‘mmap缓冲区的指针。 + + +### memoryFd + + +``` +int32_t AudioMmapBufferDescripter::memoryFd +``` + +**æ述:** + +mmap缓冲区的文件æ述符。 + + +### moduleId [1/2] + + +``` +int32_t AudioDevExtInfo::moduleId +``` + +**æ述:** + +音频æµç»‘定的模å—ID。 + + +### moduleId [2/2] + + +``` +int32_t AudioMixExtInfo::moduleId +``` + +**æ述:** + +æµæ‰€å±žæ¨¡å—æ ‡è¯†ç¬¦ã€‚ + + +### period + + +``` +uint32_t AudioSampleAttributes::period +``` + +**æ述:** + +éŸ³é¢‘é‡‡æ ·å‘¨æœŸã€‚ + + +### pins + + +``` +enum AudioPortPin AudioDeviceDescriptor::pins +``` + +**æ述:** + +音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入),详情å‚考[AudioPortPin](#audioportpin)。 + + +### portId [1/4] + + +``` +unsigned int AudioPort::portId +``` + +**æ述:** + +音频端å£çš„ID。 + + +### portId [2/4] + + +``` +unsigned int AudioDeviceDescriptor::portId +``` + +**æ述:** + +音频端å£ID。 + + +### portId [3/4] + + +``` +unsigned int AudioSubPortCapability::portId +``` + +**æ述:** + +å端å£ID。 + + +### portId [4/4] + + +``` +int32_t AudioRouteNode::portId +``` + +**æ述:** + +音频端å£ID。 + + +### portName + + +``` +const char* AudioPort::portName +``` + +**æ述:** + +音频端å£çš„å称。 + + +### portNum + + +``` +unsigned int AudioAdapterDescriptor::portNum +``` + +**æ述:** + +一个音频适é…器支æŒçš„端å£æ•°ç›®ã€‚ + + +### ports + + +``` +struct AudioPort* AudioAdapterDescriptor::ports +``` + +**æ述:** + +一个音频适é…器支æŒçš„端å£åˆ—表。 + + +### role + + +``` +enum AudioPortRole AudioRouteNode::role +``` + +**æ述:** + +指定端å£è§’色为sink或source。 + + +### sampleRate + + +``` +unsigned int AudioSampleAttributes::sampleRate +``` + +**æ述:** + +éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ã€‚ + + +### sampleRateMasks + + +``` +unsigned int AudioPortCapability::sampleRateMasks +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ï¼ˆ8kã€16kã€32kã€48k)。 + + +### scene + + +``` +union AudioSceneDescriptor::SceneDesc AudioSceneDescriptor::scene +``` + +**æ述:** + +音频场景的å称。 + + +### sessionType + + +``` +enum AudioSessionType AudioSessionExtInfo::sessionType +``` + +**æ述:** + +音频会è¯ç±»åž‹ã€‚ + + +### silenceThreshold + + +``` +uint32_t AudioSampleAttributes::silenceThreshold +``` + +**æ述:** + +音频æ•èŽ·ç¼“冲区阈值。 + + +### sinks + + +``` +const struct AudioRouteNode* AudioRoute::sinks +``` + +**æ述:** + +接å—端列表。 + + +### sinksNum + + +``` +uint32_t AudioRoute::sinksNum +``` + +**æ述:** + +接å—端节点数é‡ã€‚ + + +### sources + + +``` +const struct AudioRouteNode* AudioRoute::sources +``` + +**æ述:** + +å‘é€ç«¯åˆ—表。 + + +### sourcesNum + + +``` +uint32_t AudioRoute::sourcesNum +``` + +**æ述:** + +å‘é€ç«¯èŠ‚点数é‡ã€‚ + + +### startThreshold + + +``` +uint32_t AudioSampleAttributes::startThreshold +``` + +**æ述:** + +音频渲染开始阈值。 + + +### stopThreshold + + +``` +uint32_t AudioSampleAttributes::stopThreshold +``` + +**æ述:** + +音频渲染åœæ¢é˜ˆå€¼ã€‚ + + +### streamId [1/2] + + +``` +int32_t AudioSampleAttributes::streamId +``` + +**æ述:** + +渲染或æ•èŽ·çš„éŸ³é¢‘æ ‡è¯†ç¬¦ã€‚ + + +### streamId [2/2] + + +``` +int32_t AudioMixExtInfo::streamId +``` + +**æ述:** + +ç”±è°ƒç”¨è€…ä¼ é€’çš„Render或Captureæ ‡è¯†ç¬¦ã€‚ + + +### subPorts + + +``` +struct AudioSubPortCapability* AudioPortCapability::subPorts +``` + +**æ述:** + +支æŒçš„å端å£åˆ—表。 + + +### subPortsNum + + +``` +unsigned int AudioPortCapability::subPortsNum +``` + +**æ述:** + +支æŒçš„å端å£æ•°ç›®ï¼ˆä»…用于输出设备)。 + + +### supportSampleFormatNum + + +``` +uint32_t AudioPortCapability::supportSampleFormatNum +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼æ•°é‡ã€‚ + + +### supportSampleFormats + + +``` +enum AudioSampleFormat* AudioPortCapability::supportSampleFormats +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼ï¼Œè¯¦è¯·å‚考[AudioSampleFormat](_codec.md#audiosampleformat)。 + + +### totalBufferFrames + + +``` +int32_t AudioMmapBufferDescripter::totalBufferFrames +``` + +**æ述:** + +缓冲区总大å°ï¼Œå•ä½ï¼šå¸§ã€‚ + + +### transferFrameSize + + +``` +int32_t AudioMmapBufferDescripter::transferFrameSize +``` + +**æ述:** + +ä¼ è¾“å¤§å°ï¼Œå•ä½ï¼šå¸§ã€‚ + + +### tvNSec + + +``` +int64_t AudioTimeStamp::tvNSec +``` + +**æ述:** + +tvNSec时间,å•ä½ï¼šçº³ç§’。 + + +### tvSec + + +``` +int64_t AudioTimeStamp::tvSec +``` + +**æ述:** + +tvSec时间,å•ä½ï¼šç§’。 + + +### type [1/3] + + +``` +enum AudioCategory AudioSampleAttributes::type +``` + +**æ述:** + +音频类型,详情å‚考[AudioCategory](#audiocategory)。 + + +### type [2/3] + + +``` +enum AudioPortPin AudioDevExtInfo::type +``` + +**æ述:** + +音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入),详情å‚考[AudioPortPin](#audioportpin)。 + + +### type [3/3] + + +``` +enum AudioPortType AudioRouteNode::type +``` + +**æ述:** + +指定端å£ç±»åž‹ã€‚ + + +### device + + +``` + struct AudioDevExtInfo AudioRouteNode::device +``` + +**æ述:** + +设备特定信æ¯ã€‚ + + +### mix + + +``` + struct AudioMixExtInfo AudioRouteNode::mix +``` + +**æ述:** + +音轨特定信æ¯ã€‚ + + +### session + + +``` + struct AudioSessionExtInfo AudioRouteNode::session +``` + +**æ述:** + +会è¯ç‰¹å®šä¿¡æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md new file mode 100644 index 0000000000000000000000000000000000000000..c4ddc25428e9e04cacde47a42b131bec1d9e60cf --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter.md @@ -0,0 +1,326 @@ +# AudioAdapter + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [InitAllPorts](#initallports) )(struct AudioAdapter \*adapter) | åˆå§‹åŒ–一个音频适é…器所有的端å£é©±åŠ¨ [更多...](#initallports) | +| ( [CreateRender](#createrender) )(struct AudioAdapter \*adapter, const struct [AudioDeviceDescriptor](_audio_device_descriptor.md) \*desc, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs, struct [AudioRender](_audio_render.md) \*\*render) | 创建一个音频æ’放(render)接å£çš„对象 [更多...](#createrender) | +| ( [DestroyRender](#destroyrender) )(struct AudioAdapter \*adapter, struct [AudioRender](_audio_render.md) \*render) | 销æ¯ä¸€ä¸ªéŸ³é¢‘æ’放(render)接å£çš„对象 [更多...](#destroyrender) | +| ( [CreateCapture](#createcapture) )(struct AudioAdapter \*adapter, const struct [AudioDeviceDescriptor](_audio_device_descriptor.md) \*desc, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs, struct [AudioCapture](_audio_capture.md) \*\*capture) | 创建一个音频录音(capture)接å£çš„对象 [更多...](#createcapture) | +| ( [DestroyCapture](#destroycapture) )(struct AudioAdapter \*adapter, struct [AudioCapture](_audio_capture.md) \*capture) | 销æ¯ä¸€ä¸ªéŸ³é¢‘录音(capture)接å£çš„对象 [更多...](#destroycapture) | +| ( [GetPortCapability](#getportcapability) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, struct [AudioPortCapability](_audio_port_capability.md) \*capability) | 获å–一个音频适é…器的端å£é©±åŠ¨çš„能力集 [更多...](#getportcapability) | +| ( [SetPassthroughMode](#setpassthroughmode) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, enum [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) mode) | 设置音频端å£é©±åŠ¨çš„æ•°æ®é€ä¼ æ¨¡å¼ [更多...](#setpassthroughmode) | +| ( [GetPassthroughMode](#getpassthroughmode) )(struct AudioAdapter \*adapter, struct [AudioPort](_audio_port.md) \*port, enum [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) \*mode) | 获å–音频端å£é©±åŠ¨çš„æ•°æ®é€ä¼ æ¨¡å¼ [更多...](#getpassthroughmode) | +| ( [UpdateAudioRoute](#updateaudioroute) )(struct AudioAdapter \*adapter, const struct [AudioRoute](_audio_route.md) \*route, int32_t \*routeHandle) | 更新一个或多个å‘é€ç«¯å’ŒæŽ¥å—端之间的路由 [更多...](#updateaudioroute) | +| ( [ReleaseAudioRoute](#releaseaudioroute) )(struct \*adapter, int32_t routeHandle) | 释放一个音频路由. [更多...](#releaseaudioroute) | + + +## **详细æè¿°** + +AudioAdapter音频适é…å™¨æŽ¥å£ + +æ供音频适é…器(声å¡ï¼‰å¯¹å¤–支æŒçš„驱动能力,包括åˆå§‹åŒ–端å£ã€åˆ›å»ºrenderã€åˆ›å»ºcaptureã€èŽ·å–端å£èƒ½åŠ›é›†ç‰ + +**å‚è§ï¼š** + +[AudioRender](_audio_render.md) + +[AudioCapture](_audio_capture.md) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CreateCapture + + +``` +int32_t(* AudioAdapter::CreateCapture) (struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs, struct AudioCapture **capture) +``` + +**æ述:** + +创建一个音频录音(capture)接å£çš„对象 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器的指针 | +| desc | 指å‘è¦å¯åŠ¨çš„音频适é…器的æ述符的指针 | +| attrs | 指å‘è¦æ‰“å¼€çš„éŸ³é¢‘é‡‡æ ·å±žæ€§çš„æŒ‡é’ˆ | +| capture | 指å‘AudioCapture对象的二级指针 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetPortCapability](#getportcapability) + +[DestroyCapture](#destroycapture) + + +### CreateRender + + +``` +int32_t(* AudioAdapter::CreateRender) (struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs, struct AudioRender **render) +``` + +**æ述:** + +创建一个音频æ’放(render)接å£çš„对象 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| desc | 待打开的音频设备æ述符 | +| attrs | å¾…æ‰“å¼€çš„éŸ³é¢‘é‡‡æ ·å±žæ€§ | +| render | 获å–的音频æ’放接å£çš„对象实例ä¿å˜åˆ°renderä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetPortCapability](#getportcapability) + +[DestroyRender](#destroyrender) + + +### DestroyCapture + + +``` +int32_t(* AudioAdapter::DestroyCapture) (struct AudioAdapter *adapter, struct AudioCapture *capture) +``` + +**æ述:** + +销æ¯ä¸€ä¸ªéŸ³é¢‘录音(capture)接å£çš„对象 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| capture | å¾…æ“作的音频录音接å£å¯¹è±¡ | + +**注æ„:** + +在音频录音过程ä¸ï¼Œä¸èƒ½é”€æ¯è¯¥æŽ¥å£å¯¹è±¡ + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[CreateCapture](#createcapture) + + +### DestroyRender + + +``` +int32_t(* AudioAdapter::DestroyRender) (struct AudioAdapter *adapter, struct AudioRender *render) +``` + +**æ述:** + +销æ¯ä¸€ä¸ªéŸ³é¢‘æ’放(render)接å£çš„对象 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | + +**注æ„:** + +在音频æ’放过程ä¸ï¼Œä¸èƒ½é”€æ¯è¯¥æŽ¥å£å¯¹è±¡ + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[CreateRender](#createrender) + + +### GetPassthroughMode + + +``` +int(* AudioAdapter::GetPassthroughMode) (struct AudioAdapter *adapter, struct AudioPort *port, enum AudioPortPassthroughMode *mode) +``` + +**æ述:** + +获å–音频端å£é©±åŠ¨çš„æ•°æ®é€ä¼ æ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| port | 待获å–çš„ç«¯å£ | +| mode | 获å–çš„ä¼ è¾“æ¨¡å¼ä¿å˜åˆ°modeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetPassthroughMode](#setpassthroughmode) + + +### GetPortCapability + + +``` +int(* AudioAdapter::GetPortCapability) (struct AudioAdapter *adapter, struct AudioPort *port, struct AudioPortCapability *capability) +``` + +**æ述:** + +获å–一个音频适é…器的端å£é©±åŠ¨çš„能力集 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| port | 待获å–çš„ç«¯å£ | +| capability | 获å–的端å£èƒ½åŠ›ä¿å˜åˆ°capabilityä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### InitAllPorts + + +``` +int(* AudioAdapter::InitAllPorts) (struct AudioAdapter *adapter) +``` + +**æ述:** + +åˆå§‹åŒ–一个音频适é…器所有的端å£é©±åŠ¨ + +在音频æœåŠ¡ä¸ï¼Œè°ƒç”¨å…¶ä»–驱动接å£å‰éœ€è¦é¦–先调用该接å£æ£€æŸ¥ç«¯å£æ˜¯å¦å·²ç»åˆå§‹åŒ–完æˆï¼Œå¦‚果端å£é©±åŠ¨åˆå§‹åŒ–完æˆï¼Œåˆ™å‡½æ•°è¿”回值0, å¦åˆ™è¿”回负值,如果端å£æ²¡æœ‰åˆå§‹åŒ–完æˆï¼Œåˆ™éœ€è¦ç‰å¾…一段时间(例如100ms)åŽé‡æ–°è¿›è¡Œæ£€æŸ¥ï¼Œç›´åˆ°ç«¯å£åˆå§‹åŒ–完æˆåŽå†ç»§ç»æ“作 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### ReleaseAudioRoute + + +``` +int32_t(* AudioAdapter::ReleaseAudioRoute) (struct AudioAdapter *adapter, int32_t routeHandle) +``` + +**æ述:** + +释放一个音频路由. + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| routeHandle | 待释放的路由å¥æŸ„. | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### SetPassthroughMode + + +``` +int(* AudioAdapter::SetPassthroughMode) (struct AudioAdapter *adapter, struct AudioPort *port, enum AudioPortPassthroughMode mode) +``` + +**æ述:** + +设置音频端å£é©±åŠ¨çš„æ•°æ®é€ä¼ æ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| port | å¾…è®¾ç½®çš„ç«¯å£ | +| mode | å¾…è®¾ç½®çš„ä¼ è¾“æ¨¡å¼ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetPassthroughMode](#getpassthroughmode) + + +### UpdateAudioRoute + + +``` +int32_t(* AudioAdapter::UpdateAudioRoute) (struct AudioAdapter *adapter, const struct AudioRoute *route, int32_t *routeHandle) +``` + +**æ述:** + +更新一个或多个å‘é€ç«¯å’ŒæŽ¥å—端之间的路由 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| adapter | å¾…æ“作的音频适é…器对象 | +| route | è·¯ç”±ä¿¡æ¯ | +| routeHandle | 生æˆçš„路由å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..37968692e35f2e2db9256d19583836daad3789e0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_adapter_descriptor.md @@ -0,0 +1,25 @@ +# AudioAdapterDescriptor + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [adapterName](_audio.md#adaptername) | 音频适é…器的å称。 | +| [portNum](_audio.md#portnum) | 一个音频适é…器支æŒçš„端å£æ•°ç›®ã€‚ | +| [ports](_audio.md#ports) | 一个音频适é…器支æŒçš„端å£åˆ—表。 | + + +## **详细æè¿°** + +音频适é…器æ述符。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md b/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md new file mode 100644 index 0000000000000000000000000000000000000000..84a9d471c65afca1d228083706ac4d352a689826 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_attribute.md @@ -0,0 +1,263 @@ +# AudioAttribute + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [GetFrameSize](#getframesize) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*size) | 获å–音频帧(frameï¼‰çš„å¤§å° [更多...](#getframesize) | +| ( [GetFrameCount](#getframecount) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*count) | 获å–音频bufferä¸çš„音频帧数 [更多...](#getframecount) | +| ( [SetSampleAttributes](#setsampleattributes) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs) | è®¾ç½®éŸ³é¢‘é‡‡æ ·çš„å±žæ€§å‚æ•° [更多...](#setsampleattributes) | +| ( [GetSampleAttributes](#getsampleattributes) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, struct [AudioSampleAttributes](_audio_sample_attributes.md) \*attrs) | 获å–éŸ³é¢‘é‡‡æ ·çš„å±žæ€§å‚æ•° [更多...](#getsampleattributes) | +| ( [GetCurrentChannelId](#getcurrentchannelid) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint32_t \*channelId) | 获å–音频的数æ®é€šé“ID [更多...](#getcurrentchannelid) | +| ( [SetExtraParams](#setextraparams) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const char \*keyValueList) | 设置音频拓展å‚æ•° [更多...](#setextraparams) | +| ( [GetExtraParams](#getextraparams) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, char \*keyValueList) | 获å–音频拓展å‚æ•° [更多...](#getextraparams) | +| ( [ReqMmapBuffer](#reqmmapbuffer) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, int32_t reqSize, struct [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) \*desc) | 请求mmap缓冲区 [更多...](#reqmmapbuffer) | +| ( [GetMmapPosition](#getmmapposition) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获å–当å‰mmap的读/写ä½ç½® [更多...](#getmmapposition) | + + +## **详细æè¿°** + +AudioAttributeéŸ³é¢‘å±žæ€§æŽ¥å£ + +æ供音频æ’放(render)或录音(capture)需è¦çš„公共属性驱动能力,包括获å–帧(frame)信æ¯ã€è®¾ç½®é‡‡æ ·å±žæ€§ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### GetCurrentChannelId + + +``` +int32_t(* AudioAttribute::GetCurrentChannelId) (AudioHandle handle, uint32_t *channelId) +``` + +**æ述:** + +获å–音频的数æ®é€šé“ID + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| channelId | 获å–的通é“IDä¿å˜åˆ°channelIdä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetExtraParams + + +``` +int32_t(* AudioAttribute::GetExtraParams) (AudioHandle handle, char *keyValueList) +``` + +**æ述:** + +获å–音频拓展å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| keyValueList | 拓展å‚数键值对å—ç¬¦ä¸²åˆ—è¡¨ï¼Œæ ¼å¼ä¸ºkey=value,多个键值对通过分å·åˆ†å‰² | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值。 + + +### GetFrameCount + + +``` +int32_t(* AudioAttribute::GetFrameCount) (AudioHandle handle, uint64_t *count) +``` + +**æ述:** + +获å–音频bufferä¸çš„音频帧数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| count | 一个音频bufferä¸åŒ…å«çš„音频帧数,获å–åŽä¿å˜åˆ°countä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetFrameSize + + +``` +int32_t(* AudioAttribute::GetFrameSize) (AudioHandle handle, uint64_t *size) +``` + +**æ述:** + +获å–音频帧(frameï¼‰çš„å¤§å° + +获å–一帧音频数æ®çš„长度(å—节数) + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| size | 获å–的音频帧大å°ï¼ˆå—节数)ä¿å˜åˆ°sizeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetMmapPosition + + +``` +int32_t(* AudioAttribute::GetMmapPosition) (AudioHandle handle, uint64_t *frames, struct AudioTimeStamp *time) +``` + +**æ述:** + +获å–当å‰mmap的读/写ä½ç½® + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| frames | 获å–的音频帧计数ä¿å˜åˆ°framesä¸ | +| time | 获å–çš„å…³è”时间戳ä¿å˜åˆ°timeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetSampleAttributes + + +``` +int32_t(* AudioAttribute::GetSampleAttributes) (AudioHandle handle, struct AudioSampleAttributes *attrs) +``` + +**æ述:** + +获å–éŸ³é¢‘é‡‡æ ·çš„å±žæ€§å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| attrs | 获å–çš„éŸ³é¢‘é‡‡æ ·å±žæ€§ï¼ˆä¾‹å¦‚é‡‡æ ·é¢‘çŽ‡ã€é‡‡æ ·ç²¾åº¦ã€é€šé“)ä¿å˜åˆ°attrsä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetSampleAttributes](#setsampleattributes) + + +### ReqMmapBuffer + + +``` +int32_t(* AudioAttribute::ReqMmapBuffer) (AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescripter *desc) +``` + +**æ述:** + +请求mmap缓冲区 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| reqSize | è¯·æ±‚ç¼“å†²åŒºçš„å¤§å° | +| desc | 缓冲区æ述符 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### SetExtraParams + + +``` +int32_t(* AudioAttribute::SetExtraParams) (AudioHandle handle, const char *keyValueList) +``` + +**æ述:** + +设置音频拓展å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| keyValueList | 拓展å‚数键值对å—ç¬¦ä¸²åˆ—è¡¨ï¼Œæ ¼å¼ä¸ºkey=value,多个键值对通过分å·åˆ†å‰² | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### SetSampleAttributes + + +``` +int32_t(* AudioAttribute::SetSampleAttributes) (AudioHandle handle, const struct AudioSampleAttributes *attrs) +``` + +**æ述:** + +è®¾ç½®éŸ³é¢‘é‡‡æ ·çš„å±žæ€§å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| attrs | å¾…è®¾ç½®çš„éŸ³é¢‘é‡‡æ ·å±žæ€§ï¼Œä¾‹å¦‚é‡‡æ ·é¢‘çŽ‡ã€é‡‡æ ·ç²¾åº¦ã€é€šé“ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetSampleAttributes](#getsampleattributes) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md b/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md new file mode 100644 index 0000000000000000000000000000000000000000..0cc96d36c54f5325f93f26beb4f2e8ec7daffd6f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_capture.md @@ -0,0 +1,84 @@ +# AudioCapture + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| control | 音频控制能力接å£ï¼Œè¯¦æƒ…å‚考[AudioControl](_audio_control.md) | +| attr | 音频属性能力接å£ï¼Œè¯¦æƒ…å‚考[AudioAttribute](_audio_attribute.md) | +| scene | 音频场景能力接å£ï¼Œè¯¦æƒ…å‚考[AudioScene](_audio_scene.md) | +| volume | 音频音é‡èƒ½åŠ›æŽ¥å£ï¼Œè¯¦æƒ…å‚考[AudioVolume](_audio_volume.md) | +| ( [CaptureFrame](#captureframe) )(struct AudioCapture \*capture, void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 从音频驱动ä¸å½•åˆ¶ï¼ˆcapture)一帧输入数æ®ï¼ˆå½•éŸ³ï¼ŒéŸ³é¢‘上行数æ®ï¼‰ [更多...](#captureframe) | +| ( [GetCapturePosition](#getcaptureposition) )(struct AudioCapture \*capture, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获å–音频输入帧数的上一次计数 [更多...](#getcaptureposition) | + + +## **详细æè¿°** + +AudioCapture音频录音接å£ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CaptureFrame + + +``` +int32_t(* AudioCapture::CaptureFrame) (struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes) +``` + +**æ述:** + +从音频驱动ä¸å½•åˆ¶ï¼ˆcapture)一帧输入数æ®ï¼ˆå½•éŸ³ï¼ŒéŸ³é¢‘上行数æ®ï¼‰ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| capture | å¾…æ“作的音频录音接å£å¯¹è±¡ | +| frame | å¾…å˜æ”¾è¾“入数æ®çš„音频frame | +| requestBytes | å¾…å˜æ”¾è¾“入数æ®çš„音频frame大å°ï¼ˆå—节数) | +| replyBytes | 实际读å–到的音频数æ®é•¿åº¦ï¼ˆå—节数),获å–åŽä¿å˜åˆ°replyBytesä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetCapturePosition + + +``` +int32_t(* AudioCapture::GetCapturePosition) (struct AudioCapture *capture, uint64_t *frames, struct AudioTimeStamp *time) +``` + +**æ述:** + +获å–音频输入帧数的上一次计数 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| capture | å¾…æ“作的音频录音接å£å¯¹è±¡ | +| frames | 获å–的音频帧计数ä¿å˜åˆ°framesä¸ | +| time | 获å–çš„å…³è”时间戳ä¿å˜åˆ°timeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[CaptureFrame](#captureframe) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_control.md b/zh-cn/device-dev/reference/hdi-apis/_audio_control.md new file mode 100644 index 0000000000000000000000000000000000000000..1d4d71c6d86d3874b823102ae0d71b296daa5794 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_control.md @@ -0,0 +1,214 @@ +# AudioControl + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [Start](#start) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | å¯åŠ¨ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† [更多...](#start) | +| ( [Stop](#stop) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | åœæ¢ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† [更多...](#stop) | +| ( [Pause](#pause) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | æš‚åœä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† [更多...](#pause) | +| ( [Resume](#resume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | æ¢å¤ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† [更多...](#resume) | +| ( [Flush](#flush) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | 刷新音频缓冲区bufferä¸çš„æ•°æ® [更多...](#flush) | +| ( [TurnStandbyMode](#turnstandbymode) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle) | è®¾ç½®æˆ–åŽ»è®¾ç½®è®¾å¤‡çš„å¾…æœºæ¨¡å¼ [更多...](#turnstandbymode) | +| ( [AudioDevDump](#audiodevdump) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, int32_t range, int32_t fd) | DumpéŸ³é¢‘è®¾å¤‡ä¿¡æ¯ [更多...](#audiodevdump) | + + +## **详细æè¿°** + +AudioControl音频控制接å£ã€‚ + +æ供音频æ’放(render)或录音(capture)需è¦çš„公共控制驱动能力,包括Startã€Stopã€Pauseã€Resumeã€Flushç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### AudioDevDump + + +``` +int32_t(* AudioControl::AudioDevDump) (AudioHandle handle, int32_t range, int32_t fd) +``` + +**æ述:** + +DumpéŸ³é¢‘è®¾å¤‡ä¿¡æ¯ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| range | Dumpä¿¡æ¯èŒƒå›´ï¼Œåˆ†ä¸ºç®€è¦ä¿¡æ¯ã€å…¨é‡ä¿¡æ¯ | +| fd | 指定Dumpç›®æ ‡æ–‡ä»¶ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### Flush + + +``` +int32_t(* AudioControl::Flush) (AudioHandle handle) +``` + +**æ述:** + +刷新音频缓冲区bufferä¸çš„æ•°æ® + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### Pause + + +``` +int32_t(* AudioControl::Pause) (AudioHandle handle) +``` + +**æ述:** + +æš‚åœä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[Resume](#resume) + + +### Resume + + +``` +int32_t(* AudioControl::Resume) (AudioHandle handle) +``` + +**æ述:** + +æ¢å¤ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[Pause](#pause) + + +### Start + + +``` +int32_t(* AudioControl::Start) (AudioHandle handle) +``` + +**æ述:** + +å¯åŠ¨ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[Stop](#stop) + + +### Stop + + +``` +int32_t(* AudioControl::Stop) (AudioHandle handle) +``` + +**æ述:** + +åœæ¢ä¸€ä¸ªéŸ³é¢‘æ’放(render)或录音(captureï¼‰å¤„ç† + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[Start](#start) + + +### TurnStandbyMode + + +``` +int32_t(* AudioControl::TurnStandbyMode) (AudioHandle handle) +``` + +**æ述:** + +è®¾ç½®æˆ–åŽ»è®¾ç½®è®¾å¤‡çš„å¾…æœºæ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | + +**返回:** + +设置设备待机模å¼æˆåŠŸè¿”回值0,å†æ¬¡æ‰§è¡ŒåŽåŽ»è®¾ç½®å¾…机模å¼æˆåŠŸè¿”回æ£å€¼ï¼Œå¤±è´¥è¿”回负值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md new file mode 100644 index 0000000000000000000000000000000000000000..1a4a421f8463c9ce844d987f98c89b4cce8cffe9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_dev_ext_info.md @@ -0,0 +1,25 @@ +# AudioDevExtInfo + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [moduleId](_audio.md#moduleid-12) | 音频æµç»‘定的模å—ID。 | +| [type](_audio.md#type-23) | 音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入),详情å‚考[AudioPortPin](_audio.md#audioportpin)。 | +| [desc](_audio.md#desc-55) | 地å€æ述。 | + + +## **详细æè¿°** + +音频设备拓展信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..5e10acce99f5c951a1daf983a6b01e36fe84b3de --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_device_descriptor.md @@ -0,0 +1,25 @@ +# AudioDeviceDescriptor + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [portId](_audio.md#portid-24) | 频端å£ID。 | +| [pins](_audio.md#pins) | 音频端å£ä¸Šçš„PIN脚(输出ã€è¾“入),详情å‚考[AudioPortPin](_audio.md#audioportpin)。 | +| [desc](_audio.md#desc-15) | 以å—符串命å的音频设备。 | + + +## **详细æè¿°** + +音频场景æ述符。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md b/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md new file mode 100644 index 0000000000000000000000000000000000000000..045023b3ff1ff9db7e0bf85e19d2546fdf4a6fd9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_manager.md @@ -0,0 +1,148 @@ +# AudioManager + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [GetAllAdapters](#getalladapters) )(struct AudioAdapterManager \*manager, struct [AudioAdapterDescriptor](_audio_adapter_descriptor.md) \*\*descs, int \*size) | 获å–音频驱动ä¸æ”¯æŒçš„所有适é…器的列表 [更多...](#getalladapters) | +| ( [LoadAdapter](#loadadapter) )(struct AudioAdapterManager \*manager, const struct [AudioAdapterDescriptor](_audio_adapter_descriptor.md) \*desc, struct [AudioAdapter](_audio_adapter.md) \*\*adapter) | åŠ è½½ä¸€ä¸ªéŸ³é¢‘é€‚é…器(声å¡ï¼‰çš„驱动 [更多...](#loadadapter) | +| ( [UnloadAdapter](#unloadadapter) )(struct AudioAdapterManager \*manager, struct [AudioAdapter](_audio_adapter.md) \*adapter) | å¸è½½éŸ³é¢‘适é…器(声å¡ï¼‰çš„驱动 [更多...](#unloadadapter) | +| ( [ReleaseAudioManagerObject](#releaseaudiomanagerobject) )(struct AudioManager \*object) | 释放音频管ç†æŽ¥å£å¯¹è±¡ [更多...](#releaseaudiomanagerobject) | + + +## **详细æè¿°** + +AudioManager音频适é…器管ç†æŽ¥å£ + +按照音频æœåŠ¡ä¸‹å‘的音频适é…器(声å¡ï¼‰æè¿°ç¬¦åŠ è½½ä¸€ä¸ªå…·ä½“çš„éŸ³é¢‘é€‚é…å™¨é©±åŠ¨ç¨‹åº + +å‚è§ï¼š + +[AudioAdapter](_audio_adapter.md) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### GetAllAdapters + + +``` +int(* AudioManager::GetAllAdapters) (struct AudioAdapterManager *manager, struct AudioAdapterDescriptor **descs, int *size) +``` + +**æ述:** + +获å–音频驱动ä¸æ”¯æŒçš„所有适é…器的列表 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| manager | å¾…æ“作的音频管ç†æŽ¥å£å¯¹è±¡ | +| descs | 获å–到的音频适é…器列表ä¿å˜åˆ°descsä¸ | +| size | 获å–到的音频适é…器列表的长度ä¿å˜åˆ°sizeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[LoadAdapter](#loadadapter) + + +### LoadAdapter + + +``` +int(* AudioManager::LoadAdapter) (struct AudioAdapterManager *manager, const struct AudioAdapterDescriptor *desc, struct AudioAdapter **adapter) +``` + +**æ述:** + +åŠ è½½ä¸€ä¸ªéŸ³é¢‘é€‚é…器(声å¡ï¼‰çš„驱动 + +åŠ è½½ä¸€ä¸ªå…·ä½“çš„éŸ³é¢‘é©±åŠ¨ï¼Œä¾‹å¦‚usb驱动,在具体实现ä¸å¯èƒ½åŠ 载的是一个动æ€é“¾æŽ¥åº“(\*.so) + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| manager | å¾…æ“作的音频管ç†æŽ¥å£å¯¹è±¡ | +| desc | å¾…åŠ è½½çš„éŸ³é¢‘é€‚é…器æ述符 | +| adapter | 获å–的音频适é…器接å£çš„对象实例ä¿å˜åˆ°adapterä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetAllAdapters](#getalladapters) + +[UnloadAdapter](#unloadadapter) + + +### ReleaseAudioManagerObject + + +``` +bool(* AudioManager::ReleaseAudioManagerObject) (struct AudioManager *object) +``` + +**æ述:** + +释放音频管ç†æŽ¥å£å¯¹è±¡ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| object | å¾…æ“作的音频管ç†æŽ¥å£å¯¹è±¡ | + +**返回:** + +æˆåŠŸè¿”回ture,失败返回false + + +### UnloadAdapter + + +``` +void(* AudioManager::UnloadAdapter) (struct AudioAdapterManager *manager, struct AudioAdapter *adapter) +``` + +**æ述:** + +å¸è½½éŸ³é¢‘适é…器(声å¡ï¼‰çš„驱动 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| manager | å¾…æ“作的音频管ç†æŽ¥å£å¯¹è±¡ | +| adapter | å¾…å¸è½½çš„音频适é…器接å£çš„对象 | + +**å‚è§ï¼š** + +[LoadAdapter](#loadadapter) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md new file mode 100644 index 0000000000000000000000000000000000000000..fcf31a50003dfd54672b80acc06b907f1f80295b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_mix_ext_info.md @@ -0,0 +1,24 @@ +# AudioMixExtInfo + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [moduleId](_audio.md#moduleid-22) | æµæ‰€å±žæ¨¡å—æ ‡è¯†ç¬¦ã€‚ | +| [streamId](_audio.md#streamid-22) | ç”±è°ƒç”¨è€…ä¼ é€’çš„Render或Captureæ ‡è¯†ç¬¦ã€‚ | + + +## **详细æè¿°** + +音轨拓展信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md b/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md new file mode 100644 index 0000000000000000000000000000000000000000..cd301a7d69f96715c46423c1ed984d7b59b17173 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_mmap_buffer_descripter.md @@ -0,0 +1,27 @@ +# AudioMmapBufferDescripter + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [memoryAddress](_audio.md#memoryaddress) | 指å‘mmap缓冲区的指针。 | +| [memoryFd](_audio.md#memoryfd) | mmap缓冲区的文件æ述符。 | +| [totalBufferFrames](_audio.md#totalbufferframes) | 缓冲区总大å°ï¼Œå•ä½ï¼šå¸§ã€‚ | +| [transferFrameSize](_audio.md#transferframesize) | ä¼ è¾“å¤§å°ï¼Œå•ä½ï¼šå¸§ã€‚ | +| [isShareable](_audio.md#isshareable) | mmap缓冲区是å¦å¯ä»¥åœ¨è¿›ç¨‹é—´å…±äº«ã€‚ | + + +## **详细æè¿°** + +mmap缓冲区æ述符。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port.md new file mode 100644 index 0000000000000000000000000000000000000000..5ad207379d352367e346ca39e607789e4d38207a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_port.md @@ -0,0 +1,25 @@ +# AudioPort + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [dir](_audio.md#dir) | 音频端å£çš„类型,详情å‚考[AudioPortDirection](_audio.md#audioportdirection)。 | +| [portId](_audio.md#portid-14) | 音频端å£çš„ID。 | +| [portName](_audio.md#portname) | 音频端å£çš„å称。 | + + +## **详细æè¿°** + +音频端å£ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md new file mode 100644 index 0000000000000000000000000000000000000000..6545ac35c4833ef5e247a78a03361ce016574928 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_port_cap.md @@ -0,0 +1,77 @@ +# AudioPortCap + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [sampleFormats](#sampleformats) [[SAMPLE_FMT_NUM](_codec.md#ga9bda75c363e9bcff915cdd521dd7ba84)] | 支æŒçš„éŸ³é¢‘é‡‡æ ·æ ¼å¼ï¼Œè¯¦è§[AudioSampleFormat](_codec.md#audiosampleformat)。 | +| [sampleRate](#samplerate) [[SAMPLE_RATE_NUM](_codec.md#ga0d905eaa05b4b6fcec76924eb795d7fe)] | 支æŒçš„éŸ³é¢‘é‡‡æ ·çŽ‡ï¼Œè¯¦è§[AudioSampleRate](_codec.md#audiosamplerate)。 | +| [channelLayouts](#channellayouts) [[CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1)] | 支æŒçš„音频通é“æ•°channel layouts。 | +| [channelCount](#channelcount) [[CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1)] | 支æŒçš„音频通é“数。 | + + +## **详细æè¿°** + +定义音频编解ç 能力。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### channelCount + + +``` +int32_t AudioPortCap::channelCount[CHANNEL_NUM] +``` + +**æ述:** + +支æŒçš„音频通é“æ•° + + +### channelLayouts + + +``` +int32_t AudioPortCap::channelLayouts[CHANNEL_NUM] +``` + +**æ述:** + +支æŒçš„音频通é“æ•°channel layouts + + +### sampleFormats + + +``` +int32_t AudioPortCap::sampleFormats[SAMPLE_FMT_NUM] +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘é‡‡æ ·æ ¼å¼ï¼Œè¯¦è§[AudioSampleFormat](_codec.md#audiosampleformat) + + +### sampleRate + + +``` +int32_t AudioPortCap::sampleRate[SAMPLE_RATE_NUM] +``` + +**æ述:** + +支æŒçš„éŸ³é¢‘é‡‡æ ·çŽ‡ï¼Œè¯¦è§[AudioSampleRate](_codec.md#audiosamplerate) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md b/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md new file mode 100644 index 0000000000000000000000000000000000000000..4fbfb7c94e6286adf5b6d23a34f2d2ecd0d239f9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_port_capability.md @@ -0,0 +1,34 @@ +# AudioPortCapability + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [deviceType](_audio.md#devicetype) | 设备输出ã€è¾“入类型。 | +| [deviceId](_audio.md#deviceid) | 绑定(bind)设备ID,唯一的设备识别符。 | +| [hardwareMode](_audio.md#hardwaremode) | 是å¦æ”¯æŒè®¾å¤‡ç»‘定处ç†ã€‚ | +| [formatNum](_audio.md#formatnum) | 支æŒçš„éŸ³é¢‘æ ¼å¼æ•°ç›®ã€‚ | +| [formats](_audio.md#formats) | 支æŒçš„éŸ³é¢‘æ ¼å¼ï¼Œè¯¦æƒ…å‚考[AudioFormat](_audio.md#audioformat)。 | +| [sampleRateMasks](_audio.md#sampleratemasks) | 支æŒçš„éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ï¼ˆ8kã€16kã€32kã€48k)。 | +| [channelMasks](_audio.md#channelmasks) | 设备的声é“布局掩ç (mask),详情å‚考[AudioChannelMask](_audio.md#audiochannelmask)。 | +| [channelCount](_audio.md#channelcount-22) | 支æŒçš„最大声é“总数。 | +| [subPortsNum](_audio.md#subportsnum) | 支æŒçš„å端å£æ•°ç›®ï¼ˆä»…用于输出设备)。 | +| [subPorts](_audio.md#subports) | 支æŒçš„å端å£åˆ—表。 | +| [supportSampleFormatNum](_audio.md#supportsampleformatnum) | 支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼æ•°é‡ã€‚ | +| [supportSampleFormats](_audio.md#supportsampleformats) | 支æŒçš„éŸ³é¢‘æ ·æœ¬æ ¼å¼ï¼Œè¯¦è¯·å‚考[AudioSampleFormat](_audio.md#audiosampleformat)。 | + + +## **详细æè¿°** + +音频端å£çš„支æŒèƒ½åŠ›ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_render.md b/zh-cn/device-dev/reference/hdi-apis/_audio_render.md new file mode 100644 index 0000000000000000000000000000000000000000..8f2fbb7f23b9011a2a2c0949356cafd80e58c7c0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_render.md @@ -0,0 +1,297 @@ +# AudioRender + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| control | 音频控制能力接å£ï¼Œè¯¦æƒ…å‚考[AudioControl](_audio_control.md) | +| attr | 音频属性能力接å£ï¼Œè¯¦æƒ…å‚考[AudioAttribute](_audio_attribute.md) | +| scene | 音频场景能力接å£ï¼Œè¯¦æƒ…å‚考[AudioScene](_audio_scene.md) | +| volume | 音频音é‡èƒ½åŠ›æŽ¥å£ï¼Œè¯¦æƒ…å‚考[AudioVolume](_audio_volume.md) | +| ( [GetLatency](#getlatency) )(struct AudioRender \*render, uint32_t \*ms) | 获å–音频硬件驱动估计的延迟时间 [更多...](#getlatency) | +| ( [RenderFrame](#renderframe) )(struct AudioRender \*render, const void \*frame, uint64_t requestBytes, uint64_t \*replyBytes) | 往音频驱动ä¸æ’放(render)一帧输出数æ®ï¼ˆæ”¾éŸ³ï¼ŒéŸ³é¢‘下行数æ®ï¼‰ [更多...](#renderframe) | +| ( [GetRenderPosition](#getrenderposition) )(struct AudioRender \*render, uint64_t \*frames, struct [AudioTimeStamp](_audio_time_stamp.md) \*time) | 获å–音频输出帧数的上一次计数 [更多...](#getrenderposition) | +| ( [SetRenderSpeed](#setrenderspeed) )(struct AudioRender \*render, float speed) | 设置一个音频的æ’放速度 [更多...](#setrenderspeed) | +| ( [GetRenderSpeed](#getrenderspeed) )(struct AudioRender \*render, float \*speed) | 获å–一个音频当å‰çš„æ’放速度 [更多...](#getrenderspeed) | +| ( [SetChannelMode](#setchannelmode) )(struct AudioRender \*render, enum [AudioChannelMode](_audio.md#audiochannelmode) mode) | 设置音频æ’放的通é“æ¨¡å¼ [更多...](#setchannelmode) | +| ( [GetChannelMode](#getchannelmode) )(struct AudioRender \*render, enum [AudioChannelMode](_audio.md#audiochannelmode) \*mode) | 获å–音频æ’放当å‰çš„通é“æ¨¡å¼ [更多...](#getchannelmode) | +| ( [RegCallback](#regcallback) )(struct AudioRender \*render, [RenderCallback](_audio.md#rendercallback) callback, void \*cookie) | 注册音频回调函数,用于放音过程ä¸ç¼“冲区数æ®å†™ã€DrainBuffer完æˆé€šçŸ¥ [更多...](#regcallback) | +| ( [DrainBuffer](#drainbuffer) )(struct AudioRender \*render, enum [AudioDrainNotifyType](_audio.md#audiodrainnotifytype) \*type) | 排空缓冲区ä¸çš„æ•°æ® [更多...](#drainbuffer) | + + +## **详细æè¿°** + +AudioRender音频æ’æ”¾æŽ¥å£ + +æ供音频æ’放支æŒçš„驱动能力,包括音频控制ã€éŸ³é¢‘属性ã€éŸ³é¢‘场景ã€éŸ³é¢‘音é‡ã€èŽ·å–硬件延迟时间ã€æ’放音频帧数æ®ï¼ˆrender frameï¼‰ç‰ + +**å‚è§ï¼š** + +[AudioControl](_audio_control.md) + +[AudioAttribute](_audio_attribute.md) + +[AudioScene](_audio_scene.md) + +[AudioVolume](_audio_volume.md) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### DrainBuffer + + +``` +int32_t(* AudioRender::DrainBuffer) (struct AudioRender *render, enum AudioDrainNotifyType *type) +``` + +**æ述:** + +排空缓冲区ä¸çš„æ•°æ® + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| type | DrainBufferçš„æ“作类型,详情请å‚考[AudioDrainNotifyType](_audio.md#audiodrainnotifytype) | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[RegCallback](#regcallback) + + +### GetChannelMode + + +``` +int32_t(* AudioRender::GetChannelMode) (struct AudioRender *render, enum AudioChannelMode *mode) +``` + +**æ述:** + +获å–音频æ’放当å‰çš„通é“æ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| mode | 获å–的通é“模å¼ä¿å˜åˆ°modeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetChannelMode](#setchannelmode) + + +### GetLatency + + +``` +int32_t(* AudioRender::GetLatency) (struct AudioRender *render, uint32_t *ms) +``` + +**æ述:** + +获å–音频硬件驱动估计的延迟时间 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| ms | 获å–的延迟时间(å•ä½ï¼šæ¯«ç§’)ä¿å˜åˆ°msä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### GetRenderPosition + + +``` +int32_t(* AudioRender::GetRenderPosition) (struct AudioRender *render, uint64_t *frames, struct AudioTimeStamp *time) +``` + +**æ述:** + +获å–音频输出帧数的上一次计数 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| frames | 获å–的音频帧计数ä¿å˜åˆ°framesä¸ | +| time | 获å–çš„å…³è”时间戳ä¿å˜åˆ°timeä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[RenderFrame](#renderframe) + + +### GetRenderSpeed + + +``` +int32_t(* AudioRender::GetRenderSpeed) (struct AudioRender *render, float *speed) +``` + +**æ述:** + +获å–一个音频当å‰çš„æ’放速度 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| speed | 获å–çš„æ’放速度ä¿å˜åˆ°speedä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetRenderSpeed](#setrenderspeed) + + +### RegCallback + + +``` +int32_t(* AudioRender::RegCallback) (struct AudioRender *render, RenderCallback callback, void *cookie) +``` + +**æ述:** + +注册音频回调函数,用于放音过程ä¸ç¼“冲区数æ®å†™ã€DrainBuffer完æˆé€šçŸ¥ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| callback | 注册的回调函数 | +| cookie | å›žè°ƒå‡½æ•°çš„å…¥å‚ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[RegCallback](#regcallback) + + +### RenderFrame + + +``` +int32_t(* AudioRender::RenderFrame) (struct AudioRender *render, const void *frame, uint64_t requestBytes, uint64_t *replyBytes) +``` + +**æ述:** + +往音频驱动ä¸æ’放(render)一帧输出数æ®ï¼ˆæ”¾éŸ³ï¼ŒéŸ³é¢‘下行数æ®ï¼‰ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| frame | 待写入的输出数æ®çš„音频frame | +| requestBytes | 待写入的输出数æ®çš„音频frame大å°ï¼ˆå—节数) | +| replyBytes | 实际写入的音频数æ®é•¿åº¦ï¼ˆå—节数),获å–åŽä¿å˜åˆ°replyBytesä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + + +### SetChannelMode + + +``` +int32_t(* AudioRender::SetChannelMode) (struct AudioRender *render, enum AudioChannelMode mode) +``` + +**æ述:** + +设置音频æ’放的通é“æ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| speed | 待设置的通é“æ¨¡å¼ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetChannelMode](#getchannelmode) + + +### SetRenderSpeed + + +``` +int32_t(* AudioRender::SetRenderSpeed) (struct AudioRender *render, float speed) +``` + +**æ述:** + +设置一个音频的æ’放速度 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| render | å¾…æ“作的音频æ’放接å£å¯¹è±¡ | +| speed | 待设置的æ’放速度 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetRenderSpeed](#getrenderspeed) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_route.md b/zh-cn/device-dev/reference/hdi-apis/_audio_route.md new file mode 100644 index 0000000000000000000000000000000000000000..d4db5ceddec9bf88fbeb75fa15f6c1a61dc57ac5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_route.md @@ -0,0 +1,26 @@ +# AudioRoute + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [sourcesNum](_audio.md#sourcesnum) | å‘é€ç«¯èŠ‚点数é‡ã€‚ | +| [sources](_audio.md#sources) | å‘é€ç«¯åˆ—表。 | +| [sinksNum](_audio.md#sinksnum) | 接å—端节点数é‡ã€‚ | +| [sinks](_audio.md#sinks) | 接å—端列表。 | + + +## **详细æè¿°** + +音频路由信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md b/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md new file mode 100644 index 0000000000000000000000000000000000000000..2686ecf9b5d43ab44660185531ecc550aca6cc71 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_route_node.md @@ -0,0 +1,28 @@ +# AudioRouteNode + + +## **è¿°** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [portId](_audio.md#portid-44) | 音频端å£ID。 | +| [role](_audio.md#role) | 指定端å£è§’色为sink或source。 | +| [type](_audio.md#type-33) | 指定端å£ç±»åž‹ã€‚ | +| [device](_audio.md#device) | 设备特定信æ¯ã€‚ | +| [mix](_audio.md#mix) | 音轨特定信æ¯ã€‚ | +| [session](_audio.md#session) | 会è¯ç‰¹å®šä¿¡æ¯ã€‚ | + + +## **详细æè¿°** + +音频路由节点。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md b/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md new file mode 100644 index 0000000000000000000000000000000000000000..8b2c871f1cf272d6f90fbc43ce08b37e108da7f3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_sample_attributes.md @@ -0,0 +1,35 @@ +# AudioSampleAttributes + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [type](_audio.md#type-13) | 音频类型,详情å‚考[AudioCategory](_audio.md#audiocategory)。 | +| [interleaved](_audio.md#interleaved) | 音频数æ®äº¤ç»‡çš„æ ‡è®°ã€‚ | +| [format](_audio.md#format) | 音频数æ®æ ¼å¼ï¼Œè¯¦æƒ…å‚考[AudioFormat](_audio.md#audioformat)。 | +| [sampleRate](_audio.md#samplerate) | éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡ã€‚ | +| [channelCount](_audio.md#channelcount-12) | 音频通é“数目,如å•é€šé“(mono)为1ã€ç«‹ä½“声(stereo)为2。 | +| [period](_audio.md#period) | éŸ³é¢‘é‡‡æ ·å‘¨æœŸã€‚ | +| [frameSize](_audio.md#framesize) | 音频数æ®çš„帧大å°ã€‚ | +| [isBigEndian](_audio.md#isbigendian) | 音频数æ®çš„å¤§ç«¯æ ‡å¿—ã€‚ | +| [isSignedData](_audio.md#issigneddata) | 音频数æ®çš„有符å·æˆ–æ— ç¬¦å·æ ‡å¿—。 | +| [startThreshold](_audio.md#startthreshold) | 音频渲染开始阈值。 | +| [stopThreshold](_audio.md#stopthreshold) | 音频渲染åœæ¢é˜ˆå€¼ã€‚ | +| [silenceThreshold](_audio.md#silencethreshold) | 音频æ•èŽ·ç¼“冲区阈值。 | +| [streamId](_audio.md#streamid-12) | 渲染或æ•èŽ·çš„éŸ³é¢‘æ ‡è¯†ç¬¦ã€‚ | + + +## **详细æè¿°** + +éŸ³é¢‘é‡‡æ ·å±žæ€§ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md b/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md new file mode 100644 index 0000000000000000000000000000000000000000..520381a9b410129142f620ecb394f8fa2183ce94 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_scene.md @@ -0,0 +1,100 @@ +# AudioScene + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [CheckSceneCapability](#checkscenecapability) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSceneDescriptor](_audio_scene_descriptor.md) \*scene, bool \*supported) | 是å¦æ”¯æŒæŸä¸ªéŸ³é¢‘场景的é…ç½® [更多...](#checkscenecapability) | +| ( [SelectScene](#selectscene) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSceneDescriptor](_audio_scene_descriptor.md) \*scene) | 选择音频场景 [更多...](#selectscene) | + + +## **详细æè¿°** + +AudioScene音频场景接å£ã€‚ + +æ供音频æ’放(render)或录音(capture)需è¦çš„公共场景驱动能力,包括选择音频场景ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CheckSceneCapability + + +``` +int32_t(* AudioScene::CheckSceneCapability) (AudioHandle handle, const struct AudioSceneDescriptor *scene, bool *supported) +``` + +**æ述:** + +是å¦æ”¯æŒæŸä¸ªéŸ³é¢‘场景的é…ç½® + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| scene | 待获å–的音频场景æ述符 | +| supported | 是å¦æ”¯æŒçš„状æ€ä¿å˜åˆ°supportedä¸ï¼Œtrue表示支æŒï¼Œfalse表示ä¸æ”¯æŒ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SelectScene](#selectscene) + + +### SelectScene + + +``` +int32_t(* AudioScene::SelectScene) (AudioHandle handle, const struct AudioSceneDescriptor *scene) +``` + +**æ述:** + +选择音频场景 + +- 1. 选择一个éžå¸¸å…·ä½“的音频场景(应用场景和输出设备的组åˆï¼‰ï¼Œä¾‹å¦‚åŒæ ·æ˜¯ä½¿ç”¨æ‰‹æœºä¸çš„å–‡å作为输出设备 + - 在媒体æ’放场景scene为media_speaker + - 在è¯éŸ³é€šè¯å…æ场景scene为voice_speaker + +- 2. åªæ˜¯é€‰æ‹©ä¸€ä¸ªéŸ³é¢‘场景,例如使用场景为媒体æ’放(media)ã€ç”µå½±æ’放(movie)ã€æ¸¸æˆæ’放(game) + +- 3. åªæ˜¯é€‰æ‹©ä¸€ä¸ªéŸ³é¢‘输出设备,例如输出设备为å¬ç’(receiver)ã€å–‡å(speaker)ã€æœ‰çº¿è€³æœºï¼ˆheadset) + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| scene | 待设置的音频场景æ述符 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[CheckSceneCapability](#checkscenecapability) diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md b/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..624073d4aec715fb57f5695527a5d8cd662c5d05 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_scene_descriptor.md @@ -0,0 +1,30 @@ +# AudioSceneDescriptor + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景æè¿° [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [scene](_audio.md#scene) | 音频场景的å称。 | +| [desc](_audio.md#desc-25) | 音频设备æ述符。 | + + +## **详细æè¿°** + +音频场景æ述符。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md b/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md new file mode 100644 index 0000000000000000000000000000000000000000..d48ad307922f7be094c3e4492497e7564a9a70e3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_session_ext_info.md @@ -0,0 +1,23 @@ +# AudioSessionExtInfo + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [sessionType](_audio.md#sessiontype) | 音频会è¯ç±»åž‹ã€‚ | + + +## **详细æè¿°** + +会è¯æ‹“展信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md b/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md new file mode 100644 index 0000000000000000000000000000000000000000..1bc223b1d5f70bb6b1725cf4d184216cc1c93e3f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_sub_port_capability.md @@ -0,0 +1,25 @@ +# AudioSubPortCapability + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [portId](_audio.md#portid-34) | å端å£ID。 | +| [desc](_audio.md#desc-45) | 以å—符串命åçš„å端å£ã€‚ | +| [mask](_audio.md#mask) | æ•°æ®é€ä¼ 模å¼ï¼Œè¯¦æƒ…å‚考[AudioPortPassthroughMode](_audio.md#audioportpassthroughmode)。 | + + +## **详细æè¿°** + +音频å端å£çš„支æŒèƒ½åŠ›ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md b/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md new file mode 100644 index 0000000000000000000000000000000000000000..ec53fdefc97c8e41d22e4b68f00796577b63b74e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_time_stamp.md @@ -0,0 +1,26 @@ +# AudioTimeStamp + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [tvSec](_audio.md#tvsec) | tvSec时间,å•ä½ï¼šç§’。 | +| [tvNSec](_audio.md#tvnsec) | tvNSec时间,å•ä½ï¼šçº³ç§’。 | + + +## **详细æè¿°** + +音频时间戳。 + +时间定义,POSIX timespec的替代å“。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md b/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md new file mode 100644 index 0000000000000000000000000000000000000000..2766ba7eb2bb60cb95e4281799707f2ceb81abd1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_audio_volume.md @@ -0,0 +1,242 @@ +# AudioVolume + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [SetMute](#setmute) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool mute) | 设置音频的é™éŸ³çŠ¶æ€ [更多...](#setmute) | +| ( [GetMute](#getmute) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool \*mute) | 获å–音频的é™éŸ³çŠ¶æ€ [更多...](#getmute) | +| ( [SetVolume](#setvolume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float volume) | 设置一个音频æµçš„éŸ³é‡ [更多...](#setvolume) | +| ( [GetVolume](#getvolume) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*volume) | 获å–一个音频æµçš„éŸ³é‡ [更多...](#getvolume) | +| ( [GetGainThreshold](#getgainthreshold) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*min, float \*max) | 获å–音频æµå¢žç›Šçš„阈值 [更多...](#getgainthreshold) | +| ( [GetGain](#getgain) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float \*gain) | 获å–音频æµçš„增益 [更多...](#getgain) | +| ( [SetGain](#setgain) )([AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float gain) | 设置音频æµçš„增益 [更多...](#setgain) | + + +## **详细æè¿°** + +AudioVolume音频音é‡æŽ¥å£ã€‚ + +æ供音频æ’放(render)或录音(capture)需è¦çš„公共音é‡é©±åŠ¨èƒ½åŠ›ï¼ŒåŒ…括é™éŸ³æ“作ã€è®¾ç½®éŸ³é‡ã€è®¾ç½®å¢žç›Šç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### GetGain + + +``` +int32_t(* AudioVolume::GetGain) (AudioHandle handle, float *gain) +``` + +**æ述:** + +获å–音频æµçš„增益 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| gain | ä¿å˜å½“å‰èŽ·å–到的增益到gainä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetGainThreshold](#getgainthreshold) + +[SetGain](#setgain) + + +### GetGainThreshold + + +``` +int32_t(* AudioVolume::GetGainThreshold) (AudioHandle handle, float *min, float *max) +``` + +**æ述:** + +获å–音频æµå¢žç›Šçš„阈值 + +在具体的功能实现ä¸ï¼Œå¯ä»¥æ ¹æ®èŠ¯ç‰‡å¹³å°çš„实际情况æ¥è¿›è¡Œå¤„ç†ï¼š + +- 1. å¯ä»¥ä½¿ç”¨å®žé™…的增益值,例如增益的范围为-50db ~ 6db + +- 2. 也å¯ä»¥å°†å¢žç›ŠèŒƒå›´è®¾å®šä¸º0.0~1.0,如果增益的范围为-50db ~ 6db, åˆ™å¢žç›Šçš„æ˜ å°„å…³ç³»ä¸º0.0表示é™éŸ³ï¼Œ1.0表示最大增益(6db) + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| min | 获å–的音频增益的阈值下é™ä¿å˜åˆ°minä¸ | +| max | 获å–的音频增益的阈值上é™ä¿å˜åˆ°maxä¸ | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetGain](#getgain) + +[SetGain](#setgain) + + +### GetMute + + +``` +int32_t(* AudioVolume::GetMute) (AudioHandle handle, bool *mute) +``` + +**æ述:** + +获å–音频的é™éŸ³çŠ¶æ€ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| mute | 获å–çš„é™éŸ³çŠ¶æ€ä¿å˜åˆ°muteä¸ï¼Œtrue表示é™éŸ³æ“作ã€false表示å–消é™éŸ³æ“作 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetMute](#setmute) + + +### GetVolume + + +``` +int32_t(* AudioVolume::GetVolume) (AudioHandle handle, float *volume) +``` + +**æ述:** + +获å–一个音频æµçš„éŸ³é‡ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| volume | 获å–的音é‡ä¿å˜åˆ°volumeä¸ï¼ŒèŒƒå›´0.0~1.0 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[SetVolume](#setvolume) + + +### SetGain + + +``` +int32_t(* AudioVolume::SetGain) (AudioHandle handle, float gain) +``` + +**æ述:** + +设置音频æµçš„增益 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| gain | gain 待设置的增益 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetGainThreshold](#getgainthreshold) + +[GetGain](#getgain) + + +### SetMute + + +``` +int32_t(* AudioVolume::SetMute) (AudioHandle handle, bool mute) +``` + +**æ述:** + +设置音频的é™éŸ³çŠ¶æ€ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| mute | 待设置的é™éŸ³çŠ¶æ€ï¼Œtrue表示é™éŸ³æ“作ã€false表示å–消é™éŸ³æ“作 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 + +**å‚è§ï¼š** + +[GetMute](#getmute) + + +### SetVolume + + +``` +int32_t(* AudioVolume::SetVolume) (AudioHandle handle, float volume) +``` + +**æ述:** + +设置一个音频æµçš„音é‡ã€‚ + +音é‡çš„å–值范围是0.0~1.0,如果音频æœåŠ¡ä¸çš„音é‡ç‰çº§ä¸º15级(0 ~ 15), 则音é‡çš„æ˜ å°„å…³ç³»ä¸º0.0表示é™éŸ³ï¼Œ1.0表示最大音é‡ç‰çº§ï¼ˆ15) + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | å¾…æ“作的音频å¥æŸ„ | +| volume | 待设置的音é‡ï¼ŒèŒƒå›´0.0~1.0 | + +**返回:** + +æˆåŠŸè¿”回值0,失败返回负值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md b/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md new file mode 100644 index 0000000000000000000000000000000000000000..3f269e41cebe579b6dd22d6ea14b78eb7f3128de --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_auth_result_info.md @@ -0,0 +1,111 @@ +# AuthResultInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [result](#result) | 用户身份认è¯ç»“果。 | +| [freezingTime](#freezingtime) | 认è¯æ–¹å¼è¢«å†»ç»“的时间。 | +| [remainTimes](#remaintimes) | 认è¯æ–¹å¼è·ç¦»è¢«å†»ç»“çš„å¯å¤„ç†è®¤è¯è¯·æ±‚次数。 | +| [msgs](#msgs) | 执行器å‘é€çš„消æ¯ã€‚ | +| [token](#token) | 用户身份认è¯ä»¤ç‰Œã€‚ | +| rootSecret | ä¿æŠ¤æ–‡ä»¶åŠ 密密钥的密钥。 | + + +## **详细æè¿°** + +用户身份认è¯ç»“果信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### freezingTime + + +``` +int AuthResultInfo::freezingTime +``` + +**æ述:** + +认è¯æ–¹å¼è¢«å†»ç»“的时间。 + + +### msgs + + +``` +struct ExecutorSendMsg [] AuthResultInfo::msgs +``` + +**æ述:** + +执行器å‘é€çš„消æ¯ã€‚ + + +### remainTimes + + +``` +int AuthResultInfo::remainTimes +``` + +**æ述:** + +认è¯æ–¹å¼è·ç¦»è¢«å†»ç»“çš„å¯å¤„ç†è®¤è¯è¯·æ±‚次数。 + + +### result + + +``` +unsigned int AuthResultInfo::result +``` + +**æ述:** + +用户身份认è¯ç»“果。 + + +### token + + +``` +unsigned char [] AuthResultInfo::token +``` + +**æ述:** + +用户身份认è¯ä»¤ç‰Œã€‚ + + +### rootSecret + + +``` +unsigned char [] AuthResultInfo::rootSecret +``` + +**æ述:** + +ä¿æŠ¤æ–‡ä»¶åŠ 密密钥的密钥。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md b/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md new file mode 100644 index 0000000000000000000000000000000000000000..8a43490939301ffa64c3dc9b11ce588041ee6e69 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_auth_solution.md @@ -0,0 +1,98 @@ +# AuthSolution + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [userId](#userid) | 用户ID。 | +| [authTrustLevel](#authtrustlevel) | 认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹AuthType}。 | +| [executorSensorHint](#executorsensorhint) | 既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ | +| [challenge](#challenge) | 挑战值,用于ç¾å‘认è¯ä»¤ç‰Œã€‚ | + + +## **详细æè¿°** + +认è¯æ–¹æ¡ˆã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authTrustLevel + + +``` +unsigned int AuthSolution::authTrustLevel +``` + +**æ述:** + +认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ + + +### authType + + +``` +enum AuthType AuthSolution::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹AuthType}。 + + +### challenge + + +``` +unsigned char [] AuthSolution::challenge +``` + +**æ述:** + +挑战值,用于ç¾å‘认è¯ä»¤ç‰Œã€‚ + + +### executorSensorHint + + +``` +unsigned int AuthSolution::executorSensorHint +``` + +**æ述:** + +既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ + + +### userId + + +``` +int AuthSolution::userId +``` + +**æ述:** + +用户ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_battery_info.md b/zh-cn/device-dev/reference/hdi-apis/_battery_info.md new file mode 100644 index 0000000000000000000000000000000000000000..8373d179faf623504f0e9deee42a05dd4be0ca68 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_battery_info.md @@ -0,0 +1,224 @@ +# BatteryInfo + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [capacity](#capacity) | è¡¨ç¤ºç”µæ± çš„ç”µé‡ç™¾åˆ†æ¯”。 | +| [voltage](#voltage) | è¡¨ç¤ºç”µæ± çš„ç”µåŽ‹ã€‚ | +| [temperature](#temperature) | è¡¨ç¤ºç”µæ± çš„æ¸©åº¦ | +| [healthState](#healthstate) | è¡¨ç¤ºç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ | +| [pluggedType](#pluggedtype) | è¡¨ç¤ºç”µæ± çš„å……ç”µè®¾å¤‡ç±»åž‹ã€‚ | +| [pluggedMaxCurrent](#pluggedmaxcurrent) | è¡¨ç¤ºç”µæ± çš„æœ€å¤§å……ç”µç”µæµã€‚ | +| [pluggedMaxVoltage](#pluggedmaxvoltage) | è¡¨ç¤ºç”µæ± çš„æœ€å¤§å……ç”µç”µåŽ‹ã€‚ | +| [chargeState](#chargestate) | è¡¨ç¤ºç”µæ± çš„å……ç”µçŠ¶æ€ã€‚ | +| [chargeCounter](#chargecounter) | è¡¨ç¤ºç”µæ± çš„å……ç”µæ¬¡æ•°ã€‚ | +| [totalEnergy](#totalenergy) | è¡¨ç¤ºç”µæ± çš„æ€»å®¹é‡ã€‚ | +| [curAverage](#curaverage) | è¡¨ç¤ºç”µæ± çš„å¹³å‡ç”µæµã€‚ | +| [curNow](#curnow) | è¡¨ç¤ºç”µæ± çš„å®žæ—¶ç”µæµã€‚ | +| [remainEnergy](#remainenergy) | è¡¨ç¤ºç”µæ± çš„å‰©ä½™å®¹é‡ã€‚ | +| [present](#present) | 表示是å¦æ”¯æŒç”µæ± æˆ–è€…ç”µæ± æ˜¯å¦åœ¨ä½ã€‚ | +| [technology](#technology) | è¡¨ç¤ºç”µæ± çš„æŠ€æœ¯åž‹å·ã€‚ | + + +## **详细æè¿°** + +ç”µæ± ç›¸å…³ä¿¡æ¯ã€‚ + +**Since:** + +3.1 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### capacity + + +``` +int BatteryInfo::capacity +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„ç”µé‡ç™¾åˆ†æ¯”。 + + +### chargeCounter + + +``` +int BatteryInfo::chargeCounter +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å……ç”µæ¬¡æ•°ã€‚ + + +### chargeState + + +``` +int BatteryInfo::chargeState +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å……ç”µçŠ¶æ€ã€‚ + + +### curAverage + + +``` +int BatteryInfo::curAverage +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å¹³å‡ç”µæµã€‚ + + +### curNow + + +``` +int BatteryInfo::curNow +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å®žæ—¶ç”µæµã€‚ + + +### healthState + + +``` +int BatteryInfo::healthState +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ + + +### pluggedMaxCurrent + + +``` +int BatteryInfo::pluggedMaxCurrent +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„æœ€å¤§å……ç”µç”µæµã€‚ + + +### pluggedMaxVoltage + + +``` +int BatteryInfo::pluggedMaxVoltage +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„æœ€å¤§å……ç”µç”µåŽ‹ã€‚ + + +### pluggedType + + +``` +int BatteryInfo::pluggedType +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å……ç”µè®¾å¤‡ç±»åž‹ã€‚ + + +### present + + +``` +byte BatteryInfo::present +``` + +**æ述:** + +表示是å¦æ”¯æŒç”µæ± æˆ–è€…ç”µæ± æ˜¯å¦åœ¨ä½ã€‚ + + +### remainEnergy + + +``` +int BatteryInfo::remainEnergy +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„å‰©ä½™å®¹é‡ã€‚ + + +### technology + + +``` +String BatteryInfo::technology +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„æŠ€æœ¯åž‹å·ã€‚ + + +### temperature + + +``` +int BatteryInfo::temperature +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„æ¸©åº¦ + + +### totalEnergy + + +``` +int BatteryInfo::totalEnergy +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„æ€»å®¹é‡ã€‚ + + +### voltage + + +``` +int BatteryInfo::voltage +``` + +**æ述:** + +è¡¨ç¤ºç”µæ± çš„ç”µåŽ‹ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md b/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md new file mode 100644 index 0000000000000000000000000000000000000000..667b9b2a71c852b359534877e1f4c7294afa1137 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_buffer_data.md @@ -0,0 +1,24 @@ +# BufferData + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [phyAddr](_display.md#phyaddr-12) | 物ç†å†…å˜åœ°å€ã€‚ | +| [virAddr](_display.md#viraddr) | 虚拟内å˜åœ°å€ã€‚ | + + +## **详细æè¿°** + +定义一层的缓冲区数æ®ï¼ŒåŒ…括虚拟和物ç†å†…å˜åœ°å€ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_camera.md b/zh-cn/device-dev/reference/hdi-apis/_camera.md new file mode 100644 index 0000000000000000000000000000000000000000..066935359619d140db859247ec934dc16ac93ad6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_camera.md @@ -0,0 +1,1837 @@ +# Camera + + +## **汇总** + + +### 文件 + +| 文件 | æè¿° | +| -------- | -------- | +| [icamera_device.h](icamera__device_8h.md) | Camera设备æ“作接å£ã€‚ | +| [icamera_device_callback.h](icamera__device__callback_8h.md) | Camera设备的回调接å£ï¼Œä¸»è¦åŒ…å«Camera设备å‘生错误时和上报metadata的回调函数。 | +| [icamera_host.h](icamera__host_8h.md) | CameraæœåŠ¡çš„管ç†ç±»ï¼Œå¯¹ä¸Šå±‚æä¾›HDI接å£ã€‚ | +| [icamera_host_callback.h](icamera__host__callback_8h.md) | ICameraHost的回调接å£ï¼Œæä¾›Camera设备和闪关ç¯çŠ¶æ€å˜åŒ–的回调函数,回调函数由调用者实现。 | +| [ioffline_stream_operator.h](ioffline__stream__operator_8h.md) | 离线æµçš„æ“作接å£ã€‚ | +| [istream_operator.h](istream__operator_8h.md) | æµçš„æ“作接å£ã€‚ | +| [istream_operator_callback.h](istream__operator__callback_8h.md) | [IStreamOperator](istream__operator_8h.md)相关的回调,这些回调å‡ç”±è°ƒç”¨è€…实现。 | +| [types.h](types_8h.md) | Camera模å—HDI接å£ä½¿ç”¨çš„æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + +| ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | Camera设备æ“作。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | +| [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | Camera设备æ“作回调。[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | +| [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | CameraæœåŠ¡çš„管ç†ç±»ã€‚[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | +| [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | CameraæœåŠ¡çš„管ç†å›žè°ƒã€‚[更多...](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | +| [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | 离线æµçš„æ“作类。[更多...](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | +| [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | æµçš„æ“作类。[更多...](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | +| [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | æµçš„æ“作回调类。[更多...](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | +| [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) | æµä¿¡æ¯ï¼Œç”¨äºŽåˆ›å»ºæµæ—¶ä¼ 入相关的é…ç½®å‚数。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_info.md) | +| [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | æµçš„属性。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | +| [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) | æ•èŽ·è¯·æ±‚的相关信æ¯ã€‚ [更多...](_o_h_o_s_1_1_camera_1_1_capture_info.md) | +| [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | æ•èŽ·ç»“æŸç›¸å…³ä¿¡æ¯ï¼Œç”¨äºŽæ•èŽ·ç»“æŸå›žè°ƒ **OnCaptureEnded**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | +| [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | æµé”™è¯¯ä¿¡æ¯ï¼Œç”¨äºŽå›žè°ƒ **OnCaptureError**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | + + +### 类型定义 + +| 类型定义 | æè¿° | +| -------- | -------- | +| **OHOS::Camera::CameraAbility** = CameraMetadata | Camera设备能力集åˆã€‚ | +| **OHOS::Camera::CameraSetting** = CameraMetadata | Camera设置å‚数,包括sensor帧率,3A相关å‚æ•°ç‰ã€‚ | +| **OHOS::Camera::MetaType** = int32_t | 整型。 | + + +### 枚举 + +| 枚举 | æè¿° | +| -------- | -------- | +| [OHOS::Camera::CamRetCode](#camretcode) : int32_t { OHOS::Camera::NO_ERROR = 0, OHOS::Camera::CAMERA_BUSY = -1, OHOS::Camera::INSUFFICIENT_RESOURCES = -2, OHOS::Camera::INVALID_ARGUMENT = -3, OHOS::Camera::METHOD_NOT_SUPPORTED = -4, OHOS::Camera::CAMERA_CLOSED = -5, OHOS::Camera::DEVICE_ERROR = -6 } | HDI接å£çš„返回值。 [更多...](#camretcode) | +| [OHOS::Camera::ResultCallbackMode](#resultcallbackmode) : int32_t { OHOS::Camera::PER_FRAME, OHOS::Camera::ON_CHANGED } | metadata的上报模å¼ã€‚ [更多...](#resultcallbackmode) | +| [OHOS::Camera::OperationMode](#operationmode) : int32_t { OHOS::Camera::NORMAL = 0 } | æµçš„使用模å¼ã€‚ [更多...](#operationmode) | +| [OHOS::Camera::StreamIntent](#streamintent) : int32_t { OHOS::Camera::PREVIEW = 0, OHOS::Camera::VIDEO = 1, OHOS::Camera::STILL_CAPTURE = 2, OHOS::Camera::POST_VIEW = 3, OHOS::Camera::ANALYZE = 4, OHOS::Camera::CUSTOM = 5 } | æµçš„类型。 [更多...](#streamintent) | +| [OHOS::Camera::EncodeType](#encodetype) : int32_t { OHOS::Camera::ENCODE_TYPE_NULL = 0, OHOS::Camera::ENCODE_TYPE_H264 = 1, OHOS::Camera::ENCODE_TYPE_H265 = 2, OHOS::Camera::ENCODE_TYPE_JPEG = 3 } | æµæ•°æ®çš„ç¼–ç 类型。 [更多...](#encodetype) | +| [OHOS::Camera::StreamSupportType](#streamsupporttype) : int32_t { OHOS::Camera::DYNAMIC_SUPPORTED, OHOS::Camera::RE_CONFIGURED_REQUIRED, OHOS::Camera::NOT_SUPPORTED } | 动æ€é…ç½®æµçš„切æ¢æ–¹å¼ï¼Œä½¿ç”¨åœºæ™¯å‚考 [IsStreamsSupported](#isstreamssupported) 。 [更多...](#streamsupporttype) | +| [OHOS::Camera::CameraStatus](#camerastatus) { OHOS::Camera::UN_AVAILABLE = 0, OHOS::Camera::AVAILABLE = 1 } | Camera设备状æ€ã€‚ [更多...](#camerastatus) | +| [OHOS::Camera::FlashlightStatus](#flashlightstatus) : uint32_t { OHOS::Camera::FLASHLIGHT_OFF = 0, OHOS::Camera::FLASHLIGHT_ON = 1, OHOS::Camera::FLASHLIGHT_UNAVAILABLE = 2 } | 闪光ç¯çŠ¶æ€ã€‚ [更多...](#flashlightstatus) | +| [OHOS::Camera::CameraEvent](#cameraevent): uint32_t { OHOS::Camera::CAMERA_EVENT_DEVICE_ADD = 0, OHOS::Camera::CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 [更多...](#cameraevent) | +| [OHOS::Camera::ErrorType](#errortype) : uint32_t { OHOS::Camera::FATAL_ERROR = 0, OHOS::Camera::REQUEST_TIMEOUT = 1 } | 设备错误类型,用于设备错误回调 [OnError](#onerror)。 [更多...](#errortype) | +| [OHOS::Camera::StreamError](#streamerror) { OHOS::Camera::UNKNOWN_ERROR = 0, OHOS::Camera::BUFFER_LOST = 1 } | æµé”™è¯¯ç±»åž‹ï¼Œç”¨äºŽæµé”™è¯¯ç±»åž‹ [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md)。 [更多...](#streamerror) | + + +### 函数 + +| 函数 | æè¿° | +| -------- | -------- | +| **OHOS::Camera::ICameraDevice::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Device") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::ICameraDevice::GetStreamOperator](#getstreamoperator) (const OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) > &streamOperator)=0 | 获å–æµæ“作å¥æŸ„。 [更多...](#getstreamoperator) | +| [OHOS::Camera::ICameraDevice::UpdateSettings](#updatesettings) (const std::shared_ptr< CameraSetting > &settings)=0 | 更新设备控制å‚数。 [更多...](#updatesettings) | +| [OHOS::Camera::ICameraDevice::SetResultMode](#setresultmode) (const [ResultCallbackMode](#resultcallbackmode) &mode)=0 | 设置metadata上报模å¼ï¼Œé€å¸§ä¸ŠæŠ¥è¿˜æ˜¯è®¾å¤‡çŠ¶æ€å˜åŒ–时上报。 [更多...](#setresultmode) | +| [OHOS::Camera::ICameraDevice::GetEnabledResults](#getenabledresults) (std::vector< MetaType > &results)=0 | 查询使能的metadata。 [更多...](#getenabledresults) | +| [OHOS::Camera::ICameraDevice::EnableResult](#enableresult) (const std::vector< MetaType > &results)=0 | 打开metadata上报开关。 [更多...](#enableresult) | +| [OHOS::Camera::ICameraDevice::DisableResult](#disableresult) (const std::vector< MetaType > &results)=0 | å…³é—metadata上报开关。 [更多...](#disableresult) | +| [OHOS::Camera::ICameraDevice::Close](#close) ()=0 | å…³é—Camera设备。 [更多...](#close) | +| **OHOS::Camera::ICameraDeviceCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.DeviceCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::ICameraDeviceCallback::OnError](#onerror) ([ErrorType](#errortype) type, int32_t errorCode)=0 | 设备å‘生错误时调用,由调用者实现,用于返回错误信æ¯ç»™è°ƒç”¨è€…。 [更多...](#onerror) | +| [OHOS::Camera::ICameraDeviceCallback::OnResult](#onresult) (uint64_t timestamp, const std::shared_ptr< CameraMetadata > &result)=0 | 上报Camera设备相关的metadata的回调,上报方å¼æŸ¥çœ‹ [SetResultMode](#setresultmode)。 [更多...](#onresult) | +| **OHOS::Camera::ICameraHost::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Host") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::ICameraHost::Get](#get) (const char \*serviceName) | 获å–ICameraHost实例。 [更多...](#get) | +| [OHOS::Camera::ICameraHost::SetCallback](#setcallback) (const OHOS::sptr< [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) > &callback)=0 | 设置ICameraHost回调接å£ï¼Œå›žè°ƒå‡½æ•°å‚考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 [更多...](#setcallback) | +| [OHOS::Camera::ICameraHost::GetCameraIds](#getcameraids) (std::vector< std::string > &cameraIds)=0 | 获å–当å‰å¯ç”¨çš„Camera设备ID列表。 [更多...](#getcameraids) | +| [OHOS::Camera::ICameraHost::GetCameraAbility](#getcameraability) (const std::string &cameraId, std::shared_ptr< CameraAbility > &ability)=0 | 获å–Camera设备能力集åˆã€‚ [更多...](#getcameraability) | +| [OHOS::Camera::ICameraHost::OpenCamera](#opencamera) (const std::string &cameraId, const OHOS::sptr< [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) > &callback, OHOS::sptr< [ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) > &device)=0 | 打开Camera设备。 [更多...](#opencamera) | +| [OHOS::Camera::ICameraHost::SetFlashlight](#setflashlight) (const std::string &cameraId, bool &isEnable)=0 | 打开或关é—闪光ç¯ã€‚ [更多...](#setflashlight) | +| **OHOS::Camera::ICameraHostCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.HostCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::ICameraHostCallback::OnCameraStatus](#oncamerastatus) (const std::string &cameraId, [CameraStatus](#camerastatus) status)=0 | 用于Camera设备状æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 [更多...](#oncamerastatus) | +| [OHOS::Camera::ICameraHostCallback::OnFlashlightStatus](#onflashlightstatus) (const std::string &cameraId, [FlashlightStatus](#flashlightstatus) status)=0 | 用于在闪光ç¯çŠ¶æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 [更多...](#onflashlightstatus) | +| [OHOS::Camera::ICameraHostCallback::OnCameraEvent](#oncameraevent) (const std::string &cameraId, [CameraEvent](#cameraevent) event)=0 | 在相机事件å‘生时调用。 [更多...](#oncameraevent) | +| **OHOS::Camera::IOfflineStreamOperator::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.OfflineStreamOperator") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::IOfflineStreamOperator::CancelCapture](#cancelcapture-12) (int captureId)=0 | å–消æ•èŽ·è¯·æ±‚。 [更多...](#cancelcapture-12) | +| [OHOS::Camera::IOfflineStreamOperator::ReleaseStreams](#releasestreams-12) (const std::vector< int > &streamIds)=0 | 释放离线æµã€‚ [更多...](#releasestreams-12) | +| [OHOS::Camera::IOfflineStreamOperator::Release](#release) ()=0 | 释放所有离线æµã€‚ [更多...](#release) | +| **OHOS::Camera::IStreamOperator::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperator") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::IStreamOperator::IsStreamsSupported](#isstreamssupported) ([OperationMode](#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting, const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &info, [StreamSupportType](#streamsupporttype) &type)=0 | 查询是å¦æ”¯æŒæ·»åŠ å‚æ•°å¯¹åº”çš„æµ [更多...](#isstreamssupported) | +| [OHOS::Camera::IStreamOperator::CreateStreams](#createstreams) (const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &streamInfos)=0 | 创建æµã€‚ [更多...](#createstreams) | +| [OHOS::Camera::IStreamOperator::ReleaseStreams](#releasestreams-22) (const std::vector< int > &streamIds)=0 | 释放æµã€‚ [更多...](#releasestreams-22) | +| [OHOS::Camera::IStreamOperator::CommitStreams](#commitstreams) ([OperationMode](#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting)=0 | é…ç½®æµã€‚ [更多...](#commitstreams) | +| [OHOS::Camera::IStreamOperator::GetStreamAttributes](#getstreamattributes) (std::vector< std::shared_ptr< [StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) >> &attributes)=0 | 获å–æµçš„属性。 [更多...](#getstreamattributes) | +| [OHOS::Camera::IStreamOperator::AttachBufferQueue](#attachbufferqueue) (int streamId, const OHOS::sptr< OHOS::IBufferProducer > &producer)=0 | 绑定生产者å¥æŸ„和指定æµã€‚ [更多...](#attachbufferqueue) | +| [OHOS::Camera::IStreamOperator::DetachBufferQueue](#detachbufferqueue) (int streamId)=0 | 解除生产者å¥æŸ„和指定æµçš„绑定关系。 [更多...](#detachbufferqueue) | +| [OHOS::Camera::IStreamOperator::Capture](#capture) (int captureId, const std::shared_ptr< [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) > &info, bool isStreaming)=0 | æ•èŽ·å›¾åƒã€‚ [更多...](#capture) | +| [OHOS::Camera::IStreamOperator::CancelCapture](#cancelcapture-22) (int captureId)=0 | å–消æ•èŽ·ã€‚ [更多...](#cancelcapture-22) | +| [OHOS::Camera::IStreamOperator::ChangeToOfflineStream](#changetoofflinestream) (const std::vector< int > &streamIds, OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) > &offlineOperator)=0 | 将指定æµè½¬æ¢æˆç¦»çº¿æµã€‚ [更多...](#changetoofflinestream) | +| **OHOS::Camera::IStreamOperatorCallback::DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperatorCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OHOS::Camera::IStreamOperatorCallback::OnCaptureStarted](#oncapturestarted) (int32_t captureId, const std::vector< int32_t > &streamIds)=0 | æ•èŽ·å¼€å§‹å›žè°ƒï¼Œåœ¨æ•èŽ·å¼€å§‹æ—¶è°ƒç”¨ã€‚ [更多...](#oncapturestarted) | +| [OHOS::Camera::IStreamOperatorCallback::OnCaptureEnded](#oncaptureended) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) >> &infos)=0 | æ•èŽ·ç»“æŸå›žè°ƒï¼Œåœ¨æ•èŽ·ç»“æŸæ—¶è°ƒç”¨ã€‚ [更多...](#oncaptureended) | +| [OHOS::Camera::IStreamOperatorCallback::OnCaptureError](#oncaptureerror) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) >> &infos)=0 | æ•èŽ·é”™è¯¯å›žè°ƒï¼Œåœ¨æ•èŽ·è¿‡ç¨‹ä¸å‘生错误时调用。 [更多...](#oncaptureerror) | +| [OHOS::Camera::IStreamOperatorCallback::OnFrameShutter](#onframeshutter) (int32_t captureId, const std::vector< int32_t > &streamIds, uint64_t timestamp)=0 | 帧æ•èŽ·å›žè°ƒã€‚ [更多...](#onframeshutter) | + + +### å˜é‡ + +| å˜é‡ | æè¿° | +| -------- | -------- | +| [OHOS::Camera::StreamInfo::streamId_](#streamid-14) | æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ | +| [OHOS::Camera::StreamInfo::width_](#width-12) | 图åƒå®½åº¦ã€‚ | +| [OHOS::Camera::StreamInfo::height_](#height-12) | 图åƒé«˜åº¦ã€‚ | +| [OHOS::Camera::StreamInfo::format_](#format) | 图åƒæ ¼å¼ã€‚ | +| [OHOS::Camera::StreamInfo::dataspace_](#dataspace) | 图åƒé¢œè‰²ç©ºé—´ã€‚ | +| [OHOS::Camera::StreamInfo::intent_](#intent) | æµç±»åž‹ã€‚ | +| [OHOS::Camera::StreamInfo::tunneledMode_](#tunneledmode) | 隧é“模å¼ï¼Œå€¼ä¸ºtrue时开å¯ï¼Œfalseå…³é—。 | +| [OHOS::Camera::StreamInfo::bufferQueue_](#bufferqueue) | 图形æ供的生产者å¥æŸ„。 | +| [OHOS::Camera::StreamInfo::minFrameDuration_](#minframeduration) | 最å°å¸§é—´éš”。 | +| [OHOS::Camera::StreamInfo::encodeType_](#encodetype) | ç¼–ç 类型。 | +| [OHOS::Camera::StreamAttribute::streamId_](#streamid-24) | æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ | +| [OHOS::Camera::StreamAttribute::width_](#width-22) | 图åƒå®½åº¦ã€‚ | +| [OHOS::Camera::StreamAttribute::height_](#height-22) | 图åƒé«˜åº¦ã€‚ | +| [OHOS::Camera::StreamAttribute::overrideFormat_](#overrideformat) | é‡å†™çš„图åƒæ ¼å¼ã€‚ | +| [OHOS::Camera::StreamAttribute::overrideDataspace_](#overridedataspace) | é‡å†™çš„图åƒé¢œè‰²ç©ºé—´ã€‚ | +| [OHOS::Camera::StreamAttribute::producerUsage_](#producerusage) | é‡å†™åŽçš„生产者的使用方å¼ã€‚ | +| [OHOS::Camera::StreamAttribute::producerBufferCount_](#producerbuffercount) | é‡å†™åŽçš„生产者缓å˜æ•°é‡ã€‚ | +| [OHOS::Camera::StreamAttribute::maxBatchCaptureCount_](#maxbatchcapturecount) | è¿žæ‹æ”¯æŒçš„最大æ•èŽ·å¸§æ•°é‡ã€‚ | +| [OHOS::Camera::StreamAttribute::maxCaptureCount_](#maxcapturecount) | 最大的并å‘æ•èŽ·è¯·æ±‚个数,默认为1。 | +| [OHOS::Camera::CaptureInfo::streamIds_](#streamids) | æ•èŽ·çš„æµID集åˆã€‚ | +| [OHOS::Camera::CaptureInfo::captureSetting_](#capturesetting) | æ•èŽ·çš„é…置信æ¯ã€‚ | +| [OHOS::Camera::CaptureInfo::enableShutterCallback_](#enableshuttercallback) | 使能æ•èŽ·å›žè°ƒã€‚ | +| [OHOS::Camera::CaptureEndedInfo::streamId_](#streamid-34) | æ•èŽ·çš„æµID。 | +| [OHOS::Camera::CaptureEndedInfo::frameCount_](#framecount) | æ•èŽ·ç»“æŸæ—¶å·²ç»æŠ“å–的帧数。 | +| [OHOS::Camera::CaptureErrorInfo::streamId_](#streamid-44) | æµID。 | +| [OHOS::Camera::CaptureErrorInfo::error_](#error) | 错误类型。 | + + +## **详细æè¿°** + +Camera模å—接å£å®šä¹‰ã€‚ + +Camera模å—涉åŠç›¸æœºè®¾å¤‡çš„æ“作ã€æµçš„æ“作ã€ç¦»çº¿æµçš„æ“作和å„ç§å›žè°ƒç‰ã€‚ + +**Since:** + +1.0 + + +## **枚举类型说明** + + +### CameraEvent + + +``` +enum OHOS::Camera::CameraEvent : uint32_t +``` + +**æ述:** + +Camera事件。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| CAMERA_EVENT_DEVICE_ADD | Cameraè®¾å¤‡å¢žåŠ äº‹ä»¶ã€‚ | +| CAMERA_EVENT_DEVICE_RMV | Cameraè®¾å¤‡åˆ é™¤äº‹ä»¶ã€‚ | + + +### CameraStatus + + +``` +enum OHOS::Camera::CameraStatus +``` + +**æ述:** + +Camera设备状æ€ã€‚ + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| UN_AVAILABLE | 设备当å‰ä¸åœ¨ä½æˆ–者ä¸å¯ç”¨ã€‚ | +| AVAILABLE | 设备当å‰å¯ç”¨ã€‚ | + + +### CamRetCode + + +``` +enum OHOS::Camera::CamRetCode : int32_t +``` + +**æ述:** + +HDI接å£çš„返回值。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| NO_ERROR | 调用æˆåŠŸã€‚ | +| CAMERA_BUSY | 设备当å‰å¿™ã€‚ | +| INSUFFICIENT_RESOURCES | 资æºä¸è¶³ã€‚ | +| INVALID_ARGUMENT | å‚数错误。 | +| METHOD_NOT_SUPPORTED | ä¸æ”¯æŒå½“å‰è°ƒç”¨æ–¹æ³•ã€‚ | +| CAMERA_CLOSED | Camera设备已ç»å…³é—。 | +| DEVICE_ERROR | 驱动层å‘生严é‡é”™è¯¯ã€‚ | + + +### EncodeType + + +``` +enum OHOS::Camera::EncodeType : int32_t +``` + +**æ述:** + +æµæ•°æ®çš„ç¼–ç 类型。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| ENCODE_TYPE_NULL | 未设置编ç 类型。 | +| ENCODE_TYPE_H264 | ç¼–ç 类型为H264。 | +| ENCODE_TYPE_H265 | ç¼–ç 类型为H265。 | +| ENCODE_TYPE_JPEG | ç¼–ç 类型为JPEG。 | + + +### ErrorType + + +``` +enum OHOS::Camera::ErrorType : uint32_t +``` + +**æ述:** + +设备错误类型,用于设备错误回调 **OnError**。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| FATAL_ERROR | 严é‡é”™è¯¯ï¼Œéœ€è¦å…³é—Camera设备。 | +| REQUEST_TIMEOUT | 请求超时,需è¦å…³é—Camera设备。 | + + +### FlashlightStatus + + +``` +enum OHOS::Camera::FlashlightStatus : uint32_t +``` + +**æ述:** + +闪光ç¯çŠ¶æ€ã€‚ + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| FLASHLIGHT_OFF | 闪光ç¯å…³é—。 | +| FLASHLIGHT_ON | 闪光ç¯å¼€å¯ã€‚ | +| FLASHLIGHT_UNAVAILABLE | 闪光ç¯å½“å‰ä¸å¯ç”¨ã€‚ | + + +### OperationMode + + +``` +enum OHOS::Camera::OperationMode : int32_t +``` + +**æ述:** + +æµçš„使用模å¼ã€‚ + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| NORMAL | 普通模å¼ã€‚ | + + +### ResultCallbackMode + + +``` +enum OHOS::Camera::ResultCallbackMode : int32_t +``` + +**æ述:** + +metadata的上报模å¼ã€‚ + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| PER_FRAME | æ¯å¸§ä¸ŠæŠ¥ã€‚ | +| ON_CHANGED | 设备状æ€å˜åŒ–时上报。 | + + +### StreamError + + +``` +enum OHOS::Camera::StreamError +``` + +**æ述:** + +æµé”™è¯¯ç±»åž‹ï¼Œç”¨äºŽæµé”™è¯¯ç±»åž‹ [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md)。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| UNKNOWN_ERROR | æµæœªçŸ¥é”™è¯¯ã€‚ | +| BUFFER_LOST | 丢包。 | + + +### StreamIntent + + +``` +enum OHOS::Camera::StreamIntent : int32_t +``` + +**æ述:** + +æµçš„类型。 + +| 枚举值 | **æè¿°** | +| -------- | -------- | +| PREVIEW | æµæ•°æ®ç”¨äºŽæ˜¾ç¤ºï¼Œå³é¢„览æµã€‚ | +| VIDEO | æµæ•°æ®ç”¨äºŽç¼–ç 生æˆå½•åƒï¼Œå³å½•åƒæµã€‚ | +| STILL_CAPTURE | æµæ•°æ®ç”¨äºŽç¼–ç 生æˆç…§ç‰‡ï¼Œå³æ‹ç…§æµã€‚ | +| POST_VIEW | æµæ•°æ®ç”¨äºŽä¿å˜ç¼©ç•¥å›¾ã€‚ | +| ANALYZE | æµæ•°æ®ç”¨äºŽå›¾åƒåˆ†æžã€‚ | +| CUSTOM | 自定义类型。 | + + +### StreamSupportType + + +``` +enum OHOS::Camera::StreamSupportType : int32_t +``` + +**æ述:** + +动æ€é…ç½®æµçš„切æ¢æ–¹å¼ï¼Œä½¿ç”¨åœºæ™¯å‚考 [IsStreamsSupported](#isstreamssupported) 。 + +| 枚举值 | æè¿° | +| -------- | -------- | +| DYNAMIC_SUPPORTED | 支æŒåŠ¨æ€é…ç½®æµï¼Œå¯¹åº”çš„æµå‚数直接生效。 | +| RE_CONFIGURED_REQUIRED | ä¸æ”¯æŒåŠ¨æ€é…ç½®æµï¼Œå¯¹åº”çš„å‚数需è¦åœæ¢æµç„¶åŽé‡æ–°é…ç½®æµæ‰èƒ½ç”Ÿæ•ˆã€‚ | +| NOT_SUPPORTED | ä¸æ”¯æŒå¯¹åº”çš„æµå‚æ•°é…置。 | + + +## **函数说明** + + +### AttachBufferQueue() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::AttachBufferQueue (int streamId, const OHOS::sptr < OHOS::IBufferProducer > & producer ) +``` + +**æ述:** + +绑定生产者å¥æŸ„和指定æµã€‚ + +如果在 [CreateStreams](#createstreams) 创建æµæ—¶å·²ç»æŒ‡å®šäº†ç”Ÿäº§è€…å¥æŸ„,则ä¸éœ€è¦è°ƒç”¨è¯¥æŽ¥å£ã€‚如果需è¦é‡æ–°ç»‘定, 需先调用 [DetachBufferQueue](#detachbufferqueue) 进行解绑,然åŽå†ç»‘定。 对于一些IOT设备,å¯èƒ½ä¸éœ€è¦æˆ–者ä¸æ”¯æŒé¢„览æµçš„图åƒæ•°æ®ç¼“å˜æµè½¬ï¼Œé‚£ä¹ˆä¸éœ€è¦ç»‘定生产者å¥æŸ„, æ¤æ—¶åœ¨åˆ›å»ºæµæ—¶ [CreateStreams](#createstreams) çš„ [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) å‚数的生产者å¥æŸ„bufferQueue_为空,而 tunneledMode_需设置为false。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamId | [IN] ç”¨äºŽæ ‡è¯†è¦ç»‘定的æµã€‚ | +| producer | [IN] 生产者å¥æŸ„。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[DetachBufferQueue](#detachbufferqueue) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### CancelCapture() [1/2] + + +``` +virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::CancelCapture (int captureId) +``` + +**æ述:** + +å–消æ•èŽ·è¯·æ±‚。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] ç”¨äºŽæ ‡è¯†è¦å–消的æ•èŽ·è¯·æ±‚。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + + +### CancelCapture() [2/2] + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::CancelCapture (int captureId) +``` + +**æ述:** + +å–消æ•èŽ·ã€‚ + +å–消连ç»æ•èŽ·æ—¶ä¼šè°ƒç”¨ **OnCaptureEnded**。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | ç”¨äºŽæ ‡è¯†è¦å–消的æ•èŽ·è¯·æ±‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[Capture](#capture) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### Capture() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::Capture (int captureId, const std::shared_ptr< CaptureInfo > & info, bool isStreaming ) +``` + +**æ述:** + +æ•èŽ·å›¾åƒã€‚ + +本接å£å¿…须在调用 [CommitStreams](#commitstreams) é…ç½®æµä¹‹åŽè°ƒç”¨ã€‚ 图åƒæ•èŽ·æœ‰ä¸¤ç§æ¨¡å¼ï¼Œåˆ†åˆ«æ˜¯è¿žç»æ•èŽ·å’Œå•æ¬¡æ•èŽ·ã€‚ + +- è¿žç»æ•èŽ·å³è§¦å‘之åŽæ¨¡å—内部进行连ç»çš„æ•èŽ·ï¼Œ 消费者å¯ä»¥è¿žç»æ”¶åˆ°å›¾åƒæ•°æ®ï¼Œä¸éœ€è¦å¤šæ¬¡è°ƒç”¨æœ¬æŽ¥å£ï¼Œè‹¥å†æ¬¡è°ƒç”¨äº†æœ¬æŽ¥å£ï¼Œ 则åœæ¢å½“å‰æ•èŽ·ï¼Œæ›´æ–°æ•èŽ·ä¿¡æ¯ï¼Œå†è¿›è¡Œä¸€æ¬¡æ–°çš„æ•èŽ·ï¼Œå¤šç”¨äºŽé¢„览ã€å½•åƒæˆ–者连æ‹åœºæ™¯ã€‚ + +- å•æ¬¡æ•èŽ·å³è§¦å‘之åŽåªæ•èŽ·ä¸€å¸§å›¾åƒæ•°æ®ï¼Œç”¨äºŽå•æ¬¡æ‹ç…§åœºæ™¯ã€‚ æ•èŽ·å¯åŠ¨æ—¶ï¼Œä¼šè°ƒç”¨ **OnCaptureStarted** æ¥é€šçŸ¥è°ƒç”¨è€…æ•èŽ·å·²ç»å¯åŠ¨ã€‚ + +è¿žç»æ•èŽ·éœ€è°ƒç”¨ [CancelCapture](#cancelcapture-22) æ¥åœæ¢æ•èŽ·ã€‚ æ•èŽ·ç»“æŸæ—¶ï¼Œä¼šè°ƒç”¨ **OnCaptureEnded** æ¥é€šçŸ¥è°ƒç”¨è€…æ•èŽ·çš„帧计数ç‰ä¿¡æ¯ã€‚ [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) çš„ enableShutterCallback_ 使能 **OnFrameShutter**,使能åŽæ¯æ¬¡æ•èŽ·è§¦å‘ **OnFrameShutter** 对于多个æµåŒæ—¶æ•èŽ·çš„场景,本模å—内部ä¿è¯åŒæ—¶ä¸ŠæŠ¥å¤šè·¯æµæ•èŽ·æ•°æ®ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] æ•èŽ·è¯·æ±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œç”±è°ƒç”¨è€…æŒ‡å®šï¼Œè°ƒç”¨è€…éœ€ä¿è¯åœ¨Camera设备打开期间,æ•èŽ·è¯·æ±‚ID是唯一的。 | +| info | [IN] æ•èŽ·è¯·æ±‚çš„å‚æ•°ä¿¡æ¯ï¼Œå…·ä½“ä¿¡æ¯æŸ¥çœ‹ [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md)。 | +| isStreaming | [IN] 是å¦è¿žç»æ•èŽ·ï¼Œtrue表示连ç»æ•èŽ·ï¼Œå¦åˆ™ä¸ºå•æ¬¡æ•èŽ·ã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +OnFrameShutter + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### ChangeToOfflineStream() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::ChangeToOfflineStream (const std::vector< int > & streamIds, OHOS::sptr< IStreamOperatorCallback > & callback, OHOS::sptr< IOfflineStreamOperator > & offlineOperator ) +``` + +**æ述:** + +将指定æµè½¬æ¢æˆç¦»çº¿æµã€‚ + +离线æµåªèƒ½ç”±æ‹ç…§æµè½¬æ¢è€Œæ¥ï¼Œå…¶ä»–æµä¸æ”¯æŒã€‚ 一些设备处ç†èƒ½åŠ›æœ‰é™ï¼Œå¯èƒ½å¯¼è‡´æ‹ç…§æ—¶ç®—法处ç†æ—¶é—´è¾ƒé•¿ï¼Œä»Žè€Œå¼•èµ·æ•èŽ·è¯·æ±‚å †ç§¯åœ¨æ¨¡å—内部,而转æ¢ä¸ºç¦»çº¿ æµä¹‹åŽï¼Œå¯å…³é—底层设备,由离线æµæŽ¥æ›¿ï¼Œè¿›è¡ŒåŽç»çš„处ç†ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamIds | [IN] 用于指定è¦è½¬æ¢æˆç¦»çº¿æµçš„æµé›†åˆã€‚ | +| callback | [IN] 用于设置离线æµçš„回调。 | +| offlineOperator | [OUT] 转æ¢åŽçš„离线æµã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### Close() + + +``` +virtual void OHOS::Camera::ICameraDevice::Close () +``` + +**æ述:** + +å…³é—Camera设备。 + +**å‚è§ï¼š** + +[OpenCamera](#opencamera) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### CommitStreams() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::CommitStreams (OperationMode mode, const std::shared_ptr< CameraMetadata > & modeSetting ) +``` + +**æ述:** + +é…ç½®æµã€‚ + +本接å£éœ€åœ¨è°ƒç”¨ [CreateStreams](#createstreams) 创建æµä¹‹åŽè°ƒç”¨ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| mode | [IN] æµè¿è¡Œçš„模å¼ï¼Œæ”¯æŒçš„模å¼å®šä¹‰åœ¨ **OperationMode**。 | +| modeSetting | [IN] æµçš„é…ç½®å‚数,包括帧率,ZOOMç‰ä¿¡æ¯ã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### CreateStreams() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::CreateStreams (const std::vector< std::shared_ptr< StreamInfo >> & streamInfos) +``` + +**æ述:** + +创建æµã€‚ + +æ¤å‡½æ•°æŽ¥å£ä¾æ®è¾“入的æµä¿¡æ¯åˆ›å»ºæµï¼Œè°ƒç”¨è¯¥æŽ¥å£ä¹‹å‰éœ€å…ˆé€šè¿‡ [IsStreamsSupported](#isstreamssupported) 查询HAL是å¦æ”¯æŒè¦åˆ›å»ºçš„æµã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamInfos | [IN] æµä¿¡æ¯åˆ—表,æµä¿¡æ¯å®šä¹‰åœ¨ [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md)。输入的æµä¿¡æ¯å¯èƒ½ä¼šè¢«ä¿®æ”¹ï¼Œéœ€é€šè¿‡ [GetStreamAttributes](#getstreamattributes) 获å–最新的æµå±žæ€§ã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### DetachBufferQueue() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::DetachBufferQueue (int streamId) +``` + +**æ述:** + +解除生产者å¥æŸ„和指定æµçš„绑定关系。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamId | [IN] ç”¨äºŽæ ‡è¯†è¦è§£é™¤ç»‘定的æµã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看[CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[AttachBufferQueue](#attachbufferqueue) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### DisableResult() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::DisableResult (const std::vector< MetaType > & results) +``` + +**æ述:** + +å…³é—metadata上报开关。 + +å±è”½ä¹‹åŽï¼Œç›¸åº”çš„**OnResult**ä¸å†ä¸ŠæŠ¥ï¼Œéœ€ [EnableResult](#enableresult) 使能之åŽæ‰ä¸ŠæŠ¥ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| results | [IN] 需è¦å…³é—上报开关的metadata。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[EnableResult](#enableresult) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### EnableResult() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::EnableResult (const std::vector< MetaType > & results) +``` + +**æ述:** + +打开metadata上报开关。 + +**OnResult** åªä¸ŠæŠ¥æ¤æŽ¥å£ä½¿èƒ½åŽçš„metadata。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| results | [IN] 需è¦æ‰“开上报开关的metadata。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[DisableResult](#disableresult) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### Get() + + +``` +static sptr<ICameraHost> OHOS::Camera::ICameraHost::Get (const char * serviceName) +``` + +**æ述:** + +获å–ICameraHost实例。 + +æ¤æŽ¥å£ä¸ºCamera调用入å£ï¼Œéœ€è¦å…ˆé€šè¿‡è¯¥æŽ¥å£èŽ·å–ICameraHost实例,然åŽé€šè¿‡ICameraHost实例进行其它æ“作。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| serviceName | [IN] è¦èŽ·å–çš„ICameraHost实例的å称,当å‰å®žçŽ°ä¸å®žä¾‹å称固定为camera_service。 | + +**返回:** + +æˆåŠŸè¿”回ICameraHost实例,失败返回nullptr。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GetCameraAbility() + + +``` +virtual CamRetCode OHOS::Camera::ICameraHost::GetCameraAbility (const std::string & cameraId, std::shared_ptr< CameraAbility > & ability ) +``` + +**æ述:** + +获å–Camera设备能力集åˆã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | [IN] 用于指定è¦æ“作的Camera设备,通过 [GetCameraIds](#getcameraids) 获å–。 | +| ability | [OUT] 返回cameraId对应Camera设备的能力集åˆã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[GetCameraIds](#getcameraids) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GetCameraIds() + + +``` +virtual CamRetCode OHOS::Camera::ICameraHost::GetCameraIds (std::vector< std::string > & cameraIds) +``` + +**æ述:** + +获å–当å‰å¯ç”¨çš„Camera设备ID列表。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraIds | [OUT] 返回当å‰å¯ç”¨çš„设备列表 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[GetCameraAbility](#getcameraability) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GetEnabledResults() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::GetEnabledResults (std::vector< MetaType > & results) +``` + +**æ述:** + +查询使能的metadata。 + +[EnableResult](#enableresult) 使能需è¦ä¸ŠæŠ¥çš„metadata之åŽï¼Œå¯é€šè¿‡æ¤æŽ¥å£æŸ¥è¯¢ä½¿èƒ½çš„metadata。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| results | [OUT] 所有使能的metadata。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GetStreamAttributes() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::GetStreamAttributes (std::vector< std::shared_ptr< StreamAttribute >> & attributes) +``` + +**æ述:** + +获å–æµçš„属性。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| attributes | [OUT] 用于获å–æµçš„属性。在调用[CreateStreams](#createstreams) 时,通过å‚æ•°streamInfosæºå¸¦çš„æµä¿¡æ¯å¯èƒ½ä¼šè¢«é‡å†™ï¼Œå› æ¤é€šè¿‡è¯¥æŽ¥å£èŽ·å–çš„æµå±žæ€§å¯èƒ½ä¼šå’Œ [CreateStreams](#createstreams) 输入的æµä¿¡æ¯å˜åœ¨å·®å¼‚。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GetStreamOperator() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::GetStreamOperator (const OHOS::sptr< IStreamOperatorCallback > & callback, OHOS::sptr< IStreamOperator > & streamOperator ) +``` + +**æ述:** + +获å–æµæ“作å¥æŸ„。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| callback | [IN] 设置æµå›žè°ƒæŽ¥å£ï¼Œè¯¦ç»†å¯æŸ¥çœ‹ [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md), 用于上报æ•èŽ·å¼€å§‹ **OnCaptureStarted**,æ•èŽ·ç»“æŸ **OnCaptureEnded**, **OnCaptureError** æ•èŽ·é”™è¯¯ç‰ä¿¡æ¯ã€‚ | +| streamOperator | [OUT] 返回æµæ“作å¥æŸ„。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### IsStreamsSupported() + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::IsStreamsSupported (OperationMode mode, const std::shared_ptr< CameraMetadata > & modeSetting, const std::vector< std::shared_ptr< StreamInfo >> & info, StreamSupportType & type ) +``` + +**æ述:** + +查询是å¦æ”¯æŒæ·»åŠ å‚数对应的æµã€‚ + +æµæ˜¯æŒ‡ä»Žåº•å±‚设备输出,ç»æœ¬æ¨¡å—内部å„环节处ç†ï¼Œæœ€ç»ˆä¼ 递到上层æœåŠ¡æˆ–者应用的一组数æ®åºåˆ— 本模å—支æŒçš„æµçš„类型有预览æµï¼Œå½•åƒæµï¼Œæ‹ç…§æµç‰ï¼Œæ›´å¤šç±»åž‹å¯æŸ¥çœ‹ **StreamIntent**。 + +æ¤å‡½æ•°æŽ¥å£æ ¹æ®è¾“入的è¿è¡Œæ¨¡å¼å’Œé…置信æ¯ä»¥åŠå½“å‰æ¨¡å—ä¸æ£åœ¨è¿è¡Œçš„æµï¼ŒæŸ¥è¯¢æ˜¯å¦æ”¯æŒåŠ¨æ€æ·»åŠ æµã€‚ + +- 如果本模å—支æŒåœ¨ä¸åœæ¢å…¶ä»–æµçš„æƒ…å†µä¸‹æ·»åŠ æ–°æµï¼Œæˆ–者å³ä½¿åœæ¢å…¶ä»–æµä½†ä¸Šå±‚æœåŠ¡æˆ–应用ä¸æ„ŸçŸ¥ï¼Œåˆ™é€šè¿‡typeå‚数返回DYNAMIC_SUPPORTED,上层æœåŠ¡æˆ–应用å¯ä»¥ç›´æŽ¥æ·»åŠ æ–°æµã€‚ + +- 如果本模å—支æŒæ·»åŠ æ–°æµä½†éœ€è¦ä¸Šå±‚æœåŠ¡æˆ–应用先åœæ¢æ‰€æœ‰æµçš„æ•èŽ·ï¼Œåˆ™é€šè¿‡typeå‚数返回RE_CONFIGURED_REQUIRED。 + +- 如果ä¸æ”¯æŒæ·»åŠ 输入的新æµï¼Œåˆ™è¿”回NOT_SUPPORTED。 + +æ¤å‡½æ•°éœ€è¦åœ¨è°ƒç”¨ [CreateStreams](#createstreams) 创建æµä¹‹å‰è°ƒç”¨ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| mode | [IN] æµè¿è¡Œçš„模å¼ï¼Œæ”¯æŒçš„模å¼å‚考 **OperationMode**。 | +| modeSetting | [IN] æµçš„é…置,包括帧率,3Aç‰é…置信æ¯ã€‚ | +| info | [IN] æµçš„é…置信æ¯ï¼Œå…·ä½“å‚考 [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md)。 | +| type | [OUT] 对动æ€é…ç½®æµçš„支æŒç±»åž‹ï¼Œæ”¯æŒç±»åž‹å®šä¹‰åœ¨ **StreamSupportType**。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnCameraEvent() + + +``` +virtual void OHOS::Camera::ICameraHostCallback::OnCameraEvent (const std::string & cameraId, CameraEvent event ) +``` + +**æ述:** + +在相机事件å‘生时调用。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | 表示相机事件绑定的相机ID。 | +| event | 表示相机事件类型。 | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnCameraStatus() + + +``` +virtual void OHOS::Camera::ICameraHostCallback::OnCameraStatus (const std::string & cameraId, CameraStatus status ) +``` + +**æ述:** + +用于Camera设备状æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | [IN] 状æ€å‘生å˜åŒ–çš„Camera设备ID。 | +| status | [IN] 最新的设备状æ€ã€‚ | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnCaptureEnded() + + +``` +virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureEnded (int32_t captureId, const std::vector< std::shared_ptr< CaptureEndedInfo >> & infos ) +``` + +**æ述:** + +æ•èŽ·ç»“æŸå›žè°ƒï¼Œåœ¨æ•èŽ·ç»“æŸæ—¶è°ƒç”¨ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] ç”¨äºŽæ ‡è¯†å›žè°ƒå¯¹åº”çš„æ•èŽ·è¯·æ±‚。 | +| infos | [IN] æ•èŽ·ç»“æŸç›¸å…³ä¿¡æ¯ã€‚ | + +**å‚è§ï¼š** + +[OnCaptureStarted](#oncapturestarted) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnCaptureError() + + +``` +virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureError (int32_t captureId, const std::vector< std::shared_ptr< CaptureErrorInfo >> & infos ) +``` + +**æ述:** + +æ•èŽ·é”™è¯¯å›žè°ƒï¼Œåœ¨æ•èŽ·è¿‡ç¨‹ä¸å‘生错误时调用。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] ç”¨äºŽæ ‡è¯†å›žè°ƒå¯¹åº”çš„æ•èŽ·è¯·æ±‚。 | +| infos | [IN] æ•èŽ·é”™è¯¯ä¿¡æ¯åˆ—表。 | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnCaptureStarted() + + +``` +virtual void OHOS::Camera::IStreamOperatorCallback::OnCaptureStarted (int32_t captureId, const std::vector< int32_t > & streamIds ) +``` + +**æ述:** + +æ•èŽ·å¼€å§‹å›žè°ƒï¼Œåœ¨æ•èŽ·å¼€å§‹æ—¶è°ƒç”¨ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] ç”¨äºŽæ ‡è¯†å›žè°ƒå¯¹åº”çš„æ•èŽ·è¯·æ±‚。 | +| streamIds | [IN] 回调对应的æµé›†åˆã€‚ | + +**å‚è§ï¼š** + +[OnCaptureEnded](#oncaptureended) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnError() + + +``` +virtual void OHOS::Camera::ICameraDeviceCallback::OnError (ErrorType type, int32_t errorCode ) +``` + +**æ述:** + +设备å‘生错误时调用,由调用者实现,用于返回错误信æ¯ç»™è°ƒç”¨è€…。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| type | [IN] 错误类型,具体错误类型å¯å‚考 **ErrorType**。 | +| errorCode | [IN] 错误ç ,当å‰æš‚未使用。 | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnFlashlightStatus() + + +``` +virtual void OHOS::Camera::ICameraHostCallback::OnFlashlightStatus (const std::string & cameraId, FlashlightStatus status ) +``` + +**æ述:** + +用于在闪光ç¯çŠ¶æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | [IN] 状æ€å‘生å˜åŒ–的闪关ç¯æ‰€ç»‘定的Camera设备ID。 | +| status | [IN] 最新的闪光ç¯çŠ¶æ€ã€‚ | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnFrameShutter() + + +``` +virtual void OHOS::Camera::IStreamOperatorCallback::OnFrameShutter (int32_t captureId, const std::vector< int32_t > & streamIds, uint64_t timestamp ) +``` + +**æ述:** + +帧æ•èŽ·å›žè°ƒã€‚ + +通过 **Capture** 的输入å‚æ•° [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) çš„enableShutterCallback_使能该回调, 使能åŽæ¯æ¬¡æ•èŽ·å‡ä¼šè§¦å‘æ¤å›žè°ƒã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| captureId | [IN] ç”¨äºŽæ ‡è¯†å›žè°ƒå¯¹åº”çš„æ•èŽ·è¯·æ±‚。 | +| streamIds | [IN] 回调对应的æµé›†åˆã€‚ | +| timestamp | [IN] 该接å£è¢«è°ƒç”¨æ—¶çš„时间戳。 | + +**å‚è§ï¼š** + +Capture + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OnResult() + + +``` +virtual void OHOS::Camera::ICameraDeviceCallback::OnResult (uint64_t timestamp, const std::shared_ptr< CameraMetadata > & result ) +``` + +**æ述:** + +上报Camera设备相关的metadata的回调,上报方å¼æŸ¥çœ‹ [SetResultMode](#setresultmode)。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| timestamp | [IN] metadata上报的时间戳。 | +| result | [IN] 上报的metadata,上报的metadataç”± **EnableResult** 指定, å¯é€šè¿‡ **GetEnabledResults** 查询,**DisableResult** å…³é—上报开关。 | + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### OpenCamera() + + +``` +virtual CamRetCode OHOS::Camera::ICameraHost::OpenCamera (const std::string & cameraId, const OHOS::sptr< ICameraDeviceCallback > & callback, OHOS::sptr< ICameraDevice > & device ) +``` + +**æ述:** + +打开Camera设备。 + +打开指定的Camera设备,通过æ¤æŽ¥å£å¯ä»¥èŽ·å–到ICameraDevice对象,通过ICameraDevice对象å¯ä»¥æ“作具体的Camera设备。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | [IN] 需è¦æ‰“开的Camera设备ID,å¯é€šè¿‡ [GetCameraIds](#getcameraids) 接å£èŽ·å–当å‰å·²æœ‰Camera设备列表。 | +| callback | [IN] Camera设备相关的回调函数,具体å‚è§ [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md)。 | +| device | [OUT] 返回当å‰è¦æ‰“开的Camera设备ID对应的ICameraDevice对象。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[GetCameraIds](#getcameraids) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### Release() + + +``` +virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::Release () +``` + +**æ述:** + +释放所有离线æµã€‚ + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### ReleaseStreams() [1/2] + + +``` +virtual CamRetCode OHOS::Camera::IOfflineStreamOperator::ReleaseStreams (const std::vector< int > & streamIds) +``` + +**æ述:** + +释放离线æµã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamIds | ç”¨äºŽæ ‡è¯†è¦é‡Šæ”¾çš„离线æµé›†åˆã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### ReleaseStreams() [2/2] + + +``` +virtual CamRetCode OHOS::Camera::IStreamOperator::ReleaseStreams (const std::vector< int > & streamIds) +``` + +**æ述:** + +释放æµã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| streamIds | [IN] è¦é‡Šæ”¾çš„æµID列表。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸï¼› + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### SetCallback() + + +``` +virtual CamRetCode OHOS::Camera::ICameraHost::SetCallback (const OHOS::sptr< ICameraHostCallback > & callback) +``` + +**æ述:** + +设置ICameraHost回调接å£ï¼Œå›žè°ƒå‡½æ•°å‚考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| callback | [IN] è¦è®¾ç½®çš„回调函数。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### SetFlashlight() + + +``` +virtual CamRetCode OHOS::Camera::ICameraHost::SetFlashlight (const std::string & cameraId, bool & isEnable ) +``` + +**æ述:** + +打开或关é—闪光ç¯ã€‚ + +该接å£åªèƒ½ç”±æ‰“å¼€cameraId指定Camera设备的调用者调用。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| cameraId | [IN] 闪光ç¯å¯¹åº”çš„Camera设备ID。 | +| isEnable | [IN] true打开闪光ç¯ï¼Œfalseå…³é—闪光ç¯ã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**å‚è§ï¼š** + +[GetCameraIds](#getcameraids) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### SetResultMode() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::SetResultMode (const ResultCallbackMode & mode) +``` + +**æ述:** + +设置metadata上报模å¼ï¼Œé€å¸§ä¸ŠæŠ¥è¿˜æ˜¯è®¾å¤‡çŠ¶æ€å˜åŒ–时上报。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| mode | [IN] metadata的上报模å¼ï¼Œé€å¸§ä¸ŠæŠ¥æˆ–者设备状æ€å˜åŒ–时上报,查看 **ResultCallbackMode**。 | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### UpdateSettings() + + +``` +virtual CamRetCode OHOS::Camera::ICameraDevice::UpdateSettings (const std::shared_ptr< CameraSetting > & settings) +``` + +**æ述:** + +更新设备控制å‚数。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| settings | [IN] Camera设置å‚数,包括sensor帧率,3A相关å‚æ•°ç‰ã€‚ | + +**返回:** + +NO_ERROR 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看 [CamRetCode](#camretcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **å˜é‡è¯´æ˜Ž** + + +### bufferQueue_ + + +``` +OHOS::sptr<OHOS::IBufferProducer> OHOS::Camera::StreamInfo::bufferQueue_ +``` + +**æ述:** + +图形æ供的生产者å¥æŸ„。 + + +### captureSetting_ + + +``` +std::shared_ptr<CameraMetadata> OHOS::Camera::CaptureInfo::captureSetting_ +``` + +**æ述:** + +æ•èŽ·çš„é…置信æ¯ã€‚ + + +### dataspace_ + + +``` +int OHOS::Camera::StreamInfo::dataspace_ +``` + +**æ述:** + +图åƒé¢œè‰²ç©ºé—´ã€‚ + + +### enableShutterCallback_ + + +``` +bool OHOS::Camera::CaptureInfo::enableShutterCallback_ +``` + +**æ述:** + +使能æ•èŽ·å›žè°ƒï¼Œæ¯ä¸€æ¬¡æ•èŽ·åŽéƒ½ä¼šè§¦å‘ **OnFrameShutter**。 + + +### encodeType_ + + +``` +EncodeType OHOS::Camera::StreamInfo::encodeType_ +``` + +**æ述:** + +ç¼–ç 类型。 + + +### error_ + + +``` +StreamError OHOS::Camera::CaptureErrorInfo::error_ +``` + +**æ述:** + +错误类型。 + + +### format_ + + +``` +int OHOS::Camera::StreamInfo::format_ +``` + +**æ述:** + +图åƒæ ¼å¼ã€‚ + + +### frameCount_ + + +``` +int OHOS::Camera::CaptureEndedInfo::frameCount_ +``` + +**æ述:** + +æ•èŽ·ç»“æŸæ—¶å·²ç»æŠ“å–的帧数。 + + +### height_ [1/2] + + +``` +int OHOS::Camera::StreamInfo::height_ +``` + +**æ述:** + +图åƒé«˜åº¦ã€‚ + + +### height_ [2/2] + + +``` +int OHOS::Camera::StreamAttribute::height_ +``` + +**æ述:** + +图åƒé«˜åº¦ã€‚ + + +### intent_ + + +``` +StreamIntent OHOS::Camera::StreamInfo::intent_ +``` + +**æ述:** + +æµç±»åž‹ã€‚ + + +### maxBatchCaptureCount_ + + +``` +int OHOS::Camera::StreamAttribute::maxBatchCaptureCount_ +``` + +**æ述:** + +è¿žæ‹æ”¯æŒçš„最大æ•èŽ·å¸§æ•°é‡ã€‚ + + +### maxCaptureCount_ + + +``` +int OHOS::Camera::StreamAttribute::maxCaptureCount_ +``` + +**æ述:** + +最大的并å‘æ•èŽ·è¯·æ±‚个数,默认为1。 + + +### minFrameDuration_ + + +``` +int OHOS::Camera::StreamInfo::minFrameDuration_ +``` + +**æ述:** + +最å°å¸§é—´éš”。 + + +### overrideDataspace_ + + +``` +int OHOS::Camera::StreamAttribute::overrideDataspace_ +``` + +**æ述:** + +é‡å†™çš„图åƒé¢œè‰²ç©ºé—´ã€‚ + + +### overrideFormat_ + + +``` +int OHOS::Camera::StreamAttribute::overrideFormat_ +``` + +**æ述:** + +é‡å†™çš„图åƒæ ¼å¼ã€‚ + + +### producerBufferCount_ + + +``` +int OHOS::Camera::StreamAttribute::producerBufferCount_ +``` + +**æ述:** + +é‡å†™åŽçš„生产者缓å˜æ•°é‡ã€‚ + + +### producerUsage_ + + +``` +int OHOS::Camera::StreamAttribute::producerUsage_ +``` + +**æ述:** + +é‡å†™åŽçš„生产者的使用方å¼ã€‚ + + +### streamId_ [1/4] + + +``` +int OHOS::Camera::StreamInfo::streamId_ +``` + +**æ述:** + +æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ + + +### streamId_ [2/4] + + +``` +int OHOS::Camera::StreamAttribute::streamId_ +``` + +**æ述:** + +æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ + + +### streamId_ [3/4] + + +``` +int OHOS::Camera::CaptureEndedInfo::streamId_ +``` + +**æ述:** + +æ•èŽ·çš„æµID。 + + +### streamId_ [4/4] + + +``` +int OHOS::Camera::CaptureErrorInfo::streamId_ +``` + +**æ述:** + +æµID。 + + +### streamIds_ + + +``` +std::vector<int> OHOS::Camera::CaptureInfo::streamIds_ +``` + +**æ述:** + +æ•èŽ·çš„æµID集åˆã€‚ + + +### tunneledMode_ + + +``` +bool OHOS::Camera::StreamInfo::tunneledMode_ +``` + +**æ述:** + +隧é“模å¼ï¼Œå€¼ä¸ºtrue时开å¯ï¼Œfalseå…³é—。 + +å¼€å¯éš§é“模å¼åŽï¼ŒHALä¸ç›´æŽ¥å’Œä¸Šå±‚交互,通过图形æ供的生产者å¥æŸ„æ¥ä¼ 递帧数æ®ï¼Œ 对于一些IOT设备,å¯èƒ½ä¸éœ€è¦æˆ–者ä¸æ”¯æŒé¢„览æµçš„图åƒæ•°æ®ç¼“å˜æµè½¬ï¼Œæ¤æ—¶éœ€è¦å…³é—隧é“模å¼ã€‚ + + +### width_ [1/2] + + +``` +int OHOS::Camera::StreamInfo::width_ +``` + +**æ述:** + +图åƒå®½åº¦ã€‚ + + +### width_ [2/2] + + +``` +int OHOS::Camera::StreamAttribute::width_ +``` + +**æ述:** + +图åƒå®½åº¦ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec.md b/zh-cn/device-dev/reference/hdi-apis/_codec.md new file mode 100644 index 0000000000000000000000000000000000000000..f3eea39775c59854ce737f602b09aed8711e69fd --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_codec.md @@ -0,0 +1,1346 @@ +# Codec + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [codec_callback_if.h](codec__callback__if_8h.md) | 主è¦åŒ…括回调函数接å£å®šä¹‰ã€‚ | +| [codec_common_type.h](codec__common__type_8h.md) | Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ | +| [codec_component_if.h](codec__component__if_8h.md) | 主è¦åŒ…括Codec组件接å£å®šä¹‰ã€‚ | +| [codec_component_manager.h](codec__component__manager_8h.md) | 主è¦åŒ…括Codec组件管ç†ç±»æŽ¥å£ã€‚ | +| [codec_component_type.h](codec__component__type_8h.md) | Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [CodecCallbackType](_codec_callback_type.md) | Codec回调接å£å®šä¹‰ã€‚ [更多...](_codec_callback_type.md) | +| [Alignment](_alignment.md) | 对é½ç»“构定义,包å«å®½é«˜çš„对é½å€¼ã€‚ [更多...](_alignment.md) | +| [Rect](_rect.md) | 矩形的定义。 [更多...](_rect.md) | +| [RangeValue](_range_value.md) | å–值范围的定义。 [更多...](_range_value.md) | +| [CodecComponentType](_codec_component_type.md) | Codec组件接å£å®šä¹‰ã€‚ [更多...](_codec_component_type.md) | +| [CodecComponentManager](_codec_component_manager.md) | Codec组件管ç†ç±»æŽ¥å£å®šä¹‰ã€‚ [更多...](_codec_component_manager.md) | +| [VideoPortCap](_video_port_cap.md) | 定义视频编解ç 能力。 [更多...](_video_port_cap.md) | +| [AudioPortCap](_audio_port_cap.md) | 定义音频编解ç 能力。 [更多...](_audio_port_cap.md) | +| [PortCap](union_port_cap.md) | 定义音视频编解ç 能力。 [更多...](union_port_cap.md) | +| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解ç 能力。 [更多...](_codec_comp_capability.md) | +| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec bufferä¿¡æ¯çš„定义。 [更多...](_omx_codec_buffer.md) | +| [CompVerInfo](_comp_ver_info.md) | 定义组件版本信æ¯ã€‚ [更多...](_comp_ver_info.md) | +| [EventInfo](_event_info.md) | 定义事件上报信æ¯ã€‚ [更多...](_event_info.md) | +| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义。 [更多...](_support_buffer_type.md) | +| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义。 [更多...](_use_buffer_type.md) | +| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义。 [更多...](_get_buffer_handle_usage_params.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| SAMPLE_FMT_NUM 32 | é‡‡æ ·æ ¼å¼æœ€å¤§å€¼ã€‚ | +| UUID_LENGTH 128 | 定义UUID长度。 | +| PIX_FORMAT_NUM 16 | 支æŒçš„åƒç´ æ ¼å¼æ•°ç»„大å°ã€‚ | +| SAMPLE_FORMAT_NUM 12 | 支æŒçš„éŸ³é¢‘é‡‡æ ·æ ¼å¼æ•°ç»„大å°ã€‚ | +| SAMPLE_RATE_NUM 16 | 支æŒçš„éŸ³é¢‘é‡‡æ ·çŽ‡æ•°ç»„å¤§å°ã€‚ | +| CHANNEL_NUM 16 | 支æŒçš„音频通é“数组大å°ã€‚ | +| NAME_LENGTH 32 | 组件å称大å°ã€‚ | +| PROFILE_NUM 256 | 支æŒçš„profile数组大å°ã€‚ | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [CodecType](#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER, INVALID_TYPE } | 枚举编解ç 的类型。 [更多...](#codectype) | +| [Profile](#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE, AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000, AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codecè§„æ ¼ã€‚ [更多...](#profile) | +| [AudioSampleRate](#audiosamplerate) { AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000, AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100, AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | æžšä¸¾éŸ³é¢‘é‡‡æ ·çŽ‡ã€‚ [更多...](#audiosamplerate) | +| [CodecCapsMask](#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举æ’放能力。 [更多...](#codeccapsmask) | +| [CodecProcessMode](#codecprocessmode) { PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100, PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解ç 处ç†æ¨¡å¼ã€‚ [更多...](#codecprocessmode) | +| [AvCodecRole](#avcodecrole) { MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000, MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726, MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解ç 组件类型。 [更多...](#avcodecrole) | +| [AudioSampleFormat](#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P, AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P, AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P, AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P, AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P, AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P, AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT, AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P, AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | æžšä¸¾éŸ³é¢‘é‡‡æ ·æ ¼å¼ã€‚ [更多...](#audiosampleformat) | +| [CodecBufferType](#codecbuffertype) { CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4, CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型。 [更多...](#codecbuffertype) | +| [ShareMemTypes](#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内å˜ç±»åž‹ã€‚ [更多...](#sharememtypes) | +| [OmxIndexCodecExType](#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index。 [更多...](#omxindexcodecextype) | +| [OmxVideoExType](#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编ç 类型。 [更多...](#omxvideoextype) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [CodecCallbackTypeGet](#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 [更多...](#codeccallbacktypeget) | +| [CodecCallbackTypeRelease](#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 [更多...](#codeccallbacktyperelease) | +| [CodecComponentTypeGet](#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 [更多...](#codeccomponenttypeget) | +| [CodecComponentTypeRelease](#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 [更多...](#codeccomponenttyperelease) | +| [GetCodecComponentManager](#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 [更多...](#getcodeccomponentmanager) | +| [CodecComponentManagerRelease](#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 [更多...](#codeccomponentmanagerrelease) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| [CodecCallbackType::remote](#remote) | 指å‘HdfRemoteService的指针。 [更多...](#remote) | +| ( [CodecCallbackType::EventHandler](#eventhandler) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, enum OMX_EVENTTYPE event, struct [EventInfo](_event_info.md) \*info) | 事件上报。 [更多...](#eventhandler) | +| ( [CodecCallbackType::EmptyBufferDone](#emptybufferdone) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, int8_t \*appData, uint32_t appDataLen, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输入bufferç¼–ç 或者解ç 处ç†å®Œæ¯•ã€‚ [更多...](#emptybufferdone) | +| ( [CodecCallbackType::FillBufferDone](#fillbufferdone) )(struct [CodecCallbackType](_codec_callback_type.md) \*self, int8_t \*appData, uint32_t appDataLen, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输出buffer填充完毕。 [更多...](#fillbufferdone) | +| ( [CodecComponentType::GetComponentVersion](#getcomponentversion) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [CompVerInfo](_comp_ver_info.md) \*verInfo) | 获å–Codec组件版本å·ã€‚ [更多...](#getcomponentversion) | +| ( [CodecComponentType::SendCommand](#sendcommand) )(struct [CodecComponentType](_codec_component_type.md) \*self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t \*cmdData, uint32_t cmdDataLen) | å‘é€å‘½ä»¤ç»™ç»„件。 [更多...](#sendcommand) | +| ( [CodecComponentType::GetParameter](#getparameter) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t paramIndex, int8_t \*paramStruct, uint32_t paramStructLen) | 获å–组件å‚数设置。 [更多...](#getparameter) | +| ( [CodecComponentType::SetParameter](#setparameter) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*paramStruct, uint32_t paramStructLen) | 设置组件需è¦çš„å‚数。 [更多...](#setparameter) | +| ( [CodecComponentType::GetConfig](#getconfig) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 获å–组件的é…置结构。 [更多...](#getconfig) | +| ( [CodecComponentType::SetConfig](#setconfig) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 设置组件的é…置。 [更多...](#setconfig) | +| ( [CodecComponentType::GetExtensionIndex](#getextensionindex) )(struct [CodecComponentType](_codec_component_type.md) \*self, const char \*paramName, uint32_t \*indexType) | æ ¹æ®å—符串获å–组件的扩展索引。 [更多...](#getextensionindex) | +| ( [CodecComponentType::GetState](#getstate) )(struct [CodecComponentType](_codec_component_type.md) \*self, enum OMX_STATETYPE \*state) | 获å–组件的当å‰çŠ¶æ€ã€‚ [更多...](#getstate) | +| ( [CodecComponentType::ComponentTunnelRequest](#componenttunnelrequest) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE \*tunnelSetup) | 设置组件采用Tunnelæ–¹å¼é€šä¿¡ã€‚ [更多...](#componenttunnelrequest) | +| ( [CodecComponentType::UseBuffer](#usebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 指定组件端å£çš„buffer。 [更多...](#usebuffer) | +| ( [CodecComponentType::AllocateBuffer](#allocatebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | å‘组件申请端å£buffer。 [更多...](#allocatebuffer) | +| ( [CodecComponentType::FreeBuffer](#freebuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint32_t portIndex, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 释放buffer。 [更多...](#freebuffer) | +| ( [CodecComponentType::EmptyThisBuffer](#emptythisbuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解ç 输入待处ç†buffer。 [更多...](#emptythisbuffer) | +| ( [CodecComponentType::FillThisBuffer](#fillthisbuffer) )(struct [CodecComponentType](_codec_component_type.md) \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解ç 输出填充buffer。 [更多...](#fillthisbuffer) | +| ( [CodecComponentType::SetCallbacks](#setcallbacks) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [CodecCallbackType](_codec_callback_type.md) \*callback, int8_t \*appData, uint32_t appDataLen) | 设置Codec组件的回调函数。 [更多...](#setcallbacks) | +| ( [CodecComponentType::ComponentDeInit](#componentdeinit) )(struct [CodecComponentType](_codec_component_type.md) \*self) | 组件去åˆå§‹åŒ–。 [更多...](#componentdeinit) | +| ( [CodecComponentType::UseEglImage](#useeglimage) )(struct [CodecComponentType](_codec_component_type.md) \*self, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer, uint32_t portIndex, int8_t \*eglImage, uint32_t eglImageLen) | 使用已在EGLä¸ç”³è¯·çš„空间。 [更多...](#useeglimage) | +| ( [CodecComponentType::ComponentRoleEnum](#componentroleenum) )(struct [CodecComponentType](_codec_component_type.md) \*self, uint8_t \*role, uint32_t roleLen, uint32_t index) | 获å–组件角色。 [更多...](#componentroleenum) | + + +## **详细æè¿°** + +Codec模å—接å£å®šä¹‰ã€‚ + +Codec模å—涉åŠè‡ªå®šä¹‰ç±»åž‹ã€éŸ³è§†é¢‘编解ç 组件åˆå§‹åŒ–ã€å‚数设置ã€æ•°æ®çš„轮转和控制ç‰ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 + + +## **枚举类型说明** + + +### AudioSampleFormat + + +``` +enum AudioSampleFormat +``` + +**æ述:** + +æžšä¸¾éŸ³é¢‘é‡‡æ ·æ ¼å¼ã€‚ + +- 对于planarçš„é‡‡æ ·æ ¼å¼ï¼Œæ¯ä¸ªå£°é“çš„æ•°æ®æ˜¯ç‹¬ç«‹å˜å‚¨åœ¨dataä¸ã€‚ + +- 对于packedçš„é‡‡æ ·æ ¼å¼ï¼Œåªä½¿ç”¨ç¬¬ä¸€ä¸ªdata,æ¯ä¸ªå£°é“çš„æ•°æ®æ˜¯äº¤é”™å˜å‚¨çš„。 + +| 枚举值 | æè¿° | +| -------- | -------- | +| AUDIO_SAMPLE_FORMAT_S8 | 8bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S8P | 8bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U8 | 8bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U8P | 8bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S16 | 16bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S16P | 16bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U16 | 16bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U16P | 16bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S24 | 24bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S24P | 24bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U24 | 24bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U24P | 24bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S32 | 32bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S32P | 32bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U32 | 32bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U32P | 32bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S64 | 64bitä½å®½æœ‰ç¬¦å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_S64P | 64bitä½å®½æœ‰ç¬¦å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U64 | 64bitä½å®½æ— 符å·äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_U64P | 64bitä½å®½æ— 符å·éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_F32 | 32bitä½å®½æµ®ç‚¹åž‹äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_F32P | 64bitä½å®½æµ®ç‚¹åž‹éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_F64 | 64bitä½å®½åŒç²¾åº¦æµ®ç‚¹åž‹äº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FORMAT_F64P | 64bitä½å®½åŒç²¾åº¦æµ®ç‚¹åž‹éžäº¤ç»‡æ ·æœ¬ã€‚ | +| AUDIO_SAMPLE_FMT_U8 | æ— ç¬¦å·8ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_S16 | 带符å·16ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_S32 | 带符å·32ä½æ•´åž‹ï¼Œæ‰“åŒ…æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_FLOAT | æµ®ç‚¹åž‹ï¼Œæ‰“åŒ…æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_DOUBLE | åŒç²¾åº¦æµ®ç‚¹åž‹ï¼Œæ‰“åŒ…æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_U8P | æ— ç¬¦å·8ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_S16P | 带符å·16ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_S32P | 带符å·32ä½æ•´åž‹ï¼Œå¹³é¢æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_FLOATP | 浮点型,平é¢æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_DOUBLEP | åŒç²¾åº¦æµ®ç‚¹åž‹ï¼Œå¹³é¢æ ¼å¼ã€‚ | +| AUDIO_SAMPLE_FMT_INVALID | æ— æ•ˆé‡‡æ ·æ ¼å¼ã€‚ | + + +### AudioSampleRate + + +``` +enum AudioSampleRate +``` + +**æ述:** + +æžšä¸¾éŸ³é¢‘é‡‡æ ·çŽ‡ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AUD_SAMPLE_RATE_8000 | 8Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_12000 | 12Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_11025 | 11.025Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_16000 | 16Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_22050 | 22.050Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_24000 | 24Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_32000 | 32Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_44100 | 44.1Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_48000 | 48Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_64000 | 64Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_96000 | 96Ké‡‡æ ·çŽ‡ | +| AUD_SAMPLE_RATE_INVALID | æ— æ•ˆé‡‡æ ·çŽ‡ | + + +### AvCodecRole + + +``` +enum AvCodecRole +``` + +**æ述:** + +枚举音视频编解ç 组件类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| MEDIA_ROLETYPE_IMAGE_JPEG | 图åƒJPEG媒体类型 | +| MEDIA_ROLETYPE_VIDEO_AVC | 视频H.264媒体类型 | +| MEDIA_ROLETYPE_VIDEO_HEVC | 视频H.265媒体类型 | +| MEDIA_ROLETYPE_AUDIO_FIRST | 音频编解ç 器类型 | +| MEDIA_ROLETYPE_AUDIO_AAC | 音频AAC媒体类型 | +| MEDIA_ROLETYPE_AUDIO_G711A | 音频G711A媒体类型 | +| MEDIA_ROLETYPE_AUDIO_G711U | 音频G711U媒体类型 | +| MEDIA_ROLETYPE_AUDIO_G726 | 音频G726媒体类型 | +| MEDIA_ROLETYPE_AUDIO_PCM | 音频PCM媒体类型 | +| MEDIA_ROLETYPE_AUDIO_MP3 | 音频MP3媒体类型 | +| MEDIA_ROLETYPE_INVALID | æ— æ•ˆåª’ä½“ç±»åž‹ | + + +### CodecBufferType + + +``` +enum CodecBufferType +``` + +**æ述:** + +定义buffer类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CODEC_BUFFER_TYPE_INVALID | æ— æ•ˆbuffer类型 | +| CODEC_BUFFER_TYPE_VIRTUAL_ADDR | 虚拟地å€ç±»åž‹ | +| CODEC_BUFFER_TYPE_AVSHARE_MEM_FD | 共享内å˜ç±»åž‹ | +| CODEC_BUFFER_TYPE_HANDLE | handle类型 | +| CODEC_BUFFER_TYPE_DYNAMIC_HANDLE | 动æ€handle类型 | + + +### CodecCapsMask + + +``` +enum CodecCapsMask +``` + +**æ述:** + +枚举æ’放能力。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CODEC_CAP_ADAPTIVE_PLAYBACK | 自适应æ’放能力 | +| CODEC_CAP_SECURE_PLAYBACK | 安全æ’放能力 | +| CODEC_CAP_TUNNEL_PLAYBACK | 通é“æ’放能力 | +| CODEC_CAP_MULTI_PLANE | 视频图åƒå¹³é¢/音频通é“å¹³é¢èƒ½åŠ› | + + +### CodecProcessMode + + +``` +enum CodecProcessMode +``` + +**æ述:** + +枚举编解ç 处ç†æ¨¡å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PROCESS_BLOCKING_INPUT_BUFFER | åŒæ¥æ¨¡å¼è¾“å…¥buffer | +| PROCESS_BLOCKING_OUTPUT_BUFFER | åŒæ¥æ¨¡å¼è¾“出buffer | +| PROCESS_BLOCKING_CONTROL_FLOW | åŒæ¥æ¨¡å¼æŽ§åˆ¶æµ | +| PROCESS_NONBLOCKING_INPUT_BUFFER | 异æ¥æ¨¡å¼è¾“å…¥buffer | +| PROCESS_NONBLOCKING_OUTPUT_BUFFER | 异æ¥æ¨¡å¼è¾“出buffer | +| PROCESS_NONBLOCKING_CONTROL_FLOW | 异æ¥æ¨¡å¼æŽ§åˆ¶æµ | + + +### CodecType + + +``` +enum CodecType +``` + +**æ述:** + +枚举编解ç 的类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| VIDEO_DECODER | 视频解ç 类型 | +| VIDEO_ENCODER | 视频编ç 类型 | +| AUDIO_DECODER | 音频解ç 类型 | +| AUDIO_ENCODER | 音频编ç 类型 | +| INVALID_TYPE | æ— æ•ˆç±»åž‹ | + + +### OmxIndexCodecExType + + +``` +enum OmxIndexCodecExType +``` + +**æ述:** + +枚举Codec扩展index。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| OMX_IndexExtBufferTypeStartUnused | BufferType 扩展index | +| OMX_IndexParamSupportBufferType | SupportBuffer类型 | +| OMX_IndexParamUseBufferType | UseBuffer类型 | +| OMX_IndexParamGetBufferHandleUsage | GetBufferHandleUsage类型 | + + +### OmxVideoExType + + +``` +enum OmxVideoExType +``` + +**æ述:** + +枚举Codec扩展编ç 类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| OMX_VIDEO_CodingHEVC | HEVCç¼–ç 类型 | + + +### Profile + + +``` +enum Profile +``` + +**æ述:** + +枚举Codecè§„æ ¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| INVALID_PROFILE | æ— æ•ˆçš„è§„æ ¼ã€‚ | +| AAC_LC_PROFILE | AAC低å¤æ‚åº¦è§„æ ¼ã€‚ | +| AAC_MAIN_PROFILE | AACä¸»è§„æ ¼ã€‚ | +| AAC_HE_V1_PROFILE | AAC高效率和频带é‡çŽ°è§„æ ¼ï¼Œåˆç§°ä¸ºHEAAC,AAC+,或者AACPlusV1。 | +| AAC_HE_V2_PROFILE | AAC高效率和频带é‡çŽ°ä»¥åŠå˜é‡ç«‹ä½“å£°è§„æ ¼ï¼Œåˆç§°ä¸ºAAC++或者AACPlusV2。 | +| AAC_LD_PROFILE | AACä½Žå»¶è¿Ÿè§„æ ¼ã€‚ | +| AAC_ELD_PROFILE | AACå¢žå¼ºåž‹ä½Žå»¶è¿Ÿè§„æ ¼ã€‚ | +| AVC_BASELINE_PROFILE | H.264ä½Žè§„æ ¼ã€‚ | +| AVC_MAIN_PROFILE | H.264ä¸»è§„æ ¼ã€‚ | +| AVC_HIGH_PROFILE | H.264é«˜è§„æ ¼ã€‚ | +| HEVC_MAIN_PROFILE | H.265ä¸»è§„æ ¼ã€‚ | +| HEVC_MAIN_10_PROFILE | H.265 10æ¯”ç‰¹ä¸»è§„æ ¼ã€‚ | + + +### ShareMemTypes + + +``` +enum ShareMemTypes +``` + +**æ述:** + +枚举共享内å˜ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| READ_WRITE_TYPE | å¯è¯»å¯å†™çš„共享内å˜ç±»åž‹ | +| READ_ONLY_TYPE | å¯è¯»çš„共享内å˜ç±»åž‹ | + + +## **函数说明** + + +### CodecCallbackTypeGet() + + +``` +struct CodecCallbackType* CodecCallbackTypeGet (struct HdfRemoteService * remote) +``` + +**æ述:** + +实例化CodecCallbackType对象。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| remote | 输入å‚数,指å‘HdfRemoteService的指针。 | + +**返回:** + +实例化CodecCallbackType对象。 + +**Since:** + +3.1 + + +### CodecCallbackTypeRelease() + + +``` +void CodecCallbackTypeRelease (struct CodecCallbackType * instance) +``` + +**æ述:** + +释放CodecCallbackType对象。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| instance | 输入å‚数,指å‘CodecCallbackType实例的指针。 | + +**Since:** + +3.1 + + +### CodecComponentManagerRelease() + + +``` +void CodecComponentManagerRelease (void ) +``` + +**æ述:** + +释放CodecComponentManager对象。 + +**Since:** + +3.1 + + +### CodecComponentTypeGet() + + +``` +struct CodecComponentType* CodecComponentTypeGet (struct HdfRemoteService * remote) +``` + +**æ述:** + +实例化CodecComponentType对象。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| remote | 输入å‚数,指å‘RemoteService的指针。 | + +**返回:** + +实例化的CodecComponentType对象。 + +**Since:** + +3.1 + + +### CodecComponentTypeRelease() + + +``` +void CodecComponentTypeRelease (struct CodecComponentType * instance) +``` + +**æ述:** + +释放CodecComponentType对象。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| instance | 输入å‚数,指å‘CodecComponentType实例的指针。 | + +**Since:** + +3.1 + + +### GetCodecComponentManager() + + +``` +struct CodecComponentManager* GetCodecComponentManager (void ) +``` + +**æ述:** + +实例化CodecComponentManager对象。 + +**返回:** + +实例化的CodecComponentManager对象。 + +**Since:** + +3.1 + + +## **å˜é‡è¯´æ˜Ž** + + +### AllocateBuffer + + +``` +int32_t(* CodecComponentType::AllocateBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +å‘组件申请端å£buffer。 + +å‘组件申请分é…æ–°çš„buffer,æ¤æŽ¥å£åœ¨ä»¥ä¸‹æƒ…况下使用: + +- 当组件处于OMX_StateLoaded状æ€ï¼Œå¹¶ä¸”用户已ç»å‘组件å‘é€OMX_StateIdle状æ€è½¬æ¢è¯·æ±‚。 + +- 当组件处于OMX_StateWaitForResources状æ€ï¼Œæ‰€éœ€çš„资æºå¯ç”¨ï¼Œå¹¶ä¸”组件已准备好进入OMX_StateIdle状æ€ã€‚ + +- 在去使能端å£ä¸Šï¼Œç»„件处于OMX_StateExecutingã€OMX_StatePause或OMX_StateIdle状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| portIndex | 输入å‚数,指定的组件端å£ã€‚ | +| buffer | 输入输出å‚数,指å‘è¦ç”³è¯·çš„buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | + +**返回:** + +HDF_SUCCESS 表示申请bufferæˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œç”³è¯·buffer失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œç”³è¯·buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œç”³è¯·buffer失败。 + +**Since:** + +3.1 + + +### ComponentDeInit + + +``` +int32_t(* CodecComponentType::ComponentDeInit) (struct CodecComponentType *self) +``` + +**æ述:** + +组件去åˆå§‹åŒ–。 + +调用æ¤æŽ¥å£ä½¿ç»„件去åˆå§‹åŒ–,当组件处于OMX_StateLoaded状æ€æ—¶ï¼Œå°†ç›´æŽ¥å…³é—组件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | + +**返回:** + +HDF_SUCCESS 表示去åˆå§‹åŒ–æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒåŽ»åˆå§‹åŒ–失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒåŽ»åˆå§‹åŒ–失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒåŽ»åˆå§‹åŒ–失败。 + +**Since:** + +3.1 + + +### ComponentRoleEnum + + +``` +int32_t(* CodecComponentType::ComponentRoleEnum) (struct CodecComponentType *self, uint8_t *role, uint32_t roleLen, uint32_t index) +``` + +**æ述:** + +获å–组件角色。 + +æ ¹æ®ç»„件角色索引获å–对应组件角色。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| role | 输出å‚数,角色å称。 | +| roleLen | 输入å‚数,roleå—节数。 | +| index | 输入å‚数,角色的索引,一个组件å¯èƒ½æ”¯æŒå¤šç§è§’色。 | + +**返回:** + +HDF_SUCCESS 表示获å–角色æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–角色失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–角色失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–角色失败。 + +**Since:** + +3.1 + + +### ComponentTunnelRequest + + +``` +int32_t(* CodecComponentType::ComponentTunnelRequest) (struct CodecComponentType *self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE *tunnelSetup) +``` + +**æ述:** + +设置组件采用Tunnelæ–¹å¼é€šä¿¡ã€‚ + +当组件处于OMX_StateLoaded 状æ€æ—¶ï¼Œç”¨æˆ·é€šè¿‡è°ƒç”¨æ¤æŽ¥å£ç¡®å®šç»„件是å¦å¯ä»¥è¿›è¡ŒTunnelä¼ è¾“ï¼Œå¦‚æžœå¯ä»¥åˆ™è®¾ç½®ç»„件的Tunnelä¼ è¾“ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| port | 输入å‚数,组件设置的端å£ã€‚ | +| tunneledComp | 输入å‚数,组件的tunnel handle。 | +| tunneledPort | 输入å‚数,组件用æ¥Tunnel通信的端å£ã€‚ | +| tunnelSetup | 输入输出å‚数,指å‘Tunnel设置的结构体**OMX_TUNNELSETUPTYPE**指针。 | + +**返回:** + +HDF_SUCCESS 表示设置æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œè®¾ç½®å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œè®¾ç½®å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œè®¾ç½®å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### EmptyBufferDone + + +``` +int32_t(* CodecCallbackType::EmptyBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, const struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +上报输入bufferç¼–ç 或者解ç 处ç†å®Œæ¯•ã€‚ + +组件è¿è¡Œè¿‡ç¨‹ä¸å‘上报告输入bufferå·²ç»ä½¿ç”¨å®Œæ¯•ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的callback指针。 | +| appData | 输入å‚数,上层数æ®ï¼Œé€šå¸¸æ˜¯è®¾ç½®å›žè°ƒæ—¶ç»™å…¥çš„上层实例。 | +| appDataLen | 输入å‚数,appDataå—节数。 | +| buffer | 输入å‚数,已ç»å¤„ç†å®Œæ¯•çš„输入bufferä¿¡æ¯[OmxCodecBuffer](_omx_codec_buffer.md)。 | + +**返回:** + +HDF_SUCCESS 表示上报æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### EmptyThisBuffer + + +``` +int32_t(* CodecComponentType::EmptyThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +编解ç 输入待处ç†buffer。 + +æ¤æŽ¥å£åœ¨ç»„件处于OMX_StateExecuting或者OMX_StatePause状æ€æ—¶è°ƒç”¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| buffer | 输入å‚数,指å‘[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示输入bufferæˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œè¾“å…¥buffer失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œè¾“å…¥buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œè¾“å…¥buffer失败。 + +**Since:** + +3.1 + + +### EventHandler + + +``` +int32_t(* CodecCallbackType::EventHandler) (struct CodecCallbackType *self, enum OMX_EVENTTYPE event, struct EventInfo *info) +``` + +**æ述:** + +事件上报。 + +组件è¿è¡Œè¿‡ç¨‹ä¸å‘上报告错误事件ã€å‘½ä»¤å®Œæˆäº‹ä»¶ã€ç«¯å£è®¾ç½®æ›´æ”¹äº‹ä»¶ç‰ã€‚ + +- 当eEvent为OMX_EventCmdComplete,eventData为NULL,data1æ•°æ®ä¸ºOMX_COMMANDTYPE,æ¤æ—¶ï¼Œå½“data1为OMX_CommandStateSet,data2表示状æ€ï¼Œå…¶å®ƒæƒ…况下,data2表示端å£ã€‚ + +- 当event为OMX_EventError时,data1表示错误ç ,data2å’ŒeventData都为0。 + +- 当event为OMX_EventMark时,data1å’Œdata2都为0,eventData指å‘mark指针。 + +- 当event为OMX_EventPortSettingsChanged时,data1表示端å£ï¼Œdata2å’ŒeventData为0。 + +- 当event为OMX_EventBufferFlag时,data1表示端å£ï¼Œdata2表示flag,eventData为0。 + +- 当event为OMX_EventResourcesAcquired或OMX_EventDynamicResourcesAvailable时,data1ã€data2å’ŒeventData都为0。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的callback指针。 | +| event | 输入å‚数,è¦é€šçŸ¥çš„事件类型,详è§**OMX_EVENTTYPE**。 | +| info | 输入å‚数,指å‘事件上报æºå¸¦çš„ä¿¡æ¯æŒ‡é’ˆï¼Œè¯¦è§[EventInfo](_event_info.md)。 | + +**返回:** + +HDF_SUCCESS 表示事件上报æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œäº‹ä»¶ä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œäº‹ä»¶ä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œäº‹ä»¶ä¸ŠæŠ¥å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### FillBufferDone + + +``` +int32_t(* CodecCallbackType::FillBufferDone) (struct CodecCallbackType *self, int8_t *appData, uint32_t appDataLen, struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +上报输出buffer填充完毕。 + +组件è¿è¡Œè¿‡ç¨‹ä¸å‘上报告输出bufferå·²ç»å¡«å……完毕。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的callback指针。 | +| appData | 输入å‚数,上层数æ®ï¼Œé€šå¸¸æ˜¯è®¾ç½®å›žè°ƒæ—¶ç»™å…¥çš„上层实例。 | +| appDataLen | 输入å‚数,appDataå—节数。 | +| buffer | 输入å‚数,已ç»å¡«å……完毕的bufferä¿¡æ¯[OmxCodecBuffer](_omx_codec_buffer.md)。 | + +**返回:** + +HDF_SUCCESS 表示上报æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œä¸ŠæŠ¥å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### FillThisBuffer + + +``` +int32_t(* CodecComponentType::FillThisBuffer) (struct CodecComponentType *self, const struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +编解ç 输出填充buffer。 + +æ¤æŽ¥å£åœ¨ç»„件处于OMX_StateExecuting或者OMX_StatePause状æ€æ—¶è°ƒç”¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| buffer | 输入å‚数,指å‘[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示填充bufferæˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œå¡«å……buffer失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œå¡«å……buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œå¡«å……buffer失败。 + +**Since:** + +3.1 + + +### FreeBuffer + + +``` +int32_t(* CodecComponentType::FreeBuffer) (struct CodecComponentType *self, uint32_t portIndex, const struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +释放buffer。 + +æ¤æŽ¥å£åœ¨ä»¥ä¸‹æƒ…况下使用: + +- 当组件处于OMX_StateIdle状æ€ï¼Œå¹¶ä¸”å·²ç»å‘组件å‘é€OMX_StateLoaded状æ€è½¬æ¢è¯·æ±‚。 + +- 在去使能端å£ä¸Šï¼Œç»„件处于OMX_StateExecutingã€OMX_StatePause或OMX_StateIdle时调用。 + +- æ¤æŽ¥å£è°ƒç”¨å¯éšæ—¶è¿›è¡Œï¼Œä½†æ˜¯å¦‚果未在上述情况下执行,å¯èƒ½ä¼šå¯¼è‡´ç»„件上报OMX_ErrorPortUnpopulated事件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| portIndex | 输入å‚数,指定的组件端å£ã€‚ | +| buffer | 输入å‚数,指å‘[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | + +**返回:** + +HDF_SUCCESS 表示释放bufferæˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œé‡Šæ”¾buffer失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œé‡Šæ”¾buffer失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œé‡Šæ”¾buffer失败。 + +**Since:** + +3.1 + + +### GetComponentVersion + + +``` +int32_t(* CodecComponentType::GetComponentVersion) (struct CodecComponentType *self, struct CompVerInfo *verInfo) +``` + +**æ述:** + +获å–Codec组件版本å·ã€‚ + +通过查询组件,返回组件版本信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| verInfo | 输出å‚数,指å‘组件版本信æ¯çš„指针,详è§[CompVerInfo](_comp_ver_info.md)。 | + +**返回:** + +HDF_SUCCESS 表示获å–版本å·æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–版本å·å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–版本å·å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–版本å·å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### GetConfig + + +``` +int32_t(* CodecComponentType::GetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) +``` + +**æ述:** + +获å–组件的é…置结构。 + +åŠ è½½ç»„ä»¶åŽå¯ä»¥éšæ—¶è°ƒç”¨æ¤æŽ¥å£èŽ·å–组件的é…置。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| index | 输入å‚数,待填充结构的索引,详è§**OMX_INDEXTYPE**。 | +| cfgStruct | 输入输出å‚数,指å‘由组件填充的应用程åºåˆ†é…的结构体指针。 | +| cfgStructLen | 输入å‚æ•°ï¼Œä¸Šå±‚ä¼ å…¥çš„cfgStructå—节数。 | + +**返回:** + +HDF_SUCCESS 表示获å–é…ç½®æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–é…置失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–é…置失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–é…置失败。 + +**Since:** + +3.1 + + +### GetExtensionIndex + + +``` +int32_t(* CodecComponentType::GetExtensionIndex) (struct CodecComponentType *self, const char *paramName, uint32_t *indexType) +``` + +**æ述:** + +æ ¹æ®å—符串获å–组件的扩展索引。 + +将扩展å—符串转æ¢ä¸ºOpenmax IL结构索引。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| paramName | 输入å‚数,组件用æ¥è½¬æ¢ä¸ºé…置索引的å—符串。 | +| indexType | 输出å‚数,由paramName转æ¢çš„é…置索引,详è§**OMX_INDEXTYPE**。 | + +**返回:** + +HDF_SUCCESS 表示获å–扩展索引æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–扩展索引失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–扩展索引失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–扩展索引失败。 + +**Since:** + +3.1 + + +### GetParameter + + +``` +int32_t(* CodecComponentType::GetParameter) (struct CodecComponentType *self, uint32_t paramIndex, int8_t *paramStruct, uint32_t paramStructLen) +``` + +**æ述:** + +获å–组件å‚数设置。 + +当组件处于除了OMX_StateInvalid(组件状æ€å¼‚常)之外的其他状æ€ï¼Œç”¨æˆ·å¯é€šè¿‡æ¤æŽ¥å£èŽ·å–组件å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| paramIndex | 输入å‚数,待填充结构的索引,详è§**OMX_INDEXTYPE**。 | +| paramStruct | 输入输出å‚数,指å‘由组件填充的应用程åºåˆ†é…的结构体指针。 | +| paramStructLen | 输入å‚数,paramStructå—节数。 | + +**返回:** + +HDF_SUCCESS 表示获å–å‚æ•°æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–å‚数失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–å‚数失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–å‚数失败。 + +**Since:** + +3.1 + + +### GetState + + +``` +int32_t(* CodecComponentType::GetState) (struct CodecComponentType *self, enum OMX_STATETYPE *state) +``` + +**æ述:** + +获å–组件的当å‰çŠ¶æ€ã€‚ + +用户å¯è°ƒç”¨æ¤æŽ¥å£èŽ·å–组件的当å‰çŠ¶æ€ï¼Œç»„件状æ€è¯¦è§**OMX_STATETYPE**。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| state | 输出å‚数,指å‘获å–到的状æ€æŒ‡é’ˆï¼Œç»„件状æ€è¯¦è§**OMX_STATETYPE**。 | + +**返回:** + +HDF_SUCCESS 表示获å–状æ€æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–状æ€å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–状æ€å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–状æ€å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### remote + + +``` +struct HdfRemoteService* CodecCallbackType::remote +``` + +**æ述:** + +指å‘HdfRemoteService的指针。 + +**Since:** + +3.1 + + +### SendCommand + + +``` +int32_t(* CodecComponentType::SendCommand) (struct CodecComponentType *self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t *cmdData, uint32_t cmdDataLen) +``` + +**æ述:** + +å‘é€å‘½ä»¤ç»™ç»„件。 + +å‘é€å‘½ä»¤ç»™ç»„件,当命令为设置状æ€æ—¶ï¼Œä¼šæœ‰äº‹ä»¶å›žè°ƒé€šçŸ¥ç»“果给上层,其他命令则没有事件上报。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| cmd | 输入å‚数,组件è¦æ‰§è¡Œçš„命令,详è§**OMX_COMMANDTYPE**。 | +| param | 输入å‚数,组件è¦æ‰§è¡Œçš„命令æºå¸¦çš„å‚数。<br/>- 当cmd为OMX_CommandStateSet时,param的值详è§**OMX_STATETYPE**。<br/>- 当cmd为OMX_CommandFlushã€OMX_CommandPortDisableã€OMX_CommandPortEnableã€OMX_CommandMarkBuffer时,paramä¸ºç›®æ ‡ç«¯å£ã€‚ | +| cmdData | 输入å‚数,当cmd为OMX_CommandMarkBuffer时,指å‘OMX_MARKTYPE结构体指针。 | +| cmdDataLen | 输入å‚æ•°ï¼Œä¸Šå±‚ä¼ é€’çš„cmdDataå—节数。 | + +**返回:** + +HDF_SUCCESS 表示å‘é€å‘½ä»¤æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œå‘é€å‘½ä»¤å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œå‘é€å‘½ä»¤å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œå‘é€å‘½ä»¤å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### SetCallbacks + + +``` +int32_t(* CodecComponentType::SetCallbacks) (struct CodecComponentType *self, struct CodecCallbackType *callback, int8_t *appData, uint32_t appDataLen) +``` + +**æ述:** + +设置Codec组件的回调函数。 + +当组件处于OMX_StateLoaded状æ€æ—¶ï¼Œä½¿ç”¨æ¤å›žè°ƒå‡½æ•°å‘上通知事件以åŠä¸ŠæŠ¥å¯ç”¨çš„输入输出信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| callback | 输入å‚数,指å‘回调函数[CodecCallbackType](_codec_callback_type.md)对象指针。 | +| appData | 输入å‚数,指å‘应用程åºå®šä¹‰çš„值的指针,该值将在回调期间返回。 | +| appDataLen | 输入å‚æ•°ï¼Œä¸Šå±‚ä¼ é€’çš„appDataå—节数。 | + +**返回:** + +HDF_SUCCESS 表示设置回调æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œè®¾ç½®å›žè°ƒå¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œè®¾ç½®å›žè°ƒå¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œè®¾ç½®å›žè°ƒå¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### SetConfig + + +``` +int32_t(* CodecComponentType::SetConfig) (struct CodecComponentType *self, uint32_t index, int8_t *cfgStruct, uint32_t cfgStructLen) +``` + +**æ述:** + +设置组件的é…置。 + +åŠ è½½ç»„ä»¶åŽå¯ä»¥éšæ—¶è°ƒç”¨æ¤æŽ¥å£è®¾ç½®ç»„件的é…置。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| index | 输入å‚数,è¦è®¾ç½®çš„结构索引,详è§**OMX_INDEXTYPE**。 | +| cfgStruct | 输入å‚数,指å‘组件用于åˆå§‹åŒ–的应用程åºåˆ†é…结构的指针。 | +| cfgStructLen | 输入å‚数,cfgStructå—节数。 | + +**返回:** + +HDF_SUCCESS 表示设置é…ç½®æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œè®¾ç½®å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œè®¾ç½®å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œè®¾ç½®å¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### SetParameter + + +``` +int32_t(* CodecComponentType::SetParameter) (struct CodecComponentType *self, uint32_t index, int8_t *paramStruct, uint32_t paramStructLen) +``` + +**æ述:** + +设置组件需è¦çš„å‚数。 + +当组件处于OMX_StateLoadedã€OMX_StateWaitForResources状æ€æˆ–者端å£æ˜¯åŽ»ä½¿èƒ½çŠ¶æ€ï¼Œç”¨æˆ·å¯é€šè¿‡æ¤æŽ¥å£è®¾ç½®ç»„件å‚数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| index | 输入å‚数,è¦è®¾ç½®çš„结构索引,详è§**OMX_INDEXTYPE**。 | +| paramStruct | 输入å‚数,指å‘组件用于åˆå§‹åŒ–的应用程åºåˆ†é…结构的指针。 | +| paramStructLen | 输入å‚数,paramStructå—节数。 | + +**返回:** + +HDF_SUCCESS 表示设置å‚æ•°æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œè®¾ç½®å‚数失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œè®¾ç½®å‚数失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œè®¾ç½®å‚数失败。 + +**Since:** + +3.1 + + +### UseBuffer + + +``` +int32_t(* CodecComponentType::UseBuffer) (struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) +``` + +**æ述:** + +指定组件端å£çš„buffer。 + +æ¤æŽ¥å£åœ¨ä»¥ä¸‹æƒ…况下使用: + +- 当组件处于OMX_StateLoaded状æ€ï¼Œå¹¶ä¸”用户已ç»å‘组件å‘é€OMX_StateIdle状æ€è½¬æ¢è¯·æ±‚。 + +- 当组件处于OMX_StateWaitForResources状æ€ï¼Œæ‰€éœ€çš„资æºå¯ç”¨ï¼Œå¹¶ä¸”组件已准备好进入OMX_StateIdle状æ€ã€‚ + +- 在去使能端å£ä¸Šï¼Œç»„件处于OMX_StateExecutingã€OMX_StatePause或OMX_StateIdle状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| portIndex | 输入å‚数,指定的组件端å£ã€‚ | +| buffer | 输入输出å‚数,指å‘è¦ä½¿ç”¨çš„buffer结构体[OmxCodecBuffer](_omx_codec_buffer.md)指针。 | + +**返回:** + +HDF_SUCCESS 表示指定æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒæŒ‡å®šå¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒæŒ‡å®šå¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒæŒ‡å®šå¤±è´¥ã€‚ + +**Since:** + +3.1 + + +### UseEglImage + + +``` +int32_t(* CodecComponentType::UseEglImage) (struct CodecComponentType *self, struct OmxCodecBuffer *buffer, uint32_t portIndex, int8_t *eglImage, uint32_t eglImageLen) +``` + +**æ述:** + +使用已在EGLä¸ç”³è¯·çš„空间。 + +æ¤æŽ¥å£åœ¨ä»¥ä¸‹æƒ…况下使用: + +- 当组件处于OMX_StateLoaded状æ€ï¼Œå¹¶ä¸”å·²ç»å‘组件å‘é€OMX_StateIdle状æ€è½¬æ¢è¯·æ±‚。 + +- 当组件处于OMX_StateWaitForResources状æ€ï¼Œæ‰€éœ€çš„资æºå¯ç”¨ï¼Œå¹¶ä¸”组件已准备好进入OMX_StateIdle状æ€ã€‚ + +- 在去使能端å£ä¸Šï¼Œç»„件处于OMX_StateExecutingã€OMX_StatePause或OMX_StateIdle状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| self | 输入å‚数,指å‘è¦æ“作的Codec组件指针。 | +| buffer | 输入输出å‚数,指å‘[OmxCodecBuffer](_omx_codec_buffer.md)结构体的指针。 | +| portIndex | 输入å‚数,指定的组件端å£ã€‚ | +| eglImage | 输入å‚数,EGL申请的图åƒæŒ‡é’ˆã€‚ | +| eglImageLen | 输入å‚数,eglImageå—节数。 | + +**返回:** + +HDF_SUCCESS 表示使用æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œä½¿ç”¨å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œä½¿ç”¨å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œä½¿ç”¨å¤±è´¥ã€‚ + +**Since:** + +3.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md b/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md new file mode 100644 index 0000000000000000000000000000000000000000..adf3edf8dd060694cd88c7d590360ca591ec7527 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_callback_type.md @@ -0,0 +1,38 @@ +# CodecCallbackType + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [remote](_codec.md#remote) | 指å‘HdfRemoteService的指针。 [更多...](_codec.md#remote) | +| ( [EventHandler](_codec.md#eventhandler) )(struct CodecCallbackType \*self, enum OMX_EVENTTYPE event, struct [EventInfo](_event_info.md) \*info) | 事件上报。 [更多...](_codec.md#eventhandler) | +| ( [EmptyBufferDone](_codec.md#emptybufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输入bufferç¼–ç 或者解ç 处ç†å®Œæ¯•ã€‚ [更多...](_codec.md#emptybufferdone) | +| ( [FillBufferDone](_codec.md#fillbufferdone) )(struct CodecCallbackType \*self, int8_t \*appData, uint32_t appDataLen, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 上报输出buffer填充完毕。 [更多...](_codec.md#fillbufferdone) | + + +## **详细æè¿°** + +Codec回调接å£å®šä¹‰ã€‚ + +æ供了以下3ç§å›žè°ƒå‡½æ•°: + +- 组件错误事件ã€å‘½ä»¤å®Œæˆäº‹ä»¶ã€ç«¯å£è®¾ç½®ç‰äº‹ä»¶å›žè°ƒï¼Œè¯¦è§EventHandler。 + +- 输入端å£å¤„ç†å®Œbuffer回调,详è§EmptyBufferDone。 + +- 输出端å£å¡«å……完buffer回调,详è§FillBufferDone。 通过以下两ç§æ–¹å¼æ³¨å†Œå›žè°ƒ: + +- 创建组件时,通过CreateComponent方法。 + +- 当组件处于OMX_StateLoaded状æ€æ—¶ï¼Œé€šè¿‡SetCallbacks方法注册回调。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md b/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md new file mode 100644 index 0000000000000000000000000000000000000000..f8900208d56a534c34c0204d6d8124024c4fc9b6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_comp_capability.md @@ -0,0 +1,155 @@ +# CodecCompCapability + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [role](#role) | 媒体类型。 | +| [type](#type) | 编解ç 类型。 | +| [compName](#compname) [[NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17)] | 编解ç 组件å称。 | +| [supportProfiles](#supportprofiles) [[PROFILE_NUM](_codec.md#gaab6353cb3662bdc672ae8ab90df529ce)] | 支æŒçš„profiles,详è§[Profile](_codec.md#profile)。 | +| [maxInst](#maxinst) | 最大实例。 | +| [isSoftwareCodec](#issoftwarecodec) | 软件编解ç 还是硬件编解ç 。 | +| [processModeMask](#processmodemask) | 编解ç 处ç†æ¨¡å¼æŽ©ç ,详è§[CodecProcessMode](_codec.md#codecprocessmode)。 | +| [capsMask](#capsmask) | 编解ç æ’放能力掩ç ,详è§[CodecCapsMask](_codec.md#codeccapsmask)。 | +| [bitRate](#bitrate) | 支æŒçš„ç 率范围。 | +| [port](#port) | 支æŒçš„音视频编解ç 能力。 | + + +## **详细æè¿°** + +定义Codec编解ç 能力。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### bitRate + + +``` +RangeValue CodecCompCapability::bitRate +``` + +**æ述:** + +支æŒçš„ç 率范围 + + +### capsMask + + +``` +uint32_t CodecCompCapability::capsMask +``` + +**æ述:** + +编解ç æ’放能力掩ç ,详è§[CodecCapsMask](_codec.md#codeccapsmask). + + +### compName + + +``` +char CodecCompCapability::compName[NAME_LENGTH] +``` + +**æ述:** + +编解ç 组件å称 + + +### isSoftwareCodec + + +``` +bool CodecCompCapability::isSoftwareCodec +``` + +**æ述:** + +软件编解ç 还是硬件编解ç + + +### maxInst + + +``` +int32_t CodecCompCapability::maxInst +``` + +**æ述:** + +最大实例 + + +### port + + +``` +PortCap CodecCompCapability::port +``` + +**æ述:** + +支æŒçš„音视频编解ç 能力 + + +### processModeMask + + +``` +int32_t CodecCompCapability::processModeMask +``` + +**æ述:** + +编解ç 处ç†æ¨¡å¼æŽ©ç ,详è§[CodecProcessMode](_codec.md#codecprocessmode). + + +### role + + +``` +AvCodecRole CodecCompCapability::role +``` + +**æ述:** + +媒体类型 + + +### supportProfiles + + +``` +int32_t CodecCompCapability::supportProfiles[PROFILE_NUM] +``` + +**æ述:** + +支æŒçš„profiles,详è§[Profile](_codec.md#profile) + + +### type + + +``` +CodecType CodecCompCapability::type +``` + +**æ述:** + +编解ç 类型 diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md b/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md new file mode 100644 index 0000000000000000000000000000000000000000..22b2d95f61a7a6529fdf473dcec84ed2a8bedd22 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_component_manager.md @@ -0,0 +1,148 @@ +# CodecComponentManager + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ([GetComponentNum](#getcomponentnum) )() | 获å–Codec编解ç 组件数é‡ã€‚ [更多...](#getcomponentnum) | +| ( [GetComponentCapabilityList](#getcomponentcapabilitylist) )([CodecCompCapability](_codec_comp_capability.md) \*capList, int32_t count) | 获å–编解ç 能力集表。 [更多...](#getcomponentcapabilitylist) | +| ( [CreateComponent](#createcomponent) )(struct [CodecComponentType](_codec_component_type.md) \*\*component, char \*compName, void \*appData, int32_t appDataSize, struct [CodecCallbackType](_codec_callback_type.md) \*callbacks) | 创建Codec组件实例。 [更多...](#createcomponent) | +| ( [DestroyComponent](#destroycomponent))(struct [CodecComponentType](_codec_component_type.md) \*component) | 销æ¯ç»„件实例。 [更多...](#destroycomponent) | + + +## **详细æè¿°** + +Codec组件管ç†ç±»æŽ¥å£å®šä¹‰ã€‚ + +主è¦æ供以下功能: + +- 获å–Codec编解ç 组件数é‡ä»¥åŠç¼–解ç 能力集表。 + +- 创建/销æ¯Codec组件。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CreateComponent + + +``` +int32_t(* CodecComponentManager::CreateComponent) (struct CodecComponentType **component, char *compName, void *appData, int32_t appDataSize, struct CodecCallbackType *callbacks) +``` + +**æ述:** + +创建Codec组件实例。 + +æ ¹æ®ç»„件å称创建Codec组件实例。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| component | 输出å‚数,指å‘Codec组件的指针。 | +| compName | 输入å‚数,组件å称。 | +| appData | 输入å‚数,指å‘应用程åºå®šä¹‰çš„值的指针,该值将在回调期间返回。 | +| appDataSize | 输入å‚数,appDataå—节数。 | +| callbacks | 输入å‚数,回调接å£ï¼ŒæŒ‡å‘OMX_CALLBACKTYPE结构的指针,详è§[CodecCallbackType](_codec_callback_type.md)。 | + +**返回:** + +HDF_SUCCESS 表示创建组件æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œåˆ›å»ºç»„ä»¶å¤±è´¥ã€‚ + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œåˆ›å»ºç»„ä»¶å¤±è´¥ã€‚ + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œåˆ›å»ºç»„件失败。 + + +### DestroyComponent + + +``` +int32_t(* CodecComponentManager::DestroyComponent) (struct CodecComponentType *component) +``` + +**æ述:** + +销æ¯ç»„件实例。 + +销æ¯æŒ‡å®šçš„Codec组件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| component | 输入å‚数,需è¦é”€æ¯çš„Codec组件。 | + +**返回:** + +HDF_SUCCESS 表示销æ¯ç»„件æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼Œé”€æ¯ç»„件失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼Œé”€æ¯ç»„件失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼Œé”€æ¯ç»„件失败。 + + +### GetComponentCapabilityList + + +``` +int32_t(* CodecComponentManager::GetComponentCapabilityList) (CodecCompCapability *capList, int32_t count) +``` + +**æ述:** + +获å–编解ç 能力集表。 + +用户å¯é€šè¿‡æ¤æŽ¥å£äº†è§£Codec模å—æ供了哪些编解ç 能力,对应的能力体现在[CodecCompCapability](_codec_comp_capability.md)结构体。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| capList | 输出å‚数,返回全部组件的能力集表[CodecCompCapability](_codec_comp_capability.md)。 | +| count | 输入å‚数,编解ç 组件数é‡ï¼Œç”±[GetComponentNum](#getcomponentnum)获得。 | + +**返回:** + +HDF_SUCCESS 表示获å–能力集表æˆåŠŸã€‚ + +HDF_ERR_INVALID_PARAM 表示å‚æ•°æ— æ•ˆï¼ŒèŽ·å–能力集表失败。 + +HDF_ERR_INVALID_OBJECT è¡¨ç¤ºå¯¹è±¡æ— æ•ˆï¼ŒèŽ·å–能力集表失败。 + +HDF_ERR_MALLOC_FAIL 表示申请内å˜å¤±è´¥ï¼ŒèŽ·å–能力集表失败。 + + +### GetComponentNum + + +``` +int32_t(* CodecComponentManager::GetComponentNum) () +``` + +**æ述:** + +获å–Codec编解ç 组件数é‡ã€‚ + +通过æ¤æŽ¥å£èŽ·å–Codec编解ç 组件数é‡ï¼Œç”¨æ¥èŽ·å–全部编解ç 能力集。 + +**返回:** + +Codec编解ç 组件数é‡ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md b/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md new file mode 100644 index 0000000000000000000000000000000000000000..0850d4c66221b70819644d1f2d693e094c82d1ed --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_codec_component_type.md @@ -0,0 +1,54 @@ +# CodecComponentType + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [GetComponentVersion](_codec.md#getcomponentversion) )(struct CodecComponentType \*self, struct [CompVerInfo](_comp_ver_info.md) \*verInfo) | 获å–Codec组件版本å·ã€‚ [更多...](_codec.md#getcomponentversion) | +| ( [SendCommand](_codec.md#sendcommand) )(struct CodecComponentType \*self, enum OMX_COMMANDTYPE cmd, uint32_t param, int8_t \*cmdData, uint32_t cmdDataLen) | å‘é€å‘½ä»¤ç»™ç»„件。 [更多...](_codec.md#sendcommand) | +| ( [GetParameter](_codec.md#getparameter) )(struct CodecComponentType \*self, uint32_t paramIndex, int8_t \*paramStruct, uint32_t paramStructLen) | 获å–组件å‚数设置。 [更多...](_codec.md#getparameter) | +| ( [SetParameter](_codec.md#setparameter) )(struct CodecComponentType \*self, uint32_t index, int8_t \*paramStruct, uint32_t paramStructLen) | 设置组件需è¦çš„å‚数。 [更多...](_codec.md#setparameter) | +| ( [GetConfig](_codec.md#getconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 获å–组件的é…置结构。 [更多...](_codec.md#getconfig) | +| ( [SetConfig](_codec.md#setconfig) )(struct CodecComponentType \*self, uint32_t index, int8_t \*cfgStruct, uint32_t cfgStructLen) | 设置组件的é…置。 [更多...](_codec.md#setconfig) | +| ( [GetExtensionIndex](_codec.md#getextensionindex) )(struct CodecComponentType \*self, const char \*paramName, uint32_t \*indexType) | æ ¹æ®å—符串获å–组件的扩展索引。 [更多...](_codec.md#getextensionindex) | +| ( [GetState](_codec.md#getstate) )(struct CodecComponentType \*self, enum OMX_STATETYPE \*state) | 获å–组件的当å‰çŠ¶æ€ã€‚ [更多...](_codec.md#getstate) | +| ( [ComponentTunnelRequest](_codec.md#componenttunnelrequest) )(struct CodecComponentType \*self, uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, struct OMX_TUNNELSETUPTYPE \*tunnelSetup) | 设置组件采用Tunnelæ–¹å¼é€šä¿¡ã€‚ [更多...](_codec.md#componenttunnelrequest) | +| ( [UseBuffer](_codec.md#usebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 指定组件端å£çš„buffer。 [更多...](_codec.md#usebuffer) | +| ( [AllocateBuffer](_codec.md#allocatebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | å‘组件申请端å£buffer。 [更多...](_codec.md#allocatebuffer) | +| ( [FreeBuffer](_codec.md#freebuffer) )(struct CodecComponentType \*self, uint32_t portIndex, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 释放buffer。 [更多...](_codec.md#freebuffer) | +| ( [EmptyThisBuffer](_codec.md#emptythisbuffer) )(struct CodecComponentType \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解ç 输入待处ç†buffer。 [更多...](_codec.md#emptythisbuffer) | +| ( [FillThisBuffer](_codec.md#fillthisbuffer) )(struct CodecComponentType \*self, const struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer) | 编解ç 输出填充buffer。 [更多...](_codec.md#fillthisbuffer) | +| ( [SetCallbacks](_codec.md#setcallbacks) )(struct CodecComponentType \*self, struct [CodecCallbackType](_codec_callback_type.md) \*callback, int8_t \*appData, uint32_t appDataLen) | 设置Codec组件的回调函数。 [更多...](_codec.md#setcallbacks) | +| ( [ComponentDeInit](_codec.md#componentdeinit) )(struct CodecComponentType \*self) | 组件去åˆå§‹åŒ–。 [更多...](_codec.md#componentdeinit) | +| ( [UseEglImage](_codec.md#useeglimage) )(struct CodecComponentType \*self, struct [OmxCodecBuffer](_omx_codec_buffer.md) \*buffer, uint32_t portIndex, int8_t \*eglImage, uint32_t eglImageLen) | 使用已在EGLä¸ç”³è¯·çš„空间。 [更多...](_codec.md#useeglimage) | +| ( [ComponentRoleEnum](_codec.md#componentroleenum) )(struct [CodecComponentType \*self, uint8_t \*role, uint32_t roleLen, uint32_t index) | 获å–组件角色。 [更多...](_codec.md#componentroleenum) | + + +## **详细æè¿°** + +Codec组件接å£å®šä¹‰ã€‚ + +主è¦æ供以下功能: + +- 获å–组件的版本。 + +- 组件å‚æ•°é…置的获å–和设置。 + +- å‘é€å‘½ä»¤è‡³ç»„件åŠèŽ·å–组件状æ€ã€‚ + +- 设置回调函数。 + +- 设置/释放组件使用的buffer。 + +- 编解ç 输入输出bufferå¤„ç† å…·ä½“æ–¹æ³•ä½¿ç”¨è¯¦è§å‡½æ•°è¯´æ˜Žã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md b/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md new file mode 100644 index 0000000000000000000000000000000000000000..ddf1830d2f8d1634cbe777656fdefd8f61615340 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_comp_ver_info.md @@ -0,0 +1,78 @@ +# CompVerInfo + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [compName](#compname) [[NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17)] | 组件å称 | +| [compUUID](#compuuid) [[UUID_LENGTH](_codec.md#ga9226162b034cc837cd977f0fcf611c2c)] | 组件的UUIDæ ‡è¯†ç¬¦ | +| [compVersion](#compversion) | OMXç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ | +| [specVersion](#specversion) | 构建组件所ä¾æ®çš„è§„èŒƒçš„ç‰ˆæœ¬ä¿¡æ¯ | + + +## **Details** + + +## **详细æè¿°** + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### compName + + +``` +char CompVerInfo::compName[NAME_LENGTH] +``` + +**æ述:** + +组件å称 + + +### compUUID + + +``` +uint8_t CompVerInfo::compUUID[UUID_LENGTH] +``` + +**æ述:** + +组件的UUIDæ ‡è¯†ç¬¦ + + +### compVersion + + +``` +union OMX_VERSIONTYPE CompVerInfo::compVersion +``` + +**æ述:** + +OMXç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ + + +### specVersion + + +``` +union OMX_VERSIONTYPE CompVerInfo::specVersion +``` + +**æ述:** + +构建组件所ä¾æ®çš„è§„èŒƒçš„ç‰ˆæœ¬ä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_credential_info.md b/zh-cn/device-dev/reference/hdi-apis/_credential_info.md new file mode 100644 index 0000000000000000000000000000000000000000..2d38ca382a44d3e2df74c71b2a33e3dd69ccf44e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_credential_info.md @@ -0,0 +1,111 @@ +# CredentialInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [credentialId](#credentialid) | 认è¯å‡æ®ID。 | +| [index](#index) | 用户认è¯æ¡†æž¶çš„执行器索引。 | +| [templateId](#templateid) | 认è¯å‡æ®æ¨¡ç‰ˆID。 | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | +| [executorMatcher](#executormatcher) | 执行器匹é…器。 | +| [executorSensorHint](#executorsensorhint) | 既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ | + + +## **详细æè¿°** + +认è¯å‡æ®ä¿¡æ¯ã€‚ + +**自动:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType CredentialInfo::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹ã€‚ + + +### credentialId + + +``` +unsigned long CredentialInfo::credentialId +``` + +**æ述:** + +认è¯å‡æ®ID。 + + +### executorSensorHint + + +``` +unsigned int CredentialInfo::executorSensorHint +``` + +**æ述:** + +既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ + + +### executorMatcher + + +``` +unsigned int CredentialInfo::executorMatcher +``` + +**æ述:** + +执行器匹é…器。 + + +### index + + +``` +unsigned long CredentialInfo::index +``` + +**æ述:** + +用户认è¯æ¡†æž¶çš„执行器索引。 + + +### templateId + + +``` +unsigned long CredentialInfo::templateId +``` + +**æ述:** + +认è¯å‡æ®æ¨¡ç‰ˆID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md new file mode 100644 index 0000000000000000000000000000000000000000..a423b267c59d718dc84d6dd28e3ccc8c884bba7b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_device_funcs.md @@ -0,0 +1,59 @@ +# DeviceFuncs + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( **RegHotPlugCallback** )(HotPlugCallback callback, void \*data) | 注册çƒæ’拔事件回调 | +| ( **RegDisplayVBlankCallback** )(uint32_t devId, VBlankCallback callback, void \*data) | 注册VBlank事件回调。 | +| ( **RegDisplayRefreshCallback** )(uint32_t devId, RefreshCallback callback, void \*data) | 刷新请求回调。 | +| ( **GetDisplayCapability** )(uint32_t devId, [DisplayCapability](_display_capability.md) \*info) | 获å–显示设备能力集。 | +| ( **GetDisplaySupportedModes** )(uint32_t devId, uint32_t \*num, [DisplayModeInfo](_display_mode_info.md) \*modes) | 获å–显示设备支æŒçš„显示模å¼ä¿¡æ¯ã€‚ | +| ( **GetDisplayMode** )(uint32_t devId, uint32_t \*modeId) | 获å–显示设备当å‰çš„显示模å¼ã€‚ | +| ( **SetDisplayMode** )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模å¼ã€‚ | +| ( **GetDisplayPowerStatus** )(uint32_t devId, [DispPowerStatus](_display.md#disppowerstatus) \*status) | 获å–显示设备当å‰çš„电æºçŠ¶æ€ã€‚ | +| ( **SetDisplayPowerStatus** )(uint32_t devId, [DispPowerStatus](_display.md#disppowerstatus) status) | 设置显示设备当å‰çš„电æºçŠ¶æ€ã€‚ | +| ( **GetDisplayBacklight** )(uint32_t devId, uint32_t \*level) | 获å–显示设备当å‰çš„背光值。 | +| ( **SetDisplayBacklight** )(uint32_t devId, uint32_t level) | 设置显示设备当å‰çš„背光值。 | +| ( **GetDisplayProperty** )(uint32_t devId, uint32_t id, uint64_t \*value) | 获å–显示设备属性值。 | +| ( **SetDisplayProperty** )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 | +| ( **PrepareDisplayLayers** )(uint32_t devId, bool \*needFlushFb) | 显示设备åˆæˆå‰å‡†å¤‡ | +| ( **GetDisplayCompChange** )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获å–显示设备åˆæˆç±»åž‹æœ‰å˜åŒ–çš„layer | +| ( **SetDisplayClientCrop** )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的è£å‰ªåŒºåŸŸã€‚ | +| ( **SetDisplayClientDestRect** )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示区域。 | +| ( **SetDisplayClientBuffer** )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓å˜ã€‚ | +| ( **SetDisplayClientDamage** )(uint32_t devId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示è„区 | +| ( **SetDisplayVsyncEnabled** )(uint32_t devId, bool enabled) | 使能垂直åŒæ¥ä¿¡å·ã€‚ | +| ( **GetDisplayReleaseFence** )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获å–显示图层fence。 | +| ( **GetDisplaySupportedColorGamuts** )(uint32_t devId, uint32_t \*num, [ColorGamut](_display.md#colorgamut) \*gamuts) | 获å–显示设备支æŒçš„色域信æ¯ã€‚ | +| ( **GetDisplayColorGamut** )(uint32_t devId, [ColorGamut](_display.md#colorgamut) \*gamut) | 获å–显示设备当å‰çš„色域模å¼ã€‚ | +| ( **SetDisplayColorGamut** )(uint32_t devId, [ColorGamut](_display.md#colorgamut) gamut) | 设置显示设备当å‰çš„色域模å¼ã€‚ | +| ( **GetDisplayGamutMap** )(uint32_t devId, [GamutMap](_display.md#gamutmap) \*gamutMap) | 获å–显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ | +| ( **SetDisplayGamutMap** )(uint32_t devId, [GamutMap](_display.md#gamutmap) gamutMap) | 设置显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ | +| ( **SetDisplayColorTransform** )(uint32_t devId, const float \*matrix) | 设置显示设备当å‰çš„4x4的颜色转æ¢çŸ©é˜µã€‚ | +| ( **GetHDRCapabilityInfos** )(uint32_t devId, [HDRCapability](_h_d_r_capability.md) \*info) | 获å–显示设备支æŒçš„HDR属性信æ¯ã€‚ | +| ( **GetSupportedMetadataKey** )(uint32_t devId, uint32_t \*num, [HDRMetadataKey](_display.md#hdrmetadatakey) \*keys) | 获å–显示设备支æŒçš„ HDRMetadataKey。 | +| ( **Commit** )(uint32_t devId, int32_t \*fence) | æ交åˆæˆé€æ˜¾è¯·æ±‚。 | +| ( **InvokeDisplayCmd** )(uint32_t devId,...) | 调用显示设备命令。 | +| ( **CreateVirtualDisplay** )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 | +| ( **DestroyVirtualDisplay** )(uint32_t devId) | 销æ¯è™šæ‹Ÿæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| ( **SetVirtualDisplayBuffer** )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟å±çš„输出缓å˜ã€‚ | +| ( **GetWriteBackFrame** )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获å–显示设备的回写帧。 | +| ( **CreateWriteBack** )(uint32_t \*devId, uint32_t width, uint32_t height, int32_t \*format) | 对指定显示设备创建回写点。 | +| ( **DestroyWriteBack** )(uint32_t devId) | 销æ¯æŒ‡å®šæ˜¾ç¤ºè®¾å¤‡çš„回写点。 | + + +## **详细æè¿°** + +显示设备控制接å£ç»“构体,定义显示设备控制接å£å‡½æ•°æŒ‡é’ˆã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..d70dedd1806bb2b2c392c58f0ed8e4bca5deaed2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_device_info.md @@ -0,0 +1,118 @@ +# InputDeviceInfo + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [devIndex](#devindex) | 设备索引 | +| [devType](#devtype) | 设备类型 | +| [chipInfo](#chipinfo) [CHIP_INFO_LEN] | 驱动芯片编ç ä¿¡æ¯ | +| [vendorName](#vendorname) [VENDOR_NAME_LEN] | 模组厂商å | +| [chipName](#chipname) [CHIP_NAME_LEN] | é©±åŠ¨èŠ¯ç‰‡åž‹å· | +| [attrSet](#attrset)| 设备属性。 | +| [abilitySet](#abilityset)| 设备能力属性。| + + + +## **详细æè¿°** + +Input设备基础设备信æ¯ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### chipInfo + + +``` +char InputDeviceInfo::chipInfo[CHIP_INFO_LEN] +``` + +**æ述:** + +驱动芯片编ç ä¿¡æ¯ã€‚ + + +### chipName + + +``` +char InputDeviceInfo::chipName[CHIP_NAME_LEN] +``` + +**æ述:** + +驱动芯片型å·ã€‚ + + +### devIndex + + +``` +uint32_t InputDeviceInfo::devIndex +``` + +**æ述:** + +设备索引。 + + + +### devType + + +``` +uint32_t InputDeviceInfo::devType +``` + +**æ述:** + +设备类型。 + + +### vendorName + + +``` +char InputDeviceInfo::vendorName[VENDOR_NAME_LEN] +``` + +**æ述:** + +模组厂商å。 + + +### attrSet + + +``` +InputDevAttr InputDeviceInfo::attrSet +``` + +**æ述:** + +设备属性。 + + +### abilitySet + + +``` +InputDevAbility InputDeviceInfo::abilitySet +``` + +**æ述:** + +设备能力属性。 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_display.md b/zh-cn/device-dev/reference/hdi-apis/_display.md new file mode 100644 index 0000000000000000000000000000000000000000..1e8b1851aba085b8630c317c39fe21b9091e40d5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_display.md @@ -0,0 +1,3358 @@ +# Display + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [display_device.h](display__device_8h.md) | 显示设备控制接å£å£°æ˜Žã€‚ | +| [display_gfx.h](display__gfx_8h.md) | æ˜¾ç¤ºç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£å£°æ˜Žã€‚ | +| [display_gralloc.h](display__gralloc_8h.md) | 显示内å˜é©±åŠ¨æŽ¥å£å£°æ˜Žã€‚ | +| [display_layer.h](display__layer_8h.md) | 显示图层驱动接å£å£°æ˜Žã€‚ | +| [display_type.h](display__type_8h.md) | 显示类型定义,定义显示驱动接å£æ‰€ä½¿ç”¨çš„æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [DeviceFuncs](_device_funcs.md) | 显示设备控制接å£ç»“构体,定义显示设备控制接å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_device_funcs.md) | +| [GfxFuncs](_gfx_funcs.md) | æ˜¾ç¤ºç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£ç»“æž„ä½“ï¼Œå®šä¹‰ç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_gfx_funcs.md) | +| [GrallocFuncs](_gralloc_funcs.md) | 显示内å˜é©±åŠ¨æŽ¥å£ç»“构体,定义显示内å˜é©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_gralloc_funcs.md) | +| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接å£ç»“构体,定义显示图层驱动接å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_layer_funcs.md) | +| [DisplayInfo](_display_info.md) | 定义显示信æ¯ç»“构体 [更多...](_display_info.md) | +| [LayerInfo](_layer_info.md) | 定义图层信æ¯ç»“构体 [更多...](_layer_info.md) | +| [LayerAlpha](_layer_alpha.md) | 定义图层Alphaä¿¡æ¯çš„结构体 [更多...](_layer_alpha.md) | +| [BufferData](_buffer_data.md) | 定义一层的缓冲区数æ®ï¼ŒåŒ…括虚拟和物ç†å†…å˜åœ°å€ã€‚ [更多...](_buffer_data.md) | +| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于å˜æ”¾å›¾å±‚æ•°æ®ã€‚ [更多...](_layer_buffer.md) | +| [IRect](_i_rect.md) | å®šä¹‰çŸ©å½¢ä¿¡æ¯ [更多...](_i_rect.md) | +| [ISurface](_i_surface.md) | 用于å˜æ”¾çª—å£ç›¸å…³ä¿¡æ¯çš„结构体定义,æä¾›ç»™ç¡¬ä»¶åŠ é€Ÿä½¿ç”¨ï¼Œä¾‹å¦‚å›¾åƒåˆæˆï¼Œä½å›¾æ¬ç§»ç‰æ“作。 [更多...](_i_surface.md) | +| [ILine](_i_line.md) | 线æ¡æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶ç›´çº¿ã€‚ [更多...](_i_line.md) | +| [ICircle](_i_circle.md) | 圆形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶åœ†å½¢ã€‚ [更多...](_i_circle.md) | +| [Rectangle](_rectangle.md) | 矩形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶çŸ©å½¢ï¼Œ [更多...](_rectangle.md) | +| [GfxOpt](_gfx_opt.md) | 图åƒç¡¬ä»¶åŠ 速相关的æ“作选项结构体定义,用于图åƒç¡¬ä»¶åŠ 速时的æ“作选项。 [更多...](_gfx_opt.md) | +| [PropertyObject](_property_object.md) | 定义包å«å称ã€å±žæ€§ID和值的属性对象。 [更多...](_property_object.md) | +| [DisplayCapability](_display_capability.md) | 定义输出性能。 [更多...](_display_capability.md) | +| [DisplayModeInfo](_display_mode_info.md) | 定义输出模å¼ä¿¡æ¯ã€‚ [更多...](_display_mode_info.md) | +| [AllocInfo](_alloc_info.md) | 定义关于è¦åˆ†é…的内å˜çš„ä¿¡æ¯ã€‚ [更多...](_alloc_info.md) | +| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义 [更多...](_h_d_r_capability.md) | +| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数æ®ç»“构体定义 [更多...](_h_d_r_meta_data.md) | +| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验è¯å†…å˜åˆ†é…ä¿¡æ¯çš„结构体定义 [更多...](_verify_alloc_info.md) | +| [PresentTimestamp](_present_timestamp.md) | 上å±æ—¶é—´æˆ³ç»“构体定义 [更多...](_present_timestamp.md) | +| [__attribute__](____attribute____.md) | 扩展数æ®å¥æŸ„结构体定义 [更多...](____attribute____.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| **PROPERTY_NAME_LEN** 50 | 属性åå—长度。 | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([HotPlugCallback](#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | çƒæ’拔事件回调。[更多...](#hotplugcallback) | +| ([VBlankCallback](#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 [更多...](#vblankcallback) | +| ([RefreshCallback](#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调。[更多...](#refreshcallback) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [DispErrCode](#disperrcode) { DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3, DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7, DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 [更多...](#disperrcode) | +| [LayerType](#layertype) { LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SDIEBAND, LAYER_TYPE_CURSOR, LAYER_TYPE_BUTT } | 图层类型定义。 [更多...](#layertype) | +| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3), HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } | 缓冲区定义。[更多...](#anonymous-enum) | +| [PixelFormat](#pixelformat) { PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565, PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444, PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888, PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444, PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888, PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP, PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P, PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG, PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDER_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | åƒç´ æ ¼å¼ç±»åž‹å®šä¹‰ã€‚ [更多...](#pixelformat) | +| [TransformType](#transformtype) { ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270, ROTATE_BUTT } | 图层å˜æ¢ç±»åž‹å®šä¹‰ã€‚ [更多...](#transformtype) | +| [BlendType](#blendtype) { BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER, BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT, BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD, BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD, BLEND_BUTT } | 显示内å˜ç±»åž‹å®šä¹‰ã€‚ [更多...](#blendtype) | +| [RopType](#roptype) { ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN, ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN, ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN, ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE, ROP_BUTT } | ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„ROPæ“作类型。 [更多...](#roptype) | +| [ColorKey](#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color keyæ“作类型定义,å³ç¡¬ä»¶åŠ 速支æŒçš„Color keyæ“作类型。 [更多...](#colorkey) | +| [MirrorType](#mirrortype) { MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„é•œåƒæ“作类型定义 [更多...](#mirrortype) | +| [Connection](#connection) { CON_INVALID = 0, CONNECTED, DISCONNECTED } | çƒæ’拔连接类型定义 [更多...](#connection) | +| [InterfaceType](#interfacetype) { DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656, DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO, DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接å£ç±»åž‹ã€‚ [更多...](#interfacetype) | +| [DispPowerStatus](#disppowerstatus) { POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF, POWER_STATUS_BUTT } | æžšä¸¾æ˜¾ç¤ºçŠ¶æ€ [更多...](#disppowerstatus) | +| [CompositionType](#compositiontype) { COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO, COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组åˆç±»åž‹ã€‚ [更多...](#compositiontype) | +| [ColorGamut](#colorgamut) { COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_SATNDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2, COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6, COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值 [更多...](#colorgamut) | +| [GamutMap](#gamutmap) { GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | æžšä¸¾è‰²åŸŸçš„æ˜ å°„ç±»åž‹ [更多...](#gamutmap) | +| [ColorDataSpace](#colordataspace) { COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003, GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007, GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100, TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500, TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900, PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000, BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED, BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL, BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL, BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型 [更多...](#colordataspace) | +| [HDRFormat](#hdrformat) { NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3, HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDRæ ¼å¼ [更多...](#hdrformat) | +| [HDRMetadataKey](#hdrmetadatakey) { MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3, MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7, MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数æ®å…³é”®å— [更多...](#hdrmetadatakey) | +| [PresentTimestampType](#presenttimestamptype) { HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上å±æ—¶é—´æˆ³ç±»åž‹æžšä¸¾å€¼ [更多...](#presenttimestamptype) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [DeviceInitialize](#deviceinitialize) ([DeviceFuncs](_device_funcs.md) \*\*funcs) | 实现显示设备控制接å£çš„åˆå§‹åŒ–,申请æ“作显示设备控制接å£çš„资æºï¼Œå¹¶èŽ·å–对应的æ“作接å£ã€‚ [更多...](#deviceinitialize) | +| [DeviceUninitialize](#deviceuninitialize) ([DeviceFuncs](_device_funcs.md) \*funcs) | å–消显示设备控制接å£çš„åˆå§‹åŒ–,释放控制接å£ä½¿ç”¨åˆ°çš„资æºã€‚ [更多...](#deviceuninitialize) | +| [GfxInitialize](#gfxinitialize) ([GfxFuncs](_gfx_funcs.md) \*\*funcs) | 获å–ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ [更多...](#gfxinitialize) | +| [GfxUninitialize](#gfxuninitialize) ([GfxFuncs](_gfx_funcs.md) \*funcs) | é‡Šæ”¾ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ [更多...](#gfxuninitialize) | +| [GrallocInitialize](#grallocinitialize) ([GrallocFuncs](_gralloc_funcs.md) \*\*funcs) | åˆå§‹åŒ–内å˜æ¨¡å—,并获å–内å˜æ供的æ“作接å£ã€‚ [更多...](#grallocinitialize) | +| [GrallocUninitialize](#grallocuninitialize) ([GrallocFuncs](_gralloc_funcs.md) \*funcs) | å–消åˆå§‹åŒ–内å˜æ¨¡å—,并释放内å˜æ“作接å£æŒ‡é’ˆã€‚ [更多...](#grallocuninitialize) | +| [LayerInitialize](#layerinitialize) ([LayerFuncs](_layer_funcs.md) \*\*funcs) | 实现图层åˆå§‹åŒ–功能,申请图层使用的资æºï¼Œå¹¶èŽ·å–图层æ供的æ“作接å£ã€‚ [更多...](#layerinitialize) | +| [LayerUninitialize](#layeruninitialize) ([LayerFuncs](_layer_funcs.md) \*funcs) | å–消图层åˆå§‹åŒ–功能,释放图层使用到的资æºï¼Œå¹¶é‡Šæ”¾å›¾å±‚æ“作接å£æŒ‡é’ˆã€‚ [更多...](#layeruninitialize) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| ( [DeviceFuncs::RegHotPlugCallback](#reghotplugcallback) )([HotPlugCallback](#hotplugcallback) callback, void \*data) | 注册çƒæ’拔事件回调。 [更多...](#reghotplugcallback) | +| ( [DeviceFuncs::RegDisplayVBlankCallback](#regdisplayvblankcallback) )(uint32_t devId, [VBlankCallback](#vblankcallback) callback, void \*data) | 注册VBlank事件回调。 [更多...](#regdisplayvblankcallback) | +| ( [DeviceFuncs::RegDisplayRefreshCallback](#regdisplayrefreshcallback) )(uint32_t devId, [RefreshCallback](#refreshcallback) callback, void \*data) | 刷新请求回调。 [更多...](#regdisplayrefreshcallback) | +| ( [DeviceFuncs::GetDisplayCapability](#getdisplaycapability) )(uint32_t devId, [DisplayCapability](_display_capability.md) \*info) | 获å–显示设备能力集。 [更多...](#getdisplaycapability) | +| ( [DeviceFuncs::GetDisplaySupportedModes](#getdisplaysupportedmodes) )(uint32_t devId, uint32_t \*num, [DisplayModeInfo](_display_mode_info.md) \*modes) | 获å–显示设备支æŒçš„显示模å¼ä¿¡æ¯ã€‚ [更多...](#getdisplaysupportedmodes) | +| ( [DeviceFuncs::GetDisplayMode](#getdisplaymode) )(uint32_t devId, uint32_t \*modeId) | 获å–显示设备当å‰çš„显示模å¼ã€‚ [更多...](#getdisplaymode) | +| ( [DeviceFuncs::SetDisplayMode](#setdisplaymode) )(uint32_t devId, uint32_t modeId) | 设置显示设备的显示模å¼ã€‚ [更多...](#setdisplaymode) | +| ( [DeviceFuncs::GetDisplayPowerStatus](#getdisplaypowerstatus) )(uint32_t devId, [DispPowerStatus](#disppowerstatus) \*status) | 获å–显示设备当å‰çš„电æºçŠ¶æ€ã€‚ [更多...](#getdisplaypowerstatus) | +| ([ DeviceFuncs::SetDisplayPowerStatus](#setdisplaypowerstatus) )(uint32_t devId, [DispPowerStatus](#disppowerstatus) status) | 设置显示设备当å‰çš„电æºçŠ¶æ€ã€‚ [更多...](#setdisplaypowerstatus) | +| ( [DeviceFuncs::GetDisplayBacklight](#getdisplaybacklight) )(uint32_t devId, uint32_t \*level) | 获å–显示设备当å‰çš„背光值。 [更多...](#getdisplaybacklight) | +| ( [DeviceFuncs::SetDisplayBacklight](#setdisplaybacklight) )(uint32_t devId, uint32_t level) | 设置显示设备当å‰çš„背光值。 [更多...](#setdisplaybacklight) | +| ( [DeviceFuncs::GetDisplayProperty](#getdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t \*value) | 获得显示设备属性值。 [更多...](#getdisplayproperty) | +| ( [DeviceFuncs::SetDisplayProperty](#setdisplayproperty) )(uint32_t devId, uint32_t id, uint64_t value) | 设置显示设备属性值。 [更多...](#setdisplayproperty) | +| ( [DeviceFuncs::PrepareDisplayLayers](#preparedisplaylayers) )(uint32_t devId, bool \*needFlushFb) | 显示设备åˆæˆå‰å‡†å¤‡ã€‚ [更多...](#preparedisplaylayers) | +| ( [DeviceFuncs::GetDisplayCompChange](#getdisplaycompchange) )(uint32_t devId, uint32_t \*num, uint32_t \*Layers, int32_t \*type) | 获å–显示设备åˆæˆç±»åž‹æœ‰å˜åŒ–çš„layer。 [更多...](#getdisplaycompchange) | +| ( [DeviceFuncs::SetDisplayClientCrop](#setdisplayclientcrop) )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的è£å‰ªåŒºåŸŸã€‚ [更多...](#setdisplayclientcrop) | +| ( [DeviceFuncs::SetDisplayClientDestRect](#setdisplayclientdestrect) )(uint32_t devId, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示区域。 [更多...](#setdisplayclientdestrect) | +| ( [DeviceFuncs::SetDisplayClientBuffer](#setdisplayclientbuffer) )(uint32_t devId, const BufferHandle \*buffer, int32_t fence) | 设置显示设备的显示缓å˜ã€‚ [更多...](#setdisplayclientbuffer) | +| ( [DeviceFuncs::SetDisplayClientDamage](#setdisplayclientdamage) )(uint32_t devId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置显示设备的显示è„区。 [更多...](#setdisplayclientdamage) | +| ( [DeviceFuncs::SetDisplayVsyncEnabled](#setdisplayvsyncenabled) )(uint32_t devId, bool enabled) | 使能垂直åŒæ¥ä¿¡å·ã€‚ [更多...](#setdisplayvsyncenabled) | +| ( [DeviceFuncs::GetDisplayReleaseFence](#getdisplayreleasefence) )(uint32_t devId, uint32_t \*num, uint32_t \*layers, int32_t \*fences) | 获å–显示图层fence。 [更多...](#getdisplayreleasefence) | +| ( [DeviceFuncs::GetDisplaySupportedColorGamuts](#getdisplaysupportedcolorgamuts) )(uint32_t devId, uint32_t \*num, [ColorGamut](#colorgamut) \*gamuts) | 获å–显示设备支æŒçš„色域信æ¯ã€‚ [更多...](#getdisplaysupportedcolorgamuts) | +| ( [DeviceFuncs::GetDisplayColorGamut](#getdisplaycolorgamut) )(uint32_t devId, [ColorGamut](#colorgamut) \*gamut) | 获å–显示设备当å‰çš„色域模å¼ã€‚ [更多...](#getdisplaycolorgamut) | +| ( [DeviceFuncs::SetDisplayColorGamut](#setdisplaycolorgamut) )(uint32_t devId, [ColorGamut](#colorgamut) gamut) | 设置显示设备当å‰çš„色域模å¼ã€‚ [更多...](#setdisplaycolorgamut) | +| ( [DeviceFuncs::GetDisplayGamutMap](#getdisplaygamutmap) )(uint32_t devId, [ColorGamut](#colorgamut) \*gamutMap) | 获å–显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ [更多...](#getdisplaygamutmap) | +| ( [DeviceFuncs::SetDisplayGamutMap](#setdisplaygamutmap) )(uint32_t devId, [ColorGamut](#colorgamut) gamutMap) | 设置显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ [更多...](#setdisplaygamutmap) | +| ( [DeviceFuncs::SetDisplayColorTransform](#setdisplaycolortransform) )(uint32_t devId, const float \*matrix) | 设置显示设备当å‰çš„4x4的颜色转æ¢çŸ©é˜µã€‚ [更多...](#setdisplaycolortransform) | +| ( [DeviceFuncs::GetHDRCapabilityInfos](#gethdrcapabilityinfos) )(uint32_t devId, [HDRCapability](_h_d_r_capability.md) \*info) | 获å–显示设备支æŒçš„HDR属性信æ¯ã€‚ [更多...](#gethdrcapabilityinfos) | +| ( [DeviceFuncs::GetSupportedMetadataKey](#getsupportedmetadatakey) )(uint32_t devId, uint32_t \*num, [HDRMetadataKey](#hdrmetadatakey) \*keys) | 获å–显示设备支æŒçš„ HDRMetadataKey。 [更多...](#getsupportedmetadatakey) | +| ( [DeviceFuncs::Commit](#commit) )(uint32_t devId, int32_t \*fence) | æ交åˆæˆé€æ˜¾è¯·æ±‚。 [更多...](#commit) | +| ( [DeviceFuncs::InvokeDisplayCmd](#invokedisplaycmd) )(uint32_t devId,...) | 调用显示设备命令。 [更多...](#invokedisplaycmd) | +| ([ DeviceFuncs::CreateVirtualDisplay](#createvirtualdisplay) )(uint32_t width, uint32_t height, int32_t \*format, uint32_t \*devId) | 创建虚拟显示设备。 [更多...](#createvirtualdisplay) | +| ( [DeviceFuncs::DestroyVirtualDisplay](#destroyvirtualdisplay) )(uint32_t devId) | 销æ¯è™šæ‹Ÿæ˜¾ç¤ºè®¾å¤‡ã€‚ [更多...](#destroyvirtualdisplay) | +| ( [DeviceFuncs::SetVirtualDisplayBuffer](#setvirtualdisplaybuffer) )(uint32_t devId, BufferHandle \*buffer, int32_t fence) | 设置虚拟å±çš„输出缓å˜ã€‚ [更多...](#setvirtualdisplaybuffer) | +| ( [DeviceFuncs::GetWriteBackFrame](#getwritebackframe) )(uint32_t devId, BufferHandle \*buffer, int32_t \*fence) | 获å–显示设备的回写帧。 [更多...](#getwritebackframe) | +| ( [DeviceFuncs::CreateWriteBack](#createwriteback) )(uint32_t \*devId, uint32_t width, uint32_t height, int32_t \*format) | 对指定显示设备创建回写点。 [更多...](#createwriteback) | +| ( [DeviceFuncs::DestroyWriteBack](#destroywriteback) )(uint32_t devId) | 销æ¯æŒ‡å®šæ˜¾ç¤ºè®¾å¤‡çš„回写点。 [更多...](#destroywriteback) | +| [DisplayInfo::width](#width-17) | 显示å±å®½åº¦ | +| [DisplayInfo::height](#height-17) | 显示å±é«˜åº¦ | +| [DisplayInfo::rotAngle](#rotangle) | 显示å±æ—‹è½¬è§’度 | +| [LayerInfo::width](#width-27) | 图层宽度 | +| [LayerInfo::height](#height-27) | 图层高度 | +| [LayerInfo::type](#type-13) | 图层类型,包括图形层ã€è§†é¢‘层和媒体æ’æ”¾æ¨¡å¼ | +| [LayerInfo::bpp](#bpp) | æ¯åƒç´ 所å bitæ•° | +| [LayerInfo::pixFormat](#pixformat-12) | 图层åƒç´ æ ¼å¼ | +| [LayerAlpha::enGlobalAlpha](#englobalalpha-12) | 全局alphaä½¿èƒ½æ ‡å¿— | +| [LayerAlpha::enPixelAlpha](#enpixelalpha-12) | åƒç´ alphaä½¿èƒ½æ ‡å¿— | +| [LayerAlpha::alpha0](#alpha0-12) | alpha0值,å–值范围:[0, 255] | +| [LayerAlpha::alpha1](#alpha1-12) | alpha1值,å–值范围:[0, 255] | +| [LayerAlpha::gAlpha](#galpha) | 全局alpha值,å–值范围:[0, 255] | +| [BufferData::phyAddr](#phyaddr-12) | 物ç†å†…å˜åœ°å€ | +| [BufferData::virAddr](#viraddr) | 虚拟内å˜åœ°å€ | +| [LayerBuffer::fenceId](#fenceid) | buffer çš„fenceå·r | +| [LayerBuffer::width](#width-37) | buffer宽度 | +| [LayerBuffer::height](#height-37) | buffer高度 | +| [LayerBuffer::pitch](#pitch) | 一行数æ®æ‰€å å—节数 | +| [LayerBuffer::pixFormat](#pixformat-22) | bufferåƒç´ æ ¼å¼r | +| [LayerBuffer::data](#data) | 图层bufferæ•°æ® | +| [LayerBuffer::hdl](#hdl) | 图层bufferå¥æŸ„ | +| [IRect::x](#x-12) | 矩形框起始xåæ ‡ | +| [IRect::y](#y-12) | 矩形框起始yåæ ‡ | +| [IRect::w](#w) | 矩形框宽度 | +| [IRect::h](#h) | 矩形框高度 | +| [ISurface::phyAddr](#phyaddr-22) | 图åƒé¦–åœ°å€ | +| [ISurface::height](#height-47) | 图åƒé«˜åº¦ | +| [ISurface::width](#width-47) | 图åƒå®½åº¦ | +| [ISurface::stride](#stride) | 图åƒè·¨åº¦ | +| [ISurface::enColorFmt](#encolorfmt) | 图åƒæ ¼å¼ | +| [ISurface::bYCbCrClut](#bycbcrclut) | CLUT表是å¦ä½äºŽ YCbCr 空间 | +| [ISurface::bAlphaMax255](#balphamax255) | 图åƒalpha最大值为255还是128 | +| [ISurface::bAlphaExt1555](#balphaext1555) | 是å¦ä½¿èƒ½1555çš„Alpha扩展 | +| [ISurface::alpha0](#alpha0-22) | Alpha0值,å–值范围:[0,255] | +| [ISurface::alpha1](#alpha1-22) | Alpha1值,å–值范围:[0,255] | +| [ISurface::cbcrPhyAddr](#cbcrphyaddr) | CbCr分é‡åœ°å€ | +| [ISurface::cbcrStride](#cbcrstride) | CbCr分é‡è·¨åº¦ | +| [ISurface::clutPhyAddr](#clutphyaddr) | Clut表首地å€ï¼Œç”¨ä½œé¢œè‰²æ‰©å±•æˆ–é¢œè‰²æ ¡æ£ | +| [ILine::x0](#x0) | 线æ¡èµ·ç‚¹çš„xåæ ‡ | +| [ILine::y0](#y0) | 线æ¡èµ·ç‚¹çš„yåæ ‡ | +| [ILine::x1](#x1) | 线æ¡ç»ˆç‚¹çš„xåæ ‡ | +| [ILine::y1](#y1) | 线æ¡ç»ˆç‚¹çš„yåæ ‡ | +| [ILine::color](#color-13) | 线æ¡é¢œè‰² | +| [ICircle::x](#x-22) | 圆心xåæ ‡ | +| [ICircle::y](#y-22) | 圆心yåæ ‡r | +| [ICircle::r](#r) | 圆的åŠå¾„ | +| [ICircle::color](#color-23) | 圆的颜色 | +| [Rectangle::rect](#rect) | 矩形区域 | +| [Rectangle::color](#color-33) | 矩形颜色 | +| [GfxOpt::enGlobalAlpha](#englobalalpha-22) | 全局alphaä½¿èƒ½ä½ | +| [GfxOpt::globalAlpha](#globalalpha) | 全局alpha的值 | +| [GfxOpt::enPixelAlpha](#enpixelalpha-22) | åƒç´ alphaä½¿èƒ½ä½ | +| [GfxOpt::blendType](#blendtype) | æ··åˆæ–¹å¼ | +| [GfxOpt::colorKeyFrom](#colorkeyfrom) | è‰²é”®æ¨¡å¼ | +| [GfxOpt::enableRop](#enablerop) | RopåŠŸèƒ½ä½¿èƒ½ä½ | +| [GfxOpt::colorRopType](#colorroptype) | 颜色的Rop类型 | +| [GfxOpt::alphaRopType](#alpharoptype) | Alphaçš„Rop类型 | +| [GfxOpt::enableScale](#enablescale) | ç¼©æ”¾åŠŸèƒ½ä½¿èƒ½ä½ | +| [GfxOpt::rotateType](#rotatetype) | 旋转类型 | +| [GfxOpt::mirrorType](#mirrortype) | é•œåƒç±»åž‹ | +| [PropertyObject::name](#name-12) [PROPERTY_NAME_LEN] | 属性å称 | +| [PropertyObject::propId](#propid) | 属性ID | +| [PropertyObject::value](#value-12) | 属性值 | +| [DisplayCapability::name](#name-22) [PROPERTY_NAME_LEN] | 显示设备å称 | +| [DisplayCapability::type](#type-23) | 显示å±æŽ¥å£ç±»åž‹ | +| [DisplayCapability::phyWidth](#phywidth) | 物ç†å®½åº¦ | +| [DisplayCapability::phyHeight](#phyheight) | 物ç†é«˜åº¦ | +| [DisplayCapability::supportLayers](#supportlayers) | 支æŒçš„图层数 | +| [DisplayCapability::virtualDispCount](#virtualdispcount) | 支æŒçš„虚拟å±æ•° | +| [DisplayCapability::supportWriteBack](#supportwriteback) | 是å¦æ”¯æŒå›žå†™ | +| [DisplayCapability::propertyCount](#propertycount) | å±žæ€§æ•°ç»„å¤§å° | +| [DisplayCapability::props](#props) | 属性数组 | +| [DisplayModeInfo::width](#width-57) | åƒç´ 宽度 | +| [DisplayModeInfo::height](#height-57) | åƒç´ 高度 | +| [DisplayModeInfo::freshRate](#freshrate) | 刷新速率 | +| [DisplayModeInfo::id](#id) | 模å¼ID | +| [AllocInfo::width](#width-67) | 申请内å˜å®½åº¦ | +| [AllocInfo::height](#height-67) | 申请内å˜é«˜åº¦ | +| [AllocInfo::usage](#usage-12) | 申请内å˜çš„使用场景 | +| [AllocInfo::format](#format-12) | 申请内å˜æ ¼å¼ | +| [AllocInfo::expectedSize](#expectedsize) | 申请内å˜å¤§å° | +| [HDRCapability::formatCount](#formatcount) | 支æŒçš„HDRæ ¼å¼çš„æ•°é‡ | +| [HDRCapability::formats](#formats) | 支æŒçš„HDRæ ¼å¼çš„æ•°ç»„é¦–åœ°å€ | +| [HDRCapability::maxLum](#maxlum) | 最大的光亮度luminance值 | +| [HDRCapability::maxAverageLum](#maxaveragelum) | 最大的平å‡å…‰äº®åº¦luminance值 | +| [HDRCapability::minLum](#minlum) | 最å°çš„光亮度luminance值 | +| [HDRMetaData::key](#key) | HDR元数æ®å…³é”®å— | +| [HDRMetaData::value](#value-22) | 关键å—对应的值 | +| [VerifyAllocInfo::width](#width-77) | 分é…内å˜çš„宽度 | +| [VerifyAllocInfo::height](#height-77) | 分é…内å˜çš„高度 | +| [VerifyAllocInfo::usage](#usage-22) | 内å˜çš„用处 | +| [VerifyAllocInfo::format](#format-22) | 分é…内å˜çš„åƒç´ æ ¼å¼ | +| [PresentTimestamp::type](#type-33) | 上å±æ—¶é—´æˆ³ç±»åž‹ | +| [PresentTimestamp::time](#time) | 类型对应的值 | +| [__attribute__::fd](#fd) | å¥æŸ„ fd,-1代表ä¸æ”¯æŒ | +| [__attribute__::reserveInts](#reserveints) | reserve数组的个数 | +| [__attribute__::reserve](#reserve) [0] | reserve数组 | +| [__attribute__::baseAddr](#baseaddr) | 内å˜çš„åˆå§‹åœ°å€ | +| [__attribute__::yOffset](#yoffset) | Yçš„åç§»é‡ | +| [__attribute__::uOffset](#uoffset) | Uçš„åç§»é‡ | +| [__attribute__::vOffset](#voffset) | Vçš„åç§»é‡ | +| [__attribute__::yStride](#ystride) | Yçš„strideä¿¡æ¯ | +| [__attribute__::uvStride](#uvstride) | UVçš„strideä¿¡æ¯ | +| [__attribute__::uvStep](#uvstep) | UVçš„stepä¿¡æ¯ | + + +## **详细æè¿°** + +显示模å—驱动接å£å®šä¹‰ã€‚ + +æ供给图形系统使用的驱动接å£ï¼ŒåŒ…括图层管ç†ã€è®¾å¤‡æŽ§åˆ¶ã€å›¾å½¢ç¡¬ä»¶åŠ 速ã€æ˜¾ç¤ºå†…å˜ç®¡ç†å’Œå›žè°ƒæŽ¥å£ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +2.0 + + +## **类型定义说明** + + +### HotPlugCallback + + +``` +typedef void(* HotPlugCallback) (uint32_t devId, bool connected, void *data) +``` + +**æ述:** + +çƒæ’拔事件回调。 + +当有çƒæ’拔事件å‘生时,会回调该接å£ï¼Œéœ€è¦é€šè¿‡RegHotPlugCallback注册该回调接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,æ¤IDç”±HDI实现层生æˆï¼Œå¹¶é€šè¿‡å½“å‰å›žè°ƒæŽ¥å£ä¼ 递给图形æœåŠ¡ä½¿ç”¨ï¼Œç”¨ä»¥æ ‡è®°å½“å‰è¿žæŽ¥çš„显示设备。 | +| connected | 输入å‚数,指明设备的连接状æ€ï¼Œture代表连接,false代表æ–开。 | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œè¯¥å‚æ•°æºå¸¦çš„是RegHotPlugCallback接å£æ³¨å†Œæ—¶ä¼ 递的ç§æœ‰æ•°æ®åœ°å€ï¼Œè¯¦æƒ…å‚考 RegHotPlugCallback 接å£æ³¨å†Œæ—¶ä¼ 递的地å€ã€‚ | + + +### RefreshCallback + + +``` +typedef void(* RefreshCallback) (uint32_t devId, void *data) +``` + +**æ述:** + +刷新请求回调。 + +刷新请求回调,当接å£å®žçŽ°å±‚需è¦å›¾å½¢æœåŠ¡åˆ·æ–°æ•°æ®å¸§æ—¶ä¼šå›žè°ƒè¯¥æŽ¥å£ï¼Œéœ€è¦é€šè¿‡RegDisplayRefreshCallback注册该回调接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID。 | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œè¯¥å‚æ•°æºå¸¦çš„是RegDisplayRefreshCallback接å£æ³¨å†Œæ—¶ä¼ 递的地å€ã€‚ | + + +### VBlankCallback + + +``` +typedef void(* VBlankCallback) (unsigned int sequence, uint64_t ns, void *data) +``` + +**æ述:** + +VBlank 事件回调。 + +åž‚ç›´åŒæ¥äº‹ä»¶å›žè°ƒæŽ¥å£ï¼Œéœ€è¦é€šè¿‡RegDisplayVBlankCallback注册该回调接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| sequence | 输入å‚数,指明VBlankåºåˆ—ï¼Œæ˜¯ä¸€ä¸ªç´¯åŠ å€¼ã€‚ | +| ns | 输入å‚数,该次VBlank事件的时间戳,以纳秒为å•ä½ã€‚ | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œè¯¥å‚æ•°æºå¸¦çš„是RegDisplayVBlankCallback接å£æ³¨å†Œæ—¶ä¼ 递的地å€ã€‚ | + + +## **枚举类型说明** + + +### anonymous enum + + +``` +anonymous enum +``` + +**æ述:** + +缓冲区定义。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| HBM_USE_CPU_READ | CPU 读缓冲 | +| HBM_USE_CPU_WRITE | CPU å†™å†…å˜ | +| HBM_USE_MEM_MMZ | MMZ | +| HBM_USE_MEM_DMA | DMA缓冲区 | +| HBM_USE_MEM_SHARE | 共享内å˜ç¼“冲区 | +| HBM_USE_MEM_MMZ_CACHE | MMZç¼“å˜ | +| HBM_USE_MEM_FB | å¸§ç¼“å˜ | +| HBM_USE_ASSIGN_SIZE | 内å˜åˆ†é… | + + +### BlendType + + +``` +enum BlendType +``` + +**æ述:** + +显示内å˜ç±»åž‹å®šä¹‰ã€‚ + +æ ¹æ®å›¾å½¢ç³»ç»ŸæŒ‡å®šçš„类型进行分é…,包括带cache或者ä¸å¸¦cache的内å˜ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| BLEND_NONE | No æ··åˆæ“作 | +| BLEND_CLEAR | CLEAR æ··åˆæ“作 | +| BLEND_SRC | SRC æ··åˆæ“作 | +| BLEND_SRCOVER | SRC_OVER æ··åˆæ“作 | +| BLEND_DSTOVER | DST_OVER æ··åˆæ“作 | +| BLEND_SRCIN | SRC_IN æ··åˆæ“作 | +| BLEND_DSTIN | DST_IN æ··åˆæ“作 | +| BLEND_SRCOUT | SRC_OUT æ··åˆæ“作 | +| BLEND_DSTOUT | DST_OUT æ··åˆæ“作 | +| BLEND_SRCATOP | SRC_ATOP æ··åˆæ“作 | +| BLEND_DSTATOP | DST_ATOP æ··åˆæ“作 | +| BLEND_ADD | ADD æ··åˆæ“作 | +| BLEND_XOR | XOR æ··åˆæ“作 | +| BLEND_DST | DST æ··åˆæ“作 | +| BLEND_AKS | AKS æ··åˆæ“作 | +| BLEND_AKD | AKD æ··åˆæ“作 | +| BLEND_BUTT | 空æ“作 | + + +### ColorDataSpace + + +``` +enum ColorDataSpace +``` + +**æ述:** + +枚举颜色空间的类型 + + | 枚举值 | æè¿° | +| -------- | -------- | +| COLOR_DATA_SPACE_UNKNOWN | 未知的 | +| GAMUT_BT601 | BT601色域 | +| GAMUT_BT709 | BT709色域 | +| GAMUT_DCI_P3 | DCI_P3色域 | +| GAMUT_SRGB | SRGB色域 | +| GAMUT_ADOBE_RGB | ADOBE_RGB色域 | +| GAMUT_DISPLAY_P3 | DISPLAY_P3色域 | +| GAMUT_BT2020 | BT2020色域 | +| GAMUT_BT2100_PQ | BT2100_PQ色域 | +| GAMUT_BT2100_HLG | BT2100_HLG色域 | +| GAMUT_DISPLAY_BT2020 | DISPLAY_BT2020色域 | +| TRANSFORM_FUNC_UNSPECIFIED | UNSPECIFIED转æ¢å‡½æ•° | +| TRANSFORM_FUNC_LINEAR | LINEAR转æ¢å‡½æ•° | +| TRANSFORM_FUNC_SRGB | SRGB转æ¢å‡½æ•° | +| TRANSFORM_FUNC_SMPTE_170M | SMPTE_170M转æ¢å‡½æ•° | +| TRANSFORM_FUNC_GM2_2 | GM2_2转æ¢å‡½æ•° | +| TRANSFORM_FUNC_GM2_6 | GM2_6转æ¢å‡½æ•° | +| TRANSFORM_FUNC_GM2_8 | GM2_8转æ¢å‡½æ•° | +| TRANSFORM_FUNC_ST2084 | ST2084转æ¢å‡½æ•° | +| TRANSFORM_FUNC_HLG | HLG转æ¢å‡½æ•° | +| PRECISION_UNSPECIFIED | UNSPECIFIED精度 | +| PRECISION_FULL | FULL精度 | +| PRESION_LIMITED | LIMITED精度 | +| PRESION_EXTENDED | EXTENDED精度 | +| BT601_SMPTE170M_FULL | BT601色域 \| SMPTE_170M转æ¢å‡½æ•° \| FULL精度 | +| BT601_SMPTE170M_LIMITED | BT601色域 \| SMPTE_170M转æ¢å‡½æ•° \| LIMITED精度 | +| BT709_LINEAR_FULL | BT709色域 \| LINEAR转æ¢å‡½æ•° \| FULL精度 | +| BT709_LINEAR_EXTENDED | BT709色域 \| LINEAR转æ¢å‡½æ•° \| EXTENDED精度 | +| BT709_SRGB_FULL | BT709色域 \| SRGB转æ¢å‡½æ•° \| FULL精度 | +| BT709_SRGB_EXTENDED | BT709色域 \| SRGB转æ¢å‡½æ•° \| EXTENDED精度 | +| BT709_SMPTE170M_LIMITED | BT709色域 \| SMPTE_170M转æ¢å‡½æ•° \| LIMITED精度 | +| DCI_P3_LINEAR_FULL | DCI_P3色域 \| LINEAR转æ¢å‡½æ•° \| FULL精度 | +| DCI_P3_GAMMA26_FULL | DCI_P3色域 \| GM2_6转æ¢å‡½æ•° \| FULL精度 | +| DISPLAY_P3_LINEAR_FULL | DISPLAY_P3色域 \| LINEAR转æ¢å‡½æ•° \| FULL精度 | +| DCI_P3_SRGB_FULL | DCI_P3色域 \| SRGB转æ¢å‡½æ•° \| FULL精度 | +| ADOBE_RGB_GAMMA22_FULL | ADOBE_RGB色域 \| GM2_2转æ¢å‡½æ•° \| FULL精度 | +| BT2020_LINEAR_FULL | BT2020色域 \| LINEAR转æ¢å‡½æ•° \| FULL精度 | +| BT2020_SRGB_FULL | BT2020色域 \| SRGB转æ¢å‡½æ•° \| FULL精度 | +| BT2020_SMPTE170M_FULL | BT2020色域 \| SMPTE_170M转æ¢å‡½æ•° \| FULL精度 | +| BT2020_ST2084_FULL | BT2020色域 \| ST2084转æ¢å‡½æ•° \| FULL精度 | +| BT2020_HLG_FULL | BT2020色域 \| HLG转æ¢å‡½æ•° \| FULL精度 | +| BT2020_ST2084_LIMITED | BT2020色域 \| ST2084转æ¢å‡½æ•° \| LIMITED精度 | + + +### ColorGamut + + +``` +enum ColorGamut +``` + +**æ述:** + +色域类型枚举值。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| COLOR_GAMUT_INVALID | æ— æ•ˆå€¼ | +| COLOR_GAMUT_NATIVE | 默认值 | +| COLOR_GAMUT_SATNDARD_BT601 | Standard BT601类型 | +| COLOR_GAMUT_STANDARD_BT709 | Standard BT709类型 | +| COLOR_GAMUT_DCI_P3 | DCI P3类型 | +| COLOR_GAMUT_SRGB | SRGB类型 | +| COLOR_GAMUT_ADOBE_RGB | Adobe RGB类型 | +| COLOR_GAMUT_DISPLAY_P3 | display P3类型 | +| COLOR_GAMUT_BT2020 | BT2020类型 | +| COLOR_GAMUT_BT2100_PQ | BT2100 PQ类型 | +| COLOR_GAMUT_BT2100_HLG | BT2100 HLG类型 | +| COLOR_GAMUT_DISPLAY_BT2020 | Display BT2020类型 | + + +### ColorKey + + +``` +enum ColorKey +``` + +**æ述:** + +Color keyæ“作类型定义,å³ç¡¬ä»¶åŠ 速支æŒçš„Color keyæ“作类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CKEY_NONE | ä¸ä½¿ç”¨colorkey | +| CKEY_SRC | 使用æºcolorkey | +| CKEY_DST | ä½¿ç”¨ç›®æ ‡colorkey | +| CKEY_BUTT | 空æ“作 | + + +### CompositionType + + +``` +enum CompositionType +``` + +**æ述:** + +枚举特殊层的组åˆç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| COMPOSITION_CLIENT | Client åˆæˆç±»åž‹ï¼Œä½¿ç”¨CPU或者GPUåˆæˆã€‚ | +| COMPOSITION_DEVICE | Device åˆæˆç±»åž‹ï¼Œä½¿ç”¨Deviceåˆæˆã€‚ | +| COMPOSITION_CURSOR | Cursoråˆæˆç±»åž‹ï¼Œç”¨äºŽå…‰æ ‡åˆæˆã€‚ | +| COMPOSITION_VIDEO | Videoåˆæˆç±»åž‹ï¼Œç”¨äºŽè§†é¢‘层åˆæˆã€‚ | +| COMPOSITION_DEVICE_CLEAR | Device clear åˆæˆç±»åž‹ï¼Œdeviceä¼šæ¸…é™¤ç›®æ ‡åŒºåŸŸã€‚ | +| COMPOSITION_CLIENT_CLEAR | Client clear åˆæˆç±»åž‹ï¼Œserviceä¼šæ¸…é™¤ç›®æ ‡åŒºåŸŸã€‚ | +| COMPOSITION_TUNNEL | Tunnel åˆæˆç±»åž‹ï¼Œç”¨äºŽtunnel。 | +| COMPOSITION_BUTT | åˆæˆç±»åž‹ï¼Œä¸€ä¸ªä¸å¯ç”¨ç±»åž‹ï¼Œç”¨äºŽé»˜è®¤åˆå§‹åŒ–。 | + + +### Connection + + +``` +enum Connection +``` + +**æ述:** + +çƒæ’拔连接类型定义 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CON_INVALID | æ— æ•ˆç±»åž‹ | +| CONNECTED | 已连接 | +| DISCONNECTED | æ–开连接 | + + +### DispErrCode + + +``` +enum DispErrCode +``` + +**æ述:** + +返回值类型定义。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| DISPLAY_SUCCESS | æˆåŠŸ | +| DISPLAY_FAILURE | 失败 | +| DISPLAY_FD_ERR | fd错误 | +| DISPLAY_PARAM_ERR | å‚数错误 | +| DISPLAY_NULL_PTR | 空指针 | +| DISPLAY_NOT_SUPPORT | ä¸æ”¯æŒçš„特性 | +| DISPLAY_NOMEM | 内å˜ä¸è¶³ | +| DISPLAY_SYS_BUSY | 系统ç¹å¿™ | +| DISPLAY_NOT_PERM | æ“作ä¸å…许 | + + +### DispPowerStatus + + +``` +enum DispPowerStatus +``` + +**æ述:** + +æžšä¸¾æ˜¾ç¤ºçŠ¶æ€ + + | 枚举值 | æè¿° | +| -------- | -------- | +| POWER_STATUS_ON | ä¸Šç”µæ¨¡å¼ | +| POWER_STATUS_STANDBY | å¾…æœºæ¨¡å¼ | +| POWER_STATUS_SUSPEND | ä¼‘çœ æ¨¡å¼ | +| POWER_STATUS_OFF | ä¸‹ç”µæ¨¡å¼ | +| POWER_STATUS_BUTT | é»˜è®¤æ¨¡å¼ | + + +### GamutMap + + +``` +enum GamutMap +``` + +**æ述:** + +æžšä¸¾è‰²åŸŸçš„æ˜ å°„ç±»åž‹ + + | 枚举值 | æè¿° | +| -------- | -------- | +| GAMUT_MAP_CONSTANT | ä¸å˜ | +| GAMUT_MAP_EXPANSION | æ˜ å°„å¢žå¼º | +| GAMUT_MAP_HDR_CONSTANT | ä¸å˜ï¼Œç”¨äºŽHDR | +| GAMUT_MAP_HDR_EXPANSION | æ˜ å°„å¢žå¼ºï¼Œç”¨äºŽHDR | + + +### HDRFormat + + +``` +enum HDRFormat +``` + +**æ述:** + +枚举HDRæ ¼å¼ + + | 枚举值 | æè¿° | +| -------- | -------- | +| NOT_SUPPORT_HDR | ä¸æ”¯æŒHDR | +| DOLBY_VISION | Dolby Visionæ ¼å¼ | +| HDR10 | HDR10æ ¼å¼ | +| HLG | HLGæ ¼å¼ | +| HDR10_PLUS | HDR10 Plusæ ¼å¼ | +| HDR_VIVID | Vividæ ¼å¼ | + + +### HDRMetadataKey + + +``` +enum HDRMetadataKey +``` + +**æ述:** + +枚举HDR元数æ®å…³é”®å— + + | 枚举值 | æè¿° | +| -------- | -------- | +| MATAKEY_RED_PRIMARY_X | 红基色Xåæ ‡ | +| MATAKEY_RED_PRIMARY_Y | 红基色Yåæ ‡ | +| MATAKEY_GREEN_PRIMARY_X | 绿基色Xåæ ‡ | +| MATAKEY_GREEN_PRIMARY_Y | 绿基色Yåæ ‡ | +| MATAKEY_BLUE_PRIMARY_X | è“基色Xåæ ‡ | +| MATAKEY_BLUE_PRIMARY_Y | è“基色Yåæ ‡ | +| MATAKEY_WHITE_PRIMARY_X | 白点Xåæ ‡ | +| MATAKEY_WHITE_PRIMARY_Y | 白点Yåæ ‡ | +| MATAKEY_MAX_LUMINANCE | 最大的光亮度 | +| MATAKEY_MIN_LUMINANCE | 最å°çš„光亮度 | +| MATAKEY_MAX_CONTENT_LIGHT_LEVEL | 最大的内容亮度水平 | +| MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | 最大的帧平å‡äº®åº¦æ°´å¹³ | +| MATAKEY_HDR10_PLUS | HDR10 Plus | +| MATAKEY_HDR_VIVID | Vivid | + + +### InterfaceType + + +``` +enum InterfaceType +``` + +**æ述:** + +枚举接å£ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| DISP_INTF_HDMI | HDMI æŽ¥å£ | +| DISP_INTF_LCD | LCD æŽ¥å£ | +| DISP_INTF_BT1120 | BT1120 æŽ¥å£ | +| DISP_INTF_BT656 | BT656 æŽ¥å£ | +| DISP_INTF_YPBPR | YPBPR æŽ¥å£ | +| DISP_INTF_RGB | RGB æŽ¥å£ | +| DISP_INTF_CVBS | CVBS æŽ¥å£ | +| DISP_INTF_SVIDEO | SVIDEO æŽ¥å£ | +| DISP_INTF_VGA | VGA æŽ¥å£ | +| DISP_INTF_MIPI | MIPI æŽ¥å£ | +| DISP_INTF_PANEL | PANEL æŽ¥å£ | +| DISP_INTF_BUTT | BUTT接å£ï¼Œä¸€ä¸ªä¸å¯ç”¨ç±»åž‹ï¼Œç”¨äºŽé»˜è®¤åˆå§‹åŒ–。 | + + +### LayerType + + +``` +enum LayerType +``` + +**æ述:** + +图层类型定义。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| LAYER_TYPE_GRAPHIC | 图形层 | +| LAYER_TYPE_OVERLAY | 视频层 | +| LAYER_TYPE_SDIEBAND | 媒体æ’放 | +| LAYER_TYPE_CURSOR | å…‰æ ‡å±‚ | +| LAYER_TYPE_BUTT | 空图层 | + + +### MirrorType + + +``` +enum MirrorType +``` + +**æ述:** + +ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„é•œåƒæ“作类型定义 + + | 枚举值 | æè¿° | +| -------- | -------- | +| MIRROR_NONE | ä¸ä½¿ç”¨é•œåƒ | +| MIRROR_LR | å·¦å³é•œåƒ | +| MIRROR_TB | ä¸Šä¸‹é•œåƒ | +| MIRROR_BUTT | 空æ“作 | + + +### PixelFormat + + +``` +enum PixelFormat +``` + +**æ述:** + +åƒç´ æ ¼å¼ç±»åž‹å®šä¹‰ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIXEL_FMT_CLUT8 | CLUT8 æ ¼å¼ | +| PIXEL_FMT_CLUT1 | CLUT1 æ ¼å¼ | +| PIXEL_FMT_CLUT4 | CLUT4 æ ¼å¼ | +| PIXEL_FMT_RGB_565 | RGB565 æ ¼å¼ | +| PIXEL_FMT_RGBA_5658 | RGBA5658 æ ¼å¼ | +| PIXEL_FMT_RGBX_4444 | RGBX4444 æ ¼å¼ | +| PIXEL_FMT_RGBA_4444 | RGBA4444 æ ¼å¼ | +| PIXEL_FMT_RGB_444 | RGB444 æ ¼å¼ | +| PIXEL_FMT_RGBX_5551 | RGBX5551 æ ¼å¼ | +| PIXEL_FMT_RGBA_5551 | RGBA5551 æ ¼å¼ | +| PIXEL_FMT_RGB_555 | RGB555 æ ¼å¼ | +| PIXEL_FMT_RGBX_8888 | RGBX8888 æ ¼å¼ | +| PIXEL_FMT_RGBA_8888 | RGBA8888 æ ¼å¼ | +| PIXEL_FMT_RGB_888 | RGB888 æ ¼å¼ | +| PIXEL_FMT_BGR_565 | BGR565 æ ¼å¼ | +| PIXEL_FMT_BGRX_4444 | BGRX4444 æ ¼å¼ | +| PIXEL_FMT_BGRA_4444 | BGRA4444 æ ¼å¼ | +| PIXEL_FMT_BGRX_5551 | BGRX5551 æ ¼å¼ | +| PIXEL_FMT_BGRA_5551 | BGRA5551 æ ¼å¼ | +| PIXEL_FMT_BGRX_8888 | BGRX8888 æ ¼å¼ | +| PIXEL_FMT_BGRA_8888 | BGRA8888 æ ¼å¼ | +| PIXEL_FMT_YUV_422_I | YUV422 äº¤é”™æ ¼å¼ | +| PIXEL_FMT_YCBCR_422_SP | YCBCR422 åŠå¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCRCB_422_SP | YCRCB422 åŠå¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCBCR_420_SP | YCBCR420 åŠå¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCRCB_420_SP | YCRCB420 åŠå¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCBCR_422_P | YCBCR422 å¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCRCB_422_P | YCRCB422 å¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCBCR_420_P | YCBCR420 å¹³é¢æ ¼å¼ | +| PIXEL_FMT_YCRCB_420_P | YCRCB420 å¹³é¢æ ¼å¼ | +| PIXEL_FMT_YUYV_422_PKG | YUYV422 æ‰“åŒ…æ ¼å¼ | +| PIXEL_FMT_UYVY_422_PKG | UYVY422 æ‰“åŒ…æ ¼å¼t | +| PIXEL_FMT_YVYU_422_PKG | YVYU422 æ‰“åŒ…æ ¼å¼ | +| PIXEL_FMT_VYUY_422_PKG | VYUY422 æ‰“åŒ…æ ¼å¼ | +| PIXEL_FMT_VENDER_MASK | vendor mask æ ¼å¼ | +| PIXEL_FMT_BUTT | Invalid åƒç´ æ ¼å¼ | + + +### PresentTimestampType + + +``` +enum PresentTimestampType +``` + +**æ述:** + +上å±æ—¶é—´æˆ³ç±»åž‹æžšä¸¾å€¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| HARDWARE_DISPLAY_PTS_UNSUPPORTED | ä¸æ”¯æŒ | +| HARDWARE_DISPLAY_PTS_DELAY | Delay 时延类型 | +| HARDWARE_DISPLAY_PTS_TIMESTAMP | 时间戳类型 | + + +### RopType + + +``` +enum RopType +``` + +**æ述:** + +ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„ROPæ“作类型。 + +ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„ROPæ“作类型,在将å‰æ™¯ä½å›¾çš„RGB颜色分é‡å’ŒAlpha分é‡å€¼ä¸ŽèƒŒæ™¯ä½å›¾çš„RGB颜色 分é‡å€¼å’ŒAlpha分é‡å€¼è¿›è¡ŒæŒ‰ä½çš„布尔è¿ç®—(包括按ä½ä¸Žï¼ŒæŒ‰ä½æˆ–ç‰ï¼‰ï¼Œå°†ç»“果输出。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| ROP_BLACK | 黑色 | +| ROP_NOTMERGEPEN | ~(S2+S1) | +| ROP_MASKNOTPEN | ~S2&S1 | +| ROP_NOTCOPYPEN | ~S2 | +| ROP_MASKPENNOT | S2&~S1 | +| ROP_NOT | ~S1 | +| ROP_XORPEN | S2^S1 | +| ROP_NOTMASKPEN | ~(S2&S1) | +| ROP_MASKPEN | S2&S1 | +| ROP_NOTXORPEN | ~(S2^S1) | +| ROP_NOP | S1 | +| ROP_MERGENOTPEN | ~S2+S1 | +| ROP_COPYPE | S2 | +| ROP_MERGEPENNOT | S2+~S1 | +| ROP_MERGEPEN | S2+S1 | +| ROP_WHITE | 白色 | +| ROP_BUTT | æ— æ•ˆå€¼ | + + +### TransformType + + +``` +enum TransformType +``` + +**æ述:** + +图层å˜æ¢ç±»åž‹å®šä¹‰ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| ROTATE_NONE | ä¸æ—‹è½¬ | +| ROTATE_90 | 旋转90度 | +| ROTATE_180 | 旋转180度 | +| ROTATE_270 | 旋转270度 | +| ROTATE_BUTT | æ— æ•ˆæ“作 | + + +## **函数说明** + + +### DeviceInitialize() + + +``` +int32_t DeviceInitialize (DeviceFuncs **funcs) +``` + +**æ述:** + +实现显示设备控制接å£çš„åˆå§‹åŒ–,申请æ“作显示设备控制接å£çš„资æºï¼Œå¹¶èŽ·å–对应的æ“作接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,显示设备控制接å£æŒ‡é’ˆï¼Œåˆå§‹åŒ–时分é…内å˜ï¼Œè°ƒç”¨è€…ä¸éœ€è¦åˆ†é…内å˜ï¼Œè°ƒç”¨è€…获å–该指针用于æ“作显示设备。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### DeviceUninitialize() + + +``` +int32_t DeviceUninitialize (DeviceFuncs * funcs) +``` + +**æ述:** + +å–消显示设备控制接å£çš„åˆå§‹åŒ–,释放控制接å£ä½¿ç”¨åˆ°çš„资æºã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,显示设备控制接å£æŒ‡é’ˆï¼Œç”¨äºŽé‡Šæ”¾åˆå§‹åŒ–函数ä¸åˆ†é…çš„æ“作指针内å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GfxInitialize() + + +``` +int32_t GfxInitialize (GfxFuncs **funcs) +``` + +**æ述:** + +获å–ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿæ¨¡å—æ“作接å£æŒ‡é’ˆï¼Œè°ƒç”¨è€…ä¸éœ€è¦åˆ†é…内å˜ï¼Œè°ƒç”¨è€…获å–该指针æ“ä½œç¡¬ä»¶åŠ é€Ÿã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GfxUninitialize() + + +``` +int32_t GfxUninitialize (GfxFuncs * funcs) +``` + +**æ述:** + +é‡Šæ”¾ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿæ“作接å£æŒ‡é’ˆã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GrallocInitialize() + + +``` +int32_t GrallocInitialize (GrallocFuncs **funcs) +``` + +**æ述:** + +åˆå§‹åŒ–内å˜æ¨¡å—,并获å–内å˜æ供的æ“作接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,内å˜æ¨¡å—æ“作接å£æŒ‡é’ˆï¼Œåˆå§‹åŒ–内å˜æ¨¡å—时分é…内å˜ï¼Œè°ƒç”¨è€…ä¸éœ€è¦åˆ†é…内å˜ï¼Œè°ƒç”¨è€…获å–该指针æ“作内å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### GrallocUninitialize() + + +``` +int32_t GrallocUninitialize (GrallocFuncs * funcs) +``` + +**æ述:** + +å–消åˆå§‹åŒ–内å˜æ¨¡å—,并释放内å˜æ“作接å£æŒ‡é’ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,内å˜æ“作接å£æŒ‡é’ˆï¼Œç”¨äºŽé‡Šæ”¾å†…å˜åˆå§‹åŒ–函数ä¸åˆ†é…çš„æ“作指针内å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### LayerInitialize() + + +``` +int32_t LayerInitialize (LayerFuncs **funcs) +``` + +**æ述:** + +实现图层åˆå§‹åŒ–功能,申请图层使用的资æºï¼Œå¹¶èŽ·å–图层æ供的æ“作接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,图层æ“作接å£æŒ‡é’ˆï¼Œåˆå§‹åŒ–图层时分é…内å˜ï¼Œè°ƒç”¨è€…ä¸éœ€è¦åˆ†é…内å˜ï¼Œè°ƒç”¨è€…获å–该指针æ“作图层。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**å‚è§ï¼š** + +[LayerUninitialize](#layeruninitialize) + + +### LayerUninitialize() + + +``` +int32_t LayerUninitialize (LayerFuncs * funcs) +``` + +**æ述:** + +å–消图层åˆå§‹åŒ–功能,释放图层使用到的资æºï¼Œå¹¶é‡Šæ”¾å›¾å±‚æ“作接å£æŒ‡é’ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,图层æ“作接å£æŒ‡é’ˆï¼Œç”¨äºŽé‡Šæ”¾å›¾å±‚åˆå§‹åŒ–函数ä¸åˆ†é…çš„æ“作指针内å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + +**å‚è§ï¼š** + +[LayerInitialize](#layerinitialize) + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **å˜é‡è¯´æ˜Ž** + + +### alpha0 [1/2] + + +``` +uint8_t LayerAlpha::alpha0 +``` + +**æ述:** + +alpha0值,å–值范围:[0, 255] + + +### alpha0 [2/2] + + +``` +uint8_t ISurface::alpha0 +``` + +**æ述:** + +Alpha0值,å–值范围:[0,255] + + +### alpha1 [1/2] + + +``` +uint8_t LayerAlpha::alpha1 +``` + +**æ述:** + +alpha1值,å–值范围:[0, 255] + + +### alpha1 [2/2] + + +``` +uint8_t ISurface::alpha1 +``` + +**æ述:** + +Alpha1值,å–值范围:[0,255] + + +### alphaRopType + + +``` +RopType GfxOpt::alphaRopType +``` + +**æ述:** + +Alphaçš„Rop类型 + + +### bAlphaExt1555 + + +``` +bool ISurface::bAlphaExt1555 +``` + +**æ述:** + +是å¦ä½¿èƒ½1555çš„Alpha扩展 + + +### bAlphaMax255 + + +``` +bool ISurface::bAlphaMax255 +``` + +**æ述:** + +图åƒalpha最大值为255还是128 + + +### baseAddr + + +``` +void* __attribute__::baseAddr +``` + +**æ述:** + +内å˜çš„åˆå§‹åœ°å€ + + +### blendType + + +``` +BlendType GfxOpt::blendType +``` + +**æ述:** + +æ··åˆæ–¹å¼ + + +### bpp + + +``` +int32_t LayerInfo::bpp +``` + +**æ述:** + +æ¯åƒç´ 所å bitæ•° + + +### bYCbCrClut + + +``` +bool ISurface::bYCbCrClut +``` + +**æ述:** + +CLUT表是å¦ä½äºŽ YCbCr 空间 + + +### cbcrPhyAddr + + +``` +uint64_t ISurface::cbcrPhyAddr +``` + +**æ述:** + +CbCr分é‡åœ°å€ + + +### cbcrStride + + +``` +int32_t ISurface::cbcrStride +``` + +**æ述:** + +CbCr分é‡è·¨åº¦ + + +### clutPhyAddr + + +``` +uint64_t ISurface::clutPhyAddr +``` + +**æ述:** + +Clut表首地å€ï¼Œç”¨ä½œé¢œè‰²æ‰©å±•æˆ–é¢œè‰²æ ¡æ£ + + +### color [1/3] + + +``` +uint32_t ILine::color +``` + +**æ述:** + +线æ¡é¢œè‰² + + +### color [2/3] + + +``` +uint32_t ICircle::color +``` + +**æ述:** + +圆的颜色 + + +### color [3/3] + + +``` +uint32_t Rectangle::color +``` + +**æ述:** + +矩形颜色 + + +### colorKeyFrom + + +``` +ColorKey GfxOpt::colorKeyFrom +``` + +**æ述:** + +è‰²é”®æ¨¡å¼ + + +### colorRopType + + +``` +RopType GfxOpt::colorRopType +``` + +**æ述:** + +颜色的Rop类型 + + +### Commit + + +``` +int32_t(* DeviceFuncs::Commit) (uint32_t devId, int32_t *fence) +``` + +**æ述:** + +æ交åˆæˆé€æ˜¾è¯·æ±‚。 + +图形æœåŠ¡é€šè¿‡è¯¥æŽ¥å£å‘接å£å®žçŽ°å±‚æ交åˆæˆé€æ˜¾è¯·æ±‚,如果有硬件åˆæˆå±‚,接å£å®žçŽ°å±‚需è¦åœ¨è¿™æ—¶è¿›è¡Œåˆæˆï¼Œå¹¶ä¸”把最终åˆæˆçš„æ•°æ®é€åˆ°ç¡¬ä»¶è¿›è¡Œæ˜¾ç¤ºã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| fences | 输出å‚数,fence首地å€ï¼ŒæŒ‡å‘fence数组的首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### CreateVirtualDisplay + + +``` +int32_t(* DeviceFuncs::CreateVirtualDisplay) (uint32_t width, uint32_t height, int32_t *format, uint32_t *devId) +``` + +**æ述:** + +创建虚拟显示设备。 + +该接å£ç”¨äºŽåˆ›å»ºä¸€ä¸ªè™šæ‹Ÿæ˜¾ç¤ºè®¾å¤‡ã€‚ + +**å‚æ•°:** + +| å称 | æè¿° | +| -------- | -------- | +| width | 输入å‚数,指定显示设备的åƒç´ 宽度。 | +| height | 输入å‚数,指定显示设备的åƒç´ 高度。 | +| format | 输出å‚数,指定显示设备的åƒç´ æ ¼å¼ã€‚详情å‚考[PixelFormat](#pixelformat),接å£å®žçŽ°å±‚å¯ä»¥æ ¹æ®ç¡¬ä»¶éœ€æ±‚,修改format并返回给图形æœåŠ¡ã€‚ | +| devId | 输出å‚数,用于接å£å±‚返回创建的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### CreateWriteBack + + +``` +int32_t(* DeviceFuncs::CreateWriteBack) (uint32_t *devId, uint32_t width, uint32_t height, int32_t *format) +``` + +**æ述:** + +对指定显示设备创建回写点。 + +该接å£ç”¨æ¥å¯¹æŒ‡å®šçš„设备创建一个回写点,如果回写点数é‡è¶…过了é™åˆ¶ï¼ŒæŽ¥å£å®žçŽ°å±‚将会返回失败。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID,接å£å®žçŽ°å±‚在创建完回写点åŽå°†å›žå†™ç‚¹è®¾å¤‡IDå˜æ”¾åœ¨è¯¥å‚æ•°ä¸è¿”回给图形æœåŠ¡ã€‚ | +| width | 输入å‚数,回写åƒç´ 宽度。 | +| height | 输入å‚数,回写åƒç´ 高度。 | +| format | 输入å‚数,回写点数æ®æ ¼å¼ï¼Œè¯¦æƒ…å‚考[PixelFormat](#pixelformat),接å£å®žçŽ°å±‚å¯ä»¥æ ¹æ®ç¡¬ä»¶éœ€æ±‚,修改format并返回给图形æœåŠ¡ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### data + + +``` +BufferData LayerBuffer::data +``` + +**æ述:** + +图层bufferæ•°æ® + + +### DestroyVirtualDisplay + + +``` +int32_t(* DeviceFuncs::DestroyVirtualDisplay) (uint32_t devId) +``` + +**æ述:** + +销æ¯è™šæ‹Ÿæ˜¾ç¤ºè®¾å¤‡ã€‚ + +该接å£ç”¨äºŽé”€æ¯æŒ‡å®šçš„虚拟显示设备。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### DestroyWriteBack + + +``` +int32_t(* DeviceFuncs::DestroyWriteBack) (uint32_t devId) +``` + +**æ述:** + +销æ¯æŒ‡å®šæ˜¾ç¤ºè®¾å¤‡çš„回写点。 + +该接å£ç”¨ä¾†é”€æ¯æŒ‡å®šçš„回写点。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### enableRop + + +``` +bool GfxOpt::enableRop +``` + +**æ述:** + +RopåŠŸèƒ½ä½¿èƒ½ä½ + + +### enableScale + + +``` +bool GfxOpt::enableScale +``` + +**æ述:** + +ç¼©æ”¾åŠŸèƒ½ä½¿èƒ½ä½ + + +### enColorFmt + + +``` +PixelFormat ISurface::enColorFmt +``` + +**æ述:** + +图åƒæ ¼å¼ + + +### enGlobalAlpha [1/2] + + +``` +bool LayerAlpha::enGlobalAlpha +``` + +**æ述:** + +全局alphaä½¿èƒ½æ ‡å¿— + + +### enGlobalAlpha [2/2] + + +``` +bool GfxOpt::enGlobalAlpha +``` + +**æ述:** + +全局alphaä½¿èƒ½ä½ + + +### enPixelAlpha [1/2] + + +``` +bool LayerAlpha::enPixelAlpha +``` + +**æ述:** + +åƒç´ alphaä½¿èƒ½æ ‡å¿— + + +### enPixelAlpha [2/2] + + +``` +bool GfxOpt::enPixelAlpha +``` + +**æ述:** + +åƒç´ alphaä½¿èƒ½ä½ + + +### expectedSize + + +``` +uint32_t AllocInfo::expectedSize +``` + +**æ述:** + +申请内å˜å¤§å° + + +### fd + + +``` +int32_t __attribute__::fd +``` + +**æ述:** + +å¥æŸ„ fd,-1代表ä¸æ”¯æŒã€‚ + + +### fenceId + + +``` +int32_t LayerBuffer::fenceId +``` + +**æ述:** + +buffer çš„fenceå· + + +### format [1/2] + + +``` +PixelFormat AllocInfo::format +``` + +**æ述:** + +申请内å˜æ ¼å¼ + + +### format [2/2] + + +``` +PixelFormat VerifyAllocInfo::format +``` + +**æ述:** + +分é…内å˜çš„åƒç´ æ ¼å¼ + + +### formatCount + + +``` +uint32_t HDRCapability::formatCount +``` + +**æ述:** + +支æŒçš„HDRæ ¼å¼çš„æ•°é‡ + + +### formats + + +``` +HDRFormat* HDRCapability::formats +``` + +**æ述:** + +支æŒçš„HDRæ ¼å¼çš„æ•°ç»„é¦–åœ°å€ + + +### freshRate + + +``` +uint32_t DisplayModeInfo::freshRate +``` + +**æ述:** + +刷新速率 + + +### gAlpha + + +``` +uint8_t LayerAlpha::gAlpha +``` + +**æ述:** + +全局alpha值,å–值范围:[0, 255] + + +### GetDisplayBacklight + + +``` +int32_t(* DeviceFuncs::GetDisplayBacklight) (uint32_t devId, uint32_t *level) +``` + +**æ述:** + +获å–显示设备当å‰çš„背光值。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·å–设置显示设备的背光值。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| level | 输出å‚数,ä¿å˜å¯¹åº”设备的背光值,由接å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayCapability + + +``` +int32_t(* DeviceFuncs::GetDisplayCapability) (uint32_t devId, DisplayCapability *info) +``` + +**æ述:** + +获å–显示设备能力集。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·å–显示设备具备哪些显示能力。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| info | 输出å‚数,设备支æŒçš„能力级信æ¯ï¼Œè¯¦æƒ…å‚考 {\@DisplayCapability}。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayColorGamut + + +``` +int32_t(* DeviceFuncs::GetDisplayColorGamut) (uint32_t devId, ColorGamut *gamut) +``` + +**æ述:** + +获å–显示设备当å‰çš„色域模å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| gamut | 输出å‚数,ä¿å˜å¯¹åº”设备的色域模å¼ï¼Œç”±æŽ¥å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayCompChange + + +``` +int32_t(* DeviceFuncs::GetDisplayCompChange) (uint32_t devId, uint32_t *num, uint32_t *Layers, int32_t *type) +``` + +**æ述:** + +获å–显示设备åˆæˆç±»åž‹æœ‰å˜åŒ–çš„layer。 + +在åˆæˆå‡†å¤‡é˜¶æ®µï¼Œæ˜¾ç¤ºè®¾å¤‡ä¼šæ ¹æ®è®¾å¤‡çš„åˆæˆèƒ½åŠ›ä¿®æ”¹å›¾å±‚çš„åˆæˆç±»åž‹ï¼Œè¯¥æŽ¥å£ä¼šè¿”回哪些图层åˆæˆç±»åž‹å‘生了å˜åŒ–。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输出å‚数,表示åˆæˆç±»åž‹å‘生了å˜åŒ–的图层数é‡ã€‚ | +| Layers | 输出å‚数,指å‘图层数组首地å€ã€‚ | +| type | 输出å‚数,指å‘åˆæˆç±»åž‹æ•°ç»„首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayGamutMap + + +``` +int32_t(* DeviceFuncs::GetDisplayGamutMap) (uint32_t devId, GamutMap *gamutMap) +``` + +**æ述:** + +获å–显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| gamutMap | 输出å‚数,ä¿å˜å¯¹åº”è®¾å¤‡çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ï¼Œç”±æŽ¥å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayMode + + +``` +int32_t(* DeviceFuncs::GetDisplayMode) (uint32_t devId, uint32_t *modeId) +``` + +**æ述:** + +获å–显示设备当å‰çš„显示模å¼ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·å–显示设备当å‰çš„显示模å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| modeId | 输出å‚数,å˜æ”¾å½“å‰è®¾å¤‡çš„显示模å¼ID, 由接å£å®žçŽ°å±‚进行数æ®çš„写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayPowerStatus + + +``` +int32_t(* DeviceFuncs::GetDisplayPowerStatus) (uint32_t devId, DispPowerStatus *status) +``` + +**æ述:** + +获å–显示设备当å‰çš„电æºçŠ¶æ€ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„电æºçŠ¶æ€ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| status | 输出å‚数,ä¿å˜å¯¹åº”设备的电æºçŠ¶æ€ï¼Œç”±æŽ¥å£å®žçŽ°å±‚进行状æ€çš„写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayProperty + + +``` +int32_t(* DeviceFuncs::GetDisplayProperty) (uint32_t devId, uint32_t id, uint64_t *value) +``` + +**æ述:** + +获得显示设备属性值。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·å–显示设备具体的属性值。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| id | 输入å‚数,由接å£GetDisplayCapability返回属性ID。 | +| level | 输出å‚数,属性ID对应的属性值,由接å£å®žçŽ°å±‚写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplayReleaseFence + + +``` +int32_t(* DeviceFuncs::GetDisplayReleaseFence) (uint32_t devId, uint32_t *num, uint32_t *layers, int32_t *fences) +``` + +**æ述:** + +获å–显示图层fence。 + +图形æœåŠ¡åœ¨è°ƒç”¨æŽ¥å£CommitåŽï¼Œéœ€è¦é€šè¿‡è¯¥æŽ¥å£èŽ·å–图层的fenceä¿¡æ¯ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输出å‚数,图层个数。 | +| layers | 输出å‚数,图层首地å€ï¼ŒæŒ‡å‘图层数组的首地å€ã€‚ | +| fences | 输出å‚数,fence首地å€ï¼ŒæŒ‡å‘fence数组的首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplaySupportedColorGamuts + + +``` +int32_t(* DeviceFuncs::GetDisplaySupportedColorGamuts) (uint32_t devId, uint32_t *num, ColorGamut *gamuts) +``` + +**æ述:** + +获å–显示设备支æŒçš„色域信æ¯ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输出å‚数,设备支æŒçš„色域数组个数。 | +| gamuts | 输出å‚数,色域首地å€ï¼ŒæŒ‡å‘色域数组首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetDisplaySupportedModes + + +``` +int32_t(* DeviceFuncs::GetDisplaySupportedModes) (uint32_t devId, uint32_t *num, DisplayModeInfo *modes) +``` + +**æ述:** + +获å–显示设备支æŒçš„显示模å¼ä¿¡æ¯ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·å–到显示设备支æŒå“ªäº›æ˜¾ç¤ºæ¨¡å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输出å‚数,设备支æŒçš„模å¼æ•°é‡ã€‚ | +| modes | 输出å‚数,设备支æŒçš„所有模å¼ä¿¡æ¯ï¼ŒåŒ…括所有能支æŒçš„分辨率和刷新率,æ¯ä¸€ä¸ªæ¨¡å¼å®žçŽ°å±‚都有一个Id与之对应,在获å–当å‰æ¨¡å¼ 和设置当å‰æ¨¡å¼æ—¶éƒ½ä¼šä½¿ç”¨åˆ°ï¼Œè¯¦æƒ…å‚考 {\@DisplayModeInfo}。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetHDRCapabilityInfos + + +``` +int32_t(* DeviceFuncs::GetHDRCapabilityInfos) (uint32_t devId, HDRCapability *info) +``` + +**æ述:** + +获å–显示设备支æŒçš„HDR属性信æ¯ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| info | 输出å‚数,ä¿å˜å¯¹åº”设备的HDR属性信æ¯ï¼Œç”±æŽ¥å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetSupportedMetadataKey + + +``` +int32_t(* DeviceFuncs::GetSupportedMetadataKey) (uint32_t devId, uint32_t *num, HDRMetadataKey *keys) +``` + +**æ述:** + +获å–显示设备支æŒçš„ HDRMetadataKey。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输出å‚数,设备支æŒçš„HDRMetadataKey数组个数。 | +| keys | 输出å‚数,HDRMetadataKey首地å€ï¼ŒæŒ‡å‘HDRMetadataKey数组首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### GetWriteBackFrame + + +``` +int32_t(* DeviceFuncs::GetWriteBackFrame) (uint32_t devId, BufferHandle *buffer, int32_t *fence) +``` + +**æ述:** + +获å–显示设备的回写帧。 + +该接å£ç”¨æ¥èŽ·å–devId指定的回写点数æ®ï¼ŒæŽ¥å£å®žçŽ°å±‚将显示设备回写点的数æ®å†™å…¥åˆ°è®¾ç½®çš„缓å˜ä¸ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| buffer | 输出å‚数,回写点数æ®ç¼“å˜ã€‚ | +| fence | 输出å‚数,åŒæ¥æ …æ ,图形æœåŠ¡åœ¨è°ƒç”¨è¯¥æŽ¥å£æ—¶ï¼Œéœ€è¦å°†Bufferçš„release fence ä¼ å…¥ï¼Œæ ‡è®°è¯¥ç¼“å˜æ˜¯å¦å¯ä»¥è¢«å†™å…¥ï¼ŒæŽ¥å£å®žçŽ°å±‚在接å£è¿”回å‰éœ€è¦å°†bufferçš„acquirce fence å†™å…¥å›žä¼ ç»™å›¾å½¢æœåŠ¡ï¼Œç”¨æ¥æ ‡è®°å›žå†™æ•°æ®æ˜¯å¦å·²ç»å†™å…¥ç¼“å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### globalAlpha + + +``` +uint32_t GfxOpt::globalAlpha +``` + +**æ述:** + +全局alpha的值 + + +### h + + +``` +int32_t IRect::h +``` + +**æ述:** + +矩形框高度 + + +### hdl + + +``` +BufferHandle* LayerBuffer::hdl +``` + +**æ述:** + +图层bufferå¥æŸ„ + + +### height [1/7] + + +``` +uint32_t DisplayInfo::height +``` + +**æ述:** + +显示å±é«˜åº¦ + + +### height [2/7] + + +``` +int32_t LayerInfo::height +``` + +**æ述:** + +图层高度 + + +### height [3/7] + + +``` +int32_t LayerBuffer::height +``` + +**æ述:** + +buffer高度 + + +### height [4/7] + + +``` +int32_t ISurface::height +``` + +**æ述:** + +图åƒé«˜åº¦ + + +### height [5/7] + + +``` +int32_t DisplayModeInfo::height +``` + +**æ述:** + +åƒç´ 高度 + + +### height [6/7] + + +``` +uint32_t AllocInfo::height +``` + +**æ述:** + +申请内å˜é«˜åº¦ + + +### height [7/7] + + +``` +uint32_t VerifyAllocInfo::height +``` + +**æ述:** + +分é…内å˜çš„高度 + + +### id + + +``` +int32_t DisplayModeInfo::id +``` + +**æ述:** + +模å¼ID + + +### InvokeDisplayCmd + + +``` +int32_t(* DeviceFuncs::InvokeDisplayCmd) (uint32_t devId,...) +``` + +**æ述:** + +调用显示设备命令。 + +该接å£ç”¨äºŽå›¾å½¢æœåŠ¡å’ŒæŽ¥å£å®žçŽ°å±‚之间的接å£æ‰©å±•ï¼Œå¦‚果由临时接å£æ–°å¢žå¯ä»¥é€šè¿‡è¯¥æŽ¥å£è¿›è¡Œæ‰©å±•ï¼Œä¸ç”¨å¢žåŠ 新的接å£å®šä¹‰ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### key + + +``` +HDRMetadataKey HDRMetaData::key +``` + +**æ述:** + +HDR元数æ®å…³é”®å— + + +### maxAverageLum + + +``` +float HDRCapability::maxAverageLum +``` + +**æ述:** + +最大的平å‡å…‰äº®åº¦luminance值 + + +### maxLum + + +``` +float HDRCapability::maxLum +``` + +**æ述:** + +最大的光亮度luminance值 + + +### minLum + + +``` +float HDRCapability::minLum +``` + +**æ述:** + +最å°çš„光亮度luminance值 + + +### mirrorType + + +``` +MirrorType GfxOpt::mirrorType +``` + +**æ述:** + +é•œåƒç±»åž‹ + + +### name [1/2] + + +``` +char PropertyObject::name[PROPERTY_NAME_LEN] +``` + +**æ述:** + +属性å称 + + +### name [2/2] + + +``` +char DisplayCapability::name[PROPERTY_NAME_LEN] +``` + +**æ述:** + +显示设备å称 + + +### phyAddr [1/2] + + +``` +uint64_t BufferData::phyAddr +``` + +**æ述:** + +物ç†å†…å˜åœ°å€ + + +### phyAddr [2/2] + + +``` +uint64_t ISurface::phyAddr +``` + +**æ述:** + +图åƒé¦–åœ°å€ + + +### phyHeight + + +``` +uint32_t DisplayCapability::phyHeight +``` + +**æ述:** + +物ç†é«˜åº¦ + + +### phyWidth + + +``` +uint32_t DisplayCapability::phyWidth +``` + +**æ述:** + +物ç†å®½åº¦ + + +### pitch + + +``` +int32_t LayerBuffer::pitch +``` + +**æ述:** + +一行数æ®æ‰€å å—节数 + + +### pixFormat [1/2] + + +``` +PixelFormat LayerInfo::pixFormat +``` + +**æ述:** + +图层åƒç´ æ ¼å¼ + + +### pixFormat [2/2] + + +``` +PixelFormat LayerBuffer::pixFormat +``` + +**æ述:** + +bufferåƒç´ æ ¼å¼ + + +### PrepareDisplayLayers + + +``` +int32_t(* DeviceFuncs::PrepareDisplayLayers) (uint32_t devId, bool *needFlushFb) +``` + +**æ述:** + +显示设备åˆæˆå‰å‡†å¤‡ã€‚ + +图形æœåŠ¡åœ¨åˆæˆå‰éœ€è¦é€šè¿‡è¯¥æŽ¥å£é€šçŸ¥æ˜¾ç¤ºè®¾å¤‡è¿›è¡Œåˆæˆå‰çš„准备工作。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| needFlushFb | 输出å‚数,接å£å®žçŽ°å±‚通过该å‚数指示图形æœåŠ¡åœ¨commitå‰æ˜¯å¦éœ€è¦é€šè¿‡SetDisplayClientBufferé‡æ–°è®¾ç½®æ˜¾ç¤ºå¸§å˜ã€‚ true表示需è¦è®¾ç½®æ˜¾ç¤ºå¸§å˜ï¼Œfalse表示ä¸éœ€è¦ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### propertyCount + + +``` +uint32_t DisplayCapability::propertyCount +``` + +**æ述:** + +å±žæ€§æ•°ç»„å¤§å° + + +### propId + + +``` +uint32_t PropertyObject::propId +``` + +**æ述:** + +属性ID + + +### props + + +``` +PropertyObject* DisplayCapability::props +``` + +**æ述:** + +属性数组 + + +### r + + +``` +int32_t ICircle::r +``` + +**æ述:** + +圆的åŠå¾„ + + +### rect + + +``` +IRect Rectangle::rect +``` + +**æ述:** + +矩形区域 + + +### RegDisplayRefreshCallback + + +``` +int32_t(* DeviceFuncs::RegDisplayRefreshCallback) (uint32_t devId, RefreshCallback callback, void *data) +``` + +**æ述:** + +刷新请求回调。 + +注册刷新请求事件回调,当实现层有刷新需求时,实现层通过回调注册的接å£é€šçŸ¥å›¾å½¢æœåŠ¡ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| callback | 输入å‚数,刷新请求事件回调实例,当有接å£å®žçŽ°å±‚有刷新请求时,需è¦é€šè¿‡è¯¥å®žä¾‹é€šçŸ¥å›¾å½¢æœåŠ¡ã€‚ | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œåœ¨äº‹ä»¶å›žè°ƒæŽ¥å£ä¸éœ€è¦è¿”回给图形æœåŠ¡ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### RegDisplayVBlankCallback + + +``` +int32_t(* DeviceFuncs::RegDisplayVBlankCallback) (uint32_t devId, VBlankCallback callback, void *data) +``` + +**æ述:** + +注册VBlank事件回调。 + +注册VBlank事件回调,当有VBlank事件å‘生时接å£å®žçŽ°å±‚需è¦å›žè°ƒæ³¨å†Œçš„接å£ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| callback | 输入å‚数,VBlank事件回调实例,当有VBlank事件å‘生时并且DisplayVsync处于Enable状æ€ï¼ŒæŽ¥å£å®žçŽ°å±‚需è¦é€šè¿‡è¯¥å®žä¾‹é€šçŸ¥å›¾å½¢æœåŠ¡ã€‚ | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œåœ¨äº‹ä»¶å›žè°ƒæŽ¥å£ä¸éœ€è¦è¿”回给图形æœåŠ¡ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### RegHotPlugCallback + + +``` +int32_t(* DeviceFuncs::RegHotPlugCallback) ((HotPlugCallback callback, void *data) +``` + +**æ述:** + +注册çƒæ’拔事件回调。 + +注册çƒæ’拔事件回调,当有çƒæ’拔事件å‘生时接å£å®žçŽ°å±‚需è¦å›žè°ƒæ³¨å†Œçš„接å£ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| callback | 输入å‚数,çƒæ’拔事件回调实例,当有çƒæ’拔事件å‘生时,接å£å®žçŽ°å±‚需è¦é€šè¿‡è¯¥å®žä¾‹é€šçŸ¥å›¾å½¢æœåŠ¡ã€‚ | +| data | 输出å‚数,图形æœåŠ¡æºå¸¦çš„ç§æœ‰æ•°æ®ï¼Œåœ¨äº‹ä»¶å›žè°ƒæŽ¥å£ä¸éœ€è¦è¿”回给图形æœåŠ¡ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### reserve + + +``` +int32_t __attribute__::reserve[0] +``` + +**æ述:** + +reserve数组 + + +### reserveInts + + +``` +uint32_t __attribute__::reserveInts +``` + +**æ述:** + +reserve数组的个数 + + +### rotAngle + + +``` +int32_t DisplayInfo::rotAngle +``` + +**æ述:** + +显示å±æ—‹è½¬è§’度 + + +### rotateType + + +``` +TransformType GfxOpt::rotateType +``` + +**æ述:** + +旋转类型 + + +### SetDisplayBacklight + + +``` +int32_t(* DeviceFuncs::SetDisplayBacklight) (uint32_t devId, uint32_t level) +``` + +**æ述:** + +设置显示设备当å‰çš„背光值。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„背光值。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| level | 输入å‚数,表示需è¦è®¾ç½®çš„背光值。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayClientBuffer + + +``` +int32_t(* DeviceFuncs::SetDisplayClientBuffer) (uint32_t devId, const BufferHandle *buffer, int32_t fence) +``` + +**æ述:** + +设置显示设备的显示缓å˜ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£å°†æ˜¾ç¤ºç¼“å˜è®¾ç½®ç»™æ˜¾ç¤ºè®¾å¤‡ï¼Œæ˜¾ç¤ºè®¾å¤‡ç¡¬ä»¶åˆæˆç»“果将会å˜æ”¾åœ¨è¯¥æ˜¾ç¤ºç¼“å˜ä¸ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| buffer | 输入å‚数,显示缓å˜ã€‚ | +| fence | 输入å‚数,åŒæ¥æ …æ ï¼Œæ ‡è¯†æ˜¾ç¤ºç¼“å˜æ˜¯å¦å¯ä»¥è®¿é—®ï¼Œæœ‰å›¾å½¢æœåŠ¡åˆ›å»ºå’Œé‡Šæ”¾ï¼ŒæŽ¥å£å®žçŽ°å±‚需è¦ç‰å¾…åŒæ¥æ …æ å‘é€ä¿¡å·åŽæ‰èƒ½ä½¿ç”¨æ˜¾ç¤ºç¼“å˜ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayClientCrop + + +``` +int32_t(* DeviceFuncs::SetDisplayClientCrop) (uint32_t devId, IRect *rect) +``` + +**æ述:** + +设置显示设备的è£å‰ªåŒºåŸŸã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„ClientBufferçš„è£å‰ªåŒºåŸŸï¼Œè£å‰ªåŒºåŸŸä¸èƒ½è¶…过ClientBuffer的大å°ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| rect | 输入å‚数,ClientBufferçš„è£å‰ªåŒºåŸŸã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayClientDamage + + +``` +int32_t(* DeviceFuncs::SetDisplayClientDamage) (uint32_t devId, uint32_t num, IRect *rect) +``` + +**æ述:** + +设置显示设备的显示è„区。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£è®¾ç½®æ˜¾ç¤ºè®¾å¤‡è„区,接å£å®žçŽ°å±‚å¯ä»¥æ ¹æ®è¯¥åŒºåŸŸè¿›è¡ŒåŒºåŸŸåˆ·æ–°ï¼Œè„区是由多个矩形区域组åˆèµ·æ¥çš„。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| num | 输入å‚数,矩形个数。 | +| rect | 输入å‚数,区域矩形指针,指å‘矩形数组的首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayClientDestRect + + +``` +int32_t(* DeviceFuncs::SetDisplayClientDestRect) (uint32_t devId, IRect *rect) +``` + +**æ述:** + +设置显示设备的显示区域。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„显示区域。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| rect | 输入å‚数,显示区域。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayColorGamut + + +``` +int32_t(* DeviceFuncs::SetDisplayColorGamut) (uint32_t devId, ColorGamut gamut) +``` + +**æ述:** + +设置显示设备当å‰çš„色域模å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| gamut | 输入å‚数,表示需è¦è®¾ç½®çš„色域模å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayColorTransform + + +``` +int32_t(* DeviceFuncs::SetDisplayColorTransform) (uint32_t devId, const float *matrix) +``` + +**æ述:** + +设置显示设备当å‰çš„4x4的颜色转æ¢çŸ©é˜µã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| matrix | 输入å‚数,表示需è¦è®¾ç½®çš„颜色转æ¢æ¨¡å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayGamutMap + + +``` +int32_t(* DeviceFuncs::SetDisplayGamutMap) (uint32_t devId, GamutMap gamutMap) +``` + +**æ述:** + +设置显示设备当å‰çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| gamutMap | 输入å‚数,表示需è¦è®¾ç½®çš„è‰²åŸŸæ˜ å°„æ¨¡å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayMode + + +``` +int32_t(* DeviceFuncs::SetDisplayMode) (uint32_t devId, uint32_t modeId) +``` + +**æ述:** + +设置显示设备的显示模å¼ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„显示模å¼ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| modeId | 输入å‚数,指明需è¦è®¾ç½®çš„模å¼ID,接å£å®žçŽ°å±‚将设备切æ¢åˆ°è¯¥å‚数对应的显示模å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayPowerStatus + + +``` +int32_t(* DeviceFuncs::SetDisplayPowerStatus) (uint32_t devId, DispPowerStatus status) +``` + +**æ述:** + +设置显示设备当å‰çš„电æºçŠ¶æ€ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£èŽ·è®¾ç½®æ˜¾ç¤ºè®¾å¤‡çš„电æºçŠ¶æ€ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| status | 输入å‚数,表示需è¦è®¾ç½®çš„电æºçŠ¶æ€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayProperty + + +``` +int32_t(* DeviceFuncs::SetDisplayProperty) (uint32_t devId, uint32_t id, uint64_t value) +``` + +**æ述:** + +设置显示设备属性值。 + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£è®¾ç½®æ˜¾ç¤ºè®¾å¤‡å…·ä½“的属性值。 + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| id | 输入å‚数,由接å£GetDisplayCapability返回属性ID。 | +| value | 输入å‚数,需è¦è®¾ç½®çš„属性值。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetDisplayVsyncEnabled + + +``` +int32_t(* DeviceFuncs::SetDisplayVsyncEnabled) (uint32_t devId, bool enabled) +``` + +**æ述:** + +使能垂直åŒæ¥ä¿¡å·ã€‚ + +图形æœåŠ¡å¯ä»¥é€šè¿‡è¯¥æŽ¥å£ä½¿èƒ½æˆ–å–消垂直åŒæ¥ä¿¡å·ï¼Œå½“有垂直åŒæ¥ä¿¡å·äº§ç”Ÿæ—¶ï¼ŒæŽ¥å£å®žçŽ°å±‚需è¦å›žè°ƒå›¾å½¢æœåŠ¡é€šè¿‡RegDisplayVBlankCallback注册的 VBlankCallback 回调。 图形æœåŠ¡åœ¨éœ€è¦åˆ·æ–°æ˜¾ç¤ºæ—¶éœ€è¦ä½¿èƒ½åž‚ç›´åŒæ¥ä¿¡å·ï¼Œåœ¨æ”¶åˆ°VBlankCallback事件回调时å†è¿›è¡Œåˆæˆé€æ˜¾ï¼Œä¸éœ€è¦åˆ·æ–°æ˜¾ç¤ºæ—¶éœ€è¦å–消垂直åŒæ¥ä¿¡å·ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| enabled | 输入å‚数,使能状æ€ï¼Œtrue表示能,false表示ä¸èƒ½ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### SetVirtualDisplayBuffer + + +``` +int32_t(* DeviceFuncs::SetVirtualDisplayBuffer) (uint32_t devId, BufferHandle *buffer, int32_t fence) +``` + +**æ述:** + +设置虚拟å±çš„输出缓å˜ã€‚ + +该接å£ç”¨äºŽè®¾ç½®è™šæ‹Ÿå±è¾“出缓å˜ï¼ŒæŽ¥å£å®žçŽ°å±‚需è¦å°†è™šæ‹Ÿå±çš„输出放入到该缓å˜ä¸ï¼ŒæŽ¥å£å®žçŽ°å±‚需è¦ç‰å¾…åŒæ¥æ …æ å‘é€ä¿¡å·åŽæ‰èƒ½ä½¿ç”¨ç¼“å˜ã€‚ + +**å‚æ•°:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| buffer | 输出å‚数,输出缓å˜ã€‚ | +| fence | 输出å‚数,åŒæ¥æ …æ 。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](#disperrcode)。 + + +### stride + + +``` +int32_t ISurface::stride +``` + +**æ述:** + +图åƒè·¨åº¦ + + +### supportLayers + + +``` +uint32_t DisplayCapability::supportLayers +``` + +**æ述:** + +支æŒçš„图层数 + + +### supportWriteBack + + +``` +bool DisplayCapability::supportWriteBack +``` + +**æ述:** + +是å¦æ”¯æŒå›žå†™ + + +### time + + +``` +int64_t PresentTimestamp::time +``` + +**æ述:** + +类型对应的值 + + +### type [1/3] + + +``` +LayerType LayerInfo::type +``` + +**æ述:** + +图层类型,包括图形层ã€è§†é¢‘层和媒体æ’æ”¾æ¨¡å¼ + + +### type [2/3] + + +``` +InterfaceType DisplayCapability::type +``` + +**æ述:** + +显示å±æŽ¥å£ç±»åž‹ + + +### type [3/3] + + +``` +PresentTimestampType PresentTimestamp::type +``` + +**æ述:** + +上å±æ—¶é—´æˆ³ç±»åž‹ + + +### uOffset + + +``` +size_t __attribute__::uOffset +``` + +**æ述:** + +Uçš„åç§»é‡ + + +### usage [1/2] + + +``` +uint64_t AllocInfo::usage +``` + +**æ述:** + +申请内å˜çš„使用场景 + + +### usage [2/2] + + +``` +uint64_t VerifyAllocInfo::usage +``` + +**æ述:** + +内å˜çš„用处 + + +### uvStep + + +``` +size_t __attribute__::uvStep +``` + +**æ述:** + +UVçš„stepä¿¡æ¯ + + +### uvStride + + +``` +size_t __attribute__::uvStride +``` + +**æ述:** + +UVçš„strideä¿¡æ¯ + + +### value [1/2] + + +``` +uint64_t PropertyObject::value +``` + +**æ述:** + +属性值 + + +### value [2/2] + + +``` +float HDRMetaData::value +``` + +**æ述:** + +关键å—对应的值 + + +### virAddr + + +``` +void* BufferData::virAddr +``` + +**æ述:** + +虚拟内å˜åœ°å€ + + +### virtualDispCount + + +``` +uint32_t DisplayCapability::virtualDispCount +``` + +**æ述:** + +支æŒçš„虚拟å±æ•° + + +### vOffset + + +``` +size_t __attribute__::vOffset +``` + +**æ述:** + +Vçš„åç§»é‡ + + +### w + + +``` +int32_t IRect::w +``` + +**æ述:** + +矩形框宽度 + + +### width [1/7] + + +``` +uint32_t DisplayInfo::width +``` + +**æ述:** + +显示å±å®½åº¦ + + +### width [2/7] + + +``` +int32_t LayerInfo::width +``` + +**æ述:** + +图层宽度 + + +### width [3/7] + + +``` +int32_t LayerBuffer::width +``` + +**æ述:** + +buffer宽度 + + +### width [4/7] + + +``` +int32_t ISurface::width +``` + +**æ述:** + +图åƒå®½åº¦ + + +### width [5/7] + + +``` +int32_t DisplayModeInfo::width +``` + +**æ述:** + +åƒç´ 宽度 + + +### width [6/7] + + +``` +uint32_t AllocInfo::width +``` + +**æ述:** + +申请内å˜å®½åº¦ + + +### width [7/7] + + +``` +uint32_t VerifyAllocInfo::width +``` + +**æ述:** + +分é…内å˜çš„宽度 + + +### x [1/2] + + +``` +int32_t IRect::x +``` + +**æ述:** + +矩形框起始xåæ ‡ + + +### x [2/2] + + +``` +int32_t ICircle::x +``` + +**æ述:** + +圆心xåæ ‡ + + +### x0 + + +``` +int32_t ILine::x0 +``` + +**æ述:** + +线æ¡èµ·ç‚¹çš„xåæ ‡ + + +### x1 + + +``` +int32_t ILine::x1 +``` + +**æ述:** + +线æ¡ç»ˆç‚¹çš„xåæ ‡ + + +### y [1/2] + + +``` +int32_t IRect::y +``` + +**æ述:** + +矩形框起始yåæ ‡ + + +### y [2/2] + + +``` +int32_t ICircle::y +``` + +**æ述:** + +圆心yåæ ‡r + + +### y0 + + +``` +int32_t ILine::y0 +``` + +**æ述:** + +线æ¡èµ·ç‚¹çš„yåæ ‡ + + +### y1 + + +``` +int32_t ILine::y1 +``` + +**æ述:** + +线æ¡ç»ˆç‚¹çš„yåæ ‡ + + +### yOffset + + +``` +size_t __attribute__::yOffset +``` + +**æ述:** + +Yçš„åç§»é‡ + + +### yStride + + +``` +size_t __attribute__::yStride +``` + +**æ述:** + +Yçš„strideä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_capability.md b/zh-cn/device-dev/reference/hdi-apis/_display_capability.md new file mode 100644 index 0000000000000000000000000000000000000000..a4a43e5cb58d12934ab7589b6e901c97b5a4c3c7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_display_capability.md @@ -0,0 +1,31 @@ +# DisplayCapability + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [name](_display.md#name-22) [PROPERTY_NAME_LEN] | 显示设备å称 | +| [type](_display.md#type-23) | 显示å±æŽ¥å£ç±»åž‹ | +| [phyWidth](_display.md#phywidth) | 物ç†å®½åº¦ | +| [phyHeight](_display.md#phyheight) | 物ç†é«˜åº¦ | +| [supportLayers](_display.md#supportlayers) | 支æŒçš„图层数 | +| [virtualDispCount](_display.md#virtualdispcount) | 支æŒçš„虚拟å±æ•° | +| [supportWriteBack](_display.md#supportwriteback) | 是å¦æ”¯æŒå›žå†™ | +| [propertyCount](_display.md#propertycount) | å±žæ€§æ•°ç»„å¤§å° | +| [props](_display.md#props) | 属性数组 | + + +## **详细æè¿°** + +定义输出性能。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_info.md b/zh-cn/device-dev/reference/hdi-apis/_display_info.md new file mode 100644 index 0000000000000000000000000000000000000000..b67997b6de13b855cdea17de0987e37d70b233be --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_display_info.md @@ -0,0 +1,25 @@ +# DisplayInfo + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](_display.md#width-17) | 显示å±å®½åº¦ | +| [height](_display.md#height-17) | 显示å±é«˜åº¦ | +| [rotAngle](_display.md#rotangle) | 显示å±æ—‹è½¬è§’度 | + + +## **详细æè¿°** + +定义显示信æ¯ç»“构体。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md b/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md new file mode 100644 index 0000000000000000000000000000000000000000..eafd58d19e35fad8b0a08e5389bd1ca9e34b1209 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_display_mode_info.md @@ -0,0 +1,26 @@ +# DisplayModeInfo + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](_display.md#width-57) | åƒç´ 宽度 | +| [height](_display.md#height-57) | åƒç´ 高度 | +| [freshRate](_display.md#freshrate) | 刷新速率 | +| [id](_display.md#id) | 模å¼ID | + + +## **详细æè¿°** + +定义输出模å¼ä¿¡æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md b/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md new file mode 100644 index 0000000000000000000000000000000000000000..cc322e8336343a6499543a67f7ca6565cf3f29b3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_enroll_param.md @@ -0,0 +1,72 @@ +# EnrollParam + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | +| [executorType](#executortype) | 执行器类型。 | +| [executorId](#executorsensorhint) | 既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ | + + +## **详细æè¿°** + +录入结果信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType EnrollParam::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹ã€‚ + + +### executorSensorHint + + +``` +unsigned int EnrollParam::executorSensorHint +``` + +**æ述:** + +既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ + + +### executorType + + +``` +unsigned int EnrollParam::executorType +``` + +**æ述:** + +执行器类型。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md b/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md new file mode 100644 index 0000000000000000000000000000000000000000..a1213411c37768ce085514a640f8d89adc301a63 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_enroll_resultinfo.md @@ -0,0 +1,72 @@ +# EnrollResultInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [credentialId](#credentialid) | 认è¯å‡æ®ID。 | +| [oldInfo](#oldinfo) | æ—§å‡æ®ä¿¡æ¯ã€‚ | +| [rootSecret](#rootsecret) | ä¿æŠ¤æ–‡ä»¶åŠ 密密钥的密钥。 | + + +## **详细æè¿°** + +注册认è¯å‡æ®å‚数。 + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### credentialId + + +``` +unsigned long EnrollResultInfo::credentialId +``` + +**æ述:** + +认è¯å‡æ®ID。 + + +### oldInfo + + +``` +struct CredentialInfo EnrollParam::oldInfo +``` + +**æ述:** + +æ—§å‡æ®ä¿¡æ¯{\@link CredentialInfo}。 + + +### rootSecret + + +``` +unsigned char[] EnrollParam::rootSecret +``` + +**æ述:** + +ä¿æŠ¤æ–‡ä»¶åŠ 密密钥的密钥。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md b/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md new file mode 100644 index 0000000000000000000000000000000000000000..36c6ffd6e1e8e66e645074fd4fb3b81388059e14 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_enrolled_info.md @@ -0,0 +1,59 @@ +# EnrolledInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [enrolledId](#enrolledid) | 注册ID,用户注册新的认è¯å‡æ®æ—¶ä¼šæ›´æ–°æ³¨å†ŒID。 | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | + + +## **详细æè¿°** + +注册信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType EnrolledInfo::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹AuthType}。 + + +### enrolledId + + +``` +unsigned long EnrolledInfo::enrolledId +``` + +**æ述:** + +注册ID,用户注册新的认è¯å‡æ®æ—¶ä¼šæ›´æ–°æ³¨å†ŒID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_event_info.md b/zh-cn/device-dev/reference/hdi-apis/_event_info.md new file mode 100644 index 0000000000000000000000000000000000000000..02b70dc552b5ced6c3ed1b8f1cc995cce92fab1d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_event_info.md @@ -0,0 +1,103 @@ +# EventInfo + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [appData](#appdata) | 设置回调时给入的上层实例。 | +| [appDataLen](#appdatalen) | appDataå—节数。 | +| [data1](#data1) | 事件上报æºå¸¦çš„æ•°æ®1。 | +| [data2](#data2) | 事件上报æºå¸¦çš„æ•°æ®2。 | +| [eventData](#eventdata) | 事件上报æºå¸¦çš„æ•°æ®ä¿¡æ¯ã€‚ | +| [eventDataLen](#eventdatalen) | eventDataå—节数。 | + + +## **详细æè¿°** + +定义事件上报信æ¯ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### appData + + +``` +int8_t* EventInfo::appData +``` + +**æ述:** + +设置回调时给入的上层实例 + + +### appDataLen + + +``` +uint32_t EventInfo::appDataLen +``` + +**æ述:** + +appDataå—节数 + + +### data1 + + +``` +uint32_t EventInfo::data1 +``` + +**æ述:** + +事件上报æºå¸¦çš„æ•°æ®1 + + +### data2 + + +``` +uint32_t EventInfo::data2 +``` + +**æ述:** + +事件上报æºå¸¦çš„æ•°æ®2 + + +### eventData + + +``` +int8_t* EventInfo::eventData +``` + +**æ述:** + +事件上报æºå¸¦çš„æ•°æ®ä¿¡æ¯ + + +### eventDataLen + + +``` +uint32_t EventInfo::eventDataLen +``` + +**æ述:** + +eventDataå—节数 diff --git a/zh-cn/device-dev/reference/hdi-apis/_event_package.md b/zh-cn/device-dev/reference/hdi-apis/_event_package.md new file mode 100644 index 0000000000000000000000000000000000000000..d044d04799d0a1a4c8c726025cbb3624db1a7bf5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_event_package.md @@ -0,0 +1,77 @@ +# InputEventPackage + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [type](#type) | 输入事件的属性 | +| [code](#code) | 输入事件的特定编ç 项 | +| [value](#value) | 输入事件编ç 项对应的值 | +| [timestamp](#timestamp) | 输入事件对应的时间戳 | + + +## **详细æè¿°** + +Input事件数æ®åŒ…结构。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### code + + +``` +uint32_t EventPackage::code +``` + +**æ述:** + +输入事件的特定编ç 项 + + +### timestamp + + +``` +uint64_t EventPackage::timestamp +``` + +**æ述:** + +输入事件对应的时间戳 + + +### type + + +``` +uint32_t EventPackage::type +``` + +**æ述:** + +输入事件的属性 + + +### value + + +``` +int32_t EventPackage::value +``` + +**æ述:** + +输入事件编ç 项对应的值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_info.md b/zh-cn/device-dev/reference/hdi-apis/_executor_info.md new file mode 100644 index 0000000000000000000000000000000000000000..29f4d116ca581180a4a07be6ffccddbc250ee365 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_info.md @@ -0,0 +1,152 @@ +# ExecutorInfo + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) | [HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [sensorId](#sensorid) | ä¼ æ„Ÿå™¨ID,ä¸åŒä¼ 感器在人脸/å£ä»¤è®¤è¯é©±åŠ¨å†…çš„å”¯ä¸€æ ‡è¯†ã€‚ | +| [executorType](#executortype) | æ‰§è¡Œå™¨ç±»åž‹ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„能力/算法类型进行分类。 | +| [index](#index) | 用户认è¯æ¡†æž¶çš„执行器索引。 | +| [executorRole](#executorrole) | 执行器角色。 | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | +| [esl](#esl) | 执行器安全ç‰çº§ã€‚ | +| [publicKey](#publickey) | æ‰§è¡Œå™¨å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒè¯¥æ‰§è¡Œå™¨ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ | +| [extraInfo](#extrainfo) | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| [info](#info) | 执行器注册信æ¯ã€‚ | + + +## **详细æè¿°** + +执行器信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType ExecutorInfo::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹ã€‚ + + +### esl + + +``` +enum ExecutorSecureLevel ExecutorInfo::esl +``` + +**æ述:** + +执行器安全ç‰çº§[ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel)。 + + +### executorRole + + +``` +enum ExecutorRole ExecutorInfo::executorRole +``` + +**æ述:** + +执行器角色[ExecutorRole](_hdf_user_auth.md#executorrole)。 + + +### executorType + + +``` +unsigned int ExecutorInfo::executorType +``` + +**æ述:** + +æ‰§è¡Œå™¨ç±»åž‹ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„能力/算法类型进行分类。 + + +### extraInfo + + +``` +unsigned char [] ExecutorInfo::extraInfo +``` + +**æ述:** + +其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ + + +### index + + +``` +unsigned long ExecutorInfo::index +``` + +**æ述:** + +用户认è¯æ¡†æž¶çš„执行器索引。 + + +### info + + +``` +struct ExecutorRegisterInfo ExecutorInfo::info +``` + +**æ述:** + +执行器注册信æ¯ExecutorRegisterInfo。 + + +### publicKey + + +``` +unsigned char [] ExecutorInfo::publicKey +``` + +**æ述:** + +æ‰§è¡Œå™¨å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒè¯¥æ‰§è¡Œå™¨ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ + + +### sensorId + + +``` +unsigned short ExecutorInfo::sensorId +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ID,ä¸åŒä¼ 感器在人脸认è¯é©±åŠ¨å†…çš„å”¯ä¸€æ ‡è¯†ã€‚ + +ä¼ æ„Ÿå™¨ID,ä¸åŒä¼ 感器在å£ä»¤è®¤è¯é©±åŠ¨å†…çš„å”¯ä¸€æ ‡è¯†ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md b/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md new file mode 100644 index 0000000000000000000000000000000000000000..ff242ae7d76d8749b458eac663519c3ca30fbb12 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_register_info.md @@ -0,0 +1,111 @@ +# ExecutorRegisterInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | +| [executorRole](#executorrole) | 执行器角色。 | +| [executorSensorHint](#executorsensorhint) | 既定用户认è¯å‡æ®ç±»åž‹çš„执行器ID。 | +| [executorMatcher](#executormatcher) | æ‰§è¡Œå™¨ç±»åž‹ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„认è¯èƒ½åŠ›è¿›è¡Œåˆ†ç±»ã€‚ | +| [esl](#esl) | 执行器安全ç‰çº§ã€‚ | +| [publicKey](#publickey) | æ‰§è¡Œå™¨å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒè¯¥æ‰§è¡Œå™¨ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ | + + +## **详细æè¿°** + +执行器注册信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType ExecutorRegisterInfo::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹ã€‚ + + +### esl + + +``` +enum ExecutorSecureLevel ExecutorRegisterInfo::esl +``` + +**æ述:** + +执行器安全ç‰çº§[ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel)。 + + +### executorSensorHint + + +``` +unsigned int ExecutorRegisterInfo::executorSensorHint +``` + +**æ述:** + +既定用户认è¯å‡æ®ç±»åž‹çš„æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ + + +### executorRole + + +``` +enum ExecutorRole ExecutorRegisterInfo::executorRole +``` + +**æ述:** + +执行器角色[ExecutorRole](_hdf_user_auth.md#executorrole)。 + + +### executorMatcher + + +``` +unsigned int ExecutorRegisterInfo::executorMatcher +``` + +**æ述:** + +执行器匹é…å™¨ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„认è¯èƒ½åŠ›è¿›è¡Œåˆ†ç±»ã€‚ + + +### publicKey + + +``` +unsigned char [] ExecutorRegisterInfo::publicKey +``` + +**æ述:** + +æ‰§è¡Œå™¨å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒè¯¥æ‰§è¡Œå™¨ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md b/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md new file mode 100644 index 0000000000000000000000000000000000000000..90ed9fcc8933fe089cf35c374839e4168bf83f8c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_executor_send_msg.md @@ -0,0 +1,70 @@ +# ExecutorSendMsg + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [executorIndex](#executorindex) | 用户认è¯æ¡†æž¶çš„执行器索引。 | +| [commandId](#commandid) | 消æ¯å‘½ä»¤ID。 | +| [msg](#msg) | 执行器å‘é€çš„消æ¯ã€‚ | + + +## **详细æè¿°** + +执行器å‘é€çš„消æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### executorIndex + + +``` +unsigned long ExecutorSendMsg::executorIndex +``` + +**æ述:** + +用户认è¯æ¡†æž¶çš„执行器索引。 + + +### commandId + + +``` +unsigned int ExecutorSendMsg::commandId +``` + +**æ述:** + +消æ¯å‘½ä»¤ID。 + + +### msg + + +``` +unsigned char [] ExecutorSendMsg::msg +``` + +**æ述:** + +执行器å‘é€çš„消æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b9c9e4ad7876f5796cd736e15b1ec3ae429eb4c1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_face_auth_types_8idl.md @@ -0,0 +1,46 @@ +# FaceAuthTypes.idl + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [ExecutorInfo](_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_executor_info.md) | +| [TemplateInfo](_template_info.md) | å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](_template_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](_hdf_face_auth.md#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](_hdf_face_auth.md#authtype) | +| [ExecutorRole](_hdf_face_auth.md#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_face_auth.md#executorrole) | +| [ExecutorSecureLevel](_hdf_face_auth.md#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](_hdf_face_auth.md#executorsecurelevel) | +| [CommandId](_hdf_face_auth.md#commandid) : int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认è¯åŠŸèƒ½ç›¸å…³æ“作命令。 [更多...](_hdf_face_auth.md#commandid) | +| [FaceTipsCode](_hdf_face_auth.md#facetipscode) : int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4, FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8, FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举æ示信æ¯ç¼–ç 。 [更多...](_hdf_face_auth.md#facetipscode) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.face_auth.v1_0 | 人脸认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义人脸认è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md b/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md new file mode 100644 index 0000000000000000000000000000000000000000..2f5936c9d16e2800eb9fd6718d7f18f552e99685 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_get_buffer_handle_usage_params.md @@ -0,0 +1,77 @@ +# GetBufferHandleUsageParams + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [size](#size) | ç»“æž„ä½“å¤§å° | +| [version](#version) | ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ | +| [portIndex](#portindex) | 端å£ç´¢å¼• | +| [usage](#usage) | 使用率 | + + +## **详细æè¿°** + +BufferHandleUsage类型定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### portIndex + + +``` +uint32_t GetBufferHandleUsageParams::portIndex +``` + +**æ述:** + +端å£ç´¢å¼• + + +### size + + +``` +uint32_t GetBufferHandleUsageParams::size +``` + +**æ述:** + +ç»“æž„ä½“å¤§å° + + +### usage + + +``` +uint32_t GetBufferHandleUsageParams::usage +``` + +**æ述:** + +usage + + +### version + + +``` +union OMX_VERSIONTYPE GetBufferHandleUsageParams::version +``` + +**æ述:** + +ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md new file mode 100644 index 0000000000000000000000000000000000000000..76ed3097f7da3a13a35b00d4f791bfcf2ffa2ccf --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_gfx_funcs.md @@ -0,0 +1,239 @@ +# GfxFuncs + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [InitGfx](#initgfx) )(void) | åˆå§‹åŒ–ç¡¬ä»¶åŠ é€Ÿã€‚ [更多...](#initgfx) | +| ( [DeinitGfx](#deinitgfx) )(void) | 去åˆå§‹åŒ–ç¡¬ä»¶åŠ é€Ÿã€‚ [更多...](#deinitgfx) | +| ( [FillRect](#fillrect) )([ISurface](_i_surface.md) \*surface, [IRect](_i_rect.md) \*rect, uint32_t color, [GfxOpt](_gfx_opt.md) \*opt) | 填充矩形,用一ç§é¢œè‰²å¡«å……画布上指定矩形区域的矩形框。 [更多...](#fillrect) | +| ( [DrawRectangle](#drawrectangle) )([ISurface](_i_surface.md) \*surface, [Rectangle](_rectangle.md) \*rect, uint32_t color, [GfxOpt](_gfx_opt.md) \*opt) | 绘制矩形框,用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶æŒ‡å®šåŒºåŸŸçš„矩形框。 [更多...](#drawrectangle) | +| ( [DrawLine](#drawline) )([ISurface](_i_surface.md) \*surface, [ILine](_i_line.md) \*line, [GfxOpt](_gfx_opt.md) \*opt) | 绘制直线,使用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶ä¸€æ¡ç›´çº¿ã€‚ [更多...](#drawline) | +| ( [DrawCircle](#drawcircle) )([ISurface](_i_surface.md) \*surface, [ICircle](_i_circle.md) \*circle, [GfxOpt](_gfx_opt.md) \*opt) | 绘制圆形,使用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶æŒ‡å®šåœ†å¿ƒå’ŒåŠå¾„的圆。 [更多...](#drawcircle) | +| ( [Blit](#blit) )([ISurface](_i_surface.md) \*srcSurface, [IRect](_i_rect.md) \*srcRect, [ISurface](_i_surface.md) \*dstSurface, [IRect](_i_rect.md) \*dstRect, [GfxOpt](_gfx_opt.md) \*opt) | ä½å›¾æ¬ç§» [更多...](#blit) | +| ( [Sync](#sync) )(int32_t timeOut) | ç¡¬ä»¶åŠ é€ŸåŒæ¥ã€‚ [更多...](#sync) | + + +## **详细æè¿°** + +æ˜¾ç¤ºç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£ç»“æž„ä½“ï¼Œå®šä¹‰ç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### Blit + + +``` +int32_t(* GfxFuncs::Blit) (ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt) +``` + +**æ述:** + +ä½å›¾æ¬ç§» + +在ä½å›¾æ¬ç§»è¿‡ç¨‹ä¸ï¼Œå¯ä»¥å®žçŽ°è‰²å½©ç©ºé—´è½¬æ¢ã€ç¼©æ”¾ã€æ—‹è½¬ç‰åŠŸèƒ½ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| srcSurface | 输入å‚数,æºä½å›¾ä¿¡æ¯ã€‚ | +| srcRect | 输入å‚数,æºä½å›¾æ¬ç§»åŒºåŸŸã€‚ | +| dstSurface | 输出å‚æ•°ï¼Œç›®æ ‡ä½å›¾ä¿¡æ¯ã€‚ | +| dstRect | 输出å‚æ•°ï¼Œç›®æ ‡ä½å›¾åŒºåŸŸã€‚ | +| opt | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿé€‰é¡¹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### DeinitGfx + + +``` +int32_t(* GfxFuncs::DeinitGfx) (void) +``` + +**æ述:** + +去åˆå§‹åŒ–ç¡¬ä»¶åŠ é€Ÿã€‚ + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[InitGfx](#initgfx) + + +### DrawCircle + + +``` +int32_t(* GfxFuncs::DrawCircle) (ISurface *surface, ICircle *circle, GfxOpt *opt) +``` + +**æ述:** + +绘制圆形,使用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶æŒ‡å®šåœ†å¿ƒå’ŒåŠå¾„的圆。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| surface | 输入å‚数,画布。 | +| circle | 输入å‚数,圆形结构。 | +| opt | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿé€‰é¡¹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### DrawLine + + +``` +int32_t(* GfxFuncs::DrawLine) (ISurface *surface, ILine *line, GfxOpt *opt) +``` + +**æ述:** + +绘制直线,使用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶ä¸€æ¡ç›´çº¿ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| surface | 输入å‚数,画布。 | +| line | 输入å‚数,直线结构。 | +| opt | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿé€‰é¡¹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### DrawRectangle + + +``` +int32_t(* GfxFuncs::DrawRectangle) (ISurface *surface, Rectangle *rect, uint32_t color, GfxOpt *opt) +``` + +**æ述:** + +绘制矩形框,用一ç§é¢œè‰²åœ¨ç”»å¸ƒä¸Šç»˜åˆ¶æŒ‡å®šåŒºåŸŸçš„矩形框。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| surface | 输入å‚数,画布。 | +| rect | 输入å‚数,矩形框结构。 | +| color | 输入å‚数,绘制的颜色。 | +| opt | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿé€‰é¡¹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### FillRect + + +``` +int32_t(* GfxFuncs::FillRect) (ISurface *surface, IRect *rect, uint32_t color, GfxOpt *opt) +``` + +**æ述:** + +填充矩形,用一ç§é¢œè‰²å¡«å……画布上指定矩形区域的矩形框。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| surface | 输入å‚数,画布。 | +| rect | 输入å‚数,填充的矩形区域。 | +| color | 输入å‚数,填充的颜色。 | +| opt | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€Ÿé€‰é¡¹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### InitGfx + + +``` +int32_t(* GfxFuncs::InitGfx) (void) +``` + +**æ述:** + +åˆå§‹åŒ–ç¡¬ä»¶åŠ é€Ÿã€‚ + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[DeinitGfx](#deinitgfx) + + +### Sync + + +``` +int32_t(* GfxFuncs::Sync) (int32_t timeOut) +``` + +**æ述:** + +ç¡¬ä»¶åŠ é€ŸåŒæ¥ã€‚ + +åœ¨ä½¿ç”¨ç¡¬ä»¶åŠ é€Ÿæ¨¡å—进行图åƒç»˜åˆ¶ã€å›¾åƒå åŠ ã€å›¾åƒæ¬ç§»æ—¶ï¼Œé€šè¿‡è°ƒç”¨è¯¥æŽ¥å£è¿›è¡Œç¡¬ä»¶åŒæ¥ï¼Œè¯¥æŽ¥å£ä¼šç‰å¾…ç¡¬ä»¶åŠ é€Ÿå®Œæˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| timeOut | 输入å‚æ•°ï¼Œç¡¬ä»¶åŠ é€ŸåŒæ¥è¶…时设置,设置为0è¡¨ç¤ºæ— è¶…æ—¶ï¼Œç‰å¾…ç›´åˆ°ç¡¬ä»¶åŠ é€Ÿå®Œæˆã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md b/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md new file mode 100644 index 0000000000000000000000000000000000000000..00fdaa09fd517f09213a136e8ab126a907c73b02 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_gfx_opt.md @@ -0,0 +1,33 @@ +# GfxOpt + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [enGlobalAlpha](_display.md#englobalalpha-22) | 全局alphaä½¿èƒ½æ ‡å¿— | +| [globalAlpha](_display.md#globalalpha) | 全局alpha的值 | +| [enPixelAlpha](_display.md#enpixelalpha-22) | åƒç´ alphaä½¿èƒ½æ ‡å¿— | +| [blendType](_display.md#blendtype) | æ··åˆæ–¹å¼ | +| [colorKeyFrom](_display.md#colorkeyfrom) | è‰²é”®æ¨¡å¼ | +| [enableRop](_display.md#enablerop) | RopåŠŸèƒ½ä½¿èƒ½ä½ | +| [colorRopType](_display.md#colorroptype) | 颜色的Rop类型 | +| [alphaRopType](_display.md#alpharoptype) | Alphaçš„Rop类型 | +| [enableScale](_display.md#enablescale) | ç¼©æ”¾åŠŸèƒ½ä½¿èƒ½ä½ | +| [rotateType](_display.md#rotatetype) | 旋转类型 | +| [mirrorType](_display.md#mirrortype) | é•œåƒç±»åž‹ | + + +## **详细æè¿°** + +图åƒç¡¬ä»¶åŠ 速相关的æ“作选项结构体定义,用于图åƒç¡¬ä»¶åŠ 速时的æ“作选项。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md new file mode 100644 index 0000000000000000000000000000000000000000..d67c99a3dd81c1e4afa35a157c5b43538d65f4c1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_gralloc_funcs.md @@ -0,0 +1,273 @@ +# GrallocFuncs + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [AllocMem](#allocmem) )(const [AllocInfo](_alloc_info.md) \*info, BufferHandle \*\*handle) | 显示内å˜åˆ†é…。 [更多...](#allocmem) | +| ( [FreeMem](#freemem) )(BufferHandle \*handle) | 显示内å˜é‡Šæ”¾ã€‚ [更多...](#freemem) | +| ( [Mmap](#mmap) )(BufferHandle \*handle) | 显示内å˜æ˜ 射,将内å˜æ˜ 射到对应的进程地å€ç©ºé—´ä¸ã€‚ [更多...](#mmap) | +| ( [MmapYUV](#mmapyuv) )(BufferHandle \*handle, YUVDescInfo \*info) | YUV 内å˜æ˜ 射。 [更多...](#mmapyuv) | +| ( [MmapCache](#mmapcache) )(BufferHandle \*handle) | 显示内å˜æ˜ 射,将内å˜æ˜ 射为 cache 内å˜åˆ°å¯¹åº”的进程地å€ç©ºé—´ä¸ã€‚ [更多...](#mmapcache) | +| ( [Unmap](#unmap) )(BufferHandle \*handle) | 内å˜åæ˜ å°„ï¼Œå°†å†…å˜è¿›è¡Œåæ˜ å°„ã€‚ [更多...](#unmap) | +| ( [FlushCache](#flushcache) )(BufferHandle \*handle) | 刷新cache,刷新cache里的内容到内å˜å¹¶ä¸”使cacheé‡Œçš„å†…å®¹æ— æ•ˆã€‚ [更多...](#flushcache) | +| ( [FlushMCache](#flushmcache) )(BufferHandle \*handle) | 刷新Mmapæ˜ å°„çš„cache,刷新Mmapæ˜ å°„çš„cache里的内容到内å˜å¹¶ä¸”使cacheé‡Œçš„å†…å®¹æ— æ•ˆã€‚ [更多...](#flushmcache) | +| ( [InvalidateCache](#invalidatecache) )(BufferHandle \*handle) | 使cacheä¸çš„å†…å®¹æ— æ•ˆç”¨ä»¥å˜å‚¨æ›´æ–°å†…å˜å†…容。 [更多...](#invalidatecache) | +| ( [IsSupportedAlloc](#issupportedalloc) )(uint32_t num, const [VerifyAllocInfo](_verify_alloc_info.md) \*infos, bool \*supporteds) | 检测给定的VerifyAllocInfo数组信æ¯èƒ½å¦ç”³è¯·å†…å˜æˆåŠŸã€‚ [更多...](#issupportedalloc) | + + +## **详细æè¿°** + +显示内å˜é©±åŠ¨æŽ¥å£ç»“构体,定义显示内å˜é©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### AllocMem + + +``` +int32_t(* GrallocFuncs::AllocMem) (const AllocInfo *info, BufferHandle **handle) +``` + +**æ述:** + +显示内å˜åˆ†é…。 + +æ ¹æ®GUIå›¾å½¢ç³»ç»Ÿä¼ é€’çš„å‚数分é…内å˜ï¼Œåˆ†é…的内å˜æ ¹æ®ç±»åž‹å¯åˆ†ä¸ºå…±äº«å†…å˜ã€cache内å˜å’Œéžcache内å˜ç‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| info | 输入å‚数,指示申请内å˜AllocInfoä¿¡æ¯. | +| handle | 输入å‚数,指å‘申请的内å˜handle指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### FlushCache + + +``` +int32_t(* GrallocFuncs::FlushCache) (BufferHandle *handle) +``` + +**æ述:** + +刷新cache,刷新cache里的内容到内å˜å¹¶ä¸”使cacheé‡Œçš„å†…å®¹æ— æ•ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚数,待刷新cacheçš„handle指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### FlushMCache + + +``` +int32_t(* GrallocFuncs::FlushMCache) (BufferHandle *handle) +``` + +**æ述:** + +刷新Mmapæ˜ å°„çš„cache,刷新Mmapæ˜ å°„çš„cache里的内容到内å˜å¹¶ä¸”使cacheé‡Œçš„å†…å®¹æ— æ•ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚数,待刷新cacheçš„handle指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### FreeMem + + +``` +void(* GrallocFuncs::FreeMem) (BufferHandle *handle) +``` + +**æ述:** + +显示内å˜é‡Šæ”¾ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输入å‚数,待释放的内å˜handle指针。 | + +**返回:** + +æˆåŠŸè¿”回有效地å€ï¼Œå¤±è´¥è¿”回NULL。 + + +### InvalidateCache + + +``` +int32_t(* GrallocFuncs::InvalidateCache) (BufferHandle *handle) +``` + +**æ述:** + +使cacheä¸çš„å†…å®¹æ— æ•ˆç”¨ä»¥å˜å‚¨æ›´æ–°å†…å˜å†…容。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚æ•°ï¼Œå¾…æ— æ•ˆcacheçš„handle指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### IsSupportedAlloc + + +``` +int32_t(* GrallocFuncs::IsSupportedAlloc) (uint32_t num, const VerifyAllocInfo *infos, bool *supporteds) +``` + +**æ述:** + +检测给定的VerifyAllocInfo数组信æ¯èƒ½å¦ç”³è¯·å†…å˜æˆåŠŸã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| num | 输入å‚数,VerifyAllocInfo数组个数。 | +| infos | 输出å‚数,VerifyAllocInfo数组首地å€ã€‚ | +| supporteds | 输出å‚数,supporteds数组首地å€, 表示能å¦ç”³è¯·æˆåŠŸã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### Mmap + + +``` +void*(* GrallocFuncs::Mmap) (BufferHandle *handle) +``` + +**æ述:** + +显示内å˜æ˜ 射,将内å˜æ˜ 射到对应的进程地å€ç©ºé—´ä¸ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输入å‚æ•°ï¼Œå¾…æ˜ å°„å†…å˜handle指针。 | + +**返回:** + +æˆåŠŸè¿”回有效地å€ï¼Œå¤±è´¥è¿”回NULL。 + + +### MmapCache + + +``` +void*(* GrallocFuncs::MmapCache) (BufferHandle *handle) +``` + +**æ述:** + +显示内å˜æ˜ 射,将内å˜æ˜ 射为 cache 内å˜åˆ°å¯¹åº”的进程地å€ç©ºé—´ä¸ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚æ•°ï¼Œå¾…æ˜ å°„å†…å˜ handle 指针。 | + +**返回:** + +æˆåŠŸè¿”回有效地å€ï¼Œå¤±è´¥è¿”回 NULL。 + + +### MmapYUV + + +``` +void*(* GrallocFuncs::MmapYUV) (BufferHandle *handle, YUVDescInfo *info) +``` + +**æ述:** + +YUV 内å˜æ˜ 射。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚数,指示内å˜æ˜ 射的输出缓å˜ã€‚ | +| info | 输出å‚数,指示内å˜æ˜ å°„çš„YUVDescInfoä¿¡æ¯ã€‚ | + +**返回:** + +æˆåŠŸè¿”回有效地å€ï¼Œå¤±è´¥è¿”回 NULL。 + + +### Unmap + + +``` +int32_t(* GrallocFuncs::Unmap) (BufferHandle *handle) +``` + +**æ述:** + +内å˜åæ˜ å°„ï¼Œå°†å†…å˜è¿›è¡Œåæ˜ å°„ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| handle | 输出å‚数,待åæ˜ å°„å†…å˜handle指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md new file mode 100644 index 0000000000000000000000000000000000000000..08d19bbbbfe355000de3b0421183a4a8f1eb73da --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_capability.md @@ -0,0 +1,27 @@ +# HDRCapability + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [formatCount](_display.md#formatcount) | 支æŒçš„HDRæ ¼å¼çš„æ•°é‡ | +| [formats](_display.md#formats) | 支æŒçš„HDRæ ¼å¼çš„æ•°ç»„é¦–åœ°å€ | +| [maxLum](_display.md#maxlum) | 最大的光亮度luminance值 | +| [maxAverageLum](_display.md#maxaveragelum) | 最大的平å‡å…‰äº®åº¦luminance值 | +| [minLum](_display.md#minlum) | 最å°çš„光亮度luminance值 | + + +## **详细æè¿°** + +HDR属性结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md new file mode 100644 index 0000000000000000000000000000000000000000..d20665318f9555957e07bac0617c2f65e6f5586f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_h_d_r_meta_data.md @@ -0,0 +1,24 @@ +# HDRMetaData + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [key](_display.md#key) | HDR元数æ®å…³é”®å—。 | +| [value](_display.md#value-22) | 关键å—对应的值。 | + + +## **详细æè¿°** + +HDR元数æ®ç»“构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md new file mode 100644 index 0000000000000000000000000000000000000000..742e19ca1cb15f5562d8a22f65651c69e2250123 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_face_auth.md @@ -0,0 +1,157 @@ +# HdfFaceAuth + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [FaceAuthTypes.idl](_face_auth_types_8idl.md) | 定义人脸认è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 | +| [IExecutor.idl](face__auth_2_i_executor_8idl.md) | 定义执行器接å£ï¼Œç”¨äºŽèŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ | +| [IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚ | +| [IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md) | 定义获å–人脸认è¯é©±åŠ¨çš„执行器列表接å£ï¼Œç”¨äºŽä»Žäººè„¸è®¤è¯é©±åŠ¨èŽ·å–执行器对象列表。 | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [ExecutorInfo](_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_executor_info.md) | +| [TemplateInfo](_template_info.md) | å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](_template_info.md) | +| [IExecutor](interface_i_executor.md) | 定义执行器接å£ï¼Œç”¨äºŽèŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ [更多...](interface_i_executor.md) | +| [IExecutorCallback](interface_i_executor_callback.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚使用细节è§[IExecutor](interface_i_executor.md)。 [更多...](interface_i_executor_callback.md) | +| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获å–人脸认è¯é©±åŠ¨çš„执行器列表接å£ã€‚ [更多...](interface_i_face_auth_interface.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](#authtype) | +| [ExecutorRole](#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | +| [ExecutorSecureLevel](#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](#executorsecurelevel) | +| [CommandId](#commandid) : int { LOCK_TEMPLATE = 1, UNLOCK_TEMPLATE = 2, VENDOR_COMMAND_BEGIN = 10000 } | 枚举人脸认è¯åŠŸèƒ½ç›¸å…³æ“作命令。 [更多...](#commandid) | +| [FaceTipsCode](#facetipscode) : int { FACE_AUTH_TIP_TOO_BRIGHT = 1, FACE_AUTH_TIP_TOO_DARK = 2, FACE_AUTH_TIP_TOO_CLOSE = 3, FACE_AUTH_TIP_TOO_FAR = 4, FACE_AUTH_TIP_TOO_HIGH = 5, FACE_AUTH_TIP_TOO_LOW = 6, FACE_AUTH_TIP_TOO_RIGHT = 7, FACE_AUTH_TIP_TOO_LEFT = 8, FACE_AUTH_TIP_TOO_MUCH_MOTION = 9, FACE_AUTH_TIP_POOR_GAZE = 10, FACE_AUTH_TIP_NOT_DETECTED = 11, VENDOR_FACE_AUTH_TIP_BEGIN = 10000 } | 枚举æ示信æ¯ç¼–ç 。 [更多...](#facetipscode) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.face_auth.v1_0 | 人脸认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +æ供人脸认è¯é©±åŠ¨çš„æ ‡å‡†API接å£ã€‚ + +人脸认è¯é©±åŠ¨ä¸ºäººè„¸è®¤è¯æœåŠ¡æ供统一的访问接å£ã€‚获å–人脸认è¯é©±åŠ¨ä»£ç†åŽï¼Œäººè„¸è®¤è¯æœåŠ¡å¯ä»¥è°ƒç”¨ç›¸å…³æŽ¥å£èŽ·å–执行器,获å–人脸认è¯æ‰§è¡Œå™¨åŽï¼Œ 人脸认è¯æœåŠ¡å¯ä»¥è°ƒç”¨ç›¸å…³æŽ¥å£èŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ + +**Since:** + +3.2 + + +## **枚举类型说明** + + +### AuthType + + +``` +enum AuthType : int +``` + +**æ述:** + +枚举用户认è¯å‡æ®ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIN | 认è¯å‡æ®ç±»åž‹ä¸ºå£ä»¤ã€‚ | +| FACE | 认è¯å‡æ®ç±»åž‹ä¸ºäººè„¸ã€‚ | +| FINGERPRINT | 认è¯å‡æ®ç±»åž‹ä¸ºæŒ‡çº¹ã€‚ | + + +### CommandId + + +``` +enum CommandId : int +``` + +**æ述:** + +枚举人脸认è¯åŠŸèƒ½ç›¸å…³æ“作命令。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| LOCK_TEMPLATE | é”定人脸模版。 | +| UNLOCK_TEMPLATE | 解é”人脸模版。 | +| VENDOR_COMMAND_BEGIN | 用于厂商自定义æ“作指令。 | + + +### ExecutorRole + + +``` +enum ExecutorRole : int +``` + +**æ述:** + +枚举执行器角色。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| COLLECTOR | 执行器角色为采集器,æ供用户认è¯æ—¶çš„æ•°æ®é‡‡é›†èƒ½åŠ›ï¼Œéœ€è¦å’Œè®¤è¯å™¨é…åˆå®Œæˆç”¨æˆ·è®¤è¯ã€‚ | +| VERIFIER | 执行器角色为认è¯å™¨ï¼Œæ供用户认è¯æ—¶æ•°æ®å¤„ç†èƒ½åŠ›ï¼Œè¯»å–å˜å‚¨å‡æ®æ¨¡æ¿ä¿¡æ¯å¹¶å®Œæˆæ¯”对。 | +| ALL_IN_ONE | 执行器角色为全功能执行器,å¯æ供用户认è¯æ•°æ®é‡‡é›†ã€å¤„ç†ã€å‚¨å˜åŠæ¯”对能力。 | + + +### ExecutorSecureLevel + + +``` +enum ExecutorSecureLevel : int +``` + +**æ述:** + +枚举执行器安全ç‰çº§ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| ESL0 | 执行器安全级别为0,关键æ“ä½œåœ¨æ— è®¿é—®æŽ§åˆ¶æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL1 | 执行器安全级别为1,关键æ“作在有访问控制的执行环境ä¸å®Œæˆã€‚ | +| ESL2 | 执行器安全级别为2,关键æ“作在å¯ä¿¡æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL3 | 执行器安全级别为3,关键æ“作在高安环境如独立安全芯片ä¸å®Œæˆã€‚ | + + +### FaceTipsCode + + +``` +enum FaceTipsCode : int +``` + +**æ述:** + +枚举æ示信æ¯ç¼–ç 。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| FACE_AUTH_TIP_TOO_BRIGHT | 获å–的人脸图åƒç”±äºŽå…‰ç…§åº¦é«˜è€Œè¿‡äº®ã€‚ | +| FACE_AUTH_TIP_TOO_DARK | 获å–的人脸图åƒç”±äºŽå…‰ç…§åº¦ä½Žè€Œè¿‡æš—。 | +| FACE_AUTH_TIP_TOO_CLOSE | 人脸离设备过近。 | +| FACE_AUTH_TIP_TOO_FAR | 人脸离设备过远。 | +| FACE_AUTH_TIP_TOO_HIGH | 设备过高,åªæ‹åˆ°äººè„¸çš„上åŠéƒ¨åˆ†ã€‚ | +| FACE_AUTH_TIP_TOO_LOW | 设备过低,åªæ‹åˆ°äººè„¸çš„下åŠéƒ¨åˆ†ã€‚ | +| FACE_AUTH_TIP_TOO_RIGHT | 设备åå³ï¼Œåªæ‹åˆ°äººè„¸çš„å³ä¾§éƒ¨åˆ†ã€‚ | +| FACE_AUTH_TIP_TOO_LEFT | 设备å左,åªæ‹åˆ°äººè„¸çš„左侧部分。 | +| FACE_AUTH_TIP_TOO_MUCH_MOTION | 人脸信æ¯é‡‡é›†è¿‡ç¨‹ä¸ï¼Œäººè„¸ç§»åŠ¨è¿‡å¤šã€‚ | +| FACE_AUTH_TIP_POOR_GAZE | 用户未注视设备。 | +| FACE_AUTH_TIP_NOT_DETECTED | 未检测到人脸。 | +| VENDOR_FACE_AUTH_TIP_BEGIN | 用于厂商自定义æ示信æ¯ã€‚ | diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md new file mode 100644 index 0000000000000000000000000000000000000000..10de6c4064d9b27e522693a9d859d5a097d1e85f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_pin_auth.md @@ -0,0 +1,127 @@ +# HdfPinAuth + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [IExecutor.idl](pin__auth_2_i_executor_8idl.md) | å®šä¹‰æ‰§è¡Œå™¨æ ‡å‡†API接å£ã€‚接å£å¯ç”¨äºŽèŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚ | +| [IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和获å–ä¿¡æ¯ã€‚ | +| [IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md) | 定义获å–å£ä»¤è®¤è¯é©±åŠ¨çš„执行器列表接å£ï¼Œç”¨äºŽä»Žå£ä»¤è®¤è¯é©±åŠ¨èŽ·å–执行器对象列表。 | +| [PinAuthTypes.idl](_pin_auth_types_8idl.md) | 定义å£ä»¤è®¤è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IExecutor](interface_pin_i_executor.md) | å®šä¹‰æ‰§è¡Œå™¨æ ‡å‡†API接å£ã€‚接å£å¯ç”¨äºŽèŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚[更多...](interface_pin_i_executor.md) | +| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚使用细节è§[IExecutor](interface_pin_i_executor.md)。 [更多...](interface_pin_i_executor_callback.md) | +| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获å–å£ä»¤è®¤è¯é©±åŠ¨çš„执行器列表接å£ã€‚ [更多...](interface_i_pin_auth_interface.md) | +| [ExecutorInfo](_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_executor_info.md) | +| [TemplateInfo](_template_info.md) | å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](_template_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](#authtype) | +| [ExecutorRole](#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | +| [ExecutorSecureLevel](#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](#executorsecurelevel) | +| [CommandId](#commandid) : int { DEFAULT = 0 } | 枚举å£ä»¤è®¤è¯ç›¸å…³åŠŸèƒ½æ“作命令。 [更多...](#commandid) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.pin_auth.v1_0 | å£ä»¤è®¤è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +æä¾›å£ä»¤è®¤è¯é©±åŠ¨çš„æ ‡å‡†API接å£ã€‚ + +å£ä»¤è®¤è¯é©±åŠ¨ä¸ºå£ä»¤è®¤è¯æœåŠ¡æ供统一的访问接å£ã€‚获å–å£ä»¤è®¤è¯é©±åŠ¨ä»£ç†åŽï¼Œå£ä»¤è®¤è¯æœåŠ¡å¯ä»¥è°ƒç”¨ç›¸å…³æŽ¥å£èŽ·å–执行器,获å–å£ä»¤è®¤è¯æ‰§è¡Œå™¨åŽï¼Œ å£ä»¤è®¤è¯æœåŠ¡å¯ä»¥è°ƒç”¨ç›¸å…³æŽ¥å£èŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚ + +**Since:** + +3.2 + + +## **枚举类型说明** + + +### AuthType + + +``` +enum AuthType : int +``` + +**æ述:** + +枚举用户认è¯å‡æ®ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIN | 认è¯å‡æ®ç±»åž‹ä¸ºå£ä»¤ã€‚ | +| FACE | 认è¯å‡æ®ç±»åž‹ä¸ºäººè„¸ã€‚ | +| FINGERPRINT | 认è¯å‡æ®ç±»åž‹ä¸ºæŒ‡çº¹ã€‚ | + + +### CommandId + + +``` +enum CommandId : int +``` + +**æ述:** + +枚举å£ä»¤è®¤è¯ç›¸å…³åŠŸèƒ½æ“作命令。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| DEFAULT | é»˜è®¤æ— æ•ˆæ“作命令。 | + + +### ExecutorRole + + +``` +enum ExecutorRole : int +``` + +**æ述:** + +枚举执行器角色。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| COLLECTOR | 执行器角色为采集器,æ供用户认è¯æ—¶çš„æ•°æ®é‡‡é›†èƒ½åŠ›ï¼Œéœ€è¦å’Œè®¤è¯å™¨é…åˆå®Œæˆç”¨æˆ·è®¤è¯ã€‚ | +| VERIFIER | 执行器角色为认è¯å™¨ï¼Œæ供用户认è¯æ—¶æ•°æ®å¤„ç†èƒ½åŠ›ï¼Œè¯»å–å˜å‚¨å‡æ®æ¨¡æ¿ä¿¡æ¯å¹¶å®Œæˆæ¯”对。 | +| ALL_IN_ONE | 执行器角色为全功能执行器,å¯æ供用户认è¯æ•°æ®é‡‡é›†ã€å¤„ç†ã€å‚¨å˜åŠæ¯”对能力。 | + + +### ExecutorSecureLevel + + +``` +enum ExecutorSecureLevel : int +``` + +**æ述:** + +枚举执行器安全ç‰çº§ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| ESL0 | 执行器安全级别为0,关键æ“ä½œåœ¨æ— è®¿é—®æŽ§åˆ¶æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL1 | 执行器安全级别为1,关键æ“作在有访问控制的执行环境ä¸å®Œæˆã€‚ | +| ESL2 | 执行器安全级别为2,关键æ“作在å¯ä¿¡æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL3 | 执行器安全级别为3,关键æ“作在高安环境如独立安全芯片ä¸å®Œæˆã€‚ | diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md new file mode 100644 index 0000000000000000000000000000000000000000..5652e991ce997a3b1c53d18467dc185f278e806d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_thermal_callback_info.md @@ -0,0 +1,38 @@ +# HdfThermalCallbackInfo + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [info](#info) | 设备å‘çƒçš„ä¿¡æ¯åˆ—表。 | + + +## **详细æè¿°** + +设备å‘çƒçš„ä¿¡æ¯åˆ—表。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### info + + +``` +List<struct ThermalZoneInfo> HdfThermalCallbackInfo::info +``` + +**æ述:** + +设备å‘çƒçš„ä¿¡æ¯åˆ—表。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md b/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md new file mode 100644 index 0000000000000000000000000000000000000000..abdbc3ced7dfeafaf2c4892d213017fd87642005 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_hdf_user_auth.md @@ -0,0 +1,134 @@ +# HdfUserAuth + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [IUserAuthInterface.idl](_i_user_auth_interface_8idl.md) | 声明用户认è¯é©±åŠ¨çš„API接å£ã€‚接å£å¯ç”¨äºŽæ³¨å†Œæ‰§è¡Œå™¨ï¼Œç®¡ç†ç”¨æˆ·è®¤è¯å‡æ®ï¼Œå®ŒæˆPINç 和生物特å¾è®¤è¯ã€‚ | +| [UserAuthTypes.idl](_user_auth_types_8idl.md) | 定义用户认è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认è¯é©±åŠ¨çš„API接å£ã€‚ [更多...](interface_i_user_auth_interface.md) | +| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信æ¯ã€‚ [更多...](_executor_register_info.md) | +| [ExecutorInfo](_user_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_user_executor_info.md) | +| [ScheduleInfo](_schedule_info.md) | 调度信æ¯ã€‚ [更多...](_schedule_info.md) | +| [AuthSolution](_auth_solution.md) | 认è¯æ–¹æ¡ˆã€‚ [更多...](_auth_solution.md) | +| [ExecutorSendMsg](_executor_send_msg.md) | 执行器å‘é€çš„消æ¯ã€‚ [更多...](_executor_send_msg.md) | +| [AuthResultInfo](_auth_result_info.md) | 用户身份认è¯ç»“果信æ¯ã€‚ [更多...](_auth_result_info.md) | +| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信æ¯ã€‚ [更多...](_identify_result_info.md) | +| [EnrollParam](_enroll_param.md) | 注册认è¯å‡æ®å‚数。 [更多...](_enroll_param.md) | +| [CredentialInfo](_credential_info.md) | 认è¯å‡æ®ä¿¡æ¯ã€‚ [更多...](_credential_info.md) | +| [EnrolledInfo](_enrolled_info.md) | 注册信æ¯ã€‚ [更多...](_enrolled_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](#authtype) | +| [ExecutorRole](#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](#executorrole) | +| [ExecutorSecureLevel](#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](#executorsecurelevel) | +| [PinSubType](#pinsubtype) : int { PIN\_SIX = 10000, PIN\_NUMBER = 10001, PIN\_MIX = 10002 } | å£ä»¤è®¤è¯å类型。 [更多...](#pinsubtype) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| package ohos.hdi.user_auth.v1_0 | 用户认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +æ供用户认è¯é©±åŠ¨çš„æ ‡å‡†API接å£ã€‚ + +用户认è¯é©±åŠ¨ä¸ºç”¨æˆ·è®¤è¯æœåŠ¡æ供统一的访问接å£ã€‚获å–用户认è¯é©±åŠ¨ä»£ç†åŽï¼Œç”¨æˆ·è®¤è¯æœåŠ¡å¯ä»¥è°ƒç”¨ç›¸å…³æŽ¥å£æ³¨å†Œæ‰§è¡Œå™¨ï¼Œç®¡ç†ç”¨æˆ·è®¤è¯å‡æ®ï¼Œ 完æˆPINç 和生物特å¾ã€‚ + +**Since:** + +3.2 + + +## **枚举类型说明** + + +### AuthType + + +``` +enum AuthType : int +``` + +**æ述:** + +枚举用户认è¯å‡æ®ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIN | 认è¯å‡æ®ç±»åž‹ä¸ºå£ä»¤ã€‚ | +| FACE | 认è¯å‡æ®ç±»åž‹ä¸ºäººè„¸ã€‚ | +| FINGERPRINT | 认è¯å‡æ®ç±»åž‹ä¸ºæŒ‡çº¹ã€‚ | +| ALL | 表示包å«æ‰€æœ‰è®¤è¯å‡æ®ç±»åž‹ã€‚ | + + +### ExecutorRole + + +``` +enum ExecutorRole : int +``` + +**æ述:** + +枚举执行器角色。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| COLLECTOR | 执行器角色为采集器,æ供用户认è¯æ—¶çš„æ•°æ®é‡‡é›†èƒ½åŠ›ï¼Œéœ€è¦å’Œè®¤è¯å™¨é…åˆå®Œæˆç”¨æˆ·è®¤è¯ã€‚ | +| VERIFIER | 执行器角色为认è¯å™¨ï¼Œæ供用户认è¯æ—¶æ•°æ®å¤„ç†èƒ½åŠ›ï¼Œè¯»å–å˜å‚¨å‡æ®æ¨¡æ¿ä¿¡æ¯å¹¶å®Œæˆæ¯”对。 | +| ALL_IN_ONE | 执行器角色为全功能执行器,å¯æ供用户认è¯æ•°æ®é‡‡é›†ã€å¤„ç†ã€å‚¨å˜åŠæ¯”对能力。 | + + +### ExecutorSecureLevel + + +``` +enum ExecutorSecureLevel : int +``` + +**æ述:** + +枚举执行器安全ç‰çº§ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| ESL0 | 执行器安全级别为0,关键æ“ä½œåœ¨æ— è®¿é—®æŽ§åˆ¶æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL1 | 执行器安全级别为1,关键æ“作在有访问控制的执行环境ä¸å®Œæˆã€‚ | +| ESL2 | 执行器安全级别为2,关键æ“作在å¯ä¿¡æ‰§è¡ŒçŽ¯å¢ƒä¸å®Œæˆã€‚ | +| ESL3 | 执行器安全级别为3,关键æ“作在高安环境如独立安全芯片ä¸å®Œæˆã€‚ | + + +### PinSubType + + +``` +enum PinSubType : int +``` + +**æ述:** + +å£ä»¤è®¤è¯å类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| PIN_SIX | å…ä½å£ä»¤å¯†ç 。 | +| PIN_NUMBER| æ•°å—å£ä»¤å¯†ç 。 | +| PIN_MIX | æ··åˆå¯†ç 。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..96897505990ce8d3b82c7a6d27b6f0f21cfb6cb5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_battery_callback_8idl.md @@ -0,0 +1,40 @@ +# IBatteryCallback.idl + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IBatteryCallback](interface_i_battery_callback.md) | ç”µæ± ä¿¡æ¯çš„回调。 [更多...](interface_i_battery_callback.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | ç”µæ± ä¿¡æ¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +ç”µæ± ä¿¡æ¯çš„回调。 + +ç”µæ± æ¨¡å—ä¸ºç”µæ± æœåŠ¡æä¾›çš„è®¢é˜…ç”µæ± ä¿¡æ¯å˜åŒ–的回调。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..7a4a80ad0cd4c4d46a7afd72724c1fc404b56903 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_battery_interface_8idl.md @@ -0,0 +1,36 @@ +# IBatteryInterface.idl + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IBatteryInterface](interface_i_battery_interface.md) | 获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ [更多...](interface_i_battery_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | ç”µæ± ä¿¡æ¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ + +æœåŠ¡èŽ·å–æ¤å¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£èŽ·å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯ã€‚ + +**Since:** + +3.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_circle.md b/zh-cn/device-dev/reference/hdi-apis/_i_circle.md new file mode 100644 index 0000000000000000000000000000000000000000..1bc7edaa14025dad5c55d757af5ac06dbeb04bc4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_circle.md @@ -0,0 +1,26 @@ +# ICircle + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [x](_display.md#x-22) | 矩形框起始Xåæ ‡ã€‚ | +| [y](_display.md#y-22) | 矩形框起始Yåæ ‡ã€‚ | +| [r](_display.md#r) | 圆的åŠå¾„。 | +| [color](_display.md#color-23) | 圆的颜色。 | + + +## **详细æè¿°** + +圆形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶åœ†å½¢ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..3776682000f467549f40f0f7bfb4d606a56ccb9c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_face_auth_interface_8idl.md @@ -0,0 +1,34 @@ +# IFaceAuthInterface.idl + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IFaceAuthInterface](interface_i_face_auth_interface.md) | 定义获å–人脸认è¯é©±åŠ¨çš„执行器列表接å£ã€‚ [更多...](interface_i_face_auth_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.face_auth.v1_0 | 人脸认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义获å–人脸认è¯é©±åŠ¨çš„执行器列表接å£ï¼Œç”¨äºŽä»Žäººè„¸è®¤è¯é©±åŠ¨èŽ·å–执行器对象列表。 + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md b/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..cf3f527b4fe26462524e33a0bc2e87b7a294d5e4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_input_interface.md @@ -0,0 +1,64 @@ +# IInputInterface + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [iInputManager](#iinputmanager) | Input设备的设备管ç†æŽ¥å£ã€‚ | +| [iInputController](#iinputcontroller) | Input设备的业务控制接å£ã€‚ | +| [iInputReporter](#iinputreporter) | Input设备的数æ®ä¸ŠæŠ¥æŽ¥å£ã€‚ | + + +## **详细æè¿°** + +定义用于æä¾›Input设备驱动程åºåŠŸèƒ½çš„接å£ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### iInputController + + +``` +InputController* IInputInterface::iInputController +``` + +**æ述:** + +Input设备的业务控制接å£ã€‚ + + +### iInputManager + + +``` +InputManager* IInputInterface::iInputManager +``` + +**æ述:** + +Input设备的设备管ç†æŽ¥å£ã€‚ + + +### iInputReporter + + +``` +InputReporter* IInputInterface::iInputReporter +``` + +**æ述:** + +Input设备的数æ®ä¸ŠæŠ¥æŽ¥å£ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_line.md b/zh-cn/device-dev/reference/hdi-apis/_i_line.md new file mode 100644 index 0000000000000000000000000000000000000000..ee33cb7f530956d58f511b68858c0770d7530ce6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_line.md @@ -0,0 +1,27 @@ +# ILine + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [x0](_display.md#x0) | 线æ¡èµ·ç‚¹çš„Xåæ ‡ã€‚ | +| [y0](_display.md#y0) | 线æ¡èµ·ç‚¹çš„Yåæ ‡ã€‚ | +| [x1](_display.md#x1) | 线æ¡ç»ˆç‚¹çš„Xåæ ‡ã€‚ | +| [y1](_display.md#y1) | 线æ¡ç»ˆç‚¹çš„Yåæ ‡ã€‚ | +| [color](_display.md#color-13) | 线æ¡é¢œè‰²ã€‚ | + + +## **详细æè¿°** + +线æ¡æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶ç›´çº¿ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..75007400f13eb9b00a91b8954caf233be2906ad9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_pin_auth_interface_8idl.md @@ -0,0 +1,34 @@ +# IPinAuthInterface.idl + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IPinAuthInterface](interface_i_pin_auth_interface.md) | 定义获å–å£ä»¤è®¤è¯é©±åŠ¨çš„执行器列表接å£ã€‚ [更多...](interface_i_pin_auth_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.pin_auth.v1_0 | å£ä»¤è®¤è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义获å–å£ä»¤è®¤è¯é©±åŠ¨çš„执行器列表接å£ï¼Œç”¨äºŽä»Žå£ä»¤è®¤è¯é©±åŠ¨èŽ·å–执行器对象列表。 + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..58b85115424fd410feff222b777c099e50a88746 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_power_hdi_callback_8idl.md @@ -0,0 +1,40 @@ +# IPowerHdiCallback.idl + + +## **概述** + +**所属模å—:** + +[Power](power.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | ä¼‘çœ /唤醒状æ€çš„回调。 [更多...](interface_i_power_hdi_callback.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电æºæŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +ä¼‘çœ /唤醒状æ€çš„回调。 + +电æºæ¨¡å—为电æºæœåŠ¡æä¾›çš„è®¢é˜…ä¼‘çœ /唤醒状æ€çš„回调。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b6899c701f1f7919e937b3f9e7e86e7693e13fe2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_power_interface_8idl.md @@ -0,0 +1,40 @@ +# IPowerInterface.idl + + +## **概述** + +**所属模å—:** + +[Power](power.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IPowerInterface](interface_i_power_interface.md) | ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ [更多...](interface_i_power_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电æºæŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ + +电æºæ¨¡å—为电æºæœåŠ¡æä¾›ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€å’Œè¿è¡Œé”管ç†çš„接å£ã€‚ + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_rect.md b/zh-cn/device-dev/reference/hdi-apis/_i_rect.md new file mode 100644 index 0000000000000000000000000000000000000000..f2b8f481e4ebb1800008d7ccf84bf9da98e0ef96 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_rect.md @@ -0,0 +1,26 @@ +# IRect + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [x](_display.md#x-12) | 矩形框起始Xåæ ‡ã€‚ | +| [y](_display.md#y-12) | 矩形框起始Yåæ ‡ã€‚ | +| [w](_display.md#w) | 矩形框宽度。 | +| [h](_display.md#h) | 矩形框高度。 | + + +## **详细æè¿°** + +定义矩形信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_surface.md b/zh-cn/device-dev/reference/hdi-apis/_i_surface.md new file mode 100644 index 0000000000000000000000000000000000000000..2108ff270981699143688f0452a594b229c2e83b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_surface.md @@ -0,0 +1,35 @@ +# ISurface + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [phyAddr](_display.md#phyaddr-22) | 图åƒé¦–åœ°å€ | +| [height](_display.md#height-47) | 图åƒé«˜åº¦ | +| [width](_display.md#width-47) | 图åƒå®½åº¦ | +| [stride](_display.md#stride) | 图åƒè·¨åº¦ | +| [enColorFmt](_display.md#encolorfmt) | 图åƒæ ¼å¼ | +| [bYCbCrClut](_display.md#bycbcrclut) | CLUT表是å¦ä½äºŽ YCbCr 空间 | +| [bAlphaMax255](_display.md#balphamax255) | 图åƒalpha最大值为255还是128 | +| [bAlphaExt1555](_display.md#balphaext1555) | 是å¦ä½¿èƒ½1555çš„Alpha扩展 | +| [alpha0](_display.md#alpha0-22) | Alpha0值,å–值范围:[0,255] | +| [alpha1](_display.md#alpha1-22) | Alpha1值,å–值范围:[0,255] | +| [cbcrPhyAddr](_display.md#cbcrphyaddr) | CLUT表首地å€ï¼Œç”¨ä½œé¢œè‰²æ‰©å±•æˆ–é¢œè‰²æ ¡æ£ | +| [cbcrStride](_display.md#cbcrstride) | CbCr分é‡è·¨åº¦ | +| [clutPhyAddr](_display.md#clutphyaddr) | CbCr分é‡åœ°å€ | + + +## **详细æè¿°** + +用于å˜æ”¾çª—å£ç›¸å…³ä¿¡æ¯çš„结构体定义,æä¾›ç»™ç¡¬ä»¶åŠ é€Ÿä½¿ç”¨ï¼Œä¾‹å¦‚å›¾åƒåˆæˆï¼Œä½å›¾æ¬ç§»ç‰æ“作。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..5a4758d6b98696af3f30cdea9973526aa0dc68e4 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_callback_8idl.md @@ -0,0 +1,40 @@ +# IThermalCallback.idl + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备å‘çƒçŠ¶æ€çš„回调。 [更多...](interface_i_thermal_callback.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | 设备温度管ç†æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +设备å‘çƒçŠ¶æ€çš„回调。 + +çƒæ¨¡å—为çƒæœåŠ¡æ供的设备å‘çƒçŠ¶æ€çš„回调。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..06a92364867540b188c6d3cec54e94ff968d74ca --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_thermal_interface_8idl.md @@ -0,0 +1,40 @@ +# IThermalInterface.idl + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ [更多...](interface_i_thermal_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | 设备温度管ç†æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ + +çƒæ¨¡å—为çƒæœåŠ¡æ供的设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..7f3c5bd0151a021922e2030f7c66bd5bd19aa98f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_user_auth_interface_8idl.md @@ -0,0 +1,34 @@ +# IUserAuthInterface.idl + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IUserAuthInterface](interface_i_user_auth_interface.md) | 声明用户认è¯é©±åŠ¨çš„API接å£ã€‚ [更多...](interface_i_user_auth_interface.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.user_auth.v1_0 | 用户认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +声明用户认è¯é©±åŠ¨çš„API接å£ã€‚接å£å¯ç”¨äºŽæ³¨å†Œæ‰§è¡Œå™¨ï¼Œç®¡ç†ç”¨æˆ·è®¤è¯å‡æ®ï¼Œå®ŒæˆPINç 和生物特å¾è®¤è¯ã€‚ + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md new file mode 100644 index 0000000000000000000000000000000000000000..4010893f082cb29cf18a9f8aaeeff6c7ea0bbec6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi.md @@ -0,0 +1,369 @@ +# IWiFi + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [start](#start) )(struct IWiFi \*iwifi) | 创建HAL和驱动之间的通é“åŠèŽ·å–驱动网å¡ä¿¡æ¯ï¼Œè¯¥å‡½æ•°è°ƒç”¨åœ¨åˆ›å»ºIWiFi实体åŽè¿›è¡Œã€‚ [更多...](#start) | +| ( [stop](#stop) )(struct IWiFi \*iwifi) | 销æ¯HAL和驱动之间的通é“,该函数调用在销æ¯IWiFi实体å‰è¿›è¡Œã€‚ [更多...](#stop) | +| ( [getSupportFeature](#getsupportfeature) )(uint8_t \*supType, uint32_t size) | 获å–该设备支æŒçš„WLAN特性(ä¸è€ƒè™‘当å‰çš„使用状æ€ï¼‰ã€‚ [更多...](#getsupportfeature) | +| ( [getSupportCombo](#getsupportcombo) )(uint64_t \*combo, uint32_t size) | 获å–多网å¡å…±å˜æƒ…况。 [更多...](#getsupportcombo) | +| ( [createFeature](#createfeature) )(int32_t type, struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*ifeature) | æ ¹æ®è¾“入类型创建对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 [更多...](#createfeature) | +| ( [getFeatureByIfName](#getfeaturebyifname) )(const char \*ifName, struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*ifeature) | 通过网络接å£åå—获å–对应的特性。 [更多...](#getfeaturebyifname) | +| ( [registerEventCallback](#registereventcallback) )([CallbackFunc](_w_l_a_n.md#callbackfunc) cbFunc, const char \*ifName) | 注册IWiFi的回调函数,监å¬å¼‚æ¥äº‹ä»¶ã€‚ [更多...](#registereventcallback) | +| ( [unregisterEventCallback](#unregistereventcallback) )([CallbackFunc](_w_l_a_n.md#callbackfunc) cbFunc, const char \*ifName) | 去注册IWiFi的回调函数。 [更多...](#unregistereventcallback) | +| ( [destroyFeature](#destroyfeature) )(struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*ifeature) | æ ¹æ®è¾“入类型销æ¯å¯¹åº”的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 [更多...](#destroyfeature) | +| ( [resetDriver](#resetdriver) )(const uint8_t chipId, const char \*ifName) | é‡ç½®å…·æœ‰æŒ‡å®šèŠ¯ç‰‡IDçš„WLAN驱动程åºã€‚ [更多...](#resetdriver) | +| ( [getNetDevInfo](#getnetdevinfo) )(struct NetDeviceInfoResult \*netDeviceInfoResult) | 获å–网络设备信æ¯ï¼ˆè®¾å¤‡ç´¢å¼•ã€ç½‘å¡åå—ã€MACç‰ä¿¡æ¯ï¼‰ã€‚ [更多...](#getnetdevinfo) | +| ( [getPowerMode](#getpowermode) )(const char \*ifName, uint8_t \*mode) | 获å–æ£åœ¨ä½¿ç”¨çš„功率模å¼ã€‚ [更多...](#getpowermode) | +| ( [setPowerMode](#setpowermode) )(const char \*ifName, uint8_t mode) | è®¾ç½®åŠŸçŽ‡æ¨¡å¼ [更多...](#setpowermode) | + + +## **详细æè¿°** + +HAL对WLANæœåŠ¡æ供的基本能力。 + +用于创建HAL与驱动的通é“,创建/获å–/销æ¯WLAN特性ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### createFeature + + +``` +int32_t(* IWiFi::createFeature) (int32_t type, struct IWiFiBaseFeature **ifeature) +``` + +**æ述:** + +æ ¹æ®è¾“入类型创建对应的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| type | 输入å‚数,创建的feature类型。 | +| ifeature | 输出å‚数,获å–创建的feature对象。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### destroyFeature + + +``` +int32_t(* IWiFi::destroyFeature) (struct IWiFiBaseFeature *ifeature) +``` + +**æ述:** + +æ ¹æ®è¾“入类型销æ¯å¯¹åº”的特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ifeature | 输入å‚数,销æ¯çš„feature对象。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getFeatureByIfName + + +``` +int32_t(* IWiFi::getFeatureByIfName) (const char *ifName, struct IWiFiBaseFeature **ifeature) +``` + +**æ述:** + +通过网络接å£åå—获å–对应的特性。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ifName | 输入å‚数,网å¡å称。 | +| ifeature | 输出å‚数,获å–该网络接å£åå—çš„feature对象。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getNetDevInfo + + +``` +int32_t(* IWiFi::getNetDevInfo) (struct NetDeviceInfoResult *netDeviceInfoResult) +``` + +**æ述:** + +获å–网络设备信æ¯ï¼ˆè®¾å¤‡ç´¢å¼•ã€ç½‘å¡åå—ã€MACç‰ä¿¡æ¯ï¼‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| netDeviceInfoResult | 输出å‚数,得到的网络设备信æ¯ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getPowerMode + + +``` +int32_t(* IWiFi::getPowerMode) (const char *ifName, uint8_t *mode) +``` + +**æ述:** + +获å–æ£åœ¨ä½¿ç”¨çš„功率模å¼ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ifName | 输入å‚数,网å¡å称。 | +| mode | 输出å‚数,功率模å¼ï¼ŒåŒ…括ç¡çœ 模å¼ï¼ˆå¾…机状æ€è¿è¡Œï¼‰ã€ä¸€èˆ¬æ¨¡å¼ï¼ˆæ£å¸¸é¢å®šåŠŸçŽ‡è¿è¡Œï¼‰ã€ç©¿å¢™æ¨¡å¼ï¼ˆæœ€å¤§åŠŸçŽ‡è¿è¡Œï¼Œæ高信å·å¼ºåº¦å’Œè¦†ç›–é¢ç§¯ï¼‰ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getSupportCombo + + +``` +int32_t(* IWiFi::getSupportCombo) (uint64_t *combo, uint32_t size) +``` + +**æ述:** + +获å–多网å¡å…±å˜æƒ…况。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| combo | 输出å‚数,基于芯片的能力ä¿å˜å½“å‰æ‰€æœ‰æ”¯æŒçš„多网å¡å…±å˜æƒ…况(比如支æŒAP,STA,P2Pç‰ä¸åŒç»„åˆçš„å…±å˜ï¼‰ã€‚ | +| size | 输入å‚数,combo数组的长度。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getSupportFeature + + +``` +int32_t(* IWiFi::getSupportFeature) (uint8_t *supType, uint32_t size) +``` + +**æ述:** + +获å–该设备支æŒçš„WLAN特性(ä¸è€ƒè™‘当å‰çš„使用状æ€ï¼‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| supType | 输出å‚数,ä¿å˜å½“å‰è®¾å¤‡æ”¯æŒçš„特性。 | +| size | 输入å‚数,supType数组的长度。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### registerEventCallback + + +``` +int32_t(* IWiFi::registerEventCallback) (CallbackFunc cbFunc, const char *ifName) +``` + +**æ述:** + +注册IWiFi的回调函数,监å¬å¼‚æ¥äº‹ä»¶ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| cbFunc | 输入å‚数,注册的回调函数。 | +| ifName | 输入å‚数,网å¡å称。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### resetDriver + + +``` +int32_t(* IWiFi::resetDriver) (const uint8_t chipId, const char *ifName) +``` + +**æ述:** + +é‡ç½®å…·æœ‰æŒ‡å®šèŠ¯ç‰‡IDçš„WLAN驱动程åºã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| chipId | 输入å‚数,需è¦è¿›è¡Œé‡ç½®é©±åŠ¨çš„对应芯片ID。 | +| ifName | 输入å‚数,网å¡å称。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### setPowerMode + + +``` +int32_t(* IWiFi::setPowerMode) (const char *ifName, uint8_t mode) +``` + +**æ述:** + +è®¾ç½®åŠŸçŽ‡æ¨¡å¼ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ifName | 输入å‚数,网å¡å称。 | +| mode | 输入å‚数,功率模å¼,包括ç¡çœ 模å¼ï¼ˆå¾…机状æ€è¿è¡Œï¼‰ã€ä¸€èˆ¬æ¨¡å¼ï¼ˆæ£å¸¸é¢å®šåŠŸçŽ‡è¿è¡Œï¼‰ã€ç©¿å¢™æ¨¡å¼ï¼ˆæœ€å¤§åŠŸçŽ‡è¿è¡Œï¼Œæ高信å·å¼ºåº¦å’Œè¦†ç›–é¢ç§¯ï¼‰ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### start + + +``` +int32_t(* IWiFi::start) (struct IWiFi *iwifi) +``` + +**æ述:** + +创建HAL和驱动之间的通é“åŠèŽ·å–驱动网å¡ä¿¡æ¯ï¼Œè¯¥å‡½æ•°è°ƒç”¨åœ¨åˆ›å»ºIWiFi实体åŽè¿›è¡Œã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| iwifi | 输入å‚数,IWiFi对象。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### stop + + +``` +int32_t(* IWiFi::stop) (struct IWiFi *iwifi) +``` + +**æ述:** + +销æ¯HAL和驱动之间的通é“,该函数调用在销æ¯IWiFi实体å‰è¿›è¡Œã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| iwifi | 输入å‚数,IWiFi对象。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### unregisterEventCallback + + +``` +int32_t(* IWiFi::unregisterEventCallback) (CallbackFunc cbFunc, const char *ifName) +``` + +**æ述:** + +去注册IWiFi的回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| cbFunc | 输入å‚数,去注册的回调函数。 | +| ifName | 输入å‚数,网å¡å称。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md new file mode 100644 index 0000000000000000000000000000000000000000..2b291fba5e1a5852eee597b9d401ea72884f5b70 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_ap.md @@ -0,0 +1,101 @@ +# IWiFiAp + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [baseFeature](#basefeature) | 基本特性。 | +| ( [getAsscociatedStas](#getasscociatedstas) )(const struct IWiFiAp \*apFeature, struct [StaInfo](_sta_info.md) \*staInfo, uint32_t count, uint32_t \*num) | 获å–连接上的所有STAçš„ä¿¡æ¯ï¼ˆç›®å‰åªåŒ…å«MAC地å€ï¼‰ã€‚ [更多...](#getasscociatedstas) | +| ( [setCountryCode](#setcountrycode) )(const struct IWiFiAp \*apFeature, const char \*code, uint32_t len) | 设置国家ç (表示AP射频所在的国家,规定了AP射频特性,包括APçš„å‘é€åŠŸçŽ‡ã€æ”¯æŒçš„ä¿¡é“ç‰ã€‚其目的是为了使AP的射频特性符åˆä¸åŒå›½å®¶æˆ–区域的法律法规è¦æ±‚)。 [更多...](#setcountrycode) | + + +## **详细æè¿°** + +继承了IWiFiBaseFeature基本特性,并包å«AP模å¼ä¸‹èŽ·å–连接STAçš„ä¿¡æ¯å’Œè®¾ç½®å›½å®¶ç 的功能。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### baseFeature + + +``` +struct IWiFiBaseFeature IWiFiAp::baseFeature +``` + +**æ述:** + +基本特性。 + + +### getAsscociatedStas + + +``` +int32_t(* IWiFiAp::getAsscociatedStas) (const struct IWiFiAp *apFeature, struct StaInfo *staInfo, uint32_t count, uint32_t *num) +``` + +**æ述:** + +获å–连接上的所有STAçš„ä¿¡æ¯ï¼ˆç›®å‰åªåŒ…å«MAC地å€ï¼‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| apFeature | 输入å‚数,AP特性。 | +| staInfo | 输出å‚数,ä¿å˜ä¸ŽAP连接的STA的基本信æ¯ã€‚ | +| count | 输入å‚数,staInfoç»“æž„ä½“æ•°ç»„çš„å…ƒç´ ä¸ªæ•°ã€‚ | +| num | 输出å‚数,实际连接的STA的个数。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### setCountryCode + + +``` +int32_t(* IWiFiAp::setCountryCode) (const struct IWiFiAp *apFeature, const char *code, uint32_t len) +``` + +**æ述:** + +设置国家ç (表示AP射频所在的国家,规定了AP射频特性,包括APçš„å‘é€åŠŸçŽ‡ã€æ”¯æŒçš„ä¿¡é“ç‰ã€‚其目的是为了使AP的射频特性符åˆä¸åŒå›½å®¶æˆ–区域的法律法规è¦æ±‚)。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| apFeature | 输入å‚数,AP特性。 | +| code | 输入å‚数,设置的国家ç 。 | +| len | 输入å‚数,国家ç 长度。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md new file mode 100644 index 0000000000000000000000000000000000000000..0f440188c6e2ce31ffc78229a6d82c8e53a3702a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_base_feature.md @@ -0,0 +1,259 @@ +# IWiFiBaseFeature + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [ifName](#ifname) [[IFNAME_MAX_LEN](_w_l_a_n.md#ga63637ece87095ff8d153f650434ecf97)] | 网å¡å称。 | +| **type** | 特性的类型,å‚考[FeatureType](_w_l_a_n.md#featuretype)。 | +| ( [getNetworkIfaceName](#getnetworkifacename) )(const struct IWiFiBaseFeature \*baseFeature) | æ ¹æ®åŸºæœ¬ç‰¹æ€§èŽ·å–网å¡å称。 [更多...](#getnetworkifacename) | +| ( [getFeatureType](#getfeaturetype) )(const struct IWiFiBaseFeature \*baseFeature) | 获å–基本特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 [更多...](#getfeaturetype) | +| ( [setMacAddress](#setmacaddress) )(const struct IWiFiBaseFeature \*baseFeature, unsigned char \*mac, uint8_t len) | æ ¹æ®ä¼ å…¥å‚数设置对应网å¡çš„MAC地å€ã€‚ [更多...](#setmacaddress) | +| ( [getDeviceMacAddress](#getdevicemacaddress) )(const struct IWiFiBaseFeature \*baseFeature, unsigned char \*mac, uint8_t len) | 获å–设备的MAC地å€ã€‚ [更多...](#getdevicemacaddress) | +| ( [getValidFreqsWithBand](#getvalidfreqswithband) )(const struct IWiFiBaseFeature \*baseFeature, int32_t band, int32_t \*freqs, uint32_t count, uint32_t \*num) | 获å–指定频段(2.4G或者5G)下支æŒçš„频率。 [更多...](#getvalidfreqswithband) | +| ( [setTxPower](#settxpower) )(const struct IWiFiBaseFeature \*baseFeature, int32_t power) | 设置å‘射功率。 [更多...](#settxpower) | +| ( [getChipId](#getchipid) )(const struct IWiFiBaseFeature \*baseFeature, uint8_t \*chipId) | 获得当å‰é©±åŠ¨çš„芯片ID。 [更多...](#getchipid) | +| ( [getIfNamesByChipId](#getifnamesbychipid) )(const uint8_t chipId, char \*\*ifNames, uint32_t \*num) | 通过芯片ID获得当å‰èŠ¯ç‰‡æ‰€æœ‰çš„网å¡å称。 [更多...](#getifnamesbychipid) | + + +## **详细æè¿°** + +WLAN基本特性æ“作接å£ï¼ŒåŒ…括获å–网å¡å称,设置MAC地å€ï¼Œè®¾ç½®å‘射功率ç‰å…¬å…±èƒ½åŠ›æŽ¥å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### getChipId + + +``` +int32_t(* IWiFiBaseFeature::getChipId) (const struct IWiFiBaseFeature *baseFeature, uint8_t *chipId) +``` + +**æ述:** + +获得当å‰é©±åŠ¨çš„芯片ID。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | +| chipId | 输出å‚数,获得的芯片ID。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getDeviceMacAddress + + +``` +int32_t(* IWiFiBaseFeature::getDeviceMacAddress) (const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len) +``` + +**æ述:** + +获å–设备的MAC地å€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | +| mac | 输出å‚数,获得的MAC地å€ã€‚ | +| len | 输入å‚数,获得的MAC地å€é•¿åº¦ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getFeatureType + + +``` +int32_t(*IWiFiBaseFeature::getFeatureType) (const struct IWiFiBaseFeature *baseFeature) +``` + +**æ述:** + +获å–基本特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回特性类型。 + +如果æ“作失败,则返回负值。 + + +### getIfNamesByChipId + + +``` +int32_t(* IWiFiBaseFeature::getIfNamesByChipId) (const uint8_t chipId, char **ifNames, uint32_t *num) +``` + +**æ述:** + +通过芯片ID获得当å‰èŠ¯ç‰‡æ‰€æœ‰çš„网å¡å称。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| chipId | 输入å‚数,需è¦èŽ·å–网å¡å称的芯片ID。 | +| ifNames | 输出å‚数,网å¡å称。 | +| num | 输出å‚数,网å¡çš„æ•°é‡ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### getNetworkIfaceName + + +``` +const char*(* IWiFiBaseFeature::getNetworkIfaceName) (const struct IWiFiBaseFeature *baseFeature) +``` + +**æ述:** + +æ ¹æ®åŸºæœ¬ç‰¹æ€§èŽ·å–网å¡å称。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回网å¡å称。 + +如果æ“作失败,则返回NULL。 + + +### getValidFreqsWithBand + + +``` +int32_t(* IWiFiBaseFeature::getValidFreqsWithBand) (const struct IWiFiBaseFeature *baseFeature, int32_t band, int32_t *freqs, uint32_t count, uint32_t *num) +``` + +**æ述:** + +获å–指定频段(2.4G或者5G)下支æŒçš„频率。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | +| band | 输入å‚数,指定的一个频段。 | +| freqs | 输出å‚数,ä¿å˜æ”¯æŒçš„频率。 | +| count | 输入å‚æ•°ï¼Œé¢‘çŽ‡æ•°ç»„çš„å…ƒç´ ä¸ªæ•°ã€‚ | +| num | 输出å‚数,实际支æŒçš„频率个数。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### ifName + + +``` +char IWiFiBaseFeature::ifName[IFNAME_MAX_LEN] +``` + +**æ述:** + +网å¡å称。 + + +### setMacAddress + + +``` +int32_t(* IWiFiBaseFeature::setMacAddress) (const struct IWiFiBaseFeature *baseFeature, unsigned char *mac, uint8_t len) +``` + +**æ述:** + +æ ¹æ®ä¼ å…¥å‚数设置对应网å¡çš„MAC地å€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | +| mac | 输入å‚数,设置的MAC地å€ã€‚ | +| len | 输入å‚数,设置的MAC地å€é•¿åº¦ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### setTxPower + + +``` +int32_t(* IWiFiBaseFeature::setTxPower) (const struct IWiFiBaseFeature *baseFeature, int32_t power) +``` + +**æ述:** + +设置å‘射功率。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| baseFeature | 输入å‚数,基本特性。 | +| power | 输入å‚数,设置的å‘射功率。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md new file mode 100644 index 0000000000000000000000000000000000000000..aff3e568d7d0cae1422620565645673dbcb5508e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_i_wi_fi_sta.md @@ -0,0 +1,99 @@ +# IWiFiSta + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [baseFeature](#basefeature) | 基本特性。 | +| ( [setScanningMacAddress](#setscanningmacaddress) )(const struct IWiFiSta \*staFeature, unsigned char \*scanMac, uint8_t len) | 设置扫æå•ä¸ªMAC地å€ã€‚ [更多...](#setscanningmacaddress) | +| ( [startScan](#startscan) )(const char \*ifName, WifiScan \*scan) | å¯åŠ¨æ‰«æ。 [更多...](#startscan) | + + +## **详细æè¿°** + +继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,é¢å¤–包å«è®¾ç½®æ‰«æå•ä¸ªMAC地å€åŠŸèƒ½ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### baseFeature + + +``` +struct IWiFiBaseFeature IWiFiSta::baseFeature +``` + +**æ述:** + +基本特性。 + + +### setScanningMacAddress + + +``` +int32_t(* IWiFiSta::setScanningMacAddress) (const struct IWiFiSta *staFeature, unsigned char *scanMac, uint8_t len) +``` + +**æ述:** + +设置扫æå•ä¸ªMAC地å€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| staFeature | 输入å‚数,STA特性。 | +| scanMac | 输入å‚数,设置STA扫æçš„MAC地å€ã€‚ | +| len | 输入å‚数,MAC地å€çš„长度。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### startScan + + +``` +int32_t(* IWiFiSta::startScan) (const char *ifName, WifiScan *scan) +``` + +**æ述:** + +å¯åŠ¨æ‰«æ。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ifName | 输入å‚数,网å¡å称。 | +| scan | 输入å‚数,扫æå‚数。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md b/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md new file mode 100644 index 0000000000000000000000000000000000000000..f990a2d18bffdca9b2404f92e1c56f191bc93676 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_identify_result_info.md @@ -0,0 +1,72 @@ +# IdentifyResultInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [result](#result) | 用户身份识别结果。 | +| [userId](#userid) | 用户ID。 | +| [token](#token) | 用户身份识别令牌。 | + + +## **详细æè¿°** + +用户身份识别结果信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### result + + +``` +int IdentifyResultInfo::result +``` + +**æ述:** + +用户身份识别结果。 + + +### token + + +``` +unsigned char [] IdentifyResultInfo::token +``` + +**æ述:** + +用户身份识别令牌。 + + +### userId + + +``` +int IdentifyResultInfo::userId +``` + +**æ述:** + +用户ID。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input.md b/zh-cn/device-dev/reference/hdi-apis/_input.md new file mode 100644 index 0000000000000000000000000000000000000000..9914bfec5d164e82eb19072c2bc546a26066ae65 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input.md @@ -0,0 +1,238 @@ +# Input + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [input_controller.h](input__controller_8h.md) | æè¿°Input设备业务控制相关的接å£å£°æ˜Žã€‚ | +| [input_manager.h](input__manager_8h.md) | æè¿°Input设备管ç†ç›¸å…³çš„接å£å£°æ˜Žã€‚ | +| [input_reporter.h](input__reporter_8h.md) | æè¿°Input设备数æ®ä¸ŠæŠ¥ç›¸å…³çš„接å£å£°æ˜Žã€‚ | +| [input_type.h](input__type_8h.md) | Input设备相关的类型定义,定义了Input设备驱动接å£æ‰€ä½¿ç”¨çš„结构体åŠæžšä¸¾ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [InputController](_input_controller.md) | æä¾›Input设备业务控制相关的接å£ã€‚ [更多...](_input_controller.md) | +| [InputManager](_input_manager.md) | æä¾›Input设备管ç†ç›¸å…³çš„接å£ã€‚ [更多...](_input_manager.md) | +| [IInputInterface](_i_input_interface.md) | 定义用于æ供输入设备驱动能力的接å£ã€‚[更多...](_i_input_interface.md) | +| [InputReporter](_input_reporter.md) | æä¾›Input设备数æ®ä¸ŠæŠ¥ç›¸å…³çš„接å£ã€‚ [更多...](_input_reporter.md) | +| [InputEventPackage](_event_package.md) | Input事件数æ®åŒ…结构。 [更多...](_event_package.md) | +| [InputHotPlugEvent](_input_hotplug_event.md) | çƒæ’拔事件数æ®åŒ…结构。 [更多...](_input_hotplug_event.md) | +| [InputDevDesc](_input_dev_desc.md) | Input设备æè¿°ä¿¡æ¯ã€‚ [更多...](_input_dev_desc.md) | +| [InputEventCb](_input_report_event_cb.md) | æ¤ç»“构体定义了输入事件回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ [更多...](_input_report_event_cb.md) | +| [InputHostCb](_input_host_cb.md) | æ¤ç»“构体定义了çƒæ’拔事件上报回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ [更多...](_input_host_cb.md) | +| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,å˜å‚¨æ”¯æŒäº‹ä»¶çš„ä½å›¾ã€‚ [更多...](_input_dev_ability.md) | +| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信æ¯ã€‚ [更多...](_input_dimension_info.md) | +| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信æ¯ã€‚ [更多...](_input_dev_identify.md) | +| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 [更多...](_input_dev_attr.md) | +| [InputDeviceInfo](_device_info.md) | Input设备基础设备信æ¯ã€‚ [更多...](_device_info.md) | +| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数æ®ç»“构。 [更多...](_input_extra_cmd.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| **MAX_INPUT_DEV_NUM** 32 | Input设备最大数é‡ã€‚ | +| **DEV_NAME_LEN** 64 | Input设备å称长度。 | +| **CHIP_INFO_LEN** 10 | 芯片信æ¯é•¿åº¦ã€‚ | +| **CHIP_NAME_LEN** 10 | 芯片å称长度。 | +| **VENDOR_NAME_LEN** 10 | 厂商å称长度。 | +| **SELF_TEST_RESULT_LEN** 20 | 自测结果长度。 | +| **DEV_MANAGER_SERVICE_NAME** "hdf_input_host" | Input设备节点æœåŠ¡å称。 | +| **DIV_ROUND_UP(nr, d)** (((nr) + (d) - 1) / (d)) | å‘上å–整计算公å¼ã€‚| +| **BYTE_HAS_BITS** 8 | 一个å—节所包å«çš„比特数。 | +| **BITS_TO_UINT64(count)** DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(uint64_t)) | 比特与64ä½æ— 符å·æ•´æ•°çš„转æ¢å…¬å¼ã€‚ | +| **HDF_FF_CNT** (0x7f + 1) | Input设备å‘é€åŠ›å馈命令的数é‡æœ€å¤§å€¼ã€‚| + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [RetStatus](#retstatus) { INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3, INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 [更多...](#retstatus) | +| [InputDevType](#inputdevtype) { INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE, INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 [更多...](#inputdevtype) | +| [PowerStatus](#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN } | 定义电æºçŠ¶æ€ã€‚ [更多...](#powerstatus) | +| [CapacitanceTest](#capacitancetest) { BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST, TEST_TYPE_UNKNOWN } | 定义容值测试类型。 [更多...](#capacitancetest) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GetInputInterface](#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£èŽ·å–æ“作Input设备的所有接å£ã€‚ [更多...](#getinputinterface) | +| [ReleaseInputInterface](#releaseinputinterface) ([IInputInterface](_i_input_interface.md) \*\*inputInterface) | InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£é‡Šæ”¾æ“作Input设备的所有接å£ã€‚ [更多...](#releaseinputinterface) | + + +## **详细æè¿°** + +Input模å—驱动接å£å£°æ˜Žã€‚ + +本模å—为InputæœåŠ¡æ供相关驱动接å£ï¼ŒåŒ…括Input设备的打开和关é—ã€Input事件获å–ã€è®¾å¤‡ä¿¡æ¯æŸ¥è¯¢ã€å›žè°ƒå‡½æ•°æ³¨å†Œã€ç‰¹æ€§çŠ¶æ€æŽ§åˆ¶ç‰æŽ¥å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **枚举类型说明** + + +### CapacitanceTest + + +``` +enum CapacitanceTest +``` + +**æ述:** + +定义容值测试类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| BASE_TEST | 基础容值测试 | +| FULL_TEST | å…¨é‡å®¹å€¼è‡ªæ£€æµ‹è¯• | +| MMI_TEST | MMI容值测试 | +| RUNNING_TEST | è€åŒ–容值测试 | +| TEST_TYPE_UNKNOWN | 未知的测试类型 | + + +### InputDevType + + +``` +enum InputDevType +``` + +**æ述:** + +定义Input设备类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| INDEV_TYPE_TOUCH | 触摸å±ã€‚ | +| INDEV_TYPE_KEY | 物ç†æŒ‰é”®ã€‚ | +| INDEV_TYPE_KEYBOARD | 键盘。 | +| INDEV_TYPE_MOUSE | é¼ æ ‡ã€‚ | +| INDEV_TYPE_BUTTON | 虚拟按键。 | +| INDEV_TYPE_CROWN | è¡¨å† ã€‚ | +| INDEV_TYPE_ENCODER | 自定义编ç 的特定功能或者事件。 | +| INDEV_TYPE_UNKNOWN | 未知输入设备类型。 | + + +### PowerStatus + + +``` +enum PowerStatus +``` + +**æ述:** + +定义电æºçŠ¶æ€ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| INPUT_RESUME | æ£å¸¸å”¤é†’。 | +| INPUT_SUSPEND | ä¼‘çœ ä¸‹ç”µæ¨¡å¼ã€‚ | +| INPUT_LOW_POWER | ä¼‘çœ ä½ŽåŠŸè€—æ¨¡å¼ã€‚ | +| INPUT_POWER_STATUS_UNKNOWN | 未知电æºçŠ¶æ€ã€‚ | + + +### RetStatus + + +``` +enum RetStatus +``` + +**æ述:** + +定义返回值类型。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| INPUT_SUCCESS | æˆåŠŸã€‚ | +| INPUT_FAILURE | 失败。 | +| INPUT_INVALID_PARAM | æ— æ•ˆå‚数。 | +| INPUT_NOMEM | 内å˜ä¸è¶³ã€‚ | +| INPUT_NULL_PTR | 空指针。 | +| INPUT_TIMEOUT | 执行超时。 | +| INPUT_UNSUPPORTED | 特性ä¸æ”¯æŒã€‚ | + + +## **函数说明** + + +### GetInputInterface() + + +``` +int32_t GetInputInterface (IInputInterface **interface) +``` + +**æ述:** + +InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£èŽ·å–æ“作Input设备的所有接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| interface | 对Input设备进行接å£æ“作的指针,通常在InputæœåŠ¡å¯åŠ¨åŽï¼Œé€šè¿‡è°ƒç”¨æ¤å‡½æ•°èŽ·å–Input设备æ“作接å£ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看**RetSatus**。 + +**Since:** + +1.0 + +**Version:** + +1.0 + +### ReleaseInputInterface() + + +``` +int32_t ReleaseInputInterface (IInputInterface *inputInterface) +``` + +**æ述:** + +InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£é‡Šæ”¾æ“作Input设备的所有接å£ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| inputInterface| 对Input设备进行接å£æ“作的指针。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看**RetSatus**。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_controller.md b/zh-cn/device-dev/reference/hdi-apis/_input_controller.md new file mode 100644 index 0000000000000000000000000000000000000000..58ab8b158a18cc045e658f398061460f0ef07b0b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_controller.md @@ -0,0 +1,276 @@ +# InputController + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [SetPowerStatus](#setpowerstatus) )(uint32_t devIndex, uint32_t status) | 设置电æºçŠ¶æ€ [更多...](#setpowerstatus) | +| ( [GetPowerStatus](#getpowerstatus) )(uint32_t devIndex, uint32_t \*status) | 获å–电æºçŠ¶æ€ [更多...](#getpowerstatus) | +| ( [GetDeviceType](#getdevicetype) )(uint32_t devIndex, uint32_t \*deviceType) | 获å–devIndex对应的Input设备的类型 [更多...](#getdevicetype) | +| ( [GetChipInfo](#getchipinfo) )(uint32_t devIndex, char \*chipInfo, uint32_t length) | 获å–器件对应的编ç ä¿¡æ¯ [更多...](#getchipinfo) | +| ( [GetVendorName](#getvendorname) )(uint32_t devIndex, char \*vendorName, uint32_t length) | 获å–devIndex对应的模组厂商å [更多...](#getvendorname) | +| ( [GetChipName](#getchipname) )(uint32_t devIndex, char \*chipName, uint32_t length) | 获å–devIndex对应的驱动芯片å [更多...](#getchipname) | +| ( [SetGestureMode](#setgesturemode) )(uint32_t devIndex, uint32_t gestureMode) | è®¾ç½®æ‰‹åŠ¿æ¨¡å¼ [更多...](#setgesturemode) | +| ( [RunCapacitanceTest](#runcapacitancetest) )(uint32_t devIndex, uint32_t testType, char \*result, uint32_t length) | 执行容值自检测试 [更多...](#runcapacitancetest) | +| ( [RunExtraCommand](#runextracommand) )(uint32_t devIndex, [InputExtraCmd](_input_extra_cmd.md) \*cmd) | 执行拓展指令 [更多...](#runextracommand) | + + +## **详细æè¿°** + +æä¾›Input设备业务控制相关的接å£ã€‚ + +æ¤ç±»æŽ¥å£åŒ…å«ç”µæºçŠ¶æ€çš„设置ã€ç‰¹æ€§çš„使能ã€å™¨ä»¶ä¿¡æ¯çš„获å–,以åŠäº§çº¿ç›¸å…³çš„测试功能接å£ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### GetChipInfo + + +``` +int32_t(* InputController::GetChipInfo) (uint32_t devIndex, char *chipInfo, uint32_t length) +``` + +**æ述:** + +获å–器件对应的编ç ä¿¡æ¯ã€‚ + +一款产å“通常会有多家模组和Driver IC,上层应用如果关注具体器件型å·ï¼Œåˆ™é€šè¿‡æ¤æŽ¥å£æ¥èŽ·å–。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| chipInfo | 输出å‚数,获å–的对应设备索引的器件编ç ä¿¡æ¯ã€‚ | +| length | 输入å‚数,ä¿å˜å™¨ä»¶èŠ¯ç‰‡ä¿¡æ¯çš„内å˜é•¿åº¦ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetChipName + + +``` +int32_t(* InputController::GetChipName) (uint32_t devIndex, char *chipName, uint32_t length) +``` + +**æ述:** + +获å–devIndex对应的驱动芯片å。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| chipName | 输出å‚数,获å–的对应设备索引的驱动芯片å。 | +| length | 输入å‚数,ä¿å˜é©±åŠ¨èŠ¯ç‰‡å的内å˜é•¿åº¦ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetDeviceType + + +``` +int32_t(* InputController::GetDeviceType) (uint32_t devIndex, uint32_t *deviceType) +``` + +**æ述:** + +获å–devIndex对应的Input设备的类型。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| deviceType | 输出å‚数,获å–的对应设备索引的设备类型,具体å‚考[InputDevType](_input.md#inputdevtype)。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetPowerStatus + + +``` +int32_t(* InputController::GetPowerStatus) (uint32_t devIndex, uint32_t *status) +``` + +**æ述:** + +获å–电æºçŠ¶æ€ã€‚ + +åœ¨ç³»ç»Ÿä¼‘çœ æˆ–è€…å”¤é†’æ—¶ï¼ŒInputæœåŠ¡æˆ–电æºç®¡ç†æ¨¡å—获å–电æºçŠ¶æ€ï¼Œä»¥ä¾¿é©±åŠ¨IC能æ£å¸¸è¿›å…¥å¯¹åº”çš„ä¼‘çœ æ¨¡å¼ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| status | 输出å‚数,获å–的对应设备索引的电æºçŠ¶æ€ï¼Œå…·ä½“å‚考[PowerStatus](_input.md#powerstatus)。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetVendorName + + +``` +int32_t(* InputController::GetVendorName) (uint32_t devIndex, char *vendorName, uint32_t length) +``` + +**æ述:** + +获å–devIndex对应的模组厂商å。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| vendorName | 获å–的对应设备索引的模组厂商å。 | +| length | ä¿å˜æ¨¡ç»„厂商å的内å˜é•¿åº¦ã€‚ | + +**返回:** + +Returns INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +Returns 其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### RunCapacitanceTest + + +``` +int32_t(* InputController::RunCapacitanceTest) (uint32_t devIndex, uint32_t testType, char *result, uint32_t length) +``` + +**æ述:** + +执行容值自检测试。 + +å¯åŠ¨ä¸åŒæ£€æµ‹åœºæ™¯ä¸‹çš„容值自检测试,并获å–测试结果,容值自检项由器件厂商自定义, 一般包括RawData测试ã€çŸè·¯æ£€æµ‹ã€å¼€è·¯æ£€æµ‹ã€å¹²æ‰°æ£€æµ‹ã€è¡Œåˆ—差检测ç‰æµ‹è¯•é¡¹ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| testType | 输入å‚数,容值测试的测试类型,具体å‚考[CapacitanceTest](_input.md#capacitancetest)。 | +| result | 输出å‚数,容值测试的结果,æˆåŠŸåˆ™è¾“出“SUCCâ€ï¼Œå¤±è´¥åˆ™è¿”回对应的错误æ示。 | +| length | 输入å‚数,ä¿å˜å®¹å€¼æµ‹è¯•ç»“果的内å˜é•¿åº¦ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### RunExtraCommand + + +``` +int32_t(* InputController::RunExtraCommand) (uint32_t devIndex, InputExtraCmd *cmd) +``` + +**æ述:** + +执行拓展指令。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| cmd | 输入å‚数,拓展指令数æ®åŒ…,包括指令编ç åŠå‚数,具体å‚考[InputExtraCmd](_input_extra_cmd.md)。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### SetGestureMode + + +``` +int32_t(* InputController::SetGestureMode) (uint32_t devIndex, uint32_t gestureMode) +``` + +**æ述:** + +设置手势模å¼ã€‚ + +上层应用开关手势模å¼ï¼Œå³è®¾ç½®æ‰‹åŠ¿æ¨¡å¼çš„对应使能bit。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| gestureMode | 输入å‚数,手势模å¼çš„开关状æ€ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### SetPowerStatus + + +``` +int32_t(* InputController::SetPowerStatus) (uint32_t devIndex, uint32_t status) +``` + +**æ述:** + +设置电æºçŠ¶æ€ã€‚ + +åœ¨ç³»ç»Ÿä¼‘çœ æˆ–è€…å”¤é†’æ—¶ï¼ŒInputæœåŠ¡æˆ–电æºç®¡ç†æ¨¡å—设置电æºçŠ¶æ€ï¼Œä»¥ä½¿é©±åŠ¨IC能æ£å¸¸è¿›å…¥å¯¹åº”çš„ä¼‘çœ æ¨¡å¼ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| status | 输入å‚数,设置的电æºçŠ¶æ€ï¼ŒInputæœåŠ¡æŽ§åˆ¶Input设备进入resume或者suspendç‰çŠ¶æ€[PowerStatus](_input.md#powerstatus)。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md new file mode 100644 index 0000000000000000000000000000000000000000..d7ec4c6686ae6b2f80a83c11b74685a1bdfcb128 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_ability.md @@ -0,0 +1,196 @@ +# InputDevAbility + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [devProp](#devprop) | 设备属性 | +| [eventType](#eventtype) | 记录支æŒçš„事件类型的ä½å›¾ | +| [absCode](#abscode) | 记录支æŒçš„ç»å¯¹åæ ‡çš„ä½å›¾ | +| [relCode](#relcode) | 记录支æŒçš„相对åæ ‡çš„ä½å›¾ | +| [keyCode](#keycode) | 记录支æŒçš„按键值的ä½å›¾ | +| [ledCode](#ledcode) | 记录设备支æŒçš„指示ç¯çš„ä½å›¾ | +| [miscCode](misccode#) |记录设备支æŒçš„其他功能的ä½å›¾ | +| [soundCode](#soundcode) | 记录设备支æŒçš„声音或è¦æŠ¥çš„ä½å›¾ | +| [forceCode](#forcecode) | 记录设备支æŒçš„作用力功能的ä½å›¾ | +| [switchCode](#switchcode) | 记录设备支æŒçš„开关功能的ä½å›¾ | +| [keyType](#keytype) | 按键状æ€çš„ä½å›¾ | +| [ledType](#ledtype) | LED状æ€çš„ä½å›¾ | +| [soundType](#soundtype) | 声音状æ€çš„ä½å›¾ | +| [switchType](#switchtype) | 开关状æ€çš„ä½å›¾ | + +## **详细æè¿°** + +Input设备的能力属性,å˜å‚¨æ”¯æŒäº‹ä»¶çš„ä½å›¾ã€‚用ä½çš„æ–¹å¼æ¥è¡¨ç¤ºè¯¥Input设备能够上报的事件类型。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### devProp + + +``` +uint64_t InputDevAbility::devProp[BITS_TO_UINT64(INPUT_PROP_CNT)] +``` + +**æ述:** + +设备属性。 + + +### eventType + + +``` +uint64_t InputDevAbility::eventType[BITS_TO_UINT64(EV_CNT)] +``` + +**æ述:** + +用于记录支æŒçš„事件类型的ä½å›¾ã€‚ + +### absCode + + +``` +uint64_t InputDevAbility::absCode[BITS_TO_UINT64(ABS_CNT)] +``` + +**æ述:** + +记录支æŒçš„ç»å¯¹åæ ‡çš„ä½å›¾ã€‚ + +### relCode + + +``` +uint64_t InputDevAbility::relCode[BITS_TO_UINT64(REL_CNT)] +``` + +**æ述:** + +记录支æŒçš„相对åæ ‡çš„ä½å›¾ã€‚ + +### keyCode + + +``` +uint64_t InputDevAbility::keyCode[BITS_TO_UINT64(KEY_CNT)] +``` + +**æ述:** + +记录支æŒçš„按键值的ä½å›¾ã€‚ + + +### ledCode + + +``` +uint64_t InputDevAbility::ledCode[BITS_TO_UINT64(LED_CNT)] +``` + +**æ述:** + +记录设备支æŒçš„指示ç¯çš„ä½å›¾ã€‚ + + +### miscCode + + +``` +uint64_t InputDevAbility::miscCode[BITS_TO_UINT64(MSC_CNT)] +``` + +**æ述:** + +记录设备支æŒçš„其他功能的ä½å›¾ã€‚ + + +### soundCode + + +``` +uint64_t InputDevAbility::soundCode[BITS_TO_UINT64(SND_CNT)] +``` + +**æ述:** + +记录设备支æŒçš„声音或è¦æŠ¥çš„ä½å›¾ã€‚ + + +### forceCode + +``` +uint64_t InputDevAbility::forceCode[BITS_TO_UINT64(HDF_FF_CNT)] +``` + +**æ述:** + +记录设备支æŒçš„作用力功能的ä½å›¾ã€‚ + + +### switchCode + +``` +uint64_t InputDevAbility::switchCode[BITS_TO_UINT64(SW_CNT)] +``` + +**æ述:** + +记录设备支æŒçš„开关功能的ä½å›¾ã€‚ + + +### keyType + +``` +uint64_t InputDevAbility::keyType[BITS_TO_UINT64(KEY_CNT)] +``` + +**æ述:** + +按键状æ€çš„ä½å›¾ã€‚ + + +### ledType + +``` +uint64_t InputDevAbility::ledType[BITS_TO_UINT64(LED_CNT)] +``` + +**æ述:** + +LED状æ€çš„ä½å›¾ã€‚ + +### soundType + +``` +uint64_t InputDevAbility::soundType[BITS_TO_UINT64(SND_CNT)] +``` + +**æ述:** + +声音状æ€çš„ä½å›¾ã€‚ + +### switchType + +``` +uint64_t InputDevAbility::switchType[BITS_TO_UINT64(SW_CNT)] +``` + +**æ述:** + +开关状æ€çš„ä½å›¾ã€‚ + diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md new file mode 100644 index 0000000000000000000000000000000000000000..d6dcb2b37936249aeae66af38131a56c27019797 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_attr.md @@ -0,0 +1,58 @@ +# InputDevAttr + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [devName](#devname) | 设备å | +| [id](#id) | è®¾å¤‡è¯†åˆ«ä¿¡æ¯ | +| [axisInfo](#axisinfo) | è®¾å¤‡ç»´åº¦ä¿¡æ¯ | + +## **详细æè¿°** + +Input设备属性。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### devName + +``` +char InputDevAttr::devName[DEV_NAME_LEN] +``` + +**æ述:** + +设备å。 + +### id + +``` +InputDevIdentify InputDevAttr::id +``` + +**æ述:** + +设备识别信æ¯ã€‚ + +### axisInfo + +``` +InputDimensionInfo InputDevAttr::axisInfo[ABS_CNT]; +``` + +**æ述:** + +设备维度信æ¯ã€‚ \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md new file mode 100644 index 0000000000000000000000000000000000000000..5950fca754533fbb0f35713da421cac14917b3a5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_desc.md @@ -0,0 +1,51 @@ +# InputDevDesc + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [devIndex](#devindex) | 设备索引 | +| [devType](#devtype) | 设备类型 | + + +## **详细æè¿°** + +Input设备æè¿°ä¿¡æ¯ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### devIndex + + +``` +uint32_t InputHotPlugEvent::devIndex +``` + +**æ述:** + +设备索引。 + + +### devType + + +``` +uint32_t InputHotPlugEvent::devType +``` + +**æ述:** + +设备类型。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md b/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md new file mode 100644 index 0000000000000000000000000000000000000000..8520f5f62c0ef6732a00091ae3fb49a910e03632 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dev_identify.md @@ -0,0 +1,69 @@ +# InputDevIdentify + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [busType](#bustype) | 总线类型 | +| [vendor](#vendor) | ç”Ÿäº§å•†ç¼–å· | +| [product](#product) | 产å“ç¼–å· | +| [fuzz](#version) | ç‰ˆæœ¬å· | + +## **详细æè¿°** + +Input设备的识别信æ¯ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### busType + +``` +uint16_t InputDevIdentify::busType +``` + +**æ述:** + +总线类型。 + +### vendor + +``` +uint16_t InputDevIdentify::vendor +``` + +**æ述:** + +生产商编å·ã€‚ + +### product + +``` +uint16_t InputDevIdentify::product +``` + +**æ述:** + +产å“ç¼–å·ã€‚ + +### version + +``` +uint16_t InputDevIdentify::version +``` + +**æ述:** + +版本å·ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md b/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md new file mode 100644 index 0000000000000000000000000000000000000000..bdbbdbd5d33b9886691cbedfa742fa432c43f34e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_dimension_info.md @@ -0,0 +1,91 @@ +# InputDimensionInfo + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [axis](#axis) | åæ ‡è½´ | +| [min](#min) | 记录å„个åæ ‡çš„æœ€å°å€¼ | +| [max](#max) | 记录å„个åæ ‡çš„æœ€å¤§å€¼ | +| [fuzz](#fuzz) | 记录å„个åæ ‡çš„åˆ†è¾¨çŽ‡ | +| [flat](#flat) | 记录å„个åæ ‡çš„åŸºå‡†å€¼ | +| [range](#range) | 范围 | + +## **详细æè¿°** + +Input设备的维度信æ¯ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### axis + +``` +int32_t InputDimensionInfo::axis +``` + +**æ述:** + +åæ ‡è½´ã€‚ + +### min + +``` +int32_t InputDimensionInfo::min +``` + +**æ述:** + +记录å„个åæ ‡çš„æœ€å°å€¼ã€‚ + +### max + +``` +int32_t InputDimensionInfo::max +``` + +**æ述:** + +记录å„个åæ ‡çš„æœ€å¤§å€¼ã€‚ + +### fuzz + +``` +int32_t InputDimensionInfo::fuzz +``` + +**æ述:** + +记录å„个åæ ‡çš„åˆ†è¾¨çŽ‡ã€‚ + +### flat + +``` +int32_t InputDimensionInfo::flat +``` + +**æ述:** + +记录å„个åæ ‡çš„åŸºå‡†å€¼ã€‚ + +### range + +``` +int32_t InputDimensionInfo::range +``` + +**æ述:** + +范围。 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md b/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md new file mode 100644 index 0000000000000000000000000000000000000000..56083e65b9a4c823d7c5fc42cc29ddbd3b910228 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_extra_cmd.md @@ -0,0 +1,51 @@ +# InputExtraCmd + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [cmdCode](#cmdcode) | 指令对应的编ç 。 | +| [cmdValue](#cmdvalue) | æŒ‡ä»¤ä¼ è¾“çš„æ•°æ®ã€‚ | + + +## **详细æè¿°** + +扩展指令的数æ®ç»“构。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### cmdCode + + +``` +const char* InputExtraCmd::cmdCode +``` + +**æ述:** + +指令对应的编ç + + +### cmdValue + + +``` +const char* InputExtraCmd::cmdValue +``` + +**æ述:** + +æŒ‡ä»¤ä¼ è¾“çš„æ•°æ® diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md b/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md new file mode 100644 index 0000000000000000000000000000000000000000..372d6d7847b87f3d69a034e382093462d778e26e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_host_cb.md @@ -0,0 +1,44 @@ +# InputHostCb + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [HotPlugCallback](#hotplugcallback) ) (const [InputHotPlugEvent](_input_hotplug_event.md) \*event) | çƒæ’拔事件上报的回调函数。 [更多...](#hotplugcallback) | + + +## **详细æè¿°** + +æ¤ç»“构体定义了çƒæ’拔事件上报回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### HotPlugCallback + + +``` +void (* InputHostCb::HotPlugCallback) (const InputHotPlugEvent* event); +``` + +**æ述:** + +çƒæ’拔事件上报的回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | 输入å‚数,上报的çƒæ’拔事件数æ®ã€‚ | \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md b/zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md new file mode 100644 index 0000000000000000000000000000000000000000..1bfe63ea8dbf62d5577191ab8c18ca4fa4af7096 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_hotplug_event.md @@ -0,0 +1,66 @@ +# InputHotPlugEvent + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [devIndex](#devindex) | 设备索引 | +| [devType](#devtype) | 设备类型 | +| [status](#status) | 设备状æ€| + + +## **详细æè¿°** + +çƒæ’拔事件数æ®åŒ…结构。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### devIndex + + +``` +uint32_t InputHotPlugEvent::devIndex +``` + +**æ述:** + +设备索引。 + + +### devType + + +``` +uint32_t InputHotPlugEvent::devType +``` + +**æ述:** + +设备类型。 + + +### status + + +``` +uint32_t InputHotPlugEvent::status +``` + +**æ述:** + +设备状æ€ã€‚ +- 1:离线 +- 0:在线。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_manager.md b/zh-cn/device-dev/reference/hdi-apis/_input_manager.md new file mode 100644 index 0000000000000000000000000000000000000000..ac0611a28958d35fe31156a134270a7be2c0ba03 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_manager.md @@ -0,0 +1,156 @@ +# InputManager + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [ScanInputDevice](#scaninputdevice) )(DevDesc \*staArr, uint32_t arrLen) | InputæœåŠ¡ç”¨äºŽæ‰«æ所有在线设备。 [更多...](#scaninputdevice) | +| ( [OpenInputDevice](#openinputdevice) )(uint32_t devIndex) | InputæœåŠ¡æ‰“开对应设备的设备文件 [更多...](#openinputdevice) | +| ( [CloseInputDevice](#closeinputdevice) )(uint32_t devIndex) | InputæœåŠ¡å…³é—对应设备的设备文件 [更多...](#closeinputdevice) | +| ( [GetInputDevice](#getinputdevice) )(uint32_t devIndex, [InputDeviceInfo](_device_info.md) \*\*devInfo) | InputæœåŠ¡èŽ·å–对应IDçš„è®¾å¤‡ä¿¡æ¯ [更多...](#getinputdevice) | +| ( [GetInputDeviceList](#getinputdevicelist) )(uint32_t \*devNum, [InputDeviceInfo](_device_info.md) \*\*devList, uint32_t size) | InputæœåŠ¡èŽ·å–所有Inputè®¾å¤‡åˆ—è¡¨çš„è®¾å¤‡ä¿¡æ¯ [更多...](#getinputdevicelist) | + + +## **详细æè¿°** + +æä¾›Input设备管ç†ç›¸å…³çš„接å£ã€‚ + +æ¤ç±»æŽ¥å£åŒ…Input设备的扫æã€æ‰“开和关é—ã€ç‰¹å®šè®¾å¤‡ä¿¡æ¯æŸ¥è¯¢ï¼Œä»¥åŠæ‰€æœ‰è®¾å¤‡åˆ—表信æ¯èŽ·å–ç‰æŽ¥å£ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CloseInputDevice + + +``` +int32_t(* InputManager::CloseInputDevice) (uint32_t devIndex) +``` + +**æ述:** + +InputæœåŠ¡å…³é—对应设备的设备文件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。| + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetInputDevice + + +``` +int32_t(* InputManager::GetInputDevice) (uint32_t devIndex, InputDeviceInfo **devInfo) +``` + +**æ述:** + +InputæœåŠ¡èŽ·å–对应ID的设备信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| devInfo | 输出å‚数,å³devIndex对应的设备的设备信æ¯ï¼Œå…·ä½“å‚考[InputDeviceInfo](_device_info.md)。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### GetInputDeviceList + + +``` +int32_t(* InputManager::GetInputDeviceList) (uint32_t *devNum, InputDeviceInfo **devList, uint32_t size) +``` + +**æ述:** + +InputæœåŠ¡èŽ·å–所有Input设备列表的设备信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devNum | 输出å‚数,当å‰å·²ç»æ³¨å†Œè¿‡çš„所有Input设备的总数。 | +| devInfo | 输出å‚数,Input设备列表所对应的设备信æ¯ï¼Œå…·ä½“å‚考[InputDeviceInfo](_device_info.md)。 | +| size | 输入å‚数,å³æŒ‡å®šdeviceListæ•°ç»„å¯¹åº”çš„å…ƒç´ ä¸ªæ•°ã€‚| + +返回: + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### OpenInputDevice + + +``` +int32_t(* InputManager::OpenInputDevice) (uint32_t devIndex) +``` + +**æ述:** + +InputæœåŠ¡æ‰“开对应设备的设备文件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### ScanInputDevice + + +``` +int32_t(* InputManager::ScanInputDevice) (InputDevDesc *staArr, uint32_t arrLen) +``` + +**æ述:** + +InputæœåŠ¡ç”¨äºŽæ‰«æ所有在线设备。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| staArr | 输出å‚数,å˜æ”¾Input设备扫æä¿¡æ¯çš„数组,信æ¯åŒ…å«è®¾å¤‡ç´¢å¼•ä»¥åŠè®¾å¤‡ç±»åž‹ã€‚ | +| arrLen | 输入å‚数,staArr数组的长度信æ¯ã€‚ | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md b/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md new file mode 100644 index 0000000000000000000000000000000000000000..b6dd9371652a5af31acba24509d9bc040d8fe6c7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_report_event_cb.md @@ -0,0 +1,47 @@ +# InputEventCb + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [EventPkgCallback](#eventpkgcallback) )(const [InputEventPackage](_event_package.md) \*\*pkgs, uint32_t count, uint32_t devIndex) | 输入事件数æ®ä¸ŠæŠ¥çš„回调函数。 [更多...](#eventpkgcallback) | + + +## **详细æè¿°** + +æ¤ç»“构体定义了输入事件回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### EventPkgCallback + + +``` +void (* InputEventCb::EventPkgCallback)(const InputEventPackage **pkgs, uint32_t count, uint32_t devIndex); +``` + +**æ述:** + +输入事件数æ®ä¸ŠæŠ¥çš„回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| pkgs| 驱动上报的Input事件数æ®ã€‚ | +| count | Input事件数æ®åŒ…的个数。 | +| devIndex | Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | + diff --git a/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md b/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md new file mode 100644 index 0000000000000000000000000000000000000000..fb4feb386c944bed951b37290c8711af10e4d28f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_input_reporter.md @@ -0,0 +1,126 @@ +# InputReporter + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [RegisterReportCallback](#registerreportcallback) )(uint32_t devIndex, [InputHostCb](_input_report_event_cb.md) \*callback) | 注册对应设备的回调函数。 [更多...](#registerreportcallback) | +| ( [UnregisterReportCallback](#unregisterreportcallback) )(uint32_t devIndex) | 注销对应设备的回调函数。 [更多...](#unregisterreportcallback) | +| ( [RegisterHotPlugCallback](#registerhotplugcallback) )([InputHostCb](_input_report_event_cb.md) \*callback) | 注册Input设备的çƒæ’拔回调函数。 [更多...](#registerhotplugcallback) | +| ( [UnregisterHotPlugCallback](#unregisterhotplugcallback) )(void) | 注销Input设备的çƒæ’拔回调函数。 [更多...](#unregisterhotplugcallback) | + + +## **详细æè¿°** + +æä¾›Input设备数æ®ä¸ŠæŠ¥ç›¸å…³çš„接å£ã€‚ + +æ¤ç±»æŽ¥å£åŒ…å«Input设备的数æ®ä¸ŠæŠ¥å›žè°ƒå‡½æ•°çš„注册和注销。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### RegisterHotPlugCallback + + +``` +int32_t(* InputReporter::RegisterHotPlugCallback) (InputHostCb *callback) +``` + +**æ述:** + +注册Input设备的çƒæ’拔回调函数。 + +InputæœåŠ¡é€šè¿‡æ¤æŽ¥å£æ³¨å†Œå›žè°ƒå‡½æ•°åˆ°hdiä¸ï¼Œæ‰€æœ‰Input设备由æ¤å‡½æ•°è¿›è¡Œçƒæ’拔事件上报。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| callback | 输入å‚数,回调函数的函数指针。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### RegisterReportCallback + + +``` +int32_t(* InputReporter::RegisterReportCallback) (uint32_t devIndex, InputEventCb *callback) +``` + +**æ述:** + +注册对应设备的回调函数。 + +InputæœåŠ¡é€šè¿‡æ¤æŽ¥å£æ³¨å†Œæ•°æ®å›žè°ƒå‡½æ•°åˆ°hdiä¸ï¼Œhdi通过æ¤å›žè°ƒå‡½æ•°ä¸ŠæŠ¥Input事件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。 | +| callback | 输入å‚数,回调函数的函数指针。 | + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### UnregisterHotPlugCallback + + +``` +int32_t(* InputReporter::UnregisterHotPlugCallback) (void) +``` + +**æ述:** + +注销Input设备的çƒæ’拔回调函数。 + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 + + +### UnregisterReportCallback + + +``` +int32_t(* InputReporter::UnregisterReportCallback) (uint32_t devIndex) +``` + +**æ述:** + +注销对应设备的回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devIndex | 输入å‚数,Inputè®¾å¤‡ç´¢å¼•ï¼Œç”¨äºŽæ ‡å¿—å¤šä¸ªInput设备,å–值从0开始,最多支æŒ32个设备。| + +**返回:** + +INPUT_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[RetSatus](_input.md#retstatus)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md b/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md new file mode 100644 index 0000000000000000000000000000000000000000..9dc52678aecefe62852b3c53f430b051c1f39bb0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_alpha.md @@ -0,0 +1,27 @@ +# LayerAlpha + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [enGlobalAlpha](_display.md#englobalalpha-12) | 全局alphaä½¿èƒ½æ ‡å¿— | +| [enPixelAlpha](_display.md#enpixelalpha-12) | åƒç´ alphaä½¿èƒ½æ ‡å¿— | +| [alpha0](_display.md#alpha0-12) | alpha0值,å–值范围:[0, 255] | +| [alpha1](_display.md#alpha1-12) | alpha1值,å–值范围:[0, 255] | +| [gAlpha](_display.md#galpha) | 全局alpha值,å–值范围:[0, 255] | + + +## **详细æè¿°** + +定义图层Alphaä¿¡æ¯çš„结构体。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md b/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md new file mode 100644 index 0000000000000000000000000000000000000000..179aa36a396027e7cbae879faf591dcbfc977550 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_buffer.md @@ -0,0 +1,29 @@ +# LayerBuffer + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [fenceId](_display.md#fenceid) | bufferçš„fenceå· | +| [width](_display.md#width-37) | buffer宽度 | +| [height](_display.md#height-37) | buffer高度 | +| [pitch](_display.md#pitch) | 一行数æ®æ‰€å å—节数 | +| [pixFormat](_display.md#pixformat-22) | 图层åƒç´ æ ¼å¼ | +| [data](_display.md#data) | 图层bufferæ•°æ® | +| [hdl](_display.md#hdl) | 图层bufferå¥æŸ„ | + + +## **详细æè¿°** + +图层Buffer,用于å˜æ”¾å›¾å±‚æ•°æ®ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md b/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md new file mode 100644 index 0000000000000000000000000000000000000000..6868d6a8388fc43ef53e245a960504741a1ebf6c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_funcs.md @@ -0,0 +1,1267 @@ +# LayerFuncs + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [InitDisplay](#initdisplay) )(uint32_t devId) | åˆå§‹åŒ–显示设备。 [更多...](#initdisplay) | +| ( [DeinitDisplay](#deinitdisplay) )(uint32_t devId) | å–消åˆå§‹åŒ–显示设备。 [更多...](#deinitdisplay) | +| ( [GetDisplayInfo](#getdisplayinfo) )(uint32_t devId, [DisplayInfo](_display_info.md) \*dispInfo) | 获å–显示设备相关信æ¯ã€‚ [更多...](#getdisplayinfo) | +| ( [CreateLayer](#createlayer) )(uint32_t devId, const [LayerInfo](_layer_info.md) \*layerInfo, uint32_t \*layerId) | 打开图层。 [更多...](#createlayer) | +| ( [CloseLayer](#closelayer) )(uint32_t devId, uint32_t layerId) | å…³é—图层。 [更多...](#closelayer) | +| ( [SetLayerVisible](#setlayervisible) )(uint32_t devId, uint32_t layerId, bool visible) | 设置图层是å¦å¯è§ã€‚ [更多...](#setlayervisible) | +| ( [GetLayerVisibleState](#getlayervisiblestate) )(uint32_t devId, uint32_t layerId, bool \*visible) | 获å–图层是å¦å¯è§çŠ¶æ€ã€‚ [更多...](#getlayervisiblestate) | +| ( [SetLayerSize](#setlayersize) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 设置图层大å°ã€‚ [更多...](#setlayersize) | +| ( [GetLayerSize](#getlayersize) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 获å–图层大å°ã€‚ [更多...](#getlayersize) | +| ( [SetLayerCrop](#setlayercrop) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*rect) | 设置图层è£å‰ªåŒºåŸŸã€‚ [更多...](#setlayercrop) | +| ( [SetLayerZorder](#setlayerzorder) )(uint32_t devId, uint32_t layerId, uint32_t zorder) | 设置图层Z轴次åºã€‚ [更多...](#setlayerzorder) | +| ( [GetLayerZorder](#getlayerzorder) )(uint32_t devId, uint32_t layerId, uint32_t \*zorder) | 获å–图层Z轴次åºã€‚ [更多...](#getlayerzorder) | +| ( [SetLayerPreMulti](#setlayerpremulti) )(uint32_t devId, uint32_t layerId, bool preMul) | 设置图层预乘。 [更多...](#setlayerpremulti) | +| ( [GetLayerPreMulti](#getlayerpremulti) )(uint32_t devId, uint32_t layerId, bool \*preMul) | 获å–å›¾å±‚é¢„ä¹˜æ ‡è¯†ã€‚ [更多...](#getlayerpremulti) | +| ( [SetLayerAlpha](#setlayeralpha) )(uint32_t devId, uint32_t layerId, [LayerAlpha](_layer_alpha.md) \*alpha) | 设置图层alpha值。 [更多...](#setlayeralpha) | +| ( [GetLayerAlpha](#getlayeralpha) )(uint32_t devId, uint32_t layerId, [LayerAlpha](_layer_alpha.md) \*alpha) | 获å–图层alpha值。 [更多...](#getlayeralpha) | +| ( [SetLayerColorKey](#setlayercolorkey) )(uint32_t devId, uint32_t layerId, bool enable, uint32_t key) | 设置图层colorkey属性,在图层å åŠ æ—¶ä½¿ç”¨ã€‚ [更多...](#setlayercolorkey) | +| ( [GetLayerColorKey](#getlayercolorkey) )(uint32_t devId, uint32_t layerId, bool \*enable, uint32_t \*key) | 获å–图层colorkey。 [更多...](#getlayercolorkey) | +| ( [SetLayerPalette](#setlayerpalette) )(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 设置图层调色æ¿ã€‚ [更多...](#setlayerpalette) | +| ( [GetLayerPalette](#getlayerpalette) )(uint32_t devId, uint32_t layerId, uint32_t \*palette, uint32_t len) | 获å–图层调色æ¿ã€‚ [更多...](#getlayerpalette) | +| ( [SetTransformMode](#settransformmode) )(uint32_t devId, uint32_t layerId, [TransformType](_display.md#transformtype) type) | 设置图层å˜æ¢æ¨¡å¼ï¼Œæ ¹æ®ä¸åŒçš„场景设置图层的旋转ã€ç¼©æ”¾ã€ç§»ä½ç‰ã€‚ [更多...](#settransformmode) | +| ( [SetLayerCompression](#setlayercompression) )(uint32_t devId, uint32_t layerId, int32_t compType) | 设置图层压缩功能 [更多...](#setlayercompression) | +| ( [GetLayerCompression](#getlayercompression) )(uint32_t devId, uint32_t layerId, int32_t \*compType) | 获å–图层压缩功能是å¦æ‰“开。 [更多...](#getlayercompression) | +| ( [SetLayerDirtyRegion](#setlayerdirtyregion) )(uint32_t devId, uint32_t layerId, [IRect](_i_rect.md) \*region) | 设置图层刷新区域。 [更多...](#setlayerdirtyregion) | +| ( [GetLayerBuffer](#getlayerbuffer) )(uint32_t devId, uint32_t layerId, [LayerBuffer](_layer_buffer.md) \*buffer) | 获å–图层的buffer。 [更多...](#getlayerbuffer) | +| ( [Flush](#flush) )(uint32_t devId, uint32_t layerId, [LayerBuffer](_layer_buffer.md) \*buffer) | 刷新图层。 [更多...](#flush) | +| ( [WaitForVBlank](#waitforvblank) )(uint32_t devId, uint32_t layerId, int32_t timeOut) | 实现ç‰å¾…帧消éšæœŸåˆ°æ¥åŠŸèƒ½ã€‚ [更多...](#waitforvblank) | +| ( [SnapShot](#snapshot) )(uint32_t devId, [LayerBuffer](_layer_buffer.md) \*buffer) | 实现抓图功能。 [更多...](#snapshot) | +| ( [SetLayerVisibleRegion](#setlayervisibleregion) )(uint32_t devId, uint32_t layerId, uint32_t num, [IRect](_i_rect.md) \*rect) | 设置一个图层的å¯è§åŒºåŸŸ [更多...](#setlayervisibleregion) | +| ( [SetLayerBuffer](#setlayerbuffer) )(uint32_t devId, uint32_t layerId, const BufferHandle \*buffer, int32_t fence) | 设置一个层的缓冲区。 [更多...](#setlayerbuffer) | +| ( [InvokeLayerCmd](#invokelayercmd) )(uint32_t devId, uint32_t layerId, uint32_t cmd,...) | æ‰©å±•æŽ¥å£ [更多...](#invokelayercmd) | +| ( [SetLayerCompositionType](#setlayercompositiontype) )(uint32_t devId, uint32_t layerId, [CompositionType](_display.md#compositiontype) type) | 设置客户端期望的组åˆç±»åž‹ [更多...](#setlayercompositiontype) | +| ( [SetLayerBlendType](#setlayerblendtype) )(uint32_t devId, uint32_t layerId, [BlendType](_display.md#blendtype) type) | 设置混åˆç±»åž‹ [更多...](#setlayerblendtype) | +| ( [SetLayerColorTransform](#setlayercolortransform) )(uint32_t devId, uint32_t layerId, const float \*matrix) | 设置图层当å‰çš„颜色转æ¢çŸ©é˜µã€‚ [更多...](#setlayercolortransform) | +| ( [SetLayerColorDataSpace](#setlayercolordataspace) )(uint32_t devId, uint32_t layerId, [ColorDataSpace](_display.md#colordataspace) colorSpace) | 设置图层的颜色数æ®ç©ºé—´ã€‚ [更多...](#setlayercolordataspace) | +| ( [GetLayerColorDataSpace](#getlayercolordataspace) )(uint32_t devId, uint32_t layerId, [ColorDataSpace](_display.md#colordataspace) \*colorSpace) | 获å–图层当å‰çš„颜色数æ®ç©ºé—´ã€‚ [更多...](#getlayercolordataspace) | +| ( [SetLayerMetaData](#setlayermetadata) )(uint32_t devId, uint32_t layerId, uint32_t num, const [HDRMetaData](_h_d_r_meta_data.md) \*metaData) | 设置图层的HDRmetaData。 [更多...](#setlayermetadata) | +| ( [SetLayerMetaDataSet](#setlayermetadataset) )(uint32_t devId, uint32_t layerId, [HDRMetadataKey](_display.md#hdrmetadatakey) key, uint32_t num, const uint8_t \*metaData) | 设置图层的metaData set。 [更多...](#setlayermetadataset) | +| ( [GetSupportedPresentTimestamp](#getsupportedpresenttimestamp) )(uint32_t devId, uint32_t layerId, [PresentTimestampType](_display.md#presenttimestamptype) \*type) | 获å–图层支æŒçš„上å±æ—¶é—´æˆ³ç±»åž‹ã€‚ [更多...](#getsupportedpresenttimestamp) | +| ( [GetHwPresentTimestamp](#gethwpresenttimestamp) )(uint32_t devId, uint32_t layerId, [PresentTimestamp](_present_timestamp.md) \*pts) | 获å–图层的上å±æ—¶é—´æˆ³ä¿¡æ¯ã€‚ [更多...](#gethwpresenttimestamp) | +| ( [SetLayerTunnelHandle](#setlayertunnelhandle) )(uint32_t devId, uint32_t layerId, ExtDataHandle \*handle) | 设置图层的tunnelå¥æŸ„。 [更多...](#setlayertunnelhandle) | +| ( [GetLayerReleaseFence](#getlayerreleasefence) )(uint32_t devId, uint32_t layerId, int32_t \*fence) | 获å–图层的åŒæ¥æ …æ 。 [更多...](#getlayerreleasefence) | + + +## **详细æè¿°** + +显示图层驱动接å£ç»“构体,定义显示图层驱动接å£å‡½æ•°æŒ‡é’ˆã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### CloseLayer + + +``` +int32_t(* LayerFuncs::CloseLayer) (uint32_t devId, uint32_t layerId) +``` + +**æ述:** + +å…³é—图层。 + +在完æˆæ˜¾ç¤ºåŽï¼Œå¦‚æžœä¸åœ¨éœ€è¦ä½¿ç”¨å›¾å±‚,调用关é—图层接å£å…³é—图层。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +**OpenLayer** + + +### CreateLayer + + +``` +int32_t(* LayerFuncs::CreateLayer) (uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId) +``` + +**æ述:** + +打开图层。 + +GUI在使用图层时,需è¦å…ˆæ ¹æ®å›¾å±‚ä¿¡æ¯æ‰“开图层,打开图层æˆåŠŸå¯èŽ·å¾—图层IDï¼Œæ ¹æ®å›¾å±‚ID使用图层å„接å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerInfo | 输入å‚数,图层信æ¯ï¼Œä¸Šå±‚GUIæ‰“å¼€å›¾å±‚æ—¶éœ€ä¼ é€’å›¾å±‚ä¿¡æ¯ï¼ŒåŒ…括图层类型,图层大å°ï¼Œåƒç´ æ ¼å¼ç‰ä¿¡æ¯ã€‚ | +| layerId | 输入å‚数,图层ID,打开图层æˆåŠŸåŽè¿”回给GUI的图层IDï¼Œç”¨äºŽæ ‡è¯†å”¯ä¸€çš„å›¾å±‚ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[CloseLayer](#closelayer) + + +### DeinitDisplay + + +``` +int32_t(* LayerFuncs::DeinitDisplay) (uint32_t devId) +``` + +**æ述:** + +å–消åˆå§‹åŒ–显示设备。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[InitDisplay](#initdisplay) + + +### Flush + + +``` +int32_t(* LayerFuncs::Flush) (uint32_t devId, uint32_t layerId, LayerBuffer *buffer) +``` + +**æ述:** + +刷新图层。 + +å°†buffer显示数æ®åˆ·æ–°åˆ°æŒ‡å®šçš„layerId图层上,实现图åƒæ•°æ®æ˜¾ç¤ºåˆ°å±å¹•ä¸Šã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| buffer | 输出å‚数,待刷新的buffer。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### GetDisplayInfo + + +``` +int32_t(* LayerFuncs::GetDisplayInfo) (uint32_t devId, DisplayInfo *dispInfo) +``` + +**æ述:** + +获å–显示设备相关信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| dispInfo | 输出å‚数,显示相关信æ¯ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### GetHwPresentTimestamp + + +``` +int32_t(* LayerFuncs::GetHwPresentTimestamp) (uint32_t devId, uint32_t layerId, PresentTimestamp *pts) +``` + +**æ述:** + +获å–图层的上å±æ—¶é—´æˆ³ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| pts | 输出å‚数,ä¿å˜å›¾å±‚的上å±æ—¶é—´æˆ³ä¿¡æ¯, 由接å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### GetLayerAlpha + + +``` +int32_t(* LayerFuncs::GetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlpha *alpha) +``` + +**æ述:** + +获å–图层alpha值。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| alpha | 输出å‚数,ä¿å˜èŽ·å–的图层alpha值。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerAlpha](#setlayeralpha) + + +### GetLayerBuffer + + +``` +int32_t(* LayerFuncs::GetLayerBuffer) (uint32_t devId, uint32_t layerId, LayerBuffer *buffer) +``` + +**æ述:** + +获å–图层的buffer。 + +å‘bufferä¸ç»˜å›¾åŽï¼Œè°ƒç”¨Flush接å£æ˜¾ç¤ºåˆ°å±å¹•ä¸Šã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| buffer | 输出å‚数,ä¿å˜èŽ·å–的图层buffer。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[Flush](#flush) + + +### GetLayerColorDataSpace + + +``` +int32_t(* LayerFuncs::GetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, ColorDataSpace *colorSpace) +``` + +**æ述:** + +获å–图层当å‰çš„颜色数æ®ç©ºé—´ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| colorSpace | 输出å‚数,ä¿å˜å¯¹åº”图层的颜色数æ®ç©ºé—´ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### GetLayerColorKey + + +``` +int32_t(* LayerFuncs::GetLayerColorKey) (uint32_t devId, uint32_t layerId, bool *enable, uint32_t *key) +``` + +**æ述:** + +获å–图层colorkey。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| enable | 输出å‚数,ä¿å˜èŽ·å–çš„enableè‰²é”®ä½¿èƒ½æ ‡è¯†ã€‚ | +| key | 输出å‚数,ä¿å˜èŽ·å–的色键值,å³é¢œè‰²å€¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerColorKey](#setlayercolorkey) + + +### GetLayerCompression + + +``` +int32_t(* LayerFuncs::GetLayerCompression) (uint32_t devId, uint32_t layerId, int32_t *compType) +``` + +**æ述:** + +获å–图层压缩功能是å¦æ‰“开。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| compType | 输出å‚数,ä¿å˜èŽ·å–的图层压缩功能状æ€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerCompression](#setlayercompression) + + +### GetLayerPalette + + +``` +int32_t(* LayerFuncs::GetLayerPalette) (uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len) +``` + +**æ述:** + +获å–图层调色æ¿ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| palette | 输出å‚数,ä¿å˜èŽ·å–的图层调色æ¿ã€‚ | +| len | 输入å‚数,调色æ¿é•¿åº¦ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerPalette](#setlayerpalette) + + +### GetLayerPreMulti + + +``` +int32_t(* LayerFuncs::GetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool *preMul) +``` + +**æ述:** + +获å–å›¾å±‚é¢„ä¹˜æ ‡è¯†ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| preMul | 输出å‚数,ä¿å˜èŽ·å–çš„å›¾å±‚é¢„ä¹˜ä½¿èƒ½æ ‡è¯†ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerPreMulti](#setlayerpremulti) + + +### GetLayerReleaseFence + + +``` +int32_t(* LayerFuncs::GetLayerReleaseFence) (uint32_t devId, uint32_t layerId, int32_t *fence) +``` + +**æ述:** + +获å–图层的åŒæ¥æ …æ 。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| fence | 输出å‚数,ä¿å˜å›¾å±‚çš„ release fence, 由接å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### GetLayerSize + + +``` +int32_t(* LayerFuncs::GetLayerSize) (uint32_t devId, uint32_t layerId, IRect *rect) +``` + +**æ述:** + +获å–图层大å°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| rect | 输出å‚数,ä¿å˜èŽ·å–的图层大å°ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerSize](#setlayersize) + + +### GetLayerVisibleState + + +``` +int32_t(* LayerFuncs::GetLayerVisibleState) (uint32_t devId, uint32_t layerId, bool *visible) +``` + +**æ述:** + +获å–图层是å¦å¯è§çŠ¶æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| visible | 输出å‚数,ä¿å˜èŽ·å–的图层å¯è§çŠ¶æ€ï¼Œtrue表示图层å¯è§ï¼Œfalse表示图层ä¸å¯è§ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerVisible](#setlayervisible) + + +### GetLayerZorder + + +``` +int32_t(* LayerFuncs::GetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_t *zorder) +``` + +**æ述:** + +获å–图层Z轴次åºã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| zorder | 输出å‚数,ä¿å˜èŽ·å–的图层Z轴次åºï¼Œä¸ºæ•´æ•°å€¼ï¼Œå–值范围为[0, 255],值越大图层越往上排列。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[SetLayerZorder](#setlayerzorder) + + +### GetSupportedPresentTimestamp + + +``` +int32_t(* LayerFuncs::GetSupportedPresentTimestamp) (uint32_t devId, uint32_t layerId, PresentTimestampType *type) +``` + +**æ述:** + +获å–图层支æŒçš„上å±æ—¶é—´æˆ³ç±»åž‹ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| type | 输出å‚数,ä¿å˜å›¾å±‚支æŒçš„上å±æ—¶é—´æˆ³ç±»åž‹, 由接å£å®žçŽ°å±‚进行写入。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### InitDisplay + + +``` +int32_t(* LayerFuncs::InitDisplay) (uint32_t devId) +``` + +**æ述:** + +åˆå§‹åŒ–显示设备。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[DeinitDisplay](#deinitdisplay) + + +### InvokeLayerCmd + + +``` +int32_t(* LayerFuncs::InvokeLayerCmd) (uint32_t devId, uint32_t layerId, uint32_t cmd,...) +``` + +**æ述:** + +æ‰©å±•æŽ¥å£ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备的ID。å–值范围为0 ~ 4,其ä¸0表示第一个显示设备,4表示最åŽä¸€ä¸ªæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| layerId | 输入å‚数,层IDï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªå±‚ã€‚å¯ä»¥å¯¹è¯¥å±‚进行æ“作。 | +| cmd | 输入å‚数,表示扩展cmd,用于识别ä¸åŒçš„æ„图。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerAlpha + + +``` +int32_t(* LayerFuncs::SetLayerAlpha) (uint32_t devId, uint32_t layerId, LayerAlpha *alpha) +``` + +**æ述:** + +设置图层alpha值。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| alpha | 输入å‚数,待设置的图层 alpha 值。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerAlpha](#getlayeralpha) + + +### SetLayerBlendType + + +``` +int32_t(* LayerFuncs::SetLayerBlendType) (uint32_t devId, uint32_t layerId, BlendType type) +``` + +**æ述:** + +设置混åˆç±»åž‹ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备的ID。å–值范围为0 ~ 4,其ä¸0表示第一个显示设备,4表示最åŽä¸€ä¸ªæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| layerId | 输入å‚数,层IDï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªå±‚ã€‚å¯ä»¥å¯¹è¯¥å±‚进行æ“作。 | +| type | 输入å‚数,指示混åˆç±»åž‹ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerBuffer + + +``` +int32_t(* LayerFuncs::SetLayerBuffer) (uint32_t devId, uint32_t layerId, const BufferHandle *buffer, int32_t fence) +``` + +**æ述:** + +设置一个层的缓冲区。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备的ID。å–值范围为0 ~ 4,其ä¸0表示第一个显示设备,4表示最åŽä¸€ä¸ªæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| layerId | 输入å‚数,层IDï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªå±‚ã€‚å¯ä»¥å¯¹è¯¥å±‚进行æ“作。 | +| buffer | 输入å‚数,指示缓冲区å¥æŸ„的指针,该指针包å«æ‰€æœ‰ç”¨äºŽåˆæˆçš„缓冲区的所有信æ¯ã€‚ | +| fence | 输入å‚数,åŒæ¥æ–‡ä»¶çš„fd。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerColorDataSpace + + +``` +int32_t(* LayerFuncs::SetLayerColorDataSpace) (uint32_t devId, uint32_t layerId, ColorDataSpace colorSpace) +``` + +**æ述:** + +设置图层的颜色数æ®ç©ºé—´ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| colorSpace | 输入å‚数,表示需è¦è®¾ç½®çš„颜色数æ®ç©ºé—´ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerColorKey + + +``` +int32_t(* LayerFuncs::SetLayerColorKey) (uint32_t devId, uint32_t layerId, bool enable, uint32_t key) +``` + +**æ述:** + +设置图层colorkey属性,在图层å åŠ æ—¶ä½¿ç”¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| enable | 输入å‚æ•°ï¼Œå¾…è®¾ç½®çš„è‰²é”®ä½¿èƒ½æ ‡è¯†ã€‚ | +| key | 输入å‚数,待设置的色键值,å³é¢œè‰²å€¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerColorKey](#getlayercolorkey) + + +### SetLayerColorTransform + + +``` +int32_t(* LayerFuncs::SetLayerColorTransform) (uint32_t devId, uint32_t layerId, const float *matrix) +``` + +**æ述:** + +设置图层当å‰çš„颜色转æ¢çŸ©é˜µã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| matrix | 输入å‚数,表示需è¦è®¾ç½®çš„颜色转æ¢æ¨¡å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerCompositionType + + +``` +int32_t(* LayerFuncs::SetLayerCompositionType) (uint32_t devId, uint32_t layerId, CompositionType type) +``` + +**æ述:** + +设置客户端期望的组åˆç±»åž‹ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备的ID。å–值范围为0 ~ 4,其ä¸0表示第一个显示设备,4表示最åŽä¸€ä¸ªæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| layerId | 输入å‚数,层IDï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªå±‚ã€‚å¯ä»¥å¯¹è¯¥å±‚进行æ“作。 | +| type | 输入å‚数,指示客户端期望的组åˆç±»åž‹ã€‚它å¯èƒ½éšå®žçŽ°è€Œå˜åŒ–。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerCompression + + +``` +int32_t(* LayerFuncs::SetLayerCompression) (uint32_t devId, uint32_t layerId, int32_t compType) +``` + +**æ述:** + +设置图层压缩功能 + +在特定场景下,需è¦å¯¹å›¾åƒæ•°æ®è¿›è¡ŒåŽ‹ç¼©ï¼Œå¯è®¾ç½®å¯åŠ¨æˆ–å…³é—图层压缩功能。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| compType | 输入å‚æ•°ï¼Œå›¾å±‚åŽ‹ç¼©ä½¿èƒ½æ ‡è¯†ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerCompression](#getlayercompression) + + +### SetLayerCrop + + +``` +int32_t(* LayerFuncs::SetLayerCrop) (uint32_t devId, uint32_t layerId, IRect *rect) +``` + +**æ述:** + +设置图层è£å‰ªåŒºåŸŸã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| rect | 输入å‚数,待设置的è£å‰ªåŒºåŸŸã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerDirtyRegion + + +``` +int32_t(* LayerFuncs::SetLayerDirtyRegion) (uint32_t devId, uint32_t layerId, IRect *region) +``` + +**æ述:** + +设置图层刷新区域。 + +GUI图形系统绘制好图åƒæ•°æ®åŽï¼Œåœ¨è°ƒç”¨Flush接å£åˆ·æ–°å±å¹•ä¹‹å‰éœ€è¦è®¾ç½®å›¾å±‚刷新区域。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| region | 输入å‚数,待设置的刷新区域。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerMetaData + + +``` +int32_t(* LayerFuncs::SetLayerMetaData) (uint32_t devId, uint32_t layerId, uint32_t num, const HDRMetaData *metaData) +``` + +**æ述:** + +设置图层的HDRmetaData。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| num | 输入å‚数,metadata 数组个数。 | +| metaData | 输入å‚数,表示需è¦è®¾ç½®çš„ metadata 数组首地å€ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerMetaDataSet + + +``` +int32_t(* LayerFuncs::SetLayerMetaDataSet) (uint32_t devId, uint32_t layerId, HDRMetadataKey key, uint32_t num, const uint8_t *metaData) +``` + +**æ述:** + +设置图层的metaData set。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| key | 输入å‚数,表示需è¦è®¾ç½®çš„ HDRMetadataKey。 | +| num | 输入å‚数,metadata 数组个数。 | +| metaData | 输入å‚数,表示需è¦è®¾ç½®çš„ metadata 数组首地å€, æ•°æ®ç±»åž‹ä¸ºuint8_t。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerPalette + + +``` +int32_t(* LayerFuncs::SetLayerPalette) (uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len) +``` + +**æ述:** + +设置图层调色æ¿ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| palette | 输入å‚数,待设置的图层调色æ¿ã€‚ | +| len | 输入å‚数,调色æ¿é•¿åº¦ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerPalette](#getlayerpalette) + + +### SetLayerPreMulti + + +``` +int32_t(* LayerFuncs::SetLayerPreMulti) (uint32_t devId, uint32_t layerId, bool preMul) +``` + +**æ述:** + +设置图层预乘。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| preMul | 输入å‚æ•°ï¼Œå¾…è®¾ç½®çš„å›¾å±‚é¢„ä¹˜ä½¿èƒ½æ ‡è¯†ï¼Œ1表示使能图层预乘,0表示ä¸ä½¿èƒ½å›¾å±‚预乘。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerPreMulti](#getlayerpremulti) + + +### SetLayerSize + + +``` +int32_t(* LayerFuncs::SetLayerSize) (uint32_t devId, uint32_t layerId, IRect *rect) +``` + +**æ述:** + +设置图层大å°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| rect | 输入å‚数,待设置的图层大å°ï¼Œå•ä½ä¸ºåƒç´ 。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerSize](#getlayersize) + + +### SetLayerTunnelHandle + + +``` +int32_t(* LayerFuncs::SetLayerTunnelHandle) (uint32_t devId, uint32_t layerId, ExtDataHandle *handle) +``` + +**æ述:** + +设置图层的tunnelå¥æŸ„。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,指示需è¦æ“作的设备ID。 | +| layerId | 输入å‚数,指示需è¦æ“作的图层ID。 | +| handle | 输入å‚数,表示需è¦è®¾ç½®çš„å¥æŸ„。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerVisible + + +``` +int32_t(* LayerFuncs::SetLayerVisible) (uint32_t devId, uint32_t layerId, bool visible) +``` + +**æ述:** + +设置图层是å¦å¯è§ã€‚ + +ä¸å¯è§æƒ…况下图层ä¸æ˜¾ç¤ºåœ¨å±å¹•ä¸Šï¼Œå¯è§æƒ…况下图层显示在å±å¹•ä¸Šã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| visible | 输入å‚数,待设置的图层å¯è§æ ‡è¯†ï¼Œè®¾ç½®true表示图层å¯è§ï¼Œè®¾ç½®false表示图层ä¸å¯è§ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerVisibleState](#getlayervisiblestate) + + +### SetLayerVisibleRegion + + +``` +int32_t(* LayerFuncs::SetLayerVisibleRegion) (uint32_t devId, uint32_t layerId, uint32_t num, IRect *rect) +``` + +**æ述:** + +设置一个图层的å¯è§åŒºåŸŸ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备的ID。å–值范围为0 ~ 4,其ä¸0表示第一个显示设备,4表示最åŽä¸€ä¸ªæ˜¾ç¤ºè®¾å¤‡ã€‚ | +| layerId | 输入å‚数,层IDï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªå±‚ã€‚å¯ä»¥å¯¹è¯¥å±‚进行æ“作。 | +| num | 输入å‚数,指定rect的计数,该区域包å«å¤šä¸ª [IRect](_i_rect.md),num表示该区域ä¸æœ‰å¤šå°‘个rect区域。 | +| rect | 输出å‚数,rectes对象的指针。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SetLayerZorder + + +``` +int32_t(* LayerFuncs::SetLayerZorder) (uint32_t devId, uint32_t layerId, uint32_t zorder) +``` + +**æ述:** + +设置图层Z轴次åºã€‚ + +图层的Zåºå€¼è¶Šå¤§ï¼Œå›¾å±‚越é 上显示。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| zorder | 输入å‚数,待设置的图层Zåºï¼Œä¸ºæ•´æ•°å€¼ï¼Œå–值范围为[0, 255],值越大图层越往上排列。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + +**å‚è§ï¼š** + +[GetLayerZorder](#getlayerzorder) + + +### SetTransformMode + + +``` +int32_t(* LayerFuncs::SetTransformMode) (uint32_t devId, uint32_t layerId, TransformType type) +``` + +**æ述:** + +设置图层å˜æ¢æ¨¡å¼ï¼Œæ ¹æ®ä¸åŒçš„场景设置图层的旋转ã€ç¼©æ”¾ã€ç§»ä½ç‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| type | 输入å‚数,待设置的图层å˜æ¢æ¨¡å¼ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### SnapShot + + +``` +int32_t(* LayerFuncs::SnapShot) (uint32_t devId, LayerBuffer *buffer) +``` + +**æ述:** + +实现抓图功能。 + +本函数将显示设备上的图åƒæ•°æ®æˆªå›¾ä¿å˜åˆ°bufferä¸ï¼Œç”¨äºŽè°ƒè¯•ã€åº”用截图ç‰åœºæ™¯ã€‚ + +otherwise. + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| buffer | 输出å‚数,ä¿å˜æˆªå±çš„bufferä¿¡æ¯ã€‚ | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 + + +### WaitForVBlank + + +``` +int32_t(* LayerFuncs::WaitForVBlank) (uint32_t devId, uint32_t layerId, int32_t timeOut) +``` + +**æ述:** + +实现ç‰å¾…帧消éšæœŸåˆ°æ¥åŠŸèƒ½ã€‚ + +该函数会让系统ç‰å¾…,直到帧消éšæœŸåˆ°æ¥ï¼Œç”¨äºŽè½¯ä»¶å’Œç¡¬ä»¶ä¹‹é—´çš„åŒæ¥ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| devId | 输入å‚数,显示设备ID,用于支æŒå¤šä¸ªæ˜¾ç¤ºè®¾å¤‡ï¼Œå–值从0开始,0表示第一个设备,最大支æŒ5个设备。 | +| layerId | 输入å‚数,图层IDï¼Œå›¾å±‚çš„å”¯ä¸€æ ‡è¯†ï¼Œæ ¹æ®å›¾å±‚IDæ“作图层。 | +| timeOut | 输入å‚数,超时时间,在设置的超时时间åŽï¼Œæ²¡æœ‰ç‰åˆ°å¸§æ¶ˆéšæœŸåˆ°æ¥åˆ™è¶…时返回。 | + +**返回:** + +DISPLAY_SUCCESS 表示执行æˆåŠŸã€‚ + +其他值表示执行失败,具体错误ç 查看[DispErrCode](_display.md#disperrcode)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_layer_info.md b/zh-cn/device-dev/reference/hdi-apis/_layer_info.md new file mode 100644 index 0000000000000000000000000000000000000000..dec0da93d00b2149b713cc2369472137edc4cb8f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_layer_info.md @@ -0,0 +1,29 @@ +# LayerInfo + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](_display.md#width-27) | 图层宽度 | +| [height](_display.md#height-27) | 图层高度 | +| [type](_display.md#type-13) | 图层类型,包括图形层ã€è§†é¢‘层和媒体æ’放模å¼ã€‚ | +| [bpp](_display.md#bpp) | æ¯åƒç´ 所å bitæ•° | +| [pixFormat](_display.md#pixformat-12) | 图层åƒç´ æ ¼å¼ | + + +## **详细æè¿°** + +定义图层信æ¯ç»“构体。 + +在创建图层时,需è¦å°†LayerInfoä¼ é€’ç»™åˆ›å»ºå›¾å±‚æŽ¥å£ï¼Œåˆ›å»ºå›¾å±‚接å£æ ¹æ®å›¾å±‚ä¿¡æ¯åˆ›å»ºç›¸åº”图层。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light.md b/zh-cn/device-dev/reference/hdi-apis/_light.md new file mode 100644 index 0000000000000000000000000000000000000000..62e49861d2aaad72185e10e690f2b52c59a93309 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light.md @@ -0,0 +1,159 @@ +# Light + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [light_if.h](light__if_8h.md) | 声明light模å—的通用API,å¯ç”¨äºŽèŽ·å–ç¯IDã€æ‰“开或关é—ç¯ã€å¹¶è®¾ç½®ç¯å…‰äº®åº¦å’Œé—ªçƒæ¨¡å¼ã€‚ | +| [light_type.h](light_8typeh.md) | 定义ç¯çš„æ•°æ®ç»“构,包括ç¯IDã€ç¯çš„模å¼ã€ç¯çš„é—ªçƒæ¨¡å¼å’ŒæŒç»æ—¶é—´ã€ç¯çš„状æ€ã€ç¯çš„效果。 | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [LightFlashEffect](_light_flash_effect.md) | 定义闪çƒå‚数。 [更多...](_light_flash_effect.md) | +| [LightEffect](_light_effect.md) | 定义ç¯çš„效果å‚数。 [更多...](_light_effect.md) | +| [LightInfo](_light_info.md) | 定义ç¯çš„基本信æ¯ã€‚ [更多...](_light_info.md) | +| [LightInterface](_light_interface.md) | 定义å¯ä»¥åœ¨ç¯ä¸Šæ‰§è¡Œçš„基本æ“作。 [更多...](_light_interface.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [LightStatus](#lightstatus) { LIGHT_SUCCESS = 0, LIGHT_NOT_SUPPORT = -1, LIGHT_NOT_FLASH = -2, LIGHT_NOT_BRIGHTNESS = -3 } | 枚举ç¯æ¨¡å—的状æ€å€¼ã€‚ [更多...](#lightstatus) | +| [LightId](#lightid) { LIGHT_ID_NONE = 0, LIGHT_ID_BATTERY = 1, LIGHT_ID_NOTIFICATIONS = 2, LIGHT_ID_ATTENTION = 3, LIGHT_ID_BUTT = 4 } | 枚举ç¯ç±»åž‹ [更多...](#lightid) | +| [LightFlashMode](#lightflashmode) { LIGHT_FLASH_NONE = 0, LIGHT_FLASH_TIMED = 1, LIGHT_FLASH_BUTT = 2 } | 枚举ç¯çš„æ¨¡å¼ [更多...](#lightflashmode) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [NewLightInterfaceInstance](#newlightinterfaceinstance) (void) | 创建LightInterface实例。 [更多...](#newlightinterfaceinstance) | +| [FreeLightInterfaceInstance](#freelightinterfaceinstance) (void) | 释放LightInterface实例和相关资æºã€‚ [更多...](#freelightinterfaceinstance) | + + +## **详细æè¿°** + +ç¯æ¨¡å—对ç¯æœåŠ¡æ供通用的接å£èƒ½åŠ›ã€‚ + +ç¯æ¨¡å—为ç¯æœåŠ¡æ供通用的接å£åŽ»è®¿é—®ç¯é©±åŠ¨ã€‚ æœåŠ¡èŽ·å–ç¯é©±åŠ¨å¯¹è±¡æˆ–代ç†åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„APIs接å£èŽ·å–ç¯ä¿¡æ¯ã€æ‰“开或关é—ç¯ï¼Œå¹¶æ ¹æ®ç¯ID设置ç¯é—ªçƒæ¨¡å¼ã€‚ + +**Since:** + +3.1 + + +## **枚举类型说明** + + +### LightFlashMode + + +``` +enum LightFlashMode +``` + +**æ述:** + +枚举ç¯çš„æ¨¡å¼ + + | 枚举值 | æè¿° | +| -------- | -------- | +| LIGHT_FLASH_NONE | 常亮。 | +| LIGHT_FLASH_TIMED | é—ªçƒã€‚ | +| LIGHT_FLASH_BUTT | æ— æ•ˆæ¨¡å¼ã€‚ | + + +### LightId + + +``` +enum LightId +``` + +**æ述:** + +枚举ç¯ç±»åž‹ + + | 枚举值 | æè¿° | +| -------- | -------- | +| LIGHT_ID_NONE | 未知ID。 | +| LIGHT_ID_BATTERY | 电æºæŒ‡ç¤ºç¯ã€‚ | +| LIGHT_ID_NOTIFICATIONS | 通知ç¯ã€‚ | +| LIGHT_ID_ATTENTION | 报è¦ç¯ã€‚ | +| LIGHT_ID_BUTT | æ— æ•ˆID。 | + + +### LightStatus + + +``` +enum LightStatus +``` + +**æ述:** + +枚举ç¯æ¨¡å—的状æ€å€¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| LIGHT_SUCCESS | æ“作æˆåŠŸã€‚ | +| LIGHT_NOT_SUPPORT | ç¯IDä¸æ”¯æŒã€‚ | +| LIGHT_NOT_FLASH | 设置闪çƒä¸æ”¯æŒã€‚ | +| LIGHT_NOT_BRIGHTNESS | 设置亮度ä¸æ”¯æŒã€‚ | + + +## **函数说明** + + +### FreeLightInterfaceInstance() + + +``` +int32_t FreeLightInterfaceInstance (void ) +``` + +**æ述:** + +释放LightInterface实例和相关资æºã€‚ + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +3.1 + + +### NewLightInterfaceInstance() + + +``` +const struct LightInterface* NewLightInterfaceInstance (void ) +``` + +**æ述:** + +创建LightInterface实例。 + +创建的LightInterface实例å¯ç”¨äºŽæ‰§è¡Œç›¸å…³çš„ç¯æŽ§åˆ¶æ“作。 + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +3.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_effect.md b/zh-cn/device-dev/reference/hdi-apis/_light_effect.md new file mode 100644 index 0000000000000000000000000000000000000000..63a331afec767e0ed728758026263075c7cbed70 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light_effect.md @@ -0,0 +1,57 @@ +# LightEffect + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### Public 属性 + +| Public 属性 | æè¿° | +| -------- | -------- | +| [lightBrightness](#lightbrightness) | 亮度值。 | +| [flashEffect](#flasheffect) | é—ªçƒæ¨¡å¼ã€‚ | + + +## **详细æè¿°** + +定义ç¯çš„效果å‚数。 + +å‚数包括亮度和闪çƒæ¨¡å¼ã€‚ + +**Since:** + +3.1 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### flashEffect + + +``` +struct LightFlashEffect LightEffect::flashEffect +``` + +**æ述:** + +é—ªçƒæ¨¡å¼ã€‚详è§[LightFlashEffect](_light_flash_effect.md)。 + + +### lightBrightness + + +``` +int32_t LightEffect::lightBrightness +``` + +**æ述:** + +亮度值:Bits 24–31为扩展ä½ï¼ŒBits 16–23为红色,Bits 8–15为绿色,Bits 0–7为è“色。 如果相对应的å—节段ä¸ç‰äºŽ0,表示打开相应颜色的ç¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md b/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md new file mode 100644 index 0000000000000000000000000000000000000000..9a8a9123a99ee397b85ff88fc9158af0a16d446e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light_flash_effect.md @@ -0,0 +1,70 @@ +# LightFlashEffect + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [flashMode](#flashmode) | é—ªçƒæ¨¡å¼ã€‚ | +| [onTime](#ontime) | 表示ç¯åœ¨é—ªçƒæœŸé—´ç‚¹äº®æ—¶æŒç»çš„时间(毫秒)。 | +| [offTime](#offtime) | 表示ç¯åœ¨é—ªçƒæœŸé—´ç†„çæ—¶æŒç»çš„时间(毫秒)。 | + + +## **详细æè¿°** + +定义闪çƒå‚数。 + +这些å‚数包括闪çƒæ¨¡å¼ä»¥åŠé—ªçƒæœŸé—´æŒ‡ç¤ºç¯çš„打开和关é—时间。 + +**Since:** + +3.1 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### flashMode + + +``` +int32_t LightFlashEffect::flashMode +``` + +**æ述:** + +é—ªçƒæ¨¡å¼ï¼Œè¯¦è§[LightFlashMode](_light.md#lightflashmode)。 + + +### offTime + + +``` +int32_t LightFlashEffect::offTime +``` + +**æ述:** + +表示ç¯åœ¨é—ªçƒæœŸé—´ç†„çæ—¶æŒç»çš„时间(毫秒)。 + + +### onTime + + +``` +int32_t LightFlashEffect::onTime +``` + +**æ述:** + +表示ç¯åœ¨é—ªçƒæœŸé—´ç‚¹äº®æ—¶æŒç»çš„时间(毫秒)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_info.md b/zh-cn/device-dev/reference/hdi-apis/_light_info.md new file mode 100644 index 0000000000000000000000000000000000000000..20d8387e71e256aaefa055c21bd9b66d208379d2 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light_info.md @@ -0,0 +1,57 @@ +# LightInfo + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [lightId](#lightid) | ç¯ID | +| [reserved](#reserved) | è‡ªå®šä¹‰æ‰©å±•ä¿¡æ¯ | + + +## **详细æè¿°** + +定义ç¯çš„基本信æ¯ã€‚ + +基本的ç¯ä¿¡æ¯åŒ…括ç¯ID和自定义扩展信æ¯ã€‚ + +**Since:** + +3.1 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### lightId + + +``` +uint32_t LightInfo::lightId +``` + +**æ述:** + +ç¯ID,详è§[LightId](_light.md#lightid)。 + + +### reserved + + +``` +int32_t LightInfo::reserved +``` + +**æ述:** + +自定义扩展信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_light_interface.md b/zh-cn/device-dev/reference/hdi-apis/_light_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..9621d96fb11e3d7a3df73214c9aa2d5a45f0b252 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_light_interface.md @@ -0,0 +1,109 @@ +# LightInterface + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### Public 属性 + +| Public 属性 | æè¿° | +| -------- | -------- | +| ( [GetLightInfo](#getlightinfo) )([out] struct [LightInfo](_light_info.md) \*\*lightInfo, [out] uint32_t \*count) | 获å–当å‰ç³»ç»Ÿä¸æ‰€æœ‰ç±»åž‹çš„ç¯ä¿¡æ¯ã€‚ [更多...](#getlightinfo) | +| ( [TurnOnLight](#turnonlight) )([in] uint32_t lightId, [in] struct [LightEffect](_light_effect.md) \*effect) | æ ¹æ®æŒ‡å®šçš„ç¯ID打开列表ä¸çš„å¯ç”¨ç¯ã€‚ [更多...](#turnonlight) | +| ( [TurnOffLight](#turnofflight) )([in] uint32_t lightId) | æ ¹æ®æŒ‡å®šçš„ç¯IDå…³é—列表ä¸çš„å¯ç”¨ç¯ã€‚ [更多...](#turnofflight) | + + +## **详细æè¿°** + +定义å¯ä»¥åœ¨ç¯ä¸Šæ‰§è¡Œçš„基本æ“作。 + +æ“作包括获å–ç¯çš„ä¿¡æ¯ã€æ‰“开或关é—ç¯ã€è®¾ç½®ç¯çš„亮度和闪çƒæ¨¡å¼ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### GetLightInfo + + +``` +int32_t(* LightInterface::GetLightInfo) ([out] struct LightInfo **lightInfo,[out] uint32_t *count) +``` + +**æ述:** + +获å–当å‰ç³»ç»Ÿä¸æ‰€æœ‰ç±»åž‹çš„ç¯ä¿¡æ¯ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| lightInfo | 表示指å‘ç¯ä¿¡æ¯çš„二级指针,详è§[LightInfo](_light_info.md)。 | +| count | 表示指å‘ç¯æ•°é‡çš„指针。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### TurnOffLight + + +``` +int32_t(* LightInterface::TurnOffLight) ([in] uint32_t lightId) +``` + +**æ述:** + +æ ¹æ®æŒ‡å®šçš„ç¯IDå…³é—列表ä¸çš„å¯ç”¨ç¯ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| lightId | 表示ç¯ID,详è§[LightId](_light.md#lightid)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### TurnOnLight + + +``` +int32_t(* LightInterface::TurnOnLight) ([in] uint32_t lightId,[in] struct LightEffect *effect) +``` + +**æ述:** + +æ ¹æ®æŒ‡å®šçš„ç¯ID打开列表ä¸çš„å¯ç”¨ç¯ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| lightId | 表示ç¯ID,详è§[LightId](_light.md#lightid)。 | +| effect | 表示指å‘ç¯æ•ˆæžœçš„指针,如果lightbrightnesså—段为0时, ç¯çš„äº®åº¦æ ¹æ®HCSé…置的默认亮度进行设置,详è§[LightEffect](_light_effect.md)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果ä¸æ”¯æŒç¯ID,则返回-1。 + +如果ä¸æ”¯æŒé—ªçƒè®¾ç½®ï¼Œåˆ™è¿”回-2。 + +如果ä¸æ”¯æŒäº®åº¦è®¾ç½®ï¼Œåˆ™è¿”回-3。 + diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md new file mode 100644 index 0000000000000000000000000000000000000000..73ab78e3a96dd2462352ba188d74bb550375939d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md @@ -0,0 +1,24 @@ +# OHOS::Camera::CaptureEndedInfo + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [streamId_](_camera.md#streamid-34) | æ•èŽ·çš„æµID。 | +| [frameCount_](_camera.md#framecount) | æ•èŽ·ç»“æŸæ—¶å·²ç»æŠ“å–的帧数。 | + + +## **详细æè¿°** + +æ•èŽ·ç»“æŸç›¸å…³ä¿¡æ¯ï¼Œç”¨äºŽæ•èŽ·ç»“æŸå›žè°ƒ[OnCaptureEnded](_camera.md#oncaptureended)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md new file mode 100644 index 0000000000000000000000000000000000000000..fed70cf0c2f5339c6d17280d30ba324167a08120 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md @@ -0,0 +1,24 @@ +# OHOS::Camera::CaptureErrorInfo + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [streamId_](_camera.md#streamid-44) | æµID。 | +| [error_](_camera.md#error) | 错误类型。 | + + +## **详细æè¿°** + +æµé”™è¯¯ä¿¡æ¯ï¼Œç”¨äºŽå›žè°ƒ[OnCaptureError](_camera.md#oncaptureerror)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md new file mode 100644 index 0000000000000000000000000000000000000000..ed436019406bf6e0646d37c6a78cc3996d993b0e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md @@ -0,0 +1,25 @@ +# OHOS::Camera::CaptureInfo + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [streamIds_](_camera.md#streamids) | æ•èŽ·çš„æµID集åˆã€‚ | +| [captureSetting_](_camera.md#capturesetting) | æ•èŽ·çš„é…置信æ¯ã€‚ | +| [enableShutterCallback_](_camera.md#enableshuttercallback) | 使能æ•èŽ·å›žè°ƒï¼Œæ¯ä¸€æ¬¡æ•èŽ·åŽéƒ½ä¼šè§¦å‘ [OnFrameShutter](_camera.md#onframeshutter)。 | + + +## **详细æè¿°** + +æ•èŽ·è¯·æ±‚的相关信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md new file mode 100644 index 0000000000000000000000000000000000000000..7000a726a8d5d1456daafc9e9baff100c162208b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md @@ -0,0 +1,30 @@ +# OHOS::Camera::ICameraDevice + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Device") | IPC通信tokenæ ¡éªŒã€‚ | +| [GetStreamOperator](_camera.md#getstreamoperator) (const OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) > &streamOperator)=0 | 获å–æµæ“作å¥æŸ„。 [更多...](_camera.md#getstreamoperator) | +| [UpdateSettings](_camera.md#updatesettings) (const std::shared_ptr< CameraSetting > &settings)=0 | 更新设备控制å‚数。 [更多...](_camera.md#updatesettings) | +| [SetResultMode](_camera.md#setresultmode) (const [ResultCallbackMode](_camera.md#resultcallbackmode) &mode)=0 | 设置metadata上报模å¼ï¼Œé€å¸§ä¸ŠæŠ¥è¿˜æ˜¯è®¾å¤‡çŠ¶æ€å˜åŒ–时上报。 [更多...](_camera.md#setresultmode) | +| [GetEnabledResults](_camera.md#getenabledresults) (std::vector< MetaType > &results)=0 | 查询使能的metadata。 [更多...](_camera.md#getenabledresults) | +| [EnableResult](_camera.md#enableresult) (const std::vector< MetaType > &results)=0 | 打开metadata上报开关。 [更多...](_camera.md#enableresult) | +| [DisableResult](_camera.md#disableresult) (const std::vector< MetaType > &results)=0 | å…³é—metadata上报开关。 [更多...](_camera.md#disableresult) | +| [Close](_camera.md#close) ()=0 | å…³é—Camera设备。 [更多...](_camera.md#close) | + + +## **详细æè¿°** + +Camera设备æ“作。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..4a7f16ecc6932bca6fc726e496004236aa3f81ad --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md @@ -0,0 +1,25 @@ +# OHOS::Camera::ICameraDeviceCallback + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.DeviceCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OnError](_camera.md#onerror) ([ErrorType](_camera.md#errortype) type, int32_t errorCode)=0 | 设备å‘生错误时调用,由调用者实现,用于返回错误信æ¯ç»™è°ƒç”¨è€…。 [更多...](_camera.md#onerror) | +| [OnResult](_camera.md#onresult) (uint64_t timestamp, const std::shared_ptr< CameraMetadata > &result)=0 | 上报camera设备相关的metadata的回调,上报方å¼æŸ¥çœ‹ [SetResultMode](_camera.md#setresultmode)。 [更多...](_camera.md#onresult) | + + +## **详细æè¿°** + +Camera设备æ“作回调。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md new file mode 100644 index 0000000000000000000000000000000000000000..a77249e55bb64230e8eb8c1d48e59c9623013a3e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md @@ -0,0 +1,35 @@ +# OHOS::Camera::ICameraHost + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.Host") | IPC通信tokenæ ¡éªŒã€‚ | +| [SetCallback](_camera.md#setcallback) (const OHOS::sptr< [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) > &callback)=0 | 设置ICameraHost回调接å£ï¼Œå›žè°ƒå‡½æ•°å‚考 [ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)。 [更多...](_camera.md#setcallback) | +| [GetCameraIds](_camera.md#getcameraids) (std::vector< std::string > &cameraIds)=0 | 获å–当å‰å¯ç”¨çš„Camera设备ID列表。 [更多...](_camera.md#getcameraids) | +| [GetCameraAbility](_camera.md#getcameraability) (const std::string &cameraId, std::shared_ptr< CameraAbility > &ability)=0 | 获å–Camera设备能力集åˆã€‚ [更多...](_camera.md#getcameraability) | +| [OpenCamera](_camera.md#opencamera) (const std::string &cameraId, const OHOS::sptr< [ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) > &callback, OHOS::sptr< [ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) > &device)=0 | 打开Camera设备。 [更多...](_camera.md#opencamera) | +| [SetFlashlight](_camera.md#setflashlight) (const std::string &cameraId, bool &isEnable)=0 | 打开或关é—闪光ç¯ã€‚ [更多...](_camera.md#setflashlight) | + + +### é™æ€ Public æˆå‘˜å‡½æ•° + + | é™æ€ Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [Get](_camera.md#get) (const char \*serviceName) | 获å–ICameraHost实例。 [更多...](_camera.md#get) | + + +## **详细æè¿°** + +CameraæœåŠ¡çš„管ç†ç±»ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..7a0885b50d8f9647c9fd0dc82e9684dd2acdf255 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md @@ -0,0 +1,26 @@ +# OHOS::Camera::ICameraHostCallback + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.HostCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OnCameraStatus](_camera.md#oncamerastatus) (const std::string &cameraId, [CameraStatus](_camera.md#camerastatus) status)=0 | 用于Camera设备状æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 [更多...](_camera.md#oncamerastatus) | +| [OnFlashlightStatus](_camera.md#onflashlightstatus) (const std::string &cameraId, [FlashlightStatus](_camera.md#flashlightstatus) status)=0 | 用于在闪光ç¯çŠ¶æ€å˜åŒ–时上报状æ€ä¿¡æ¯ç»™è°ƒç”¨è€…。 [更多...](_camera.md#onflashlightstatus) | +| [OnCameraEvent](_camera.md#oncameraevent) (const std::string &cameraId, [CameraEvent](_camera.md#cameraevent) event)=0 | 在相机事件å‘生时调用。 [更多...](_camera.md#oncameraevent) | + + +## **详细æè¿°** + +CameraæœåŠ¡çš„管ç†å›žè°ƒã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md new file mode 100644 index 0000000000000000000000000000000000000000..f8793d89a49086de20c50ba6beb49a85107eaba9 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md @@ -0,0 +1,26 @@ +# OHOS::Camera::IOfflineStreamOperator + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.OfflineStreamOperator") | IPC通信tokenæ ¡éªŒã€‚ | +| [CancelCapture](_camera.md#cancelcapture-12) (int captureId)=0 | å–消æ•èŽ·è¯·æ±‚。 [更多...](_camera.md#cancelcapture-12) | +| [ReleaseStreams](_camera.md#releasestreams-12) (const std::vector< int > &streamIds)=0 | 释放离线æµã€‚ [更多...](_camera.md#releasestreams-12) | +| [Release](_camera.md#release) ()=0 | 释放所有离线æµã€‚ [更多...](_camera.md#release) | + + +## **详细æè¿°** + +离线æµçš„æ“作类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md new file mode 100644 index 0000000000000000000000000000000000000000..b38ca7889204518e9f9321b212375022a92b2acd --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md @@ -0,0 +1,33 @@ +# OHOS::Camera::IStreamOperator + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperator") | IPC通信tokenæ ¡éªŒã€‚ | +| [IsStreamsSupported](_camera.md#isstreamssupported) ([OperationMode](_camera.md#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting, const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &info, [StreamSupportType](_camera.md#streamsupporttype) &type)=0 | 查询是å¦æ”¯æŒæ·»åŠ å‚æ•°å¯¹åº”çš„æµ [更多...](_camera.md#isstreamssupported) | +| [CreateStreams](_camera.md#createstreams) (const std::vector< std::shared_ptr< [StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) >> &streamInfos)=0 | 创建æµã€‚ [更多...](_camera.md#createstreams) | +| [ReleaseStreams](_camera.md#releasestreams-22) (const std::vector< int > &streamIds)=0 | 释放æµã€‚ [更多...](_camera.md#releasestreams-22) | +| [CommitStreams](_camera.md#commitstreams) ([OperationMode](_camera.md#operationmode) mode, const std::shared_ptr< CameraMetadata > &modeSetting)=0 | é…ç½®æµã€‚ [更多...](_camera.md#commitstreams) | +| [GetStreamAttributes](_camera.md#getstreamattributes) (std::vector< std::shared_ptr< [StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) >> &attributes)=0 | 获å–æµçš„属性。 [更多...](_camera.md#getstreamattributes) | +| [AttachBufferQueue](_camera.md#attachbufferqueue) (int streamId, const OHOS::sptr< OHOS::IBufferProducer > &producer)=0 | 绑定生产者å¥æŸ„和指定æµã€‚ [更多...](_camera.md#attachbufferqueue) | +| [DetachBufferQueue](_camera.md#detachbufferqueue) (int streamId)=0 | 解除生产者å¥æŸ„和指定æµçš„绑定关系。 [更多...](_camera.md#detachbufferqueue) | +| [Capture](_camera.md#capture) (int captureId, const std::shared_ptr< [CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) > &info, bool isStreaming)=0 | æ•èŽ·å›¾åƒã€‚ [更多...](_camera.md#capture) | +| [CancelCapture](_camera.md#cancelcapture-22) (int captureId)=0 | å–消æ•èŽ·ã€‚ [更多...](_camera.md#cancelcapture-22) | +| [ChangeToOfflineStream](_camera.md#changetoofflinestream) (const std::vector< int > &streamIds, OHOS::sptr< [IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) > &callback, OHOS::sptr< [IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) > &offlineOperator)=0 | 将指定æµè½¬æ¢æˆç¦»çº¿æµã€‚ [更多...](_camera.md#changetoofflinestream) | + + +## **详细æè¿°** + +æµçš„æ“作类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..4935fd6e235e1850ee9309db17f28910e75f5996 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md @@ -0,0 +1,27 @@ +# OHOS::Camera::IStreamOperatorCallback + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| **DECLARE_INTERFACE_DESCRIPTOR** (u"HDI.Camera.V1_0.StreamOperatorCallback") | IPC通信tokenæ ¡éªŒã€‚ | +| [OnCaptureStarted](_camera.md#oncapturestarted) (int32_t captureId, const std::vector< int32_t > &streamIds)=0 | æ•èŽ·å¼€å§‹å›žè°ƒï¼Œåœ¨æ•èŽ·å¼€å§‹æ—¶è°ƒç”¨ã€‚ [更多...](_camera.md#oncapturestarted) | +| [OnCaptureEnded](_camera.md#oncaptureended) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) >> &infos)=0 | æ•èŽ·ç»“æŸå›žè°ƒï¼Œåœ¨æ•èŽ·ç»“æŸæ—¶è°ƒç”¨ã€‚ [更多...](_camera.md#oncaptureended) | +| [OnCaptureError](_camera.md#oncaptureerror) (int32_t captureId, const std::vector< std::shared_ptr< [CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) >> &infos)=0 | æ•èŽ·é”™è¯¯å›žè°ƒï¼Œåœ¨æ•èŽ·è¿‡ç¨‹ä¸å‘生错误时调用。 [更多...](_camera.md#oncaptureerror) | +| [OnFrameShutter](_camera.md#onframeshutter) (int32_t captureId, const std::vector< int32_t > &streamIds, uint64_t timestamp)=0 | 帧æ•èŽ·å›žè°ƒã€‚ [更多...](_camera.md#onframeshutter) | + + +## **详细æè¿°** + +æµçš„æ“作回调类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md new file mode 100644 index 0000000000000000000000000000000000000000..568e09e49daf3d929d6862a117be57fad26048eb --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md @@ -0,0 +1,31 @@ +# OHOS::Camera::StreamAttribute + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [streamId_](_camera.md#streamid-24) | æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ | +| [width_](_camera.md#width-22) | 图åƒå®½åº¦ã€‚ | +| [height_](_camera.md#height-22) | 图åƒé«˜åº¦ã€‚ | +| [overrideFormat_](_camera.md#overrideformat) | é‡å†™çš„图åƒæ ¼å¼ã€‚ | +| [overrideDatasapce_](_camera.md#overridedataspace) | é‡å†™çš„图åƒé¢œè‰²ç©ºé—´ | +| [producerUsage_](_camera.md#producerusage) | é‡å†™åŽçš„生产者的使用方å¼ã€‚ | +| [producerBufferCount_](_camera.md#producerbuffercount) | é‡å†™åŽçš„生产者缓å˜æ•°é‡ã€‚ | +| [maxBatchCaptureCount_](_camera.md#maxbatchcapturecount) | è¿žæ‹æ”¯æŒçš„最大æ•èŽ·å¸§æ•°é‡ã€‚ | +| [maxCaptureCount_](_camera.md#maxcapturecount) | 最大的并å‘æ•èŽ·è¯·æ±‚个数,默认为1。 | + + +## **详细æè¿°** + +æµçš„属性。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md new file mode 100644 index 0000000000000000000000000000000000000000..f258c8e39376ad1284bfaff72cbd2b4a8273b4d5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md @@ -0,0 +1,32 @@ +# OHOS::Camera::StreamInfo + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [streamId_](_camera.md#streamid-14) | æµçš„IDï¼Œç”¨äºŽåœ¨è®¾å¤‡å†…å”¯ä¸€æ ‡è¯†ä¸€æ¡æµã€‚ | +| [width_](_camera.md#width-12) | 图åƒå®½åº¦ã€‚ | +| [height_](_camera.md#height-12) | 图åƒé«˜åº¦ã€‚ | +| [format_](_camera.md#format) | 图åƒæ ¼å¼ã€‚ | +| [datasapce_](_camera.md#dataspace) | 图åƒé¢œè‰²ç©ºé—´ã€‚ | +| [intent_](_camera.md#intent) | æµç±»åž‹ã€‚ | +| [tunneledMode_](_camera.md#tunneledmode) | 隧é“模å¼ï¼Œå€¼ä¸ºtrue时开å¯ï¼Œfalseå…³é—。 | +| [bufferQueue_](_camera.md#bufferqueue) | 图形æ供的生产者å¥æŸ„。 | +| [minFrameDuration_](_camera.md#minframeduration) | 最å°å¸§é—´éš”。 | +| [encodeType_](_camera.md#encodetype) | ç¼–ç 类型。 | + + +## **详细æè¿°** + +æµä¿¡æ¯ï¼Œç”¨äºŽåˆ›å»ºæµæ—¶ä¼ 入相关的é…ç½®å‚数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md new file mode 100644 index 0000000000000000000000000000000000000000..0ae62b90c880862107a3d949d7b659b322ca278e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md @@ -0,0 +1,25 @@ +# OHOS::USB::USBDeviceInfo + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [status](_u_s_b.md#status) | USBè®¾å¤‡çŠ¶æ€ | +| [busNum](_u_s_b.md#busnum-12) | USBæ€»çº¿ç¼–å· | +| [devNum](_u_s_b.md#devnum) | USBè®¾å¤‡ç¼–å· | + + +## **详细æè¿°** + +USB设备信æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md new file mode 100644 index 0000000000000000000000000000000000000000..545ea45988ed42a69dd6b855e100795956fb4850 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md @@ -0,0 +1,27 @@ +# OHOS::USB::UsbCtrlTransfer + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [requestType](_u_s_b.md#requesttype) | 请求类型 | +| [requestCmd](_u_s_b.md#requestcmd) | è¯·æ±‚å‘½ä»¤å— | +| [value](_u_s_b.md#value) | 请求值 | +| [index](_u_s_b.md#index) | 索引 | +| [timeout](_u_s_b.md#timeout) | 超时时间 | + + +## **详细æè¿°** + +USBæŽ§åˆ¶ä¼ è¾“ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md new file mode 100644 index 0000000000000000000000000000000000000000..5df0bae75c4fc4c442c14211b38e55b2b928dba5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md @@ -0,0 +1,24 @@ +# OHOS::USB::UsbDev + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [busNum](_u_s_b.md#busnum-22) | USBæ€»çº¿ç¼–å· | +| [devAddr](_u_s_b.md#devaddr) | USBè®¾å¤‡åœ°å€ | + + +## **详细æè¿°** + +USB设备。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md new file mode 100644 index 0000000000000000000000000000000000000000..c576768593247cab80492de2de938a982745071c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md @@ -0,0 +1,35 @@ +# OHOS::USB::UsbInfo + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [setDevInfoStatus](_u_s_b.md#setdevinfostatus) (int32_t status) | 设置USB设备状æ€ã€‚ [更多...](_u_s_b.md#setdevinfostatus) | +| [setDevInfoBusNum](_u_s_b.md#setdevinfobusnum) (int32_t busNum) | 设置USB总线编å·ã€‚ [更多...](_u_s_b.md#setdevinfobusnum) | +| [setDevInfoDevNum](_u_s_b.md#setdevinfodevnum) (int32_t devNum) | 设置USB设备编å·ã€‚ [更多...](_u_s_b.md#setdevinfodevnum) | +| [getDevInfoStatus](_u_s_b.md#getdevinfostatus) () const | 获å–USB设备状æ€ã€‚ [更多...](_u_s_b.md#getdevinfostatus) | +| [getDevInfoBusNum](_u_s_b.md#getdevinfobusnum) () const | 获å–USB总线编å·ã€‚ [更多...](_u_s_b.md#getdevinfobusnum) | +| [getDevInfoDevNum](_u_s_b.md#getdevinfodevnum) () const | 获å–USB设备编å·ã€‚ [更多...](_u_s_b.md#getdevinfodevnum) | + + +### Private æˆå‘˜å˜é‡ + + | Private æˆå‘˜å˜é‡ | æè¿° | +| -------- | -------- | +| [USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) devInfo | USB设备信æ¯ã€‚ | + + +## **详细æè¿°** + +USB设备信æ¯ç±»ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md new file mode 100644 index 0000000000000000000000000000000000000000..e58adfe5cdf7a56550c81967622d862343ac384f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md @@ -0,0 +1,24 @@ +# OHOS::USB::UsbPipe + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [interfaceId](_u_s_b.md#interfaceid) | USB设备接å£ID | +| [endpointId](_u_s_b.md#endpointid) | USB设备端点ID | + + +## **详细æè¿°** + +管é“ä¿¡æ¯ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md new file mode 100644 index 0000000000000000000000000000000000000000..9bc4102d6e28c072dee510f953bb241cf9413766 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md @@ -0,0 +1,62 @@ +# OHOS::USB::UsbdClient + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OpenDevice](_u_s_b.md#opendevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 打开设备,建立连接。 [更多...](_u_s_b.md#opendevice) | +| [CloseDevice](_u_s_b.md#closedevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | å…³é—设备,释放与设备相关的所有系统资æºã€‚ [更多...](_u_s_b.md#closedevice) | +| [GetDeviceDescriptor](_u_s_b.md#getdevicedescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获å–设备æ述符。 [更多...](_u_s_b.md#getdevicedescriptor) | +| [GetStringDescriptor](_u_s_b.md#getstringdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | æ ¹æ®String ID获å–设备的å—符串æ述符。 [更多...](_u_s_b.md#getstringdescriptor) | +| [GetConfigDescriptor](_u_s_b.md#getconfigdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | æ ¹æ®config ID获å–设备的é…ç½®æ述符config。 [更多...](_u_s_b.md#getconfigdescriptor) | +| [GetRawDescriptor](_u_s_b.md#getrawdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获å–原始æ述符。 [更多...](_u_s_b.md#getrawdescriptor) | +| [GetFileDescriptor](_u_s_b.md#getfiledescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, int32_t &fd) | 获å–文件æ述符。 [更多...](_u_s_b.md#getfiledescriptor) | +| [SetConfig](_u_s_b.md#setconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t configIndex) | 设置当å‰çš„configä¿¡æ¯ã€‚ [更多...](_u_s_b.md#setconfig) | +| [GetConfig](_u_s_b.md#getconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t &configIndex) | 获å–当å‰çš„configä¿¡æ¯ã€‚ [更多...](_u_s_b.md#getconfig) | +| [ClaimInterface](_u_s_b.md#claiminterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t force) | 打开接å£ï¼Œå¹¶å£°æ˜Žç‹¬å 接å£ï¼Œå¿…须在数æ®ä¼ 输å‰æ‰§è¡Œã€‚ [更多...](_u_s_b.md#claiminterface) | +| [ReleaseInterface](_u_s_b.md#releaseinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid) | å…³é—接å£ï¼Œé‡Šæ”¾æŽ¥å£çš„å 用,在åœæ¢æ•°æ®ä¼ 输åŽæ‰§è¡Œã€‚ [更多...](_u_s_b.md#releaseinterface) | +| [SetInterface](_u_s_b.md#setinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t altIndex) | 设置指定接å£çš„备选设置,用于在具有相åŒID但ä¸åŒå¤‡ç”¨è®¾ç½®çš„两个接å£ä¹‹é—´è¿›è¡Œé€‰æ‹©ã€‚ [更多...](_u_s_b.md#setinterface) | +| [BulkTransferRead](_u_s_b.md#bulktransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行批é‡æ•°æ®è¯»å–,返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–,å¯ä»¥è®¾ç½®è¶…时时间。 [更多...](_u_s_b.md#bulktransferread) | +| [BulkTransferWrite](_u_s_b.md#bulktransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, const std::vector< uint8_t > &data) | 在给定端点上执行批é‡æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](_u_s_b.md#bulktransferwrite) | +| [ControlTransfer](_u_s_b.md#controltransfer) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) &ctrl, std::vector< uint8_t > &data) | 对æ¤è®¾å¤‡æ‰§è¡Œç«¯ç‚¹é›¶çš„æŽ§åˆ¶äº‹åŠ¡ï¼Œä¼ è¾“æ–¹å‘由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ï¼Œåˆ™ä¼ è¾“æ˜¯å†™å…¥ï¼Œå¦‚æžœæ˜¯USB_DIR_IN ï¼Œåˆ™ä¼ è¾“æ˜¯è¯»å–。 [更多...](_u_s_b.md#controltransfer) | +| [InterruptTransferRead](_u_s_b.md#interrupttransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ä¸æ–æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 [更多...](_u_s_b.md#interrupttransferread) | +| [InterruptTransferWrite](_u_s_b.md#interrupttransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ä¸æ–æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](_u_s_b.md#interrupttransferwrite) | +| [IsoTransferRead](_u_s_b.md#isotransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ç‰æ—¶æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 [更多...](_u_s_b.md#isotransferread) | +| [IsoTransferWrite](_u_s_b.md#isotransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ç‰æ—¶æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](_u_s_b.md#isotransferwrite) | +| [RequestQueue](_u_s_b.md#requestqueue) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const std::vector< uint8_t > &clientData, const std::vector< uint8_t > &buffer) | 将指定的端点进行异æ¥æ•°æ®å‘é€æˆ–者接收请求,数æ®ä¼ 输方å‘由端点方å‘决定。 [更多...](_u_s_b.md#requestqueue) | +| [RequestWait](_u_s_b.md#requestwait) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &clientData, std::vector< uint8_t > &buffer, int32_t timeout) | ç‰å¾…RequestQueue异æ¥è¯·æ±‚çš„æ“作结果。 [更多...](_u_s_b.md#requestwait) | +| [RequestCancel](_u_s_b.md#requestcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | å–消待处ç†çš„æ•°æ®è¯·æ±‚。 [更多...](_u_s_b.md#requestcancel) | +| [GetCurrentFunctions](_u_s_b.md#getcurrentfunctions) (int32_t &funcs) | 获å–从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ [更多...](_u_s_b.md#getcurrentfunctions) | +| [SetCurrentFunctions](_u_s_b.md#setcurrentfunctions) (int32_t funcs) | 设置从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ [更多...](_u_s_b.md#setcurrentfunctions) | +| [SetPortRole](_u_s_b.md#setportrole) (int32_t portId, int32_t powerRole, int32_t dataRole) | 设置port端å£çš„角色。 [更多...](_u_s_b.md#setportrole) | +| [QueryPort](_u_s_b.md#queryport) (int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode) | 查询port端å£çš„当å‰è®¾ç½®ã€‚ [更多...](_u_s_b.md#queryport) | +| [BindUsbdSubscriber](_u_s_b.md#bindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 绑定订阅者。 [更多...](_u_s_b.md#bindusbdsubscriber) | +| [UnbindUsbdSubscriber](_u_s_b.md#unbindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 解绑订阅者。 [更多...](_u_s_b.md#unbindusbdsubscriber) | +| [RegBulkCallback](_u_s_b.md#regbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const sptr< IRemoteObject > &cb) | 注册批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ [更多...](_u_s_b.md#regbulkcallback) | +| [UnRegBulkCallback](_u_s_b.md#unregbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 注销批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ [更多...](_u_s_b.md#unregbulkcallback) | +| [BulkRead](_u_s_b.md#bulkread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批é‡ä¼ 输异æ¥è¯»æ•°æ®ã€‚ [更多...](_u_s_b.md#bulkread) | +| [BulkWrite](_u_s_b.md#bulkwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批é‡ä¼ 输异æ¥å†™æ•°æ®ã€‚ [更多...](_u_s_b.md#bulkwrite) | +| [BulkCancel](_u_s_b.md#bulkcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 批é‡ä¼ 输异æ¥å–消接å£ï¼Œç”¨äºŽå–消当å‰æŽ¥å£çš„异æ¥æ‰¹é‡è¯»å†™æ“作。 [更多...](_u_s_b.md#bulkcancel) | + + +### é™æ€ Public æˆå‘˜å‡½æ•° + + | é™æ€ Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [GetInstance](_u_s_b.md#getinstance) () | 获å–实例。 | + + +## 详细æè¿° + +USB驱动客户端类。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md new file mode 100644 index 0000000000000000000000000000000000000000..57043338245c2dc4c9531bb08ba21e2abd987d9e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md @@ -0,0 +1,41 @@ +# OHOS::USB::UsbdSubscriber + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [DeviceEvent](_u_s_b.md#deviceevent) (const [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) &info)=0 | 设备事件。 [更多...](_u_s_b.md#deviceevent) | +| [PortChangedEvent](_u_s_b.md#portchangedevent) (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode)=0 | 端å£æ”¹å˜äº‹ä»¶ã€‚ [更多...](_u_s_b.md#portchangedevent) | +| [OnRemoteRequest](_u_s_b.md#onremoterequest) (uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override | 远程请求。 [更多...](_u_s_b.md#onremoterequest) | + + +### Private æˆå‘˜å‡½æ•° + + | Private æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OHOS::USB::UsbdSubscriber::ParserUsbInfo](_u_s_b.md#parserusbinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) | 解æžUSB设备信æ¯ã€‚ [更多...](_u_s_b.md#parserusbinfo) | +| [OHOS::USB::UsbdSubscriber::ParserPortInfo](_u_s_b.md#parserportinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) | 解æžUSB设备端å£ä¿¡æ¯ã€‚ [更多...](_u_s_b.md#parserportinfo) | + + +## **详细æè¿°** + +USB驱动订阅类。 + +**Since:** + +3.0 + +**Version:** + +1.0 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md b/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md new file mode 100644 index 0000000000000000000000000000000000000000..9b59c569ce179b8ea38d724027c1726aeeaf40c1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_omx_codec_buffer.md @@ -0,0 +1,194 @@ +# OmxCodecBuffer + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [bufferId](#bufferid) | bufferçš„ID。 | +| [size](#size) | 结构体大å°ã€‚ | +| [version](#version) | 组件版本信æ¯ã€‚ | +| [bufferType](#buffertype) | buffer类型。 | +| [buffer](#buffer) | ç¼–ç 或者解ç 使用的buffer。 | +| [bufferLen](#bufferlen) | buffer大å°ã€‚ | +| [allocLen](#alloclen) | 申请的buffer大å°ã€‚ | +| [filledLen](#filledlen) | å¡«å……çš„buffer大å°ã€‚ | +| [offset](#offset) | 有效数æ®ä»Žç¼“冲区开始的起始å移é‡ã€‚ | +| [fenceFd](#fencefd) | 该æ述符æ¥è‡ªbuffer消费者,Codecç‰å¾…æˆåŠŸåŽæ‰å¯ä»¥ä½¿ç”¨è¾“入或者输出buffer。 | +| [type](#type) | 共享内å˜ç±»åž‹ã€‚ | +| [pts](#pts) | 时间戳。 | +| [flag](#flag) | æ ‡å¿—ã€‚ | + + +## **详细æè¿°** + +Codec bufferä¿¡æ¯çš„定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### allocLen + + +``` +uint32_t OmxCodecBuffer::allocLen +``` + +**æ述:** + +申请的bufferå¤§å° + + +### buffer + + +``` +uint8_t* OmxCodecBuffer::buffer +``` + +**æ述:** + +ç¼–ç 或者解ç 使用的buffer + + +### bufferId + + +``` +uint32_t OmxCodecBuffer::bufferId +``` + +**æ述:** + +buffer ID + + +### bufferLen + + +``` +uint32_t OmxCodecBuffer::bufferLen +``` + +**æ述:** + +bufferå¤§å° + + +### bufferType + + +``` +enum CodecBufferType OmxCodecBuffer::bufferType +``` + +**æ述:** + +buffer类型 + + +### fenceFd + + +``` +int32_t OmxCodecBuffer::fenceFd +``` + +**æ述:** + +该æ述符æ¥è‡ªbuffer消费者,Codecç‰å¾…æˆåŠŸåŽæ‰å¯ä»¥ä½¿ç”¨è¾“入或者输出buffer + + +### filledLen + + +``` +uint32_t OmxCodecBuffer::filledLen +``` + +**æ述:** + +å¡«å……çš„bufferå¤§å° + + +### flag + + +``` +uint32_t OmxCodecBuffer::flag +``` + +**æ述:** + +æ ‡å¿— + + +### offset + + +``` +uint32_t OmxCodecBuffer::offset +``` + +**æ述:** + +有效数æ®ä»Žç¼“冲区开始的起始åç§»é‡ + + +### pts + + +``` +int64_t OmxCodecBuffer::pts +``` + +**æ述:** + +时间戳 + + +### size + + +``` +uint32_t OmxCodecBuffer::size +``` + +**æ述:** + +ç»“æž„ä½“å¤§å° + + +### type + + +``` +enum ShareMemTypes OmxCodecBuffer::type +``` + +**æ述:** + +共享内å˜ç±»åž‹ + + +### version + + +``` +union OMX_VERSIONTYPE OmxCodecBuffer::version +``` + +**æ述:** + +ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..9e2a1a49e5be8d62450f959d90cca14151476c7e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_pin_auth_types_8idl.md @@ -0,0 +1,45 @@ +# PinAuthTypes.idl + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [ExecutorInfo](_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_executor_info.md) | +| [TemplateInfo](_template_info.md) | å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](_template_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](_hdf_pin_auth.md#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](_hdf_face_auth.md#authtype) | +| [ExecutorRole](_hdf_pin_auth.md#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_face_auth.md#executorrole) | +| [ExecutorSecureLevel](_hdf_pin_auth.md#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](_hdf_face_auth.md#executorsecurelevel) | +| [CommandId](_hdf_pin_auth.md#commandid) : int { DEFAULT = 0 } | 枚举å£ä»¤è®¤è¯åŠŸèƒ½ç›¸å…³æ“作命令。 [更多...](_hdf_face_auth.md#commandid) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.pin_auth.v1_0 | å£ä»¤è®¤è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义å£ä»¤è®¤è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..179b60a2a0a0261d0e9d3c8afd29316395f440ef --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_power_types_8idl.md @@ -0,0 +1,42 @@ +# PowerTypes.idl + + +## **概述** + +**所属模å—:** + +[Power](power.md) + + +## **汇总** + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [PowerHdfCmd](power.md#powerhdfcmd) { CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND, CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电æºå‘½ä»¤çš„å‚数。 [更多...](power.md#powerhdfcmd) | +| [PowerHdfCallbackCmd](power.md#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电æºçŠ¶æ€å›žè°ƒçš„å‚数。 [更多...](power.md#powerhdfcallbackcmd) | +| [PowerHdfState](power.md#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电æºçš„状æ€ã€‚ [更多...](power.md#powerhdfstate) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电æºç®¡ç†æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +电æºç›¸å…³çš„æ•°æ®ç±»åž‹ã€‚ + +电æºç®¡ç†ä¸ä½¿ç”¨çš„æ•°æ®ç±»åž‹ï¼ŒåŒ…括命令å‚æ•°ã€å›žè°ƒå‚数和系统状æ€ã€‚ + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md b/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md new file mode 100644 index 0000000000000000000000000000000000000000..75be9d799ef7eb95d18e7484fcf739a32cf44408 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_present_timestamp.md @@ -0,0 +1,24 @@ +# PresentTimestamp + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [type](_display.md#type-33) | 上å±æ—¶é—´æˆ³ç±»åž‹ | +| [time](_display.md#time) | 类型对应的值 | + + +## **详细æè¿°** + +上å±æ—¶é—´æˆ³ç»“构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_property_object.md b/zh-cn/device-dev/reference/hdi-apis/_property_object.md new file mode 100644 index 0000000000000000000000000000000000000000..5520d0be40f9064035c5f374f32739ebe89798dc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_property_object.md @@ -0,0 +1,25 @@ +# PropertyObject + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [name](_display.md#name-12) [PROPERTY_NAME_LEN] | 属性å称 | +| [propId](_display.md#propid) | 属性ID | +| [value](_display.md#value-12) | 属性值 | + + +## **详细æè¿°** + +定义包å«å称ã€å±žæ€§ID和值的属性对象。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_range_value.md b/zh-cn/device-dev/reference/hdi-apis/_range_value.md new file mode 100644 index 0000000000000000000000000000000000000000..723b312f4a6bb0b12078398487a4ba026204d60d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_range_value.md @@ -0,0 +1,51 @@ +# RangeValue + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [min](#min) | 最å°å€¼ | +| [max](#max) | 最大值 | + + +## **详细æè¿°** + +å–值范围的定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### max + + +``` +int32_t RangeValue::max +``` + +**æ述:** + +最大值 + + +### min + + +``` +int32_t RangeValue::min +``` + +**æ述:** + +最å°å€¼ diff --git a/zh-cn/device-dev/reference/hdi-apis/_rect.md b/zh-cn/device-dev/reference/hdi-apis/_rect.md new file mode 100644 index 0000000000000000000000000000000000000000..c241e45e26485c1110984ac3a9bd24cfecb53422 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_rect.md @@ -0,0 +1,51 @@ +# Rect + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](#width) | 矩形的宽 | +| [height](#height) | 矩形的高 | + + +## **详细æè¿°** + +矩形的定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### height + + +``` +int32_t Rect::height +``` + +**æ述:** + +矩形的高 + + +### width + + +``` +int32_t Rect::width +``` + +**æ述:** + +矩形的宽 diff --git a/zh-cn/device-dev/reference/hdi-apis/_rectangle.md b/zh-cn/device-dev/reference/hdi-apis/_rectangle.md new file mode 100644 index 0000000000000000000000000000000000000000..374827e42143f6317681811d5d2c53c30469ced8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_rectangle.md @@ -0,0 +1,24 @@ +# Rectangle + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [rect](_display.md#rect) | 矩形区域 | +| [color](_display.md#color-33) | 矩形颜色 | + + +## **详细æè¿°** + +矩形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶çŸ©å½¢ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md b/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md new file mode 100644 index 0000000000000000000000000000000000000000..4fcebffea49a53a5907520898ee73d4e84f4b09e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_schedule_info.md @@ -0,0 +1,111 @@ +# ScheduleInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [scheduleId](#scheduleid) | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的执行器调度过程。 | +| [templateIds](#templateids) | 模版ID列表。 | +| [authType](#authtype) | 用户认è¯å‡æ®ç±»åž‹ã€‚ | +| [executorMatcher](#executormatcher) | 执行器匹é…器。 | +| [scheduleMode](#schedulemode) | 调度模å¼ï¼Œæ”¯æŒæ³¨å†Œã€è®¤è¯å’Œè¯†åˆ«æ¨¡å¼ã€‚ | +| [executors](#executors) | 执行器信æ¯åˆ—表。 | + + +## **详细æè¿°** + +调度信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### authType + + +``` +enum AuthType ScheduleInfo::authType +``` + +**æ述:** + +用户认è¯å‡æ®ç±»åž‹ã€‚ + + +### executors + + +``` +struct ExecutorInfo [] ScheduleInfo::executors +``` + +**æ述:** + +执行器信æ¯åˆ—表。 + + +### executorMatcher + + +``` +unsigned int ScheduleInfo::executorMatcher +``` + +**æ述:** + +执行器匹é…器。 + + +### scheduleId + + +``` +unsigned long ScheduleInfo::scheduleId +``` + +**æ述:** + +调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的执行器调度过程。 + + +### scheduleMode + + +``` +unsigned int ScheduleInfo::scheduleMode +``` + +**æ述:** + +调度模å¼ï¼Œæ”¯æŒæ³¨å†Œã€è®¤è¯å’Œè¯†åˆ«æ¨¡å¼ã€‚ + + +### templateIds + + +``` +unsigned long [] ScheduleInfo::templateIds +``` + +**æ述:** + +模版ID列表。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor.md b/zh-cn/device-dev/reference/hdi-apis/_sensor.md new file mode 100644 index 0000000000000000000000000000000000000000..8af61d4b6a4eab3cd53ef07e76ba0273ebe8d67c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sensor.md @@ -0,0 +1,326 @@ +# Sensor + + +## **汇总** + + +### 文件 + +| 文件 | æè¿° | +| -------- | -------- | +| [sensor_if.h](sensor__if_8h.md) | Sensor模å—对外通用的接å£å£°æ˜Žæ–‡ä»¶ï¼Œæ供获å–ä¼ æ„Ÿå™¨è®¾å¤‡ä¿¡æ¯ã€è®¢é˜…/å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€ 使能/åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ã€è®¾ç½®ä¼ 感器模å¼ã€è®¾ç½®ä¼ 感器精度,é‡ç¨‹ç‰å¯é€‰é…置接å£å®šä¹‰ã€‚ | +| [sensor_type.h](sensor__type_8h.md) | å®šä¹‰ä¼ æ„Ÿå™¨æ¨¡å—æ‰€ä½¿ç”¨çš„ä¼ æ„Ÿå™¨ç±»åž‹ï¼Œä¼ æ„Ÿå™¨ä¿¡æ¯ï¼Œä¼ 感器数æ®ç»“æž„ç‰æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + +| ç±» | æè¿° | +| -------- | -------- | +| [SensorInterface](_sensor_interface.md) | æä¾›sensor设备基本控制æ“作接å£ã€‚ [更多...](_sensor_interface.md) | +| [SensorInformation](_sensor_information.md) | å®šä¹‰ä¼ æ„Ÿå™¨åŸºæœ¬ä¿¡æ¯ã€‚ [更多...](_sensor_information.md) | +| [SensorEvents](_sensor_events.md) | ä¸ŠæŠ¥ä¼ æ„Ÿå™¨æ•°æ®ç»“构。 [更多...](_sensor_events.md) | + + +### å®å®šä¹‰ + +| å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [SENSOR_NAME_MAX_LEN](#sensornamemaxlen) 32 | Sensorå称的最大长度。 | +| [SENSOR_VERSION_MAX_LEN](#sensorversionmaxlen) 16 | Sensor版本å·çš„最大长度。 | + + +### 类型定义 + +| 类型定义 | æè¿° | +| -------- | -------- | +| ([RecordDataCallback](#recorddatacallback)) (const struct [SensorEvents](_sensor_events.md) \*) | ä¼ æ„Ÿå™¨ä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°çš„å®šä¹‰ï¼Œä¼ æ„Ÿå™¨æœåŠ¡ç”¨æˆ·åœ¨è®¢é˜…ä¼ æ„Ÿå™¨æ—¶ï¼Œ 需è¦æ³¨å†Œä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°ï¼Œä¼ 感器使能åŽï¼Œä¼ 感器æœåŠ¡ç”¨æˆ·å¯ä»¥æŽ¥å—åˆ°ä¼ æ„Ÿå™¨æ•°æ®ï¼Œè¯¦è§[SensorInterface](_sensor_interface.md)。 [更多...](#recorddatacallback) | + + +### 枚举 + +| 枚举 | æè¿° | +| -------- | -------- | +| [SensorStatus](#sensorstatus) { SENSOR_SUCCESS = 0, SENSOR_FAILURE = -1, SENSOR_NOT_SUPPORT = -2, SENSOR_INVALID_PARAM = -3, SENSOR_INVALID_SERVICE = -4, SENSOR_NULL_PTR = -5 } | å®šä¹‰ä¼ æ„Ÿå™¨æ¨¡å—返回值类型。 [更多...](#sensorstatus) | +| [SensorTypeTag](#sensortypetag) { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_ACCELEROMETER = 1, SENSOR_TYPE_GYROSCOPE = 2, SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3, SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, SENSOR_TYPE_AMBIENT_LIGHT = 5, SENSOR_TYPE_MAGNETIC_FIELD = 6, SENSOR_TYPE_CAPACITIVE = 7, SENSOR_TYPE_BAROMETER = 8, SENSOR_TYPE_TEMPERATURE = 9, SENSOR_TYPE_HALL = 10, SENSOR_TYPE_GESTURE = 11, SENSOR_TYPE_PROXIMITY = 12, SENSOR_TYPE_HUMIDITY = 13, SENSOR_TYPE_MEDICAL_BEGIN = 128, SENSOR_TYPE_MEDICAL_END = 160, SENSOR_TYPE_PHYSICAL_MAX = 255, SENSOR_TYPE_ORIENTATION = 256, SENSOR_TYPE_GRAVITY = 257, SENSOR_TYPE_LINEAR_ACCELERATION = 258, SENSOR_TYPE_ROTATION_VECTOR = 259, SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, SENSOR_TYPE_GAME_ROTATION_VECTOR = 262, SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, SENSOR_TYPE_SIGNIFICANT_MOTION = 264, SENSOR_TYPE_PEDOMETER_DETECTION = 265, SENSOR_TYPE_PEDOMETER = 266, SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, SENSOR_TYPE_HEART_RATE = 278, SENSOR_TYPE_DEVICE_ORIENTATION = 279, SENSOR_TYPE_WEAR_DETECTION = 280, SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, SENSOR_TYPE_MAX } | å®šä¹‰ä¼ æ„Ÿå™¨ç±»åž‹æ ‡è¯†ã€‚ [更多...](#sensortypetag) | +| [SensorAccuracyType](#sensoraccuracytype) { SENSOR_NO_ACCURACY = 0, SENSOR_LOW_ACCURACY = 1, SENSOR_MEDIUM_ACCURACY = 2, SENSOR_HIGH_ACCURACY = 3, SENSOR_MAX_ACCURACY } | ä¼ æ„Ÿå™¨çš„ç²¾åº¦ç±»åž‹ã€‚ [更多...](#sensoraccuracytype) | +| [SensorRangeType](#sensorrangetype) { SENSOR_RANGE_LEVEL1 = 0, SENSOR_RANGE_LEVEL2 = 1, SENSOR_RANGE_LEVEL3 = 2, SENSOR_RANGE_LEVEL_MAX } | ä¼ æ„Ÿå™¨çš„é‡ç¨‹çº§åˆ«ã€‚ [更多...](#sensorrangetype) | +| [SensorModeType](#sensormodetype) { SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3, SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | ä¼ æ„Ÿå™¨çš„å·¥ä½œæ¨¡å¼ã€‚ [更多...](#sensormodetype) | +| [SensorGroupType](#sensorgrouptype) { TRADITIONAL_SENSOR_TYPE = 0, MEDICAL_SENSOR_TYPE = 1, SENSOR_GROUP_TYPE_MAX } | æžšä¸¾ä¼ æ„Ÿå™¨çš„ç¡¬ä»¶æœåŠ¡ç»„。 [更多...](#sensorgrouptype) | + + +### 函数 + +| 函数 | æè¿° | +| -------- | -------- | +| [NewSensorInterfaceInstance](#newsensorinterfaceinstance) (void) | åˆ›å»ºä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ [更多...](#newsensorinterfaceinstance) | +| [FreeSensorInterfaceInstance](#freesensorinterfaceinstance) (void) | é‡Šæ”¾ä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ [更多...](#freesensorinterfaceinstance) | + + +## **详细æè¿°** + +ä¼ æ„Ÿå™¨è®¾å¤‡é©±åŠ¨å¯¹ä¼ æ„Ÿå™¨æœåŠ¡æ供通用的接å£èƒ½åŠ›ã€‚ + +模å—æä¾›ä¼ æ„Ÿå™¨æœåŠ¡å¯¹ä¼ 感器驱动访问统一接å£ï¼ŒæœåŠ¡èŽ·å–驱动对象或者代ç†åŽï¼Œ 通过其æ供的å„ç±»æ–¹æ³•ï¼Œä»¥ä¼ æ„Ÿå™¨id区分访问ä¸åŒç±»åž‹ä¼ 感器设备,实现获å–ä¼ æ„Ÿå™¨è®¾å¤‡ä¿¡æ¯ã€è®¢é˜…/å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€ 使能/åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ã€è®¾ç½®ä¼ 感器模å¼ã€è®¾ç½®ä¼ 感器精度ã€é‡ç¨‹ç‰å¯é€‰é…ç½®ç‰ã€‚ + +**Since:** + +2.2 + +**Version:** + +1.0 + + +## **å®å®šä¹‰è¯´æ˜Ž** + + +### SENSOR_NAME_MAX_LEN + + +``` +#define SENSOR_NAME_MAX_LEN 32 +``` + +**æ述:** + +Sensorå称的最大长度。 + + +### SENSOR_VERSION_MAX_LEN + + +``` +#define SENSOR_VERSION_MAX_LEN 16 +``` + +**æ述:** + +Sensor版本å·çš„最大长度。 + + +## **类型定义说明** + + +### RecordDataCallback + + +``` +typedef int32_t(* RecordDataCallback) (const struct SensorEvents *) +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°çš„å®šä¹‰ï¼Œä¼ æ„Ÿå™¨æœåŠ¡ç”¨æˆ·åœ¨è®¢é˜…ä¼ æ„Ÿå™¨æ—¶ï¼Œ 需è¦æ³¨å†Œä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°ï¼Œä¼ 感器使能åŽï¼Œä¼ 感器æœåŠ¡ç”¨æˆ·å¯ä»¥æŽ¥å—åˆ°ä¼ æ„Ÿå™¨æ•°æ®ï¼Œè¯¦è§[SensorInterface](_sensor_interface.md)。 + + +## **枚举类型说明** + + +### SensorAccuracyType + + +``` +enum SensorAccuracyType +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„ç²¾åº¦ç±»åž‹ã€‚ + +| 枚举值 | æè¿° | +| -------- | -------- | +| SENSOR_NO_ACCURACY | æ— ç²¾åº¦ç±»åž‹ã€‚ | +| SENSOR_LOW_ACCURACY | 低精度类型。 | +| SENSOR_MEDIUM_ACCURACY | ä¸ç‰ç²¾åº¦ç±»åž‹ã€‚ | +| SENSOR_HIGH_ACCURACY | 高精度类型。 | +| SENSOR_MAX_ACCURACY | 最大精度类型。 | + + +### SensorGroupType + + +``` +enum SensorGroupType +``` + +**æ述:** + +æžšä¸¾ä¼ æ„Ÿå™¨çš„ç¡¬ä»¶æœåŠ¡ç»„。 + +| 枚举值 | æè¿° | +| -------- | -------- | +| TRADITIONAL_SENSOR_TYPE | ä¼ ç»Ÿä¼ æ„Ÿå™¨ç±»åž‹ï¼Œä¼ æ„Ÿå™¨ID枚举值范围为128-160。 | +| MEDICAL_SENSOR_TYPE | åŒ»ç–—ä¼ æ„Ÿå™¨ç±»åž‹ï¼Œä¼ æ„Ÿå™¨ID枚举值范围ä¸åœ¨128-160之间。 | +| SENSOR_GROUP_TYPE_MAX | æœ€å¤§ä¼ æ„Ÿå™¨ç±»åž‹ã€‚ | + + +### SensorModeType + + +``` +enum SensorModeType +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„å·¥ä½œæ¨¡å¼ã€‚ + +| 枚举值 | æè¿° | +| -------- | -------- | +| SENSOR_MODE_DEFAULT | ä¼ æ„Ÿå™¨é»˜è®¤å·¥ä½œæ¨¡å¼çŠ¶æ€ã€‚ | +| SENSOR_MODE_REALTIME | ä¼ æ„Ÿå™¨å®žæ—¶å·¥ä½œæ¨¡å¼çŠ¶æ€ï¼Œä¸€ç»„æ•°æ®ä¸ŠæŠ¥ä¸€æ¬¡ã€‚ | +| SENSOR_MODE_ON_CHANGE | ä¼ æ„Ÿå™¨å®žæ—¶å·¥ä½œæ¨¡å¼çŠ¶æ€ï¼ŒçŠ¶æ€å˜æ›´ä¸ŠæŠ¥ä¸€æ¬¡ã€‚ | +| SENSOR_MODE_ONE_SHOT | ä¼ æ„Ÿå™¨å®žæ—¶å·¥ä½œæ¨¡å¼çŠ¶æ€ï¼Œåªä¸ŠæŠ¥ä¸€æ¬¡ã€‚ | +| SENSOR_MODE_FIFO_MODE | ä¼ æ„Ÿå™¨ç¼“å˜å·¥ä½œæ¨¡å¼çŠ¶æ€ï¼Œæ ¹æ®é…置的缓å˜å¤§å°ä¸ŠæŠ¥ã€‚ | +| SENSOR_MODE_MAX | ä¼ æ„Ÿå™¨æœ€å¤§ç±»åž‹æ ‡è¯†ã€‚ | + + +### SensorRangeType + + +``` +enum SensorRangeType +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„é‡ç¨‹çº§åˆ«ã€‚ + +| 枚举值 | æè¿° | +| -------- | -------- | +| SENSOR_RANGE_LEVEL1 | é‡ç¨‹çº§åˆ«1。 | +| SENSOR_RANGE_LEVEL2 | é‡ç¨‹çº§åˆ«2。 | +| SENSOR_RANGE_LEVEL3 | é‡ç¨‹çº§åˆ«3。 | +| SENSOR_RANGE_LEVEL_MAX | é‡ç¨‹æœ€å¤§çº§åˆ«ã€‚ | + + +### SensorStatus + + +``` +enum SensorStatus +``` + +**æ述:** + +å®šä¹‰ä¼ æ„Ÿå™¨æ¨¡å—返回值类型。 + +| 枚举值 | æè¿° | +| -------- | -------- | +| SENSOR_SUCCESS | ä¼ æ„Ÿå™¨æ‰§è¡ŒæˆåŠŸã€‚ | +| SENSOR_FAILURE | ä¼ æ„Ÿå™¨æ‰§è¡Œå¤±è´¥ã€‚ | +| SENSOR_NOT_SUPPORT | ä¼ æ„Ÿå™¨ä¸æ”¯æŒã€‚ | +| SENSOR_INVALID_PARAM | ä¼ æ„Ÿå™¨æ— æ•ˆå‚数。 | +| SENSOR_INVALID_SERVICE | ä¼ æ„Ÿå™¨æ— æ•ˆæœåŠ¡ã€‚ | +| SENSOR_NULL_PTR | ä¼ æ„Ÿå™¨ç©ºæŒ‡é’ˆã€‚ | + + +### SensorTypeTag + + +``` +enum SensorTypeTag +``` + +**æ述:** + +å®šä¹‰ä¼ æ„Ÿå™¨ç±»åž‹æ ‡è¯†ã€‚ + +| 枚举值 | æè¿° | +| -------- | -------- | +| SENSOR_TYPE_NONE | ç©ºä¼ æ„Ÿå™¨ç±»åž‹ï¼Œç”¨äºŽæµ‹è¯•ã€‚ | +| SENSOR_TYPE_ACCELEROMETER | åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_GYROSCOPE | é™€èžºä»ªä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_PHOTOPLETHYSMOGRAPH | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ELECTROCARDIOGRAPH | å¿ƒç”µä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_AMBIENT_LIGHT | çŽ¯å¢ƒå…‰ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_MAGNETIC_FIELD | 地ç£ä¼ 感器。 | +| SENSOR_TYPE_CAPACITIVE | ç”µå®¹ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_BAROMETER | æ°”åŽ‹è®¡ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_TEMPERATURE | æ¸©åº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_HALL | éœå°”ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_GESTURE | æ‰‹åŠ¿ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_PROXIMITY | æŽ¥è¿‘å…‰ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_HUMIDITY | æ¹¿åº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_MEDICAL_BEGIN | åŒ»ç–—ä¼ æ„Ÿå™¨ID枚举值范围的开始。 | +| SENSOR_TYPE_MEDICAL_END | åŒ»ç–—ä¼ æ„Ÿå™¨ID枚举值范围的结æŸã€‚ | +| SENSOR_TYPE_PHYSICAL_MAX | 物ç†ä¼ 感器最大类型。 | +| SENSOR_TYPE_ORIENTATION | æ–¹å‘ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_GRAVITY | é‡åŠ›ä¼ 感器。 | +| SENSOR_TYPE_LINEAR_ACCELERATION | çº¿æ€§åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ROTATION_VECTOR | 旋转矢é‡ä¼ 感器。 | +| SENSOR_TYPE_AMBIENT_TEMPERATURE | çŽ¯å¢ƒæ¸©åº¦ä¼ æ„Ÿå™¨ | +| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | æœªæ ¡å‡†ç£åœºä¼ 感器。 | +| SENSOR_TYPE_GAME_ROTATION_VECTOR | 游æˆæ—‹è½¬çŸ¢é‡ä¼ 感器。 | +| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | æœªæ ¡å‡†é™€èžºä»ªä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_SIGNIFICANT_MOTION | å¤§å¹…åº¦åŠ¨ä½œä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_PEDOMETER_DETECTION | 计æ¥å™¨æ£€æµ‹ä¼ 感器。 | +| SENSOR_TYPE_PEDOMETER | 计æ¥å™¨ä¼ 感器。 | +| SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | 地ç£æ—‹è½¬çŸ¢é‡ä¼ 感器。 | +| SENSOR_TYPE_HEART_RATE | å¿ƒçŽ‡ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_DEVICE_ORIENTATION | 设备方å‘ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_WEAR_DETECTION | ä½©æˆ´æ£€æµ‹ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | æœªæ ¡å‡†åŠ é€Ÿåº¦ä¼ æ„Ÿå™¨ã€‚ | +| SENSOR_TYPE_MAX | ä¼ æ„Ÿå™¨ç±»åž‹æœ€å¤§ä¸ªæ•°æ ‡è¯†ã€‚ | + + +## **函数说明** + + +### FreeSensorInterfaceInstance() + + +``` +int32_t FreeSensorInterfaceInstance (void ) +``` + +**æ述:** + +é‡Šæ”¾ä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ + +**返回:** + +如果释放实例æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果释放实例失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 + + +### NewSensorInterfaceInstance() + + +``` +const struct SensorInterface* NewSensorInterfaceInstance (void ) +``` + +**æ述:** + +åˆ›å»ºä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | è¡¨ç¤ºä¼ æ„Ÿå™¨ID。有关详细信æ¯ï¼Œè¯¦è§[SensorTypeTag](#sensortypetag)。 | +| cb | 表示è¦æ³¨å†Œçš„回调函数。有关详细信æ¯ï¼Œè¯¦è§[RecordDataCallback](#recorddatacallback)。 | + +**返回:** + +如果创建实例æˆåŠŸï¼Œåˆ™è¿”回éžé›¶å€¼ã€‚ + +如果创建实例失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md new file mode 100644 index 0000000000000000000000000000000000000000..51c8079517f1e6cb44ca20b482c9dfc357328a1e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sensor_events.md @@ -0,0 +1,122 @@ +# SensorEvents + + +## **概述** + +**所属模å—:** + +[Sensor](_sensor.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [sensorId](#sensorid) | ä¼ æ„Ÿå™¨çš„æ ‡è¯†å·ã€‚ | +| [version](#version) | ä¼ æ„Ÿå™¨ç®—æ³•ç‰ˆæœ¬å·ã€‚ | +| [timestamp](#timestamp) | ä¼ æ„Ÿå™¨æ•°æ®ç”Ÿæˆæ—¶é—´ã€‚ | +| [option](#option) | ä¼ æ„Ÿå™¨é‡ç¨‹ç²¾åº¦å¯é€‰é…置。 | +| [mode](#mode) | ä¼ æ„Ÿå™¨å·¥ä½œæ¨¡å¼ã€‚ | +| [data](#data) | ä¼ æ„Ÿå™¨æ•°æ®åœ°å€ã€‚ | +| [dataLen](#section0442151664211) | ä¼ æ„Ÿå™¨æ•°æ®é•¿åº¦ã€‚ | + + +## **详细æè¿°** + +ä¸ŠæŠ¥ä¼ æ„Ÿå™¨æ•°æ®ç»“构。 + +ä¸ŠæŠ¥ä¼ æ„Ÿå™¨è®¾å¤‡æ•°æ®äº‹ä»¶ä¿¡æ¯åŒ…æ‹¬ä¼ æ„Ÿå™¨çš„æ ‡è¯†å·ã€ä¼ 感器算法版本å·ã€ä¼ 感器数æ®ç”Ÿæˆæ—¶é—´ã€ä¼ 感器é‡ç¨‹ç²¾åº¦å¯é€‰é…ç½®ã€ä¼ 感器工作模å¼ã€ä¼ 感器数æ®åœ°å€ã€ä¼ 感器数æ®é•¿åº¦ã€‚ + +**Since:** + +2.2 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### data + + +``` +uint8_t* SensorEvents::data +``` + +**æ述:** + +ä¼ æ„Ÿå™¨æ•°æ®åœ°å€ã€‚ + + +### mode + + +``` +int32_t SensorEvents::mode +``` + +**æ述:** + +ä¼ æ„Ÿå™¨å·¥ä½œæ¨¡å¼ã€‚ + + +### option + + +``` +uint32_t SensorEvents::option +``` + +**æ述:** + +ä¼ æ„Ÿå™¨é‡ç¨‹ç²¾åº¦å¯é€‰é…置。 + + +### sensorId + + +``` +int32_t SensorEvents::sensorId +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„æ ‡è¯†å·ã€‚ + + +### timestamp + + +``` +int64_t SensorEvents::timestamp +``` + +**æ述:** + +ä¼ æ„Ÿå™¨æ•°æ®ç”Ÿæˆæ—¶é—´ã€‚ + + +### version + + +``` +int32_t SensorEvents::version +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ç®—æ³•ç‰ˆæœ¬å·ã€‚ + + +### h2dataLen + + +``` +int32_t SensorEvents::dataLen +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ç®—æ³•ç‰ˆæœ¬å·ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md new file mode 100644 index 0000000000000000000000000000000000000000..083c23aab81e737015db46d92d10380f6775cbdb --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sensor_information.md @@ -0,0 +1,148 @@ +# SensorInformation + + +## **概述** + +**所属模å—:** + +[Sensor](_sensor.md) + + +## **汇总** + + +### Public 属性 + +| Public 属性 | æè¿° | +| -------- | -------- | +| [sensorName](#sensorname) [[SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen)] | ä¼ æ„Ÿå™¨å称。 | +| [vendorName](#vendorname) [[SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen)] | ä¼ æ„Ÿå™¨è®¾å¤‡åŽ‚å•†ã€‚ | +| [firmwareVersion](#firmwareversion) [[SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen)] | ä¼ æ„Ÿå™¨å›ºä»¶ç‰ˆæœ¬å·ã€‚ | +| [hardwareVersion](#hardwareversion)<br/>[[SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen)] | ä¼ æ„Ÿå™¨ç¡¬ä»¶ç‰ˆæœ¬å·ã€‚ | +| [sensorTypeId](#sensortypeid) | ä¼ æ„Ÿå™¨ç±»åž‹ç¼–å·ã€‚ | +| [sensorId](#sensorid) | ä¼ æ„Ÿå™¨çš„æ ‡è¯†å·ï¼Œç”±ä¼ 感器驱动开å‘者定义。 | +| [maxRange](#maxrange) | ä¼ æ„Ÿå™¨çš„æœ€å¤§é‡ç¨‹ã€‚ | +| [accuracy](#accuracy) | ä¼ æ„Ÿå™¨çš„ç²¾åº¦ã€‚ | +| [power](#power) | ä¼ æ„Ÿå™¨çš„åŠŸè€—ã€‚ | + + +## **详细æè¿°** + +å®šä¹‰ä¼ æ„Ÿå™¨åŸºæœ¬ä¿¡æ¯ã€‚ + +ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ä¿¡æ¯åŒ…æ‹¬ä¼ æ„Ÿå™¨åå—ã€è®¾å¤‡åŽ‚商ã€å›ºä»¶ç‰ˆæœ¬å·ã€ç¡¬ä»¶ç‰ˆæœ¬å·ã€ä¼ 感器类型编å·ã€ä¼ æ„Ÿå™¨æ ‡è¯†ã€æœ€å¤§é‡ç¨‹ã€ç²¾åº¦ã€åŠŸè€—。 + +**Since:** + +2.2 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### accuracy + + +``` +float SensorInformation::accuracy +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„ç²¾åº¦ã€‚ + + +### firmwareVersion + + +``` +char SensorInformation::firmwareVersion[SENSOR_VERSION_MAX_LEN] +``` + +**æ述:** + +ä¼ æ„Ÿå™¨å›ºä»¶ç‰ˆæœ¬å·ã€‚ + + +### hardwareVersion + + +``` +char SensorInformation::hardwareVersion[SENSOR_VERSION_MAX_LEN] +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ç¡¬ä»¶ç‰ˆæœ¬å·ã€‚ + + +### maxRange + + +``` +float SensorInformation::maxRange +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„æœ€å¤§é‡ç¨‹ã€‚ + + +### sensorId + + +``` +int32_t SensorInformation::sensorId +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„æ ‡è¯†å·ï¼Œç”±ä¼ 感器驱动开å‘者定义。 + + +### sensorName + + +``` +char SensorInformation::sensorName[SENSOR_NAME_MAX_LEN] +``` + +**æ述:** + +ä¼ æ„Ÿå™¨å称。 + + +### sensorTypeId + + +``` +int32_t SensorInformation::sensorTypeId +``` + +**æ述:** + +ä¼ æ„Ÿå™¨ç±»åž‹ç¼–å·ï¼Œå”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ 感器设备类型,详è§[SensorTypeTag](_sensor.md#sensortypetag)。 + + +### vendorName + + +``` +char SensorInformation::vendorName[SENSOR_NAME_MAX_LEN] +``` + +**æ述:** + +ä¼ æ„Ÿå™¨è®¾å¤‡åŽ‚å•†ã€‚ + + +### power + + +``` +char SensorInformation::power +``` + +**æ述:** + +ä¼ æ„Ÿå™¨çš„åŠŸè€—ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md b/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..a6c64a9af33a52941b36c03b13843f780e9d518f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sensor_interface.md @@ -0,0 +1,234 @@ +# SensorInterface + + +## **概述** + +**所属模å—:** + +[Sensor](_sensor.md) + + +## **汇总** + + +### Public 属性 + +| Public 属性 | æè¿° | +| -------- | -------- | +| ( [GetAllSensors](#getallsensors) )([out] struct [SensorInformation](_sensor_information.md) \*\*sensorInfo, [out] int32_t \*count) | 获å–当å‰ç³»ç»Ÿä¸æ‰€æœ‰ç±»åž‹çš„ä¼ æ„Ÿå™¨ä¿¡æ¯ã€‚ [更多...](#getallsensors) | +| ( [Enable](#enable) )([in] int32_t sensorId) | æ ¹æ®ä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹æ ‡è¯†ä½¿èƒ½ä¼ æ„Ÿå™¨ä¿¡æ¯åˆ—表里å˜åœ¨çš„设备,åªæœ‰æ•°æ®è®¢é˜…è€…ä½¿èƒ½ä¼ æ„Ÿå™¨åŽï¼Œæ‰èƒ½èŽ·å–è®¢é˜…çš„ä¼ æ„Ÿå™¨æ•°æ®ã€‚ [更多...](#enable) | +| ( [Disable](#disable) )([in] int32_t sensorId) | æ ¹æ®ä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹æ ‡è¯†åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ä¿¡æ¯åˆ—表里å˜åœ¨çš„设备。 [更多...](#disable) | +| ( [SetBatch](#setbatch) )([in] int32_t sensorId, [in] int64_t samplingInterval, [in] int64_t reportInterval) | è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨çš„æ•°æ®é‡‡æ ·é—´éš”和数æ®ä¸ŠæŠ¥é—´éš”。 [更多...](#setbatch) | +| ( [SetMode](#setmode) )([in] int32_t sensorId, [in] int32_t mode) | è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨çš„æ•°æ®ä¸ŠæŠ¥æ¨¡å¼ï¼Œä¸åŒçš„工作模å¼ï¼Œä¸ŠæŠ¥æ•°æ®çš„æ–¹å¼ä¸åŒã€‚ [更多...](#setmode) | +| ( [SetOption](#setoption) )([in] int32_t sensorId, [in] uint32_t option) | è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨é‡ç¨‹ã€ç²¾åº¦ç‰å¯é€‰é…置。 [更多...](#setoption) | +| ( [Register](#register) )([in] int32_t groupId, [in] [RecordDataCallback](_sensor.md#recorddatacallback) cb) | è®¢é˜…è€…æ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ï¼Œç³»ç»Ÿä¼šå°†èŽ·å–åˆ°çš„ä¼ æ„Ÿå™¨æ•°æ®ä¸ŠæŠ¥ç»™è®¢é˜…者。 [更多...](#register) | +| ( [Unregister](#unregister) )([in] int32_t groupId, [in] [RecordDataCallback](_sensor.md#recorddatacallback) cb) | 订阅者å–æ¶ˆæ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ã€‚ [更多...](#unregister) | + + +## **详细æè¿°** + +æä¾›sensor设备基本控制æ“作接å£ã€‚ + +结构体æ供获å–ä¼ æ„Ÿå™¨è®¾å¤‡ä¿¡æ¯ã€è®¢é˜…/å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€ä½¿èƒ½/åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ã€è®¾ç½®ä¼ 感器模å¼ã€è®¾ç½®ä¼ 感器精度ã€é‡ç¨‹ç‰å¯é€‰é…置接å£å®šä¹‰ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### Disable + + +``` +int32_t(* SensorInterface::Disable) ([in] int32_t sensorId) +``` + +**æ述:** + +æ ¹æ®ä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹æ ‡è¯†åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ä¿¡æ¯åˆ—表里å˜åœ¨çš„设备。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | å”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹ï¼Œè¯¦è§[SensorTypeTag](_sensor.md#sensortypetag)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### Enable + + +``` +int32_t(* SensorInterface::Enable) ([in] int32_t sensorId) +``` + +**æ述:** + +æ ¹æ®ä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹æ ‡è¯†ä½¿èƒ½ä¼ æ„Ÿå™¨ä¿¡æ¯åˆ—表里å˜åœ¨çš„设备,åªæœ‰æ•°æ®è®¢é˜…è€…ä½¿èƒ½ä¼ æ„Ÿå™¨åŽï¼Œæ‰èƒ½èŽ·å–è®¢é˜…çš„ä¼ æ„Ÿå™¨æ•°æ®ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | å”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹ï¼Œè¯¦è§[SensorTypeTag](_sensor.md#sensortypetag)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### GetAllSensors + + +``` +int32_t(* SensorInterface::GetAllSensors) ([out] struct SensorInformation **sensorInfo,[out] int32_t *count) +``` + +**æ述:** + +获å–当å‰ç³»ç»Ÿä¸æ‰€æœ‰ç±»åž‹çš„ä¼ æ„Ÿå™¨ä¿¡æ¯ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorInfo | 输出系统ä¸æ³¨å†Œçš„æ‰€æœ‰ä¼ æ„Ÿå™¨ä¿¡æ¯ï¼Œä¸€ç§ç±»åž‹ä¼ 感器信æ¯åŒ…æ‹¬ä¼ æ„Ÿå™¨åå—ã€è®¾å¤‡åŽ‚商〠固件版本å·ã€ç¡¬ä»¶ç‰ˆæœ¬å·ã€ä¼ 感器类型编å·ã€ä¼ æ„Ÿå™¨æ ‡è¯†ã€æœ€å¤§é‡ç¨‹ã€ç²¾åº¦ã€åŠŸè€—,详è§[SensorInformation](_sensor_information.md)。 | +| count | 输出系统ä¸æ³¨å†Œçš„ä¼ æ„Ÿå™¨æ•°é‡ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### Register + + +``` +int32_t(* SensorInterface::Register) ([in] int32_t groupId,[in] RecordDataCallback cb) +``` + +**æ述:** + +è®¢é˜…è€…æ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ï¼Œç³»ç»Ÿä¼šå°†èŽ·å–åˆ°çš„ä¼ æ„Ÿå™¨æ•°æ®ä¸ŠæŠ¥ç»™è®¢é˜…者。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| groupId | ä¼ æ„Ÿå™¨ç»„ID。 sensorId枚举值范围为128-160ï¼Œè¡¨ç¤ºå·²è®¢é˜…åŒ»ç–—ä¼ æ„Ÿå™¨æœåŠ¡ï¼Œåªéœ€æˆåŠŸè®¢é˜…ä¸€æ¬¡ï¼Œæ— éœ€é‡å¤è®¢é˜…。 sensorId枚举值范围ä¸åœ¨128-160之间,这æ„味ç€ä¼ ç»Ÿä¼ æ„Ÿå™¨å·²è®¢é˜…ï¼Œåªéœ€æˆåŠŸè®¢é˜…ä¸€æ¬¡ï¼Œæ— éœ€é‡å¤è®¢é˜…。 | +| cb | è¦æ³¨å†Œçš„回调函数,详è§[RecordDataCallback](_sensor.md#recorddatacallback)。 | + +**返回:** + +如果注册回调函数æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果注册回调函数失败,则返回负数。 + + +### SetBatch + + +``` +int32_t(* SensorInterface::SetBatch) ([in] int32_t sensorId,[in] int64_t samplingInterval,[in] int64_t reportInterval) +``` + +**æ述:** + +è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨çš„æ•°æ®é‡‡æ ·é—´éš”和数æ®ä¸ŠæŠ¥é—´éš”。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | å”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹ï¼Œè¯¦è§[SensorTypeTag](_sensor.md#sensortypetag)。 | +| samplingInterval | è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨çš„æ•°æ®é‡‡æ ·é—´éš”,å•ä½çº³ç§’。 | +| reportInterval | è¡¨ç¤ºä¼ æ„Ÿå™¨æ•°æ®ä¸ŠæŠ¥é—´éš”,å•ä½çº³ç§’。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + + +### SetMode + + +``` +int32_t(* SensorInterface::SetMode) ([in] int32_t sensorId,[in] int32_t mode) +``` + +**æ述:** + +è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨çš„æ•°æ®ä¸ŠæŠ¥æ¨¡å¼ï¼Œä¸åŒçš„工作模å¼ï¼Œä¸ŠæŠ¥æ•°æ®çš„æ–¹å¼ä¸åŒã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | å”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹ï¼Œè¯¦è§[SensorTypeTag](_sensor.md#sensortypetag)。 | +| mode | ä¼ æ„Ÿå™¨çš„æ•°æ®ä¸ŠæŠ¥æ¨¡å¼ï¼Œè¯¦è§[SensorModeType](_sensor.md#sensormodetype)。 | + +**返回:** + +å¦‚æžœè®¾ç½®ä¼ æ„Ÿå™¨æ•°æ®æŠ¥å‘Šæ¨¡å¼æˆåŠŸï¼Œåˆ™è¿”回0。 + +å¦‚æžœè®¾ç½®ä¼ æ„Ÿå™¨æ•°æ®æŠ¥å‘Šæ¨¡å¼å¤±è´¥ï¼Œåˆ™è¿”回负数。 + + +### SetOption + + +``` +int32_t(* SensorInterface::SetOption) ([in] int32_t sensorId,[in] uint32_t option) +``` + +**æ述:** + +è®¾ç½®æŒ‡å®šä¼ æ„Ÿå™¨é‡ç¨‹ã€ç²¾åº¦ç‰å¯é€‰é…置。 + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| sensorId | å”¯ä¸€æ ‡è¯†ä¸€ä¸ªä¼ æ„Ÿå™¨è®¾å¤‡ç±»åž‹ï¼Œè¯¦è§[SensorTypeTag](_sensor.md#sensortypetag)。 | +| option | ä¼ æ„Ÿå™¨çš„é‡ç¨‹ã€ç²¾åº¦ç‰é…置。 | + +**返回:** + +如果设置å‚æ•°æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果设置å‚数失败,则返回负数。 + + +### Unregister + + +``` +int32_t(* SensorInterface::Unregister) ([in] int32_t groupId,[in] RecordDataCallback cb) +``` + +**æ述:** + +订阅者å–æ¶ˆæ³¨å†Œä¼ æ„Ÿå™¨æ•°æ®å›žè°ƒå‡½æ•°ã€‚ + +**å‚数:** + +| å称 | æè¿° | +| -------- | -------- | +| groupId | ä¼ æ„Ÿå™¨ç»„ID。 sensorId枚举值范围为128-160ï¼Œè¡¨ç¤ºå·²è®¢é˜…åŒ»ç–—ä¼ æ„Ÿå™¨æœåŠ¡ã€‚åªéœ€æˆåŠŸå–æ¶ˆè®¢é˜…ä¸€æ¬¡ï¼Œæ— éœ€é‡å¤å–消订阅。 sensorId枚举值范围ä¸åœ¨128-160之间,这æ„味ç€ä¼ ç»Ÿä¼ æ„Ÿå™¨å·²è®¢é˜…ã€‚å¹¶ä¸”æˆåŠŸå–消订阅。 | +| cb | è¦å–消注册的回调函数,详è§[RecordDataCallback](_sensor.md#recorddatacallback)。 | + +**返回:** + +如果å–消注册回调函数æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果å–消注册回调函数失败,则返回负数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_sta_info.md b/zh-cn/device-dev/reference/hdi-apis/_sta_info.md new file mode 100644 index 0000000000000000000000000000000000000000..605e17a4f2e3e629a11939553baf0b28cbf0561e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_sta_info.md @@ -0,0 +1,46 @@ +# StaInfo + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [mac](#mac) [[WIFI_MAC_ADDR_LENGTH](_w_l_a_n.md#ga27ea7645cf89c113dae48346e19a676f)] | STAçš„MACåœ°å€ | + + +## **详细æè¿°** + +æ述与AP连接的STA的基本信æ¯ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### mac + + +``` +unsigned char StaInfo::mac[WIFI_MAC_ADDR_LENGTH] +``` + +**æ述:** + +STAçš„MAC地å€ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md b/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md new file mode 100644 index 0000000000000000000000000000000000000000..22e7876400f9ef145757edc027231d5053b53499 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_support_buffer_type.md @@ -0,0 +1,77 @@ +# SupportBufferType + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [size](#size) | ç»“æž„ä½“å¤§å° | +| [version](#version) | ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ | +| [portIndex](#portindex) | 端å£ç´¢å¼• | +| [bufferTypes](#buffertypes) | 支æŒçš„所有Buffer类型 | + + +## **详细æè¿°** + +SupportBuffer类型定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### bufferTypes + + +``` +uint32_t SupportBufferType::bufferTypes +``` + +**æ述:** + +支æŒçš„所有Buffer类型 + + +### portIndex + + +``` +uint32_t SupportBufferType::portIndex +``` + +**æ述:** + +端å£ç´¢å¼• + + +### size + + +``` +uint32_t SupportBufferType::size +``` + +**æ述:** + +ç»“æž„ä½“å¤§å° + + +### version + + +``` +union OMX_VERSIONTYPE SupportBufferType::version +``` + +**æ述:** + +ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_template_info.md b/zh-cn/device-dev/reference/hdi-apis/_template_info.md new file mode 100644 index 0000000000000000000000000000000000000000..1d900c103ee8602a976a9364388b7a5ab2a0215f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_template_info.md @@ -0,0 +1,85 @@ +# TemplateInfo + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) | [HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [executorType](#executortype) | æ‰§è¡Œå™¨ç±»åž‹ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„算法类型进行分类。 | +| [freezingTime](#freezingtime) | 认è¯æ–¹å¼è¢«å†»ç»“的时间。 | +| [remainTimes](#remaintimes) | 认è¯æ–¹å¼è·ç¦»è¢«å†»ç»“çš„å¯å¤„ç†è®¤è¯è¯·æ±‚次数。 | +| [extraInfo](#extrainfo) | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | + + +## **详细æè¿°** + +å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### executorType + + +``` +unsigned int TemplateInfo::executorType +``` + +**æ述:** + +æ‰§è¡Œå™¨ç±»åž‹ï¼Œæ ¹æ®æ‰§è¡Œå™¨æ”¯æŒçš„算法类型进行分类。 + + +### extraInfo + + +``` +unsigned char [] TemplateInfo::extraInfo +``` + +**æ述:** + +其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ + + +### freezingTime + + +``` +int TemplateInfo::freezingTime +``` + +**æ述:** + +认è¯æ–¹å¼è¢«å†»ç»“的时间。 + + +### remainTimes + + +``` +int TemplateInfo::remainTimes +``` + +**æ述:** + +认è¯æ–¹å¼è·ç¦»è¢«å†»ç»“çš„å¯å¤„ç†è®¤è¯è¯·æ±‚次数。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..38c78e4de0d69fd3c775a820e311780c09d6482f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_thermal_types_8idl.md @@ -0,0 +1,41 @@ +# ThermalTypes.idl + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [ThermalZoneInfo](_thermal_zone_info.md) | 设备å‘çƒçš„ä¿¡æ¯ã€‚ [更多...](_thermal_zone_info.md) | +| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备å‘çƒçš„ä¿¡æ¯åˆ—表。 [更多...](_hdf_thermal_callback_info.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | 设备温度管ç†æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +设备å‘çƒçŠ¶æ€ç›¸å…³çš„æ•°æ®ç±»åž‹ã€‚ + +çƒç®¡ç†ä¸ä½¿ç”¨çš„æ•°æ®ç±»åž‹ï¼ŒåŒ…括设备å‘çƒçš„ä¿¡æ¯å’Œè®¾å¤‡å‘çƒçš„ä¿¡æ¯åˆ—表。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md b/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md new file mode 100644 index 0000000000000000000000000000000000000000..6c60b3463c1d06fa6efc51a5d5c0ba07fc3be39f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_thermal_zone_info.md @@ -0,0 +1,55 @@ +# ThermalZoneInfo + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [type](#type) | å‘çƒå™¨ä»¶çš„类型。 | +| [temp](#temp) | 器件的温度值。 | + + +## **详细æè¿°** + +设备å‘çƒçš„ä¿¡æ¯ã€‚ + +**Since:** + +3.1 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### temp + + +``` +int ThermalZoneInfo::temp +``` + +**æ述:** + +器件的温度值。 + + +### type + + +``` +String ThermalZoneInfo::type +``` + +**æ述:** + +å‘çƒå™¨ä»¶çš„类型。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b924caff85bec0cdd0dcac7a8eefa0fca8334854 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_types_8idl.md @@ -0,0 +1,49 @@ +# Types.idl + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [BatteryInfo](_battery_info.md) | ç”µæ± ç›¸å…³ä¿¡æ¯ã€‚ [更多...](_battery_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [BatteryHealthState](battery.md#batteryhealthstate) { BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE, BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | ç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ [更多...](battery.md#batteryhealthstate) | +| [BatteryChargeState](battery.md#batterychargestate) { CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL, CHARGE_STATE_RESERVED } | ç”µæ± çš„å……ç”µçŠ¶æ€ã€‚ [更多...](battery.md#batterychargestate) | +| [BatteryPluggedType](battery.md#batterypluggedtype) { PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS, PLUGGED_TYPE_BUTT } | ç”µæ± çš„å……ç”µè®¾å¤‡ç±»åž‹ã€‚ [更多...](battery.md#batterypluggedtype) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | ç”µæ± ä¿¡æ¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +ç”µæ± ä¿¡æ¯ç›¸å…³æ•°æ®ç±»åž‹ã€‚ + +ç”µæ± ä¿¡æ¯ä¸ä½¿ç”¨çš„æ•°æ®ç±»åž‹ï¼ŒåŒ…括å¥åº·çŠ¶æ€ã€å……电状æ€ã€å……ç”µè®¾å¤‡ç±»åž‹å’Œç”µæ± ä¿¡æ¯ç»“构。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md b/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md new file mode 100644 index 0000000000000000000000000000000000000000..3753bc9918d7c0294c6ac0a78719179b8c252740 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_u_s_b.md @@ -0,0 +1,1863 @@ +# USB + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [usb_info.h](usb__info_8h.md) | USB驱动订阅模å—使用的数æ®ç±»åž‹ã€‚ | +| [usbd_client.h](usbd__client_8h.md) | å£°æ˜Žæ ‡å‡†USB驱动接å£å‡½æ•°ã€‚ | +| [usbd_subscriber.h](usbd__subscriber_8h.md) | USB驱动订阅模å—。 | +| [usbd_type.h](usbd__type_8h.md) | USB驱动模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信æ¯ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | +| [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | USB设备信æ¯ç±»ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | +| [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | Usb驱动类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | +| [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | 订阅类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | +| [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | USB设备。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | +| [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | 管é“ä¿¡æ¯ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | +| [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | USBæŽ§åˆ¶ä¼ è¾“ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [USB_MAX_INTERFACES](#usb\_max\_interfaces) 32 | USB设备最大接å£æ•°é‡ã€‚ | + + +### é™æ€å¸¸é‡ + + | é™æ€å¸¸é‡ | æè¿° | +| -------- | -------- | +| [USB_ENDPOINT_DIR_MASK](#usb\_endpoint\_dir\_mask) 0x80 | 从地å€ä¸æå–USB Endpointæ–¹å‘çš„ä½æŽ©ç 。 | +| [USB_ENDPOINT_DIR_IN](#usb\_endpoint\_dir\_in) 0x80 | USB Endpoint从设备到主机的数æ®æ–¹å‘。 | +| [USB_ENDPOINT_DIR_OUT](#usb\_endpoint\_dir\_out) 0 | USB Endpoint从主机到设备的数æ®æ–¹å‘。 | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([UsbdRequestCallback](#usbdrequestcallback)) (uint8_t \*requestArg) | 请求回调函数。[更多...](#usbdrequestcallback) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [UsbdBulkCbCmd](#usbdbulkcbcmd) { CMD_USBD_BULK_CALLBACK_READ, CMD_USBD_BULK_CALLBACK_WRITE } | 批é‡å›žè°ƒå‘½ä»¤å—。 [更多...](#usbdbulkcbcmd) | +| [UsbdDeviceAction](#usbddeviceaction) { ACT_DEVUP = 0, ACT_DEVDOWN, ACT_UPDEVICE, ACT_DOWNDEVICE } | 主机端和设备端æ’拔事件。 [更多...](#usbddeviceaction) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [OHOS::USB::UsbInfo::setDevInfoStatus](#setdevinfostatus) (int32_t status) | 设置USB设备状æ€ã€‚ [更多...](#setdevinfostatus) | +| [OHOS::USB::UsbInfo::setDevInfoBusNum](#setdevinfobusnum) (int32_t busNum) | 设置USB总线编å·ã€‚ [更多...](#setdevinfobusnum) | +| [OHOS::USB::UsbInfo::setDevInfoDevNum](#setdevinfodevnum) (int32_t devNum) | 设置USB设备编å·ã€‚ [更多...](#setdevinfodevnum) | +| [OHOS::USB::UsbInfo::getDevInfoStatus](#getdevinfostatus) () const | 获å–USB设备状æ€ã€‚ [更多...](#getdevinfostatus) | +| [OHOS::USB::UsbInfo::getDevInfoBusNum](#getdevinfobusnum) () const | 获å–USB总线编å·ã€‚ [更多...](#getdevinfobusnum) | +| [OHOS::USB::UsbInfo::getDevInfoDevNum](#getdevinfodevnum) () const | 获å–USB设备编å·ã€‚ [更多...](#getdevinfodevnum) | +| [OHOS::USB::UsbdClient::GetInstance](#getinstance) () | 获å–实例。 [更多...](#getinstance) | +| [OHOS::USB::UsbdClient::OpenDevice](#opendevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | 打开设备,建立连接。 [更多...](#opendevice) | +| [OHOS::USB::UsbdClient::CloseDevice](#closedevice) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev) | å…³é—设备,释放与设备相关的所有系统资æºã€‚ [更多...](#closedevice) | +| [OHOS::USB::UsbdClient::GetDeviceDescriptor](#getdevicedescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获å–设备æ述符。 [更多...](#getdevicedescriptor) | +| [OHOS::USB::UsbdClient::GetStringDescriptor](#getstringdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | æ ¹æ®String ID获å–设备的å—符串æ述符。 [更多...](#getstringdescriptor) | +| [OHOS::USB::UsbdClient::GetConfigDescriptor](#getconfigdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t descId, std::vector< uint8_t > &descriptor) | æ ¹æ®config ID获å–设备的é…ç½®æ述符config。 [更多...](#getconfigdescriptor) | +| [OHOS::USB::UsbdClient::GetRawDescriptor](#getrawdescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &descriptor) | 获å–原始æ述符。 [更多...](#getrawdescriptor) | +| [OHOS::USB::UsbdClient::GetFileDescriptor](#getfiledescriptor) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, int32_t &fd) | 获å–文件æ述符。 [更多...](#getfiledescriptor) | +| [OHOS::USB::UsbdClient::SetConfig](#setconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t configIndex) | 设置当å‰çš„configä¿¡æ¯ã€‚ [更多...](#setconfig) | +| [OHOS::USB::UsbdClient::GetConfig](#getconfig) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t &configIndex) | 获å–当å‰çš„configä¿¡æ¯ã€‚ [更多...](#getconfig) | +| [OHOS::USB::UsbdClient::ClaimInterface](#claiminterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t force) | 打开接å£ï¼Œå¹¶å£°æ˜Žç‹¬å 接å£ï¼Œå¿…须在数æ®ä¼ 输å‰æ‰§è¡Œã€‚ [更多...](#claiminterface) | +| [OHOS::USB::UsbdClient::ReleaseInterface](#releaseinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid) | å…³é—接å£ï¼Œé‡Šæ”¾æŽ¥å£çš„å 用,在åœæ¢æ•°æ®ä¼ 输åŽæ‰§è¡Œã€‚ [更多...](#releaseinterface) | +| [OHOS::USB::UsbdClient::SetInterface](#setinterface) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, uint8_t interfaceid, uint8_t altIndex) | 设置指定接å£çš„备选设置,用于在具有相åŒID但ä¸åŒå¤‡ç”¨è®¾ç½®çš„两个接å£ä¹‹é—´è¿›è¡Œé€‰æ‹©ã€‚ [更多...](#setinterface) | +| [OHOS::USB::UsbdClient::BulkTransferRead](#bulktransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行批é‡æ•°æ®è¯»å–,返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–,å¯ä»¥è®¾ç½®è¶…时时间。 [更多...](#bulktransferread) | +| [OHOS::USB::UsbdClient::BulkTransferWrite](#bulktransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, const std::vector< uint8_t > &data) | 在给定端点上执行批é‡æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](#bulktransferwrite) | +| [OHOS::USB::UsbdClient::ControlTransfer](#controltransfer) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) &ctrl, std::vector< uint8_t > &data) | 对æ¤è®¾å¤‡æ‰§è¡Œç«¯ç‚¹é›¶çš„æŽ§åˆ¶äº‹åŠ¡ï¼Œä¼ è¾“æ–¹å‘由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ï¼Œåˆ™ä¼ è¾“æ˜¯å†™å…¥ï¼Œå¦‚æžœæ˜¯USB_DIR_IN ï¼Œåˆ™ä¼ è¾“æ˜¯è¯»å–。 [更多...](#controltransfer) | +| [OHOS::USB::UsbdClient::InterruptTransferRead](#interrupttransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ä¸æ–æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 [更多...](#interrupttransferread) | +| [OHOS::USB::UsbdClient::InterruptTransferWrite](#interrupttransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ä¸æ–æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](#interrupttransferwrite) | +| [OHOS::USB::UsbdClient::IsoTransferRead](#isotransferread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ç‰æ—¶æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 [更多...](#isotransferread) | +| [OHOS::USB::UsbdClient::IsoTransferWrite](#isotransferwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, int32_t timeout, std::vector< uint8_t > &data) | 在给定端点上执行ç‰æ—¶æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ [更多...](#isotransferwrite) | +| [OHOS::USB::UsbdClient::RequestQueue](#requestqueue) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const std::vector< uint8_t > &clientData, const std::vector< uint8_t > &buffer) | 将指定的端点进行异æ¥æ•°æ®å‘é€æˆ–者接收请求,数æ®ä¼ 输方å‘由端点方å‘决定。 [更多...](#requestqueue) | +| [OHOS::USB::UsbdClient::RequestWait](#requestwait) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, std::vector< uint8_t > &clientData, std::vector< uint8_t > &buffer, int32_t timeout) | ç‰å¾…RequestQueue异æ¥è¯·æ±‚çš„æ“作结果。 [更多...](#requestwait) | +| [OHOS::USB::UsbdClient::RequestCancel](#requestcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | å–消待处ç†çš„æ•°æ®è¯·æ±‚。 [更多...](#requestcancel) | +| [OHOS::USB::UsbdClient::GetCurrentFunctions](#getcurrentfunctions) (int32_t &funcs) | 获å–从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ [更多...](#getcurrentfunctions) | +| [OHOS::USB::UsbdClient::SetCurrentFunctions](#setcurrentfunctions) (int32_t funcs) | 设置从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ [更多...](#setcurrentfunctions) | +| [OHOS::USB::UsbdClient::SetPortRole](#setportrole) (int32_t portId, int32_t powerRole, int32_t dataRole) | 设置port端å£çš„角色。 [更多...](#setportrole) | +| [OHOS::USB::UsbdClient::QueryPort](#queryport) (int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode) | 查询port端å£çš„当å‰è®¾ç½®ã€‚ [更多...](#queryport) | +| [OHOS::USB::UsbdClient::BindUsbdSubscriber](#bindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 绑定订阅者。 [更多...](#bindusbdsubscriber) | +| [OHOS::USB::UsbdClient::UnbindUsbdSubscriber](#unbindusbdsubscriber) (const sptr< [UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) > &subscriber) | 解绑订阅者。 [更多...](#unbindusbdsubscriber) | +| [OHOS::USB::UsbdClient::RegBulkCallback](#regbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, const sptr< IRemoteObject > &cb) | 注册批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ [更多...](#regbulkcallback) | +| [OHOS::USB::UsbdClient::UnRegBulkCallback](#unregbulkcallback) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 注销批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ [更多...](#unregbulkcallback) | +| [OHOS::USB::UsbdClient::BulkRead](#bulkread) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批é‡ä¼ 输异æ¥è¯»æ•°æ®ã€‚ [更多...](#bulkread) | +| [OHOS::USB::UsbdClient::BulkWrite](#bulkwrite) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe, sptr< Ashmem > &ashmem) | 批é‡ä¼ 输异æ¥å†™æ•°æ®ã€‚ [更多...](#bulkwrite) | +| [OHOS::USB::UsbdClient::BulkCancel](#bulkcancel) (const [UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) &dev, const [UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) &pipe) | 批é‡ä¼ 输异æ¥å–消接å£ï¼Œç”¨äºŽå–消当å‰æŽ¥å£çš„异æ¥æ‰¹é‡è¯»å†™æ“作。 [更多...](#bulkcancel) | +| [OHOS::USB::UsbdSubscriber::DeviceEvent](#deviceevent) (const [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) &info)=0 | 设备事件。 [更多...](#deviceevent) | +| [OHOS::USB::UsbdSubscriber::PortChangedEvent](#portchangedevent) (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode)=0 | 端å£æ”¹å˜äº‹ä»¶ã€‚ [更多...](#portchangedevent) | +| [OHOS::USB::UsbdSubscriber::OnRemoteRequest](#onremoterequest) (uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override | 远程请求。 [更多...](#onremoterequest) | +| [OHOS::USB::UsbdSubscriber::ParserUsbInfo](#parserusbinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) | 解æžUSB设备信æ¯ã€‚ [更多...](#parserusbinfo) | +| [OHOS::USB::UsbdSubscriber::ParserPortInfo](#parserportinfo) (MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) | 解æžUSB设备端å£ä¿¡æ¯ã€‚ [更多...](#parserportinfo) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| [OHOS::USB::USBDeviceInfo::status](#status) | USBè®¾å¤‡çŠ¶æ€ | +| [OHOS::USB::USBDeviceInfo::busNum](#busnum-12) | USBæ€»çº¿ç¼–å· | +| [OHOS::USB::USBDeviceInfo::devNum](#devnum) | USBè®¾å¤‡ç¼–å· | +| [OHOS::USB::UsbDev::busNum](#busnum-22) | USBæ€»çº¿ç¼–å· | +| [OHOS::USB::UsbDev::devAddr](#devaddr) | USBè®¾å¤‡åœ°å€ | +| [OHOS::USB::UsbPipe::interfaceId](#interfaceid) | USB设备接å£ID | +| [OHOS::USB::UsbPipe::endpointId](#endpointid) | USB设备端点ID | +| [OHOS::USB::UsbCtrlTransfer::requestType](#requesttype) | 请求类型 | +| [OHOS::USB::UsbCtrlTransfer::requestCmd](#requestcmd) | è¯·æ±‚å‘½ä»¤å— | +| [OHOS::USB::UsbCtrlTransfer::value](#value) | 请求值 | +| [OHOS::USB::UsbCtrlTransfer::index](#index) | 索引 | +| [OHOS::USB::UsbCtrlTransfer::timeout](#timeout) | 超时时间 | +| [OHOS::USB::UsbInfo::devInfo](#devinfo ) | USBè®¾å¤‡ä¿¡æ¯ | + + +## **详细æè¿°** + +定义(USBï¼‰åŠŸèƒ½çš„æ ‡å‡†API接å£ã€‚ + +该模å—用于获å–æ述符ã€æŽ¥å£å¯¹è±¡ã€è¯·æ±‚对象和æ交请求的自定义数æ®ç±»åž‹å’Œå‡½æ•°ã€‚ + +**Since:** + +3.0 + +**Version:** + +1.0 + + +## **å®å®šä¹‰è¯´æ˜Ž** + + +### USB_MAX_INTERFACES + + +``` +#define USB_MAX_INTERFACES 32 +``` + +**æ述:** + +USB设备最大接å£æ•°é‡ + + +## **é™æ€å¸¸é‡è¯´æ˜Ž** + +### USB_ENDPOINT_DIR_MASK + +``` +static const int32_t USB_ENDPOINT_DIR_MASK = 0x80 +``` + +**æ述:** + +从地å€ä¸æå–USB Endpointæ–¹å‘çš„ä½æŽ©ç + + +### USB_ENDPOINT_DIR_IN + +``` +static const int32_t USB_ENDPOINT_DIR_IN = 0x80 +``` + +**æ述:** + +USB Endpoint从设备到主机的数æ®æ–¹å‘ + +### USB_ENDPOINT_DIR_OUT + +``` +static const int32_t USB_ENDPOINT_DIR_OUT = 0 +``` + +**æ述:** + +USB Endpoint从主机到设备的数æ®æ–¹å‘ + + +## **类型定义说明** + + +### UsbdRequestCallback + + +``` +typedef void(* UsbdRequestCallback) (uint8_t *requestArg) +``` + +**æ述:** + +请求回调函数 + + +## **枚举类型说明** + + +### UsbdBulkCbCmd + + +``` +enum UsbdBulkCbCmd +``` + +**æ述:** + +批é‡å›žè°ƒå‘½ä»¤å—。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CMD_USBD_BULK_CALLBACK_READ | 批é‡å›žè°ƒè¯»å– | +| CMD_USBD_BULK_CALLBACK_WRITE | 批é‡å›žè°ƒå†™å…¥ | + + +### UsbdDeviceAction + + +``` +enum UsbdDeviceAction +``` + +**æ述:** + +主机端和设备端æ’拔事件。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| ACT_DEVUP | 主机端接入设备 | +| ACT_DEVDOWN | 主机端拔出设备 | +| ACT_UPDEVICE | 设备连接 | +| ACT_DOWNDEVICE | 设备æ–å¼€ | + + +## **函数说明** + + +### BindUsbdSubscriber() + + +``` +int32_t OHOS::USB::UsbdClient::BindUsbdSubscriber (const sptr< UsbdSubscriber > & subscriber) +``` + +**æ述:** + +绑定订阅者。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| subscriber | 输入å‚数,订阅者信æ¯ï¼Œè¯¦è§[UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### BulkCancel() + + +``` +int32_t OHOS::USB::UsbdClient::BulkCancel (const UsbDev & dev, const UsbPipe & pipe ) +``` + +**æ述:** + +批é‡ä¼ 输异æ¥å–消接å£ï¼Œç”¨äºŽå–消当å‰æŽ¥å£çš„异æ¥æ‰¹é‡è¯»å†™æ“作。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### BulkRead() + + +``` +int32_t OHOS::USB::UsbdClient::BulkRead (const UsbDev & dev, const UsbPipe & pipe, sptr< Ashmem > & ashmem ) +``` + +**æ述:** + +批é‡ä¼ 输异æ¥è¯»æ•°æ®ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| ashmem | 输出å‚数,为共享内å˜ï¼Œç”¨äºŽå˜æ”¾è¯»å–çš„æ•°æ®ï¼Œè¯¦è§**Ashmem**。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### BulkTransferRead() + + +``` +int32_t OHOS::USB::UsbdClient::BulkTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行批é‡æ•°æ®è¯»å–,返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–,å¯ä»¥è®¾ç½®è¶…时时间。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输出å‚数,获å–写入的数æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### BulkTransferWrite() + + +``` +int32_t OHOS::USB::UsbdClient::BulkTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, const std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行批é‡æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输入å‚数,写入的数æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### BulkWrite() + + +``` +int32_t OHOS::USB::UsbdClient::BulkWrite (const UsbDev & dev, const UsbPipe & pipe, sptr< Ashmem > & ashmem ) +``` + +**æ述:** + +批é‡ä¼ 输异æ¥å†™æ•°æ®ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| ashmem | 输入å‚数,为共享内å˜ï¼Œç”¨äºŽå˜æ”¾éœ€è¦å†™å…¥çš„æ•°æ®ï¼Œè¯¦è§**Ashmem**。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### ClaimInterface() + + +``` +int32_t OHOS::USB::UsbdClient::ClaimInterface (const UsbDev & dev, uint8_t interfaceid, uint8_t force ) +``` + +**æ述:** + +打开接å£ï¼Œå¹¶å£°æ˜Žç‹¬å 接å£ï¼Œå¿…须在数æ®ä¼ 输å‰æ‰§è¡Œã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| interfaceid | 输入å‚数,USB设备interface ID。 | +| force | 输入å‚数,是å¦å¼ºåˆ¶: 1强制 0ä¸å¼ºåˆ¶ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### CloseDevice() + + +``` +int32_t OHOS::USB::UsbdClient::CloseDevice (const UsbDev & dev) +``` + +**æ述:** + +å…³é—设备,释放与设备相关的所有系统资æºã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### ControlTransfer() + + +``` +int32_t OHOS::USB::UsbdClient::ControlTransfer (const UsbDev & dev, const UsbCtrlTransfer & ctrl, std::vector< uint8_t > & data ) +``` + +**æ述:** + +对æ¤è®¾å¤‡æ‰§è¡Œç«¯ç‚¹é›¶çš„æŽ§åˆ¶äº‹åŠ¡ï¼Œä¼ è¾“æ–¹å‘由请求类型决定。 如果requestType& USB_ENDPOINT_DIR_MASK是USB_DIR_OUT ï¼Œåˆ™ä¼ è¾“æ˜¯å†™å…¥ï¼Œå¦‚æžœæ˜¯USB_DIR_IN ï¼Œåˆ™ä¼ è¾“æ˜¯è¯»å–。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| ctrl | 输入å‚数,USB设备控制数æ®åŒ…结构,详è§[UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md)。 | +| data | 输入/输出å‚数,读å–/写入的数æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### DeviceEvent() + + +``` +virtual int32_t OHOS::USB::UsbdSubscriber::DeviceEvent (const UsbInfo & info) +``` + +**æ述:** + +设备事件。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| [UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | 输入å‚数,USB设备信æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetConfig() + + +``` +int32_t OHOS::USB::UsbdClient::GetConfig (const UsbDev & dev, uint8_t & configIndex ) +``` + +**æ述:** + +获å–当å‰çš„configä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| configIndex | 输出å‚数,USB设备configä¿¡æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetConfigDescriptor() + + +``` +int32_t OHOS::USB::UsbdClient::GetConfigDescriptor (const UsbDev & dev, uint8_t descId, std::vector< uint8_t > & descriptor ) +``` + +**æ述:** + +æ ¹æ®config ID获å–设备的é…ç½®æ述符config。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| descId | 输入å‚数,USBçš„config ID。 | +| descriptor | 输出å‚数,获å–USB设备configä¿¡æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetCurrentFunctions() + + +``` +int32_t OHOS::USB::UsbdClient::GetCurrentFunctions (int32_t & funcs) +``` + +**æ述:** + +获å–从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输出å‚数,获å–当å‰è®¾å¤‡çš„function的值。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetDeviceDescriptor() + + +``` +int32_t OHOS::USB::UsbdClient::GetDeviceDescriptor (const UsbDev & dev, std::vector< uint8_t > & descriptor ) +``` + +**æ述:** + +获å–设备æ述符。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| descriptor | 输出å‚数,USB设备æ述符信æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### getDevInfoBusNum() + + +``` +int32_t OHOS::USB::UsbInfo::getDevInfoBusNum () const +``` + +**æ述:** + +获å–USB总线编å·ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输出å‚数,USB总线编å·ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### getDevInfoDevNum() + + +``` +int32_t OHOS::USB::UsbInfo::getDevInfoDevNum () const +``` + +**æ述:** + +获å–USB设备编å·ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输出å‚数,USB设备编å·ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### getDevInfoStatus() + + +``` +int32_t OHOS::USB::UsbInfo::getDevInfoStatus () const +``` + +**æ述:** + +获å–USB设备状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输出å‚数,设备状æ€ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetFileDescriptor() + + +``` +int32_t OHOS::USB::UsbdClient::GetFileDescriptor (const UsbDev & dev, int32_t & fd ) +``` + +**æ述:** + +获å–文件æ述符。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| fd | 输出å‚数,USB设备文件æ述符。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetRawDescriptor() + + +``` +int32_t OHOS::USB::UsbdClient::GetRawDescriptor (const UsbDev & dev, std::vector< uint8_t > & descriptor ) +``` + +**æ述:** + +获å–原始æ述符。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| descriptor | 输出å‚数,USB设备原始æ述符。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### GetStringDescriptor() + + +``` +int32_t OHOS::USB::UsbdClient::GetStringDescriptor (const UsbDev & dev, uint8_t descId, std::vector< uint8_t > & descriptor ) +``` + +**æ述:** + +æ ¹æ®String ID获å–设备的å—符串æ述符。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| descId | 输入å‚数,USBçš„string ID。 | +| descriptor | 输出å‚数,获å–USB设备configä¿¡æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### InterruptTransferRead() + + +``` +int32_t OHOS::USB::UsbdClient::InterruptTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行ä¸æ–æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输出å‚数,读å–çš„æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### InterruptTransferWrite() + + +``` +int32_t OHOS::USB::UsbdClient::InterruptTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行ä¸æ–æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输入å‚数,写入的数æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### IsoTransferRead() + + +``` +int32_t OHOS::USB::UsbdClient::IsoTransferRead (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行ç‰æ—¶æ•°æ®è¯»å–, 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®è¯»å–。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输出å‚数,读å–çš„æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### IsoTransferWrite() + + +``` +int32_t OHOS::USB::UsbdClient::IsoTransferWrite (const UsbDev & dev, const UsbPipe & pipe, int32_t timeout, std::vector< uint8_t > & data ) +``` + +**æ述:** + +在给定端点上执行ç‰æ—¶æ•°æ®å†™å…¥ï¼Œ 返回读å–çš„æ•°æ®å’Œé•¿åº¦ï¼Œç«¯ç‚¹æ–¹å‘必须为数æ®å†™å…¥ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| timeout | 输入å‚数,超时时间。 | +| data | 输入å‚数,读å–çš„æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### OnRemoteRequest() + + +``` +int32_t OHOS::USB::UsbdSubscriber::OnRemoteRequest (uint32_t code, MessageParcel & data, MessageParcel & reply, MessageOption & option ) +``` + +**æ述:** + +远程请求。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| code | 输入å‚数,命令å—。 | +| data | 输入å‚数,待解æžçš„æ•°æ®ã€‚ | +| reply | 输出å‚数,返回的数æ®ã€‚ | +| option | 输入å‚数,选项数æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### OpenDevice() + + +``` +int32_t OHOS::USB::UsbdClient::OpenDevice (const UsbDev & dev) +``` + +**æ述:** + +打开设备,建立连接。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### ParserUsbInfo() + + +``` +static int32_t OHOS::USB::UsbdSubscriber::ParserUsbInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, UsbInfo &info) +``` + +**æ述:** + +解æžUSB设备信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| data | 输入å‚数,命令å—。| +| reply | 输出å‚数,返回的数æ®ã€‚ | +| option | 输入å‚数,选项数æ®ã€‚| +| info | 输出å‚数,USB设备信æ¯ã€‚| + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + +### ParserPortInfo() + + +``` +static int32_t OHOS::USB::UsbdSubscriber::ParserPortInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option, PortInfo &info) +``` + +**æ述:** + +解æžUSB设备端å£ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| data | 输入å‚数,命令å—。| +| reply | 输出å‚数,返回的数æ®ã€‚ | +| option | 输入å‚数,选项数æ®ã€‚| +| info | 输出å‚数,USB设备端å£ä¿¡æ¯ã€‚| + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### PortChangedEvent() + + +``` +virtual int32_t OHOS::USB::UsbdSubscriber::PortChangedEvent (int32_t portId, int32_t powerRole, int32_t dataRole, int32_t mode ) +``` + +**æ述:** + +端å£æ”¹å˜äº‹ä»¶ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| portId | 输入å‚数,端å£ID。 | +| powerRole | 输入å‚数,电æºè§’色的值。 | +| dataRole | 输入å‚数,数æ®è§’色的值。 | +| mode | 输入å‚数,端å£æ¨¡å¼çš„值。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### QueryPort() + + +``` +int32_t OHOS::USB::UsbdClient::QueryPort (int32_t & portId, int32_t & powerRole, int32_t & dataRole, int32_t & mode ) +``` + +**æ述:** + +查询port端å£çš„当å‰è®¾ç½®ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| portId | 输出å‚数,port接å£ID。 | +| powerRole | 输出å‚数,电æºè§’色的值。 | +| dataRole | 输出å‚数,数æ®è§’色的值。 | +| mode | 输出å‚数,模å¼çš„值。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### RegBulkCallback() + + +``` +int32_t OHOS::USB::UsbdClient::RegBulkCallback (const UsbDev & dev, const UsbPipe & pipe, const sptr< IRemoteObject > & cb ) +``` + +**æ述:** + +注册批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| cb | 输入å‚数,回调函数对象的引用。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### ReleaseInterface() + + +``` +int32_t OHOS::USB::UsbdClient::ReleaseInterface (const UsbDev & dev, uint8_t interfaceid ) +``` + +**æ述:** + +å…³é—接å£ï¼Œé‡Šæ”¾æŽ¥å£çš„å 用,在åœæ¢æ•°æ®ä¼ 输åŽæ‰§è¡Œã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| interfaceid | 输入å‚数,USB设备interface ID。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### RequestCancel() + + +``` +int32_t OHOS::USB::UsbdClient::RequestCancel (const UsbDev & dev, const UsbPipe & pipe ) +``` + +**æ述:** + +å–消待处ç†çš„æ•°æ®è¯·æ±‚。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### RequestQueue() + + +``` +int32_t OHOS::USB::UsbdClient::RequestQueue (const UsbDev & dev, const UsbPipe & pipe, const std::vector< uint8_t > & clientData, const std::vector< uint8_t > & buffer ) +``` + +**æ述:** + +将指定的端点进行异æ¥æ•°æ®å‘é€æˆ–者接收请求,数æ®ä¼ 输方å‘由端点方å‘决定。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | +| clientData | 输入å‚数,用户数æ®ã€‚ | +| buffer | 输入å‚æ•°ï¼Œä¼ è¾“çš„æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### RequestWait() + + +``` +int32_t OHOS::USB::UsbdClient::RequestWait (const UsbDev & dev, std::vector< uint8_t > & clientData, std::vector< uint8_t > & buffer, int32_t timeout ) +``` + +**æ述:** + +ç‰å¾…RequestQueue异æ¥è¯·æ±‚çš„æ“作结果。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| clientData | 输入å‚数,用户数æ®ã€‚ | +| buffer | 输入å‚æ•°ï¼Œä¼ è¾“æ•°æ®ã€‚ | +| timeout | 输入å‚数,超时时间。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### SetConfig() + + +``` +int32_t OHOS::USB::UsbdClient::SetConfig (const UsbDev & dev, uint8_t configIndex ) +``` + +**æ述:** + +设置当å‰çš„configä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| configIndex | 输入å‚数,USB设备configä¿¡æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### SetCurrentFunctions() + + +``` +int32_t OHOS::USB::UsbdClient::SetCurrentFunctions (int32_t funcs) +``` + +**æ述:** + +设置从设备支æŒçš„功能列表(按ä½åŸŸè¡¨ç¤ºï¼‰ï¼ˆä»Žè®¾å¤‡ï¼‰ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| funcs | 输入å‚æ•°ï¼Œä¼ å…¥è®¾å¤‡æ”¯æŒçš„function的值。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### setDevInfoBusNum() + + +``` +void OHOS::USB::UsbInfo::setDevInfoBusNum (int32_t busNum) +``` + +**æ述:** + +设置USB总线编å·ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输入å‚数,USB总线编å·ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### setDevInfoDevNum() + + +``` +void OHOS::USB::UsbInfo::setDevInfoDevNum (int32_t devNum) +``` + +**æ述:** + +设置USB设备编å·ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输入å‚数,USB设备编å·ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### setDevInfoStatus() + + +``` +void OHOS::USB::UsbInfo::setDevInfoStatus (int32_t status) +``` + +**æ述:** + +设置USB设备状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| status | 输入å‚数,设备状æ€ã€‚ | + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### SetInterface() + + +``` +int32_t OHOS::USB::UsbdClient::SetInterface (const UsbDev & dev, uint8_t interfaceid, uint8_t altIndex ) +``` + +**æ述:** + +设置指定接å£çš„备选设置,用于在具有相åŒID但ä¸åŒå¤‡ç”¨è®¾ç½®çš„两个接å£ä¹‹é—´è¿›è¡Œé€‰æ‹©ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| interfaceid | 输入å‚数,USB设备interface ID。 | +| altIndex | 输入å‚数,interfaceçš„AlternateSettingä¿¡æ¯ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### SetPortRole() + + +``` +int32_t OHOS::USB::UsbdClient::SetPortRole (int32_t portId, int32_t powerRole, int32_t dataRole ) +``` + +**æ述:** + +设置port端å£çš„角色。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| portId | 输入å‚数,port接å£ID。 | +| powerRole | 输入å‚数,电æºè§’色的值。 | +| dataRole | 输入å‚数,数æ®è§’色的值。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### UnbindUsbdSubscriber() + + +``` +int32_t OHOS::USB::UsbdClient::UnbindUsbdSubscriber (const sptr< UsbdSubscriber > & subscriber) +``` + +**æ述:** + +解绑订阅者。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| subscriber | 输入å‚数,订阅者信æ¯ï¼Œè¯¦è§[UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +### UnRegBulkCallback() + + +``` +int32_t OHOS::USB::UsbdClient::UnRegBulkCallback (const UsbDev & dev, const UsbPipe & pipe ) +``` + +**æ述:** + +注销批é‡ä¼ 输异æ¥å›žè°ƒå‡½æ•°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| dev | 输入å‚数,USB设备地å€ä¿¡æ¯ï¼Œè¯¦è§[UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)。 | +| pipe | 输入å‚数,USB设备pipeä¿¡æ¯ï¼Œè¯¦è§[UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éžé›¶å€¼ 表示æ“作失败。 + +**Since:** + +3.0 + +**Version:** + +1.0 + +### GetInstance() + + +``` +OHOS::USB::UsbdClient::GetInstance() +``` + +**æ述:** + +获å–实例。 + +**Since:** + +3.0 + +**Version:** + +1.0 + + +## **å˜é‡è¯´æ˜Ž** + + +### busNum [1/2] + + +``` +int32_t OHOS::USB::USBDeviceInfo::busNum +``` + +**æ述:** + +USBæ€»çº¿ç¼–å· + + +### busNum [2/2] + + +``` +uint8_t OHOS::USB::UsbDev::busNum +``` + +**æ述:** + +USBæ€»çº¿ç¼–å· + + +### devAddr + + +``` +uint8_t OHOS::USB::UsbDev::devAddr +``` + +**æ述:** + +USBè®¾å¤‡åœ°å€ + +### devInfo + + +``` +OHOS::USB::UsbInfo devInfo +``` + +**æ述:** + +USBè®¾å¤‡ä¿¡æ¯ + + +### devNum + + +``` +int32_t OHOS::USB::USBDeviceInfo::devNum +``` + +**æ述:** + +USBè®¾å¤‡ç¼–å· + + +### endpointId + + +``` +uint8_t OHOS::USB::UsbPipe::endpointId +``` + +**æ述:** + +USB设备端点ID + + +### index + + +``` +int32_t OHOS::USB::UsbCtrlTransfer::index +``` + +**æ述:** + +索引 + + +### interfaceId + + +``` +uint8_t OHOS::USB::UsbPipe::interfaceId +``` + +**æ述:** + +USB设备接å£ID + + +### requestCmd + + +``` +int32_t OHOS::USB::UsbCtrlTransfer::requestCmd +``` + +**æ述:** + +è¯·æ±‚å‘½ä»¤å— + + +### requestType + + +``` +int32_t OHOS::USB::UsbCtrlTransfer::requestType +``` + +**æ述:** + +请求类型 + + +### status + + +``` +int32_t OHOS::USB::USBDeviceInfo::status +``` + +**æ述:** + +USBè®¾å¤‡çŠ¶æ€ + + +### timeout + + +``` +int32_t OHOS::USB::UsbCtrlTransfer::timeout +``` + +**æ述:** + +超时时间 + + +### value + + +``` +int32_t OHOS::USB::UsbCtrlTransfer::value +``` + +**æ述:** + +请求值 diff --git a/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md b/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md new file mode 100644 index 0000000000000000000000000000000000000000..99e2e88d43d8cea5b32d737fca929bc64e8772cb --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_use_buffer_type.md @@ -0,0 +1,77 @@ +# UseBufferType + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [size](#size) | ç»“æž„ä½“å¤§å° | +| [version](#version) | ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ | +| [portIndex](#portindex) | 端å£ç´¢å¼• | +| [bufferType](#buffertype) | Buffer类型 | + + +## **详细æè¿°** + +UseBuffer类型定义。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### bufferType + + +``` +uint32_t UseBufferType::bufferType +``` + +**æ述:** + +Buffer类型 + + +### portIndex + + +``` +uint32_t UseBufferType::portIndex +``` + +**æ述:** + +端å£ç´¢å¼• + + +### size + + +``` +uint32_t UseBufferType::size +``` + +**æ述:** + +ç»“æž„ä½“å¤§å° + + +### version + + +``` +union OMX_VERSIONTYPE UseBufferType::version +``` + +**æ述:** + +ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ diff --git a/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md b/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..fe896715602f302e112f2b7ce8a6965bc4a6b264 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_user_auth_types_8idl.md @@ -0,0 +1,54 @@ +# UserAuthTypes.idl + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [ExecutorRegisterInfo](_executor_register_info.md) | 执行器注册信æ¯ã€‚ [更多...](_executor_register_info.md) | +| [ExecutorInfo](_executor_info.md) | 执行器信æ¯ã€‚ [更多...](_executor_info.md) | +| [ScheduleInfo](_schedule_info.md) | 调度信æ¯ã€‚ [更多...](_schedule_info.md) | +| [AuthSolution](_auth_solution.md) | 认è¯æ–¹æ¡ˆã€‚ [更多...](_auth_solution.md) | +| [ExecutorSendMsg](_executor_send_msg.md) | 执行器å‘é€çš„消æ¯ã€‚ [更多...](_executor_send_msg.md) | +| [AuthResultInfo](_auth_result_info.md) | 用户身份认è¯ç»“果信æ¯ã€‚ [更多...](_auth_result_info.md) | +| [IdentifyResultInfo](_identify_result_info.md) | 用户身份识别结果信æ¯ã€‚ [更多...](_identify_result_info.md) | +| [EnrollParam](_enroll_param.md) | 注册认è¯å‡æ®å‚数。 [更多...](_enroll_param.md) | +| [CredentialInfo](_credential_info.md) | 认è¯å‡æ®ä¿¡æ¯ã€‚ [更多...](_credential_info.md) | +| [EnrolledInfo](_enrolled_info.md) | 注册信æ¯ã€‚ [更多...](_enrolled_info.md) | +| [EnrollResultInfo](_enroll_resultinfo.md) | 录入结果信æ¯ã€‚[更多...](_enroll_resultinfo.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AuthType](_hdf_user_auth.md#authtype) : int { PIN = 1, FACE = 2, FINGERPRINT = 4, ALL = 0 } | 枚举用户认è¯å‡æ®ç±»åž‹ã€‚ [更多...](_hdf_user_auth.md#authtype) | +| [ExecutorRole](_hdf_user_auth.md#executorrole) : int { COLLECTOR = 1, VERIFIER = 2, ALL_IN_ONE = 3 } | 枚举执行器角色。 [更多...](_hdf_user_auth.md#executorrole) | +| [ExecutorSecureLevel](_hdf_user_auth.md#executorsecurelevel) : int { ESL0 = 0, ESL1 = 1, ESL2 = 2, ESL3 = 3 } | 枚举执行器安全ç‰çº§ã€‚ [更多...](_hdf_user_auth.md#executorsecurelevel) | +| [PinSubType](_hdf_user_auth.md#pinsubtype) : int { PIN\_SIX = 10000, PIN\_NUMBER = 10001, PIN\_MIX = 10002 } | å£ä»¤è®¤è¯å类型。 [更多...](_hdf_user_auth.md#pinsubtype) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.user_auth.v1_0 | 用户认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义用户认è¯é©±åŠ¨çš„枚举类和数æ®ç»“构。 + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md b/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md new file mode 100644 index 0000000000000000000000000000000000000000..126685bf071258a5a15d65dc8804d274f1a55325 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_user_executor_info.md @@ -0,0 +1,59 @@ +# ExecutorInfo + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| executorIndex | 用户认è¯æ¡†æž¶çš„执行器索引。 | +| info | 执行器注册信æ¯ã€‚ | + + +## **详细æè¿°** + +执行器信æ¯ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### executorIndex + + +``` +unsigned long ExecutorInfo::executorIndex +``` + +**æ述:** + +用户认è¯æ¡†æž¶çš„执行器索引。 + + +### info + + +``` +struct ExecutorRegisterInfo ExecutorInfo::info +``` + +**æ述:** + +执行器注册信æ¯[ExecutorRegisterInfo](_executor_register_info.md)。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md b/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md new file mode 100644 index 0000000000000000000000000000000000000000..dc697ac80a3a92a5e11de4a8454af11cf5bc5a5b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_verify_alloc_info.md @@ -0,0 +1,26 @@ +# VerifyAllocInfo + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [width](_display.md#width-77) | 分é…内å˜çš„宽度 | +| [height](_display.md#height-77) | 分é…内å˜çš„高度 | +| [usage](_display.md#usage-22) | 内å˜çš„用处 | +| [format](_display.md#format-22) | 分é…内å˜çš„åƒç´ æ ¼å¼ | + + +## **详细æè¿°** + +用于验è¯å†…å˜åˆ†é…ä¿¡æ¯çš„结构体定义。 diff --git a/zh-cn/device-dev/reference/hdi-apis/_vibrator.md b/zh-cn/device-dev/reference/hdi-apis/_vibrator.md new file mode 100644 index 0000000000000000000000000000000000000000..b3d4c3a0a251d34fd3722591f477e63b3f86f38e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_vibrator.md @@ -0,0 +1,171 @@ +# Vibrator + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [vibrator_if.h](vibrator__if_8h.md) | 定义马达数æ®ç»“构,包括马达模å¼å’Œæ•ˆæžœæŒ¯åŠ¨ã€‚ | +| [vibrator_type.h](vibrator__type_8h.md) | 定义马达数æ®ç»“构,包括马达模å¼å’Œæ•ˆæžœæŒ¯åŠ¨ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [VibratorInterface](_vibrator_interface.md) | æä¾›Vibrator设备基本控制æ“作接å£ã€‚[更多...](_vibrator_interface.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [VibratorMode](#vibratormode) { VIBRATOR_MODE_ONCE = 0, VIBRATOR_MODE_PRESET = 1, VIBRATOR_MODE_BUTT } | 枚举马达振动模å¼ã€‚ [更多...](#vibratormode) | +| [VibratorStatus](#vibratorstatus) { VIBRATOR_SUCCESS = 0, VIBRATOR_NOT_PERIOD = -1, VIBRATOR_NOT_INTENSITY = -2, VIBRATOR_NOT_FREQUENCY= -3} | 枚举马达振动模å¼ã€‚[更多...](#vibratorstatus) | +| [VibratorInfo](#vibratorinfo) { isSupportIntensity, isSupportFrequency, intensityMaxValue, intensityMinValue, frequencyMaxValue, frequencyMinValue} | 定义马达å‚数。[更多...](#vibratorinfo) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [NewVibratorInterfaceInstance](#newvibratorinterfaceinstance) (void) | 创建一个VibratorInterface实例。 [更多...](#newvibratorinterfaceinstance) | +| [FreeVibratorInterfaceInstance](#freevibratorinterfaceinstance) (void) | 释放VibratorInterface实例以åŠç›¸å…³èµ„æºã€‚ [更多...](#freevibratorinterfaceinstance) | + + +## **详细æè¿°** + +马达驱动对马达æœåŠ¡æ供通用的接å£èƒ½åŠ›ã€‚ + +æœåŠ¡èŽ·å–驱动对象或者代ç†åŽï¼Œé©¬è¾¾æœåŠ¡å¯åŠ¨æˆ–åœæ¢æŒ¯åŠ¨ã€‚ 通过驱动程åºå¯¹è±¡æˆ–代ç†æ供使用功能。 + +**Since:** + +2.2 + +**版本** + +1.0: + + +## **枚举类型说明** + + +### VibratorMode + + +``` +enum VibratorMode +``` + +**æ述:** + +枚举马达振动模å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| VIBRATOR_MODE_ONCE | 表示给定æŒç»æ—¶é—´å†…的一次性振动。 | +| VIBRATOR_MODE_PRESET | 表示具有预置效果的周期性振动。 | +| VIBRATOR_MODE_BUTT | 表示效果模å¼æ— 效。 | + + +### VibratorStatus + + +``` +enum VibratorStatus +``` + +**æ述:** + +枚举马达振动模å¼ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| VIBRATOR_SUCCESS | æ“作æˆåŠŸã€‚ | +| VIBRATOR_NOT_PERIOD | ä¸æ”¯æŒæŒ¯åŠ¨å‘¨æœŸè®¾ç½®ã€‚ | +| VIBRATOR_NOT_INTENSITY | ä¸æ”¯æŒæŒ¯å¹…设置。 | +| VIBRATOR_NOT_FREQUENCY | ä¸æ”¯æŒé¢‘率设置。 | + + +### VibratorInfo + + +``` +enum VibratorInfo +``` + +**æ述:** + +定义马达å‚数。 + +å‚数包括设置马达振幅和频率以åŠæŒ¯å¹…和频率的范围。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| isSupportIntensity | 设置马达振幅。1表示支æŒï¼Œ0表示ä¸æ”¯æŒã€‚ | +| isSupportFrequency | 设置马达频率。1表示支æŒï¼Œ0表示ä¸æ”¯æŒã€‚ | +| intensityMaxValue | 最大振幅。 | +| intensityMinValue | 最å°æŒ¯å¹…。 | +| frequencyMaxValue | 最大频率。 | +| frequencyMinValue | 最å°é¢‘率。 | + + +## **函数说明** + + +### FreeVibratorInterfaceInstance() + + +``` +int32_t FreeVibratorInterfaceInstance (void ) +``` + +**æ述:** + +释放VibratorInterface实例以åŠç›¸å…³èµ„æºã€‚ + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 + + +### NewVibratorInterfaceInstance() + + +``` +const struct VibratorInterface* NewVibratorInterfaceInstance (void ) +``` + +**æ述:** + +创建一个VibratorInterface实例。 + +获的马达接å£å®žä¾‹å¯ç”¨äºŽæŽ§åˆ¶é©¬è¾¾æŒ‰ç…§é…置进行振动。 + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md b/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..3812f340bae039c6c2d64f9cb25ffa59bab7b3b8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_vibrator_interface.md @@ -0,0 +1,208 @@ +# VibratorInterface + + +## **概述** + +**所属模å—:** + +[Vibrator](_vibrator.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| ( [StartOnce](#startonce) )([in] uint32_t duration) | 控制马达以执行给定æŒç»æ—¶é—´çš„一次性振动。 [更多...](#startonce) | +| ( [Start](#start) )([in] const char \*effectType) | 控制马达以预置效果执行周期性振动。 [更多...](#start) | +| ( [Stop](#stop) )([in] enum [VibratorMode](_vibrator.md#vibratormode) mode) | åœæ¢é©¬è¾¾æŒ¯åŠ¨ã€‚ [更多...](#stop) | +| ( [GetVibratorInfo](#getvibratorinfo))([out] struct VibratorInfo \*\*vibratorInfo) | 获å–有关系统ä¸æ”¯æŒè®¾ç½®æŒ¯å¹…和频率的所有马达信æ¯ã€‚[更多...](#getvibratorinfo) | +| ( [EnableVibratorModulation](#enablevibratormodulation))(uint32_t duration, int32_t intensity, int32_t frequency) | æ ¹æ®ä¼ 入的振动效果å¯åŠ¨é©¬è¾¾ã€‚ [更多...](#enablevibratormodulation) | + + +## **详细æè¿°** + +æä¾›Vibrator设备基本控制æ“作接å£ã€‚ + +æ“作包括马达模å¼å’Œæ•ˆæžœæŒ¯åŠ¨ã€åœæ¢é©¬è¾¾æŒ¯åŠ¨ã€‚ + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### Start + + +``` +int32_t(*VibratorInterface::Start) ([in] const char *effectType) +``` + +**æ述:** + +控制马达以预置效果执行周期性振动。 + +å•æ¬¡æŒ¯åŠ¨ä¸Žå‘¨æœŸæŒ¯åŠ¨ç›¸äº’排斥。在执行一次性振动之å‰ï¼Œéœ€é€€å‡ºå‘¨æœŸæ€§æŒ¯åŠ¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| effectType | 指å‘指示预置效果类型的指针。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 + + +### StartOnce + + +``` +int32_t(*VibratorInterface::StartOnce) ([in] uint32_t duration) +``` + +**æ述:** + +控制马达以执行给定æŒç»æ—¶é—´çš„一次性振动。 + +å•æ¬¡æŒ¯åŠ¨ä¸Žå‘¨æœŸæŒ¯åŠ¨ç›¸äº’排斥。在执行一次性振动之å‰ï¼Œéœ€é€€å‡ºå‘¨æœŸæ€§æŒ¯åŠ¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| duration | 指示一次性振动的æŒç»æ—¶é—´ï¼Œä»¥æ¯«ç§’为å•ä½ã€‚ | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 + + +### Stop + + +``` +int32_t(*VibratorInterface::Stop) ([in] enum VibratorMode mode) +``` + +**æ述:** + +åœæ¢é©¬è¾¾æŒ¯åŠ¨ã€‚ + +马达å¯åŠ¨å‰ï¼Œå¿…须在任何模å¼ä¸‹åœæ¢æŒ¯åŠ¨ã€‚æ¤åŠŸèƒ½ç”¨åœ¨æŒ¯åŠ¨è¿‡ç¨‹ä¹‹åŽã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| mode | 指示振动模å¼ï¼Œå¯ä»¥æ˜¯ä¸€æ¬¡æ€§æˆ–周期性的,详è§[VibratorMode](_vibrator.md#vibratormode)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +2.2 + +**Version:** + +1.0 + + +### GetVibratorInfo + + +``` +int32_t (*VibratorInterface::GetVibratorInfo)([out] struct VibratorInfo **vibratorInfo) +``` + +**æ述:** + +获å–有关系统ä¸æ”¯æŒè®¾ç½®æŒ¯å¹…和频率的所有马达信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| vibratorInfo | 表示指å‘马达信æ¯çš„æŒ‡é’ˆï¼Œè¯¦è§ [VibratorInfo](_vibrator.md#vibratorinfo)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +3.2 + +**Version:** + +1.1 + + +### EnableVibratorModulation + + +``` +int32_t (*VibratorInterface::EnableVibratorModulation)(uint32_t duration, int32_t intensity, int32_t frequency); +``` + +**æ述:** + +æ ¹æ®ä¼ 入的振动效果å¯åŠ¨é©¬è¾¾ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| duration | 表示马达振动的æŒç»æ—¶é—´ï¼Œä»¥æ¯«ç§’为å•ä½ã€‚ | +| intensity | 表示振动周期内的马达振幅。 | +| frequency | 表示振动周期内的马达频率。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果ä¸æ”¯æŒæŒ¯åŠ¨å‘¨æœŸè®¾ç½®ï¼Œåˆ™è¿”回-1。 + +如果ä¸æ”¯æŒæŒ¯å¹…设置,则返回-2。 + +如果ä¸æ”¯æŒé¢‘率设置,则返回-3。 + + +**Since:** + + +3.2 + + +**Version:** + + +1.1 diff --git a/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md new file mode 100644 index 0000000000000000000000000000000000000000..0b3aea7ea7efe0a9d32a357d6432cc438d455b36 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_video_port_cap.md @@ -0,0 +1,116 @@ +# VideoPortCap + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [minSize](#minsize) | 支æŒçš„最å°åˆ†è¾¨çŽ‡ | +| [maxSize](#maxsize) | 支æŒçš„最大分辨率 | +| [whAlignment](#whalignment) | 宽高对é½å€¼ | +| [blockCount](#blockcount) | 支æŒçš„å—æ•°é‡èŒƒå›´ | +| [blocksPerSecond](#blockspersecond) | æ¯ç§’å¯å¤„ç†çš„å—æ•°é‡èŒƒå›´ | +| [blockSize](#blocksize) | 支æŒçš„å—å¤§å° | +| [supportPixFmts](#supportpixfmts) [[PIX_FORMAT_NUM](_codec.md#gadb8c6478388b68c09835ebe093a8920a)] | 支æŒçš„åƒç´ æ ¼å¼ | + + +## **详细æè¿°** + +定义视频编解ç 能力。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### blockCount + + +``` +RangeValue VideoPortCap::blockCount +``` + +**æ述:** + +支æŒçš„å—æ•°é‡èŒƒå›´ + + +### blockSize + + +``` +Rect VideoPortCap::blockSize +``` + +**æ述:** + +支æŒçš„å—å¤§å° + + +### blocksPerSecond + + +``` +RangeValue VideoPortCap::blocksPerSecond +``` + +**æ述:** + +æ¯ç§’å¯å¤„ç†çš„å—æ•°é‡èŒƒå›´ + + +### maxSize + + +``` +Rect VideoPortCap::maxSize +``` + +**æ述:** + +支æŒçš„最大分辨率 + + +### minSize + + +``` +Rect VideoPortCap::minSize +``` + +**æ述:** + +支æŒçš„最å°åˆ†è¾¨çŽ‡ + + +### supportPixFmts + + +``` +int32_t VideoPortCap::supportPixFmts[PIX_FORMAT_NUM] +``` + +**æ述:** + +支æŒçš„åƒç´ æ ¼å¼ + + +### whAlignment + + +``` +Alignment VideoPortCap::whAlignment +``` + +**æ述:** + +宽高对é½å€¼ diff --git a/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md b/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md new file mode 100644 index 0000000000000000000000000000000000000000..1abeadfea0e954a557e821a716cab04c96aa158c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/_w_l_a_n.md @@ -0,0 +1,304 @@ +# WLAN + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [wifi_hal.h](wifi__hal_8h.md) | æ供给WLANæœåŠ¡çš„WLAN基本能力接å£ã€‚ | +| [wifi_hal_ap_feature.h](wifi__hal__ap__feature_8h.md) | æä¾›WLANçš„AP特性能力(获å–与AP连接的STA的基本信æ¯ã€è®¾ç½®å›½å®¶ç )。 | +| [wifi_hal_base_feature.h](wifi__hal__base__feature_8h.md) | æä¾›WLAN基本特性能力。 | +| [wifi_hal_sta_feature.h](wifi__hal__sta__feature_8h.md) | æä¾›WLANçš„STA特性能力。 | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IWiFi](_i_wi_fi.md) | HAL对WLANæœåŠ¡æ供的基本能力。 [更多...](_i_wi_fi.md) | +| [StaInfo](_sta_info.md) | æ述与AP连接的STAçš„åŸºæœ¬ä¿¡æ¯ [更多...](_sta_info.md) | +| [IWiFiAp](_i_wi_fi_ap.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,并包å«AP模å¼ä¸‹èŽ·å–连接STAçš„ä¿¡æ¯å’Œè®¾ç½®å›½å®¶ç 的功能。 [更多...](_i_wi_fi_ap.md) | +| [IWiFiBaseFeature](_i_wi_fi_base_feature.md) | WLAN基本特性æ“作接å£ï¼ŒåŒ…括获å–网å¡å称,设置MAC地å€ï¼Œè®¾ç½®å‘射功率ç‰å…¬å…±èƒ½åŠ›æŽ¥å£ã€‚ [更多...](_i_wi_fi_base_feature.md) | +| [IWiFiSta](_i_wi_fi_sta.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,é¢å¤–包å«è®¾ç½®æ‰«æå•ä¸ªMAC地å€åŠŸèƒ½ã€‚ [更多...](_i_wi_fi_sta.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| IFNAME_MAX_LEN 16 | 网å¡å称最大长度。 | +| WIFI_MAC_ADDR_LENGTH 6 | WLANçš„MAC地å€é•¿åº¦ã€‚ | +| ERR_UNAUTH_ACCESS (-6) | 定义访问失败错误ç 。 | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([CallbackFunc](#callbackfunc)) (uint32_t event, void \*data, const char \*ifName) | 定义IWiFi回调函数的原型,监å¬å¼‚æ¥äº‹ä»¶ã€‚ [更多...](#callbackfunc) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [FeatureType](#featuretype) { PROTOCOL_80211_IFTYPE_UNSPECIFIED, PROTOCOL_80211_IFTYPE_ADHOC, PROTOCOL_80211_IFTYPE_STATION, PROTOCOL_80211_IFTYPE_AP, PROTOCOL_80211_IFTYPE_AP_VLAN, PROTOCOL_80211_IFTYPE_WDS, PROTOCOL_80211_IFTYPE_MONITOR, PROTOCOL_80211_IFTYPE_MESH_POINT, PROTOCOL_80211_IFTYPE_P2P_CLIENT, PROTOCOL_80211_IFTYPE_P2P_GO, PROTOCOL_80211_IFTYPE_P2P_DEVICE, PROTOCOL_80211_IFTYPE_NUM } | 枚举WLAN相关特性的类型[FeatureType](#featuretype)。 [更多...](#featuretype) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [WifiConstruct](#wificonstruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)ä¸èƒ½åŠ›æŽ¥å£ã€‚ [更多...](#wificonstruct) | +| [WifiDestruct](#wifidestruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 销æ¯IWiFi结构体并释放相关资æºã€‚ [更多...](#wifidestruct) | +| [InitApFeature](#initapfeature) (struct [IWiFiAp](_i_wi_fi_ap.md) \*\*fe) | åˆå§‹åŒ–AP特性。WLANæœåŠ¡åœ¨åˆ›å»ºAP类型的特性[FeatureType](#featuretype)时调用。 [更多...](#initapfeature) | +| [InitBaseFeature](#initbasefeature) (struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*fe) | WLANæœåŠ¡åˆ›å»ºä»»ä½•ç±»åž‹çš„特性{\@Link FeatureType}时,都需è¦è°ƒç”¨æ¤å‡½æ•°ã€‚ [更多...](#initbasefeature) | +| [InitStaFeature](#initstafeature) (struct [IWiFiSta](_i_wi_fi_sta.md) \*\*fe) | åˆå§‹åŒ–STA特性。WLANæœåŠ¡åœ¨åˆ›å»ºSTA类型的特性[FeatureType](#featuretype)时调用。 [更多...](#initstafeature) | + + +## **详细æè¿°** + +WLAN模å—å‘上层WLANæœåŠ¡æ供了统一接å£ã€‚ + +HDI层开å‘人员å¯æ ¹æ®WLAN模å—æ供的å‘上统一接å£èŽ·å–如下能力:建立/å…³é—WLANçƒç‚¹ï¼Œæ‰«æ,关è”WLANçƒç‚¹ï¼ŒWLANå¹³å°èŠ¯ç‰‡ç®¡ç†ï¼Œç½‘络数æ®ç¼“冲的申请ã€é‡Šæ”¾ã€ç§»åŠ¨ç‰æ“作,网络设备管ç†ï¼Œç”µæºç®¡ç†ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **类型定义说明** + + +### CallbackFunc + + +``` +typedef int32_t(* CallbackFunc) (uint32_t event, void *data, const char *ifName) +``` + +**æ述:** + +定义IWiFi回调函数的原型,监å¬å¼‚æ¥äº‹ä»¶ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | 输入å‚æ•°ï¼Œå›žè°ƒä¼ å…¥çš„äº‹ä»¶ç±»åž‹æ ‡è¯†ã€‚ | +| data | 输入å‚æ•°ï¼Œå›žè°ƒä¼ å…¥çš„æ•°æ®ã€‚ | +| ifName | 输入å‚数,网å¡å称。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +## **枚举类型说明** + + +### FeatureType + + +``` +enum FeatureType +``` + +**æ述:** + +枚举WLAN相关特性的类型[FeatureType](#featuretype)。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| PROTOCOL_80211_IFTYPE_UNSPECIFIED | 未定义的类型 | +| PROTOCOL_80211_IFTYPE_ADHOC | 特设型网络 | +| PROTOCOL_80211_IFTYPE_STATION | 工作站 | +| PROTOCOL_80211_IFTYPE_AP | 接入点 | +| PROTOCOL_80211_IFTYPE_AP_VLAN | 虚拟接入点 | +| PROTOCOL_80211_IFTYPE_WDS | æ— çº¿åˆ†å¸ƒå¼ç³»ç»Ÿ | +| PROTOCOL_80211_IFTYPE_MONITOR | 网络监å¬å™¨ | +| PROTOCOL_80211_IFTYPE_MESH_POINT | 组网 | +| PROTOCOL_80211_IFTYPE_P2P_CLIENT | 对ç‰ç½‘络客户端 | +| PROTOCOL_80211_IFTYPE_P2P_GO | 对ç‰ç½‘络群组所有者 | +| PROTOCOL_80211_IFTYPE_P2P_DEVICE | 对ç‰ç½‘络设备 | +| PROTOCOL_80211_IFTYPE_NUM | 网å£çš„æ•°ç›® | + + +## **函数说明** + + +### InitApFeature() + + +``` +int32_t InitApFeature (struct IWiFiAp **fe) +``` + +**æ述:** + +åˆå§‹åŒ–AP特性。WLANæœåŠ¡åœ¨åˆ›å»ºAP类型的特性[FeatureType](#featuretype)时调用。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| fe | 输入å‚数,AP特性[IWiFiAp](_i_wi_fi_ap.md)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### InitBaseFeature() + + +``` +int32_t InitBaseFeature (struct IWiFiBaseFeature **fe) +``` + +**æ述:** + +WLANæœåŠ¡åˆ›å»ºä»»ä½•ç±»åž‹çš„特性{\@Link FeatureType}时,都需è¦è°ƒç”¨æ¤å‡½æ•°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| fe | 输入å‚数,基本特性[IWiFiBaseFeature](_i_wi_fi_base_feature.md)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### InitStaFeature() + + +``` +int32_t InitStaFeature (struct IWiFiSta **fe) +``` + +**æ述:** + +åˆå§‹åŒ–STA特性。WLANæœåŠ¡åœ¨åˆ›å»ºSTA类型的特性[FeatureType](#featuretype)时调用。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| fe | 输出å‚数,STA特性[IWiFiSta](_i_wi_fi_sta.md)。 | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### WifiConstruct() + + +``` +int32_t WifiConstruct (struct IWiFi **wifiInstance) +``` + +**æ述:** + +创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)ä¸èƒ½åŠ›æŽ¥å£ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| wifiInstance | HALæœåŠ¡å¯¹è±¡[IWiFi](_i_wi_fi.md) | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 + + +### WifiDestruct() + + +``` +int32_t WifiDestruct (struct IWiFi **wifiInstance) +``` + +**æ述:** + +销æ¯IWiFi结构体并释放相关资æºã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| wifiInstance | HALæœåŠ¡å¯¹è±¡[IWiFi](_i_wi_fi.md) | + +**返回:** + +如果æ“作æˆåŠŸï¼Œåˆ™è¿”回0。 + +如果æ“作失败,则返回负值。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/annotated.md b/zh-cn/device-dev/reference/hdi-apis/annotated.md new file mode 100644 index 0000000000000000000000000000000000000000..86ba79c685e4f78974093e893d95a35995197b62 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/annotated.md @@ -0,0 +1,267 @@ +# 结构体 + + + +- **[__attribute__](____attribute____.md)** + +- **[Alignment](_alignment.md)** + +- **[AllocInfo](_alloc_info.md)** + +- **[AudioAdapter](_audio_adapter.md)** + +- **[AudioAdapterDescriptor](_audio_adapter_descriptor.md)** + +- **[AudioAttribute](_audio_attribute.md)** + +- **[AudioCapture](_audio_capture.md)** + +- **[AudioControl](_audio_control.md)** + +- **[AudioDevExtInfo](_audio_dev_ext_info.md)** + +- **[AudioDeviceDescriptor](_audio_device_descriptor.md)** + +- **[AudioManager](_audio_manager.md)** + +- **[AudioMixExtInfo](_audio_mix_ext_info.md)** + +- **[AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md)** + +- **[AudioPort](_audio_port.md)** + +- **[AudioPortCap](_audio_port_cap.md)** + +- **[AudioPortCapability](_audio_port_capability.md)** + +- **[AudioRender](_audio_render.md)** + +- **[AudioRoute](_audio_route.md)** + +- **[AudioRouteNode](_audio_route_node.md)** + +- **[AudioSampleAttributes](_audio_sample_attributes.md)** + +- **[AudioScene](_audio_scene.md)** + +- **[AudioSceneDescriptor](_audio_scene_descriptor.md)** + +- **[AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md)** + +- **[AudioSessionExtInfo](_audio_session_ext_info.md)** + +- **[AudioSubPortCapability](_audio_sub_port_capability.md)** + +- **[AudioTimeStamp](_audio_time_stamp.md)** + +- **[AudioVolume](_audio_volume.md)** + +- **[AuthResultInfo](_auth_result_info.md)** + +- **[AuthSolution](_auth_solution.md)** + +- **[BatteryInfo](_battery_info.md)** + +- **[BufferData](_buffer_data.md)** + +- **[CodecCallbackType](_codec_callback_type.md)** + +- **[CodecCompCapability](_codec_comp_capability.md)** + +- **[CodecComponentManager](_codec_component_manager.md)** + +- **[CodecComponentType](_codec_component_type.md)** + +- **[CompVerInfo](_comp_ver_info.md)** + +- **[CredentialInfo](_credential_info.md)** + +- **[DeviceFuncs](_device_funcs.md)** + +- **[DeviceInfo](_device_info.md)** + +- **[DisplayCapability](_display_capability.md)** + +- **[DisplayInfo](_display_info.md)** + +- **[DisplayModeInfo](_display_mode_info.md)** + +- **[EnrolledInfo](_enrolled_info.md)** + +- **[EnrollParam](_enroll_param.md)** + +- **[EnrollResultInfo](_enroll_resultinfo.md)** + +- **[EventInfo](_event_info.md)** + +- **[EventPackage](_event_package.md)** + +- **[ExecutorInfo](_executor_info.md)** + +- **[ExecutorInfo](_user_executor_info.md)** + +- **[ExecutorRegisterInfo](_executor_register_info.md)** + +- **[ExecutorSendMsg](_executor_send_msg.md)** + +- **[GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md)** + +- **[GfxFuncs](_gfx_funcs.md)** + +- **[GfxOpt](_gfx_opt.md)** + +- **[GrallocFuncs](_gralloc_funcs.md)** + +- **[HdfThermalCallbackInfo](_hdf_thermal_callback_info.md)** + +- **[HDRCapability](_h_d_r_capability.md)** + +- **[HDRMetaData](_h_d_r_meta_data.md)** + +- **[IBatteryCallback](interface_i_battery_callback.md)** + +- **[IBatteryInterface](interface_i_battery_interface.md)** + +- **[ICircle](_i_circle.md)** + +- **[IdentifyResultInfo](_identify_result_info.md)** + +- **[IExecutor](interface_i_executor.md)** + +- **[IExecutor](interface_pin_i_executor.md)** + +- **[IExecutorCallback](interface_i_executor_callback.md)** + +- **[IExecutorCallback](interface_pin_i_executor_callback.md)** + +- **[IFaceAuthInterface](interface_i_face_auth_interface.md)** + +- **[IInputInterface](_i_input_interface.md)** + +- **[ILine](_i_line.md)** + +- **[InputController](_input_controller.md)** + +- **[InputExtraCmd](_input_extra_cmd.md)** + +- **[InputManager](_input_manager.md)** + +- **[InputReporter](_input_reporter.md)** + +- **[InputReportEventCb](_input_report_event_cb.md)** + +- **[IPinAuthInterface](interface_i_pin_auth_interface.md)** + +- **[IPowerHdiCallback](interface_i_power_hdi_callback.md)** + +- **[IPowerInterface](interface_i_power_interface.md)** + +- **[IRect](_i_rect.md)** + +- **[ISurface](_i_surface.md)** + +- **[IThermalCallback](interface_i_thermal_callback.md)** + +- **[IThermalInterface](interface_i_thermal_interface.md)** + +- **[IUserAuthInterface](interface_i_user_auth_interface.md)** + +- **[IWiFi](_i_wi_fi.md)** + +- **[IWiFiAp](_i_wi_fi_ap.md)** + +- **[IWiFiBaseFeature](_i_wi_fi_base_feature.md)** + +- **[IWiFiSta](_i_wi_fi_sta.md)** + +- **[LayerAlpha](_layer_alpha.md)** + +- **[LayerBuffer](_layer_buffer.md)** + +- **[LayerFuncs](_layer_funcs.md)** + +- **[LayerInfo](_layer_info.md)** + +- **[LightEffect](_light_effect.md)** + +- **[LightFlashEffect](_light_flash_effect.md)** + +- **[LightInfo](_light_info.md)** + +- **[LightInterface](_light_interface.md)** + +- **[OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md)** + +- **[OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md)** + +- **[OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md)** + +- **[OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md)** + +- **[OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md)** + +- **[OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md)** + +- **[OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md)** + +- **[OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md)** + +- **[OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md)** + +- **[OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md)** + +- **[OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md)** + +- **[OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md)** + +- **[OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md)** + +- **[OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md)** + +- **[OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md)** + +- **[OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md)** + +- **[OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md)** + +- **[OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md)** + +- **[OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md)** + +- **[OmxCodecBuffer](_omx_codec_buffer.md)** + +- **[PortCap](union_port_cap.md)** + +- **[PresentTimestamp](_present_timestamp.md)** + +- **[PropertyObject](_property_object.md)** + +- **[RangeValue](_range_value.md)** + +- **[Rect](_rect.md)** + +- **[Rectangle](_rectangle.md)** + +- **[ScheduleInfo](_schedule_info.md)** + +- **[SensorEvents](_sensor_events.md)** + +- **[SensorInformation](_sensor_information.md)** + +- **[SensorInterface](_sensor_interface.md)** + +- **[StaInfo](_sta_info.md)** + +- **[SupportBufferType](_support_buffer_type.md)** + +- **[TemplateInfo](_template_info.md)** + +- **[ThermalZoneInfo](_thermal_zone_info.md)** + +- **[UseBufferType](_use_buffer_type.md)** + +- **[VerifyAllocInfo](_verify_alloc_info.md)** + +- **[VibratorInterface](_vibrator_interface.md)** + +- **[VideoPortCap](_video_port_cap.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..39a1c6b4c753d39fa2c89bf7aea12435a1a1397d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__adapter_8h.md @@ -0,0 +1,31 @@ +# audio_adapter.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioAdapter](_audio_adapter.md) | AudioAdapter音频适é…å™¨æŽ¥å£ [更多...](_audio_adapter.md) | + + +## **详细æè¿°** + +Audio适é…器的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..095bcf40db692f78de203acd93a8bf9d0058821d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__attribute_8h.md @@ -0,0 +1,31 @@ +# audio_attribute.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioAttribute](_audio_attribute.md) | AudioAttributeéŸ³é¢‘å±žæ€§æŽ¥å£ [更多...](_audio_attribute.md) | + + +## **详细æè¿°** + +Audio属性的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..62573f64322601ee09e1172bb3e0036654ad439d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__capture_8h.md @@ -0,0 +1,31 @@ +# audio_capture.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioCapture](_audio_capture.md) | AudioCaptureéŸ³é¢‘å½•éŸ³æŽ¥å£ [更多...](_audio_capture.md) | + + +## **详细æè¿°** + +Audio录音的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..04254ba25ab995425f023c5dc54a8ee23a340fb1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__control_8h.md @@ -0,0 +1,31 @@ +# audio_control.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioControl](_audio_control.md) | AudioControléŸ³é¢‘æŽ§åˆ¶æŽ¥å£ [更多...](_audio_control.md) | + + +## **详细æè¿°** + +Audio控制的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7ac28b26d6aa3f47e03f6eee4990e6b5da257a86 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__manager_8h.md @@ -0,0 +1,38 @@ +# audio_manager.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioManager](_audio_manager.md) | AudioManager音频适é…器管ç†æŽ¥å£ [更多...](_audio_manager.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GetAudioManagerFuncs](_audio.md#getaudiomanagerfuncs) (void) | 获å–音频适é…器管ç†æŽ¥å£çš„æ“作函数列表,详情å‚考[AudioManager](_audio_manager.md)[更多...](_audio.md#getaudiomanagerfuncs) | + + +## **详细æè¿°** + +Audio适é…器管ç†åŠåŠ 载的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7f1d7eaa28d7a5ecf2edba37ea302a9d8b96463b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__render_8h.md @@ -0,0 +1,31 @@ +# audio_render.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioRender](_audio_render.md) | AudioRender音频æ’æ”¾æŽ¥å£ [更多...](_audio_render.md) | + + +## **详细æè¿°** + +Audioæ’放的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..09b3026f883670d286ec9bedca1e4a27f8a65d54 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__scene_8h.md @@ -0,0 +1,31 @@ +# audio_scene.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioScene](_audio_scene.md) | AudioSceneéŸ³é¢‘åœºæ™¯æŽ¥å£ [更多...](_audio_scene.md) | + + +## **详细æè¿°** + +Audio场景的接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..5d038c1abc9b3780f27c3a1143fd02639cc99119 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__types_8h.md @@ -0,0 +1,75 @@ +# audio_types.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioPort](_audio_port.md) | éŸ³é¢‘ç«¯å£ [更多...](_audio_port.md) | +| [AudioAdapterDescriptor](_audio_adapter_descriptor.md) | 音频适é…器æ述符 [更多...](_audio_adapter_descriptor.md) | +| [AudioDeviceDescriptor](_audio_device_descriptor.md) | 音频设备æ述符 [更多...](_audio_device_descriptor.md) | +| [AudioSceneDescriptor](_audio_scene_descriptor.md) | 音频场景æ述符 [更多...](_audio_scene_descriptor.md) | +| [AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md) | 音频场景æè¿° [更多...](union_audio_scene_descriptor_1_1_scene_desc.md) | +| [AudioSampleAttributes](_audio_sample_attributes.md) | éŸ³é¢‘é‡‡æ ·å±žæ€§ [更多...](_audio_sample_attributes.md) | +| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 [更多...](_audio_time_stamp.md) | +| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频å端å£çš„支æŒèƒ½åŠ› [更多...](_audio_sub_port_capability.md) | +| [AudioPortCapability](_audio_port_capability.md) | 音频端å£çš„支æŒèƒ½åŠ› [更多...](_audio_port_capability.md) | +| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区æ述符 [更多...](_audio_mmap_buffer_descripter.md) | +| [AudioDevExtInfo](_audio_dev_ext_info.md) | éŸ³é¢‘è®¾å¤‡æ‹“å±•ä¿¡æ¯ [更多...](_audio_dev_ext_info.md) | +| [AudioMixExtInfo](_audio_mix_ext_info.md) | éŸ³è½¨æ‹“å±•ä¿¡æ¯ [更多...](_audio_mix_ext_info.md) | +| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会è¯æ‹“å±•ä¿¡æ¯ [更多...](_audio_session_ext_info.md) | +| [AudioRouteNode](_audio_route_node.md) | 音频路由节点 [更多...](_audio_route_node.md) | +| [AudioRoute](_audio_route.md) | éŸ³é¢‘è·¯ç”±ä¿¡æ¯ [更多...](_audio_route.md) | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| [AudioHandle](_audio.md#ga18675ddb073465fdeac33a897f675d79) | 音频å¥æŸ„ | +| ([RenderCallback](_audio.md#rendercallback)) (enum [AudioCallbackType](_audio.md#audiocallbacktype), void \*reserved, void \*cookie) | 回调函数指针 [更多...](_audio.md#rendercallback) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AudioPortDirection](_audio.md#audioportdirection) { PORT_OUT = 0x1u, PORT_IN = 0x2u, PORT_OUT_IN = 0x3u } | 音频端å£çš„类型 [更多...](_audio.md#audioportdirection) | +| [AudioPortPin](_audio.md#audioportpin) { PIN_NONE = 0x0u, PIN_OUT_SPEAKER = 0x1u, PIN_OUT_HEADSET = 0x2u, PIN_OUT_LINEOUT = 0x4u, PIN_OUT_HDMI = 0x8u, PIN_OUT_USB = 0x10u, PIN_OUT_USB_EXT = 0x20u, PIN_IN_MIC = 0x8000001u, PIN_IN_HS_MIC = 0x8000002u, PIN_IN_LINEIN = 0x8000004u, PIN_IN_USB_EXT = 0x8000008u } | 音频适é…器端å£çš„PINè„š [更多...](_audio.md#audioportpin) | +| [AudioCategory](_audio.md#audiocategory) { AUDIO_IN_MEDIA = 0, AUDIO_IN_COMMUNICATION, AUDIO_IN_RINGTONE, AUDIO_IN_CALL } | 音频类型(category) [更多...](_audio.md#audiocategory) | +| [AudioFormat](_audio.md#audioformat) { AUDIO_FORMAT_PCM_8_BIT = 0x1u, AUDIO_FORMAT_PCM_16_BIT = 0x2u, AUDIO_FORMAT_PCM_24_BIT = 0x3u, AUDIO_FORMAT_PCM_32_BIT = 0x4u, AUDIO_FORMAT_AAC_MAIN = 0x1000001u, AUDIO_FORMAT_AAC_LC = 0x1000002u, AUDIO_FORMAT_AAC_LD = 0x1000003u, AUDIO_FORMAT_AAC_ELD = 0x1000004u, AUDIO_FORMAT_AAC_HE_V1 = 0x1000005u, AUDIO_FORMAT_AAC_HE_V2 = 0x1000006u, AUDIO_FORMAT_G711A = 0x2000001u, AUDIO_FORMAT_G711U = 0x2000002u, AUDIO_FORMAT_G726 = 0x2000003u } | éŸ³é¢‘æ ¼å¼ [更多...](_audio.md#audioformat) | +| [AudioChannelMask](_audio.md#audiochannelmask) { AUDIO_CHANNEL_FRONT_LEFT = 0x1, AUDIO_CHANNEL_FRONT_RIGHT = 0x2, AUDIO_CHANNEL_MONO = 0x1u, AUDIO_CHANNEL_STEREO = 0x3u } | 音频通é“掩ç (mask) [更多...](_audio.md#audiochannelmask) | +| [AudioSampleRatesMask](_audio.md#audiosampleratesmask) { AUDIO_SAMPLE_RATE_MASK_8000 = 0x1u, AUDIO_SAMPLE_RATE_MASK_12000 = 0x2u, AUDIO_SAMPLE_RATE_MASK_11025 = 0x4u, AUDIO_SAMPLE_RATE_MASK_16000 = 0x8u, AUDIO_SAMPLE_RATE_MASK_22050 = 0x10u, AUDIO_SAMPLE_RATE_MASK_24000 = 0x20u, AUDIO_SAMPLE_RATE_MASK_32000 = 0x40u, AUDIO_SAMPLE_RATE_MASK_44100 = 0x80u, AUDIO_SAMPLE_RATE_MASK_48000 = 0x100u, AUDIO_SAMPLE_RATE_MASK_64000 = 0x200u, AUDIO_SAMPLE_RATE_MASK_96000 = 0x400u, AUDIO_SAMPLE_RATE_MASK_INVALID = 0xFFFFFFFFu } | éŸ³é¢‘é‡‡æ ·é¢‘çŽ‡MASK [更多...](_audio.md#audiosampleratesmask) | +| [AudioPortPassthroughMode](_audio.md#audioportpassthroughmode) { PORT_PASSTHROUGH_LPCM = 0x1, PORT_PASSTHROUGH_RAW = 0x2, PORT_PASSTHROUGH_HBR2LBR = 0x4, PORT_PASSTHROUGH_AUTO = 0x8 } | 音频端å£çš„æ•°æ®é€ä¼ æ¨¡å¼ [更多...](_audio.md#audioportpassthroughmode) | +| [AudioSampleFormat](_audio.md#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P, AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P, AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P, AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P, AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P, AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P, AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT, AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P, AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | åŽŸå§‹éŸ³é¢‘æ ·æœ¬æ ¼å¼ [更多...](_audio.md#audiosampleformat) | +| [AudioChannelMode](_audio.md#audiochannelmode) { AUDIO_CHANNEL_NORMAL = 0, AUDIO_CHANNEL_BOTH_LEFT, AUDIO_CHANNEL_BOTH_RIGHT, AUDIO_CHANNEL_EXCHANGE, AUDIO_CHANNEL_MIX, AUDIO_CHANNEL_LEFT_MUTE, AUDIO_CHANNEL_RIGHT_MUTE, AUDIO_CHANNEL_BOTH_MUTE } | 音频æ’放的通é“æ¨¡å¼ [更多...](_audio.md#audiochannelmode) | +| [AudioDrainNotifyType](_audio.md#audiodrainnotifytype) { AUDIO_DRAIN_NORMAL_MODE, AUDIO_DRAIN_EARLY_MODE } | DrainBuffer函数结æŸç±»åž‹ [更多...](_audio.md#audiodrainnotifytype) | +| [AudioCallbackType](_audio.md#audiocallbacktype) { AUDIO_NONBLOCK_WRITE_COMPELETED, AUDIO_DRAIN_COMPELETED, AUDIO_FLUSH_COMPLETED, AUDIO_RENDER_FULL, AUDIO_ERROR_OCCUR } | 回调函数通知事件类型 [更多...](_audio.md#audiocallbacktype) | +| [AudioPortRole](_audio.md#audioportrole) { AUDIO_PORT_UNASSIGNED_ROLE = 0, AUDIO_PORT_SOURCE_ROLE = 1, AUDIO_PORT_SINK_ROLE = 2 } | 音频端å£è§’色 [更多...](_audio.md#audioportrole) | +| [AudioPortType](_audio.md#audioporttype) { AUDIO_PORT_UNASSIGNED_TYPE = 0, AUDIO_PORT_DEVICE_TYPE = 1, AUDIO_PORT_MIX_TYPE = 2, AUDIO_PORT_SESSION_TYPE = 3 } | 音频端å£ç±»åž‹. [更多...](_audio.md#audioporttype) | +| [AudioSessionType](_audio.md#audiosessiontype) { AUDIO_OUTPUT_STAGE_SESSION = 0, AUDIO_OUTPUT_MIX_SESSION, AUDIO_ALLOCATE_SESSION, AUDIO_INVALID_SESSION } | 端å£ä¼šè¯ç±»åž‹ [更多...](_audio.md#audiosessiontype) | + + +## **详细æè¿°** + +Audio模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ + +Audio模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ï¼ŒåŒ…括音频端å£ã€é€‚é…器æ述符ã€è®¾å¤‡æ述符ã€åœºæ™¯æ述符ã€é‡‡æ ·å±žæ€§ã€æ—¶é—´æˆ³ç‰ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md b/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..743fa7b97a30dd5cf2fa49bc650e50de06928579 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/audio__volume_8h.md @@ -0,0 +1,31 @@ +# audio_volume.h + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [AudioVolume](_audio_volume.md) | AudioVolume音频音é‡æŽ¥å£ [更多...](_audio_volume.md) | + + +## **详细æè¿°** + +Audio音é‡çš„接å£å®šä¹‰æ–‡ä»¶ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/battery.md b/zh-cn/device-dev/reference/hdi-apis/battery.md new file mode 100644 index 0000000000000000000000000000000000000000..1a16568662ace94731352b6bf85f4da96607314b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/battery.md @@ -0,0 +1,118 @@ +# Battery + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [IBatteryCallback.idl](_i_battery_callback_8idl.md) | ç”µæ± ä¿¡æ¯çš„回调。 | +| [IBatteryInterface.idl](_i_battery_interface_8idl.md) | 获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ | +| [Types.idl](_types_8idl.md) | ç”µæ± ä¿¡æ¯ç›¸å…³æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IBatteryCallback](interface_i_battery_callback.md) | ç”µæ± ä¿¡æ¯çš„回调。 [更多...](interface_i_battery_callback.md) | +| [IBatteryInterface](interface_i_battery_interface.md) | 获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ [更多...](interface_i_battery_interface.md) | +| [BatteryInfo](_battery_info.md) | ç”µæ± ç›¸å…³ä¿¡æ¯ã€‚ [更多...](_battery_info.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [BatteryHealthState](#batteryhealthstate) { BATTERY_HEALTH_UNKNOWN = 0, BATTERY_HEALTH_GOOD, BATTERY_HEALTH_OVERHEAT, BATTERY_HEALTH_OVERVOLTAGE, BATTERY_HEALTH_COLD, BATTERY_HEALTH_DEAD, BATTERY_HEALTH_RESERVED } | ç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ [更多...](#batteryhealthstate) | +| [BatteryChargeState](#batterychargestate) { CHARGE_STATE_NONE = 0, CHARGE_STATE_ENABLE, CHARGE_STATE_DISABLE, CHARGE_STATE_FULL, CHARGE_STATE_RESERVED } | ç”µæ± çš„å……ç”µçŠ¶æ€ã€‚ [更多...](#batterychargestate) | +| [BatteryPluggedType](#batterypluggedtype) { PLUGGED_TYPE_NONE = 0, PLUGGED_TYPE_AC, PLUGGED_TYPE_USB, PLUGGED_TYPE_WIRELESS, PLUGGED_TYPE_BUTT } | ç”µæ± çš„å……ç”µè®¾å¤‡ç±»åž‹ã€‚ [更多...](#batterypluggedtype) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| package ohos.hdi.battery.v1_0 | ç”µæ± ä¿¡æ¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +æ供获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ + +ç”µæ± æ¨¡å—ä¸ºç”µæ± æœåŠ¡æ供的获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ æœåŠ¡èŽ·å–æ¤æ¨¡å—的对象或代ç†åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£èŽ·å–ç”µæ± ä¿¡æ¯ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„å˜åŒ–。 + +**Since:** + +3.1 + +**Version:** + +1.0 + + +## **枚举类型说明** + + +### BatteryChargeState + + +``` +enum BatteryChargeState +``` + +**æ述:** + +ç”µæ± çš„å……ç”µçŠ¶æ€ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| CHARGE_STATE_NONE | è¡¨ç¤ºç”µæ± å……ç”µçŠ¶æ€æœªçŸ¥ã€‚ | +| CHARGE_STATE_ENABLE | è¡¨ç¤ºç”µæ± å……ç”µçŠ¶æ€ä¸ºä½¿èƒ½çŠ¶æ€ã€‚ | +| CHARGE_STATE_DISABLE | è¡¨ç¤ºç”µæ± å……ç”µçŠ¶æ€ä¸ºåœæ¢çŠ¶æ€ã€‚ | +| CHARGE_STATE_FULL | è¡¨ç¤ºç”µæ± å……ç”µçŠ¶æ€ä¸ºå·²å……满状æ€ã€‚ | +| CHARGE_STATE_RESERVED | 预留。 | + + +### BatteryHealthState + + +``` +enum BatteryHealthState +``` + +**æ述:** + +ç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| BATTERY_HEALTH_UNKNOWN | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€æœªçŸ¥ã€‚ | +| BATTERY_HEALTH_GOOD | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ä¸ºæ£å¸¸ã€‚ | +| BATTERY_HEALTH_OVERHEAT | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ä¸ºè¿‡çƒã€‚ | +| BATTERY_HEALTH_OVERVOLTAGE | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ä¸ºè¿‡åŽ‹ã€‚ | +| BATTERY_HEALTH_COLD | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ä¸ºä½Žæ¸©ã€‚ | +| BATTERY_HEALTH_DEAD | è¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ä¸ºè€—尽。 | +| BATTERY_HEALTH_RESERVED | 预留。 | + + +### BatteryPluggedType + + +``` +enum BatteryPluggedType +``` + +**æ述:** + +ç”µæ± çš„å……ç”µè®¾å¤‡ç±»åž‹ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| PLUGGED_TYPE_NONE | 表示连接充电器类型未知。 | +| PLUGGED_TYPE_AC | 表示连接的充电器类型为交æµå……电器。 | +| PLUGGED_TYPE_USB | 表示连接的充电器类型为USB充电器。 | +| PLUGGED_TYPE_WIRELESS | è¡¨ç¤ºè¿žæŽ¥çš„å……ç”µå™¨ç±»åž‹ä¸ºæ— çº¿å……ç”µå™¨ã€‚ | +| PLUGGED_TYPE_BUTT | 预留。 | diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..901abda364d0489a74a9b6c5808360a2886eb36b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__callback__if_8h.md @@ -0,0 +1,41 @@ +# codec_callback_if.h + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [CodecCallbackType](_codec_callback_type.md) | Codec回调接å£å®šä¹‰ã€‚ [更多...](_codec_callback_type.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [CodecCallbackTypeGet](_codec.md#codeccallbacktypeget) (struct HdfRemoteService \*remote) | 实例化CodecCallbackType对象。 [更多...](_codec.md#codeccallbacktypeget) | +| [CodecCallbackTypeRelease](_codec.md#codeccallbacktyperelease) (struct [CodecCallbackType](_codec_callback_type.md) \*instance) | 释放CodecCallbackType对象。 [更多...](_codec.md#codeccallbacktyperelease) | + + +## **详细æè¿°** + +主è¦åŒ…括回调函数接å£å®šä¹‰ã€‚ + +Codec模å—事件上报ã€ä¸ŠæŠ¥è¾“å…¥buffer和输出buffer处ç†å®Œæ¯•ç‰æŽ¥å£å®šä¹‰ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7f573637c2dbff1f5945f81c5dc0bb57550d2999 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__common__type_8h.md @@ -0,0 +1,46 @@ +# codec_common_type.h + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [Alignment](_alignment.md) | 对é½ç»“构定义,包å«å®½é«˜çš„对é½å€¼ [更多...](_alignment.md) | +| [Rect](_rect.md) | 矩形的定义 [更多...](_rect.md) | +| [RangeValue](_range_value.md) | å–值范围的定义 [更多...](_range_value.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [CodecType](_codec.md#codectype) { VIDEO_DECODER, VIDEO_ENCODER, AUDIO_DECODER, AUDIO_ENCODER, INVALID_TYPE } | 枚举编解ç 的类型 [更多...](_codec.md#codectype) | +| [Profile](_codec.md#profile) { INVALID_PROFILE = 0, AAC_LC_PROFILE = 0x1000, AAC_MAIN_PROFILE, AAC_HE_V1_PROFILE, AAC_HE_V2_PROFILE, AAC_LD_PROFILE, AAC_ELD_PROFILE, AVC_BASELINE_PROFILE = 0x2000, AVC_MAIN_PROFILE, AVC_HIGH_PROFILE, HEVC_MAIN_PROFILE = 0x3000, HEVC_MAIN_10_PROFILE } | 枚举Codecè§„æ ¼ [更多...](_codec.md#profile) | +| [AudioSampleRate](_codec.md#audiosamplerate) { AUD_SAMPLE_RATE_8000 = 8000, AUD_SAMPLE_RATE_12000 = 12000, AUD_SAMPLE_RATE_11025 = 11025, AUD_SAMPLE_RATE_16000 = 16000, AUD_SAMPLE_RATE_22050 = 22050, AUD_SAMPLE_RATE_24000 = 24000, AUD_SAMPLE_RATE_32000 = 32000, AUD_SAMPLE_RATE_44100 = 44100, AUD_SAMPLE_RATE_48000 = 48000, AUD_SAMPLE_RATE_64000 = 64000, AUD_SAMPLE_RATE_96000 = 96000, AUD_SAMPLE_RATE_INVALID } | æžšä¸¾éŸ³é¢‘é‡‡æ ·çŽ‡ [更多...](_codec.md#audiosamplerate) | +| [CodecCapsMask](_codec.md#codeccapsmask) { CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1, CODEC_CAP_SECURE_PLAYBACK = 0x2, CODEC_CAP_TUNNEL_PLAYBACK = 0x4, CODEC_CAP_MULTI_PLANE = 0x10000 } | 枚举æ’放能力 [更多...](_codec.md#codeccapsmask) | +| [CodecProcessMode](_codec.md#codecprocessmode) { PROCESS_BLOCKING_INPUT_BUFFER = 0X1, PROCESS_BLOCKING_OUTPUT_BUFFER = 0X2, PROCESS_BLOCKING_CONTROL_FLOW = 0X4, PROCESS_NONBLOCKING_INPUT_BUFFER = 0X100, PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200, PROCESS_NONBLOCKING_CONTROL_FLOW = 0X400 } | 枚举编解ç 处ç†æ¨¡å¼ [更多...](_codec.md#codecprocessmode) | + + +## **详细æè¿°** + +Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ + +Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ï¼ŒåŒ…括编解ç 类型ã€éŸ³è§†é¢‘å‚æ•°ã€buffer定义ç‰ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..4e4587ac518b6a11993f76ff6f599d9d05f76bd8 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__component__if_8h.md @@ -0,0 +1,41 @@ +# codec_component_if.h + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [CodecComponentType](_codec_component_type.md) | Codec组件接å£å®šä¹‰ã€‚ [更多...](_codec_component_type.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [CodecComponentTypeGet](_codec.md#codeccomponenttypeget) (struct HdfRemoteService \*remote) | 实例化CodecComponentType对象。 [更多...](_codec.md#codeccomponenttypeget) | +| [CodecComponentTypeRelease](_codec.md#codeccomponenttyperelease) (struct [CodecComponentType](_codec_component_type.md) \*instance) | 释放CodecComponentType对象。 [更多...](_codec.md#codeccomponenttyperelease) | + + +## **详细æè¿°** + +主è¦åŒ…括Codec组件接å£å®šä¹‰ã€‚ + +Codec模å—æ供了获å–组件信æ¯ã€ç»™ç»„件å‘é€å‘½ä»¤ã€ç»„件å‚数设置ã€buffer轮转和控制ç‰æŽ¥å£å®šä¹‰ã€‚创建组件åŽï¼Œå¯ä½¿ç”¨ä¸‹åˆ—接å£è¿›è¡Œç¼–解ç 处ç†ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..77ea946aef35c4d7d6254e37baee11b398c7b68f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__component__manager_8h.md @@ -0,0 +1,41 @@ +# codec_component_manager.h + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [CodecComponentManager](_codec_component_manager.md) | Codec组件管ç†ç±»æŽ¥å£å®šä¹‰ã€‚ [更多...](_codec_component_manager.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GetCodecComponentManager](_codec.md#getcodeccomponentmanager) (void) | 实例化CodecComponentManager对象。 [更多...](_codec.md#getcodeccomponentmanager) | +| [CodecComponentManagerRelease](_codec.md#codeccomponentmanagerrelease) (void) | 释放CodecComponentManager对象。 [更多...](_codec.md#codeccomponentmanagerrelease) | + + +## **详细æè¿°** + +主è¦åŒ…括Codec组件管ç†ç±»æŽ¥å£ã€‚ + +Codec模å—获å–组件编解ç 能力集ã€åˆ›å»ºç»„件和销æ¯ç»„件ç‰æŽ¥å£å®šä¹‰ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..c83e715ec17f67d91ff5dd89e44ffa81c5dbe3a7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/codec__component__type_8h.md @@ -0,0 +1,68 @@ +# codec_component_type.h + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [VideoPortCap](_video_port_cap.md) | 定义视频编解ç 能力 [更多...](_video_port_cap.md) | +| [AudioPortCap](_audio_port_cap.md) | 定义音频编解ç 能力 [更多...](_audio_port_cap.md) | +| [PortCap](union_port_cap.md) | 定义音视频编解ç 能力 [更多...](union_port_cap.md) | +| [CodecCompCapability](_codec_comp_capability.md) | 定义Codec编解ç 能力 [更多...](_codec_comp_capability.md) | +| [OmxCodecBuffer](_omx_codec_buffer.md) | Codec bufferä¿¡æ¯çš„定义 [更多...](_omx_codec_buffer.md) | +| [CompVerInfo](_comp_ver_info.md) | å®šä¹‰ç»„ä»¶ç‰ˆæœ¬ä¿¡æ¯ [更多...](_comp_ver_info.md) | +| [EventInfo](_event_info.md) | å®šä¹‰äº‹ä»¶ä¸ŠæŠ¥ä¿¡æ¯ [更多...](_event_info.md) | +| [SupportBufferType](_support_buffer_type.md) | SupportBuffer类型定义. [更多...](_support_buffer_type.md) | +| [UseBufferType](_use_buffer_type.md) | UseBuffer类型定义 [更多...](_use_buffer_type.md) | +| [GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md) | BufferHandleUsage类型定义 [更多...](_get_buffer_handle_usage_params.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [SAMPLE_FMT_NUM](_codec.md#ga9bda75c363e9bcff915cdd521dd7ba84) 32 | é‡‡æ ·æ ¼å¼æœ€å¤§å€¼ | +| [UUID_LENGTH](_codec.md#ga9226162b034cc837cd977f0fcf611c2c) 128 | 定义UUID长度 | +| [PIX_FORMAT_NUM](_codec.md#gadb8c6478388b68c09835ebe093a8920a) 16 | 支æŒçš„åƒç´ æ ¼å¼æ•°ç»„å¤§å° | +| [SAMPLE_FORMAT_NUM](_codec.md#gaf958b9cc535f6260e2e8b7ce42c89946) 12 | 支æŒçš„éŸ³é¢‘é‡‡æ ·æ ¼å¼æ•°ç»„å¤§å° | +| [SAMPLE_RATE_NUM](_codec.md#ga0d905eaa05b4b6fcec76924eb795d7fe) 16 | 支æŒçš„éŸ³é¢‘é‡‡æ ·çŽ‡æ•°ç»„å¤§å° | +| [CHANNEL_NUM](_codec.md#ga6511732d5b29a6781cf38783157f21e1) 16 | 支æŒçš„音频通é“æ•°ç»„å¤§å° | +| [NAME_LENGTH](_codec.md#gaf71324c57f05ff9e24bd384925dd6b17) 32 | 组件åç§°å¤§å° | +| [PROFILE_NUM](_codec.md#gaab6353cb3662bdc672ae8ab90df529ce) 256 | 支æŒçš„profileæ•°ç»„å¤§å° | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [AvCodecRole](_codec.md#avcodecrole) { MEDIA_ROLETYPE_IMAGE_JPEG = 0, MEDIA_ROLETYPE_VIDEO_AVC, MEDIA_ROLETYPE_VIDEO_HEVC, MEDIA_ROLETYPE_AUDIO_FIRST = 0x10000, MEDIA_ROLETYPE_AUDIO_AAC = 0x10000, MEDIA_ROLETYPE_AUDIO_G711A, MEDIA_ROLETYPE_AUDIO_G711U, MEDIA_ROLETYPE_AUDIO_G726, MEDIA_ROLETYPE_AUDIO_PCM, MEDIA_ROLETYPE_AUDIO_MP3, MEDIA_ROLETYPE_INVALID } | 枚举音视频编解ç 组件类型 [更多...](_codec.md#avcodecrole) | +| [AudioSampleFormat](_codec.md#audiosampleformat) { AUDIO_SAMPLE_FORMAT_S8, AUDIO_SAMPLE_FORMAT_S8P, AUDIO_SAMPLE_FORMAT_U8, AUDIO_SAMPLE_FORMAT_U8P, AUDIO_SAMPLE_FORMAT_S16, AUDIO_SAMPLE_FORMAT_S16P, AUDIO_SAMPLE_FORMAT_U16, AUDIO_SAMPLE_FORMAT_U16P, AUDIO_SAMPLE_FORMAT_S24, AUDIO_SAMPLE_FORMAT_S24P, AUDIO_SAMPLE_FORMAT_U24, AUDIO_SAMPLE_FORMAT_U24P, AUDIO_SAMPLE_FORMAT_S32, AUDIO_SAMPLE_FORMAT_S32P, AUDIO_SAMPLE_FORMAT_U32, AUDIO_SAMPLE_FORMAT_U32P, AUDIO_SAMPLE_FORMAT_S64, AUDIO_SAMPLE_FORMAT_S64P, AUDIO_SAMPLE_FORMAT_U64, AUDIO_SAMPLE_FORMAT_U64P, AUDIO_SAMPLE_FORMAT_F32, AUDIO_SAMPLE_FORMAT_F32P, AUDIO_SAMPLE_FORMAT_F64, AUDIO_SAMPLE_FORMAT_F64P, AUDIO_SAMPLE_FMT_U8, AUDIO_SAMPLE_FMT_S16, AUDIO_SAMPLE_FMT_S32, AUDIO_SAMPLE_FMT_FLOAT, AUDIO_SAMPLE_FMT_DOUBLE, AUDIO_SAMPLE_FMT_U8P, AUDIO_SAMPLE_FMT_S16P, AUDIO_SAMPLE_FMT_S32P, AUDIO_SAMPLE_FMT_FLOATP, AUDIO_SAMPLE_FMT_DOUBLEP, AUDIO_SAMPLE_FMT_INVALID } | æžšä¸¾éŸ³é¢‘é‡‡æ ·æ ¼å¼ [更多...](_codec.md#audiosampleformat) | +| [CodecBufferType](_codec.md#codecbuffertype) { CODEC_BUFFER_TYPE_INVALID = 0, CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1, CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2, CODEC_BUFFER_TYPE_HANDLE = 0x4, CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8 } | 定义buffer类型 [更多...](_codec.md#codecbuffertype) | +| [ShareMemTypes](_codec.md#sharememtypes) { READ_WRITE_TYPE = 0x1, READ_ONLY_TYPE = 0x2 } | 枚举共享内å˜ç±»åž‹ [更多...](_codec.md#sharememtypes) | +| [OmxIndexCodecExType](_codec.md#omxindexcodecextype) { OMX_IndexExtBufferTypeStartUnused = OMX_IndexKhronosExtensions + 0x00a00000, OMX_IndexParamSupportBufferType, OMX_IndexParamUseBufferType, OMX_IndexParamGetBufferHandleUsage } | 枚举Codec扩展index [更多...](_codec.md#omxindexcodecextype) | +| [OmxVideoExType](_codec.md#omxvideoextype) { OMX_VIDEO_CodingHEVC = 11 } | 枚举Codec扩展编ç 类型 [更多...](_codec.md#omxvideoextype) | + + +## **详细æè¿°** + +Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ + +Codec模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ï¼ŒåŒ…括编解ç 类型ã€éŸ³è§†é¢‘å‚æ•°ã€buffer定义ç‰ã€‚ + +**Since:** + +3.1 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7d8bb2f45071341bc1b4ab3536019f659b723353 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__device_8h.md @@ -0,0 +1,48 @@ +# display_device.h + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [DeviceFuncs](_device_funcs.md) | 显示设备控制接å£ç»“构体,定义显示设备控制接å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_device_funcs.md) | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([HotPlugCallback](_display.md#hotplugcallback)) (uint32_t devId, bool connected, void \*data) | çƒæ’拔事件回调。[更多...](_display.md#hotplugcallback) | +| ([VBlankCallback](_display.md#vblankcallback)) (unsigned int sequence, uint64_t ns, void \*data) | VBlank 事件回调。 [更多...](_display.md#vblankcallback) | +| ([RefreshCallback](_display.md#refreshcallback)) (uint32_t devId, void \*data) | 刷新请求回调。[更多...](_display.md#refreshcallback) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [DeviceInitialize](_display.md#deviceinitialize) ([DeviceFuncs](_device_funcs.md) \*\*funcs) | 实现显示设备控制接å£çš„åˆå§‹åŒ–,申请æ“作显示设备控制接å£çš„资æºï¼Œå¹¶èŽ·å–对应的æ“作接å£ã€‚ [更多...](_display.md#deviceinitialize) | +| [DeviceUninitialize](_display.md#deviceuninitialize) ([DeviceFuncs](_device_funcs.md) \*funcs) | å–消显示设备控制接å£çš„åˆå§‹åŒ–,释放控制接å£ä½¿ç”¨åˆ°çš„资æºã€‚ [更多...](_display.md#deviceuninitialize) | + + +## **详细æè¿°** + +显示设备控制接å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..10cc061b8db3075f786370c338472ba45f72102c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__gfx_8h.md @@ -0,0 +1,39 @@ +# display_gfx.h + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [GfxFuncs](_gfx_funcs.md) | æ˜¾ç¤ºç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£ç»“æž„ä½“ï¼Œå®šä¹‰ç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_gfx_funcs.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GfxInitialize](_display.md#gfxinitialize) ([GfxFuncs](_gfx_funcs.md) \*\*funcs) | 获å–ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ [更多...](_display.md#gfxinitialize) | +| [GfxUninitialize](_display.md#gfxuninitialize) ([GfxFuncs](_gfx_funcs.md) \*funcs) | é‡Šæ”¾ç¡¬ä»¶åŠ é€Ÿç›¸å…³çš„æ“作接å£æŒ‡é’ˆã€‚ [更多...](_display.md#gfxuninitialize) | + + +## **详细æè¿°** + +æ˜¾ç¤ºç¡¬ä»¶åŠ é€Ÿé©±åŠ¨æŽ¥å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..e75c7d78987dd301d0011d5afe4990a67e05db5d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__gralloc_8h.md @@ -0,0 +1,39 @@ +# display_gralloc.h + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [GrallocFuncs](_gralloc_funcs.md) | 显示内å˜é©±åŠ¨æŽ¥å£ç»“构体,定义显示内å˜é©±åŠ¨æŽ¥å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_gralloc_funcs.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GrallocInitialize](_display.md#grallocinitialize) ([GrallocFuncs](_gralloc_funcs.md) \*\*funcs) | åˆå§‹åŒ–内å˜æ¨¡å—,并获å–内å˜æ供的æ“作接å£ã€‚ [更多...](_display.md#grallocinitialize) | +| [GrallocUninitialize](_display.md#grallocuninitialize) ([GrallocFuncs](_gralloc_funcs.md) \*funcs) | å–消åˆå§‹åŒ–内å˜æ¨¡å—,并释放内å˜æ“作接å£æŒ‡é’ˆã€‚ [更多...](_display.md#grallocuninitialize) | + + +## **详细æè¿°** + +显示内å˜é©±åŠ¨æŽ¥å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..6075edc6e52f07cd9762c2b0211ed9730a9df171 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__layer_8h.md @@ -0,0 +1,39 @@ +# display_layer.h + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [LayerFuncs](_layer_funcs.md) | 显示图层驱动接å£ç»“构体,定义显示图层驱动接å£å‡½æ•°æŒ‡é’ˆã€‚ [更多...](_layer_funcs.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [LayerInitialize](_display.md#layerinitialize) ([LayerFuncs](_layer_funcs.md) \*\*funcs) | 实现图层åˆå§‹åŒ–功能,申请图层使用的资æºï¼Œå¹¶èŽ·å–图层æ供的æ“作接å£ã€‚ [更多...](_display.md#layerinitialize) | +| [LayerUninitialize](_display.md#layeruninitialize) ([LayerFuncs](_layer_funcs.md) \*funcs) | å–消图层åˆå§‹åŒ–功能,释放图层使用到的资æºï¼Œå¹¶é‡Šæ”¾å›¾å±‚æ“作接å£æŒ‡é’ˆã€‚ [更多...](_display.md#layeruninitialize) | + + +## **详细æè¿°** + +显示图层驱动接å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..1687cb06bfd133ae699fd88ab0a802476a71781e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/display__type_8h.md @@ -0,0 +1,82 @@ +# display_type.h + + +## **概述** + +**所属模å—:** + +[Display](_display.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [DisplayInfo](_display_info.md) | 定义显示信æ¯ç»“构体 [更多...](_display_info.md) | +| [LayerInfo](_layer_info.md) | 定义图层信æ¯ç»“构体 [更多...](_layer_info.md) | +| [LayerAlpha](_layer_alpha.md) | 定义图层Alphaä¿¡æ¯çš„结构体 [更多...](_layer_alpha.md) | +| [BufferData](_buffer_data.md) | 定义一层的缓冲区数æ®ï¼ŒåŒ…括虚拟和物ç†å†…å˜åœ°å€ã€‚ [更多...](_buffer_data.md) | +| [LayerBuffer](_layer_buffer.md) | 图层Buffer,用于å˜æ”¾å›¾å±‚æ•°æ®ã€‚ [更多...](_layer_buffer.md) | +| [IRect](_i_rect.md) | å®šä¹‰çŸ©å½¢ä¿¡æ¯ [更多...](_i_rect.md) | +| [ISurface](_i_surface.md) | 用于å˜æ”¾çª—å£ç›¸å…³ä¿¡æ¯çš„结构体定义,æä¾›ç»™ç¡¬ä»¶åŠ é€Ÿä½¿ç”¨ï¼Œä¾‹å¦‚å›¾åƒåˆæˆï¼Œä½å›¾æ¬ç§»ç‰æ“作。 [更多...](_i_surface.md) | +| [ILine](_i_line.md) | 线æ¡æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶ç›´çº¿ã€‚ [更多...](_i_line.md) | +| [ICircle](_i_circle.md) | 圆形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶åœ†å½¢ã€‚ [更多...](_i_circle.md) | +| [Rectangle](_rectangle.md) | 矩形æè¿°ç»“æž„ä½“å®šä¹‰ï¼Œç”¨äºŽç¡¬ä»¶åŠ é€Ÿç»˜åˆ¶çŸ©å½¢ï¼Œ [更多...](_rectangle.md) | +| [GfxOpt](_gfx_opt.md) | 图åƒç¡¬ä»¶åŠ 速相关的æ“作选项结构体定义,用于图åƒç¡¬ä»¶åŠ 速时的æ“作选项。 [更多...](_gfx_opt.md) | +| [PropertyObject](_property_object.md) | 定义包å«å称ã€å±žæ€§ID和值的属性对象。 [更多...](_property_object.md) | +| [DisplayCapability](_display_capability.md) | 定义输出性能。 [更多...](_display_capability.md) | +| [DisplayModeInfo](_display_mode_info.md) | 定义输出模å¼ä¿¡æ¯ã€‚ [更多...](_display_mode_info.md) | +| [AllocInfo](_alloc_info.md) | 定义关于è¦åˆ†é…的内å˜çš„ä¿¡æ¯ã€‚ [更多...](_alloc_info.md) | +| [HDRCapability](_h_d_r_capability.md) | HDR属性结构体定义 [更多...](_h_d_r_capability.md) | +| [HDRMetaData](_h_d_r_meta_data.md) | HDR元数æ®ç»“构体定义 [更多...](_h_d_r_meta_data.md) | +| [VerifyAllocInfo](_verify_alloc_info.md) | 用于验è¯å†…å˜åˆ†é…ä¿¡æ¯çš„结构体定义 [更多...](_verify_alloc_info.md) | +| [PresentTimestamp](_present_timestamp.md) | 上å±æ—¶é—´æˆ³ç»“构体定义 [更多...](_present_timestamp.md) | +| [__attribute__](____attribute____.md) | 扩展数æ®å¥æŸ„结构体定义 [更多...](____attribute____.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| **PROPERTY_NAME_LEN** 50 | 属性å称长度 | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [DispErrCode](_display.md#disperrcode) { DISPLAY_SUCCESS = 0, DISPLAY_FAILURE = -1, DISPLAY_FD_ERR = -2, DISPLAY_PARAM_ERR = -3, DISPLAY_NULL_PTR = -4, DISPLAY_NOT_SUPPORT = -5, DISPLAY_NOMEM = -6, DISPLAY_SYS_BUSY = -7, DISPLAY_NOT_PERM = -8 } | 返回值类型定义。 [更多...](_display.md#disperrcode) | +| [LayerType](_display.md#layertype) { LAYER_TYPE_GRAPHIC, LAYER_TYPE_OVERLAY, LAYER_TYPE_SDIEBAND, LAYER_TYPE_CURSOR, LAYER_TYPE_BUTT } | 图层类型定义。 [更多...](_display.md#layertype) | +| { HBM_USE_CPU_READ = (1 << 0), HBM_USE_CPU_WRITE = (1 << 1), HBM_USE_MEM_MMZ = (1 << 2), HBM_USE_MEM_DMA = (1 << 3), HBM_USE_MEM_SHARE = (1 << 4), HBM_USE_MEM_MMZ_CACHE = (1 << 5), HBM_USE_MEM_FB = (1 << 6), HBM_USE_ASSIGN_SIZE = (1 << 7) } |缓冲区定义。[更多...](_display.md#anonymous-enum) | +| [PixelFormat](_display.md#pixelformat) { PIXEL_FMT_CLUT8 = 0, PIXEL_FMT_CLUT1, PIXEL_FMT_CLUT4, PIXEL_FMT_RGB_565, PIXEL_FMT_RGBA_5658, PIXEL_FMT_RGBX_4444, PIXEL_FMT_RGBA_4444, PIXEL_FMT_RGB_444, PIXEL_FMT_RGBX_5551, PIXEL_FMT_RGBA_5551, PIXEL_FMT_RGB_555, PIXEL_FMT_RGBX_8888, PIXEL_FMT_RGBA_8888, PIXEL_FMT_RGB_888, PIXEL_FMT_BGR_565, PIXEL_FMT_BGRX_4444, PIXEL_FMT_BGRA_4444, PIXEL_FMT_BGRX_5551, PIXEL_FMT_BGRA_5551, PIXEL_FMT_BGRX_8888, PIXEL_FMT_BGRA_8888, PIXEL_FMT_YUV_422_I, PIXEL_FMT_YCBCR_422_SP, PIXEL_FMT_YCRCB_422_SP, PIXEL_FMT_YCBCR_420_SP, PIXEL_FMT_YCRCB_420_SP, PIXEL_FMT_YCBCR_422_P, PIXEL_FMT_YCRCB_422_P, PIXEL_FMT_YCBCR_420_P, PIXEL_FMT_YCRCB_420_P, PIXEL_FMT_YUYV_422_PKG, PIXEL_FMT_UYVY_422_PKG, PIXEL_FMT_YVYU_422_PKG, PIXEL_FMT_VYUY_422_PKG, PIXEL_FMT_VENDER_MASK = 0X7FFF0000, PIXEL_FMT_BUTT = 0X7FFFFFFF } | åƒç´ æ ¼å¼ç±»åž‹å®šä¹‰ã€‚ [更多...](_display.md#pixelformat) | +| [TransformType](_display.md#transformtype) { ROTATE_NONE = 0, ROTATE_90, ROTATE_180, ROTATE_270, ROTATE_BUTT } | 图层å˜æ¢ç±»åž‹å®šä¹‰ã€‚ [更多...](_display.md#transformtype) | +| [BlendType](_display.md#blendtype) { BLEND_NONE = 0, BLEND_CLEAR, BLEND_SRC, BLEND_SRCOVER, BLEND_DSTOVER, BLEND_SRCIN, BLEND_DSTIN, BLEND_SRCOUT, BLEND_DSTOUT, BLEND_SRCATOP, BLEND_DSTATOP, BLEND_ADD, BLEND_XOR, BLEND_DST, BLEND_AKS, BLEND_AKD, BLEND_BUTT } | 显示内å˜ç±»åž‹å®šä¹‰ã€‚ [更多...](_display.md#blendtype) | +| [RopType](_display.md#roptype) { ROP_BLACK = 0, ROP_NOTMERGEPEN, ROP_MASKNOTPEN, ROP_NOTCOPYPEN, ROP_MASKPENNOT, ROP_NOT, ROP_XORPEN, ROP_NOTMASKPEN, ROP_MASKPEN, ROP_NOTXORPEN, ROP_NOP, ROP_MERGENOTPEN, ROP_COPYPE, ROP_MERGEPENNOT, ROP_MERGEPEN, ROP_WHITE, ROP_BUTT } |ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„ROPæ“作类型。 [更多...](_display.md#roptype) | +| [ColorKey](_display.md#colorkey) { CKEY_NONE = 0, CKEY_SRC, CKEY_DST, CKEY_BUTT } | Color keyæ“作类型定义,å³ç¡¬ä»¶åŠ 速支æŒçš„Color keyæ“作类型。 [更多...](_display.md#colorkey) | +| [MirrorType](_display.md#mirrortype) { MIRROR_NONE = 0, MIRROR_LR, MIRROR_TB, MIRROR_BUTT } | ç¡¬ä»¶åŠ é€Ÿæ”¯æŒçš„é•œåƒæ“作类型定义 [更多...](_display.md#mirrortype) | +| [Connection](_display.md#connection) { CON_INVALID = 0, CONNECTED, DISCONNECTED } | çƒæ’拔连接类型定义 [更多...](_display.md#connection) | +| [InterfaceType](_display.md#interfacetype) { DISP_INTF_HDMI = 0, DISP_INTF_LCD, DISP_INTF_BT1120, DISP_INTF_BT656, DISP_INTF_YPBPR, DISP_INTF_RGB, DISP_INTF_CVBS, DISP_INTF_SVIDEO, DISP_INTF_VGA, DISP_INTF_MIPI, DISP_INTF_PANEL, DISP_INTF_BUTT } | 枚举接å£ç±»åž‹ã€‚ [更多...](_display.md#interfacetype) | +| [DispPowerStatus](_display.md#disppowerstatus) { POWER_STATUS_ON, POWER_STATUS_STANDBY, POWER_STATUS_SUSPEND, POWER_STATUS_OFF, POWER_STATUS_BUTT } | æžšä¸¾æ˜¾ç¤ºçŠ¶æ€ [更多...](_display.md#disppowerstatus) | +| [CompositionType](_display.md#compositiontype) { COMPOSITION_CLIENT, COMPOSITION_DEVICE, COMPOSITION_CURSOR, COMPOSITION_VIDEO, COMPOSITION_DEVICE_CLEAR, COMPOSITION_CLIENT_CLEAR, COMPOSITION_TUNNEL, COMPOSITION_BUTT } | 枚举特殊层的组åˆç±»åž‹ã€‚ [更多...](_display.md#compositiontype) | +| [ColorGamut](_display.md#colorgamut) { COLOR_GAMUT_INVALID = -1, COLOR_GAMUT_NATIVE = 0, COLOR_GAMUT_SATNDARD_BT601 = 1, COLOR_GAMUT_STANDARD_BT709 = 2, COLOR_GAMUT_DCI_P3 = 3, COLOR_GAMUT_SRGB = 4, COLOR_GAMUT_ADOBE_RGB = 5, COLOR_GAMUT_DISPLAY_P3 = 6, COLOR_GAMUT_BT2020 = 7, COLOR_GAMUT_BT2100_PQ = 8, COLOR_GAMUT_BT2100_HLG = 9, COLOR_GAMUT_DISPLAY_BT2020 = 10 } | 色域类型枚举值 [更多...](_display.md#colorgamut) | +| [GamutMap](_display.md#gamutmap) { GAMUT_MAP_CONSTANT = 0, GAMUT_MAP_EXPANSION = 1, GAMUT_MAP_HDR_CONSTANT = 2, GAMUT_MAP_HDR_EXPANSION = 3 } | æžšä¸¾è‰²åŸŸçš„æ˜ å°„ç±»åž‹ [更多...](_display.md#gamutmap) | +| [ColorDataSpace](_display.md#colordataspace) { COLOR_DATA_SPACE_UNKNOWN = 0, GAMUT_BT601 = 0x00000001, GAMUT_BT709 = 0x00000002, GAMUT_DCI_P3 = 0x00000003, GAMUT_SRGB = 0x00000004, GAMUT_ADOBE_RGB = 0x00000005, GAMUT_DISPLAY_P3 = 0x00000006, GAMUT_BT2020 = 0x00000007, GAMUT_BT2100_PQ = 0x00000008, GAMUT_BT2100_HLG = 0x00000009, GAMUT_DISPLAY_BT2020 = 0x0000000a, TRANSFORM_FUNC_UNSPECIFIED = 0x00000100, TRANSFORM_FUNC_LINEAR = 0x00000200, TRANSFORM_FUNC_SRGB = 0x00000300, TRANSFORM_FUNC_SMPTE_170M = 0x00000400, TRANSFORM_FUNC_GM2_2 = 0x00000500, TRANSFORM_FUNC_GM2_6 = 0x00000600, TRANSFORM_FUNC_GM2_8 = 0x00000700, TRANSFORM_FUNC_ST2084 = 0x00000800, TRANSFORM_FUNC_HLG = 0x00000900, PRECISION_UNSPECIFIED = 0x00010000, PRECISION_FULL = 0x00020000, PRESION_LIMITED = 0x00030000, PRESION_EXTENDED = 0x00040000, BT601_SMPTE170M_FULL = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT601_SMPTE170M_LIMITED = GAMUT_BT601 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, BT709_LINEAR_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT709_LINEAR_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_LINEAR \| PRESION_EXTENDED, BT709_SRGB_FULL = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT709_SRGB_EXTENDED = GAMUT_BT709 \| TRANSFORM_FUNC_SRGB \| PRESION_EXTENDED, BT709_SMPTE170M_LIMITED = GAMUT_BT709 \| TRANSFORM_FUNC_SMPTE_170M \| PRESION_LIMITED, DCI_P3_LINEAR_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_GAMMA26_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_GM2_6 \| PRECISION_FULL, DISPLAY_P3_LINEAR_FULL = GAMUT_DISPLAY_P3 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, DCI_P3_SRGB_FULL = GAMUT_DCI_P3 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, ADOBE_RGB_GAMMA22_FULL = GAMUT_ADOBE_RGB \| TRANSFORM_FUNC_GM2_2 \| PRECISION_FULL, BT2020_LINEAR_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_LINEAR \| PRECISION_FULL, BT2020_SRGB_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SRGB \| PRECISION_FULL, BT2020_SMPTE170M_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_SMPTE_170M \| PRECISION_FULL, BT2020_ST2084_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRECISION_FULL, BT2020_HLG_FULL = GAMUT_BT2020 \| TRANSFORM_FUNC_HLG \| PRECISION_FULL, BT2020_ST2084_LIMITED = GAMUT_BT2020 \| TRANSFORM_FUNC_ST2084 \| PRESION_LIMITED } | 枚举颜色空间的类型 [更多...](_display.md#colordataspace) | +| [HDRFormat](_display.md#hdrformat) { NOT_SUPPORT_HDR = 0, DOLBY_VISION = 1, HDR10 = 2, HLG = 3, HDR10_PLUS = 4, HDR_VIVID = 5 } | 枚举HDRæ ¼å¼ [更多...](_display.md#hdrformat) | +| [HDRMetadataKey](_display.md#hdrmetadatakey) { MATAKEY_RED_PRIMARY_X = 0, MATAKEY_RED_PRIMARY_Y = 1, MATAKEY_GREEN_PRIMARY_X = 2, MATAKEY_GREEN_PRIMARY_Y = 3, MATAKEY_BLUE_PRIMARY_X = 4, MATAKEY_BLUE_PRIMARY_Y = 5, MATAKEY_WHITE_PRIMARY_X = 6, MATAKEY_WHITE_PRIMARY_Y = 7, MATAKEY_MAX_LUMINANCE = 8, MATAKEY_MIN_LUMINANCE = 9, MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, MATAKEY_HDR10_PLUS = 12, MATAKEY_HDR_VIVID = 13 } | 枚举HDR元数æ®å…³é”®å— [更多...](_display.md#hdrmetadatakey) | +| [PresentTimestampType](_display.md#presenttimestamptype) { HARDWARE_DISPLAY_PTS_UNSUPPORTED = 0, HARDWARE_DISPLAY_PTS_DELAY = 1 << 0, HARDWARE_DISPLAY_PTS_TIMESTAMP = 1 << 1 } | 上å±æ—¶é—´æˆ³ç±»åž‹æžšä¸¾å€¼ [更多...](_display.md#presenttimestamptype) | + + +## **详细æè¿°** + +显示类型定义,定义显示驱动接å£æ‰€ä½¿ç”¨çš„æ•°æ®ç±»åž‹ã€‚ + +**Since:** + +1.0 + +**Version:** + +2.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..746f21f26106445e5134a3ac3b3878cc4d96098a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_8idl.md @@ -0,0 +1,34 @@ +# IExecutor.idl + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IExecutor](interface_i_executor.md) | 定义执行器接å£ï¼Œç”¨äºŽèŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ [更多...](interface_i_executor.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.face_auth.v1_0 | 人脸认è¯æŽ¥å£çš„包路径。 | + + +## **详细æè¿°** + +定义执行器接å£ï¼Œç”¨äºŽèŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..ae11adf2057ae5a01e3d4c363b60754ac0754783 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md @@ -0,0 +1,34 @@ +# IExecutorCallback.idl + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IExecutorCallback](interface_i_executor_callback.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚使用细节è§[IExecutor](interface_i_executor.md)。 [更多...](interface_i_executor_callback.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.face_auth.v1_0 | 人脸认è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚ + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/files.md b/zh-cn/device-dev/reference/hdi-apis/files.md new file mode 100644 index 0000000000000000000000000000000000000000..e44e53e4664fd78e95581381f05b11fed399faac --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/files.md @@ -0,0 +1,131 @@ +# 头文件 + + + +- **[audio_adapter.h](audio__adapter_8h.md)** + +- **[audio_attribute.h](audio__attribute_8h.md)** + +- **[audio_capture.h](audio__capture_8h.md)** + +- **[audio_control.h](audio__control_8h.md)** + +- **[audio_manager.h](audio__manager_8h.md)** + +- **[audio_render.h](audio__render_8h.md)** + +- **[audio_scene.h](audio__scene_8h.md)** + +- **[audio_types.h](audio__types_8h.md)** + +- **[audio_volume.h](audio__volume_8h.md)** + +- **[codec_callback_if.h](codec__callback__if_8h.md)** + +- **[codec_common_type.h](codec__common__type_8h.md)** + +- **[codec_component_if.h](codec__component__if_8h.md)** + +- **[codec_component_manager.h](codec__component__manager_8h.md)** + +- **[codec_component_type.h](codec__component__type_8h.md)** + +- **[display_device.h](display__device_8h.md)** + +- **[display_gfx.h](display__gfx_8h.md)** + +- **[display_gralloc.h](display__gralloc_8h.md)** + +- **[display_layer.h](display__layer_8h.md)** + +- **[display_type.h](display__type_8h.md)** + +- **[icamera_device_callback.h](icamera__device__callback_8h.md)** + +- **[icamera_device.h](icamera__device_8h.md)** + +- **[icamera_host_callback.h](icamera__host__callback_8h.md)** + +- **[icamera_host.h](icamera__host_8h.md)** + +- **[input_controller.h](input__controller_8h.md)** + +- **[input_manager.h](input__manager_8h.md)** + +- **[input_reporter.h](input__reporter_8h.md)** + +- **[input_type.h](input__type_8h.md)** + +- **[ioffline_stream_operator.h](ioffline__stream__operator_8h.md)** + +- **[istream_operator_callback.h](istream__operator__callback_8h.md)** + +- **[istream_operator.h](istream__operator_8h.md)** + +- **[light_if.h](light__if_8h.md)** + +- **[light_type.h](light_8typeh.md)** + +- **[sensor_if.h](sensor__if_8h.md)** + +- **[sensor_type.h](sensor__type_8h.md)** + +- **[types.h](types_8h.md)** + +- **[usb_info.h](usb__info_8h.md)** + +- **[usbd_client.h](usbd__client_8h.md)** + +- **[usbd_subscriber.h](usbd__subscriber_8h.md)** + +- **[usbd_type.h](usbd__type_8h.md)** + +- **[vibrator_if.h](vibrator__if_8h.md)** + +- **[vibrator_type.h](vibrator__type_8h.md)** + +- **[wifi_hal_ap_feature.h](wifi__hal__ap__feature_8h.md)** + +- **[wifi_hal_base_feature.h](wifi__hal__base__feature_8h.md)** + +- **[wifi_hal_sta_feature.h](wifi__hal__sta__feature_8h.md)** + +- **[wifi_hal.h](wifi__hal_8h.md)** + +- **[IExecutor.idl](face__auth_2_i_executor_8idl.md)** + +- **[IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md)** + +- **[FaceAuthTypes.idl](_face_auth_types_8idl.md)** + +- **[PinAuthTypes.idl](_pin_auth_types_8idl.md)** + +- **[IBatteryCallback.idl](_i_battery_callback_8idl.md)** + +- **[IBatteryInterface.idl](_i_battery_interface_8idl.md)** + +- **[IExecutor.idl](pin__auth_2_i_executor_8idl.md)** + +- **[IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md)** + +- **[IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md)** + +- **[IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md)** + +- **[IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md)** + +- **[IPowerInterface.idl](_i_power_interface_8idl.md)** + +- **[IThermalInterface.idl](_i_thermal_interface_8idl.md)** + +- **[IThermalCallback.idl](_i_thermal_callback_8idl.md)** + +- **[IUserAuthInterface.idl](_i_user_auth_interface_8idl.md)** + +- **[PowerTypes.idl](_power_types_8idl.md)** + +- **[ThermalTypes.idl](_thermal_types_8idl.md)** + +- **[Types.idl](_types_8idl.md)** + +- **[UserAuthTypes.idl](_user_auth_types_8idl.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..91b9f1c93460824bf925388ebdfba6f93a5d0c2e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/icamera__device_8h.md @@ -0,0 +1,31 @@ +# icamera_device.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::ICameraDevice](_o_h_o_s_1_1_camera_1_1_i_camera_device.md) | Camera设备æ“作。 | + + +## **详细æè¿°** + +Camera设备æ“作接å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d70ccf005f7eae0f6882672fd0761781959b8276 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/icamera__device__callback_8h.md @@ -0,0 +1,31 @@ +# icamera_device_callback.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::ICameraDeviceCallback](_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) | Camera设备æ“作回调。 | + + +## **详细æè¿°** + +Camera设备的回调接å£ï¼Œä¸»è¦åŒ…å«camera设备å‘生错误时和上报metadata的回调函数。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..e7991b95aeef1a42960f000d2132442d4542f37c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/icamera__host_8h.md @@ -0,0 +1,31 @@ +# icamera_host.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::ICameraHost](_o_h_o_s_1_1_camera_1_1_i_camera_host.md) | CameraæœåŠ¡çš„管ç†ç±»ã€‚ | + + +## **详细æè¿°** + +CameraæœåŠ¡çš„管ç†ç±»ï¼Œå¯¹ä¸Šå±‚æä¾›HDI接å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..f63aab515a0770f65885e0107c20df7e016c9149 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/icamera__host__callback_8h.md @@ -0,0 +1,31 @@ +# icamera_host_callback.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::ICameraHostCallback](_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) | CameraæœåŠ¡çš„管ç†å›žè°ƒã€‚ | + + +## **详细æè¿°** + +ICameraHost的回调接å£ï¼Œæä¾›Camera设备和闪关ç¯çŠ¶æ€å˜åŒ–的回调函数,回调函数由调用者实现。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/index.md b/zh-cn/device-dev/reference/hdi-apis/index.md new file mode 100644 index 0000000000000000000000000000000000000000..27d1c39014f7b380f9ba3477290d03c5f0af9f05 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/index.md @@ -0,0 +1,35 @@ +# NativeAPIå‚考 + + + +- **[Audio](_audio.md)** + +- **[Battery](battery.md)** + +- **[Camera](_camera.md)** + +- **[Codec](_codec.md)** + +- **[Display](_display.md)** + +- **[HdfFaceAuth](_hdf_face_auth.md)** + +- **[Input](_input.md)** + +- **[Light](_light.md)** + +- **[HdfPinAuth](_hdf_pin_auth.md)** + +- **[Power](power.md)** + +- **[Sensor](_sensor.md)** + +- **[Thermal](thermal.md)** + +- **[USB](_u_s_b.md)** + +- **[HdfUserAuth](_hdf_user_auth.md)** + +- **[Vibrator](_vibrator.md)** + +- **[WLAN](_w_l_a_n.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..f89f9a17d20e7b32832471a655cb880bdab0abbd --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/input__controller_8h.md @@ -0,0 +1,31 @@ +# input_controller.h + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [InputController](_input_controller.md) | æä¾›Input设备业务控制相关的接å£ã€‚ [更多...](_input_controller.md) | + + +## **详细æè¿°** + +æè¿°Input设备业务控制相关的接å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..245d9225041d3f59c2e7e344294361e0a36e066b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/input__manager_8h.md @@ -0,0 +1,40 @@ +# input_manager.h + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [InputManager](_input_manager.md) | æä¾›Input设备管ç†ç›¸å…³çš„接å£ã€‚ [更多...](_input_manager.md) | +| [IInputInterface](_i_input_interface.md) | 定义用于æ供输入设备驱动能力的接å£ã€‚[更多...](_i_input_interface.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [GetInputInterface](_input.md#getinputinterface) ([IInputInterface](_i_input_interface.md) \*\*interface) | InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£èŽ·å–æ“作Input设备的所有接å£ã€‚ [更多...](_input.md#getinputinterface) | +| [ReleaseInputInterface](_input.md#releaseinputinterface) ([IInputInterface](_i_input_interface.md) \*\*inputInterface) | InputæœåŠ¡é€šè¿‡è°ƒç”¨æ¤æŽ¥å£é‡Šæ”¾æ“作Input设备的所有接å£ã€‚ [更多...](_input.md#releaseinputinterface) | + + +## **详细æè¿°** + +æè¿°Input设备管ç†ç›¸å…³çš„接å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..f537d55f387293772c63fc1446483d6629dc4166 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/input__reporter_8h.md @@ -0,0 +1,31 @@ +# input_reporter.h + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [InputReporter](_input_reporter.md) | æä¾›Input设备数æ®ä¸ŠæŠ¥ç›¸å…³çš„接å£ã€‚ [更多...](_input_reporter.md) | + + +## **详细æè¿°** + +æè¿°Input设备数æ®ä¸ŠæŠ¥ç›¸å…³çš„接å£å£°æ˜Žã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..73d10e58c09a8c28292362c505269a7ec79f1371 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/input__type_8h.md @@ -0,0 +1,68 @@ +# input_type.h + + +## **概述** + +**所属模å—:** + +[Input](_input.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [InputEventPackage](_event_package.md) | Input事件数æ®åŒ…结构。 [更多...](_event_package.md) | +| [InputHotPlugEvent](_input_hotplug_event.md) | çƒæ’拔事件数æ®åŒ…结构。 [更多...](_input_hotplug_event.md) | +| [InputDevDesc](_input_dev_desc.md) | Input设备æè¿°ä¿¡æ¯ã€‚ [更多...](_input_dev_desc.md) | +| [InputEventCb](_input_report_event_cb.md) | æ¤ç»“构体定义了输入事件回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ [更多...](_input_report_event_cb.md) | +| [InputHostCb](_input_host_cb.md) | æ¤ç»“构体定义了çƒæ’拔事件上报回调函数并æ供给InputæœåŠ¡ä½¿ç”¨ã€‚ [更多...](_input_host_cb.md) | +| [InputDevAbility](_input_dev_ability.md) | Input设备的能力属性,å˜å‚¨æ”¯æŒäº‹ä»¶çš„ä½å›¾ã€‚ [更多...](_input_dev_ability.md) | +| [InputDimensionInfo](_input_dimension_info.md) | Input设备的维度信æ¯ã€‚ [更多...](_input_dimension_info.md) | +| [InputDevIdentify](_input_dev_identify.md) | Input设备的识别信æ¯ã€‚ [更多...](_input_dev_identify.md) | +| [InputDevAttr](_input_dev_attr.md) | Input设备属性。 [更多...](_input_dev_attr.md) | +| [InputDeviceInfo](_device_info.md) | Input设备基础设备信æ¯ã€‚ [更多...](_device_info.md) | +| [InputExtraCmd](_input_extra_cmd.md) | 扩展指令的数æ®ç»“构。 [更多...](_input_extra_cmd.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| **MAX_INPUT_DEV_NUM** 32 | Input设备最大数é‡ã€‚ | +| **DEV_NAME_LEN** 64 | Input设备å称长度。 | +| **CHIP_INFO_LEN** 10 | 芯片信æ¯é•¿åº¦ã€‚ | +| **CHIP_NAME_LEN** 10 | 芯片å称长度。 | +| **VENDOR_NAME_LEN** 10 | 厂商å称长度。 | +| **SELF_TEST_RESULT_LEN** 20 | 自测结果长度。 | +| **DEV_MANAGER_SERVICE_NAME** "hdf_input_host" | Input设备节点æœåŠ¡å称。 | +| **DIV_ROUND_UP(nr, d)** (((nr) + (d) - 1) / (d)) | å‘上å–整计算公å¼ã€‚| +| **BYTE_HAS_BITS** 8 | 一个å—节所包å«çš„比特数。 | +| **BITS_TO_UINT64(count)** DIV_ROUND_UP(count, BYTE_HAS_BITS * sizeof(uint64_t)) | 比特与64ä½æ— 符å·æ•´æ•°çš„转æ¢å…¬å¼ã€‚ | +| **HDF_FF_CNT** (0x7f + 1) | Input设备å‘é€åŠ›å馈命令的数é‡æœ€å¤§å€¼ã€‚| + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [RetStatus](_input.md#retstatus) { INPUT_SUCCESS = 0, INPUT_FAILURE = -1, INPUT_INVALID_PARAM = -2, INPUT_NOMEM = -3, INPUT_NULL_PTR = -4, INPUT_TIMEOUT = -5, INPUT_UNSUPPORTED = -6 } | 定义返回值类型。 [更多...](_input.md#retstatus) | +| [InputDevType](_input.md#inputdevtype) { INDEV_TYPE_TOUCH, INDEV_TYPE_KEY, INDEV_TYPE_KEYBOARD, INDEV_TYPE_MOUSE, INDEV_TYPE_BUTTON, INDEV_TYPE_CROWN, INDEV_TYPE_ENCODER, INDEV_TYPE_UNKNOWN } | 定义Input设备类型。 [更多...](_input.md#inputdevtype) | +| [PowerStatus](_input.md#powerstatus) { INPUT_RESUME, INPUT_SUSPEND, INPUT_LOW_POWER, INPUT_POWER_STATUS_UNKNOWN } | 定义电æºçŠ¶æ€ã€‚ [更多...](_input.md#powerstatus) | +| [CapacitanceTest](_input.md#capacitancetest) { BASE_TEST, FULL_TEST, MMI_TEST, RUNNING_TEST, TEST_TYPE_UNKNOWN } | 定义容值测试类型。 [更多...](_input.md#capacitancetest) | + + +## **详细æè¿°** + +Input设备相关的类型定义,定义了Input设备驱动接å£æ‰€ä½¿ç”¨çš„结构体åŠæžšä¸¾ç±»åž‹ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..cafdf21cd8e3a4d1eccbe3d8fa82ddb1256470a1 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_callback.md @@ -0,0 +1,56 @@ +# IBatteryCallback + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [Update](#update) ([in] struct [BatteryInfo](_battery_info.md) event) | ç”µæ± ä¿¡æ¯çš„回调方法。 [更多...](#update) | + + +## **详细æè¿°** + +ç”µæ± ä¿¡æ¯çš„回调。 + +æœåŠ¡åˆ›å»ºæ¤å›žè°ƒå¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨IBatteryInterface的接å£æ³¨å†Œå›žè°ƒï¼Œä»Žè€Œè®¢é˜…ç”µæ± ä¿¡æ¯çš„å˜åŒ–。 + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### Update() + + +``` +IBatteryCallback::Update ([in] struct BatteryInfo event) +``` + +**æ述:** + +ç”µæ± ä¿¡æ¯çš„回调方法。 + +å½“ç”µæ± ä¿¡æ¯å‘生å˜åŒ–时,将通过æ¤æ–¹æ³•çš„å‚数返回给æœåŠ¡ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | ç”µæ± ä¿¡æ¯ï¼Œå¦‚电é‡ï¼Œç”µåŽ‹ï¼Œå¥åº·çŠ¶æ€ç‰ã€‚ | + +**å‚è§ï¼š** + +[BatteryInfo](_battery_info.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..d82964f347df262b4764b633f78815fb8257cf52 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_battery_interface.md @@ -0,0 +1,409 @@ +# IBatteryInterface + + +## **概述** + +**所属模å—:** + +[Battery](battery.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [Register](#register) ([in] [IBatteryCallback](interface_i_battery_callback.md) event) | æ³¨å†Œç”µæ± ä¿¡æ¯çš„回调。 [更多...](#register) | +| [UnRegister](#unregister) () | å–æ¶ˆæ³¨å†Œç”µæ± ä¿¡æ¯çš„回调。 [更多...](#unregister) | +| [ChangePath](#changepath) ([in] String path) | è®¾ç½®ç”µæ± ä¿¡æ¯èŠ‚点的路径。 [更多...](#changepath) | +| [GetCapacity](#getcapacity) ([out] int capacity) | 获å–ç”µæ± çš„ç”µé‡ç™¾åˆ†æ¯”。 [更多...](#getcapacity) | +| [GetVoltage](#getvoltage) ([out] int voltage) | 获å–ç”µæ± çš„ç”µåŽ‹ï¼Œå•ä½å¾®ä¼ã€‚ [更多...](#getvoltage) | +| [GetTemperature](#gettemperature) ([out] int temperature) | 获å–ç”µæ± çš„å……ç”µæ¸©åº¦ï¼Œå•ä½0.1æ‘„æ°åº¦ã€‚ [更多...](#gettemperature) | +| [GetHealthState](#gethealthstate) ([out] enum [BatteryHealthState](battery.md#batteryhealthstate) healthState) | 获å–ç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ [更多...](#gethealthstate) | +| [GetPluggedType](#getpluggedtype) ([out] enum [BatteryPluggedType](battery.md#batterypluggedtype) pluggedType) | 获å–充电设备类型。 [更多...](#getpluggedtype) | +| [GetChargeState](#getchargestate) ([out] enum [BatteryChargeState](battery.md#batterychargestate) chargeState) | 获å–充电状æ€ã€‚ [更多...](#getchargestate) | +| [GetPresent](#getpresent) ([out] boolean present) | 获å–是å¦æ”¯æŒç”µæ± æˆ–è€…ç”µæ± æ˜¯å¦åœ¨ä½ã€‚ [更多...](#getpresent) | +| [GetTechnology](#gettechnology) ([out] String technology) | 获å–ç”µæ± çš„æŠ€æœ¯åž‹å·ã€‚ [更多...](#gettechnology) | +| [GetTotalEnergy](#gettotalenergy) ([out] int totalEnergy) | 获å–ç”µæ± çš„æ€»å®¹é‡ã€‚ [更多...](#gettotalenergy) | +| [GetCurrentAverage](#getcurrentaverage) ([out] int curAverage) | 获å–ç”µæ± çš„å¹³å‡ç”µæµã€‚ [更多...](#getcurrentaverage) | +| [GetCurrentNow](#getcurrentnow) ([out] int curNow) | 获å–ç”µæ± çš„ç”µæµã€‚ [更多...](#getcurrentnow) | +| [GetRemainEnergy](#getremainenergy) ([out] int remainEnergy) | 获å–ç”µæ± çš„å‰©ä½™å®¹é‡ã€‚ [更多...](#getremainenergy) | +| [GetBatteryInfo](#getbatteryinfo) ([out] struct [BatteryInfo](_battery_info.md) info) | 获å–ç”µæ± çš„å…¨éƒ¨ä¿¡æ¯ã€‚ [更多...](#getbatteryinfo) | + + +## **详细æè¿°** + +获å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯çš„接å£ã€‚ + +æœåŠ¡èŽ·å–æ¤å¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£èŽ·å–ã€è®¢é˜…ç”µæ± ä¿¡æ¯ã€‚ + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### ChangePath() + + +``` +IBatteryInterface::ChangePath ([in] String path) +``` + +**æ述:** + +è®¾ç½®ç”µæ± ä¿¡æ¯èŠ‚点的路径。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| path | 输入å‚æ•°ï¼Œç”µæ± ä¿¡æ¯èŠ‚点的路径。 | + +**返回:** + +HDF_SUCCESS 表示路径设置æˆåŠŸã€‚ + + +### GetBatteryInfo() + + +``` +IBatteryInterface::GetBatteryInfo ([out] struct BatteryInfo info) +``` + +**æ述:** + +获å–ç”µæ± çš„å…¨éƒ¨ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| info | 输出å‚æ•°ï¼Œç”µæ± çš„å…¨éƒ¨ä¿¡æ¯ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[BatteryInfo](_battery_info.md) + + +### GetCapacity() + + +``` +IBatteryInterface::GetCapacity ([out] int capacity) +``` + +**æ述:** + +获å–ç”µæ± çš„ç”µé‡ç™¾åˆ†æ¯”。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| capacity | 输出å‚数,表示电é‡çš„百分比值。 | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetChargeState() + + +``` +IBatteryInterface::GetChargeState ([out] enum BatteryChargeState chargeState) +``` + +**æ述:** + +获å–充电状æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| chargeState | 输出å‚数,表示充电状æ€ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[BatteryChargeState](battery.md#batterychargestate) + + +### GetCurrentAverage() + + +``` +IBatteryInterface::GetCurrentAverage ([out] int curAverage) +``` + +**æ述:** + +获å–ç”µæ± çš„å¹³å‡ç”µæµã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| totalEnergy | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± çš„å¹³å‡ç”µæµï¼Œå•ä½æ¯«å®‰ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetCurrentNow() + + +``` +IBatteryInterface::GetCurrentNow ([out] int curNow) +``` + +**æ述:** + +获å–ç”µæ± çš„ç”µæµã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| curNow | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± çš„å®žæ—¶ç”µæµï¼Œå•ä½æ¯«å®‰ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetHealthState() + + +``` +IBatteryInterface::GetHealthState ([out] enum BatteryHealthState healthState) +``` + +**æ述:** + +获å–ç”µæ± çš„å¥åº·çŠ¶æ€ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| healthState | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± å¥åº·çŠ¶æ€ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[BatteryHealthState](battery.md#batteryhealthstate) + + +### GetPluggedType() + + +``` +IBatteryInterface::GetPluggedType ([out] enum BatteryPluggedType pluggedType) +``` + +**æ述:** + +获å–充电设备类型。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| pluggedType | 输出å‚数,表示充电设备类型。 | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[BatteryPluggedType](battery.md#batterypluggedtype) + + +### GetPresent() + + +``` +IBatteryInterface::GetPresent ([out] boolean present) +``` + +**æ述:** + +获å–是å¦æ”¯æŒç”µæ± æˆ–è€…ç”µæ± æ˜¯å¦åœ¨ä½ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| present | 输出å‚数,表示是å¦æ”¯æŒç”µæ± æˆ–è€…ç”µæ± æ˜¯å¦åœ¨ä½ã€‚true表示支æŒæˆ–在ä½ï¼Œfalse表示ä¸æ”¯æŒæˆ–ä¸åœ¨ä½ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetRemainEnergy() + + +``` +IBatteryInterface::GetRemainEnergy ([out] int remainEnergy) +``` + +**æ述:** + +获å–ç”µæ± çš„å‰©ä½™å®¹é‡ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| remainEnergy | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± çš„å‰©ä½™å®¹é‡ï¼Œå•ä½æ¯«å®‰æ—¶ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetTechnology() + + +``` +IBatteryInterface::GetTechnology ([out] String technology) +``` + +**æ述:** + +获å–ç”µæ± çš„æŠ€æœ¯åž‹å·ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| technology | 输出å‚数,当å‰ç”µæ± 技术型å·ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetTemperature() + + +``` +IBatteryInterface::GetTemperature ([out] int temperature) +``` + +**æ述:** + +获å–ç”µæ± çš„å……ç”µæ¸©åº¦ï¼Œå•ä½0.1æ‘„æ°åº¦ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| temperature | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± æ¸©åº¦ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetTotalEnergy() + + +``` +IBatteryInterface::GetTotalEnergy ([out] int totalEnergy) +``` + +**æ述:** + +获å–ç”µæ± çš„æ€»å®¹é‡ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| totalEnergy | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± çš„æ€»å®¹é‡ï¼Œå•ä½æ¯«å®‰æ—¶ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### GetVoltage() + + +``` +IBatteryInterface::GetVoltage ([out] int voltage) +``` + +**æ述:** + +获å–ç”µæ± çš„ç”µåŽ‹ï¼Œå•ä½å¾®ä¼ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| voltage | 输出å‚æ•°ï¼Œè¡¨ç¤ºç”µæ± çš„ç”µåŽ‹ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + + +### Register() + + +``` +IBatteryInterface::Register ([in] IBatteryCallback event) +``` + +**æ述:** + +æ³¨å†Œç”µæ± ä¿¡æ¯çš„回调。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | 输入å‚数,æœåŠ¡æ³¨å†Œçš„回调。 | + +**返回:** + +HDF_SUCCESS 表示注册æˆåŠŸã€‚ + + +### UnRegister() + + +``` +IBatteryInterface::UnRegister () +``` + +**æ述:** + +å–æ¶ˆæ³¨å†Œç”µæ± ä¿¡æ¯çš„回调。 + +**返回:** + +HDF_SUCCESS 表示å–消注册æˆåŠŸã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md new file mode 100644 index 0000000000000000000000000000000000000000..32a215289c1ff2bba8aaf381d61f8a6fa930a816 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md @@ -0,0 +1,296 @@ +# IExecutor + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [GetExecutorInfo](#getexecutorinfo) ([out] struct [ExecutorInfo](_executor_info.md) executorInfo) | 获å–执行器信æ¯ï¼Œäººè„¸è®¤è¯æœåŠ¡å°†æ‰§è¡Œå™¨æ³¨å†Œåˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶æ—¶éœ€è¦é€šè¿‡è¯¥æŽ¥å£èŽ·å–对应信æ¯ã€‚ [更多...](#getexecutorinfo) | +| [GetTemplateInfo](#gettemplateinfo) ([in] unsigned long templateId, [out] struct [TemplateInfo](_template_info.md) templateInfo) | 获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](#gettemplateinfo) | +| [OnRegisterFinish](#onregisterfinish-12) ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完æˆæ‰§è¡Œå™¨æ³¨å†Œï¼Œå¯¹äººè„¸ç‰¹å¾æ¨¡ç‰ˆè¿›è¡Œå¯¹è´¦ï¼Œç”¨äºŽåˆ é™¤æ— æ•ˆçš„äººè„¸ç‰¹å¾æ¨¡æ¿åŠç›¸å…³ä¿¡æ¯ã€‚ [更多...](#onregisterfinish-12) | +| [Enroll](#enroll) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 注册人脸特å¾æ¨¡ç‰ˆã€‚ [更多...](#enroll) | +| [Authenticate](#authenticate) ([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 人脸认è¯ã€‚ [更多...](#authenticate) | +| [Identify](#identify) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | 人脸识别。 [更多...](#identify) | +| [Delete](#delete) ([in] unsigned long[] templateIdList) | åˆ é™¤äººè„¸ç‰¹å¾æ¨¡ç‰ˆã€‚ [更多...](#delete) | +| [Cancel](#cancel) ([in] unsigned long scheduleId) | å–消æ“作请求。 [更多...](#cancel) | +| [SendCommand](#sendcommand) ([in] int commandId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_i_executor_callback.md) callbackObj) | å‘é€äººè„¸è®¤è¯åŠŸèƒ½ç›¸å…³æ“作命令。 [更多...](#sendcommand) | + + +## **详细æè¿°** + +定义执行器接å£ï¼Œç”¨äºŽèŽ·å–执行器,获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œäººè„¸ç‰¹å¾æ¨¡ç‰ˆï¼Œè¿›è¡Œç”¨æˆ·äººè„¸è®¤è¯ï¼Œåˆ 除人脸特å¾æ¨¡ç‰ˆç‰ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### Authenticate() + + +``` +IExecutor::Authenticate ([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +人脸认è¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| templateIdList | 指定è¦è®¤è¯çš„模版ID列表。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Cancel() + + +``` +IExecutor::Cancel ([in] unsigned long scheduleId) +``` + +**æ述:** + +å–消æ“作请求。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Delete() + + +``` +IExecutor::Delete ([in] unsigned long[] templateIdList) +``` + +**æ述:** + +åˆ é™¤äººè„¸ç‰¹å¾æ¨¡ç‰ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateIdList | 指定è¦åˆ 除的模版ID列表。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Enroll() + + +``` +IExecutor::Enroll ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +注册人脸特å¾æ¨¡ç‰ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetExecutorInfo() + + +``` +IExecutor::GetExecutorInfo ([out] struct ExecutorInfo executorInfo) +``` + +**æ述:** + +获å–执行器信æ¯ï¼Œäººè„¸è®¤è¯æœåŠ¡å°†æ‰§è¡Œå™¨æ³¨å†Œåˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶æ—¶éœ€è¦é€šè¿‡è¯¥æŽ¥å£èŽ·å–对应信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| executorInfo | 执行器信æ¯[ExecutorInfo](_executor_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetTemplateInfo() + + +``` +IExecutor::GetTemplateInfo ([in] unsigned long templateId, [out] struct TemplateInfo templateInfo ) +``` + +**æ述:** + +获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateId | å‡æ®æ¨¡ç‰ˆID。 | +| templateInfo | å‡æ®æ¨¡ç‰ˆä¿¡æ¯[TemplateInfo](_template_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Identify() + + +``` +IExecutor::Identify ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +人脸识别。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnRegisterFinish() [1/2] + + +``` +IExecutor::OnRegisterFinish ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo ) +``` + +**æ述:** + +完æˆæ‰§è¡Œå™¨æ³¨å†Œï¼Œå¯¹äººè„¸ç‰¹å¾æ¨¡ç‰ˆè¿›è¡Œå¯¹è´¦ï¼Œç”¨äºŽåˆ é™¤æ— æ•ˆçš„äººè„¸ç‰¹å¾æ¨¡æ¿åŠç›¸å…³ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateIdList | 用户认è¯æ¡†æž¶å†…由该执行器注册的人脸特å¾æ¨¡ç‰ˆID列表。 | +| frameworkPublicKey | 用户认è¯æ¡†æž¶çš„å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒç”¨æˆ·è®¤è¯æ¡†æž¶ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnSetData() + + +``` +IExecutor::OnSetData ([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data ) +``` + +**æ述:** + +设置å£ä»¤æ•°æ®ï¼Œå£ä»¤è®¤è¯é©±åŠ¨å¤„ç†æ³¨å†Œæˆ–认è¯å£ä»¤è¯·æ±‚时,如果å£ä»¤æ•°æ®ç”±å£ä»¤è®¤è¯æœåŠ¡èŽ·å–,需è¦é€šè¿‡è¯¥æŽ¥å£å°†å£ä»¤æ•°æ®ä¼ ç»™å£ä»¤è®¤è¯é©±åŠ¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| authSubType | å£ä»¤å类型,如å…ä½æ•°å—PINç ç‰ã€‚ | +| data | å£ä»¤æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### SendCommand() + + +``` +IExecutor::SendCommand ([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +å‘é€äººè„¸è®¤è¯åŠŸèƒ½ç›¸å…³æ“作命令。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| commandId | æ“作命令ID[CommandId](_hdf_pin_auth.md#commandid)。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..70e9ae565dca1ee9fa562596c0966b6a48f31508 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor_callback.md @@ -0,0 +1,85 @@ +# IExecutorCallback + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OnResult](#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义æ“作结果回调函数。 [更多...](#onresult) | +| [OnAcquireInfo](#onacquireinfo) ([in] int acquire, [in] unsigned char[] extraInfo) | 定义æ“作过程信æ¯å馈回调函数。 [更多...](#onacquireinfo) | + + +## **详细æè¿°** + +定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和获å–ä¿¡æ¯ã€‚使用细节è§[IExecutor](interface_i_executor.md)。 + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### OnAcquireInfo() + + +``` +IExecutorCallback::OnAcquireInfo ([in] int acquire, [in] unsigned char[] extraInfo ) +``` + +**æ述:** + +定义æ“作过程信æ¯å馈回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| acquire | æ示信æ¯ç¼–ç [FaceTipsCode](_hdf_face_auth.md#facetipscode)。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnResult() + + +``` +IExecutorCallback::OnResult ([in] int result, [in] unsigned char[] extraInfo ) +``` + +**æ述:** + +定义æ“作请求处ç†ç»“果回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| result | æ“作请求处ç†ç»“果。 | +| extraInfo | 其他相关信æ¯ï¼Œå¦‚用户认è¯é€šè¿‡æ—¶ç”¨äºŽè¿”回执行器ç¾å‘的认è¯ä»¤ç‰Œç‰ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..32041928f7fe5e3bbd82e4861cb8d86733d4bc7d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_face_auth_interface.md @@ -0,0 +1,58 @@ +# IFaceAuthInterface + + +## **概述** + +**所属模å—:** + +[HdfFaceAuth](_hdf_face_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [GetExecutorList](#getexecutorlist) ([out] [IExecutor](interface_i_executor.md)[] executorList) | 获å–执行器列表,人脸认è¯æœåŠ¡è¿›ç¨‹å¯åŠ¨è¿›è¡Œåˆå§‹åŒ–æ“作时通过该接å£èŽ·å–人脸认è¯é©±åŠ¨æ”¯æŒçš„执行器列表。 [更多...](#getexecutorlist) | + + +## **详细æè¿°** + +定义获å–人脸认è¯é©±åŠ¨çš„执行器列表接å£ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### GetExecutorList() + + +``` +IFaceAuthInterface::GetExecutorList ([out] IExecutor[] executorList) +``` + +**æ述:** + +获å–执行器列表,人脸认è¯æœåŠ¡è¿›ç¨‹å¯åŠ¨è¿›è¡Œåˆå§‹åŒ–æ“作时通过该接å£èŽ·å–人脸认è¯é©±åŠ¨æ”¯æŒçš„执行器列表。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| executorList | 执行器对象列表[IExecutor](interface_i_executor.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..c6d110537f39b948361d104ee1ab4978f141eca3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_pin_auth_interface.md @@ -0,0 +1,58 @@ +# IPinAuthInterface + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [GetExecutorList](#getexecutorlist) ([out] [IExecutor](interface_pin_i_executor.md)[] executorList) | 获å–执行器列表,å£ä»¤è®¤è¯æœåŠ¡è¿›ç¨‹å¯åŠ¨è¿›è¡Œåˆå§‹åŒ–æ“作时通过该接å£èŽ·å–å£ä»¤è®¤è¯é©±åŠ¨æ”¯æŒçš„执行器列表。 [更多...](#getexecutorlist) | + + +## **详细æè¿°** + +定义获å–å£ä»¤è®¤è¯é©±åŠ¨çš„执行器列表接å£ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### GetExecutorList() + + +``` +IPinAuthInterface::GetExecutorList ([out] IExecutor[] executorList) +``` + +**æ述:** + +获å–执行器列表,å£ä»¤è®¤è¯æœåŠ¡è¿›ç¨‹å¯åŠ¨è¿›è¡Œåˆå§‹åŒ–æ“作时通过该接å£èŽ·å–å£ä»¤è®¤è¯é©±åŠ¨æ”¯æŒçš„执行器列表。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| executorList | 执行器对象列表[IExecutor](interface_pin_i_executor.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..993bd9ed6101f16f848009998b1088adb9a1f655 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_hdi_callback.md @@ -0,0 +1,61 @@ +# IPowerHdiCallback + + +## **概述** + +**所属模å—:** + +[Power](power.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OnSuspend](#onsuspend) () | ä¼‘çœ çŠ¶æ€çš„回调方法。 [更多...](#onsuspend) | +| [OnWakeup](#onwakeup) () | 唤醒状æ€çš„回调方法。 [更多...](#onwakeup) | + + +## **详细æè¿°** + +ä¼‘çœ /唤醒状æ€çš„回调。 + +æœåŠ¡åˆ›å»ºæ¤å›žè°ƒå¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨IPowerInterface的接å£æ³¨å†Œå›žè°ƒï¼Œä»Žè€Œè®¢é˜…ä¼‘çœ /唤醒状æ€çš„å˜åŒ–。 + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### OnSuspend() + + +``` +IPowerHdiCallback::OnSuspend () +``` + +**æ述:** + +ä¼‘çœ çŠ¶æ€çš„回调方法。 + +å½“è®¾å¤‡è¿›å…¥ä¼‘çœ çŠ¶æ€æ—¶ï¼Œå°†é€šè¿‡æ¤æ–¹æ³•é€šçŸ¥ç»™æœåŠ¡ã€‚ + + +### OnWakeup() + + +``` +IPowerHdiCallback::OnWakeup () +``` + +**æ述:** + +唤醒状æ€çš„回调方法。 + +当设备进入唤醒状æ€æ—¶ï¼Œå°†é€šè¿‡æ¤æ–¹æ³•é€šçŸ¥ç»™æœåŠ¡ã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..73d549879069aba5d3d0b90d89cc12631fda7d41 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_power_interface.md @@ -0,0 +1,178 @@ +# IPowerInterface + + +## **概述** + +**所属模å—:** + +[Power](power.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [RegisterCallback](#registercallback) ([in] [IPowerHdiCallback](interface_i_power_hdi_callback.md) ipowerHdiCallback) | æ³¨å†Œä¼‘çœ /唤醒状æ€çš„回调。 [更多...](#registercallback) | +| [StartSuspend](#startsuspend) () | æ‰§è¡Œè®¾å¤‡ä¼‘çœ æ“作。 [更多...](#startsuspend) | +| [StopSuspend](#stopsuspend) () | 执行设备唤醒æ“作。 [更多...](#stopsuspend) | +| [ForceSuspend](#forcesuspend) () | æ‰§è¡Œè®¾å¤‡å¼ºåˆ¶ä¼‘çœ æ“作。 [更多...](#forcesuspend) | +| [SuspendBlock](#suspendblock) ([in] String name) | 打开è¿è¡Œé”,阻æ¢ä¼‘çœ ã€‚ [更多...](#suspendblock) | +| [SuspendUnblock](#suspendunblock) ([in] String name) | å…³é—è¿è¡Œé”,å–消阻æ¢ä¼‘çœ ã€‚ [更多...](#suspendunblock) | +| [PowerDump](#powerdump) ([out] String info) | 获å–电æºçš„Dumpä¿¡æ¯ã€‚ [更多...](#powerdump) | + + +## **详细æè¿°** + +ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ + +æœåŠ¡èŽ·å–æ¤å¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£å¯¹è®¾å¤‡è¿›è¡Œä¼‘çœ /唤醒ã€è®¢é˜…ä¼‘çœ /唤醒状æ€å’Œç®¡ç†è¿è¡Œé”。 + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### ForceSuspend() + + +``` +IPowerInterface::ForceSuspend () +``` + +**æ述:** + +æ‰§è¡Œè®¾å¤‡å¼ºåˆ¶ä¼‘çœ æ“作。 + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ + + +### PowerDump() + + +``` +IPowerInterface::PowerDump ([out] String info) +``` + +**æ述:** + +获å–电æºçš„Dumpä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| info | 输出å‚数,电æºçš„Dumpä¿¡æ¯ã€‚ | + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ + + +### RegisterCallback() + + +``` +IPowerInterface::RegisterCallback ([in] IPowerHdiCallback ipowerHdiCallback) +``` + +**æ述:** + +æ³¨å†Œä¼‘çœ /唤醒状æ€çš„回调。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| ipowerHdiCallback | 输入å‚数,æœåŠ¡æ³¨å†Œçš„回调。 | + +**返回:** + +HDF_SUCCESS 表示注册æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[IPowerHdiCallback](interface_i_power_hdi_callback.md) + + +### StartSuspend() + + +``` +IPowerInterface::StartSuspend () +``` + +**æ述:** + +æ‰§è¡Œè®¾å¤‡ä¼‘çœ æ“作。 + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ + + +### StopSuspend() + + +``` +IPowerInterface::StopSuspend () +``` + +**æ述:** + +执行设备唤醒æ“作。 + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ + + +### SuspendBlock() + + +``` +IPowerInterface::SuspendBlock ([in] String name) +``` + +**æ述:** + +打开è¿è¡Œé”,阻æ¢ä¼‘çœ ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| name | 输入å‚数,è¿è¡Œé”çš„å称。 | + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ + + +### SuspendUnblock() + + +``` +IPowerInterface::SuspendUnblock ([in] String name) +``` + +**æ述:** + +å…³é—è¿è¡Œé”,å–消阻æ¢ä¼‘çœ ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| name | 输入å‚数,è¿è¡Œé”çš„å称。 | + +**返回:** + +HDF_SUCCESS 表示æ“作æˆåŠŸã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..b713dbcc70868b061dd239f2b0527d8c3e1652e6 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_callback.md @@ -0,0 +1,56 @@ +# IThermalCallback + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OnThermalDataEvent](#onthermaldataevent) ([in] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 设备å‘çƒçŠ¶æ€å˜åŒ–的回调方法。 [更多...](#onthermaldataevent) | + + +## **详细æè¿°** + +订阅设备å‘çƒçŠ¶æ€çš„回调。 + +æœåŠ¡åˆ›å»ºæ¤å›žè°ƒå¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨IThermalInterface的接å£æ³¨å†Œå›žè°ƒï¼Œä»Žè€Œè®¢é˜…设备å‘çƒçŠ¶æ€çš„å˜åŒ–。 + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### OnThermalDataEvent() + + +``` +IThermalCallback::OnThermalDataEvent ([in] struct HdfThermalCallbackInfo event) +``` + +**æ述:** + +设备å‘çƒçŠ¶æ€å˜åŒ–的回调方法。 + +当设备å‘çƒçŠ¶æ€å‘生å˜åŒ–时,将通过æ¤æ–¹æ³•çš„å‚数返回给æœåŠ¡ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | 输入å‚数,设备å‘çƒä¿¡æ¯ï¼ŒåŒ…括器件类型ã€å™¨ä»¶æ¸©åº¦ã€‚ | + +**å‚è§ï¼š** + +[HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..cffe822befa71b155d2095b34d79894ae12bbb08 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_thermal_interface.md @@ -0,0 +1,171 @@ +# IThermalInterface + + +## **概述** + +**所属模å—:** + +[Thermal](thermal.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [SetCpuFreq](#setcpufreq) ([in] int freq) | 设置CPU频率。 [更多...](#setcpufreq) | +| [SetGpuFreq](#setgpufreq) ([in] int freq) | 设置GPU频率。 [更多...](#setgpufreq) | +| [SetBatteryCurrent](#setbatterycurrent) ([in] int current) | 设置充电电æµã€‚ [更多...](#setbatterycurrent) | +| [GetThermalZoneInfo](#getthermalzoneinfo) ([out] struct [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) event) | 获å–设备å‘çƒçš„ä¿¡æ¯ã€‚ [更多...](#getthermalzoneinfo) | +| [Register](#register) ([in] [IThermalCallback](interface_i_thermal_callback.md) callbackObj) | 注册设备å‘çƒçŠ¶æ€çš„回调。 [更多...](#register) | +| [Unregister](#unregister) () | å–消注册设备å‘çƒçŠ¶æ€çš„回调。 [更多...](#unregister) | + + +## **详细æè¿°** + +设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ + +æœåŠ¡èŽ·å–æ¤å¯¹è±¡åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£ç®¡ç†ã€æŽ§åˆ¶å’Œè®¢é˜…设备温度。 + +**Since:** + +3.1 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### GetThermalZoneInfo() + + +``` +IThermalInterface::GetThermalZoneInfo ([out] struct HdfThermalCallbackInfo event) +``` + +**æ述:** + +获å–设备å‘çƒçš„ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| event | 输出å‚数,设备å‘çƒä¿¡æ¯ï¼ŒåŒ…括器件类型ã€å™¨ä»¶æ¸©åº¦ã€‚ | + +**返回:** + +HDF_SUCCESS 表示获å–æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) + + +### Register() + + +``` +IThermalInterface::Register ([in] IThermalCallback callbackObj) +``` + +**æ述:** + +注册设备å‘çƒçŠ¶æ€çš„回调。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| callbackObj | 输入å‚数,æœåŠ¡æ³¨å†Œçš„回调。 | + +**返回:** + +HDF_SUCCESS 表示注册æˆåŠŸã€‚ + +**å‚è§ï¼š** + +[IThermalCallback](interface_i_thermal_callback.md) + + +### SetBatteryCurrent() + + +``` +IThermalInterface::SetBatteryCurrent ([in] int current) +``` + +**æ述:** + +设置充电电æµã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| current | 输入å‚数,充电电æµï¼Œå•ä½æ¯«å®‰ã€‚ | + +**返回:** + +HDF_SUCCESS 表示设置æˆåŠŸ + + +### SetCpuFreq() + + +``` +IThermalInterface::SetCpuFreq ([in] int freq) +``` + +**æ述:** + +设置CPU频率。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| freq | 输入å‚数,设置CPU频率的值。 | + +**返回:** + +HDF_SUCCESS 表示设置æˆåŠŸã€‚ + + +### SetGpuFreq() + + +``` +IThermalInterface::SetGpuFreq ([in] int freq) +``` + +**æ述:** + +设置GPU频率。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| freq | 输入å‚数,设置GPU频率的值。 | + +**返回:** + +HDF_SUCCESS 表示设置æˆåŠŸã€‚ + + +### Unregister() + + +``` +IThermalInterface::Unregister () +``` + +**æ述:** + +å–消注册设备å‘çƒçŠ¶æ€çš„回调。 + +**返回:** + +HDF_SUCCESS 表示å–消注册æˆåŠŸã€‚ diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md new file mode 100644 index 0000000000000000000000000000000000000000..9471fe3dcd50cd9a9eb64b937221e654fb0d024a --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_user_auth_interface.md @@ -0,0 +1,587 @@ +# IUserAuthInterface + + +## **概述** + +**所属模å—:** + +[HdfUserAuth](_hdf_user_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [Init](#init) () | åˆå§‹åŒ–用户认è¯é©±åŠ¨ç¼“å˜ä¿¡æ¯ï¼Œç”¨äºŽç”¨æˆ·è®¤è¯æ¡†æž¶è¿›ç¨‹å¯åŠ¨æ—¶åˆå§‹åŒ–ä¿¡æ¯ã€‚ [更多...](#init) | +| [AddExecutor](#addexecutor) ([in] struct [ExecutorRegisterInfo](_executor_register_info.md) info, [out] unsigned long index, [out] unsigned char[] publicKey, [out] unsigned long[] templateIds) | æ·»åŠ è®¤è¯æ‰§è¡Œå™¨æ¥èŽ·å–认è¯èƒ½åŠ›ï¼Œç”¨äºŽå„认è¯åŸºç¡€æœåŠ¡å¦‚å£ä»¤è®¤è¯æœåŠ¡ç‰å°†è®¤è¯èƒ½åŠ›å¯¹æŽ¥åˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶ã€‚ [更多...](#addexecutor) | +| [DeleteExecutor](#deleteexecutor) ([in] unsigned long index) | åˆ é™¤æ‰§è¡Œå™¨ï¼Œç”¨äºŽæ¸…ç†å¤±æ•ˆçš„执行器信æ¯ã€‚ [更多...](#deleteexecutor) | +| [OpenSession](#opensession) ([in] int userId, [out] unsigned char[] challenge) | å¼€å¯ä¸€ä¸ªè®¤è¯å‡æ®ç®¡ç†ä¼šè¯ï¼Œç”¨äºŽåœ¨è¯·æ±‚管ç†ç”¨æˆ·è®¤è¯å‡æ®å‰èŽ·å–有效挑战值。 [更多...](#opensession) | +| [CloseSession](#closesession) ([in] int userId) | å…³é—认è¯å‡æ®ç®¡ç†ä¼šè¯ï¼Œå®Œæˆç”¨æˆ·è®¤è¯å‡æ®ç®¡ç†è¯·æ±‚处ç†åŽï¼Œè°ƒç”¨è¯¥æŽ¥å£ä½¿åŽŸæŒ‘战值失效。 [更多...](#closesession) | +| [BeginEnrollment](#beginenrollment) ([in] int userId, [in] unsigned char[] authToken, [in] struct [EnrollParam](_enroll_param.md) param, [out] struct [ScheduleInfo](_schedule_info.md) info) | 开始注册用户认è¯å‡æ®ã€‚当注册å‡æ®ç±»åž‹ä¸ºå£ä»¤ä¸”该用户已ç»æ³¨å†Œäº†å£ä»¤å‡æ®æ—¶ï¼Œå°†ä¼šæ›´æ–°å£ä»¤å‡æ®ã€‚ [更多...](#beginenrollment) | +| [UpdateEnrollmentResult](#updateenrollmentresult) ([in] int userId, [in] unsigned char[] scheduleResult, [out] unsigned long credentialId, [out] struct [CredentialInfo](_credential_info.md) oldInfo) | 更新用户å‡æ®æ³¨å†Œç»“果,完æˆå‡æ®æ³¨å†Œã€‚ [更多...](#updateenrollmentresult) | +| [CancelEnrollment](#cancelenrollment) ([in] int userId) | å–消注册请求。 [更多...](#cancelenrollment) | +| [DeleteCredential](#deletecredential) ([in] int userId, [in] unsigned long credentialId, [in] unsigned char[] authToken, [out] struct [CredentialInfo](_credential_info.md) info) | åˆ é™¤ç”¨æˆ·å‡æ®ä¿¡æ¯ã€‚ [更多...](#deletecredential) | +| [GetCredential](#getcredential) ([in] int userId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [out] struct [CredentialInfo](_credential_info.md)[] infos) | 查询用户å‡æ®ä¿¡æ¯ã€‚ [更多...](#getcredential) | +| [GetUserInfo](#getuserinfo) ([in] int userId, [out] unsigned long secureUid, [out] enum PinSubType pinSubType, [out] struct [EnrolledInfo](_enrolled_info.md)[] infos) | 查询用户认è¯ç›¸å…³ä¿¡æ¯ã€‚ [更多...](#getuserinfo) | +| [DeleteUser](#deleteuser) ([in] int userId, [in] unsigned char[] authToken, [out] struct [CredentialInfo](_credential_info.md)[] deletedInfos) | åˆ é™¤ç”¨æˆ·å£ä»¤è®¤è¯å‡æ®ï¼Œåœ¨ç”¨æˆ·IAMç³»ç»Ÿå†…åˆ é™¤è¯¥ç”¨æˆ·ï¼Œè¯¥è¯·æ±‚ç”±ç”¨æˆ·è§¦å‘。 [更多...](#deleteuser) | +| [EnforceDeleteUser](#enforcedeleteuser) ([in] int userId, [out] struct [CredentialInfo](_credential_info.md)[] deletedInfos) | å¼ºåˆ¶åˆ é™¤ç”¨æˆ·ï¼Œè¯¥è¯·æ±‚ç”±ç³»ç»Ÿå†…ç®¡ç†ç”¨æˆ·çš„模å—触å‘。 [更多...](#enforcedeleteuser) | +| [BeginAuthentication](#beginauthentication) ([in] unsigned long contextId, [in] struct [AuthSolution](_auth_solution.md) param, [out] struct [ScheduleInfo](_schedule_info.md)[] scheduleInfos) | 开始认è¯ç”¨æˆ·ï¼Œå¹¶ç”Ÿæˆè®¤è¯æ–¹æ¡ˆã€‚ [更多...](#beginauthentication) | +| [UpdateAuthenticationResult](#updateauthenticationresult) ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct [AuthResultInfo](_auth_result_info.md) info) | 更新认è¯ç»“果,评估认è¯æ–¹æ¡ˆçš„认è¯ç»“果。 [更多...](#updateauthenticationresult) | +| [CancelAuthentication](#cancelauthentication) ([in] unsigned long contextId) | å–消用户认è¯è¯·æ±‚。 [更多...](#cancelauthentication) | +| [BeginIdentification](#beginidentification) ([in] unsigned long contextId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [in] unsigned char[] challenge, [in] unsigned int executorSensorHint, [out] struct [ScheduleInfo](_schedule_info.md) scheduleInfo) | 开始用户身份识别,并生æˆè¯†åˆ«æ–¹æ¡ˆã€‚ [更多...](#beginidentification) | +| [UpdateIdentificationResult](#updateidentificationresult) ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct [IdentifyResultInfo](_identify_result_info.md) info) | 更新用户身份识别结果,生æˆèº«ä»½è¯†åˆ«æ–¹æ¡ˆçš„结果。 [更多...](#updateidentificationresult) | +| [CancelIdentification](#cancelidentification) ([in] unsigned long contextId) | å–消用户身份识别请求。 [更多...](#cancelidentification) | +| [GetAuthTrustLevel](#getauthtrustlevel) ([in] GetUserInfoint userId, [in] enum [AuthType](_hdf_face_auth.md#authtype) authType, [out] unsigned int authTrustLevel) | 获å–当å‰è®¤è¯ç±»åž‹çš„认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ [更多...](#getauthtrustlevel) | +| [GetValidSolution](#getvalidsolution) ([in] int userId, [in] enum [AuthType](_hdf_face_auth.md#authtype)[] authTypes, [in] unsigned int authTrustLevel, [out] enum [AuthType](_hdf_face_auth.md#authtype)[] validTypes) | 获å–指定认è¯ç»“æžœå¯ä¿¡ç‰çº§ä¸‹æœ‰æ•ˆçš„认è¯æ–¹å¼ã€‚ [更多...](#getvalidsolution) | + + +## **详细æè¿°** + +声明用户认è¯é©±åŠ¨çš„API接å£ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### AddExecutor() + + +``` +IUserAuthInterface::AddExecutor ([in] struct ExecutorRegisterInfo info, [out] unsigned long index, [out] unsigned char[] publicKey, [out] unsigned long[] templateIds ) +``` + +**æ述:** + +æ·»åŠ è®¤è¯æ‰§è¡Œå™¨æ¥èŽ·å–认è¯èƒ½åŠ›ï¼Œç”¨äºŽå„认è¯åŸºç¡€æœåŠ¡å¦‚å£ä»¤è®¤è¯æœåŠ¡ç‰å°†è®¤è¯èƒ½åŠ›å¯¹æŽ¥åˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| info | 执行器注册信æ¯[ExecutorRegisterInfo](_executor_register_info.md)。 | +| index | 用户认è¯æ¡†æž¶çš„执行器索引。 | +| publicKey | 用户认è¯æ¡†æž¶å…¬é’¥ã€‚ | +| templateIds | 该执行器已注册的模版ID列表。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### BeginAuthentication() + + +``` +IUserAuthInterface::BeginAuthentication ([in] unsigned long contextId, [in] struct AuthSolution param, [out] struct ScheduleInfo[] scheduleInfos ) +``` + +**æ述:** + +开始认è¯ç”¨æˆ·ï¼Œå¹¶ç”Ÿæˆè®¤è¯æ–¹æ¡ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | +| param | 认è¯æ–¹æ¡ˆ[AuthSolution](_auth_solution.md)。 | +| scheduleInfos | 调度信æ¯[ScheduleInfo](_schedule_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### BeginEnrollment() + + +``` +IUserAuthInterface::BeginEnrollment ([in] int userId, [in] unsigned char[] authToken, [in] struct EnrollParam param, [out] struct ScheduleInfo info ) +``` + +**æ述:** + +开始注册用户认è¯å‡æ®ã€‚当注册å‡æ®ç±»åž‹ä¸ºå£ä»¤ä¸”该用户已ç»æ³¨å†Œäº†å£ä»¤å‡æ®æ—¶ï¼Œå°†ä¼šæ›´æ–°å£ä»¤å‡æ®ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| authToken | 用户å£ä»¤è®¤è¯ä»¤ç‰Œã€‚ | +| param | 注册å‡æ®å‚æ•°[EnrollParam](_enroll_param.md)。 | +| info | 调度信æ¯[ScheduleInfo](_schedule_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### BeginIdentification() + + +``` +IUserAuthInterface::BeginIdentification([in] unsigned long contextId, [in] enum AuthType authType, [in] unsigned char[] challenge, [in] unsigned int executorSensorHint, [out] struct ScheduleInfo scheduleInfo) +``` + +**æ述:** + +开始用户身份识别,并生æˆè¯†åˆ«æ–¹æ¡ˆã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | +| authType | 用户身份识别类型[AuthType](_hdf_user_auth.md#authtype)。 | +| challenge | éšæœºæŒ‘战值,用于生æˆç”¨æˆ·èº«ä»½è¯†åˆ«ä»¤ç‰Œï¼Œé˜²æ¢é‡æ”¾ã€‚ | +| executorSensorHint | æ‰§è¡Œå™¨ä¼ æ„Ÿå™¨æ示,用于找到对应认è¯æ–¹å¼çš„ä¼ æ„Ÿå™¨ã€‚ | +| scheduleInfo | 调度信æ¯[ScheduleInfo](_schedule_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### CancelAuthentication() + + +``` +IUserAuthInterface::CancelAuthentication ([in] unsigned long contextId) +``` + +**æ述:** + +å–消用户认è¯è¯·æ±‚。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### CancelEnrollment() + + +``` +IUserAuthInterface::CancelEnrollment ([in] int userId) +``` + +**æ述:** + +å–消注册请求。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### CancelIdentification() + + +``` +IUserAuthInterface::CancelIdentification ([in] unsigned long contextId) +``` + +**æ述:** + +å–消用户身份识别请求。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### CloseSession() + + +``` +IUserAuthInterface::CloseSession ([in] int userId) +``` + +**æ述:** + +å…³é—认è¯å‡æ®ç®¡ç†ä¼šè¯ï¼Œå®Œæˆç”¨æˆ·è®¤è¯å‡æ®ç®¡ç†è¯·æ±‚处ç†åŽï¼Œè°ƒç”¨è¯¥æŽ¥å£ä½¿åŽŸæŒ‘战值失效。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### DeleteCredential() + + +``` +IUserAuthInterface::DeleteCredential ([in] int userId, [in] unsigned long credentialId, [in] unsigned char[] authToken, [out] struct CredentialInfo info ) +``` + +**æ述:** + +åˆ é™¤ç”¨æˆ·å‡æ®ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| credentialId | å‡æ®ID。 | +| authToken | 用户å£ä»¤è®¤è¯ä»¤ç‰Œã€‚ | +| info | åˆ é™¤çš„å‡æ®ä¿¡æ¯[CredentialInfo](_credential_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### DeleteExecutor() + + +``` +IUserAuthInterface::DeleteExecutor ([in] unsigned long index) +``` + +**æ述:** + +åˆ é™¤æ‰§è¡Œå™¨ï¼Œç”¨äºŽæ¸…ç†å¤±æ•ˆçš„执行器信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| index | 用户认è¯æ¡†æž¶çš„执行器索引。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### DeleteUser() + + +``` +IUserAuthInterface::DeleteUser ([in] int userId, [in] unsigned char[] authToken, [out] struct CredentialInfo[] deletedInfos ) +``` + +**æ述:** + +åˆ é™¤ç”¨æˆ·å£ä»¤è®¤è¯å‡æ®ï¼Œåœ¨ç”¨æˆ·IAMç³»ç»Ÿå†…åˆ é™¤è¯¥ç”¨æˆ·ï¼Œè¯¥è¯·æ±‚ç”±ç”¨æˆ·è§¦å‘。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| authToken | 用户å£ä»¤è®¤è¯ä»¤ç‰Œã€‚ | +| deletedInfos | åˆ é™¤çš„å‡æ®ä¿¡æ¯[CredentialInfo](_credential_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### EnforceDeleteUser() + + +``` +IUserAuthInterface::EnforceDeleteUser ([in] int userId, [out] struct CredentialInfo[] deletedInfos ) +``` + +**æ述:** + +å¼ºåˆ¶åˆ é™¤ç”¨æˆ·ï¼Œè¯¥è¯·æ±‚ç”±ç³»ç»Ÿå†…ç®¡ç†ç”¨æˆ·çš„模å—触å‘。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| deletedInfos | åˆ é™¤çš„å‡æ®ä¿¡æ¯[CredentialInfo](_credential_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetAuthTrustLevel() + + +``` +IUserAuthInterface::GetAuthTrustLevel ([in] int userId, [in] enum AuthType authType, [out] unsigned int authTrustLevel ) +``` + +**æ述:** + +获å–当å‰è®¤è¯ç±»åž‹çš„认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| authType | 认è¯ç±»åž‹[AuthType](_hdf_user_auth.md#authtype)。 | +| authTrustLevel | 认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetCredential() + + +``` +IUserAuthInterface::GetCredential ([in] int userId, [in] enum AuthType authType, [out] struct CredentialInfo[] infos ) +``` + +**æ述:** + +查询用户å‡æ®ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| authType | å‡æ®ç±»åž‹[AuthType](_hdf_user_auth.md#authtype)。 | +| infos | å‡æ®ä¿¡æ¯[CredentialInfo](_credential_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetUserInfo() + + +``` +IUserAuthInterface::GetUserInfo([in] int userId, [out] unsigned long secureUid, [out] enum PinSubType pinSubType, [out] struct EnrolledInfo[] infos) +``` + +**æ述:** + +查询用户认è¯ç›¸å…³ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| secureUid | 安全用户ID。 | +| pinSubType | å£ä»¤è®¤è¯å类型,请å‚考[PinSubType](_hdf_user_auth.md#pinsubtype)。 | +| infos | 注册信æ¯[EnrolledInfo](_enrolled_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetValidSolution() + + +``` +IUserAuthInterface::GetValidSolution ([in] int userId, [in] enum AuthType[] authTypes, [in] unsigned int authTrustLevel, [out] enum AuthType[] validTypes ) +``` + +**æ述:** + +获å–指定认è¯ç»“æžœå¯ä¿¡ç‰çº§ä¸‹æœ‰æ•ˆçš„认è¯æ–¹å¼ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| authTypes | 用于ç›é€‰çš„认è¯æ–¹å¼åˆ—表[AuthType](_hdf_user_auth.md#authtype)。 | +| authTrustLevel | 认è¯ç»“æžœå¯ä¿¡ç‰çº§ã€‚ | +| validTypes | 有效的认è¯æ–¹å¼åˆ—表[AuthType](_hdf_user_auth.md#authtype)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Init() + + +``` +IUserAuthInterface::Init () +``` + +**æ述:** + +åˆå§‹åŒ–用户认è¯é©±åŠ¨ç¼“å˜ä¿¡æ¯ï¼Œç”¨äºŽç”¨æˆ·è®¤è¯æ¡†æž¶è¿›ç¨‹å¯åŠ¨æ—¶åˆå§‹åŒ–ä¿¡æ¯ã€‚ + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OpenSession() + + +``` +IUserAuthInterface::OpenSession ([in] int userId, [out] unsigned char[] challenge ) +``` + +**æ述:** + +å¼€å¯ä¸€ä¸ªè®¤è¯å‡æ®ç®¡ç†ä¼šè¯ï¼Œç”¨äºŽåœ¨è¯·æ±‚管ç†ç”¨æˆ·è®¤è¯å‡æ®å‰èŽ·å–有效挑战值。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| challenge | éšæœºæŒ‘战值,用于生æˆç”¨æˆ·èº«ä»½è®¤è¯ä»¤ç‰Œã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### UpdateAuthenticationResult() + + +``` +IUserAuthInterface::UpdateAuthenticationResult ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct AuthResultInfo info ) +``` + +**æ述:** + +更新认è¯ç»“果,评估认è¯æ–¹æ¡ˆçš„认è¯ç»“果。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | +| scheduleResult | 执行器ç¾å‘的认è¯ç»“果。 | +| info | 认è¯ç»“果信æ¯[AuthResultInfo](_auth_result_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### UpdateEnrollmentResult() + + +``` +IUserAuthInterface::UpdateEnrollmentResult([in] int userId, [in] unsigned char[] scheduleResult, [out] struct EnrollResultInfo info) +``` + +**æ述:** + +更新用户å‡æ®æ³¨å†Œç»“果,完æˆå‡æ®æ³¨å†Œã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| userId | 用户ID。 | +| scheduleResult | 执行器ç¾å‘的注册结果。 | +| oldInfo | 录入结果信æ¯[EnrollResultInfo](_enroll_resultinfo.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### UpdateIdentificationResult() + + +``` +IUserAuthInterface::UpdateIdentificationResult ([in] unsigned long contextId, [in] unsigned char[] scheduleResult, [out] struct IdentifyResultInfo info ) +``` + +**æ述:** + +更新用户身份识别结果,生æˆèº«ä»½è¯†åˆ«æ–¹æ¡ˆçš„结果。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| contextId | 上下文索引。 | +| scheduleResult | 执行器ç¾å‘的用户身份识别结果。 | +| info | 用户身份识别结果[IdentifyResultInfo](_identify_result_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md new file mode 100644 index 0000000000000000000000000000000000000000..f2ec31e36bd23413a8d772d66f0b89eb8cb6f72b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor.md @@ -0,0 +1,270 @@ +# IExecutor + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [GetTemplateInfo](interface_i_executor.md#gettemplateinfo) ([in] unsigned long templateId, [out] struct [TemplateInfo](_template_info.md) templateInfo) | 获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ [更多...](interface_i_executor.md#gettemplateinfo) | +| [Cancel](interface_i_executor.md#cancel) ([in] unsigned long scheduleId) | å–消æ“作请求。 [更多...](interface_i_executor.md#cancel) | +| [GetExecutorInfo](#getexecutorinfo) ([out] struct [ExecutorInfo](_executor_info.md) executorInfo) | 获å–执行器信æ¯ï¼Œå£ä»¤è®¤è¯æœåŠ¡å°†æ‰§è¡Œå™¨æ³¨å†Œåˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶æ—¶éœ€è¦é€šè¿‡è¯¥æŽ¥å£èŽ·å–对应信æ¯ã€‚ [更多...](#getexecutorinfo) | +| [OnRegisterFinish](#onregisterfinish) ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo) | 完æˆæ‰§è¡Œå™¨æ³¨å†Œï¼Œå¯¹å£ä»¤æ¨¡ç‰ˆä¿¡æ¯è¿›è¡Œå¯¹è´¦ï¼Œç”¨äºŽåˆ é™¤æ— æ•ˆçš„å£ä»¤æ¨¡æ¿åŠç›¸å…³ä¿¡æ¯ã€‚ [更多...](#onregisterfinish) | +| [OnSetData](interface_i_executor.md#onsetdata) ([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data) | 设置å£ä»¤æ•°æ®ï¼Œå£ä»¤è®¤è¯é©±åŠ¨å¤„ç†æ³¨å†Œæˆ–认è¯å£ä»¤è¯·æ±‚时,如果å£ä»¤æ•°æ®ç”±å£ä»¤è®¤è¯æœåŠ¡èŽ·å–,需è¦é€šè¿‡è¯¥æŽ¥å£å°†å£ä»¤æ•°æ®ä¼ ç»™å£ä»¤è®¤è¯é©±åŠ¨ã€‚ [更多...](interface_i_executor.md#onsetdata) | +| [Enroll](#enroll) ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | 注册å£ä»¤ã€‚ [更多...](#enroll) | +| [Authenticate](#authenticate) ([in] unsigned long scheduleId, [in] unsigned long templateId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | 认è¯å£ä»¤ã€‚ [ERROR:Invalid link:zh-cn_topic_0000001304382272.xml#xref15713627408,link:zh-cn_topic_0000001304382272.xml](zh-cn_topic_0000001304382272.xml) | +| [Delete](#delete) ([in] unsigned long templateId) | åˆ é™¤å£ä»¤ã€‚ [更多...](#delete) | +| [SendCommand](#sendcommand) ([in] int commandId, [in] unsigned char[] extraInfo, [in] [IExecutorCallback](interface_pin_i_executor_callback.md) callbackObj) | å‘é€å£ä»¤è®¤è¯åŠŸèƒ½ç›¸å…³æ“作命令。 [更多...](#sendcommand) | + + +## **详细æè¿°** + +å®šä¹‰æ‰§è¡Œå™¨æ ‡å‡†API接å£ã€‚接å£å¯ç”¨äºŽèŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚ + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### Authenticate() + + +``` +IExecutor::Authenticate ([in] unsigned long scheduleId, [in] unsigned long templateId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +认è¯å£ä»¤ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| templateId | 指定è¦è®¤è¯çš„模版ID。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_pin_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Cancel() + + +``` +IExecutor::Cancel ([in] unsigned long scheduleId) +``` + +**æ述:** + +å–消æ“作请求。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Delete() + + +``` +IExecutor::Delete ([in] unsigned long templateId) +``` + +**æ述:** + +åˆ é™¤å£ä»¤ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateId | 模版ID。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### Enroll() + + +``` +IExecutor::Enroll ([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +注册å£ä»¤ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_pin_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetExecutorInfo() + + +``` +IExecutor::GetExecutorInfo ([out] struct ExecutorInfo executorInfo) +``` + +**æ述:** + +获å–执行器信æ¯ï¼Œå£ä»¤è®¤è¯æœåŠ¡å°†æ‰§è¡Œå™¨æ³¨å†Œåˆ°ç”¨æˆ·è®¤è¯æ¡†æž¶æ—¶éœ€è¦é€šè¿‡è¯¥æŽ¥å£èŽ·å–对应信æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| executorInfo | 执行器信æ¯[ExecutorInfo](_executor_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### GetTemplateInfo() + + +``` +IExecutor::GetTemplateInfo ([in] unsigned long templateId, [out] struct TemplateInfo templateInfo ) +``` + +**æ述:** + +获å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateId | å‡æ®æ¨¡ç‰ˆID。 | +| templateInfo | å‡æ®æ¨¡ç‰ˆä¿¡æ¯[TemplateInfo](_template_info.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnRegisterFinish() + + +``` +IExecutor::OnRegisterFinish ([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo ) +``` + +**æ述:** + +完æˆæ‰§è¡Œå™¨æ³¨å†Œï¼Œå¯¹å£ä»¤æ¨¡ç‰ˆä¿¡æ¯è¿›è¡Œå¯¹è´¦ï¼Œç”¨äºŽåˆ é™¤æ— æ•ˆçš„å£ä»¤æ¨¡æ¿åŠç›¸å…³ä¿¡æ¯ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| templateIdList | 用户认è¯æ¡†æž¶å†…由该执行器注册的å£ä»¤å‡æ®æ¨¡ç‰ˆID列表。 | +| frameworkPublicKey | 用户认è¯æ¡†æž¶çš„å…¬é’¥ï¼Œç”¨äºŽæ ¡éªŒç”¨æˆ·è®¤è¯æ¡†æž¶ç§é’¥ç¾åçš„ä¿¡æ¯ã€‚ | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnSetData() + + +``` +IExecutor::OnSetData ([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data ) +``` + +**æ述:** + +设置å£ä»¤æ•°æ®ï¼Œå£ä»¤è®¤è¯é©±åŠ¨å¤„ç†æ³¨å†Œæˆ–认è¯å£ä»¤è¯·æ±‚时,如果å£ä»¤æ•°æ®ç”±å£ä»¤è®¤è¯æœåŠ¡èŽ·å–,需è¦é€šè¿‡è¯¥æŽ¥å£å°†å£ä»¤æ•°æ®ä¼ ç»™å£ä»¤è®¤è¯é©±åŠ¨ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| scheduleId | 调度IDï¼Œç”¨äºŽæ ‡è¯†ä¸€æ¬¡æ“作请求的调度过程。 | +| authSubType | å£ä»¤å类型,如å…ä½æ•°å—PINç ç‰ã€‚ | +| data | å£ä»¤æ•°æ®ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### SendCommand() + + +``` +IExecutor::SendCommand ([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj ) +``` + +**æ述:** + +å‘é€å£ä»¤è®¤è¯åŠŸèƒ½ç›¸å…³æ“作命令。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| commandId | æ“作命令ID[CommandId](_hdf_pin_auth.md#commandid)。 | +| extraInfo | 其他相关信æ¯ï¼Œç”¨äºŽæ”¯æŒä¿¡æ¯æ‰©å±•ã€‚ | +| callbackObj | 回调对象[IExecutorCallback](interface_pin_i_executor_callback.md)。 | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..afa114d1d6713248b831ebbca7933c13e947da39 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/interface_pin_i_executor_callback.md @@ -0,0 +1,85 @@ +# IExecutorCallback + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### Public æˆå‘˜å‡½æ•° + + | Public æˆå‘˜å‡½æ•° | æè¿° | +| -------- | -------- | +| [OnResult](interface_i_executor_callback.md#onresult) ([in] int result, [in] unsigned char[] extraInfo) | 定义æ“作结果回调函数。 [更多...](interface_i_executor_callback.md#onresult) | +| [OnGetData](#ongetdata) ([in] unsigned long scheduleId, [in] unsigned char[] salt, [in] unsigned long authSubType) | 定义请求获å–å£ä»¤æ•°æ®å›žè°ƒå‡½æ•°ã€‚ [更多...](#ongetdata) | + + +## **详细æè¿°** + +定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和获å–ä¿¡æ¯ã€‚使用细节è§[IExecutor](interface_i_executor.md)。 + +**Since:** + +3.2 + +**Version:** + +1.0 + + +## **æˆå‘˜å‡½æ•°è¯´æ˜Ž** + + +### OnGetData() + + +``` +IExecutorCallback::OnGetData ([in] unsigned long scheduleId, [in] unsigned char[] salt, [in] unsigned long authSubType ) +``` + +**æ述:** + +定义请求获å–å£ä»¤æ•°æ®å›žè°ƒå‡½æ•°ã€‚ + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| salt | ç›å€¼ï¼Œç”¨äºŽå¯¹å£ä»¤æ˜Žæ–‡è¿›è¡Œå•å‘处ç†ã€‚ | +| authSubType | å£ä»¤å类型,如å…ä½æ•°å—PINç ç‰ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 + + +### OnResult() + + +``` +IExecutorCallback::OnResult ([in] int result, [in] unsigned char[] extraInfo ) +``` + +**æ述:** + +定义æ“作请求处ç†ç»“果回调函数。 + +**å‚数:** + + | å称 | æè¿° | +| -------- | -------- | +| result | æ“作请求处ç†ç»“果。 | +| extraInfo | 其他相关信æ¯ï¼Œå¦‚用户认è¯é€šè¿‡æ—¶ç”¨äºŽè¿”回执行器ç¾å‘的认è¯ä»¤ç‰Œç‰ã€‚ | + +**返回:** + +0 表示æ“作æˆåŠŸã€‚ + +éž0 表示æ“作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md b/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..0a593960df15b13fa7993604729fe44d422f52a7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/ioffline__stream__operator_8h.md @@ -0,0 +1,31 @@ +# ioffline_stream_operator.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::IOfflineStreamOperator](_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) | 离线æµçš„æ“作类。 | + + +## **详细æè¿°** + +离线æµçš„æ“作接å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md b/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..a051ce63222611aef21f4be9f21e1c972b6468ba --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/istream__operator_8h.md @@ -0,0 +1,31 @@ +# istream_operator.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::IStreamOperator](_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) | æµçš„æ“作类。 | + + +## **详细æè¿°** + +æµçš„æ“作接å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md b/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..79f5e3d8b480e208e732160c760498ea84515517 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/istream__operator__callback_8h.md @@ -0,0 +1,31 @@ +# istream_operator_callback.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::IStreamOperatorCallback](_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) | æµçš„æ“作回调类。 | + + +## **详细æè¿°** + +[IStreamOperator](istream__operator_8h.md) 相关的回调,这些回调å‡ç”±è°ƒç”¨è€…实现。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md b/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md new file mode 100644 index 0000000000000000000000000000000000000000..55be372ba23701d13dd838bfbc217c0e0e10523b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/light_8typeh.md @@ -0,0 +1,33 @@ +# light_type.h + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### ç±» + +| ç±» | æè¿° | +| -------- | -------- | +| LightFlashEffect | 定义闪çƒå‚数。 [更多...](_light_flash_effect.md) | +| LightEffect | 定义ç¯çš„效果å‚数。 [更多...](_light_effect.md) | +| LightInfo | 定义ç¯çš„基本信æ¯ã€‚ [更多...](_light_info.md) | + + +## **详细æè¿°** + +声明light模å—的通用API,å¯ç”¨äºŽèŽ·å–ç¯IDã€æ‰“开或关é—ç¯ã€å¹¶è®¾ç½®ç¯å…‰äº®åº¦å’Œé—ªçƒæ¨¡å¼ã€‚ + +**Since:** + +3.1 + +**Version:** + +1.0 \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..989dc4180adaaf06f1dd227e2976a82aaf775830 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/light__if_8h.md @@ -0,0 +1,40 @@ +# light_if.h + + +## **概述** + +**所属模å—:** + +[Light](_light.md) + + +## **汇总** + + +### ç±» + +| ç±» | æè¿° | +| -------- | -------- | +| [LightInterface](_light_interface.md) | 定义å¯ä»¥åœ¨ç¯ä¸Šæ‰§è¡Œçš„基本æ“作。 [更多...](_light_interface.md) | + + +### 函数 + +| 函数 | æè¿° | +| -------- | -------- | +| [NewLightInterfaceInstance](_light.md#newlightinterfaceinstance) (void) | 创建LightInterface实例。 [更多...](_light.md#newlightinterfaceinstance) | +| [FreeLightInterfaceInstance](_light.md#freelightinterfaceinstance) (void) | 释放LightInterface实例和相关资æºã€‚ [更多...](_light.md#freelightinterfaceinstance) | + + +## **详细æè¿°** + +声明light模å—的通用API,å¯ç”¨äºŽèŽ·å–ç¯IDã€æ‰“开或关é—ç¯ã€å¹¶è®¾ç½®ç¯å…‰äº®åº¦å’Œé—ªçƒæ¨¡å¼ã€‚ + +**Since:** + +3.1 + +**Version:** + +1.0 + diff --git a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..b642de475903f6710b7d62886606ef708b62023e --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_8idl.md @@ -0,0 +1,34 @@ +# IExecutor.idl + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IExecutor](interface_pin_i_executor.md) | å®šä¹‰æ‰§è¡Œå™¨æ ‡å‡†API接å£ã€‚接å£å¯ç”¨äºŽèŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚ [更多...](interface_pin_i_executor.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.pin_auth.v1_0 | å£ä»¤è®¤è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +å®šä¹‰æ‰§è¡Œå™¨æ ‡å‡†API接å£ã€‚接å£å¯ç”¨äºŽèŽ·å–执行器信æ¯ï¼ŒèŽ·å–å‡æ®æ¨¡ç‰ˆä¿¡æ¯ï¼Œæ³¨å†Œå£ä»¤ï¼Œè®¤è¯å£ä»¤ï¼Œåˆ 除å£ä»¤ç‰ã€‚ + +**Since:** + +3.2 diff --git a/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md new file mode 100644 index 0000000000000000000000000000000000000000..39df7ba9021fa902cc6948b9cb567fe9de3ab613 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md @@ -0,0 +1,38 @@ +# IExecutorCallback.idl + + +## **概述** + +**所属模å—:** + +[HdfPinAuth](_hdf_pin_auth.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IExecutorCallback](interface_pin_i_executor_callback.md) | 定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和信æ¯ã€‚使用细节è§[IExecutor](interface_pin_i_executor.md)。 [更多...](interface_pin_i_executor_callback.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.pin_auth.v1_0 | å£ä»¤è®¤è¯æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +定义异æ¥API接å£å›žè°ƒï¼Œç”¨äºŽè¿”回异æ¥æŽ¥å£çš„请求处ç†ç»“果和获å–ä¿¡æ¯ã€‚使用细节è§[IExecutor](interface_pin_i_executor.md)。 + +**Since:** + +3.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/power.md b/zh-cn/device-dev/reference/hdi-apis/power.md new file mode 100644 index 0000000000000000000000000000000000000000..2ce105c12d28d9579ab2b3ad6eefbf186588e312 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/power.md @@ -0,0 +1,112 @@ +# Power + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md) | ä¼‘çœ /唤醒状æ€çš„回调。 | +| [IPowerInterface.idl](_i_power_interface_8idl.md) | ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ | +| [PowerTypes.idl](_power_types_8idl.md) | 电æºç›¸å…³çš„æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IPowerHdiCallback](interface_i_power_hdi_callback.md) | ä¼‘çœ /唤醒状æ€çš„回调。 [更多...](interface_i_power_hdi_callback.md) | +| [IPowerInterface](interface_i_power_interface.md) | ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ [更多...](interface_i_power_interface.md) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [PowerHdfCmd](#powerhdfcmd) { CMD_REGISTER_CALLBCK = 0, CMD_START_SUSPEND, CMD_STOP_SUSPEND, CMD_FORCE_SUSPEND, CMD_SUSPEND_BLOCK, CMD_SUSPEND_UNBLOCK, CMD_DUMP } | 枚举电æºå‘½ä»¤çš„å‚数。 [更多...](#powerhdfcmd) | +| [PowerHdfCallbackCmd](#powerhdfcallbackcmd) { CMD_ON_SUSPEND = 0, CMD_ON_WAKEUP } | 枚举电æºçŠ¶æ€å›žè°ƒçš„å‚数。 [更多...](#powerhdfcallbackcmd) | +| [PowerHdfState](#powerhdfstate) { AWAKE = 0, INACTIVE, SLEEP } | 枚举电æºçš„状æ€ã€‚ [更多...](#powerhdfstate) | + + +### å˜é‡ + + | å˜é‡ | æè¿° | +| -------- | -------- | +| package ohos.hdi.power.v1_0 | 电æºç®¡ç†æŽ¥å£çš„包路径。 | + + +## **详细æè¿°** + +æä¾›ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€ã€è¿è¡Œé”管ç†çš„接å£ã€‚ + +电æºæ¨¡å—为电æºæœåŠ¡æä¾›çš„ä¼‘çœ /唤醒æ“作ã€è®¢é˜…ä¼‘çœ /唤醒状æ€å’Œè¿è¡Œé”管ç†çš„接å£ã€‚ æœåŠ¡èŽ·å–æ¤æ¨¡å—的对象或代ç†åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£å¯¹è®¾å¤‡è¿›è¡Œä¼‘çœ /唤醒ã€è®¢é˜…ä¼‘çœ /唤醒状æ€å’Œç®¡ç†è¿è¡Œé”。 + +**Since:** + +3.1 + +**Version:** + +1.0 + + +## **枚举类型说明** + + +### PowerHdfCallbackCmd + + +``` +enum PowerHdfCallbackCmd +``` + +**æ述:** + +枚举电æºçŠ¶æ€å›žè°ƒçš„å‚数。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CMD_ON_SUSPEND | ä¼‘çœ å›žè°ƒçš„å‘½ä»¤å‚数。 | +| CMD_ON_WAKEUP | 唤醒回调的命令å‚数。 | + + +### PowerHdfCmd + + +``` +enum PowerHdfCmd +``` + +**æ述:** + +枚举电æºå‘½ä»¤çš„å‚数。 + + | 枚举值 | æè¿° | +| -------- | -------- | +| CMD_REGISTER_CALLBCK | 订阅状æ€çš„命令å‚æ•° | +| CMD_START_SUSPEND | ä¼‘çœ çš„å‘½ä»¤å‚æ•° | +| CMD_STOP_SUSPEND | 唤醒的命令å‚æ•° | +| CMD_FORCE_SUSPEND | å¼ºåˆ¶ä¼‘çœ çš„å‘½ä»¤å‚æ•° | +| CMD_SUSPEND_BLOCK | 打开è¿è¡Œé”的命令å‚æ•° | +| CMD_SUSPEND_UNBLOCK | å…³é—è¿è¡Œé”的命令å‚æ•° | +| CMD_DUMP | Dump的命令å‚æ•° | + + +### PowerHdfState + + +``` +enum PowerHdfState +``` + +**æ述:** + +枚举电æºçš„状æ€ã€‚ + + | 枚举值 | æè¿° | +| -------- | -------- | +| AWAKE | 唤醒状æ€ã€‚ | +| INACTIVE | éžæ´»åŠ¨çŠ¶æ€ã€‚ | +| SLEEP | ä¼‘çœ çŠ¶æ€ã€‚ | diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-caution.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-caution.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-danger.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-danger.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-note.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-note.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-notice.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-notice.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-tip.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-tip.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-warning.gif b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/device-dev/reference/hdi-apis/public_sys-resources/icon-warning.gif differ diff --git a/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..886db580b0e774b24cce3e329d712189beaaaa9d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/sensor__if_8h.md @@ -0,0 +1,39 @@ +# sensor_if.h + + +## **概述** + +**所属模å—:** + +[Sensor](_sensor.md) + + +## **汇总** + + +### ç±» + +| ç±» | æè¿° | +| -------- | -------- | +| [SensorInterface](_sensor_interface.md) | æä¾›sensor设备基本控制æ“作接å£ã€‚ [更多...](_sensor_interface.md) | + + +### 函数 + +| 函数 | æè¿° | +| -------- | -------- | +| [NewSensorInterfaceInstance](_sensor.md#newsensorinterfaceinstance) (void) | åˆ›å»ºä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ [更多...](_sensor.md#newsensorinterfaceinstance) | +| [FreeSensorInterfaceInstance](_sensor.md#freesensorinterfaceinstance) (void) | é‡Šæ”¾ä¼ æ„Ÿå™¨æŽ¥å£å®žä¾‹ã€‚ [更多...](_sensor.md#freesensorinterfaceinstance) | + + +## **详细æè¿°** + +Sensor模å—对外通用的接å£å£°æ˜Žæ–‡ä»¶ï¼Œæ供获å–ä¼ æ„Ÿå™¨è®¾å¤‡ä¿¡æ¯ã€è®¢é˜…/å–æ¶ˆè®¢é˜…ä¼ æ„Ÿå™¨æ•°æ®ã€ 使能/åŽ»ä½¿èƒ½ä¼ æ„Ÿå™¨ã€è®¾ç½®ä¼ 感器模å¼ã€è®¾ç½®ä¼ 感器精度,é‡ç¨‹ç‰å¯é€‰é…置接å£å®šä¹‰ã€‚ + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..35adb8935df3946a74ce804b53a713680154aedc --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/sensor__type_8h.md @@ -0,0 +1,59 @@ +# sensor_type.h + + +## **概述** + +**所属模å—:** + +[Sensor](_sensor.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [SensorInformation](_sensor_information.md) | å®šä¹‰ä¼ æ„Ÿå™¨åŸºæœ¬ä¿¡æ¯ã€‚ [更多...](_sensor_information.md) | +| [SensorEvents](_sensor_events.md) | ä¸ŠæŠ¥ä¼ æ„Ÿå™¨æ•°æ®ç»“构。 [更多...](_sensor_events.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [SENSOR_NAME_MAX_LEN](_sensor.md#sensornamemaxlen) 32 | Sensorå称的最大长度 | +| [SENSOR_VERSION_MAX_LEN](_sensor.md#sensorversionmaxlen) 16 | Sensor版本å·çš„最大长度 | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([RecordDataCallback](_sensor.md#recorddatacallback)) (const struct [SensorEvents](_sensor_events.md) \*) | ä¼ æ„Ÿå™¨ä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°çš„å®šä¹‰ï¼Œä¼ æ„Ÿå™¨æœåŠ¡ç”¨æˆ·åœ¨è®¢é˜…ä¼ æ„Ÿå™¨æ—¶ï¼Œ 需è¦æ³¨å†Œä¸ŠæŠ¥æ•°æ®å›žè°ƒå‡½æ•°ï¼Œä¼ 感器使能åŽï¼Œä¼ 感器æœåŠ¡ç”¨æˆ·å¯ä»¥æŽ¥å—åˆ°ä¼ æ„Ÿå™¨æ•°æ®ï¼Œè¯¦è§[SensorInterface](_sensor_interface.md)。 [更多...](_sensor.md#recorddatacallback) | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [SensorStatus](_sensor.md#sensorstatus) { SENSOR_SUCCESS = 0, SENSOR_FAILURE = -1, SENSOR_NOT_SUPPORT = -2, SENSOR_INVALID_PARAM = -3, SENSOR_INVALID_SERVICE = -4, SENSOR_NULL_PTR = -5 } | å®šä¹‰ä¼ æ„Ÿå™¨æ¨¡å—返回值类型。 [更多...](_sensor.md#sensorstatus) | +| [SensorTypeTag](_sensor.md#sensortypetag) { SENSOR_TYPE_NONE = 0, SENSOR_TYPE_ACCELEROMETER = 1, SENSOR_TYPE_GYROSCOPE = 2, SENSOR_TYPE_PHOTOPLETHYSMOGRAPH = 3, SENSOR_TYPE_ELECTROCARDIOGRAPH = 4, SENSOR_TYPE_AMBIENT_LIGHT = 5, SENSOR_TYPE_MAGNETIC_FIELD = 6, SENSOR_TYPE_CAPACITIVE = 7, SENSOR_TYPE_BAROMETER = 8, SENSOR_TYPE_TEMPERATURE = 9, SENSOR_TYPE_HALL = 10, SENSOR_TYPE_GESTURE = 11, SENSOR_TYPE_PROXIMITY = 12, SENSOR_TYPE_HUMIDITY = 13, SENSOR_TYPE_MEDICAL_BEGIN = 128, SENSOR_TYPE_MEDICAL_END = 160, SENSOR_TYPE_PHYSICAL_MAX = 255, SENSOR_TYPE_ORIENTATION = 256, SENSOR_TYPE_GRAVITY = 257, SENSOR_TYPE_LINEAR_ACCELERATION = 258, SENSOR_TYPE_ROTATION_VECTOR = 259, SENSOR_TYPE_AMBIENT_TEMPERATURE = 260, SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 261, SENSOR_TYPE_GAME_ROTATION_VECTOR = 262, SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 263, SENSOR_TYPE_SIGNIFICANT_MOTION = 264, SENSOR_TYPE_PEDOMETER_DETECTION = 265, SENSOR_TYPE_PEDOMETER = 266, SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 277, SENSOR_TYPE_HEART_RATE = 278, SENSOR_TYPE_DEVICE_ORIENTATION = 279, SENSOR_TYPE_WEAR_DETECTION = 280, SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 281, SENSOR_TYPE_MAX } | å®šä¹‰ä¼ æ„Ÿå™¨ç±»åž‹æ ‡è¯†ã€‚ [更多...](_sensor.md#sensortypetag) | +| [SensorAccuracyType](_sensor.md#sensoraccuracytype) { SENSOR_NO_ACCURACY = 0, SENSOR_LOW_ACCURACY = 1, SENSOR_MEDIUM_ACCURACY = 2, SENSOR_HIGH_ACCURACY = 3, SENSOR_MAX_ACCURACY } | ä¼ æ„Ÿå™¨çš„ç²¾åº¦ç±»åž‹ã€‚ [更多...](_sensor.md#sensoraccuracytype) | +| [SensorRangeType](_sensor.md#sensorrangetype) { SENSOR_RANGE_LEVEL1 = 0, SENSOR_RANGE_LEVEL2 = 1, SENSOR_RANGE_LEVEL3 = 2, SENSOR_RANGE_LEVEL_MAX } | ä¼ æ„Ÿå™¨çš„é‡ç¨‹çº§åˆ«ã€‚ [更多...](_sensor.md#sensorrangetype) | +| [SensorModeType](_sensor.md#sensormodetype) { SENSOR_MODE_DEFAULT = 0, SENSOR_MODE_REALTIME = 1, SENSOR_MODE_ON_CHANGE = 2, SENSOR_MODE_ONE_SHOT = 3, SENSOR_MODE_FIFO_MODE = 4, SENSOR_MODE_MAX } | ä¼ æ„Ÿå™¨çš„å·¥ä½œæ¨¡å¼ã€‚ [更多...](_sensor.md#sensormodetype) | +| [SensorGroupType](_sensor.md#sensorgrouptype) { TRADITIONAL_SENSOR_TYPE = 0, MEDICAL_SENSOR_TYPE = 1, SENSOR_GROUP_TYPE_MAX } | æžšä¸¾ä¼ æ„Ÿå™¨çš„ç¡¬ä»¶æœåŠ¡ç»„。 [更多...](_sensor.md#sensorgrouptype) | + + +## **详细æè¿°** + +å®šä¹‰ä¼ æ„Ÿå™¨æ¨¡å—æ‰€ä½¿ç”¨çš„ä¼ æ„Ÿå™¨ç±»åž‹ï¼Œä¼ æ„Ÿå™¨ä¿¡æ¯ï¼Œä¼ 感器数æ®ç»“æž„ç‰æ•°æ®ç±»åž‹ã€‚ + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/thermal.md b/zh-cn/device-dev/reference/hdi-apis/thermal.md new file mode 100644 index 0000000000000000000000000000000000000000..d639a37e380cc8615bd0440eee3909523152865b --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/thermal.md @@ -0,0 +1,45 @@ +# Thermal + + +## **汇总** + + +### 文件 + + | 文件 | æè¿° | +| -------- | -------- | +| [IThermalCallback.idl](_i_thermal_callback_8idl.md) | 设备å‘çƒçŠ¶æ€çš„回调。 | +| [IThermalInterface.idl](_i_thermal_interface_8idl.md) | 设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ | +| [ThermalTypes.idl](_thermal_types_8idl.md) | 设备å‘çƒçŠ¶æ€ç›¸å…³çš„æ•°æ®ç±»åž‹ã€‚ | + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IThermalCallback](interface_i_thermal_callback.md) | 订阅设备å‘çƒçŠ¶æ€çš„回调。 [更多...](interface_i_thermal_callback.md) | +| [IThermalInterface](interface_i_thermal_interface.md) | 设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ [更多...](interface_i_thermal_interface.md) | +| [ThermalZoneInfo](_thermal_zone_info.md) | 设备å‘çƒçš„ä¿¡æ¯ã€‚ [更多...](_thermal_zone_info.md) | +| [HdfThermalCallbackInfo](_hdf_thermal_callback_info.md) | 设备å‘çƒçš„ä¿¡æ¯åˆ—表。 [更多...](_hdf_thermal_callback_info.md) | + + +### å˜é‡ + + | å˜é‡ å称 | æè¿° | +| -------- | -------- | +| package ohos.hdi.thermal.v1_0 | 设备温度管ç†æŽ¥å£çš„包路径 | + + +## **详细æè¿°** + +æ供设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ + +çƒæ¨¡å—为çƒæœåŠ¡æ供的设备温度管ç†ã€æŽ§åˆ¶åŠè®¢é˜…接å£ã€‚ æœåŠ¡èŽ·å–æ¤æ¨¡å—的对象或代ç†åŽï¼Œå¯ä»¥è°ƒç”¨ç›¸å…³çš„接å£ç®¡ç†ã€æŽ§åˆ¶å’Œè®¢é˜…设备温度。 + +**Since:** + +3.1 + +**Version:** + +1.0 diff --git a/zh-cn/application-dev/reference/native-apis/total.md b/zh-cn/device-dev/reference/hdi-apis/total.md similarity index 100% rename from zh-cn/application-dev/reference/native-apis/total.md rename to zh-cn/device-dev/reference/hdi-apis/total.md diff --git a/zh-cn/device-dev/reference/hdi-apis/types_8h.md b/zh-cn/device-dev/reference/hdi-apis/types_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d464901d79c2444c7a1e1910b598dbe89cd1b8a0 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/types_8h.md @@ -0,0 +1,61 @@ +# types.h + + +## **概述** + +**所属模å—:** + +[Camera](_camera.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::Camera::StreamInfo](_o_h_o_s_1_1_camera_1_1_stream_info.md) | æµä¿¡æ¯ï¼Œç”¨äºŽåˆ›å»ºæµæ—¶ä¼ 入相关的é…ç½®å‚数。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_info.md) | +| [OHOS::Camera::StreamAttribute](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | æµçš„属性。 [更多...](_o_h_o_s_1_1_camera_1_1_stream_attribute.md) | +| [OHOS::Camera::CaptureInfo](_o_h_o_s_1_1_camera_1_1_capture_info.md) | æ•èŽ·è¯·æ±‚的相关信æ¯ã€‚ [更多...](_o_h_o_s_1_1_camera_1_1_capture_info.md) | +| [OHOS::Camera::CaptureEndedInfo](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | æ•èŽ·ç»“æŸç›¸å…³ä¿¡æ¯ï¼Œç”¨äºŽæ•èŽ·ç»“æŸå›žè°ƒ **OnCaptureEnded**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) | +| [OHOS::Camera::CaptureErrorInfo](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | æµé”™è¯¯ä¿¡æ¯ï¼Œç”¨äºŽå›žè°ƒ **OnCaptureError**。 [更多...](_o_h_o_s_1_1_camera_1_1_capture_error_info.md) | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| **OHOS::Camera::CameraAbility** = CameraMetadata | Camera设备能力集åˆã€‚ | +| **OHOS::Camera::CameraSetting** = CameraMetadata | Camera设置å‚数,包括sensor帧率,3A相关å‚æ•°ç‰ã€‚ | +| **OHOS::Camera::MetaType** = int32_t | 整型。 | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [OHOS::Camera::CamRetCode](_camera.md#camretcode) : int32_t { OHOS::Camera::NO_ERROR = 0, OHOS::Camera::CAMERA_BUSY = -1, OHOS::Camera::INSUFFICIENT_RESOURCES = -2, OHOS::Camera::INVALID_ARGUMENT = -3, OHOS::Camera::METHOD_NOT_SUPPORTED = -4, OHOS::Camera::CAMERA_CLOSED = -5, OHOS::Camera::DEVICE_ERROR = -6 } | HDI接å£çš„返回值。 [更多...](_camera.md#camretcode) | +| [OHOS::Camera::ResultCallbackMode](_camera.md#resultcallbackmode) : int32_t { OHOS::Camera::PER_FRAME, OHOS::Camera::ON_CHANGED } | metadata的上报模å¼ã€‚ [更多...](_camera.md#resultcallbackmode) | +| [OHOS::Camera::OperationMode](_camera.md#operationmode) : int32_t { OHOS::Camera::NORMAL = 0 } | æµçš„使用模å¼ã€‚ [更多...](_camera.md#operationmode) | +| [OHOS::Camera::StreamIntent](_camera.md#streamintent) : int32_t { OHOS::Camera::PREVIEW = 0, OHOS::Camera::VIDEO = 1, OHOS::Camera::STILL_CAPTURE = 2, OHOS::Camera::POST_VIEW = 3, OHOS::Camera::ANALYZE = 4, OHOS::Camera::CUSTOM = 5 } | æµçš„类型。 [更多...](_camera.md#streamintent) | +| [OHOS::Camera::EncodeType](_camera.md#encodetype) : int32_t { OHOS::Camera::ENCODE_TYPE_NULL = 0, OHOS::Camera::ENCODE_TYPE_H264 = 1, OHOS::Camera::ENCODE_TYPE_H265 = 2, OHOS::Camera::ENCODE_TYPE_JPEG = 3 } | æµæ•°æ®çš„ç¼–ç 类型。 [更多...](_camera.md#encodetype) | +| [OHOS::Camera::StreamSupportType](_camera.md#streamsupporttype) : int32_t { OHOS::Camera::DYNAMIC_SUPPORTED, OHOS::Camera::RE_CONFIGURED_REQUIRED, OHOS::Camera::NOT_SUPPORTED } | 动æ€é…ç½®æµçš„切æ¢æ–¹å¼ï¼Œä½¿ç”¨åœºæ™¯å‚考 [IsStreamsSupported](_camera.md#isstreamssupported) 。 [更多...](_camera.md#streamsupporttype) | +| [OHOS::Camera::CameraStatus](_camera.md#camerastatus) { OHOS::Camera::UN_AVAILABLE = 0, OHOS::Camera::AVAILABLE = 1 } | Camera设备状æ€ã€‚ [更多...](_camera.md#camerastatus) | +| [OHOS::Camera::FlashlightStatus](_camera.md#flashlightstatus) : uint32_t { OHOS::Camera::FLASHLIGHT_OFF = 0, OHOS::Camera::FLASHLIGHT_ON = 1, OHOS::Camera::FLASHLIGHT_UNAVAILABLE = 2 } | 闪光ç¯çŠ¶æ€ã€‚ [更多...](_camera.md#flashlightstatus) | +| [OHOS::Camera::CameraEvent](_camera.md#cameraevent): uint32_t { OHOS::Camera::CAMERA_EVENT_DEVICE_ADD = 0, OHOS::Camera::CAMERA_EVENT_DEVICE_RMV = 1 } | Camera事件。 [更多...](_camera.md#cameraevent) | +| [OHOS::Camera::ErrorType](_camera.md#errortype) : uint32_t { OHOS::Camera::FATAL_ERROR = 0, OHOS::Camera::REQUEST_TIMEOUT = 1 } | 设备错误类型,用于设备错误回调 **OnError**。 [更多...](_camera.md#errortype) | +| [OHOS::Camera::StreamError](_camera.md#streamerror) { OHOS::Camera::UNKNOWN_ERROR = 0, OHOS::Camera::BUFFER_LOST = 1 } | æµé”™è¯¯ç±»åž‹ï¼Œç”¨äºŽæµé”™è¯¯ç±»åž‹ **CaptureErrorInfo**。 [更多...](_camera.md#streamerror) | + + +## **详细æè¿°** + +Camera模å—HDI接å£ä½¿ç”¨çš„æ•°æ®ç±»åž‹ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md b/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md new file mode 100644 index 0000000000000000000000000000000000000000..8de76492ce9026d0aea6c5a71bd5ca2ad479d361 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md @@ -0,0 +1,24 @@ +# AudioSceneDescriptor::SceneDesc + + +## **概述** + +**所属模å—:** + +[Audio](_audio.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [id](_audio.md#id) | 音频场景的ID。 | +| [desc](_audio.md#desc-35) | 以å—符串命å的音频场景。 | + + +## **详细æè¿°** + +音频场景æ述。 diff --git a/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md b/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md new file mode 100644 index 0000000000000000000000000000000000000000..3e1b3f060202249675ae58d842207e63f25152dd --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/union_port_cap.md @@ -0,0 +1,51 @@ +# PortCap + + +## **概述** + +**所属模å—:** + +[Codec](_codec.md) + + +## **汇总** + + +### Public 属性 + + | Public 属性 | æè¿° | +| -------- | -------- | +| [video](#video) | 视频编解ç 能力 | +| [audio](#audio) | 音频编解ç 能力 | + + +## **详细æè¿°** + +定义音视频编解ç 能力。 + + +## **ç±»æˆå‘˜å˜é‡è¯´æ˜Ž** + + +### audio + + +``` +AudioPortCap PortCap::audio +``` + +**æ述:** + +音频编解ç 能力 + + +### video + + +``` +VideoPortCap PortCap::video +``` + +**æ述:** + +视频编解ç 能力 diff --git a/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md b/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..4d075be4d50a0065bee81aa13f8f93b56c68876c --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/usb__info_8h.md @@ -0,0 +1,32 @@ +# usb_info.h + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信æ¯ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | +| [OHOS::USB::UsbInfo](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | USB设备信æ¯ç±»ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) | + + +## **详细æè¿°** + +USB驱动订阅模å—使用的数æ®ç±»åž‹ã€‚ + +**Since:** + +3.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..e8ca6691a0b58d02be9447301431287af1273c80 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/usbd__client_8h.md @@ -0,0 +1,31 @@ +# usbd_client.h + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::USB::UsbdClient](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | USB驱动类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) | + + +## **详细æè¿°** + +å£°æ˜Žæ ‡å‡†USB驱动接å£å‡½æ•°ã€‚ + +**Since:** + +3.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..5bddc2d6b20509f2b5d0cfd6b7be46ee5503f7b7 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/usbd__subscriber_8h.md @@ -0,0 +1,31 @@ +# usbd_subscriber.h + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::USB::UsbdSubscriber](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | USB订阅类。[更多...](_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) | + + +## **详细æè¿°** + +USB驱动订阅模å—。 + +**Since:** + +3.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..a8a3c6bdb08dc9fa640877e6569b59c5af4b287f --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/usbd__type_8h.md @@ -0,0 +1,67 @@ +# usbd_type.h + + +## **概述** + +**所属模å—:** + +[USB](_u_s_b.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [OHOS::USB::UsbDev](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | USB设备。 [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) | +| [OHOS::USB::UsbPipe](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | 管é“ä¿¡æ¯ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) | +| [OHOS::USB::UsbCtrlTransfer](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | USBæŽ§åˆ¶ä¼ è¾“ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) | +| [OHOS::USB::USBDeviceInfo](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | USB设备信æ¯ã€‚ [更多...](_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [USB_MAX_INTERFACES](_u_s_b.md#usbmaxinterfaces) 32 | USB设备最大接å£æ•°é‡ã€‚ | + +### é™æ€å¸¸é‡ + + | é™æ€å¸¸é‡ | æè¿° | +| -------- | -------- | +| [USB_ENDPOINT_DIR_MASK](_u_s_b.md#usb\_endpoint\_dir\_mask) 0x80 | 从地å€ä¸æå–USB Endpointæ–¹å‘çš„ä½æŽ©ç 。 | +| [USB_ENDPOINT_DIR_IN](_u_s_b.md#usb\_endpoint\_dir\_in) 0x80 | USB Endpoint从设备到主机的数æ®æ–¹å‘。 | +| [USB_ENDPOINT_DIR_OUT](_u_s_b.md#usb\_endpoint\_dir\_out) 0 | USB Endpoint从主机到设备的数æ®æ–¹å‘。 | + + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([UsbdRequestCallback](_u_s_b.md#usbdrequestcallback)) (uint8_t \*requestArg) | 请求回调函数。 | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [UsbdBulkCbCmd](_u_s_b.md#usbdbulkcbcmd) { CMD_USBD_BULK_CALLBACK_READ, CMD_USBD_BULK_CALLBACK_WRITE } | 批é‡å›žè°ƒå‘½ä»¤å—。 [更多...](_u_s_b.md#usbdbulkcbcmd) | +| [UsbdDeviceAction](_u_s_b.md#usbddeviceaction) { ACT_DEVUP = 0, ACT_DEVDOWN, ACT_UPDEVICE, ACT_DOWNDEVICE } | 主机端和设备端æ’拔事件。 [更多...](_u_s_b.md#usbddeviceaction) | + + +## **详细æè¿°** + +USB驱动模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹ã€‚ + +USB驱动模å—接å£å®šä¹‰ä¸ä½¿ç”¨çš„自定义数æ®ç±»åž‹, 包括分å‘的命令å—ã€æ•°æ®æ–¹å‘ç‰ã€‚ + +**Since:** + +3.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md b/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..29b0c3a7c21a41ed4c0ae62ab3d56da43c59c3ea --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/vibrator__if_8h.md @@ -0,0 +1,39 @@ +# vibrator_if.h + + +## **概述** + +**所属模å—:** + +[Vibrator](_vibrator.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [VibratorInterface](_vibrator_interface.md) | æä¾›Vibrator设备基本控制æ“作接å£ã€‚ | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [NewVibratorInterfaceInstance](_vibrator.md#newvibratorinterfaceinstance) (void) | 创建一个VibratorInterface实例。 [更多...](_vibrator.md#newvibratorinterfaceinstance) | +| [FreeVibratorInterfaceInstance](_vibrator.md#freevibratorinterfaceinstance) (void) | 释放VibratorInterface实例以åŠç›¸å…³èµ„æºã€‚ [更多...](_vibrator.md#freevibratorinterfaceinstance) | + + +## **详细æè¿°** + +定义马达数æ®ç»“构,包括马达模å¼å’Œæ•ˆæžœæŒ¯åŠ¨ã€‚ + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md b/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..1abb949a8c7e380abacb367d82feffd85471982d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/vibrator__type_8h.md @@ -0,0 +1,33 @@ +# vibrator_type.h + + +## **概述** + +**所属模å—:** + +[Vibrator](_vibrator.md) + + +## **汇总** + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [VibratorMode](_vibrator.md#vibratormode) { VIBRATOR_MODE_ONCE = 0, VIBRATOR_MODE_PRESET = 1, VIBRATOR_MODE_BUTT } | 枚举马达振动模å¼ã€‚ [更多...](_vibrator.md#vibratormode) | +| [VibratorStatus](_vibrator.md#vibratorstatus) { VIBRATOR_SUCCESS = 0, VIBRATOR_NOT_PERIOD = -1, VIBRATOR_NOT_INTENSITY = -2, VIBRATOR_NOT_FREQUENCY= -3} | 枚举马达振动模å¼ã€‚[更多...](_vibrator.md#vibratorstatus) | +| [VibratorInfo](_vibrator.md#vibratorinfo) { isSupportIntensity, isSupportFrequency, intensityMaxValue, intensityMinValue, frequencyMaxValue, frequencyMinValue} | 定义马达å‚数。[更多...](_vibrator.md#vibratorinfo) | + + +## **详细æè¿°** + +定义马达数æ®ç»“构,包括马达模å¼å’Œæ•ˆæžœæŒ¯åŠ¨ã€‚ + +**Since:** + +2.2 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..ce0a6c3e0386722de46f68519df51ef20ba04ce5 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/wifi__hal_8h.md @@ -0,0 +1,46 @@ +# wifi_hal.h + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IWiFi](_i_wi_fi.md) | HAL对WLANæœåŠ¡æ供的基本能力。 [更多...](_i_wi_fi.md) | + + +### 类型定义 + + | 类型定义 | æè¿° | +| -------- | -------- | +| ([CallbackFunc](_w_l_a_n.md#callbackfunc)) (uint32_t event, void \*data, const char \*ifName) | 定义IWiFi回调函数的原型,监å¬å¼‚æ¥äº‹ä»¶ã€‚ [更多...](_w_l_a_n.md#callbackfunc) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [WifiConstruct](_w_l_a_n.md#wificonstruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 创建IWiFi结构体,挂接[IWiFi](_i_wi_fi.md)ä¸èƒ½åŠ›æŽ¥å£ã€‚ [更多...](_w_l_a_n.md#wificonstruct) | +| [WifiDestruct](_w_l_a_n.md#wifidestruct) (struct [IWiFi](_i_wi_fi.md) \*\*wifiInstance) | 销æ¯IWiFi结构体并释放相关资æºã€‚ [更多...](_w_l_a_n.md#wifidestruct) | + + +## **详细æè¿°** + +æ供给WLANæœåŠ¡çš„WLAN基本能力接å£ã€‚ + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..5070b56b1ba8a62600a9a0486c7125d2ed457e9d --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__ap__feature_8h.md @@ -0,0 +1,39 @@ +# wifi_hal_ap_feature.h + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [StaInfo](_sta_info.md) | æ述与AP连接的STAçš„åŸºæœ¬ä¿¡æ¯ [更多...](_sta_info.md) | +| [IWiFiAp](_i_wi_fi_ap.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,并包å«AP模å¼ä¸‹èŽ·å–连接STAçš„ä¿¡æ¯å’Œè®¾ç½®å›½å®¶ç 的功能。 [更多...](_i_wi_fi_ap.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [InitApFeature](_w_l_a_n.md#initapfeature) (struct [IWiFiAp](_i_wi_fi_ap.md) \*\*fe) | åˆå§‹åŒ–AP特性。WLANæœåŠ¡åœ¨åˆ›å»ºAP类型的特性[FeatureType](_w_l_a_n.md#featuretype)时调用。 [更多...](_w_l_a_n.md#initapfeature) | + + +## **详细æè¿°** + +æä¾›WLANçš„AP特性能力(获å–与AP连接的STA的基本信æ¯ã€è®¾ç½®å›½å®¶ç )。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..2507aeda6f531039f93e9db3bcb511b06f6622f3 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__base__feature_8h.md @@ -0,0 +1,54 @@ +# wifi_hal_base_feature.h + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IWiFiBaseFeature](_i_wi_fi_base_feature.md) | WLAN基本特性æ“作接å£ï¼ŒåŒ…括获å–网å¡å称,设置MAC地å€ï¼Œè®¾ç½®å‘射功率ç‰å…¬å…±èƒ½åŠ›æŽ¥å£ã€‚ [更多...](_i_wi_fi_base_feature.md) | + + +### å®å®šä¹‰ + + | å®å®šä¹‰ | æè¿° | +| -------- | -------- | +| [IFNAME_MAX_LEN](_w_l_a_n.md#ga63637ece87095ff8d153f650434ecf97) 16 | 网å¡å称最大长度。 | +| [WIFI_MAC_ADDR_LENGTH](_w_l_a_n.md#ga27ea7645cf89c113dae48346e19a676f) 6 | WLANçš„MAC地å€é•¿åº¦ã€‚ | +| [ERR_UNAUTH_ACCESS](_w_l_a_n.md#gadfe9ac5a374d348cd8f77a84cd5ab94e) (-6) | 定义访问失败错误ç 。 | + + +### 枚举 + + | 枚举 | æè¿° | +| -------- | -------- | +| [FeatureType](_w_l_a_n.md#featuretype) { PROTOCOL_80211_IFTYPE_UNSPECIFIED, PROTOCOL_80211_IFTYPE_ADHOC, PROTOCOL_80211_IFTYPE_STATION, PROTOCOL_80211_IFTYPE_AP, PROTOCOL_80211_IFTYPE_AP_VLAN, PROTOCOL_80211_IFTYPE_WDS, PROTOCOL_80211_IFTYPE_MONITOR, PROTOCOL_80211_IFTYPE_MESH_POINT, PROTOCOL_80211_IFTYPE_P2P_CLIENT, PROTOCOL_80211_IFTYPE_P2P_GO, PROTOCOL_80211_IFTYPE_P2P_DEVICE, PROTOCOL_80211_IFTYPE_NUM } | 枚举WLAN相关特性的类型[FeatureType](_w_l_a_n.md#featuretype)。 [更多...](_w_l_a_n.md#featuretype) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [InitBaseFeature](_w_l_a_n.md#initbasefeature) (struct [IWiFiBaseFeature](_i_wi_fi_base_feature.md) \*\*fe) | WLANæœåŠ¡åˆ›å»ºä»»ä½•ç±»åž‹çš„特性{\@Link FeatureType}时,都需è¦è°ƒç”¨æ¤å‡½æ•°ã€‚ [更多...](_w_l_a_n.md#initbasefeature) | + + +## **详细æè¿°** + +æä¾›WLAN基本特性能力。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..66cf5f1a520a17a27b8806a589916e124d362d23 --- /dev/null +++ b/zh-cn/device-dev/reference/hdi-apis/wifi__hal__sta__feature_8h.md @@ -0,0 +1,38 @@ +# wifi_hal_sta_feature.h + + +## **概述** + +**所属模å—:** + +[WLAN](_w_l_a_n.md) + + +## **汇总** + + +### ç±» + + | ç±» | æè¿° | +| -------- | -------- | +| [IWiFiSta](_i_wi_fi_sta.md) | 继承了[IWiFiBaseFeature](_i_wi_fi_base_feature.md)基本特性,é¢å¤–包å«è®¾ç½®æ‰«æå•ä¸ªMAC地å€åŠŸèƒ½ã€‚ [更多...](_i_wi_fi_sta.md) | + + +### 函数 + + | 函数 | æè¿° | +| -------- | -------- | +| [InitStaFeature](_w_l_a_n.md#initstafeature) (struct [IWiFiSta](_i_wi_fi_sta.md) \*\*fe) | åˆå§‹åŒ–STA特性。WLANæœåŠ¡åœ¨åˆ›å»ºSTA类型的特性[FeatureType](_w_l_a_n.md#featuretype)时调用。 [更多...](_w_l_a_n.md#initstafeature) | + + +## **详细æè¿°** + +æä¾›WLANçš„STA特性能力。 + +**Since:** + +1.0 + +**Version:** + +1.0 diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 5d1288e335f52ae4c05825376e4d2931fa6657f5..d93db2c101cf19d4e158414e257abb588ee14953 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -74,10 +74,15 @@ - [设备安全ç‰çº§ç®¡ç†å¼€å‘指导](subsys-security-devicesecuritylevel.md) - å¯åŠ¨æ¢å¤ - [å¯åŠ¨æ¢å¤å系统概述](subsys-boot-overview.md) - - [initå¯åŠ¨å¼•å¯¼ç»„件](subsys-boot-init.md) + - initå¯åŠ¨å¼•å¯¼ç»„件 + - [引导å¯åŠ¨é…置文件](subsys-boot-init-cfg.md) + - [jobs管ç†](subsys-boot-init-jobs.md) + - [æœåŠ¡ç®¡ç†](subsys-boot-init-service.md) + - [系统å‚æ•°](subsys-boot-init-sysparam.md) + - [沙盒管ç†](subsys-boot-init-sandbox.md) + - [æ’件](subsys-boot-init-plugin.md) - [appspawn应用åµåŒ–组件](subsys-boot-appspawn.md) - [bootstrapæœåŠ¡å¯åŠ¨ç»„件](subsys-boot-bootstrap.md) - - [syspara系统属性组件](subsys-boot-syspara.md) - [常è§é—®é¢˜](subsys-boot-faqs.md) - [å‚考](subsys-boot-ref.md) - [测试用例开å‘指导](subsys-testguide-test.md) diff --git a/zh-cn/device-dev/subsystems/figures/Hiview_module_data_interaction.png b/zh-cn/device-dev/subsystems/figures/Hiview_module_data_interaction.png index 87f67eef3f467d7ac59f2a877ae0e3ac8bb84c07..ea50df9c793f5192c17e9598970273659ecd4870 100644 Binary files a/zh-cn/device-dev/subsystems/figures/Hiview_module_data_interaction.png and b/zh-cn/device-dev/subsystems/figures/Hiview_module_data_interaction.png differ diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md b/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md index 1f80a4874cc967d60a9a6a933c7579873952be0a..87ce0460bb5d2966f2ab221ceb19a0801d0c54d0 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-demo-sdk.md @@ -9,21 +9,21 @@ KWSSdk(); virtual ~KWSSdk(); - // 定义创建唤醒è¯æ£€æµ‹å·¥å…·åŒ…的方法。 + // 定义创建唤醒è¯æ£€æµ‹å·¥å…·åŒ…的方法 int32_t Create(); - // 定义åŒæ¥æ‰§è¡Œå”¤é†’è¯æ£€æµ‹ä»»åŠ¡çš„方法。 + // 定义åŒæ¥æ‰§è¡Œå”¤é†’è¯æ£€æµ‹ä»»åŠ¡çš„方法 int32_t SyncExecute(const Array<int16_t> &audioInput); // 定义设置唤醒è¯æ£€æµ‹å›žè°ƒå™¨çš„方法。 int32_t SetCallback(const std::shared_ptr<KWSCallback> &callback); - // 定义销æ¯å”¤é†’è¯å·¥å…·åŒ…的方法,释放与æ’件的会è¯ä¿¡æ¯ã€‚ + // 定义销æ¯å”¤é†’è¯å·¥å…·åŒ…的方法,释放与æ’件的会è¯ä¿¡æ¯ int32_t Destroy(); }; ``` -2. 在//foundation/ai/engine/services/client/algorithm_sdk目录ä¸å¢žåŠ SDKä¸API接å£çš„具体实现,调用client端æ供的接å£ï¼Œå®žçŽ°ç®—法æ’件能力的使用。如下代ç 片段å³ä¸ºå”¤é†’è¯è¯†åˆ«çš„API接å£ä¸create方法的具体实现示例,更多详细代ç å¯å‚考://foundation/ai/engine/services/client/algorithm_sdk/asr/keyword_spotting。 +2. 在//foundation/ai/engine/services/client/algorithm_sdk目录ä¸å¢žåŠ SDKä¸API接å£çš„具体实现,调用client端æ供的接å£ï¼Œå®žçŽ°ç®—法æ’件能力的使用。如下代ç 片段å³ä¸ºå”¤é†’è¯è¯†åˆ«çš„API接å£ä¸create方法的具体实现示例,更多详细代ç 请å‚考://foundation/ai/engine/services/client/algorithm_sdk/asr/keyword_spotting。 ``` int32_t KWSSdk::KWSSdkImpl::Create() @@ -36,7 +36,7 @@ HILOGE("[KWSSdkImpl]Fail to init sdk components"); return KWS_RETCODE_FAILURE; } - // 调用client端æ供的接å£AieClientInit,实现åˆå§‹åŒ–引擎æœåŠ¡ï¼Œæ¿€æ´»è·¨è¿›ç¨‹è°ƒç”¨ + // 调用client端æ供的AieClientInit接å£ï¼Œå®žçŽ°åˆå§‹åŒ–引擎æœåŠ¡ï¼Œæ¿€æ´»è·¨è¿›ç¨‹è°ƒç”¨ int32_t retCode = AieClientInit(configInfo_, clientInfo_, algorithmInfo_, nullptr); if (retCode != RETCODE_SUCCESS) { HILOGE("[KWSSdkImpl]AieClientInit failed. Error code[%d]", retCode); @@ -54,7 +54,7 @@ .data = nullptr, .length = 0, }; - // 调用client端æ供的接å£AieClientPrepareï¼Œå®žçŽ°åŠ è½½ç®—æ³•æ’件 + // 调用client端æ供的AieClientPrepare接å£ï¼Œå®žçŽ°åŠ 载算法æ’件 retCode = AieClientPrepare(clientInfo_, algorithmInfo_, inputInfo, outputInfo, nullptr); if (retCode != RETCODE_SUCCESS) { HILOGE("[KWSSdkImpl]AieclientPrepare failed. Error code[%d]", retCode); @@ -74,7 +74,8 @@ } ``` - 上述代ç 为API接å£çš„具体实现,从上述示例的代ç ä¸ï¼ŒSDKä¸create接å£çš„具体实现å³ä¸ºä¸Šè¿°ç¤ºä¾‹ä»£ç ä¸create方法,该方法调用了AI引擎框架client端开放接å£AieClientInit,AieClientPrepare,从而实现与server端建立连接åŠåŠ 载算法模型的能力。 + 上述代ç 为API接å£çš„具体实现。在示例代ç ä¸ï¼ŒSDKä¸create接å£çš„具体实现å³ä¸ºä¸Šè¿°ç¤ºä¾‹ä»£ç ä¸create方法,该方法调用了AI引擎框架client端æ供的AieClientInitåŠAieClientPrepare接å£ï¼Œä»Žè€Œå®žçŽ°ä¸Žserver端建立连接åŠåŠ 载算法模型的能力。 - >  **说明:**<br> + >  **说明:** + > > SDK调用AI引擎client端接å£åº”éµå¾ªAieClientInit->AieClientPrepare->AieClientSyncProcess/AieClientAsyncProcess->AieClientRelease->AieClientDestroy顺åºï¼Œå¦åˆ™è°ƒç”¨æŽ¥å£ä¼šè¿”回错误ç 。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md index 598a744eb0f8694ad238415e23d324fda3fda055..d082cc359fab9b9cb72cc9f521192c6ad1c71ea0 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-plugin.md @@ -13,12 +13,12 @@ AI引擎框架规定了一套算法æ’件接入规范,å„æ’件需实现规定 | -------- | -------- | -------- | | const long long GetVersion() const; | **作用**:获å–æ’件版本信æ¯ã€‚<br/>**返回值**:版本å·ï¼ˆlong long) | - | | const char \*GetInferMode() const; | **作用**:获å–算法推ç†ç±»åž‹ã€‚<br/>**返回值**:"SYNC" or "ASYNC"; | - | -| int SyncProcess(IRequest \*request,<br/>IResponse \*&response); | **作用**:执行æ’件åŒæ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **request**(NOT NULL):用于å‘算法æ’ä»¶ä¼ é€’è¯·æ±‚å†…å®¹ï¼›å¼•æ“ŽæœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“ï¼›<br/>**response**(NOT NULL):作为出å‚用于接收算法æ’件å‘回的åŒæ¥ç®—法执行结果,引擎æœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“ï¼› | -| int AsyncProcess(IRequest \*request,<br/>IPluginAlgorithmCallback \*callback); | **作用**:执行异æ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **request**(NOT NULL):用于å‘算法æ’ä»¶ä¼ é€’è¯·æ±‚å†…å®¹ï¼›å¼•æ“ŽæœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“。<br/>**callback**(NOT NULL):算法æ’件异æ¥æ‰§è¡Œç»“果通过æ¤å›žè°ƒè¿”回引擎æœåŠ¡ç«¯ï¼› | -| int Prepare(long long transactionId,<br/>const DataInfo &inputInfo, DataInfo<br/>&outputInfo); | **作用**ï¼šåŠ è½½ç®—æ³•æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **transactionId**(NOT NULL):事务IDï¼Œç”¨äºŽæ ‡è®°å®¢æˆ·ç«¯+会è¯ä¿¡æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL)ï¼šåŠ è½½ç®—æ³•æ’ä»¶ä¼ å…¥çš„ä¸€äº›ä¿¡æ¯ï¼›<br/>**outputInfo**(å¯ä¸ºNULL)ï¼šè°ƒç”¨åŠ è½½æŽ¥å£æ—¶çš„出å‚,返回相关执行结果; | -| int Release(bool isFullUnload, long long<br/>transactionId, const DataInfo &inputInfo); | **作用**:å¸è½½ç›¸å…³ç®—法æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **isFullUnload**(NOT NULL):表示æ¤æ’件是å¦åªå‰©ä¸€ä¸ªclient调用,å¦åˆ™ä¸èƒ½ç›´æŽ¥å¸è½½æ’件,需ç‰æœ€åŽä¸€ä¸ªclientæ¥è¿›è¡Œå¸è½½ï¼›<br/>**transactionId**(NOT NULL):事务IDï¼Œç”¨äºŽæ ‡è®°å®¢æˆ·ç«¯+会è¯ä¿¡æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):å¸è½½ç®—法æ’ä»¶ä¼ å…¥çš„ä¸€äº›ä¿¡æ¯ï¼› | -| int SetOption(int optionType, const<br/>DataInfo &inputInfo); | **作用**:设置é…置项,å¯å°†ä¸€äº›ç®—法的拓展信æ¯é€šè¿‡æ¤æŽ¥å£ä¼ å…¥æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **optionType** (NOT NULL):算法é…置项,算法æ’件å¯æ ¹æ®éœ€è¦åˆ©ç”¨æ¤çŠ¶æ€ä½ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):æ’件å¯æ ¹æ®éœ€è¦é€šè¿‡æ¤å…¥å‚设置算法å‚æ•°ä¿¡æ¯ï¼› | -| int GetOption(int optionType, const<br/>DataInfo &inputInfo, DataInfo<br/>&outputInfo); | **作用**:给定特定的optionTypeå’ŒinputInfo,获å–其对应的é…置项信æ¯ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **optionType**(NOT NULL):所获å–é…置项信æ¯çš„对应算法状æ€ä½ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):所获å–é…置项信æ¯çš„对应算法å‚æ•°ä¿¡æ¯ï¼›<br/>**outputInfo**(å¯ä¸ºNULL):所è¦èŽ·å–çš„é…置项信æ¯è¿”回结果; | +| int SyncProcess(IRequest \*request,<br/>IResponse \*&response); | **作用**:执行æ’件åŒæ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **request**(NOT NULL):用于å‘算法æ’ä»¶ä¼ é€’è¯·æ±‚å†…å®¹ï¼›å¼•æ“ŽæœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“。<br/>**response**(NOT NULL):作为出å‚用于接收算法æ’件å‘回的åŒæ¥ç®—法执行结果,引擎æœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“。 | +| int AsyncProcess(IRequest \*request,<br/>IPluginAlgorithmCallback \*callback); | **作用**:执行异æ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **request**(NOT NULL):用于å‘算法æ’ä»¶ä¼ é€’è¯·æ±‚å†…å®¹ï¼›å¼•æ“ŽæœåŠ¡ç«¯ä¸Žæ’件的数æ®é€šé“。<br/>**callback**(NOT NULL):算法æ’件异æ¥æ‰§è¡Œç»“果通过æ¤å›žè°ƒè¿”回引擎æœåŠ¡ç«¯ã€‚ | +| int Prepare(long long transactionId,<br/>const DataInfo &inputInfo, DataInfo<br/>&outputInfo); | **作用**ï¼šåŠ è½½ç®—æ³•æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **transactionId**(NOT NULL):事务IDï¼Œç”¨äºŽæ ‡è®°å®¢æˆ·ç«¯+会è¯ä¿¡æ¯ã€‚<br/>**inputInfo**(å¯ä¸ºNULL)ï¼šåŠ è½½ç®—æ³•æ’ä»¶ä¼ å…¥çš„ä¸€äº›ä¿¡æ¯ã€‚<br/>**outputInfo**(å¯ä¸ºNULL)ï¼šè°ƒç”¨åŠ è½½æŽ¥å£æ—¶çš„出å‚,返回相关执行结果。 | +| int Release(bool isFullUnload, long long<br/>transactionId, const DataInfo &inputInfo); | **作用**:å¸è½½ç›¸å…³ç®—法æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **isFullUnload**(NOT NULL):表示æ¤æ’件是å¦åªå‰©ä¸€ä¸ªclient调用,å¦åˆ™ä¸èƒ½ç›´æŽ¥å¸è½½æ’件,需ç‰æœ€åŽä¸€ä¸ªclientæ¥è¿›è¡Œå¸è½½ã€‚<br/>**transactionId**(NOT NULL):事务IDï¼Œç”¨äºŽæ ‡è®°å®¢æˆ·ç«¯+会è¯ä¿¡æ¯ã€‚<br/>**inputInfo**(å¯ä¸ºNULL):å¸è½½ç®—法æ’ä»¶ä¼ å…¥çš„ä¸€äº›ä¿¡æ¯ã€‚ | +| int SetOption(int optionType, const<br/>DataInfo &inputInfo); | **作用**:设置é…置项,å¯å°†ä¸€äº›ç®—法的拓展信æ¯é€šè¿‡æ¤æŽ¥å£ä¼ å…¥æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **optionType** (NOT NULL):算法é…置项,算法æ’件å¯æ ¹æ®éœ€è¦åˆ©ç”¨æ¤çŠ¶æ€ä½ã€‚<br/>**inputInfo**(å¯ä¸ºNULL):æ’件å¯æ ¹æ®éœ€è¦é€šè¿‡æ¤å…¥å‚设置算法å‚æ•°ä¿¡æ¯ã€‚ | +| int GetOption(int optionType, const<br/>DataInfo &inputInfo, DataInfo<br/>&outputInfo); | **作用**:给定特定的optionTypeå’ŒinputInfo,获å–其对应的é…置项信æ¯ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值为失败。 | **optionType**(NOT NULL):所获å–é…置项信æ¯çš„对应算法状æ€ä½ã€‚<br/>**inputInfo**(å¯ä¸ºNULL):所获å–é…置项信æ¯çš„对应算法å‚æ•°ä¿¡æ¯ã€‚<br/>**outputInfo**(å¯ä¸ºNULL):所è¦èŽ·å–çš„é…置项信æ¯è¿”回结果。 | 算法æ’件类接å£ï¼šPrepareã€SyncProcessã€AsyncProcessã€Releaseã€SetOptionã€GetOption分别于客户端接å£AieClientPrepareã€AieClientSyncProcessã€AieClientAsyncProcessã€AieClientReleaseã€AieClientSetOptionã€AieClientGetOption一一对应;GetInferMode接å£ç”¨äºŽè¿”回算法执行类型——åŒæ¥æˆ–异æ¥ã€‚ @@ -31,10 +31,10 @@ AI引擎框架规定了一套算法æ’件接入规范,å„æ’件需实现规定 | 接å£å | 接å£è¯´æ˜Ž | å‚æ•°è¦æ±‚ | | -------- | -------- | -------- | -| void OnEvent(PluginEvent event,<br/>IResponse \*response); | 作用:æ’件通过æ¤å›žè°ƒè¿”回异æ¥ç®—法执行结果。 | **event**:算法执行结果枚举,‘ON_PLUGIN_SUCCEED’或 ‘ON_PLUGIN_FAIL’(æˆåŠŸæˆ–者失败);<br/>**response**:算法执行结果å°è£…ï¼› | +| void OnEvent(PluginEvent event,<br/>IResponse \*response); | 作用:æ’件通过æ¤å›žè°ƒè¿”回异æ¥ç®—法执行结果。 | **event**:算法执行结果枚举,‘ON_PLUGIN_SUCCEED’或 ‘ON_PLUGIN_FAIL’(æˆåŠŸæˆ–者失败)。<br/>**response**:算法执行结果å°è£…。 | -Requestã€Response是ai引擎æœåŠ¡ç«¯ä¸Žç®—法æ’件进行通信的对象。Requestå°è£…了调用方的请求ã€è¾“入数æ®ç‰ï¼Œè€Œæ’件主è¦é€šè¿‡Responseå°†è¿ç®—之åŽçš„结果返回给AI引擎æœåŠ¡ç«¯ã€‚ +Requestã€Response是AI引擎æœåŠ¡ç«¯ä¸Žç®—法æ’件进行通信的对象。Requestå°è£…了调用方的请求ã€è¾“入数æ®ç‰ï¼Œè€Œæ’件主è¦é€šè¿‡Responseå°†è¿ç®—之åŽçš„结果返回给AI引擎æœåŠ¡ç«¯ã€‚ Request类的属性如下表所示。 @@ -46,7 +46,7 @@ Request类的属性如下表所示。 | -------- | -------- | -------- | | innerSequenceId_ | 类型:long long<br/>作用:暂未å¯ç”¨ã€‚ | 0 | | requestId_ | 类型:int<br/>ä½œç”¨ï¼šæ ‡è¯†è¯·æ±‚åºåˆ—,用于绑定返回è¿ç®—结果。 | 0 | -| operationId_ | 类型:int<br/>作用:目å‰æš‚未å¯ç”¨ã€‚ | 0 | +| operationId_ | 类型:int<br/>作用:暂未å¯ç”¨ã€‚ | 0 | | transactionId_ | 类型:long long<br/>作用:事务IDï¼Œå”¯ä¸€æ ‡è¯†clientId+sessionId。 | 0 | | algoPluginType_ | 类型:int<br/>ä½œç”¨ï¼šå¼•æ“Žæ¡†æž¶æ ¹æ®æ’ä»¶åŠ è½½é¡ºåºåˆ†é…的算法类型的ID。 | 0 | | msg_ | 类型:DataInfo<br/>作用:å˜æ”¾è°ƒç”¨ç®—法接å£çš„输入数æ®ã€‚ | .data = nullptr<br/>.length = 0 | diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md index 54b413dd6cc5cffb4ecc358c368f1ef593520851..83150d465bf78878ad6b1cabe6716d2c14c95cd6 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-devguide-sdk.md @@ -1,21 +1,21 @@ # SDKå¼€å‘过程 -SDK头文件的功能实现是基于对SDKçš„è°ƒç”¨æ˜ å°„åˆ°å¯¹å®¢æˆ·ç«¯çš„è°ƒç”¨ã€‚å®¢æˆ·ç«¯ç«¯æ供的接å£å¦‚下表所示。 +SDK头文件的功能实现是基于对SDKçš„è°ƒç”¨æ˜ å°„åˆ°å¯¹å®¢æˆ·ç«¯çš„è°ƒç”¨ã€‚Client端æ供的接å£å¦‚下表所示。 **表1** Client端æä¾›çš„æŽ¥å£ | 接å£å | 接å£è¯´æ˜Ž | å‚æ•°è¦æ±‚ | | -------- | -------- | -------- | -| int **AieClientInit**(const ConfigInfo &configInfo,<br/> ClientInfo &clientInfo, const AlgorithmInfo<br/> &algorithmInfo, IServiceDeadCb \*cb) | **作用**:链接并åˆå§‹åŒ–引擎æœåŠ¡ï¼Œæ¿€æ´»è·¨è¿›ç¨‹è°ƒç”¨ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **configInfo**(NOT NULL):引擎相关åˆå§‹åŒ–é…置数æ®ï¼›<br/>**clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**algorithmInfo**(NOT NULL):调用算法信æ¯ï¼›<br/>**cb**(å¯ä¸ºNULL):æ»äº¡å›žè°ƒ 对象; | -| int **AieClientPrepare**(const ClientInfo &clientInfo<br/>, const AlgorithmInfo &algorithmInfo, const DataInfo<br/> &inputInfo, DataInfo &outputInfo, IClientCb \*cb) | **作用**ï¼šåŠ è½½ç®—æ³•æ’件。<br/>**返回值**: 0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**algorithmInfo**(NOT NULL):调用算法信æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL)ï¼šåŠ è½½ç®—æ³•æ’件时输入所需信æ¯ï¼›<br/>**outputInfo**(å¯ä¸ºNULL)ï¼šåŠ è½½ç®—æ³•æ’件之åŽå¦‚需返回信æ¯åˆ™é€šè¿‡æ¤å‡ºå‚返回;<br/>**cb**:异æ¥ç®—法通过æ¤å›žè°ƒè¿”回è¿ç®—ç»“æžœï¼Œå› æ¤**异æ¥ç®—法æ¤ç»“构体ä¸èƒ½ä¸ºç©º**;若为åŒæ¥ç®—æ³•ï¼Œä¼ å…¥ç©ºå€¼å³å¯ï¼› | -| int **AieClientAsyncProcess**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const DataInfo<br/> &inputInfo) | **作用**:执行异æ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**algorithmInfo**(NOT NULL):调用算法信æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):算法è¿ç®—å…¥å‚ï¼› | -| int **AieClientSyncProcess**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const<br/> DataInfo &inputInfo, DataInfo &outputInfo) | **作用**:执行åŒæ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**algorithmInfo**(NOT NULL):调用算法信æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):算法è¿ç®—å…¥å‚ï¼›<br/>**outputInfo**(å¯ä¸ºNULL):åŒæ¥ç®—法è¿ç®—结果出å‚ï¼› | -| int **AieClientRelease**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const<br/> DataInfo &inputInfo) | **作用**:å¸è½½ç®—法æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**algorithmInfo**(NOT NULL):å¸è½½ç®—法æ’件的相关信æ¯ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):调用å¸è½½æŽ¥å£æ—¶çš„输入信æ¯ï¼› | -| int **AieClientDestroy**(ClientInfo &clientInfo) | **作用**:æ–开与æœåŠ¡ç«¯çš„链接,释放相关缓å˜ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):所è¦é”€æ¯çš„引擎客户端信æ¯ï¼› | -| int **AieClientSetOption**(const ClientInfo &clientInfo,<br/> int optionType, const DataInfo &inputInfo) | **作用**:设置é…置项,å¯å°†ä¸€äº›ç®—法的拓展信æ¯é€šè¿‡æ¤æŽ¥å£ä¼ å…¥æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**optionType** (NOT NULL):算法é…置项,算法æ’件å¯æ ¹æ®éœ€è¦åˆ©ç”¨æ¤çŠ¶æ€ä½ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):æ’件å¯æ ¹æ®éœ€è¦é€šè¿‡æ¤å…¥å‚设置算法å‚æ•°ä¿¡æ¯ï¼› | -| int **AieClientGetOption**(const ClientInfo &clientInfo,<br/> int optionType, const DataInfo &inputInfo,<br/> DataInfo &outputInfo) | **作用**:给定特定的optionTypeå’ŒinputInfo,获å–其对应的é…置项信æ¯ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(NOT NULL):引擎客户端信æ¯ï¼›<br/>**optionType**(NOT NULL):所获å–é…置项信æ¯çš„对应算法状æ€ä½ï¼›<br/>**inputInfo**(å¯ä¸ºNULL):所获å–é…置项信æ¯çš„对应算法å‚æ•°ä¿¡æ¯ï¼›<br/>**outputInfo**(å¯ä¸ºNULL):所è¦èŽ·å–çš„é…置项信æ¯è¿”回结果; | +| int **AieClientInit**(const ConfigInfo &configInfo,<br/> ClientInfo &clientInfo, const AlgorithmInfo<br/> &algorithmInfo, IServiceDeadCb \*cb) | **作用**:链接并åˆå§‹åŒ–引擎æœåŠ¡ï¼Œæ¿€æ´»è·¨è¿›ç¨‹è°ƒç”¨ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **configInfo**(ä¸èƒ½ä¸ºNULL):引擎相关åˆå§‹åŒ–é…ç½®æ•°æ® <br/>**clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**algorithmInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šè°ƒç”¨ç®—æ³•ä¿¡æ¯ <br/>**cb**(å¯ä¸ºNULL):æ»äº¡å›žè°ƒå¯¹è±¡ | +| int **AieClientPrepare**(const ClientInfo &clientInfo<br/>, const AlgorithmInfo &algorithmInfo, const DataInfo<br/> &inputInfo, DataInfo &outputInfo, IClientCb \*cb) | **作用**ï¼šåŠ è½½ç®—æ³•æ’件。<br/>**返回值**: 0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**algorithmInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šè°ƒç”¨ç®—æ³•ä¿¡æ¯ <br/>**inputInfo**(å¯ä¸ºNULLï¼‰ï¼šåŠ è½½ç®—æ³•æ’ä»¶æ—¶è¾“å…¥æ‰€éœ€ä¿¡æ¯ <br/>**outputInfo**(å¯ä¸ºNULLï¼‰ï¼šåŠ è½½ç®—æ³•æ’件之åŽå¦‚需返回信æ¯åˆ™é€šè¿‡æ¤å‡ºå‚返回 <br/>**cb**:异æ¥ç®—法通过æ¤å›žè°ƒè¿”回è¿ç®—ç»“æžœï¼Œå› æ¤**异æ¥ç®—法æ¤ç»“构体ä¸èƒ½ä¸ºç©º** 若为åŒæ¥ç®—æ³•ï¼Œä¼ å…¥ç©ºå€¼å³å¯ | +| int **AieClientAsyncProcess**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const DataInfo<br/> &inputInfo) | **作用**:执行异æ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**algorithmInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šè°ƒç”¨ç®—æ³•ä¿¡æ¯ <br/>**inputInfo**(å¯ä¸ºNULL):算法è¿ç®—å…¥å‚ | +| int **AieClientSyncProcess**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const<br/> DataInfo &inputInfo, DataInfo &outputInfo) | **作用**:执行åŒæ¥ç®—法。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**algorithmInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šè°ƒç”¨ç®—æ³•ä¿¡æ¯ <br/>**inputInfo**(å¯ä¸ºNULL):算法è¿ç®—å…¥å‚ <br/>**outputInfo**(å¯ä¸ºNULL):åŒæ¥ç®—法è¿ç®—ç»“æžœå‡ºå‚ | +| int **AieClientRelease**(const ClientInfo &clientInfo,<br/> const AlgorithmInfo &algorithmInfo, const<br/> DataInfo &inputInfo) | **作用**:å¸è½½ç®—法æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**algorithmInfo**(ä¸èƒ½ä¸ºNULL):å¸è½½ç®—法æ’ä»¶çš„ç›¸å…³ä¿¡æ¯ <br/>**inputInfo**(å¯ä¸ºNULL):调用å¸è½½æŽ¥å£æ—¶çš„è¾“å…¥ä¿¡æ¯ | +| int **AieClientDestroy**(ClientInfo &clientInfo) | **作用**:æ–开与æœåŠ¡ç«¯çš„链接,释放相关缓å˜ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULL):所è¦é”€æ¯çš„å¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ | +| int **AieClientSetOption**(const ClientInfo &clientInfo,<br/> int optionType, const DataInfo &inputInfo) | **作用**:设置é…置项,å¯å°†ä¸€äº›ç®—法的拓展信æ¯é€šè¿‡æ¤æŽ¥å£ä¼ å…¥æ’件。<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**optionType** (ä¸èƒ½ä¸ºNULL):算法é…置项,算法æ’件å¯æ ¹æ®éœ€è¦åˆ©ç”¨æ¤çŠ¶æ€ä½ <br/>**inputInfo**(å¯ä¸ºNULL):æ’件å¯æ ¹æ®éœ€è¦é€šè¿‡æ¤å…¥å‚设置算法å‚æ•°ä¿¡æ¯ | +| int **AieClientGetOption**(const ClientInfo &clientInfo,<br/> int optionType, const DataInfo &inputInfo,<br/> DataInfo &outputInfo) | **作用**:给定特定的optionTypeå’ŒinputInfo,获å–其对应的é…置项信æ¯ã€‚<br/>**返回值**:0为æˆåŠŸï¼Œå…¶ä»–返回值失败。 | **clientInfo**(ä¸èƒ½ä¸ºNULLï¼‰ï¼šå¼•æ“Žå®¢æˆ·ç«¯ä¿¡æ¯ <br/>**optionType**(ä¸èƒ½ä¸ºNULL):所获å–é…置项信æ¯çš„对应算法状æ€ä½ <br/>**inputInfo**(å¯ä¸ºNULL):所获å–é…置项信æ¯çš„对应算法å‚æ•°ä¿¡æ¯ <br/>**outputInfo**(å¯ä¸ºNULL):所è¦èŽ·å–çš„é…置项信æ¯è¿”回结果 | å…¶ä¸ï¼ŒConfigInfo,ClientInfo,AlgorithmInfo,DataInfoçš„æ•°æ®ç»“构如下表所示。 @@ -25,10 +25,10 @@ SDK头文件的功能实现是基于对SDKçš„è°ƒç”¨æ˜ å°„åˆ°å¯¹å®¢æˆ·ç«¯çš„è°ƒ | 结构体å称 | 说明 | 属性 | | -------- | -------- | -------- | -| ConfigInfo | 算法é…置项信æ¯ã€‚ | **const char \*description**:é…置项信æ¯ä¸»ä½“ï¼› | -| ClientInfo | 客户端信æ¯ã€‚ | **long long clientVersion**:客户端设备版本å·ï¼ˆå½“å‰è¿˜æœªå¯ç”¨ï¼‰ï¼›<br/>**int clientId**:客户端IDï¼›<br/>**int sessionId:**会è¯IDï¼›<br/>**uid_t serverUid**:server端UIDï¼›<br/>**uid_t clientUid:**client端UIDï¼›<br/>**int extendLen**:拓展信æ¯ï¼ˆextendMsg)长度;<br/>**unsigned char \*extendMsg**:拓展信æ¯ä¸»ä½“ï¼› | -| AlgorithmInfo | 算法信æ¯ã€‚ | **long long clientVersion**:客户端设备版本å·ï¼ˆå½“å‰è¿˜æœªå¯ç”¨ï¼‰ï¼›<br/>**bool isAsync**:是å¦ä¸ºå¼‚æ¥æ‰§è¡Œï¼›<br/>**int algorithmType:**å¼•æ“Žæ¡†æž¶æ ¹æ®æ’ä»¶åŠ è½½é¡ºåºåˆ†é…的算法类型IDï¼›<br/>**long long algorithmVersion**:算法版本å·ï¼›<br/>**bool isCloud**:是å¦ä¸Šäº‘(当å‰è¿˜æœªå¯ç”¨ï¼‰ï¼›<br/>**int operateId**:执行ID(当å‰è¿˜æœªå¯ç”¨ï¼‰ï¼›<br/>**int requestId**:请求IDï¼Œæ ‡è¯†æ¯æ¬¡request,以对应执行结果;<br/>**int extendLen**:拓展信æ¯ï¼ˆextendMsg)长度;<br/>**unsigned char \*extendMsg**:拓展信æ¯ä¸»ä½“ï¼› | -| DataInfo | 算法数æ®å…¥å‚(inputInfo)ã€<br/>接å£è°ƒç”¨ç»“果出å‚(outputInfo)。 | **unsigned char \*data:**æ•°æ®ä¸»ä½“ï¼›<br/>**int length**:数æ®(data)长度; | +| ConfigInfo | 算法é…置项信æ¯ã€‚ | **const char \*description**:é…置项信æ¯ä¸»ä½“ | +| ClientInfo | 客户端信æ¯ã€‚ | **long long clientVersion**:客户端设备版本å·ï¼ˆå½“å‰è¿˜æœªå¯ç”¨ï¼‰ <br/>**int clientId**:客户端ID <br/>**int sessionId**:会è¯ID <br/>**uid_t serverUid**:server端UID <br/>**uid_t clientUid**:client端UID <br/>**int extendLen**:拓展信æ¯ï¼ˆextendMsg)长度 <br/>**unsigned char \*extendMsg**:拓展信æ¯ä¸»ä½“ | +| AlgorithmInfo | 算法信æ¯ã€‚ | **long long clientVersion**:客户端设备版本å·ï¼ˆå½“å‰è¿˜æœªå¯ç”¨ï¼‰ <br/>**bool isAsync**:是å¦ä¸ºå¼‚æ¥æ‰§è¡Œ <br/>**int algorithmType**ï¼šå¼•æ“Žæ¡†æž¶æ ¹æ®æ’ä»¶åŠ è½½é¡ºåºåˆ†é…的算法类型ID <br/>**long long algorithmVersion**ï¼šç®—æ³•ç‰ˆæœ¬å· <br/>**bool isCloud**:是å¦ä¸Šäº‘(当å‰è¿˜æœªå¯ç”¨ï¼‰ <br/>**int operateId**:执行ID(当å‰è¿˜æœªå¯ç”¨ï¼‰ <br/>**int requestId**:请求IDï¼Œæ ‡è¯†æ¯æ¬¡request,以对应执行结果 <br/>**int extendLen**:拓展信æ¯ï¼ˆextendMsg)长度 <br/>**unsigned char \*extendMsg**:拓展信æ¯ä¸»ä½“ | +| DataInfo | 算法数æ®å…¥å‚(inputInfo)ã€<br/>接å£è°ƒç”¨ç»“果出å‚(outputInfo)。 | **unsigned char \*data**:数æ®ä¸»ä½“ <br/>**int length**:数æ®(data)长度 | 具体开å‘过程å¯å‚考[唤醒è¯è¯†åˆ«SDKå¼€å‘示例](../subsystems/subsys-aiframework-demo-sdk.md)。 diff --git a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md index 659600d23bd24647f465f3e50c528c3393057e0d..8d0c3224f4dd2758f4b9479f998421414c56602e 100644 --- a/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md +++ b/zh-cn/device-dev/subsystems/subsys-aiframework-tech-codemanage.md @@ -17,14 +17,16 @@ AI引擎框架å„模å—之间的代ç ä¾èµ–关系如下图所示: 在AI引擎框架的整体规划ä¸ï¼ŒåŒ—å‘SDK属于client端的一部分,æ’件由server端调用,属于serverç«¯çš„ä¸€éƒ¨åˆ†ï¼Œå› æ¤AI引擎框架为接入的æ’件与北å‘SDK规划的路径: - SDK代ç 路径://foundation/ai/engine/services/client/algorithm_sdk - e.g. //foundation/ai/engine/services/client/algorithm_sdk/cv + + 示例1://foundation/ai/engine/services/client/algorithm_sdk/cv - e.g. //foundation/ai/engine/services/client/algorithm_sdk/nlu + 示例2://foundation/ai/engine/services/client/algorithm_sdk/nlu - æ’件代ç 路径://foundation/ai/engine/services/server/plugin - e.g. //foundation/ai/engine/services/server/plugin/cv + + 示例1://foundation/ai/engine/services/server/plugin/cv - e.g. //foundation/ai/engine/services/server/plugin/nlu + 示例2://foundation/ai/engine/services/server/plugin/nlu ## 规则:æ’件æ供的全部对外接å£ï¼Œç»Ÿä¸€å˜æ”¾åœ¨AI业务å系统interfaces/kits目录 diff --git a/zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md b/zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md index a01d244546c32e94498b6b0271dcefb4c4df8801..52e2fe1650974d7011378f267ee15acc3bad192f 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md @@ -160,6 +160,20 @@ job就是命令集åˆï¼Œjobs管ç†å°±æ˜¯å¯¹è¦æ‰§è¡Œçš„一组命令集åˆè¿›è¡Œ å°åž‹ç³»ç»Ÿå’Œæ ‡å‡†ç³»ç»Ÿ </td> </tr> + <tr height="162" style="height:121.5pt"> + <td height="162" class="xl6621952" width="140" style="height:121.5pt;border-top: none;width:105pt"> + write + </td> + <td class="xl6621952" width="215" style="border-top:none;border-left:none; width:161pt"> + write filename value<br>如:write /data/testfile 0 + </td> + <td class="xl6621952" width="225" style="border-top:none;border-left:none; width:169pt"> + 写文件命令。åŽé¢è·Ÿä¸¤ä¸ªå‚数,第一个å‚数是文件的ç»å¯¹è·¯å¾„,第二个å‚数是è¦å†™å…¥æ–‡ä»¶çš„å—符串。 + </td> + <td class="xl6621952" width="190" style="border-top:none;border-left:none; width:143pt"> + æ ‡å‡†ç³»ç»Ÿ + </td> + </tr> <tr height="185" style="height:138.75pt"> <td height="185" class="xl6621952" width="140" style="height:138.75pt;border-top: none;width:105pt"> stop @@ -300,6 +314,20 @@ job就是命令集åˆï¼Œjobs管ç†å°±æ˜¯å¯¹è¦æ‰§è¡Œçš„一组命令集åˆè¿›è¡Œ å°åž‹ç³»ç»Ÿå’Œæ ‡å‡†ç³»ç»Ÿ </td> </tr> + <tr height="162" style="height:121.5pt"> + <td height="162" class="xl6621952" width="140" style="height:121.5pt;border-top: none;width:105pt"> + syncexec + </td> + <td class="xl6621952" width="215" style="border-top:none;border-left:none; width:161pt"> + syncexec å¯æ‰§è¡Œæ–‡ä»¶è·¯å¾„ å¯æ‰§è¡Œæ–‡ä»¶ä¼ çš„å‚æ•° <br>如:syncexec /system/bin/udevadm trigger + </td> + <td class="xl6621952" width="225" style="border-top:none;border-left:none; width:169pt"> + åŒæ¥æ‰§è¡Œï¼Œsyncexec 会调用waitç‰å¾…å进程结æŸã€‚å‚数个数ä¸è¶…过10个。 + </td> + <td class="xl6621952" width="190" style="border-top:none;border-left:none; width:143pt"> + æ ‡å‡†ç³»ç»Ÿ + </td> + </tr> <tr height="231" style="height:173.25pt"> <td height="231" class="xl6621952" width="140" style="height:173.25pt;border-top: none;width:105pt"> mknode diff --git a/zh-cn/device-dev/subsystems/subsys-boot-init-service.md b/zh-cn/device-dev/subsystems/subsys-boot-init-service.md index 29d88d97fe509c7f1676c566032db0f0d1b204ef..36dcceb2d73a601de2bbcc06815e66e5eba44236 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-init-service.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-init-service.md @@ -208,11 +208,11 @@ importance </td> <td class="xl6621805" width="196" style="border-top:none;border-left:none; width:147pt"> - 当å‰æœåŠ¡ä¼˜å…ˆçº§ + æ ‡å‡†ç³»ç»Ÿï¼šå½“å‰æœåŠ¡ä¼˜å…ˆçº§<br>å°åž‹ç³»ç»Ÿï¼šæ ‡è®°æœåŠ¡é‡è¦æ€§ </td> <td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt"> æ ‡å‡†ç³»ç»Ÿä¸: æœåŠ¡ä¼˜å…ˆçº§å–值范围 [-20, 19]ï¼Œè¶…å‡ºä¸ºæ— æ•ˆè®¾ç½®ã€‚<br> - å°åž‹ç³»ç»Ÿä¸ï¼š0 : éžé‡è¦è¿›ç¨‹ï¼›éž0 : é‡è¦è¿›ç¨‹ + å°åž‹ç³»ç»Ÿä¸ï¼š0 :ä¸é‡å¯ç³»ç»Ÿ ï¼›éž0 : é‡å¯ç³»ç»Ÿã€‚ </td> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> å°åž‹ç³»ç»Ÿå’Œæ ‡å‡†ç³»ç»Ÿ diff --git a/zh-cn/device-dev/subsystems/subsys-boot-syspara.md b/zh-cn/device-dev/subsystems/subsys-boot-syspara.md deleted file mode 100755 index 30c350550f076a4cd01a355ca5847c0a0e431b67..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/subsystems/subsys-boot-syspara.md +++ /dev/null @@ -1,301 +0,0 @@ -# syspara系统属性组件 - - -## 系统å‚数简介 - -syspara系统为å„系统æœåŠ¡æ供简å•æ˜“用的键值对访问接å£ï¼Œä½¿å¾—å„个系统æœåŠ¡å¯ä»¥é€šè¿‡å„自的系统å‚æ•°æ¥è¿›è¡Œä¸šåŠ¡åŠŸèƒ½çš„é…置。系统å‚数的访问和æ“ä½œæœ‰ä¸‹å›¾æ‰€ç¤ºå‡ ä¸ªåŸºæœ¬åŽŸè¯ï¼š - - **图1** 系统å‚æ•°æ“ä½œåŽŸè¯ - -  - - **表1** 系统å‚æ•°æ“作原è¯è¯´æ˜Ž - -| 功能 | 说明 | -| -------- | -------- | -| get | 获å–系统å‚数的值。 | -| set | 设置系统å‚数的值。 | -| wait | åŒæ¥ç‰å¾…系统å‚数的值å˜æ›´ã€‚ | -| watch | 异æ¥è§‚察系统å‚数的值å˜æ›´ã€‚ | - -系统å‚æ•°åç§°é‡‡ç”¨ç‚¹åˆ†æ ¼å¼ç”±å¤šæ®µç»„æˆï¼Œæ¯ä¸€æ®µç”±å—æ¯ã€æ•°å—ã€ä¸‹åˆ’线组æˆï¼Œæ€»é•¿åº¦ä¸è¶…过96å—节。系统å‚æ•°å称分为两类: - - **表2** 系统å‚æ•°å称 - -| 类别 | å称 | 示例 | 说明 | -| -------- | -------- | -------- | -------- | -| å‚æ•°å称 | Parameter Name | const.product.**name** | 完整的系统å‚æ•°å称,末尾ä¸æ˜¯"."。 | -| å‚数目录 | Parameter Directory | const.product**.** | 以"."ç»“å°¾ï¼Œæ ‡è¯†ç›¸åŒå‰ç¼€çš„所有系统å‚数集åˆã€‚ | - -系统å‚数一共分为三大类: - - **表3** 系统å‚数分类 - -| 类别 | å‰ç¼€ | 说明 | -| -------- | -------- | -------- | -| å¸¸é‡ | **const.** | 常é‡å‚数,一旦赋值åŽç»ä¸ä¼šå†å˜æ›´ï¼Œå€¼æœ€å¤§é•¿åº¦ä¸º4096å—节(包括结æŸç¬¦ï¼‰ã€‚ | -| å¯å†™ | 其它 | å¯å†™å‚数,é‡å¯åŽä¸¢å¤±ï¼Œå€¼æœ€å¤§é•¿åº¦96å—节(包括结æŸç¬¦ï¼‰ã€‚ | -| å¯æŒä¹…化 | **persist.** | å¯å†™å¹¶å¯æŒä¹…化ä¿å˜å‚数,é‡å¯åŽä¸ä¼šä¸¢å¤±ï¼Œå€¼æœ€å¤§é•¿åº¦96å—节(包括结æŸç¬¦ï¼‰ã€‚ | - -æ¯ä¸ªç³»ç»Ÿå‚æ•°åç§°æ€»ä½“æ ¼å¼å¦‚下:[**const**|**persist**].**$sub_system**.**$desc**。 - -$sub_system为å系统或模å—çš„å称。 - -$desc为å系统或模å—下å‚æ•°çš„æè¿°å—符,å¯ä»¥ä¸ºç‚¹åˆ†æ ¼å¼è¿›è¡Œåˆ†çº§æ述。 - - -## 系统å‚数定义规则 - -æ¯ä¸ªå系统定义å„自模å—的系统å‚数,包括系统å‚æ•°å称ã€é»˜è®¤å€¼ä»¥åŠç³»ç»Ÿå‚æ•°çš„æƒé™è®¿é—®ä¿¡æ¯ã€‚ - - -### 系统å‚数值定义文件 - -系统å‚数值定义文件åŽç¼€å为**".para"**ï¼Œå…¶æ ¼å¼ç¤ºä¾‹å¦‚下: - - -``` -# This is comment -const.product.name=OHOS-PRODUCT -const.os.version.api=26 -const.telephony.enable=false|true - -const.test.withblank=My Value -``` - -注æ„:系统å‚数值ä¸æ”¯æŒæ³¨é‡ŠåŠæ¢è¡Œã€‚ - - -``` -# ä¸æ”¯æŒ -const.test.withcomment=MyValue # This should be omitted -# ä¸æ”¯æŒ -const.test.multiline="This is a multiline parameter. -Line2 value. -Last line." -``` - -系统å‚数必须通过完整的系统å‚数命令æ¥èµ‹å€¼ï¼Œèµ‹å€¼æ–¹å¼åˆ†ä¸ºä¸‰å¤§ç±»ï¼š - - **表4** 系统å‚æ•°èµ‹å€¼æ–¹å¼ - -| 类别 | 示例 | 说明 | -| -------- | -------- | -------- | -| å—符串 | const.product.name=OHOS-PRODUCT | ä¸æ”¯æŒå¤šè¡Œå—符串,ä¸æ”¯æŒæ³¨é‡Šã€‚ | -| æ•°å— | const.os.version.api=26 | æ•°å—ä¸éœ€è¦å¼•å·ã€‚ | -| 布尔 | const.telephony.enable=false | 布尔型的å¯ä»¥ä¸º0,1或false,true。 | - - -### 系统å‚æ•°DAC访问控制定义文件 - -当å‰ç³»ç»Ÿå‚数的访问æƒé™æŽ§åˆ¶é€šè¿‡è‡ªä¸»è®¿é—®æŽ§åˆ¶ï¼ˆDiscretionary Access Control)方å¼ç®¡ç†ï¼Œè®¿é—®æƒé™å®šä¹‰æ–‡ä»¶åŽç¼€å为**".para.dac"**,示例如下: - - -``` -const.product.="root:root:660" -``` - -如上所示,å¯ä»¥é€šè¿‡**å‚数路径**为相åŒå‰ç¼€çš„所有系统å‚数定义一类访问æƒé™ä¿¡æ¯ï¼›DACä¿¡æ¯é€šè¿‡":"分三段æ¥æ述,分别为å‚æ•°çš„user,group以åŠUGO规则信æ¯ã€‚ - -UGO规则信æ¯æ¯ä¸€ä½çš„定义如下图所示: - - **图2** UGOè§„åˆ™ä¿¡æ¯ - -  - - -### 系统å‚数定义文件安装方法 - -.paraå’Œ.para.dac文件都通过ohos_prebuilt_para模版安装到/etc/param/目录下,GN脚本示例如下: - - -```go -import("//base/startup/init_lite/services/etc/param/param_fixer.gni") - -ohos_prebuilt_para("ohos.para") { - source = "//base/startup/init_lite/services/etc/ohos.para" - part_name = "init" - module_install_dir = "etc/param" -} - -ohos_prebuilt_para("ohos.para.dac") { - source = "//base/startup/init_lite/services/etc/ohos.para.dac" - part_name = "init" - module_install_dir = "etc/param" -} -``` - -ohos_prebuilt_para模版会对paraæ–‡ä»¶è¿›è¡Œæ ¼å¼åŒ–处ç†ï¼ŒåŒ…æ‹¬åŽ»æ³¨é‡Šï¼ŒåŽ»ç©ºæ ¼ç‰æ“作。该模版还支æŒé€šè¿‡extra_paraså‚数扩展编译时å‚数,示例如下: - -```go - ohos_prebuilt_para("ohos.para") { - source = "//base/startup/init_lite/services/etc/param/ohos.para" - part_name = "init" - if (target_cpu == "arm64") { - extra_paras = [ "const.product.cpu.abilist=arm64-v8a" ] - } - module_install_dir = "etc/param" - } -``` - -å…¶ä¸extra_paras值的系统å‚数值处ç†æ–¹å¼ä¸ºï¼šsource文件ä¸æ²¡æœ‰å®šä¹‰è¯¥ç³»ç»Ÿå‚æ•°åˆ™æ·»åŠ ï¼›source文件ä¸å·²ç»å®šä¹‰è¯¥å‚数则覆盖。 - -### 系统å‚æ•°å€¼å®šä¹‰æ–‡ä»¶çš„åŠ è½½é¡ºåº - -系统å‚æ•°å€¼çš„åŠ è½½é¡ºåºå¦‚下: - - **表5** 系统å‚æ•°åŠ è½½é¡ºåº - -| 类别 | 路径 | 说明 | -| -------- | -------- | -------- | -| å†…æ ¸å‚æ•° | /proc/cmdline | å†…æ ¸å‚æ•°ä¸ohospara.xxx=valXXX类型的å‚数都转æ¢æˆohos.boot.xxx=valXXX系统å‚数。 | -| OS固定值 | /system/etc/param/ohos_const/\*.para | OS固定系统å‚数值å‚æ•°ä¼˜å…ˆåŠ è½½ã€‚ | -| vendorå‚数值 | /vendor/etc/param/\*.para | 厂商å‚æ•°å€¼å®šä¹‰æ–‡ä»¶æ¬¡ä¼˜å…ˆçº§åŠ è½½ï¼Œå¯ä»¥è¦†ç›–systemå‚数值定义。 | -| systemå‚数值 | /system/etc/param/\*.para | 最åŽåŠ è½½systemå‚数值定义文件,文件ä¸çš„系统å‚数值如果已ç»å˜åœ¨ï¼Œåˆ™å¿½ç•¥æŽ‰ã€‚ | - - -## shell命令使用说明 - -通过shell命令ä¸å¯ç›´æŽ¥æ“作系统å‚数。系统å‚æ•°shell命令如下表所示: - - - **表6** 系统å‚æ•°shell命令说明 - -| 功能 | 说明 | -| -------- | -------- | -| param get [**key**] | 获å–指定keyå称的系统å‚数值;如果ä¸æŒ‡å®šä»»ä½•name,则返回所有系统å‚数值。 | -| param set **key value** | 设置指定keyå称的å‚数值为value。 | -| param wait **keyvalue** | åŒæ¥ç‰å¾…指定keyå称的系统å‚数值与value匹é…。valueå¯æ”¯æŒæ¨¡ç³ŠåŒ¹é…,如"\*"表示任何值,"val\*"表示åªåŒ¹é…å‰ä¸‰ä¸ªvalå—符。 | -| param dump | 显示系统å‚数的统计信æ¯ã€‚ | - - -## syspara系统接å£è¯´æ˜Ž - - **表7** 系统属性接å£è¯´æ˜Ž - -| 接å£å | æè¿° | -| -------- | -------- | -| int GetParameter(const char\* key, const char\* def, char\* value, unsigned int len) | 获å–系统å‚数。 | -| int SetParameter(const char\* key, const char\* value) | 设置/更新系统å‚数。 | -| const char\* GetDeviceType(void) | 返回当å‰è®¾å¤‡ç±»åž‹ã€‚ | -| const char\* GetManufacture(void) | 返回当å‰è®¾å¤‡ç”Ÿäº§åŽ‚家信æ¯ã€‚ | -| const char\* GetBrand(void) | 返回当å‰è®¾å¤‡å“牌信æ¯ã€‚ | -| const char\* GetMarketName(void) | 返回当å‰è®¾å¤‡ä¼ æ’å。 | -| const char\* GetProductSeries(void) | 返回当å‰è®¾å¤‡äº§å“系列å。 | -| const char\* GetProductModel(void) | 返回当å‰è®¾å¤‡è®¤è¯åž‹å·ã€‚ | -| const char\* GetSoftwareModel(void) | 返回当å‰è®¾å¤‡å†…部软件ååž‹å·ã€‚ | -| const char\* GetHardwareModel(void) | 返回当å‰è®¾å¤‡ç¡¬ä»¶ç‰ˆæœ¬å·ã€‚ | -| const char\* GetHardwareProfile(void) | 返回当å‰è®¾å¤‡ç¡¬ä»¶profile。 | -| const char\* GetSerial(void) | 返回当å‰è®¾å¤‡åºåˆ—å·ï¼ˆSNå·ï¼‰ã€‚ | -| const char\* GetOSFullName(void) | 返回æ“作系统å。 | -| const char\* GetDisplayVersion(void) | 返回当å‰è®¾å¤‡ç”¨æˆ·å¯è§çš„软件版本å·ã€‚ | -| const char\* GetBootloaderVersion(void) | 返回当å‰è®¾å¤‡Bootloader版本å·ã€‚ | -| const char\* GetSecurityPatchTag(void) | 返回安全补ä¸æ ‡ç¾ã€‚ | -| const char\* GetAbiList(void) | 返回当å‰è®¾å¤‡æ”¯æŒçš„指令集(Abi)列表。 | -| int GetSdkApiVersion(void) | 返回与当å‰ç³»ç»Ÿè½¯ä»¶åŒ¹é…çš„SDK API 版本å·ã€‚ | -| int GetFirstApiVersion(void) | 返回系统软件首版本SDK API 版本å·ã€‚ | -| const char\* GetIncrementalVersion(void) | 返回差异版本å·ã€‚ | -| const char\* GetVersionId(void) | 返回版本id。 | -| const char\* GetBuildType(void) | 返回构建类型。 | -| const char\* GetBuildUser(void) | 返回构建账户用户å。 | -| const char\* GetBuildHost(void) | 返回构建主机å。 | -| const char\* GetBuildTime(void) | 返回构建时间。 | -| const char\* GetBuildRootHash(void) | 返回当å‰ç‰ˆæœ¬hash。 | -| const char\* GetOsReleaseType(void) | 返回系统å‘布类型。 | -| int GetDevUdid(char \*udid, int size) | 获å–设备udid。 | - - -## å¼€å‘实例 - -系统属性使用实例 - - -``` -// set && get -char key1[] = "rw.sys.version"; -char value1[] = "10.1.0"; -int ret = SetParameter(key1, value1); -char valueGet1[128] = {0}; -ret = GetParameter(key1, "version=10.1.0", valueGet1, 128); - -// get sysparm -char* value1 = GetDeviceType(); -printf("Product type =%s\n", value1); -free(value1); -char* value2 = GetManufacture(); -printf("Manufacture =%s\n", value2); -free(value2); -char* value3 = GetBrand(); -printf("GetBrand =%s\n", value3); -free(value3); -char* value4 = GetMarketName(); -printf("MarketName =%s\n", value4); -free(value4); -char* value5 = GetProductSeries(); -printf("ProductSeries =%s\n", value5); -free(value5); -char* value6 = GetProductModel(); -printf("ProductModel =%s\n", value6); -free(value6); -char* value7 = GetSoftwareModel(); -printf("SoftwareModel =%s\n", value7); -free(value7); -char* value8 = GetHardwareModel(); -printf("HardwareModel =%s\n", value8); -free(value8); -char* value9 = GetHardwareProfile(); -printf("Software profile =%s\n", value9); -free(value9); -char* value10 = GetSerial(); -printf("Serial =%s\n", value10); -free(value10); -char* value11 = GetOSFullName(); -printf("OS name =%s\n", value11); -free(value11); -char* value12 = GetDisplayVersion(); -printf("Display version =%s\n", value12); -free(value12); -char* value13 = GetBootloaderVersion(); -printf("bootloader version =%s\n", value13); -free(value13); -char* value14 = GetSecurityPatchTag(); -printf("secure patch level =%s\n", value14); -free(value14); -char* value15 = GetAbiList(); -printf("abi list =%s\n", value15); -free(value15); -int value16 = GetFirstApiVersion(); -printf("first api level =%d\n", value16); -free(value16); -char* value17 = GetIncrementalVersion(); -printf("Incremental version = %s\n", value17); -free(value17); -char* value18 = GetVersionId(); -printf("formal id =%s\n", value18); -free(value18); -char* value19 = GetBuildType(); -printf("build type =%s\n", value19); -free(value19); -char* value20 = GetBuildUser(); -printf("build user =%s\n", value20); -free(value20); -char* value21 = GetBuildHost(); -printf("Build host = %s\n", value21); -free(value21); -char* value22 = GetBuildTime(); -printf("build time =%s\n", value22); -free(value22); -char* value23 = GetBuildRootHash(); -printf("build root later..., %s\n", value23); -free(value23); -char* value24 = GetOsReleaseType(); -printf("OS release type =%s\n", value24); -free(value24); -char* value25 = GetOsReleaseType(); -printf("OS release type =%s\n", value25); -free(value25); -char value26[65] = {0}; -GetDevUdid(value26, 65); -printf("device udid =%s\n", value26); -free(value26); -``` diff --git a/zh-cn/device-dev/subsystems/subsys-boot.md b/zh-cn/device-dev/subsystems/subsys-boot.md index 42e3f43579058f170978a15ed014580baaf11cea..6245a767ce99508205913f455dfe3299cffa4215 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot.md +++ b/zh-cn/device-dev/subsystems/subsys-boot.md @@ -5,8 +5,6 @@ - **[å¯åŠ¨æ¢å¤å系统概述](subsys-boot-overview.md)** - **[initå¯åŠ¨å¼•å¯¼ç»„件](subsys-boot-init.md)** - **[appspawn应用åµåŒ–组件](subsys-boot-appspawn.md)** -- **[appspawnæ ‡å‡†ç³»ç»Ÿåº”ç”¨åµåŒ–组件](subsys-boot-appspawn-standard.md)** - **[bootstrapæœåŠ¡å¯åŠ¨ç»„件](subsys-boot-bootstrap.md)** -- **[syspara系统属性组件](subsys-boot-syspara.md)** - **[常è§é—®é¢˜](subsys-boot-faqs.md)** - **[å‚考](subsys-boot-ref.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-build-mini-lite.md b/zh-cn/device-dev/subsystems/subsys-build-mini-lite.md index 0c18f32304ff90fb79a1a78c7cead94308a77a64..a8cda2618b822f6123d84fe19e687310eb82ef9e 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-mini-lite.md +++ b/zh-cn/device-dev/subsystems/subsys-build-mini-lite.md @@ -629,7 +629,7 @@ optional arguments: # Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain. board_toolchain = "gcc-arm-none-eabi" - # The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc. + # The toolchain path installed, it's not mandatory if you have added toolchain path to your ~/.bashrc. board_toolchain_path = rebase_path("//prebuilts/gcc/linux-x86/arm/gcc-arm-none-eabi/bin", root_build_dir) diff --git a/zh-cn/device-dev/subsystems/subsys-build-standard-large.md b/zh-cn/device-dev/subsystems/subsys-build-standard-large.md index cab31620804e3b52b63744999a79a9a188132661..8c124330ebf6a5b7b201eb810cf6d859ace1b254 100644 --- a/zh-cn/device-dev/subsystems/subsys-build-standard-large.md +++ b/zh-cn/device-dev/subsystems/subsys-build-standard-large.md @@ -11,20 +11,24 @@ ### 基本概念 在了解编译构建å系统的能力å‰ï¼Œåº”了解如下基本概念: - - å¹³å° + å¼€å‘æ¿å’Œå†…æ ¸çš„ç»„åˆï¼Œä¸åŒå¹³å°æ”¯æŒçš„å系统和部件ä¸åŒã€‚ - å系统 + OpenHarmony整体éµä»Žåˆ†å±‚设计,从下å‘上ä¾æ¬¡ä¸ºï¼šå†…æ ¸å±‚ã€ç³»ç»ŸæœåŠ¡å±‚ã€æ¡†æž¶å±‚和应用层。系统功能按照“系统 > å系统 > 部件â€é€çº§å±•å¼€ï¼Œåœ¨å¤šè®¾å¤‡éƒ¨ç½²åœºæ™¯ä¸‹ï¼Œæ”¯æŒæ ¹æ®å®žé™…需求è£å‰ªæŸäº›éžå¿…è¦çš„å系统或部件。å系统是一个逻辑概念,它具体由对应的部件构æˆã€‚ - 部件 + 对å系统的进一æ¥æ‹†åˆ†ï¼Œå¯å¤ç”¨çš„软件å•å…ƒï¼Œå®ƒåŒ…å«æºç ã€é…置文件ã€èµ„æºæ–‡ä»¶å’Œç¼–译脚本;能独立构建,以二进制方å¼é›†æˆï¼Œå…·å¤‡ç‹¬ç«‹éªŒè¯èƒ½åŠ›çš„二进制å•å…ƒã€‚ - gn + Generate ninja的缩写,用于产生ninja文件。 - ninja + ninja是一个专注于速度的å°åž‹æž„建系统。 ### è¿ä½œæœºåˆ¶ diff --git a/zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md b/zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md index 69b20eac0f29ebf94d3147d192331aa4558a6d6e..18d44eedce007f87bd76e669dd6f88599e92b9ef 100644 --- a/zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-data-relational-database-guide.md @@ -179,6 +179,18 @@ | ---- | ---- | ---- | | RdbStore | int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey) | æ¢å¤æ•°æ®åº“文件。<ul><li>backupPath:指定的备份文件å。 </li><li> newKey:数æ®åº“çš„åŠ å¯†å¯†é’¥ã€‚æ³¨æ„:当å‰åªæ”¯æŒéžåŠ 密数æ®åº“çš„æ¢å¤ã€‚</li></ul> | +### 事务 + + 事务(Transaction)是一个对数æ®åº“执行工作å•å…ƒã€‚通过返回值判æ–事务是å¦æˆåŠŸï¼ŒæˆåŠŸæ—¶è¿”回0,失败时则返回相应的错误ç 。 + + 表16 事务API + + | ç±»å | 接å£å | æè¿° | + | ---- | ---- | ---- | + | RdbStore | int BeginTransaction() | å¼€å¯ä¸€ä¸ªäº‹åŠ¡ã€‚ | + | RdbStore | int Commit() | ä¿å˜æ›´æ”¹ã€‚ | + | RdbStore | int RollBack() | 回滚所åšçš„更改。 | + ## 约æŸä¸Žé™åˆ¶ æ— ã€‚ diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md index 8be5fe23e2c375fc01002165aff65ce1530e665e..4c8ed67988e5d30c5adcc5532fef02e2b376c0ea 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @@ -8,7 +8,7 @@ HiSysEvent打点æ供了事件埋点功能,开å‘者å¯ä»¥é€šè¿‡åœ¨å…³é”®è·¯ ### è¿ä½œæœºåˆ¶ -在进行HiSysEvent事件埋点之å‰ï¼Œéœ€è¦å…ˆå®ŒæˆHiSysEvent打点é…置,具体é…置方法请å‚考[《HiSysEvent打点é…置指导》](subsys-dfx-hisysevent-logging-config.md)。 +在进行HiSysEvent事件埋点之å‰ï¼Œéœ€è¦å…ˆå®ŒæˆHiSysEvent打点é…置,具体é…置方法请å‚考[HiSysEvent打点é…置指导](subsys-dfx-hisysevent-logging-config.md)。 ## å¼€å‘指导 @@ -18,28 +18,29 @@ HiSysEvent打点æ供了事件埋点功能,开å‘者å¯ä»¥é€šè¿‡åœ¨å…³é”®è·¯ ### 接å£è¯´æ˜Ž -#### c++接å£è¯´æ˜Ž +#### C++接å£è¯´æ˜Ž -c++事件埋点开å‘能力如下:HiSysEvent类,具体的API详è§æŽ¥å£æ–‡æ¡£ 。 +C++事件埋点开å‘能力如下:HiSysEvent类,具体的API详è§æŽ¥å£æ–‡æ¡£ 。 >  **说明:** -> 在OpenHarmony-3.2-Beta3版本ä¸ï¼Œä¸ºé¿å…打点风暴事件引å‘性能问题,对HiSysEvent打点进行了管控,表1ä¸çš„HiSysEvent::Write打点API接å£è¢«è¡¨2ä¸çš„HiSysEventWriteå®æŽ¥å£å–代。HiSysEvent::Write接å£å·²åºŸå¼ƒï¼Œè¯·ä½¿ç”¨HiSysEventWriteå®å®ŒæˆHiSysEvent事件打点。 +> +> 在OpenHarmony-3.2-Beta3版本ä¸ï¼Œä¸ºé¿å…打点风暴事件引å‘性能问题,对HiSysEvent打点进行了管控。表1ä¸çš„HiSysEvent::Write打点API接å£è¢«è¡¨2ä¸çš„HiSysEventWriteå®æŽ¥å£å–代。HiSysEvent::Write接å£å·²åºŸå¼ƒï¼Œè¯·ä½¿ç”¨HiSysEventWriteå®å®ŒæˆHiSysEvent事件打点。 -**表1** c++事件埋点API接å£åŠŸèƒ½ä»‹ç»ï¼ˆå·²åºŸå¼ƒï¼‰ +**表1** C++事件埋点API接å£åŠŸèƒ½ä»‹ç»ï¼ˆå·²åºŸå¼ƒï¼‰ | 接å£å | æè¿° | -| ------------------------------------------------------------ | ---------------------- | +| ------------------------------------------------------------ | --------------------- | | template<typename... Types> <br>static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | 将打点事件数æ®è¿›è¡Œè½ç›˜ | -**表2** c++事件埋点API接å£åŠŸèƒ½ä»‹ç» +**表2** C++事件埋点API接å£åŠŸèƒ½ä»‹ç» | 接å£å | æè¿° | -| ------------------------------------------------------------ | ---------------------- | -| HiSysEventWrite(domain, eventName, type, ...) | 将打点事件数æ®è¿›è¡Œè½ç›˜| +| ------------------------------------------------------------ | --------------------- | +| HiSysEventWrite(domain, eventName, type, ...) | 将打点事件数æ®è¿›è¡Œè½ç›˜ | - **表3** c++事件类型API接å£ä»‹ç» + **表3** C++äº‹ä»¶ç±»åž‹ä»‹ç» -| 接å£å | æè¿° | -| --------- | ------------ | +| 事件类型 | æè¿° | +| --------- | ----------- | | FAULT | 故障类型事件 | | STATISTIC | 统计类型事件 | | SECURITY | 安全类型事件 | @@ -52,17 +53,17 @@ kernel事件埋点开å‘能力如下: **表4** kernel事件埋点API接å£åŠŸèƒ½ä»‹ç» | 接å£å | æè¿° | -| ------------------------------------------------------------ | ------------------------------------ | -| struct hiview_hisysevent *hisysevent_create(const char *domain, const char *name, enum hisysevent_type type); | 创建一个事件对象 | -| void hisysevent_destroy(struct hiview_hisysevent *event); | 销æ¯ä¸€ä¸ªäº‹ä»¶å¯¹è±¡ | -| int hisysevent_put_integer(struct hiview_hisysevent *event, const char *key, long long value); | 将整数类型的事件å‚æ•°æ·»åŠ åˆ°äº‹ä»¶å¯¹è±¡ | +| ------------------------------------------------------------ | ----------------------------------- | +| struct hiview_hisysevent *hisysevent_create(const char *domain, const char *name, enum hisysevent_type type); | 创建一个事件对象 | +| void hisysevent_destroy(struct hiview_hisysevent *event); | 销æ¯ä¸€ä¸ªäº‹ä»¶å¯¹è±¡ | +| int hisysevent_put_integer(struct hiview_hisysevent *event, const char *key, long long value); | 将整数类型的事件å‚æ•°æ·»åŠ åˆ°äº‹ä»¶å¯¹è±¡ | | int hisysevent_put_string(struct hiview_hisysevent *event, const char *key, const char *value); | å°†å—符串类型的事件å‚æ•°æ·»åŠ åˆ°äº‹ä»¶å¯¹è±¡ | -| int hisysevent_write(struct hiview_hisysevent *event); | 将事件对象数æ®è¿›è¡Œè½ç›˜ | +| int hisysevent_write(struct hiview_hisysevent *event); | 将事件对象数æ®è¿›è¡Œè½ç›˜ | -**表5** kernel事件类型API接å£ä»‹ç» +**表5** kerneläº‹ä»¶ç±»åž‹ä»‹ç» -| 接å£å | æè¿° | -| --------- | ------------ | +| 事件类型 | æè¿° | +| --------- | ----------- | | FAULT | 故障类型事件 | | STATISTIC | 统计类型事件 | | SECURITY | 安全类型事件 | @@ -70,9 +71,9 @@ kernel事件埋点开å‘能力如下: ### å¼€å‘æ¥éª¤ -#### c++埋点开å‘æ¥éª¤ +#### C++埋点开å‘æ¥éª¤ -1. 在需è¦åŸ‹ç‚¹çš„地方直接调用埋点接å£ï¼Œå¹¶ä¼ 入相应事件å‚æ•°å³å¯ï¼š +1. 在需è¦åŸ‹ç‚¹çš„地方直接调用埋点接å£ï¼Œå¹¶ä¼ 入相应事件å‚数。 ```c++ HiSysEventWrite(HiSysEvent::Domain::AAFWK, "START_APP", HiSysEvent::EventType::BEHAVIOR, "APP_NAME", "com.ohos.demo"); @@ -80,13 +81,13 @@ kernel事件埋点开å‘能力如下: #### kernel埋点开å‘æ¥éª¤ -1. æ ¹æ®äº‹ä»¶é¢†åŸŸã€äº‹ä»¶å称ã€äº‹ä»¶ç±»åž‹å‚数,创建一个基础的事件对象: +1. æ ¹æ®äº‹ä»¶é¢†åŸŸã€äº‹ä»¶å称ã€äº‹ä»¶ç±»åž‹å‚数,创建一个基础的事件对象。 ```c struct hiview_hisysevent *event = hisysevent_create("KERNEL", "BOOT", BEHAVIOR); ``` -2. 将自定义的事件å‚æ•°ï¼Œä¼ å…¥åˆ°äº‹ä»¶å¯¹è±¡é‡Œï¼š +2. 将自定义的事件å‚æ•°ï¼Œä¼ å…¥åˆ°äº‹ä»¶å¯¹è±¡é‡Œã€‚ ```c // æ·»åŠ æ•´æ•°ç±»åž‹å‚æ•° @@ -96,13 +97,13 @@ kernel事件埋点开å‘能力如下: hisysevent_put_string(event, "MSG", "This is a test message"); ``` -3. 在事件对象构建完æˆåŽï¼Œå°†äº‹ä»¶è¿›è¡Œä¸ŠæŠ¥ï¼š +3. 在事件对象构建完æˆåŽï¼Œå°†äº‹ä»¶è¿›è¡Œä¸ŠæŠ¥ã€‚ ```c hisysevent_write(event); ``` -4. 事件上报完æˆåŽï¼Œéœ€è¦æ‰‹åŠ¨å°†å¯¹è±¡é”€æ¯ï¼š +4. 事件上报完æˆåŽï¼Œéœ€è¦æ‰‹åŠ¨å°†å¯¹è±¡é”€æ¯ã€‚ ```c hisysevent_destroy(&event); @@ -110,7 +111,7 @@ kernel事件埋点开å‘能力如下: #### 事件领域å±è”½çš„æ¥éª¤ -1. 在相应的文件ä¸å®šä¹‰å称为“DOMAIN_MASKSâ€ï¼Œå†…容形如“DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_nâ€ï¼Œå…±æœ‰ä¸‰ç§å±è”½åœºæ™¯ï¼š +1. 在相应的文件ä¸å®šä¹‰å称为“DOMAIN_MASKSâ€ï¼Œå†…容形如“DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_nâ€ã€‚共有三ç§å±è”½åœºæ™¯ï¼š - åªå±è”½å½“å‰æºç 文件ä¸çš„相应事件领域的HiSysEvent打点,在该cpp文件引入hisysevent.h头文件之å‰å®šä¹‰å®DOMAIN_MASKSå³å¯ã€‚ ```c++ @@ -125,7 +126,7 @@ kernel事件埋点开å‘能力如下: } ``` -- 全局å±è”½ç›¸åº”事件领域的HiSysEvent打点,则在/build/config/compiler/BUILD.gnä¸å®šä¹‰å®DIMAIN_MASKSå³å¯ã€‚ +- 全局å±è”½ç›¸åº”事件领域的HiSysEvent打点,则在/build/config/compiler/BUILD.gnä¸å®šä¹‰å®DOMAIN_MASKSå³å¯ã€‚ ```gn cflags_cc += ["-DDOMAIN_MASKS=\"DOMAIN_NAME_1|DOMAIN_NAME_2|...|DOMAIN_NAME_n\""] ``` @@ -140,17 +141,17 @@ kernel事件埋点开å‘能力如下: ### å¼€å‘实例 -#### c++埋点开å‘实例 +#### C++埋点开å‘实例 å‡è®¾ä¸šåŠ¡æ¨¡å—需è¦åœ¨åº”用å¯åŠ¨æ—¶è¿›è¡ŒåŸ‹ç‚¹æ¥è®°å½•åº”用å¯åŠ¨äº‹ä»¶ï¼Œä¸”需è¦è®°å½•åº”用的包åä¿¡æ¯ï¼Œå®Œæ•´ä½¿ç”¨ç¤ºä¾‹å¦‚下所示: -1. 首先,需è¦åœ¨ä¸šåŠ¡æ¨¡å—的在BUILD.gné‡Œå¢žåŠ HiSysEvent部件ä¾èµ–: +1. 首先,需è¦åœ¨ä¸šåŠ¡æ¨¡å—的在BUILD.gné‡Œå¢žåŠ HiSysEvent部件ä¾èµ–。 ```c++ external_deps = [ "hisysevent_native:libhisysevent" ] ``` -2. 在业务模å—的应用å¯åŠ¨å‡½æ•°StartAbility()ä¸ï¼Œè°ƒç”¨åŸ‹ç‚¹æŽ¥å£å¹¶ä¼ 入对应事件å‚数: +2. 在业务模å—的应用å¯åŠ¨å‡½æ•°StartAbility()ä¸ï¼Œè°ƒç”¨åŸ‹ç‚¹æŽ¥å£å¹¶ä¼ 入对应事件å‚数。 ```c++ #include "hisysevent.h" diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hiview.md b/zh-cn/device-dev/subsystems/subsys-dfx-hiview.md index 30e6f3fe4cb4b4cd079b819b5bb7ab1fc31015ff..8933696696d71441820a35fbc0a11448421763b1 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hiview.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hiview.md @@ -18,7 +18,7 @@ Hiview是一个跨平å°çš„终端设备维测æœåŠ¡é›†ï¼Œç”±æ’件管ç†å¹³å° - Faultloggeræ’件负责处ç†æ•…障相关事件; - EventLoggeræ’件负责采集事件相关的日志信æ¯ã€‚ 3. 在æµæ°´çº¿ä¸Šå®Œæˆäº‹ä»¶å¤„ç†åŽï¼Œè¿˜ä¼šæŠŠäº‹ä»¶å‘é€åˆ°å¹³å°è®¢é˜…事件队列里,然åŽå°†äº‹ä»¶æ´¾å‘到订阅æ’件进行处ç†ï¼Œå…¶ä¸ï¼š - - FreezeDetectorPluginæ’件负责处ç†å†»å±ç›¸å…³äº‹ä»¶ï¼› + - FreezeDetectoræ’件负责处ç†å†»å±ç›¸å…³äº‹ä»¶ï¼› - HiCollieCollectoræ’件负责å¡æ»ç›¸å…³äº‹ä»¶ã€‚ ### 基本概念 diff --git a/zh-cn/device-dev/subsystems/subsys-testguide-test.md b/zh-cn/device-dev/subsystems/subsys-testguide-test.md index 7b10a0a98117ba588f416673e36b0f15f71e5f74..a11367525b5348f0dd1028c56b5c8f8f0f0ef981 100644 --- a/zh-cn/device-dev/subsystems/subsys-testguide-test.md +++ b/zh-cn/device-dev/subsystems/subsys-testguide-test.md @@ -758,7 +758,7 @@ subsystem # å系统 当选择完产å“å½¢æ€ï¼Œå¯å‚考如下指令执行测试用例。 ``` - run -t UT -ts CalculatorSubTest -tc interger_sub_00l + run -t UT -ts CalculatorSubTest -tc integer_sub_00l ``` 执行命令å‚数说明: ``` @@ -798,7 +798,7 @@ subsystem # å系统 æµ‹è¯•æ¡†æž¶åœ¨æ‰§è¡Œç”¨ä¾‹æ—¶ä¼šæ ¹æ®æŒ‡ä»¤æ‰¾åˆ°æ‰€éœ€ç”¨ä¾‹ï¼Œè‡ªåŠ¨å®žçŽ°ç”¨ä¾‹ç¼–译,执行过程,完æˆè‡ªåŠ¨åŒ–测试。 ``` - run -t UT -ts CalculatorSubTest -tc interger_sub_00l + run -t UT -ts CalculatorSubTest -tc integer_sub_00l ``` 执行命令å‚数说明: ``` diff --git a/zh-cn/device-dev/subsystems/subsys-xts-guide.md b/zh-cn/device-dev/subsystems/subsys-xts-guide.md index 991972c0d7f3684aea0dbf703cf7129a11434030..36f1f7ab87265f684f24487de5b107332ef05c15 100644 --- a/zh-cn/device-dev/subsystems/subsys-xts-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-xts-guide.md @@ -143,18 +143,15 @@ XTSå系统当å‰åŒ…括acts与tools软件包: 4. 使用å®å®šä¹‰LITE_TEST_CASE写测试用例 包括三个å‚数:测试套件å称,测试用例å称,用例属性(测试类型ã€ç”¨ä¾‹ç²’度ã€ç”¨ä¾‹çº§åˆ«ï¼‰ã€‚ - - ``` LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1) { //do something }; ``` - 5. 使用å®å®šä¹‰ RUN_TEST_SUITE注册测试套件 - + ``` RUN_TEST_SUITE(IntTestSuite); ``` @@ -258,16 +255,16 @@ XTSå系统当å‰åŒ…括acts与tools软件包: // Test suite cleanup action, which is executed after the last test case static void TearDownTestCase(void){ } - // Preset action of the test case - virtual void SetUp() - { - } - // Cleanup action of the test case - virtual void TearDown() - { + // Preset action of the test case + virtual void SetUp() + { + } + // Cleanup action of the test case + virtual void TearDown() + { } }; - ``` + ``` 3. 使用å®å®šä¹‰HWTEST或HWTEST_F写测试用例 @@ -288,8 +285,7 @@ XTSå系统当å‰åŒ…括acts与tools软件包: æ¯ä¸ªæµ‹è¯•æ¨¡å—目录下新建BUILD.gn编译文件,用于指定编译åŽå¯æ‰§è¡Œæ–‡ä»¶çš„å称ã€ä¾èµ–的头文件ã€ä¾èµ–的库ç‰ï¼›å…·ä½“写法如下。æ¯ä¸ªæµ‹è¯•æ¨¡å—将独立编译æˆ.binå¯æ‰§è¡Œæ–‡ä»¶ï¼Œ 该文件å¯ç›´æŽ¥push到å•æ¿ä¸Šè¿›è¡Œæµ‹è¯•ã€‚ 举例: - - + ``` import("//test/xts/tools/lite/build/suite_lite.gni") hcpptest_suite("ActsDemoTest") { diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index fbc186aa13d8fba470584e9a178676dcfb780a13..3554669de0f544e90530523f64e038ffcfad7b69 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -24,6 +24,7 @@ - 附录 - [Hi3861å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-ide-lite-introduction-hi3861.md) - [Hi3516å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-ide-lite-introduction-hi3516.md) + - [编译形æ€æ•´ä½“说明](quick-start/quickstart-build.md) - è½»é‡å’Œå°åž‹ç³»ç»Ÿå¿«é€Ÿå…¥é—¨ï¼ˆå®‰è£…包方å¼ï¼‰ - [è½»é‡ä¸Žå°åž‹ç³»ç»Ÿå…¥é—¨æ¦‚è¿°](quick-start/quickstart-lite-overview.md) - [æ建轻é‡ä¸Žå°åž‹ç³»ç»ŸçŽ¯å¢ƒ](quick-start/quickstart-lite-env-setup.md) @@ -52,6 +53,7 @@ - [Hi3516å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-lite-introduction-hi3516.md) - [å‚考信æ¯](quick-start/quickstart-lite-reference.md) - [使用HiTool烧录代ç ](quick-start/quickstart-lite-hitool.md) + - [编译形æ€æ•´ä½“说明](quick-start/quickstart-build.md) - æ ‡å‡†ç³»ç»Ÿå¿«é€Ÿå…¥é—¨ï¼ˆIDEæ–¹å¼ï¼ŒæŽ¨è) - [æ ‡å‡†ç³»ç»Ÿå…¥é—¨æ¦‚è¿°](quick-start/quickstart-ide-standard-overview.md) - å‡†å¤‡æ ‡å‡†ç³»ç»ŸçŽ¯å¢ƒ @@ -72,6 +74,7 @@ - 附录 - [Hi3516å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-ide-standard-board-introduction-hi3516.md) - [RK3568å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-ide-standard-board-introduction-rk3568.md) + - [编译形æ€æ•´ä½“说明](quick-start/quickstart-build.md) - æ ‡å‡†ç³»ç»Ÿå¿«é€Ÿå…¥é—¨ï¼ˆå®‰è£…åŒ…æ–¹å¼ï¼‰ - [æ ‡å‡†ç³»ç»Ÿå…¥é—¨æ¦‚è¿°](quick-start/quickstart-standard-overview.md) - [æå»ºæ ‡å‡†ç³»ç»ŸçŽ¯å¢ƒ](quick-start/quickstart-standard-env-setup.md) @@ -94,8 +97,9 @@ - å¼€å‘æ¿ä»‹ç» - [Hi3516å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-standard-board-introduction-hi3516.md) - [RK3568å¼€å‘æ¿ä»‹ç»](quick-start/quickstart-standard-board-introduction-rk3568.md) - - [å‚考信æ¯](quickstart-standard-reference.md) + - [å‚考信æ¯](quick-start/quickstart-standard-reference.md) - [使用HiTool烧录代ç ](quick-start/quickstart-standard-hitool.md) + - [编译形æ€æ•´ä½“说明](quick-start/quickstart-build.md) - [获å–æºç ](get-code/sourcecode-acquire.md) @@ -151,8 +155,11 @@ - è½»é‡ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æ¡ˆä¾‹ - [带å±è§£å†³æ–¹æ¡ˆä¹‹æ’玄芯片移æ¤æ¡ˆä¾‹](porting/porting-bes2600w-on-minisystem-display-demo.md) - [Combo解决方案之ASR芯片移æ¤æ¡ˆä¾‹](porting/porting-asr582x-combo-demo.md) + - [物è”网解决方案之芯海cst85芯片移æ¤æ¡ˆä¾‹](porting/porting-cst85f01-combo-demo.md) - [è½»é‡ç³»ç»ŸSTM32F407芯片移æ¤æ¡ˆä¾‹](porting/porting-stm32f407-on-minisystem-eth.md) - + - [Combo解决方案之W800芯片移æ¤æ¡ˆä¾‹](porting/porting-w800-combo-demo.md) + - å°åž‹ç³»ç»ŸèŠ¯ç‰‡ç§»æ¤æ¡ˆä¾‹ + - [å°åž‹è®¾å¤‡STM32MP1芯片移æ¤æ¡ˆä¾‹](porting/porting-stm32mp15xx-on-smallsystem.md) - åç³»ç»Ÿå¼€å‘ - å†…æ ¸ @@ -383,6 +390,7 @@ - [Audio](driver/driver-peripherals-audio-des.md) - [Camera](driver/driver-peripherals-camera-des.md) - [Face_auth](driver/driver-peripherals-face_auth-des.md) + - [Fingerprint_auth](driver/driver-peripherals-fingerprint_auth-des.md) - [LCD](driver/driver-peripherals-lcd-des.md) - [Light](driver/driver-peripherals-light-des.md) - [Pin_auth](driver/driver-peripherals-pinauth-des.md) @@ -397,6 +405,7 @@ - [æ ‡å‡†ç³»ç»Ÿç¼–è¯‘æž„å»ºæŒ‡å¯¼](subsystems/subsys-build-standard-large.md) - [构建系统编ç 规范和最佳实践指导](subsystems/subsys-build-gn-coding-style-and-best-practice.md) - [编译构建Kconfigå¯è§†åŒ–é…置指导](subsystems/subsys-build-gn-kconfig-visual-config-guide.md) + - [HAP编译构建指导](subsystems/subsys-build-gn-hap-compilation-guide.md) - [分布å¼è¿œç¨‹å¯åŠ¨](subsystems/subsys-remote-start.md) - å›¾å½¢å›¾åƒ - [图形图åƒæ¦‚è¿°](subsystems/subsys-graphics-overview.md) @@ -467,9 +476,7 @@ - [å¯åŠ¨æ¢å¤å系统概述](subsystems/subsys-boot-overview.md) - [initå¯åŠ¨å¼•å¯¼ç»„件](subsystems/subsys-boot-init.md) - [appspawn应用åµåŒ–组件](subsystems/subsys-boot-appspawn.md) - - [appspawnæ ‡å‡†ç³»ç»Ÿåº”ç”¨åµåŒ–组件](subsystems/subsys-boot-appspawn-standard.md) - [bootstrapæœåŠ¡å¯åŠ¨ç»„件](subsystems/subsys-boot-bootstrap.md) - - [syspara系统属性组件](subsystems/subsys-boot-syspara.md) - [常è§é—®é¢˜](subsystems/subsys-boot-faqs.md) - [å‚考](subsystems/subsys-boot-ref.md) - DFX @@ -487,6 +494,7 @@ - [HiDumperå¼€å‘指导](subsystems/subsys-dfx-hidumper.md) - [HiCheckerå¼€å‘指导](subsystems/subsys-dfx-hichecker.md) - [Faultloggerå¼€å‘指导](subsystems/subsys-dfx-faultlogger.md) + - [Hiviewå¼€å‘指导](subsystems/subsys-dfx-hiview.md) - 专题 - HPM Part @@ -550,11 +558,237 @@ - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - å‚考 - - [常è§é—®é¢˜æ¦‚è¿°](faqs/faqs-overview.md) - - [环境æ建常è§é—®é¢˜](faqs/faqs-environment-setup.md) - - [编译构建常è§é—®é¢˜](faqs/faqs-building.md) - - [烧录常è§é—®é¢˜](faqs/faqs-burning.md) - - [å†…æ ¸å¸¸è§é—®é¢˜](faqs/faqs-kernel.md) - - [移æ¤å¸¸è§é—®é¢˜](faqs/faqs-porting.md) - - [å¯åŠ¨æ¢å¤å¸¸è§é—®é¢˜](faqs/faqs-startup.md) - - [系统应用常è§é—®é¢˜](faqs/faqs-system-applications.md) \ No newline at end of file + - 常è§é—®é¢˜ + - [常è§é—®é¢˜æ¦‚è¿°](faqs/faqs-overview.md) + - [环境æ建常è§é—®é¢˜](faqs/faqs-environment-setup.md) + - [编译构建常è§é—®é¢˜](faqs/faqs-building.md) + - [烧录常è§é—®é¢˜](faqs/faqs-burning.md) + - [å†…æ ¸å¸¸è§é—®é¢˜](faqs/faqs-kernel.md) + - [移æ¤å¸¸è§é—®é¢˜](faqs/faqs-porting.md) + - [å¯åŠ¨æ¢å¤å¸¸è§é—®é¢˜](faqs/faqs-startup.md) + - [系统应用常è§é—®é¢˜](faqs/faqs-system-applications.md) + + - HDI接å£å‚考 + - æ¨¡å— + - [Audio](reference/hdi-apis/_audio.md) + - [Battery](reference/hdi-apis/battery.md) + - [Camera](reference/hdi-apis/_camera.md) + - [Codec](reference/hdi-apis/_codec.md) + - [Display](reference/hdi-apis/_display.md) + - [HdfFaceAuth](reference/hdi-apis/_hdf_face_auth.md) + - [Input](reference/hdi-apis/_input.md) + - [Light](reference/hdi-apis/_light.md) + - [HdfPinAuth](reference/hdi-apis/_hdf_pin_auth.md) + - [Power](reference/hdi-apis/power.md) + - [Sensor](reference/hdi-apis/_sensor.md) + - [Thermal](reference/hdi-apis/thermal.md) + - [USB](reference/hdi-apis/_u_s_b.md) + - [HdfUserAuth](reference/hdi-apis/_hdf_user_auth.md) + - [Vibrator](reference/hdi-apis/_vibrator.md) + - [WLAN](reference/hdi-apis/_w_l_a_n.md) + - 头文件和结构体 + - 头文件 + - [audio_adapter.h](reference/hdi-apis/audio__adapter_8h.md) + - [audio_attribute.h](reference/hdi-apis/audio__attribute_8h.md) + - [audio_capture.h](reference/hdi-apis/audio__capture_8h.md) + - [audio_control.h](reference/hdi-apis/audio__control_8h.md) + - [audio_manager.h](reference/hdi-apis/audio__manager_8h.md) + - [audio_render.h](reference/hdi-apis/audio__render_8h.md) + - [audio_scene.h](reference/hdi-apis/audio__scene_8h.md) + - [audio_types.h](reference/hdi-apis/audio__types_8h.md) + - [audio_volume.h](reference/hdi-apis/audio__volume_8h.md) + - [codec_callback_if.h](reference/hdi-apis/codec__callback__if_8h.md) + - [codec_common_type.h](reference/hdi-apis/codec__common__type_8h.md) + - [codec_component_if.h](reference/hdi-apis/codec__component__if_8h.md) + - [codec_component_manager.h](reference/hdi-apis/codec__component__manager_8h.md) + - [codec_component_type.h](reference/hdi-apis/codec__component__type_8h.md) + - [display_device.h](reference/hdi-apis/display__device_8h.md) + - [display_gfx.h](reference/hdi-apis/display__gfx_8h.md) + - [display_gralloc.h](reference/hdi-apis/display__gralloc_8h.md) + - [display_layer.h](reference/hdi-apis/display__layer_8h.md) + - [display_type.h](reference/hdi-apis/display__type_8h.md) + - [icamera_device_callback.h](reference/hdi-apis/icamera__device__callback_8h.md) + - [icamera_device.h](reference/hdi-apis/icamera__device_8h.md) + - [icamera_host_callback.h](reference/hdi-apis/icamera__host__callback_8h.md) + - [icamera_host.h](reference/hdi-apis/icamera__host_8h.md) + - [input_controller.h](reference/hdi-apis/input__controller_8h.md) + - [input_manager.h](reference/hdi-apis/input__manager_8h.md) + - [input_reporter.h](reference/hdi-apis/input__reporter_8h.md) + - [input_type.h](reference/hdi-apis/input__type_8h.md) + - [ioffline_stream_operator.h](reference/hdi-apis/ioffline__stream__operator_8h.md) + - [istream_operator_callback.h](reference/hdi-apis/istream__operator__callback_8h.md) + - [istream_operator.h](reference/hdi-apis/istream__operator_8h.md) + - [light_if.h](reference/hdi-apis/light__if_8h.md) + - [light_type.h](reference/hdi-apis/light_8typeh.md) + - [sensor_if.h](reference/hdi-apis/sensor__if_8h.md) + - [sensor_type.h](reference/hdi-apis/sensor__type_8h.md) + - [types.h](reference/hdi-apis/types_8h.md) + - [usb_info.h](reference/hdi-apis/usb__info_8h.md) + - [usbd_client.h](reference/hdi-apis/usbd__client_8h.md) + - [usbd_subscriber.h](reference/hdi-apis/usbd__subscriber_8h.md) + - [usbd_type.h](reference/hdi-apis/usbd__type_8h.md) + - [vibrator_if.h](reference/hdi-apis/vibrator__if_8h.md) + - [vibrator_type.h](reference/hdi-apis/vibrator__type_8h.md) + - [wifi_hal_ap_feature.h](reference/hdi-apis/wifi__hal__ap__feature_8h.md) + - [wifi_hal_base_feature.h](reference/hdi-apis/wifi__hal__base__feature_8h.md) + - [wifi_hal_sta_feature.h](reference/hdi-apis/wifi__hal__sta__feature_8h.md) + - [wifi_hal.h](reference/hdi-apis/wifi__hal_8h.md) + - [IExecutor.idl](reference/hdi-apis/face__auth_2_i_executor_8idl.md) + - [IExecutorCallback.idl](reference/hdi-apis/face__auth_2_i_executor_callback_8idl.md) + - [FaceAuthTypes.idl](reference/hdi-apis/_face_auth_types_8idl.md) + - [PinAuthTypes.idl](reference/hdi-apis/_pin_auth_types_8idl.md) + - [IBatteryCallback.idl](reference/hdi-apis/_i_battery_callback_8idl.md) + - [IBatteryInterface.idl](reference/hdi-apis/_i_battery_interface_8idl.md) + - [IExecutor.idl](reference/hdi-apis/pin__auth_2_i_executor_8idl.md) + - [IExecutorCallback.idl](reference/hdi-apis/pin__auth_2_i_executor_callback_8idl.md) + - [IFaceAuthInterface.idl](reference/hdi-apis/_i_face_auth_interface_8idl.md) + - [IPinAuthInterface.idl](reference/hdi-apis/_i_pin_auth_interface_8idl.md) + - [IPowerHdiCallback.idl](reference/hdi-apis/_i_power_hdi_callback_8idl.md) + - [IPowerInterface.idl](reference/hdi-apis/_i_power_interface_8idl.md) + - [IThermalInterface.idl](reference/hdi-apis/_i_thermal_interface_8idl.md) + - [IThermalCallback.idl](reference/hdi-apis/_i_thermal_callback_8idl.md) + - [IUserAuthInterface.idl](reference/hdi-apis/_i_user_auth_interface_8idl.md) + - [PowerTypes.idl](reference/hdi-apis/_power_types_8idl.md) + - [ThermalTypes.idl](reference/hdi-apis/_thermal_types_8idl.md) + - [Types.idl](reference/hdi-apis/_types_8idl.md) + - [UserAuthTypes.idl](reference/hdi-apis/_user_auth_types_8idl.md) + - 结构体 + - [attribute](reference/hdi-apis/____attribute____.md) + - [Alignment](reference/hdi-apis/_alignment.md) + - [AllocInfo](reference/hdi-apis/_alloc_info.md) + - [AudioAdapter](reference/hdi-apis/_audio_adapter.md) + - [AudioAdapterDescriptor](reference/hdi-apis/_audio_adapter_descriptor.md) + - [AudioAttribute](reference/hdi-apis/_audio_attribute.md) + - [AudioCapture](reference/hdi-apis/_audio_capture.md) + - [AudioControl](reference/hdi-apis/_audio_control.md) + - [AudioDevExtInfo](reference/hdi-apis/_audio_dev_ext_info.md) + - [AudioDeviceDescriptor](reference/hdi-apis/_audio_device_descriptor.md) + - [AudioManager](reference/hdi-apis/_audio_manager.md) + - [AudioMixExtInfo](reference/hdi-apis/_audio_mix_ext_info.md) + - [AudioMmapBufferDescripter](reference/hdi-apis/_audio_mmap_buffer_descripter.md) + - [AudioPort](reference/hdi-apis/_audio_port.md) + - [AudioPortCap](reference/hdi-apis/_audio_port_cap.md) + - [AudioPortCapability](reference/hdi-apis/_audio_port_capability.md) + - [AudioRender](reference/hdi-apis/_audio_render.md) + - [AudioRoute](reference/hdi-apis/_audio_route.md) + - [AudioRouteNode](reference/hdi-apis/_audio_route_node.md) + - [AudioSampleAttributes](reference/hdi-apis/_audio_sample_attributes.md) + - [AudioScene](reference/hdi-apis/_audio_scene.md) + - [AudioSceneDescriptor](reference/hdi-apis/_audio_scene_descriptor.md) + - [AudioSceneDescriptor::SceneDesc](reference/hdi-apis/union_audio_scene_descriptor_1_1_scene_desc.md) + - [AudioSessionExtInfo](reference/hdi-apis/_audio_session_ext_info.md) + - [AudioSubPortCapability](reference/hdi-apis/_audio_sub_port_capability.md) + - [AudioTimeStamp](reference/hdi-apis/_audio_time_stamp.md) + - [AudioVolume](reference/hdi-apis/_audio_volume.md) + - [AuthResultInfo](reference/hdi-apis/_auth_result_info.md) + - [AuthSolution](reference/hdi-apis/_auth_solution.md) + - [BatteryInfo](reference/hdi-apis/_battery_info.md) + - [BufferData](reference/hdi-apis/_buffer_data.md) + - [CodecCallbackType](reference/hdi-apis/_codec_callback_type.md) + - [CodecCompCapability](reference/hdi-apis/_codec_comp_capability.md) + - [CodecComponentManager](reference/hdi-apis/_codec_component_manager.md) + - [CodecComponentType](reference/hdi-apis/_codec_component_type.md) + - [CompVerInfo](reference/hdi-apis/_comp_ver_info.md) + - [CredentialInfo](reference/hdi-apis/_credential_info.md) + - [DeviceFuncs](reference/hdi-apis/_device_funcs.md) + - [DisplayCapability](reference/hdi-apis/_display_capability.md) + - [DisplayInfo](reference/hdi-apis/_display_info.md) + - [DisplayModeInfo](reference/hdi-apis/_display_mode_info.md) + - [EnrolledInfo](reference/hdi-apis/_enrolled_info.md) + - [EnrollParam](reference/hdi-apis/_enroll_param.md) + - [EnrollResultInfo](reference/hdi-apis/_enroll_resultinfo.md) + - [EventInfo](reference/hdi-apis/_event_info.md) + - [ExecutorInfo](reference/hdi-apis/_executor_info.md) + - [ExecutorInfo](reference/hdi-apis/_user_executor_info.md) + - [ExecutorRegisterInfo](reference/hdi-apis/_executor_register_info.md) + - [ExecutorSendMsg](reference/hdi-apis/_executor_send_msg.md) + - [GetBufferHandleUsageParams](reference/hdi-apis/_get_buffer_handle_usage_params.md) + - [GfxFuncs](reference/hdi-apis/_gfx_funcs.md) + - [GfxOpt](reference/hdi-apis/_gfx_opt.md) + - [GrallocFuncs](reference/hdi-apis/_gralloc_funcs.md) + - [HdfThermalCallbackInfo](reference/hdi-apis/_hdf_thermal_callback_info.md) + - [HDRCapability](reference/hdi-apis/_h_d_r_capability.md) + - [HDRMetaData](reference/hdi-apis/_h_d_r_meta_data.md) + - [IBatteryCallback](reference/hdi-apis/interface_i_battery_callback.md) + - [IBatteryInterface](reference/hdi-apis/interface_i_battery_interface.md) + - [ICircle](reference/hdi-apis/_i_circle.md) + - [IdentifyResultInfo](reference/hdi-apis/_identify_result_info.md) + - [IExecutor](reference/hdi-apis/interface_i_executor.md) + - [IExecutor](reference/hdi-apis/interface_pin_i_executor.md) + - [IExecutorCallback](reference/hdi-apis/interface_i_executor_callback.md) + - [IExecutorCallback](reference/hdi-apis/interface_pin_i_executor_callback.md) + - [IFaceAuthInterface](reference/hdi-apis/interface_i_face_auth_interface.md) + - [IInputInterface](reference/hdi-apis/_i_input_interface.md) + - [ILine](reference/hdi-apis/_i_line.md) + - [InputController](reference/hdi-apis/_input_controller.md) + - [InputDevAbility](reference/hdi-apis/_input_dev_ability.md) + - [InputDevAttr](reference/hdi-apis/_input_dev_attr.md) + - [InputDevDesc](reference/hdi-apis/_input_dev_desc.md) + - [InputDevIdentify](reference/hdi-apis/_input_dev_identify.md) + - [InputDeviceInfo](reference/hdi-apis/_device_info.md) + - [InputDimensionInfo](reference/hdi-apis/_input_dimension_info.md) + - [InputEventCb](reference/hdi-apis/_input_report_event_cb.md) + - [InputEventPackage](reference/hdi-apis/_event_package.md) + - [InputExtraCmd](reference/hdi-apis/_input_extra_cmd.md) + - [InputHostCb](reference/hdi-apis/_input_host_cb.md) + - [InputHotPlugEvent](reference/hdi-apis/_input_hotplug_event.md) + - [InputManager](reference/hdi-apis/_input_manager.md) + - [InputReporter](reference/hdi-apis/_input_reporter.md) + - [IPinAuthInterface](reference/hdi-apis/interface_i_pin_auth_interface.md) + - [IPowerHdiCallback](reference/hdi-apis/interface_i_power_hdi_callback.md) + - [IPowerInterface](reference/hdi-apis/interface_i_power_interface.md) + - [IRect](reference/hdi-apis/_i_rect.md) + - [ISurface](reference/hdi-apis/_i_surface.md) + - [IThermalCallback](reference/hdi-apis/interface_i_thermal_callback.md) + - [IThermalInterface](reference/hdi-apis/interface_i_thermal_interface.md) + - [IUserAuthInterface](reference/hdi-apis/interface_i_user_auth_interface.md) + - [IWiFi](reference/hdi-apis/_i_wi_fi.md) + - [IWiFiAp](reference/hdi-apis/_i_wi_fi_ap.md) + - [IWiFiBaseFeature](reference/hdi-apis/_i_wi_fi_base_feature.md) + - [IWiFiSta](reference/hdi-apis/_i_wi_fi_sta.md) + - [LayerAlpha](reference/hdi-apis/_layer_alpha.md) + - [LayerBuffer](reference/hdi-apis/_layer_buffer.md) + - [LayerFuncs](reference/hdi-apis/_layer_funcs.md) + - [LayerInfo](reference/hdi-apis/_layer_info.md) + - [LightEffect](reference/hdi-apis/_light_effect.md) + - [LightFlashEffect](reference/hdi-apis/_light_flash_effect.md) + - [LightInfo](reference/hdi-apis/_light_info.md) + - [LightInterface](reference/hdi-apis/_light_interface.md) + - [OHOS::Camera::CaptureEndedInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_ended_info.md) + - [OHOS::Camera::CaptureErrorInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_error_info.md) + - [OHOS::Camera::CaptureInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_capture_info.md) + - [OHOS::Camera::ICameraDevice](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device.md) + - [OHOS::Camera::ICameraDeviceCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_device_callback.md) + - [OHOS::Camera::ICameraHost](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host.md) + - [OHOS::Camera::ICameraHostCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_camera_host_callback.md) + - [OHOS::Camera::IOfflineStreamOperator](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_offline_stream_operator.md) + - [OHOS::Camera::IStreamOperator](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator.md) + - [OHOS::Camera::IStreamOperatorCallback](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_i_stream_operator_callback.md) + - [OHOS::Camera::StreamAttribute](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_attribute.md) + - [OHOS::Camera::StreamInfo](reference/hdi-apis/_o_h_o_s_1_1_camera_1_1_stream_info.md) + - [OHOS::USB::UsbCtrlTransfer](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_ctrl_transfer.md) + - [OHOS::USB::UsbdClient](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_client.md) + - [OHOS::USB::UsbDev](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_dev.md) + - [OHOS::USB::USBDeviceInfo](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_u_s_b_device_info.md) + - [OHOS::USB::UsbdSubscriber](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usbd_subscriber.md) + - [OHOS::USB::UsbInfo](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_info.md) + - [OHOS::USB::UsbPipe](reference/hdi-apis/_o_h_o_s_1_1_u_s_b_1_1_usb_pipe.md) + - [OmxCodecBuffer](reference/hdi-apis/_omx_codec_buffer.md) + - [PortCap](reference/hdi-apis/union_port_cap.md) + - [PresentTimestamp](reference/hdi-apis/_present_timestamp.md) + - [PropertyObject](reference/hdi-apis/_property_object.md) + - [RangeValue](reference/hdi-apis/_range_value.md) + - [Rect](reference/hdi-apis/_rect.md) + - [Rectangle](reference/hdi-apis/_rectangle.md) + - [ScheduleInfo](reference/hdi-apis/_schedule_info.md) + - [SensorEvents](reference/hdi-apis/_sensor_events.md) + - [SensorInformation](reference/hdi-apis/_sensor_information.md) + - [SensorInterface](reference/hdi-apis/_sensor_interface.md) + - [StaInfo](reference/hdi-apis/_sta_info.md) + - [SupportBufferType](reference/hdi-apis/_support_buffer_type.md) + - [TemplateInfo](reference/hdi-apis/_template_info.md) + - [ThermalZoneInfo](reference/hdi-apis/_thermal_zone_info.md) + - [UseBufferType](reference/hdi-apis/_use_buffer_type.md) + - [VerifyAllocInfo](reference/hdi-apis/_verify_alloc_info.md) + - [VibratorInterface](reference/hdi-apis/_vibrator_interface.md) + - [VideoPortCap](reference/hdi-apis/_video_port_cap.md) \ No newline at end of file diff --git a/zh-cn/glossary.md b/zh-cn/glossary.md index 6bf069541423e98103d141d6bb7142d54ac565ce..f165d1f467caffacb153d9af265a4a22fa4bfccc 100644 --- a/zh-cn/glossary.md +++ b/zh-cn/glossary.md @@ -99,6 +99,6 @@ 两ç§Ability框架模型结构的其ä¸ä¸€ç§ã€‚从API 9开始支æŒã€‚Stage模型将Ability分为Abilityå’ŒExtensionAbility两大类,其ä¸ExtensionAbilityåˆè¢«æ‰©å±•ä¸ºServiceExtensionAbilityã€FormExtensionAbilityã€DataShareExtensionAbilityç‰ç‰ä¸€ç³»åˆ—ExtensionAbility。 - ### System Type,系统类型 - - Mini System,轻é‡ç³»ç»Ÿï¼šé¢å‘MCU类处ç†å™¨ï¼Œä¾‹å¦‚ARM Cortex-Mã€RISC-V 32ä½çš„设备,资æºæžå…¶æœ‰é™ï¼Œå‚考内å˜â‰¥128KiB,æ供丰富的近è·è¿žæŽ¥èƒ½åŠ›ä»¥åŠä¸°å¯Œçš„外设总线访问能力。典型产å“有智能家居领域的è”接类模组ã€ä¼ 感器设备ç‰ã€‚ + - MiniSystem,轻é‡ç³»ç»Ÿï¼šé¢å‘MCU(Microcontroller Unit,微控制å•å…ƒï¼‰ç±»å¤„ç†å™¨ï¼Œä¾‹å¦‚ARM Cortex-Mã€RISC-V 32ä½çš„设备,资æºæžå…¶æœ‰é™ï¼Œå‚考内å˜â‰¥128KiB,æ供丰富的近è·è¿žæŽ¥èƒ½åŠ›ä»¥åŠä¸°å¯Œçš„外设总线访问能力。典型产å“有智能家居领域的è”接类模组ã€ä¼ 感器设备ç‰ã€‚ - Small System,å°åž‹ç³»ç»Ÿï¼šé¢å‘应用处ç†å™¨ï¼Œä¾‹å¦‚Arm Cortex-A的设备,å‚考内å˜â‰¥1MiB,æ供更高的安全能力,æä¾›æ ‡å‡†çš„å›¾å½¢æ¡†æž¶ï¼Œæ供视频编解ç 的多媒体能力。典型产å“有智能家居领域的IPCameraã€ç”µå猫眼ã€è·¯ç”±å™¨ä»¥åŠæ™ºæ…§å‡ºè¡ŒåŸŸçš„行车记录仪ç‰ã€‚ - Standard Systemï¼Œæ ‡å‡†ç³»ç»Ÿï¼šé¢å‘应用处ç†å™¨ï¼Œä¾‹å¦‚Arm Cortex-A的设备,å‚考内å˜â‰¥128MiB,æ供增强的交互能力,æä¾›3D GPU以åŠç¡¬ä»¶åˆæˆèƒ½åŠ›ï¼Œæ供更多控件以åŠåŠ¨æ•ˆæ›´ä¸°å¯Œçš„图形能力,æ供完整的应用框架。典型产å“有高端的冰箱显示å±ç‰ã€‚ diff --git "a/zh-cn/readme/DeviceProfile\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/DeviceProfile\345\255\220\347\263\273\347\273\237.md" index 33e5add0abea9745753ab17403301d41988599b0..2831dfc08802621314c8fa80a2e53bd0f06643b7 100755 --- "a/zh-cn/readme/DeviceProfile\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/DeviceProfile\345\255\220\347\263\273\347\273\237.md" @@ -192,4 +192,4 @@ DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEv **DeviceProfileå系统** -[device\_profile\_core](https://gitee.com/openharmony/device_profile_core) \ No newline at end of file +[device\_info\_manager](https://gitee.com/openharmony/deviceprofile_device_info_manager) \ No newline at end of file diff --git a/zh-cn/readme/figures/location_En-1.png b/zh-cn/readme/figures/location_En-1.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae4bcd7173f2e95004c96fa13d420c09f017f76 Binary files /dev/null and b/zh-cn/readme/figures/location_En-1.png differ diff --git a/zh-cn/readme/figures/location_zh-1.png b/zh-cn/readme/figures/location_zh-1.png new file mode 100644 index 0000000000000000000000000000000000000000..3638a47483ec2e0f0d8443e3ab2410b333886118 Binary files /dev/null and b/zh-cn/readme/figures/location_zh-1.png differ diff --git "a/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" index 58fdeb7e52f8528d7a42e35ab1601a3ea4a0b39d..62c1be27a8e6dda14147674172ed944bdd361cbe 100644 --- "a/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\344\275\215\347\275\256\346\234\215\345\212\241\345\255\220\347\263\273\347\273\237.md" @@ -15,9 +15,9 @@ 当用户处于这些丰富的使用场景ä¸æ—¶ï¼Œç³»ç»Ÿçš„ä½ç½®èƒ½åŠ›å¯ä»¥æ供实时准确的ä½ç½®æ•°æ®ã€‚对于开å‘者,设计基于ä½ç½®ä½“验的æœåŠ¡ï¼Œä¹Ÿå¯ä»¥ä½¿åº”用的使用体验更贴近æ¯ä¸ªç”¨æˆ·ã€‚ -当应用在实现基于设备ä½ç½®çš„功能时,如:驾车导航,记录è¿åŠ¨è½¨è¿¹ç‰ï¼Œå¯ä»¥è°ƒç”¨è¯¥æ¨¡å—çš„API接å£ï¼Œå®Œæˆä½ç½®ä¿¡æ¯çš„èŽ·å– +当应用在实现基于设备ä½ç½®çš„功能时,如:驾车导航,记录è¿åŠ¨è½¨è¿¹ç‰ï¼Œå¯ä»¥è°ƒç”¨è¯¥æ¨¡å—çš„API接å£ï¼Œå®Œæˆä½ç½®ä¿¡æ¯çš„获å–。 -基本概念 +**基本概念** ä½ç½®èƒ½åŠ›ç”¨äºŽç¡®å®šç”¨æˆ·è®¾å¤‡åœ¨å“ªé‡Œï¼Œç³»ç»Ÿä½¿ç”¨ä½ç½®åæ ‡æ ‡ç¤ºè®¾å¤‡çš„ä½ç½®ï¼Œå¹¶ç”¨å¤šç§å®šä½æŠ€æœ¯æä¾›æœåŠ¡ï¼Œå¦‚GNSS定ä½ã€åŸºç«™å®šä½ã€WLAN/è“牙定ä½ï¼ˆåŸºç«™å®šä½ã€WLAN/è“牙定ä½åŽç»ç»Ÿç§°â€œç½‘络定ä½æŠ€æœ¯â€ï¼‰ã€‚通过这些定ä½æŠ€æœ¯ï¼Œæ— 论用户设备在室内或是户外,都å¯ä»¥å‡†ç¡®åœ°ç¡®å®šè®¾å¤‡ä½ç½®ã€‚ @@ -40,7 +40,7 @@ **图 1** **å系统架构图**<a name="fig4460722185514"></a> - + ## 目录<a name="section161941989596"></a> @@ -127,7 +127,7 @@ å¼€å‘者å¯ä»¥åœ¨åº”用config.json文件ä¸å£°æ˜Žæ‰€éœ€è¦çš„æƒé™ï¼Œç¤ºä¾‹ä»£ç 如下: - + ``` { "module": { @@ -145,10 +145,10 @@ } ``` - é…ç½®å—段详细说明è§ã€‚ + é…ç½®å—段详细说明è§[应用包结构é…置文件的说明](../application-dev/quick-start/stage-structure.md)。 2. 导入geolocation模å—,所有与基础定ä½èƒ½åŠ›ç›¸å…³çš„功能API,都是通过该模å—æ供的。 - + ``` import geolocation from '@ohos.geolocation'; ``` @@ -159,7 +159,7 @@ 为了é¢å‘å¼€å‘者æ供贴近其使用场景的API使用方å¼ï¼Œç³»ç»Ÿå®šä¹‰äº†å‡ ç§å¸¸è§çš„ä½ç½®èƒ½åŠ›ä½¿ç”¨åœºæ™¯ï¼Œå¹¶é’ˆå¯¹ä½¿ç”¨åœºæ™¯åšäº†é€‚当的优化处ç†ï¼Œåº”用å¯ä»¥ç›´æŽ¥åŒ¹é…使用,简化开å‘å¤æ‚度。系统当å‰æ”¯æŒåœºæ™¯å¦‚下表所示。 - + ``` export enum LocationRequestScenario { UNSET = 0x300, @@ -171,7 +171,7 @@ } ``` - + **表2** 定ä½åœºæ™¯ç±»åž‹è¯´æ˜Ž | 场景å称 | 常é‡å®šä¹‰ | 说明 | @@ -183,7 +183,7 @@ | æ— åŠŸè€—åœºæ™¯ | NO_POWER | æ— åŠŸè€—åœºæ™¯ï¼Œé€‚ç”¨äºŽä¸éœ€è¦ä¸»åŠ¨å¯åŠ¨å®šä½ä¸šåŠ¡ã€‚系统在å“应其他应用å¯åŠ¨å®šä½ä¸šåŠ¡å¹¶ä¸ŠæŠ¥ä½ç½®ç»“果时,会åŒæ—¶å‘请求æ¤åœºæ™¯çš„应用程åºä¸ŠæŠ¥å®šä½ç»“果,当å‰çš„应用程åºä¸äº§ç”Ÿå®šä½åŠŸè€—。<br/>æ¤åœºæ™¯é»˜è®¤ä»¥æœ€å°1秒间隔上报定ä½ç»“果,并且应用需è¦ç”³è¯·ohos.permission.LOCATIONæƒé™ï¼ŒåŒæ—¶èŽ·å¾—用户授æƒã€‚ | 以导航场景为例,实例化方å¼å¦‚下: - + ``` var requestInfo = {'scenario': 0x301, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` @@ -192,7 +192,7 @@ 如果定义的现有场景类型ä¸èƒ½æ»¡è¶³æ‰€éœ€çš„å¼€å‘场景,系统æ供了基本的定ä½ä¼˜å…ˆçº§ç–略类型。 - + ``` export enum LocationRequestPriority { UNSET = 0x200, @@ -202,7 +202,7 @@ } ``` - + **表3** 定ä½ä¼˜å…ˆçº§ç–略类型说明: | ç–略类型 | 常é‡å®šä¹‰ | 说明 | @@ -212,7 +212,7 @@ | 低功耗定ä½ä¼˜å…ˆç–ç•¥ | LOW_POWER | 低功耗定ä½ä¼˜å…ˆç–略主è¦ä½¿ç”¨åŸºç«™å®šä½å’ŒWLANã€è“牙定ä½æŠ€æœ¯ï¼Œä¹Ÿå¯ä»¥åŒæ—¶æ供室内和户外场景下的ä½ç½®æœåŠ¡ï¼Œå› 为其ä¾èµ–周边基站ã€å¯è§WLANã€è“牙设备的分布情况,定ä½ç»“果的精度波动范围较大,如果对定ä½ç»“果精度è¦æ±‚ä¸é«˜ï¼Œæˆ–者使用场景多在有基站ã€å¯è§WLANã€è“牙设备高密度分布的情况下,推è使用,å¯ä»¥æœ‰æ•ˆèŠ‚çœè®¾å¤‡åŠŸè€—。<br/>应用至少申请ohos.permission.LOCATIONæƒé™ï¼ŒåŒæ—¶èŽ·å¾—用户授æƒã€‚ | 以定ä½ç²¾åº¦ä¼˜å…ˆç–略为例,实例化方å¼å¦‚下: - + ``` var requestInfo = {'priority': 0x201, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` @@ -227,19 +227,19 @@ ``` 5. å¯åŠ¨å®šä½ã€‚ - + ``` geolocation.on('locationChange', requestInfo, locationChange); ``` 6. (å¯é€‰ï¼‰ç»“æŸå®šä½ã€‚ - + ``` geolocation.off('locationChange', locationChange); ``` 如果应用使用场景ä¸éœ€è¦å®žæ—¶çš„设备ä½ç½®ï¼Œå¯ä»¥èŽ·å–系统缓å˜çš„最近一次历å²å®šä½ç»“果。 - + ``` geolocation.getLastLocation((data) => { console.log('getLastLocation: data: ' + JSON.stringify(data)); @@ -256,14 +256,14 @@ > GeoConvert需è¦è®¿é—®åŽç«¯æœåŠ¡ï¼Œè¯·ç¡®ä¿è®¾å¤‡è”网,以进行信æ¯èŽ·å–。 1. 导入geolocation模å—,所有与(逆)地ç†ç¼–ç 转化能力相关的功能API,都是通过该模å—æ供的。 - + ``` import geolocation from '@ohos.geolocation'; ``` 2. 获å–转化结果。 - 调用getAddressesFromLocation,åæ ‡è½¬åŒ–åœ°ç†ä½ç½®ä¿¡æ¯ã€‚ - + ``` var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest, (data) => { @@ -273,7 +273,7 @@ å‚考接å£API说明,应用å¯ä»¥èŽ·å¾—与æ¤åæ ‡åŒ¹é…çš„GeoAddress列表,应用å¯ä»¥æ ¹æ®å®žé™…使用需求,读å–相应的å‚æ•°æ•°æ®ã€‚ - 调用getAddressesFromLocationNameä½ç½®æ述转化åæ ‡ã€‚ - + ``` var geocodeRequest = {"description": "上海市浦东新区xxè·¯xxå·", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest, (data) => { diff --git "a/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" index 53e16d1b619e6bfa1c38136b3a12598a0b6f9501..70122fe375a520f3f7fbceeb41ca91c13323ab9e 100644 --- "a/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\206\205\346\240\270\345\255\220\347\263\273\347\273\237.md" @@ -222,8 +222,6 @@ LiteOS: [device\_qemu](https://gitee.com/openharmony/device_qemu/blob/master/README_zh.md) -[prebuilts\_lite\_sysroot](https://gitee.com/openharmony/prebuilts_lite_sysroot/blob/master/README_zh.md) - Linux: [kernel\_linux\_patches](https://gitee.com/openharmony/kernel_linux_patches/blob/master/README_zh.md) diff --git a/zh-cn/release-notes/OpenHarmony-v3.0.5-LTS.md b/zh-cn/release-notes/OpenHarmony-v3.0.5-LTS.md index e5455a0cddd1a108ccc2c3c3a1ded6a627242e63..8d577c913225e56646a90f16a8c4d9d12a1a6163 100644 --- a/zh-cn/release-notes/OpenHarmony-v3.0.5-LTS.md +++ b/zh-cn/release-notes/OpenHarmony-v3.0.5-LTS.md @@ -5,7 +5,7 @@ æ¤ç‰ˆæœ¬ä¸ºOpenHarmony-3.0-LTS分支上的维护版本,基于OpenHarmony-v3.0.3-LTS版本修å¤ä¸€äº›ç¼ºé™·åŠå®‰å…¨é—®é¢˜ï¼Œå¹¶æ›´æ–°æ”¯æŒä»¥ä¸‹èƒ½åŠ›ï¼š -**è½»é‡ç³»ç»Ÿèƒ½åŠ›å¢žå¼º** +**å°åž‹ç³»ç»Ÿèƒ½åŠ›å¢žå¼º** DFXæä¾›native崩溃信æ¯é‡‡é›†èƒ½åŠ›å’Œæ•´æœºé‡å¯æ•…障检测定ä½èƒ½åŠ›ã€‚åŸºç¡€é€šä¿¡å¢žåŠ STA基础能力。 diff --git a/zh-cn/release-notes/OpenHarmony-v3.2-beta2.md b/zh-cn/release-notes/OpenHarmony-v3.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..18992d1e2478d51993d4cf7f1d2ee9bd90897428 --- /dev/null +++ b/zh-cn/release-notes/OpenHarmony-v3.2-beta2.md @@ -0,0 +1,217 @@ +# OpenHarmony 3.2 Beta2 + + +## 版本概述 + +当å‰ç‰ˆæœ¬åœ¨OpenHarmony 3.2 Beta1的基础上,更新支æŒä»¥ä¸‹èƒ½åŠ›ï¼š + +**æ ‡å‡†ç³»ç»ŸåŸºç¡€èƒ½åŠ›å¢žå¼º** + +新增支æŒçª—å£å¤šçƒåŒºåˆ†å‘机制。 + +支æŒç”µæºç®¡ç†é‡å¯æ¢å¤æœºåˆ¶ã€‚ + +多模输入新增支æŒInput手写笔压感åˆæˆã€å€¾è§’ã€æŒ‰é”®è¾“入。 + +安全域支æŒé¢„置应用预授æƒæœºåˆ¶ã€æŒ‡çº¹å½•å…¥/认è¯/识别框架。 + +驱动支æŒå½•åƒæ¨¡å¼è‡ªæ‹é•œåƒåŠŸèƒ½ã€éŸ³é¢‘音效控制ã€çº¢å¤–设备输入ã€éŸ³é¢‘USBæ’拔识别åŠäº‹ä»¶ä¸ŠæŠ¥ã€‚ + +**æ ‡å‡†ç³»ç»Ÿåº”ç”¨ç¨‹åºæ¡†æž¶èƒ½åŠ›å¢žå¼º** + +元能力支æŒå¡ç‰‡æä¾›æ–¹æ·»åŠ é™æ€å’ŒåŠ¨æ€å¡ç‰‡ã€ç»„件支æŒæœ¬åœ°å…安装å¯åŠ¨ã€ç³»ç»ŸSAå¯åŠ¨å’Œè®¿é—®ç»„件ã€æ”¯æŒå•å®žä¾‹Abilityè¿ç§»ã€è¿è¡Œç®¡ç†æ”¯æŒæ‰“开沙箱应用ã€ç³»ç»Ÿåº”用abilityä¸åœ¨æœ€æ–°ä»»åŠ¡åˆ—表显示。 + +包管ç†æ”¯æŒèŽ·å–当å‰åŒ…的包åå’Œè¯ä¹¦æŒ‡çº¹ä¿¡æ¯NDK接å£èƒ½åŠ›ã€æŸ¥è¯¢æŒ‡å®šåº”用的PackInfoä¿¡æ¯ã€åŽŸå化æœåŠ¡è€åŒ–å¸è½½ã€‚ + +**æ ‡å‡†ç³»ç»Ÿåº”ç”¨å¼€å‘æ ·ä¾‹** + +新增五å棋人机对战ã€äºŒç»´ç 生æˆå’Œè§£æžã€å¡ç‰‡ä½¿ç”¨ã€å¤šåª’体ã€çŸè§†é¢‘ã€é¢éƒ¨è¯†åˆ«èƒ½åŠ›ç‰Demoæ ·ä¾‹ï¼Œä¸ºå¼€å‘者æä¾›SDKä½¿ç”¨çš„æ ·ä¾‹ç¨‹åºï¼Œæ–¹ä¾¿å¼€å‘者快速上手使用OpenHarmony系统基础能力。 + + +## é…套关系 + + **表1** 版本软件和工具é…套关系 + +| 软件 | 版本 | 备注 | +| -------- | -------- | -------- | +| OpenHarmony | 3.2 Beta2 | NA | +| Public SDK | Ohos_sdk_public 3.2.5.5 (API Version 9 Beta2) | é¢å‘应用开å‘者æ供,ä¸åŒ…å«éœ€è¦ä½¿ç”¨ç³»ç»Ÿæƒé™çš„系统接å£ã€‚<br/>通过DevEco Studio默认获å–çš„SDK为Public SDK。 | +| Full SDK | Ohos_sdk_full 3.2.5.5 (API Version 9 Beta2) | é¢å‘OEM厂商æ供,包å«äº†éœ€è¦ä½¿ç”¨ç³»ç»Ÿæƒé™çš„系统接å£ã€‚<br/>使用Full SDK时需è¦æ‰‹åŠ¨ä»Žé•œåƒç«™ç‚¹èŽ·å–,并在DevEco Studioä¸æ›¿æ¢ï¼Œå…·ä½“æ“作å¯å‚考[替æ¢æŒ‡å—](../application-dev/quick-start/full-sdk-switch-guide.md)。 | +| HUAWEI DevEco Studio(å¯é€‰ï¼‰ | 3.0 Beta4 | OpenHarmony应用开å‘推è使用。 | +| HUAWEI DevEco Device Tool(å¯é€‰ï¼‰ | 3.0 Release | OpenHarmony智能设备集æˆå¼€å‘环境推è使用。 | + + +## æºç èŽ·å– + + +### å‰ææ¡ä»¶ + +1. 注册ç 云giteeå¸å·ã€‚ + +2. 注册ç 云SSH公钥,请å‚考[ç 云帮助ä¸å¿ƒ](https://gitee.com/help/articles/4191)。 + +3. 安装[git客户端](https://gitee.com/link?target=https%3A%2F%2Fgit-scm.com%2Fbook%2Fzh%2Fv2%2F%25E8%25B5%25B7%25E6%25AD%25A5-%25E5%25AE%2589%25E8%25A3%2585-Git)å’Œ[git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading)并é…置用户信æ¯ã€‚ + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. 安装ç 云repo工具,å¯ä»¥æ‰§è¡Œå¦‚下命令。 + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo #如果没有æƒé™ï¼Œå¯ä¸‹è½½è‡³å…¶ä»–目录,并将其é…置到环境å˜é‡ä¸chmod a+x /usr/local/bin/repo + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### 通过repoèŽ·å– + +**æ–¹å¼ä¸€ï¼ˆæŽ¨è)** + +通过repo + ssh 下载(需注册公钥,请å‚考[ç 云帮助ä¸å¿ƒ](https://gitee.com/help/articles/4191))。 + +- 从版本分支获å–æºç 。å¯èŽ·å–该版本分支的最新æºç ,包括版本å‘布åŽåœ¨è¯¥åˆ†æ”¯çš„åˆå…¥ã€‚ + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Beta2 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- 从版本å‘布Tag节点获å–æºç 。å¯èŽ·å–与版本å‘布时完全一致的æºç 。 + ``` + repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.2-Beta2 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +**æ–¹å¼äºŒ** + +通过repo + https 下载。 + +- 从版本分支获å–æºç 。å¯èŽ·å–该版本分支的最新æºç ,包括版本å‘布åŽåœ¨è¯¥åˆ†æ”¯çš„åˆå…¥ã€‚ + ``` + repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-3.2-Beta2 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +- 从版本å‘布Tag节点获å–æºç 。å¯èŽ·å–与版本å‘布时完全一致的æºç 。 + ``` + repo init -u https://gitee.com/openharmony/manifest -b refs/tags/OpenHarmony-v3.2-Beta2 --no-repo-verify + repo sync -c + repo forall -c 'git lfs pull' + ``` + +### 从镜åƒç«™ç‚¹èŽ·å– + +**表2** 获å–æºç 路径 + +| 版本æºç | **版本信æ¯** | **下载站点** | **SHA256æ ¡éªŒç ** | +| --------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| å…¨é‡ä»£ç ï¼ˆæ ‡å‡†ã€è½»é‡å’Œå°åž‹ç³»ç»Ÿï¼‰ | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256) | +| Hi3861è½»é‡ç³»ç»Ÿè§£å†³æ–¹æ¡ˆï¼ˆäºŒè¿›åˆ¶ï¼‰ | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) | +| Hi3516è½»é‡ç³»ç»Ÿè§£å†³æ–¹æ¡ˆ-LiteOS(二进制) | 3.2 Beta2 | [站点](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 Beta2 | [站点](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) | +| RK3568æ ‡å‡†ç³»ç»Ÿè§£å†³æ–¹æ¡ˆï¼ˆäºŒè¿›åˆ¶ï¼‰ | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/dayu200_standard_arm64.tar.gz.sha256) | +| æ ‡å‡†ç³»ç»ŸFull SDK包(Mac) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-full.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-full.tar.gz.sha256) | +| æ ‡å‡†ç³»ç»ŸFull SDK包(Windows\Linux) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-full.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-full.tar.gz.sha256) | +| æ ‡å‡†ç³»ç»ŸPublic SDK包(Mac) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-public.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-mac-public.tar.gz.sha256) | +| æ ‡å‡†ç³»ç»ŸPublic SDK包(Windows\Linux) | 3.2 Beta2 | [站点](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-public.tar.gz) | [SHA256æ ¡éªŒç ](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/ohos-sdk-windows_linux-public.tar.gz.sha256) | + + +## 更新说明 + +本版本在OpenHarmony 3.2 Beta1的基础上有如下å˜æ›´ã€‚ + +### SDKå˜æ›´ +从本版本起,SDK会åŒæ—¶æä¾›Public SDKå’ŒFull SDK。通过DevEco Studio默认获å–çš„SDK为Public SDK。 + +已使用较早版本SDKå¼€å‘的应用如果使用到了系统API,å‡çº§æœ¬ç‰ˆæœ¬åŽéœ€è¦[手动替æ¢SDK为Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md)æ‰å¯ä»¥ä¿è¯åº”用工程å¯ç¼–译通过。 + +### 特性å˜æ›´ + + **表3** 版本特性å˜æ›´è¡¨ + +| å系统å称 | æ ‡å‡†ç³»ç»Ÿ | è½»é‡ã€å°åž‹ç³»ç»Ÿ | +| -------- | -------- | -------- | +| 元能力 | - 为支æŒIoTè®¾å¤‡æ— UI应用开å‘,对graphicså’Œpower模å—进行解耦。<br/>- 对DFX能力ã€ä»»åŠ¡ç®¡ç†èƒ½åŠ›ã€åº”用线程模型管ç†èƒ½åŠ›ç‰åŸºç¡€èƒ½åŠ›è¿›è¡Œäº†å¢žå¼ºã€‚<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I57ZUI ã€æ–°å¢žç‰¹æ€§ã€‘支æŒIoTè®¾å¤‡æ— UI应用开å‘-graphics模å—解耦<br/>I57ZVC ã€æ–°å¢žç‰¹æ€§ã€‘支æŒIoTè®¾å¤‡æ— UI应用开å‘-power模å—解耦<br/>I5805B ã€å¢žå¼ºç‰¹æ€§ã€‘AMS ANR功能优化<br/>I581M3 ã€æ–°å¢žç‰¹æ€§ã€‘应用选择框<br/>I580JM ã€æ–°å¢žç‰¹æ€§ã€‘支æŒç³»ç»Ÿåº”用abilityä¸åœ¨æœ€æ–°ä»»åŠ¡åˆ—表显示<br/>I5FHNH ã€å¢žå¼ºç‰¹æ€§ã€‘Stage模型Context对象支æŒå‘workerä¼ é€’<br/>I58034 ã€å¢žå¼ºç‰¹æ€§ã€‘使用libuv统一JS Looper机制<br/>I57ZZH ã€æ–°å¢žç‰¹æ€§ã€‘æ供创建ä¸åŒHap包上下文能力 | NA | +| åŒ…ç®¡ç† | 新增默认应用管ç†èƒ½åŠ›ï¼Œæ”¯æŒä¼—测应用ã€èŽ·å–包指纹信æ¯ç‰åŸºç¡€èƒ½åŠ›ã€‚<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I56WD7 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæŸ¥è¯¢é»˜è®¤åº”用<br/>I56WDJ ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæ›´æ”¹é»˜è®¤åº”用<br/>I56WDR ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæ¢å¤ç³»ç»Ÿé»˜è®¤åº”用<br/>I56WEK ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæŒ‰æ–‡ä»¶ç±»åž‹è®¾ç½®é»˜è®¤åº”用<br/>I59ZMR ã€æ–°å¢žç‰¹æ€§ã€‘包管ç†æ”¯æŒä¼—测应用<br/>I5A7OV ã€æ–°å¢žç‰¹æ€§ã€‘包管ç†æä¾›NDK接å£ï¼ŒèŽ·å–当å‰åŒ…的包åå’Œè¯ä¹¦æŒ‡çº¹ä¿¡æ¯ | NA | +| 电æºå系统 | 新增çƒç®¡ç†çš„资æºç®¡æŽ§å’Œæ—¥å¿—,功耗统计支æŒæ›´å¤šæ¨¡å—。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I5AOM8 ã€æ–°å¢žç‰¹æ€§ã€‘å¢žåŠ Action Hub功能<br/>I5DC5E ã€å¢žå¼ºç‰¹æ€§ã€‘Camera耗电统计<br/>I5DC7M ã€å¢žå¼ºç‰¹æ€§ã€‘Audio耗电统计<br/>I5DC8L ã€å¢žå¼ºç‰¹æ€§ã€‘Timer功耗DFX<br/>I5DC9H ã€å¢žå¼ºç‰¹æ€§ã€‘分布å¼ä»»åŠ¡è°ƒåº¦åŠŸè€—DFX<br/>I5DOP4 ã€æ–°å¢žç‰¹æ€§ã€‘çƒç»´æµ‹DFX<br/>I5DONL ã€æ–°å¢žç‰¹æ€§ã€‘充电资æºç®¡æŽ§æ¡†æž¶<br/>I5DOLA ã€æ–°å¢žç‰¹æ€§ã€‘适é…SOC资æºç®¡æŽ§æ¡†æž¶ | NA | +| 系统æœåŠ¡ç®¡ç†å系统 | - æŒç»æž„建分布å¼åŸºç¡€èƒ½åŠ›ã€‚<br/>- åŠ å›ºç³»ç»ŸæœåŠ¡è¿›ç¨‹ç¨³å®šæ€§ã€å®‰å…¨æ€§ï¼Œä¼˜åŒ–进程内å˜ã€‚<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I5FLTY ã€æ–°å¢žç‰¹æ€§ã€‘组件ååŒå…³ç³»ç®¡ç†<br/>I5DP1O ã€æ–°å¢žç‰¹æ€§ã€‘DMSæ供系统事件ã€SA dumpã€trace打点<br/>I5CEMN ã€æ–°å¢žç‰¹æ€§ã€‘startAbilityForResult支æŒå…安装<br/>I5BAP0 ã€æ–°å¢žç‰¹æ€§ã€‘startAbility支æŒè·¨è®¾å¤‡å…安装<br/>I5B2PK ã€æ–°å¢žç‰¹æ€§ã€‘跨端è¿ç§»é€‚é…分布å¼å¯¹è±¡æŒä¹…化ä¿å˜<br/>I59XYB ã€æ–°å¢žç‰¹æ€§ã€‘æ·»åŠ ç¾¤ç»„æ ¡éªŒæœºåˆ¶<br/>I592I5 ã€æ–°å¢žç‰¹æ€§ã€‘distributedsche进程内å˜åŸºçº¿<br/>I5E4KV ã€æ–°å¢žç‰¹æ€§ã€‘SAMGRæ供系统事件ã€SA dumpã€trace打点 | NA | +| 事件通知å系统 | - 新增支æŒå·¥å…·é€‚é…多用户。<br/>- 公共事件和通知基础能力增强。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I582V2 ã€æ–°å¢žè§„æ ¼ã€‘æ”¯æŒç‚¹å¯¹ç‚¹å‘é€äº‹ä»¶â€‹<br/>I582XB ã€æ–°å¢žè§„æ ¼ã€‘å·¥å…·é€‚é…多用户<br/>I582UL ã€å¢žå¼ºç‰¹æ€§ã€‘分布å¼é€šçŸ¥åŒæ¥å¢žå¼º<br/>I582QQ ã€æ–°å¢žè§„æ ¼ã€‘é€šçŸ¥å‘é€æ”¯æŒè®¾ç½®æœªè¯»è§’æ ‡<br/>I582XB ã€æ–°å¢žè§„æ ¼ã€‘å·¥å…·é€‚é…多用户<br/>I582SD ã€DFX】ã€å¢žå¼ºç‰¹æ€§ã€‘通知DFX能力增强<br/>I582ST ã€æ–°å¢žè§„æ ¼ã€‘æ”¯æŒé…置通知清ç†äº‹ä»¶<br/>I582TF ã€å¢žå¼ºç‰¹æ€§ã€‘é€šçŸ¥æ¸ é“ä¿¡æ¯è®¾ç½®å’ŒæŸ¥è¯¢å¢žå¼º<br/>I58418 ã€æ–°å¢žè§„æ ¼ã€‘ã€äº‹ä»¶é€šçŸ¥å系统】事件通知å系统的SELinuxç–ç•¥é…ç½®<br/>I582Y4 ã€DFX打点】ã€äº‹ä»¶é€šçŸ¥å系统】æ供系统事件ã€SA dumpã€trace打点 | NA | +| 分布å¼ç¡¬ä»¶å系统 | 新增DeviceManager支æŒåŒå¸å·å‡æ®å‚数请求和导入ç‰ç‰¹æ€§ã€‚<br/>I5IUUS ã€DFX打点】ã€åˆ†å¸ƒå¼ç¡¬ä»¶å系统】æ供系统事件ã€SA dumpã€trace打点<br/>I5IUVN ã€æ–°å¢žç‰¹æ€§ã€‘支æŒåŒå¸å·å‡æ®å‚数请求和导入 | NA | +| 用户IAMå系统 | - æŒç»å¢žå¼ºç”¨æˆ·è®¤è¯çš„基础能力。<br/>- 新增用户IAM框架,支æŒæŒ‡çº¹å½•å…¥ã€è®¤è¯ã€è¯†åˆ«ã€åˆ 除功能。<br/>I5EPCD 支æŒå®ŒæˆæŒ‡å®šç”¨æˆ·çš„指纹录入ã€æ¡†æž¶ã€‘<br/>I5EPCM 支æŒå®ŒæˆæŒ‡å®šç”¨æˆ·çš„指纹认è¯å’ŒæŒ‡çº¹è¯†åˆ«ã€æ¡†æž¶ã€‘<br/>I5EPCU 支æŒå®ŒæˆæŒ‡å®šç”¨æˆ·çš„指纹认è¯åˆ 除ã€æ¡†æž¶ã€‘ | NA | +| 编译构建å系统 | - 对pythonå’Œgn进行版本å‡çº§ã€‚<br/>- 新增系统组件拆分独立编译。<br/>- 在模å—ä¾èµ–ã€ç¼–译功能开关åŠccacheæ–¹é¢æžè‡´æå‡ç¼–译性能。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I5IZC2 ã€ç¼–译构建å系统】支æŒç³»ç»Ÿç»„件与芯片组件独立构建<br/>I5IZD9 ã€é›†æˆä¼˜åŒ–】模å—ä¾èµ–优化<br/>I5IZI0 ã€é›†æˆä¼˜åŒ–】æ供编译功能选项开关<br/>I5IZH2 ã€é›†æˆä¼˜åŒ–】ccache优化 | NA | +| 多模输入å系统 | - æ供通过JS API访问输入设备信æ¯ã€‚<br/>- 新增支æŒæ‰‹å†™ç¬”作为输入设备。<br/>- 新增支æŒæŒ‰é”®è‡ªåŠ¨é‡å¤çš„事件上报。<br/>- 新增支æŒSELinux。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I530UN ã€æ–°å¢žç‰¹æ€§ã€‘窗å£å¤šçƒåŒºåˆ†å‘机制<br/>I530UT ã€æ–°å¢žç‰¹æ€§ã€‘JS API Mock<br/>I530VY ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡JS API查看手写笔输入设备基础信æ¯<br/>I530W0 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡JS API æŸ¥çœ‹é¼ æ ‡è¾“å…¥è®¾å¤‡æ‰©å±•ä¿¡æ¯<br/>I530WA ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡JS API查看触摸æ¿è¾“入设备扩展信æ¯<br/>I530WD ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡JS API查看触摸å±è¾“入设备扩展信æ¯<br/>I530WH ã€æ–°å¢žç‰¹æ€§ã€‘支æŒLinux Input手写笔功能按键输入事件接收并分å‘<br/>I530WI ã€æ–°å¢žç‰¹æ€§ã€‘支æŒLinux Input手写笔压感åˆæˆ<br/>I530WJ ã€æ–°å¢žç‰¹æ€§ã€‘支æŒLinux Input手写笔倾角<br/>I530WK ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹åŽ‹åŠ›å±žæ€§<br/>I530WM ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹è§¦æ‘¸åŒºåŸŸå±žæ€§<br/>I530WO ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹å·¥å…·åŒºåŸŸå±žæ€§<br/>I530WP ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹å·¥å…·ç±»åž‹å±žæ€§<br/>I530X8 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡é…置文件é…ç½®æŒ‰é”®æ˜ å°„è§„åˆ™<br/>I530XH ã€æ–°å¢žç‰¹æ€§ã€‘支æŒç³»ç»ŸæŒ‰é”®é€šè¿‡é…置文件é…ç½®æŒ‰é”®æ˜ å°„è§„åˆ™<br/>I530XJ ã€æ–°å¢žç‰¹æ€§ã€‘支æŒç³»ç»ŸæŒ‰é”®è‡ªåŠ¨é‡å¤<br/>I530XK ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé”®ç›˜ç±»åž‹è¯†åˆ«<br/>I530XL ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæŒ‰é”®èƒ½åŠ›è¯†åˆ«<br/>I530XM ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé”®ç›˜é€šè¿‡é…置文件é…ç½®æŒ‰é”®æ˜ å°„è§„åˆ™<br/>I530XN ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé”®ç›˜æŒ‰é”®è‡ªåŠ¨é‡å¤<br/>I530XT ã€æ–°å¢žç‰¹æ€§ã€‘支æŒé€šè¿‡C++ API按照相对åæ ‡è°ƒæ•´é¼ æ ‡ä½ç½®<br/>I530XX ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹åŽ‹åŠ›å±žæ€§<br/>I530XZ ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹è§¦æ‘¸åŒºåŸŸå±žæ€§<br/>I530Y1 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹å·¥å…·åŒºåŸŸå±žæ€§<br/>I530Y2 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒè§¦æ‘¸ç‚¹å·¥å…·ç±»åž‹å±žæ€§<br/>I530Y7 ã€æ–°å¢žè§„æ ¼ã€‘å¤šæ¨¡è¾“å…¥å系统支æŒ64ä½<br/>I530YB ã€DFX打点】ã€å¤šæ¨¡è¾“å…¥å系统】æ供系统事件ã€SA dumpã€trace打点<br/>I530YF ã€æ–°å¢žè§„æ ¼ã€‘ã€å¤šæ¨¡è¾“入】ã€input】SELinuxç–ç•¥é…ç½®<br/>I5HMBS ã€inputéƒ¨ä»¶ã€‘é”®é¼ è‡ªé€‚åº”å¸ƒå±€é€‚é… | NA | +| æ³›SensoræœåŠ¡å系统 | - 支æŒæ›´å¤šç±»åž‹çš„ä¼ æ„Ÿå™¨ä¸ŠæŠ¥ã€‚<br/>- 支æŒSELinux。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I53SFI ã€DFX打点】ã€æ³›SensoræœåŠ¡å系统】æ供系统事件ã€SA dumpã€trace打点<br/>I537CB ã€æ–°å¢žè§„æ ¼ã€‘æ³›Sensor能力æŒç»é›†æˆ-旋转矢é‡ä¼ 感器<br/>I537AN ã€æ–°å¢žè§„æ ¼ã€‘æ³›Sensor能力æŒç»é›†æˆ-é‡åŠ›ä¼ 感器<br/>I5379T ã€æ–°å¢žè§„æ ¼ã€‘æ³›Sensor能力æŒç»é›†æˆ-地ç£ä¼ 感器<br/>I5379C ã€æ–°å¢žè§„æ ¼ã€‘æ³›Sensor能力æŒç»é›†æˆ-æ–¹å‘ä¼ æ„Ÿå™¨<br/>I53784 ã€æ–°å¢žè§„æ ¼ã€‘æ³›Sensor能力æŒç»é›†æˆ-çŽ¯å¢ƒå…‰ä¼ æ„Ÿå™¨<br/>I53SFS ã€æ–°å¢žè§„æ ¼ã€‘ã€æ³›SensoræœåŠ¡ã€‘SELinuxç–ç•¥é…ç½® | NA | +| 分布å¼æ•°æ®ç®¡ç†å系统 | data_share支æŒå¤šç§æ•°æ®ç±»åž‹ã€‚<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I5EHGF ã€DataShare】DataShare支æŒå¤šç§æ•°æ®å‚¨å˜ç±»åž‹ | NA | +| webå系统 | - 新增支æŒJS相关交互能力。<br/>- 新增支æŒç½‘络ã€é”®é¼ ã€webstorageã€SELinuxç–ç•¥ç‰èƒ½åŠ›ã€‚<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I5DM1E ã€æ–°å¢žè§„æ ¼ã€‘web组件的JS窗å£ç®¡ç†<br/>I5DNG2 ã€æ–°å¢žè§„æ ¼ã€‘JS侧æ供全é‡hittest接å£ä»¥åŠDefaultUserAgent获å–<br/>I5EK53 ã€æ–°å¢žè§„æ ¼ã€‘ã€webå系统】web组件http验è¯ç®¡ç†<br/>I5EGBB ã€æ–°å¢žè§„æ ¼ã€‘ã€webå系统】ã€web部件】webå系统的SELinuxç–ç•¥é…ç½®<br/>I5EBG1 ã€æ–°å¢žè§„æ ¼ã€‘ã€webå系统】webå系统适é…w3c network information api<br/>I5EVEC ã€æ–°å¢žè§„æ ¼ã€‘ã€webå系统】webå†…æ ¸å¯¹æŽ¥é¼ æ ‡ã€é”®ç›˜ç‰å¤–设能力<br/>I5FF2L ã€æ–°å¢žè§„æ ¼ã€‘ã€webå系统】web组件支æŒwebstorage | NA | +| 驱动å系统 | - 支æŒå†…æ ¸æ€é©±åŠ¨åŠ¨æ€åŠ è½½åŠDFX能力。<br/>- æä¾›Codec2.0接å£åŠcodec驱动模型。<br/>- Cameraã€Displayã€Audioã€Sensorã€WLANç‰æ¨¡å—驱动能力增强。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I536FN ã€æ–°å¢žç‰¹æ€§ã€‘ã€é©±åŠ¨å系统】支æŒHDI passthrougt模å¼<br/>I5DJE5 ã€å¢žå¼ºç‰¹æ€§ã€‘兼容Linux uevent事件上报机制,增强设备å³æ’å³ç”¨åŠŸèƒ½<br/>I550OL ã€æ–°å¢žç‰¹æ€§ã€‘æä¾›DFX跟踪定ä½ï¼ŒèŽ·å–ä¿¡æ¯èƒ½åŠ›<br/>I544XP ã€æ–°å¢žç‰¹æ€§ã€‘支æŒHDFæœåŠ¡SELinuxæƒé™æ£€æŸ¥ æ ‡å‡†ç³»ç»Ÿ<br/>I528DG ã€æ–°å¢žç‰¹æ€§ã€‘支æŒCodec 2.0å‚考实现,简化适é…难度<br/>I50I6S ã€æ–°å¢žç‰¹æ€§ã€‘Audio新增IPC模å¼ä¸Žç›´è°ƒæ¨¡å¼æŽ¥å£è°ƒç”¨ç»Ÿä¸€<br/>I5A6H6 ã€å¢žå¼ºç‰¹æ€§ã€‘增强显示设备管ç†,支æŒå¤šå±æ˜¾ç¤ºèƒ½åŠ›<br/>I5B0C5 ã€æ–°å¢žç‰¹æ€§ã€‘Camera支æŒå®žçŽ°Mate类型的æµ<br/>I5B0BR ã€æ–°å¢žç‰¹æ€§ã€‘录åƒæ¨¡å¼è‡ªæ‹é•œåƒåŠŸèƒ½<br/>I5AJW1 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒLinux libALSA音频接å£å…¼å®¹<br/>I56V2N ã€æ–°å¢žç‰¹æ€§ã€‘HDF WLAN DAL HDI功率模å¼ç›¸å…³æŽ¥å£çš„定义与开å‘<br/>I5F411 ã€å¢žå¼ºç‰¹æ€§ã€‘马达效果能力增强 | NA | +| USBæœåŠ¡å系统 | - 支æŒUSBæœåŠ¡å¹¿æ’消æ¯ã€‚<br/>- å¢žåŠ SELinux安全ç–略。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I59MYK ã€æ–°å¢žç‰¹æ€§ã€‘USBæœåŠ¡å¹¿æ’消æ¯<br/>I5AR8N ã€æ–°å¢žè§„æ ¼ã€‘ã€USBæœåŠ¡å系统】USBæœåŠ¡å系统的SELinuxç–ç•¥é…ç½® | NA | +| å†…æ ¸å系统 | - 新增支æŒå†…å˜ç²¾ç»†åŒ–管控特性。<br/>- 新增支æŒå…³è”æœåŠ¡adj调整机制。<br/>主è¦æ¶‰åŠå¦‚下需求:<br/>I58LOD ã€æ–°å¢žç‰¹æ€§ã€‘支æŒå…³è”æœåŠ¡adj调整机制<br/>I54Y5J ã€æ–°å¢žç‰¹æ€§ã€‘支æŒmemtrack内å˜å 用和进程维度adj查询接å£ç‰¹æ€§<br/>I56B3Q ã€æ–°å¢žç‰¹æ€§ã€‘支æŒOnMemoryLevel特性<br/>I5B694 ã€æ–°å¢žç‰¹æ€§ã€‘支æŒæ–°åž‹å†…å˜ç²¾ç»†åŒ–管控特性<br/>I59O8H ã€æ–°å¢žç‰¹æ€§ã€‘支æŒpurgable memory特性<br/>I5CXOK ã€æ–°å¢žç‰¹æ€§ã€‘支æŒhyperholdå¯é 性æå‡ç‰¹æ€§ | NA | + + +### + + +### 芯片åŠå¼€å‘æ¿é€‚é… + +芯片åŠå¼€å‘æ¿é€‚é…状æ€è¯·å‚考[SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard_cn.md)ä¿¡æ¯ã€‚ + + +### Samples + + **表4** 新增Samples + +| å系统 | å称 | 简介 | å¼€å‘è¯è¨€ | +| -------- | -------- | -------- | -------- | +| 元能力 | MissionManager | 本示例通过调用系统任务管ç†çš„能力,对系统任务执行é”定ã€è§£é”ã€æ¸…ç†ã€åˆ‡æ¢åˆ°å‰å°ç‰æ“作。 | eTS | +| ç½‘ç»œç®¡ç† | AirQuality | 空气质é‡ï¼ˆAir quality)的好ååæ˜ äº†ç©ºæ°”æ±¡æŸ“ç¨‹åº¦ï¼Œå®ƒæ˜¯ä¾æ®ç©ºæ°”ä¸æ±¡æŸ“物浓度的高低æ¥åˆ¤æ–的。空气污染是一个å¤æ‚的现象,在特定时间和地点空气污染物浓度å—åˆ°è®¸å¤šå› ç´ å½±å“。æ¥è‡ªå›ºå®šå’ŒæµåŠ¨æ±¡æŸ“æºçš„人为污染物排放大å°æ˜¯å½±å“空气质é‡çš„最主è¦å› ç´ ä¹‹ä¸€ï¼Œæœ¬ç¤ºä¾‹å®žçŽ°äº†ä¸€ä¸ªç®€å•ç©ºæ°”è´¨é‡åº”用,使用折行显示能力显示空气质é‡ä¿¡æ¯ï¼Œä½¿ç”¨æŸ±å½¢å›¾å±•ç¤ºåŽ†å²è®°å½•ã€‚ | eTS | +| ArkUI | TransitionAnimation | 本示例展示了转场动画的使用,包括页é¢é—´è½¬åœºã€ç»„ä»¶å†…è½¬åœºå’Œå…±äº«å…ƒç´ è½¬åœºã€‚ | eTS | +| 应用程åºåŒ…ç®¡ç† | ZipLib | 本示例通过构建解压,压缩文件场景,å‘用户展示\@ohos.zlib接å£ã€‚ | eTS | +| 工程能力 | Npm | 本示例展示了npm引用第三方js类库和本地库,主è¦å±•ç¤ºäº†mathjsã€dayjs和本地库应用。 | eTS | +| æ•°æ®ç®¡ç† | DistributedMusicPlayer | 本示例使用fileIo获å–指定音频文件,并通过AudioPlayer完æˆäº†éŸ³ä¹çš„æ’放完æˆäº†åŸºæœ¬çš„音ä¹æ’放ã€æš‚åœã€ä¸Šä¸€æ›²ã€ä¸‹ä¸€æ›²åŠŸèƒ½ï¼›å¹¶ä½¿ç”¨DeviceManager完æˆäº†åˆ†å¸ƒå¼è®¾å¤‡åˆ—表的显示和分布å¼èƒ½åŠ›å®Œæˆäº†éŸ³ä¹æ’放状æ€çš„跨设备è¿ç§»ã€‚ | eTS | +| ArkUI | PatternLock | 本示例展示了图案密ç é”组件的使用,实现了密ç 设置ã€éªŒè¯å’Œé‡ç½®åŠŸèƒ½ã€‚ | eTS | +| 安全 | UserAuth | 本示例展示了用户认è¯ä¸äººè„¸è¯†åˆ«åŠŸèƒ½ã€‚ | eTS | +| 安全 | Cipher | æœ¬ç¤ºä¾‹å±•ç¤ºäº†åŠ è§£å¯†ç®—æ³•ï¼ŒåŒ…æ‹¬RSAåŠ å¯†ç®—æ³•ä¸ŽAESåŠ å¯†ç®—æ³•ã€‚ | eTS | +| å›¾å½¢å›¾åƒ | Screen | 本示例监å¬å±å¹•æ•°é‡å˜åŒ–,创建ã€é”€æ¯è™šæ‹Ÿå±å¹•æ¨¡æ‹Ÿå±å¹•å¢žå‡ï¼Œè¯»å–å±å¹•å±žæ€§å¹¶æ˜¾ç¤ºã€‚ | eTS | +| ArkUI | Search | 本示例展示了Search组件的使用,使用Search组件实现一个æœç´¢ç•Œé¢ã€‚ | eTS | +| è®¾å¤‡ç®¡ç† | USBManager | 本示例展示了USB设备管ç†çš„使用,包括USB设备æ’拔状æ€ç›‘å¬å’ŒUSB设备信æ¯æ˜¾ç¤ºã€‚ | eTS | +| æ•°æ®ç®¡ç† | DistributedDataGobang | 五å棋是一款比较æµè¡Œçš„棋类游æˆï¼Œæ¤æ¸¸æˆä½¿ç”¨åˆ†å¸ƒå¼æ•°æ®ç®¡ç†åŠŸèƒ½è¿›è¡Œå¼€å‘完æˆçš„。 | eTS | +| 媒体 | Image | 本示例仿照相册应用,读å–本地设备ä¸å›¾ç‰‡ï¼ŒèŽ·å–图片信æ¯ï¼Œå¯å¯¹å›¾ç‰‡è¿›è¡Œæ—‹è½¬æ“作。 | eTS | +| 安全 | AbilityAccessCtrl | 本示例通过模拟应用申请æƒé™åœºæ™¯ï¼Œå‘用户展示@ohos.abilityAccessCtrl接å£ã€‚ | eTS | +| ç½‘ç»œç®¡ç† | WebSocket | 本示例展示了WebSocket的使用,包括客户端与æœåŠ¡ç«¯çš„连接和æ–开以åŠå®¢æˆ·ç«¯æ•°æ®çš„接收和å‘é€ã€‚ | eTS | +| 通信与连接 | Bluetooth | è“牙技术是一ç§æ— 线数æ®å’Œè¯éŸ³é€šä¿¡å¼€æ”¾çš„å…¨çƒè§„范,它是基于低æˆæœ¬çš„è¿‘è·ç¦»æ— 线连接,为固定和移动设备建立通信环境的一ç§ç‰¹æ®Šçš„è¿‘è·ç¦»æ— 线技术连接。本示例实现è“牙设备å‘现,é…对,å–消é…对功能。 | eTS | +| 媒体 | GamePuzzle | 拼图Demo是基于Grid组件进行开å‘,通过image (图片处ç†)å’Œmedialibrary (媒体库管ç†)接å£å®žçŽ°èŽ·å–图片,以åŠå›¾ç‰‡è£å‰ªåˆ†å‰²ã€‚ | eTS | +| ç½‘ç»œç®¡ç† | UploadDownload | ä¸Šä¼ å°±æ˜¯å°†æ–‡ä»¶ä»Žä¸ªäººç»ˆç«¯è®¾å¤‡ä¼ é€è‡³è¿œç¨‹æœåŠ¡å™¨ï¼Œä¸‹è½½æ˜¯å°†æ–‡ä»¶ä»Žè¿œç¨‹æœåŠ¡å™¨ä¼ é€è‡³ä¸ªäººç»ˆç«¯è®¾å¤‡ï¼Œè¿›è€Œå®žçŽ°æ–‡ä»¶çš„å˜å‚¨ï¼Œè¯¥ç¤ºä¾‹ä½¿ç”¨ä¸Šä¼ 下载的接å£å®žçŽ°æ–‡ä»¶çš„ä¸Šä¼ ä¸‹è½½ã€‚ | eTS | +| è®¾å¤‡ç®¡ç† | Location | 本示例使用方å‘ä¼ æ„Ÿå™¨åŠGPS,实现获å–当å‰ä½ç½®ä¿¡æ¯ã€‚ | eTS | +| 电è¯æœåŠ¡ | Observer | 本示例通过observer接å£è®¢é˜…网络状æ€ã€ä¿¡å·çŠ¶æ€ã€é€šè¯çŠ¶æ€ã€èœ‚çªæ•°æ®ã€sim状æ€ç‰äº‹ä»¶ï¼Œå¹¶èŽ·å–状æ€å˜åŒ–返回的结果。 | eTS | +| ArkUI | AdaptiveCapabilities | æ¤Demo展示在eTSä¸çš„多设备自适应能力,包括资æºé™å®šè¯ã€åŽŸå布局和å“应å¼å¸ƒå±€ã€‚ | eTS | +| ArkUI | JsAdaptiveCapabilities | æ¤Demo展示在JSä¸çš„多设备自适应能力,包括资æºé™å®šè¯ã€åŽŸå布局和å“应å¼å¸ƒå±€ã€‚ | JS | + +请访问[Samples](https://gitee.com/openharmony/app_samples)仓了解更多信æ¯ã€‚ + + +## ä¿®å¤ç¼ºé™·åˆ—表 + + **表5** ä¿®å¤ç¼ºé™·ISSUE列表 + +| ISSUEå• | 问题æè¿° | +| -------- | -------- | +| [I4Z3G9](https://e.gitee.com/open_harmony/issues/list?issue=I4Z3G9) | ã€RK3568】打开沉浸å¼ä¸»çª—å£å’Œåœ¨ä¸»çª—å£ä¸Šæ‰“开辅助窗å£å‡ºçŽ°é—ªå± | +| [I59M4Q](https://gitee.com/openharmony/developtools_hdc/issues/I59M4Q?from=project-issue) | API9 hdc_std连接设备低概率æ–è¿ž | +| [I54D32](https://gitee.com/openharmony/multimedia_camera_standard/issues/I54D32) | ã€RK3568】ã€å¿…现】相机连ç»å¤šæ¬¡å½•åƒå‡ºçŽ°é»‘å± | + + +## é—留缺陷列表 + + **表6** é—留缺陷列表 + +| ISSUE | 问题æè¿° | å½±å“ | 计划解决日期 | +| -------- | -------- | -------- | -------- | +| I5I4GJ | 通过IDE连接rk3568设备概率æ–è¿ž | DevEco Studio进行应用的è¿è¡Œå’Œè°ƒè¯•ï¼Œé€šè¿‡hdc连接设备概率æ–连,æ–连概率1/25,æ–è¿žåŽå¯ä»¥é‡è¿žä¸Šï¼Œå½±å“å¯æŽ§ | 2022å¹´8月15å· | +| I5HTGF | 相机æ‹å‡ºæ¥ç…§ç‰‡è·Ÿé¢„览相比顺时针旋转90度 | å½±å“æ‹ç…§åŽçš„图片的体验效果 | 2022å¹´8月15å· | +| I5FUNB | linuxå†…æ ¸æ¼æ´žåŒæ¥<br/>CVE-2022-1462 | å†…æ ¸CVEæ¼æ´žå½“å‰ç¤¾åŒºæ— è¡¥ä¸ï¼Œå¾…å†…æ ¸ç¤¾åŒºè¡¥ä¸å‘布åŽåŒæ¥åˆ°Beta2分支 | è·Ÿéšå†…æ ¸ç¤¾åŒºè¡¥ä¸å‘布时间 | +| I5FUO1 | linuxå†…æ ¸æ¼æ´žåŒæ¥<br/>CVE-2022-21127 | å†…æ ¸CVEæ¼æ´žå½“å‰ç¤¾åŒºæ— è¡¥ä¸ï¼Œå¾…å†…æ ¸ç¤¾åŒºè¡¥ä¸å‘布åŽåŒæ¥åˆ°Beta2分支 | è·Ÿéšå†…æ ¸ç¤¾åŒºè¡¥ä¸å‘布时间 | diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index 039f8b8a71379a2d4da00a665f71cc8da7e093fc..7137141a9f54b6d62b3f9ae3afeadf75ad607e10 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -1,5 +1,6 @@ # OpenHarmony Release Notes ## OpenHarmony 3.x Releases +- [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md) - [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) diff --git a/zh-cn/release-notes/api-change/template/changelog-x-x.md b/zh-cn/release-notes/api-change/template/changelog-x-x.md index abf59c77cba59f171efbb6121e24f238516ad50e..b20dbfc1fc13ba0dc94a8044119ac0ae2473cfb7 100644 --- a/zh-cn/release-notes/api-change/template/changelog-x-x.md +++ b/zh-cn/release-notes/api-change/template/changelog-x-x.md @@ -1,14 +1,17 @@ -# ChangeLog -## xxxå系统(该段è½ä¸ºç¤ºä¾‹ï¼Œè¯·ä¸è¦ä¿®æ”¹æˆ–åˆ é™¤ï¼‰ -å·²ç»release的版本å‘生了影å“契约兼容性(契约兼容:也称è¯ä¹‰å…¼å®¹ï¼ŒæŒ‡ç‰ˆæœ¬æ¼”è¿›åŽï¼Œå¼€å‘者原有程åºè¡Œä¸ºä¸å‘生å˜åŒ–)的å˜æ›´ï¼ˆåŒ…括ä¸é™äºŽæŽ¥å£åã€å‚æ•°ã€è¿”回值ã€æ‰€éœ€è¦çš„æƒé™ã€è°ƒç”¨é¡ºåºã€æžšä¸¾å€¼ã€é…ç½®å‚æ•°ã€è·¯å¾„ç‰ï¼‰ï¼Œåˆ™éœ€è¦åœ¨ChangeLogä¸å¯¹å˜æ›´è¿›è¡Œé˜è¿°ã€‚ -### cl.subsystemname.x xxx功能å˜æ›´ï¼Œ 例:DeviceType属性å˜æ›´ã€ç›¸æœºæƒé™å˜æ›´ï¼ˆå°½é‡æ¦‚括,ä¸è¦è¶…过15个å—) -æ¯ä¸ªå˜æ›´æ ‡é¢˜å‰éœ€è¦é™„åŠ ç¼–å·ï¼šcl.subsystemname.x。cl为ChangeLog首å—æ¯ç¼©å†™ï¼Œsubsystemname请填写åç³»ç»Ÿè‹±æ–‡æ ‡å‡†å称,x表示å˜æ›´åºå·ï¼ˆä»Žä½Žåˆ°é«˜é€ä½å¢žåŠ )。 +# xxxå系统ChangeLog + +相比最近一个å‘布版本(包括ä¸é™äºŽLTSã€Releaseã€Betaã€monthly版本)å‘生了影å“契约兼容性(契约兼容:也称è¯ä¹‰å…¼å®¹ï¼ŒæŒ‡ç‰ˆæœ¬æ¼”è¿›åŽï¼Œå¼€å‘者原有程åºè¡Œä¸ºä¸å‘生å˜åŒ–)的å˜æ›´ï¼ˆåŒ…括ä¸é™äºŽæŽ¥å£åã€å‚æ•°ã€è¿”回值ã€æ‰€éœ€è¦çš„æƒé™ã€è°ƒç”¨é¡ºåºã€æžšä¸¾å€¼ã€é…ç½®å‚æ•°ã€è·¯å¾„ç‰ï¼‰ï¼Œåˆ™éœ€è¦åœ¨ChangeLogä¸å¯¹å˜æ›´è¿›è¡Œé˜è¿°ã€‚ + +## cl.subsystemname.x xxx功能å˜æ›´ï¼Œ 例:DeviceType属性å˜æ›´ã€ç›¸æœºæƒé™å˜æ›´ï¼ˆå°½é‡æ¦‚括,ä¸è¦è¶…过15个å—) + +æ¯ä¸ªå˜æ›´æ ‡é¢˜å‰éœ€è¦é™„åŠ ç¼–å·ï¼šcl.subsystemname.x。cl为ChangeLog首å—æ¯ç¼©å†™ï¼Œsubsystemname请填写åç³»ç»Ÿè‹±æ–‡æ ‡å‡†å称,x表示å˜æ›´åºå·ï¼ˆä»Žä½Žåˆ°é«˜é€ä½å¢žåŠ ,起始为1)。 以功能维度对å˜æ›´ç‚¹è¿›è¡Œæ¦‚括æ述。例如:xxx功能的xxxã€xxxç‰å‘生了xxxå˜åŒ–,开å‘者需è¦æ ¹æ®ä»¥ä¸‹è¯´æ˜Žå¯¹åº”用进行适é…。 如果有æ¤å˜æ›´æœ‰å¯¹åº”的需求或设计文档,å¯ä»¥åœ¨æè¿°ä¸é™„上对应的设计文档编å·ã€‚ **å˜æ›´å½±å“** -是å¦å½±å“å·²release的接å£æˆ–者接å£è¡Œä¸ºå‘生å˜æ›´ç‰ï¼›å½±å“的是JS接å£ã€Java接å£è¿˜æ˜¯Native接å£ã€‚ +是å¦å½±å“å·²å‘布的接å£æˆ–者接å£è¡Œä¸ºå‘生å˜æ›´ï¼Œå½±å“的是JS接å£è¿˜æ˜¯Native接å£ã€‚ +是å¦å½±å“在æ¤å‰ç‰ˆæœ¬å·²å¼€å‘的应用,å³åº”用是å¦éœ€è¦è¿›è¡Œé€‚é…动æ‰å¯ä»¥åœ¨æ–°ç‰ˆæœ¬SDK环境æ£å¸¸ç¼–译通过。 **关键的接å£/组件å˜æ›´** @@ -16,15 +19,13 @@ **适é…指导(å¯é€‰ï¼Œä¸æ¶‰åŠåˆ™å¯ä»¥åˆ 除)** -(å‰é¢ç©ºä¸€è¡Œï¼‰æ供指导,帮助开å‘者针对相关å˜æ›´è¿›è¡Œé€‚é…,使应用å¯ä»¥ä¸Žæ–°ç‰ˆæœ¬å…¼å®¹ã€‚例: +æ供指导,帮助开å‘者针对相关å˜æ›´è¿›è¡Œé€‚é…,使应用å¯ä»¥ä¸Žæ–°ç‰ˆæœ¬å…¼å®¹ã€‚ +例: 在xxx文件ä¸å°†xxxå‚数修改为xxx。 + ``` sample code ``` -### cl.subsystemname.x xxx功能å˜æ›´ -æ¯ä¸ªåŠŸèƒ½å˜æ›´ç‚¹åœ¨è‡ªå·±çš„åç³»ç»Ÿç« èŠ‚å†…æ–°å¢žä¸€ä¸ªåŠŸèƒ½å˜æ›´ç« 节。 -## xxxå系统 -æ¯ä¸ªå系统有且åªèƒ½æœ‰ä¸€ä¸ªåç³»ç»Ÿç« èŠ‚ã€‚ diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-ability.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-ability.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-ability.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-ability.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-arkui.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-arkui.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-arkui.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-arkui.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-battery.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-battery.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-battery.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-battery.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-bundle.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-bundle.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-bundle.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-bundle.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-communicate.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-communicate.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-communicate.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-communicate.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-dfx.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-dfx.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-dfx.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-dfx.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-distributed-data.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-distributed-data.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-distributed-data.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-distributed-data.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-distributedschedule.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-distributedschedule.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-distributedschedule.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-distributedschedule.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-event-and-notification.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-event-and-notification.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-event-and-notification.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-event-and-notification.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-file-management.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-file-management.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-file-management.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-file-management.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-global.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-global.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-global.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-global.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-init.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-init.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-init.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-init.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-misc.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-misc.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-misc.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-misc.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-multi-modal-input.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-multi-modal-input.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-multi-modal-input.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-multi-modal-input.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-multimedia.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-multimedia.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-multimedia.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-multimedia.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-resource-scheduler.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-resource-scheduler.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-resource-scheduler.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-resource-scheduler.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-soft-bus.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-soft-bus.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-soft-bus.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-soft-bus.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-unitest.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-unitest.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-unitest.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-unitest.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-web.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-web.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-web.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-web.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-window.md b/zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-window.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/js-apidiff-window.md rename to zh-cn/release-notes/api-change/v3.2-beta1/js-apidiff-window.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/native-apidiff-v3.2-beta.md b/zh-cn/release-notes/api-change/v3.2-beta1/native-apidiff-v3.2-beta.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/native-apidiff-v3.2-beta.md rename to zh-cn/release-notes/api-change/v3.2-beta1/native-apidiff-v3.2-beta.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta/readme.md b/zh-cn/release-notes/api-change/v3.2-beta1/readme.md similarity index 100% rename from zh-cn/release-notes/api-change/v3.2-beta/readme.md rename to zh-cn/release-notes/api-change/v3.2-beta1/readme.md diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-ability.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..39d9581639436f9046aebf5bd18c55cf0d5f3515 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-ability.md @@ -0,0 +1,77 @@ +# 元能力å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,元能力å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| AbilityContext | AbilityContext | isTerminating(): boolean; | 新增 | +| AbilityContext | AbilityContext | stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; | 新增 | +| AbilityContext | AbilityContext | stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;<br>stopServiceExtensionAbility(want: Want): Promise\<void>; | 新增 | +| AbilityContext | AbilityContext | startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; | 新增 | +| AbilityContext | AbilityContext | startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startServiceExtensionAbility(want: Want): Promise\<void>; | 新增 | +| abilityDelegator | AbilityDelegator | printSync(msg: string): void; | 新增 | +| ApplicationContext | ApplicationContext | unregisterEnvironmentCallback(callbackId: number, callback: AsyncCallback\<void>): void;<br>unregisterEnvironmentCallback(callbackId: number): Promise\<void>; | 新增 | +| ApplicationContext | ApplicationContext | registerEnvironmentCallback(callback: EnvironmentCallback): number; | 新增 | +| applicationInfo | ApplicationInfo | readonly appProvisionType: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly appDistributionType: string; | 新增 | +| applicationInfo | ApplicationInfo | readonly descriptionResource: Resource; | 新增 | +| applicationInfo | ApplicationInfo | readonly labelResource: Resource; | 新增 | +| applicationInfo | ApplicationInfo | readonly iconResource: Resource; | 新增 | +| applicationInfo | ApplicationInfo | readonly fingerprint: string; | 新增 | +| context | Context | createModuleContext(moduleName: string): Context;<br>createModuleContext(bundleName: string, moduleName: string): Context; | 新增 | +| ErrorObserver | ErrorObserver | onUnhandledException(errMsg: string): void; | 新增 | +| ExtensionContext | ExtensionContext | extensionAbilityInfo: ExtensionAbilityInfo; | 新增 | +| FormExtensionContext | FormExtensionContext | startAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want): Promise\<void>; | 新增 | +| MissionCallbacks | MissionCallback | notifyNetDisconnect(deviceId: string, state: number): void; | 新增 | +| MissionCallbacks | MissionCallback | notifySnapshot(deviceId: string, mission: number): void; | 新增 | +| MissionCallbacks | MissionCallback | notifyMissionsChanged(deviceId: string): void; | 新增 | +| MissionDeviceInfo | MissionDeviceInfo | deviceId: string; | 新增 | +| MissionParameter | MissionParameter | tag: number; | 新增 | +| MissionParameter | MissionParameter | fixConflict: boolean; | 新增 | +| MissionParameter | MissionParameter | deviceId: string; | 新增 | +| ohos.ability.wantConstant | Action | ACTION_MARKER_DOWNLOAD = "ohos.want.action.marketDownload" | 新增 | +| ohos.abilityAccessCtrl | AtManager | verifyAccessTokenSync(tokenID: number, permissionName: string): GrantStatus; | 新增 | +| ohos.application.Ability | CalleeCallBack | (indata: rpc.MessageParcel): rpc.Sequenceable; | 新增 | +| ohos.application.appManager | appManager | getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;<br>getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInformation>>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | denormalizeUri?(uri: string, callback: AsyncCallback\<string>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | normalizeUri?(uri: string, callback: AsyncCallback\<string>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | batchInsert?(uri: string, valueBuckets: Array\<ValuesBucket>, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | getType?(uri: string, callback: AsyncCallback\<string>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | "query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array\<string>, callback: AsyncCallback\<Object>): void;" | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | "update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueBucket: ValuesBucket, callback: AsyncCallback\<number>): void;" | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | openFile?(uri: string, mode: string, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback\<Array\<string>>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | onCreate?(want: Want, callback: AsyncCallback\<void>): void; | 新增 | +| ohos.application.DataShareExtensionAbility | DataShareExtensionAbility | context?: ExtensionContext; | 新增 | +| ohos.application.EnvironmentCallback | EnvironmentCallback | onConfigurationUpdated(config: Configuration): void; | 新增 | +| ohos.application.errorManager | errorManager | unregisterErrorObserver(observerId: number, callback: AsyncCallback\<void>): void;<br>unregisterErrorObserver(observerId: number): Promise\<void>; | 新增 | +| ohos.application.errorManager | errorManager | registerErrorObserver(observer: ErrorObserver): number; | 新增 | +| ohos.application.formInfo | FormInfoFilter | moduleName?: string; | 新增 | +| ohos.application.formProvider | formProvider | isRequestPublishFormSupported(callback: AsyncCallback\<boolean>): void;<br>isRequestPublishFormSupported(): Promise\<boolean>; | 新增 | +| ohos.application.formProvider | formProvider | requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void;<br>requestPublishForm(want: Want, callback: AsyncCallback\<string>): void;<br>requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise\<string>; | 新增 | +| ohos.application.formProvider | formProvider | getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback\<Array\<formInfo.FormInfo>>): void;<br>getFormsInfo(callback: AsyncCallback\<Array\<formInfo.FormInfo>>): void;<br>getFormsInfo(filter?: formInfo.FormInfoFilter): Promise\<Array\<formInfo.FormInfo>>; | 新增 | +| ohos.application.missionManager | missionManager | getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void;<br>getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>; | 新增 | +| ohos.application.Want | Want | moduleName?: string; | 新增 | +| ohos.distributedMissionManager | distributedMissionManager | unRegisterMissionListener(parameter: MissionDeviceInfo, callback:AsyncCallback\<void>): void;<br>unRegisterMissionListener(parameter: MissionDeviceInfo): Promise\<void>; | 新增 | +| ohos.distributedMissionManager | distributedMissionManager | registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback\<void>): void;<br>registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise\<void>; | 新增 | +| ohos.distributedMissionManager | distributedMissionManager | stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback\<void>): void;<br>stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise\<void>; | 新增 | +| ohos.distributedMissionManager | distributedMissionManager | startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback\<void>): void;<br>startSyncRemoteMissions(parameter: MissionParameter): Promise\<void>; | 新增 | +| ProcessRunningInformation | ProcessRunningInformation | bundleNames: Array\<string>; | 新增 | +| ProcessRunningInformation | ProcessRunningInformation | processName: string; | 新增 | +| ProcessRunningInformation | ProcessRunningInformation | uid: number; | 新增 | +| ProcessRunningInformation | ProcessRunningInformation | pid: number; | 新增 | +| ServiceExtensionContext | ServiceExtensionContext | stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; | 新增 | +| ServiceExtensionContext | ServiceExtensionContext | stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;<br>stopServiceExtensionAbility(want: Want): Promise\<void>; | 新增 | +| ServiceExtensionContext | ServiceExtensionContext | startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; | 新增 | +| ServiceExtensionContext | ServiceExtensionContext | startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startServiceExtensionAbility(want: Want): Promise\<void>; | 新增 | +| ohos.application.Ability | CaleeCallBack | (indata: rpc.MessageParcel): rpc.Sequenceable; | åˆ é™¤ | +| ohos.application.uriPermissionManager | uriPermissionManager | verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback\<number>): void;<br>verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise\<number>; | åˆ é™¤ | +| FormExtensionContext | FormExtensionContext | updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void;<br>updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>; | åˆ é™¤ | +| ServiceExtensionContext | ServiceExtensionContext | extensionAbilityInfo: ExtensionAbilityInfo; | åˆ é™¤ | +| ohos.application.appManager | appManager | getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;<br>getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void; | 废弃 | +| ohos.application.Ability | Ability | old : onNewWant(want: Want): void;<br>new : onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; | å˜æ›´ | +| ohos.application.Ability | Callee | old : on(method: string, callback: CaleeCallBack): void;<br>new : on(method: string, callback: CalleeCallBack): void; | å˜æ›´ | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md new file mode 100644 index 0000000000000000000000000000000000000000..cbe82cc82a409a0d0f5bb5015bd3a169c1b9eeb7 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md @@ -0,0 +1,36 @@ +# æ— éšœç¢å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1ç‰ˆæœ¬ï¼Œæ— éšœç¢å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| AccessibilityExtensionContext | Rect | height: number; | 新增 | +| AccessibilityExtensionContext | Rect | width: number; | 新增 | +| AccessibilityExtensionContext | Rect | top: number; | 新增 | +| AccessibilityExtensionContext | Rect | left: number; | 新增 | +| AccessibilityExtensionContext | AccessibilityElement | findElement(type: 'content', condition: string): Promise\<Array\<AccessibilityElement>>;<br>findElement(type: 'content', condition: string, callback: AsyncCallback\<Array\<AccessibilityElement>>): void<br>findElement(type: 'focusType', condition: FocusType): Promise\<AccessibilityElement>;<br>findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback\<AccessibilityElement>): void<br>findElement(type: 'focusDirection', condition: FocusDirection): Promise\<AccessibilityElement>;<br>findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback\<AccessibilityElement>): void | 新增 | +| AccessibilityExtensionContext | AccessibilityElement | performAction(actionName: string, parameters?: object): Promise\<boolean>;<br>performAction(actionName: string, callback: AsyncCallback\<boolean>): void;<br>performAction(actionName: string, parameters: object, callback: AsyncCallback\<boolean>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityElement | actionNames(): Promise\<Array\<string>>;<br>actionNames(callback: AsyncCallback\<Array\<string>>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityElement | "attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T): Promise\<ElementAttributeValues[T]>;<br>attributeValue\<T extends keyof ElementAttributeValues>(attributeName: T, callback: AsyncCallback\<ElementAttributeValues[T]>): void;" | 新增 | +| AccessibilityExtensionContext | AccessibilityElement | attributeNames\<T extends keyof ElementAttributeValues>(): Promise\<Array\<T>>;<br>attributeNames\<T extends keyof ElementAttributeValues>(callback: AsyncCallback\<Array\<T>>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | gestureInject(gesturePath: GesturePath, listener: Callback\<boolean>): Promise\<boolean>;<br>gestureInject(gesturePath: GesturePath, listener: Callback\<boolean>, callback: AsyncCallback\<boolean>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | getWindows(displayId?: number): Promise\<Array\<AccessibilityElement>>;<br>getWindows(callback: AsyncCallback\<Array\<AccessibilityElement>>): void;<br>getWindows(displayId: number, callback: AsyncCallback\<Array\<AccessibilityElement>>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | getWindowRootElement(windowId?: number): Promise\<AccessibilityElement>;<br>getWindowRootElement(callback: AsyncCallback\<AccessibilityElement>): void;<br>getWindowRootElement(windowId: number, callback: AsyncCallback\<AccessibilityElement>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | getFocusElement(isAccessibilityFocus?: boolean): Promise\<AccessibilityElement>;<br>getFocusElement(callback: AsyncCallback\<AccessibilityElement>): void;<br>getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\<AccessibilityElement>): void; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | setTargetBundleName(targetNames: Array\<string>): Promise\<boolean>;<br>setTargetBundleName(targetNames: Array\<string>, callback: AsyncCallback\<boolean>): boolean; | 新增 | +| AccessibilityExtensionContext | AccessibilityExtensionContext | setEventTypeFilter(type: Array\<accessibility.EventType>): Promise\<boolean>;<br>setEventTypeFilter(type: Array\<accessibility.EventType>, callback: AsyncCallback\<boolean>): boolean; | 新增 | +| ohos.accessibility | AccessibilityAbilityInfo | readonly targetBundleNames: Array\<string>; | 新增 | +| ohos.application.AccessibilityExtensionAbility | GesturePoint | positionY: number; | 新增 | +| ohos.application.AccessibilityExtensionAbility | GesturePoint | positionX: number; | 新增 | +| ohos.application.AccessibilityExtensionAbility | GesturePath | durationTime: number; | 新增 | +| ohos.application.AccessibilityExtensionAbility | GesturePath | points: Array\<GesturePoint>; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityEvent | timeStamp?: number; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityEvent | target?: AccessibilityElement; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityEvent | eventType: accessibility.EventType \| accessibility.WindowUpdateType \| TouchGuideType \| GestureType \| PageUpdateType; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityExtensionAbility | onKeyEvent(keyEvent: inputEventClient.KeyEvent): boolean; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityExtensionAbility | onAccessibilityEvent(event: AccessibilityEvent): void; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityExtensionAbility | onDisconnect(): void; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityExtensionAbility | onConnect(): void; | 新增 | +| ohos.application.AccessibilityExtensionAbility | AccessibilityExtensionAbility | context: AccessibilityExtensionContext; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-account.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-account.md new file mode 100644 index 0000000000000000000000000000000000000000..f0c7ba70f97182ec10875cd4b41f6fd029cdc9fb --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-account.md @@ -0,0 +1,40 @@ +# å¸å·å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,å¸å·å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.account.appAccount | Authenticator | getRemoteObject(): rpc.RemoteObject; | 新增 | +| ohos.account.appAccount | Authenticator | isAccountRemovable(name: string, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | Authenticator | checkAccountLabels(name: string, labels: Array\<string>, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | Authenticator | setProperties(options: SetPropertiesOptions, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | Authenticator | verifyCredential(name: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AuthenticatorCallback | onRequestContinued?: () => void; | 新增 | +| ohos.account.appAccount | Constants | KEY_BOOLEAN_RESULT = "booleanResult" | 新增 | +| ohos.account.appAccount | Constants | KEY_REQUIRED_LABELS = "requiredLabels" | 新增 | +| ohos.account.appAccount | SetPropertiesOptions | parameters?: {[key: string]: Object} | 新增 | +| ohos.account.appAccount | SetPropertiesOptions | properties?: {[key: string]: Object}, | 新增 | +| ohos.account.appAccount | VerifyCredentialOptions | parameters?: {[key:string]: Object} | 新增 | +| ohos.account.appAccount | VerifyCredentialOptions | credential?: string, | 新增 | +| ohos.account.appAccount | VerifyCredentialOptions | credentialType?: string, | 新增 | +| ohos.account.appAccount | SelectAccountsOptions | requiredLabels?: Array\<string> | 新增 | +| ohos.account.appAccount | SelectAccountsOptions | allowedOwners?: Array\<string>, | 新增 | +| ohos.account.appAccount | SelectAccountsOptions | allowedAccounts?: Array\<AppAccountInfo>, | 新增 | +| ohos.account.appAccount | OAuthTokenInfo | account?: AppAccountInfo; | 新增 | +| ohos.account.appAccount | AppAccountManager | setAuthenticatorProperties(owner: string, callback: AuthenticatorCallback): void;<br>setAuthenticatorProperties(owner: string, options: SetPropertiesOptions, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | verifyCredential(name: string, owner: string, callback: AuthenticatorCallback): void;<br>verifyCredential(name: string, owner: string, options: VerifyCredentialOptions, callback: AuthenticatorCallback): void; | 新增 | +| ohos.account.appAccount | AppAccountManager | selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback\<Array\<AppAccountInfo>>);<br>selectAccountsByOptions(options: SelectAccountsOptions): Promise\<Array\<AppAccountInfo>>; | 新增 | +| ohos.account.appAccount | AppAccountManager | deleteAccountCredential(name: string, credentialType: string, callback: AsyncCallback\<void>): void;<br>deleteAccountCredential(name: string, credentialType: string): Promise\<void>; | 新增 | +| ohos.account.appAccount | AppAccountManager | checkAccountLabels(name: string, owner: string, labels: Array\<string>, callback: AsyncCallback\<boolean>): void;<br>checkAccountLabels(name: string, owner: string, labels: Array\<string>): Promise\<boolean>; | 新增 | +| ohos.account.appAccount | AppAccountManager | checkAppAccess(name: string, bundleName: string, callback: AsyncCallback\<boolean>): void;<br>checkAppAccess(name: string, bundleName: string): Promise\<boolean>; | 新增 | +| ohos.account.osAccount | ConstraintSourceTypeInfo | type: ConstraintSourceType; | 新增 | +| ohos.account.osAccount | ConstraintSourceTypeInfo | localId: number; | 新增 | +| ohos.account.osAccount | ConstraintSourceType | CONSTRAINT_TYPE_PROFILE_OWNER = 3 | 新增 | +| ohos.account.osAccount | ConstraintSourceType | CONSTRAINT_TYPE_DEVICE_OWNER = 2 | 新增 | +| ohos.account.osAccount | ConstraintSourceType | CONSTRAINT_TYPE_BASE = 1 | 新增 | +| ohos.account.osAccount | ConstraintSourceType | CONSTRAINT_NOT_EXIST = 0 | 新增 | +| ohos.account.osAccount | AccountManager | queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback\<Array\<ConstraintSourceTypeInfo>>): void;<br>queryOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise\<Array\<ConstraintSourceTypeInfo>>; | 新增 | +| ohos.account.osAccount | AccountManager | isMainOsAccount(callback: AsyncCallback\<boolean>): void;<br>isMainOsAccount(): Promise\<boolean>; | 新增 | +| ohos.account.osAccount | AccountManager | getBundleIdFromUid(uid: number, callback: AsyncCallback\<number>): void;<br>getBundleIdFromUid(uid: number): Promise\<number>; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-arkui.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-arkui.md new file mode 100644 index 0000000000000000000000000000000000000000..c345fa6b61211f81e5ec12c490709a42cee4caa9 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-arkui.md @@ -0,0 +1,200 @@ +# ArkUIå系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,ArkUIå系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ArkUI | AbilityComponentInterface | (want: Want): AbilityComponentAttribute; | 新增 | +| ArkUI | AbilityComponentAttribute | onConnect(callback: () => void): AbilityComponentAttribute; | 新增 | +| ArkUI | AbilityComponentAttribute | onDisconnect(callback: () => void): AbilityComponentAttribute; | 新增 | +| ArkUI | HttpAuthHandler | isHttpAuthInfoSaved(): boolean; | 新增 | +| ArkUI | HttpAuthHandler | cancel(): void; | 新增 | +| ArkUI | HttpAuthHandler | confirm(userName: string, password: string): boolean; | 新增 | +| ArkUI | HttpAuthHandler | constructor(); | 新增 | +| ArkUI | HitTestValue | getExtra(): string; | 新增 | +| ArkUI | HitTestValue | getType(): HitTestType; | 新增 | +| ArkUI | HitTestValue | constructor(); | 新增 | +| ArkUI | JsResult | handlePromptConfirm(result: string): void; | 新增 | +| ArkUI | Resource | readonly moduleName: string; | 新增 | +| ArkUI | Resource | readonly bundleName: string; | 新增 | +| ArkUI | TextInputAttribute | textAlign(value: TextAlign): TextInputAttribute; | 新增 | +| ArkUI | TextInputAttribute | showPasswordIcon(value: boolean): TextInputAttribute; | 新增 | +| ArkUI | TextInputAttribute | copyOption(value: boolean \| CopyOption): TextInputAttribute; | 新增 | +| ArkUI | InputType | PhoneNumber | 新增 | +| ArkUI | TextAreaAttribute | copyOption(value: boolean \| CopyOption): TextAreaAttribute; | 新增 | +| ArkUI | TextAttribute | copyOption(value: boolean \| CopyOption): TextAttribute; | 新增 | +| ArkUI | SearchAttribute | textAlign(value: TextAlign): SearchAttribute; | 新增 | +| ArkUI | SearchAttribute | copyOption(value: boolean \| CopyOption): SearchAttribute; | 新增 | +| ArkUI | ScrollAttribute | onScrollBegin(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }): ScrollAttribute; | 新增 | +| ArkUI | Scroller | scrollBy(dx: Length, dy: Length); | 新增 | +| ArkUI | RemoteWindowInterface | (target: WindowAnimationTarget): RemoteWindowAttribute; | 新增 | +| ArkUI | WindowAnimationTarget | readonly windowBounds: RRect; | 新增 | +| ArkUI | WindowAnimationTarget | readonly abilityName: string; | 新增 | +| ArkUI | WindowAnimationTarget | readonly bundleName: string; | 新增 | +| ArkUI | RRect | radius: number; | 新增 | +| ArkUI | RRect | height: number; | 新增 | +| ArkUI | RRect | width: number; | 新增 | +| ArkUI | RRect | top: number; | 新增 | +| ArkUI | RRect | left: number; | 新增 | +| ArkUI | RelativeContainerInterface | (): RelativeContainerAttribute; | 新增 | +| ArkUI | PluginComponentAttribute | onError(callback: (info: { errcode: number; msg: string }) => void): PluginComponentAttribute; | 新增 | +| ArkUI | PluginComponentAttribute | onComplete(callback: () => void): PluginComponentAttribute; | 新增 | +| ArkUI | PluginComponentInterface | (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; | 新增 | +| ArkUI | PluginComponentTemplate | ability: string; | 新增 | +| ArkUI | PluginComponentTemplate | source: string; | 新增 | +| ArkUI | PatternLockAttribute | autoReset(value: boolean): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | onPatternComplete(callback: (input: Array\<number>) => void): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | pathStrokeWidth(value: number \| string): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | pathColor(value: ResourceColor): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | activeColor(value: ResourceColor): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | selectedColor(value: ResourceColor): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | regularColor(value: ResourceColor): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | backgroundColor(value: ResourceColor): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | circleRadius(value: Length): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockAttribute | sideLength(value: Length): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockInterface | (controller?: PatternLockController): PatternLockAttribute; | 新增 | +| ArkUI | PatternLockController | reset(); | 新增 | +| ArkUI | PatternLockController | constructor(); | 新增 | +| ArkUI | ListAttribute | onScrollBegin(event: (dx: number, dy: number) => { dxRemain: number, dyRemain: number }): ListAttribute; | 新增 | +| ArkUI | ListAttribute | alignListItem(value: ListItemAlign): ListAttribute; | 新增 | +| ArkUI | ListAttribute | lanes(value: number \| LengthConstrain): ListAttribute; | 新增 | +| ArkUI | ListItemAlign | End | 新增 | +| ArkUI | ListItemAlign | Center | 新增 | +| ArkUI | ListItemAlign | Start | 新增 | +| ArkUI | ImageFrameInfo | duration?: number; | 新增 | +| ArkUI | ImageFrameInfo | left?: number \| string; | 新增 | +| ArkUI | ImageFrameInfo | top?: number \| string; | 新增 | +| ArkUI | ImageFrameInfo | height?: number \| string; | 新增 | +| ArkUI | ImageFrameInfo | width?: number \| string; | 新增 | +| ArkUI | ImageFrameInfo | src: string \| Resource; | 新增 | +| ArkUI | GridRowAttribute | onBreakpointChange(callback: (breakpoints: string) => void): GridRowAttribute; | 新增 | +| ArkUI | GridRowInterface | (optiion?: GridRowOptions): GridRowAttribute; | 新增 | +| ArkUI | GridRowOptions | direction?: GridRowDirection; | 新增 | +| ArkUI | GridRowOptions | breakpoints?: BreakPoints; | 新增 | +| ArkUI | GridRowOptions | columns?: number \| GridRowColumnOption; | 新增 | +| ArkUI | GridRowOptions | gutter?: Length \| GetterOption; | 新增 | +| ArkUI | BreakPoints | reference?: BreakpointsReference, | 新增 | +| ArkUI | BreakPoints | value?: Array\<string>, | 新增 | +| ArkUI | GridRowDirection | RowReverse | 新增 | +| ArkUI | GridRowDirection | Row | 新增 | +| ArkUI | BreakpointsReference | ComponentSize | 新增 | +| ArkUI | BreakpointsReference | WindowSize | 新增 | +| ArkUI | GetterOption | y?: Length \| GridRowSizeOption | 新增 | +| ArkUI | GetterOption | x?: Length \| GridRowSizeOption, | 新增 | +| ArkUI | GridRowColumnOption | xxl?: number, | 新增 | +| ArkUI | GridRowColumnOption | xl?: number, | 新增 | +| ArkUI | GridRowColumnOption | lg?: number, | 新增 | +| ArkUI | GridRowColumnOption | md?: number, | 新增 | +| ArkUI | GridRowColumnOption | sm?: number, | 新增 | +| ArkUI | GridRowColumnOption | xs?: number, | 新增 | +| ArkUI | GridRowSizeOption | xxl?: Length, | 新增 | +| ArkUI | GridRowSizeOption | xl?: Length, | 新增 | +| ArkUI | GridRowSizeOption | lg?: Length, | 新增 | +| ArkUI | GridRowSizeOption | md?: Length, | 新增 | +| ArkUI | GridRowSizeOption | sm?: Length, | 新增 | +| ArkUI | GridRowSizeOption | xs?: Length, | 新增 | +| ArkUI | GridColAttribute | order(value: number \| GridColColumnOption): GridRowAttribute; | 新增 | +| ArkUI | GridColAttribute | offset(value: number \| GridColColumnOption): GridRowAttribute; | 新增 | +| ArkUI | GridColAttribute | span(value: number \| GridColColumnOption): GridRowAttribute; | 新增 | +| ArkUI | GridColInterface | (optiion?: GridColOptions): GridColAttribute; | 新增 | +| ArkUI | GridColOptions | order?: number \| GridColColumnOption; | 新增 | +| ArkUI | GridColOptions | offset?: number \| GridColColumnOption; | 新增 | +| ArkUI | GridColOptions | span?: number \| GridColColumnOption; | 新增 | +| ArkUI | GridColColumnOption | xxl?: number, | 新增 | +| ArkUI | GridColColumnOption | xl?: number, | 新增 | +| ArkUI | GridColColumnOption | lg?: number, | 新增 | +| ArkUI | GridColColumnOption | md?: number, | 新增 | +| ArkUI | GridColColumnOption | sm?: number, | 新增 | +| ArkUI | GridColColumnOption | xs?: number, | 新增 | +| ArkUI | CopyOption | CrossDevice = 2 | 新增 | +| ArkUI | CopyOption | LocalDevice = 1 | 新增 | +| ArkUI | CopyOption | InApp = 0 | 新增 | +| ArkUI | Placement | RightBottom | 新增 | +| ArkUI | Placement | RightTop | 新增 | +| ArkUI | Placement | LeftBottom | 新增 | +| ArkUI | Placement | LeftTop | 新增 | +| ArkUI | CommonMethod | onVisibleAreaChange(ratios: Array\<number>, event: (isVisible: boolean, currentRatio: number) => void): T; | 新增 | +| ArkUI | CommonMethod | alignRules(value: AlignRuleOption): T; | 新增 | +| ArkUI | CommonMethod | tabIndex(index: number): T; | 新增 | +| ArkUI | CommonMethod | borderImage(value: BorderImageOption): T; | 新增 | +| ArkUI | CommonMethod | backgroundBlurStyle(value: BlurStyle): T; | 新增 | +| ArkUI | BorderImageOption | fill?: boolean | 新增 | +| ArkUI | BorderImageOption | outset?: Length \| EdgeWidths, | 新增 | +| ArkUI | BorderImageOption | width?: Length \| EdgeWidths, | 新增 | +| ArkUI | BorderImageOption | source?: string \| Resource \| linearGradient, | 新增 | +| ArkUI | BorderImageOption | repeat?: RepeatMode, | 新增 | +| ArkUI | BorderImageOption | slice?: Length \| EdgeWidths, | 新增 | +| ArkUI | BlurStyle | Thick | 新增 | +| ArkUI | BlurStyle | Regular | 新增 | +| ArkUI | BlurStyle | Thin | 新增 | +| ArkUI | RepeatMode | Space | 新增 | +| ArkUI | RepeatMode | Round | 新增 | +| ArkUI | RepeatMode | Stretch | 新增 | +| ArkUI | RepeatMode | Repeat | 新增 | +| ArkUI | AlignRuleOption | center?: { anchor: string, align: VerticalAlign }; | 新增 | +| ArkUI | AlignRuleOption | bottom?: { anchor: string, align: VerticalAlign }; | 新增 | +| ArkUI | AlignRuleOption | top?: { anchor: string, align: VerticalAlign }; | 新增 | +| ArkUI | AlignRuleOption | middle?: { anchor: string, align: HorizontalAlign }; | 新增 | +| ArkUI | AlignRuleOption | right?: { anchor: string, align: HorizontalAlign }; | 新增 | +| ArkUI | AlignRuleOption | left?: { anchor: string, align: HorizontalAlign }; | 新增 | +| ArkUI | ICurve | interpolate(fraction : number) : number; | 新增 | +| elementName | ElementName | moduleName?: string; | 新增 | +| global | | function sendMouseEvent(event: MouseEvent): boolean; | 新增 | +| global | | function sendKeyEvent(event: KeyEvent): boolean; | 新增 | +| global | | function sendTouchEvent(event: TouchObject): boolean; | 新增 | +| global | | function sendEventByKey(id: string, action: number, params: string): boolean; | 新增 | +| global | | function getInspectorTree(): string; | 新增 | +| global | | function getInspectorByKey(id: string): string; | 新增 | +| ohos.curves | curves | function springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve; | 新增 | +| ohos.curves | curves | function cubicBezierCurve(x1: number, y1: number, x2: number, y2: number): ICurve; | 新增 | +| ohos.curves | curves | function stepsCurve(count: number, end: boolean): ICurve; | 新增 | +| ohos.curves | curves | function initCurve(curve?: Curve): ICurve; | 新增 | +| ohos.curves | ICurve | interpolate(fraction : number) : number; | 新增 | +| ohos.router | RouterMode | Single | 新增 | +| ohos.router | RouterMode | Standard | 新增 | +| ohos.uiAppearance | uiAppearance | function getDarkMode(): DarkMode; | 新增 | +| ohos.uiAppearance | uiAppearance | function setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void;<br>function setDarkMode(mode: DarkMode): Promise\<void>; | 新增 | +| ohos.uiAppearance | DarkMode | ALWAYS_LIGHT = 1 | 新增 | +| ohos.uiAppearance | DarkMode | ALWAYS_DARK = 0 | 新增 | +| viewmodel | CanvasRenderingContext2D | getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap | 新增 | +| viewmodel | OffscreenCanvasRenderingContext2D | getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap | 新增 | +| ohos.curves | curves | function spring(velocity: number, mass: number, stiffness: number, damping: number): string; | 废弃 | +| ohos.curves | curves | function cubicBezier(x1: number, y1: number, x2: number, y2: number): string; | 废弃 | +| ohos.curves | curves | function steps(count: number, end: boolean): string; | 废弃 | +| ohos.curves | curves | function init(curve?: Curve): string; | 废弃 | +| system.router | Router | static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; | 废弃 | +| system.router | Router | static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; | 废弃 | +| system.router | Router | static getState(): RouterState; | 废弃 | +| system.router | Router | static getLength(): string; | 废弃 | +| system.router | Router | static clear(): void; | 废弃 | +| system.router | Router | static getParams(): ParamsInterface; | 废弃 | +| system.router | Router | static back(options?: BackRouterOptions): void; | 废弃 | +| system.router | Router | static replace(options: RouterOptions): void; | 废弃 | +| system.router | Router | static push(options: RouterOptions): void; | 废弃 | +| system.router | DisableAlertBeforeBackPageOptions | complete?: () => void; | 废弃 | +| system.router | DisableAlertBeforeBackPageOptions | cancel?: (errMsg: string) => void; | 废弃 | +| system.router | DisableAlertBeforeBackPageOptions | success?: (errMsg: string) => void; | 废弃 | +| system.router | EnableAlertBeforeBackPageOptions | complete?: () => void; | 废弃 | +| system.router | EnableAlertBeforeBackPageOptions | cancel?: (errMsg: string) => void; | 废弃 | +| system.router | EnableAlertBeforeBackPageOptions | success?: (errMsg: string) => void; | 废弃 | +| system.router | EnableAlertBeforeBackPageOptions | message: string; | 废弃 | +| system.router | RouterState | path: string; | 废弃 | +| system.router | RouterState | name: string; | 废弃 | +| system.router | RouterState | index: number; | 废弃 | +| system.router | BackRouterOptions | params?: Object; | 废弃 | +| system.router | BackRouterOptions | uri?: string; | 废弃 | +| system.router | RouterOptions | params?: Object; | 废弃 | +| system.router | RouterOptions | uri: string; | 废弃 | +| ohos.prompt | ActionMenuOptions |old : title?: string;<br>new : title?: string \| Resource; | å˜æ›´ | +| ohos.prompt | ShowDialogOptions |old : message?: string;<br>new : message?: string \| Resource; | å˜æ›´ | +| ohos.prompt | ShowDialogOptions |old : title?: string;<br>new : title?: string \| Resource; | å˜æ›´ | +| ohos.prompt | Button |old : color: string;<br>new : color: string \| Resource; | å˜æ›´ | +| ohos.prompt | Button |old : text: string;<br>new : text: string \| Resource; | å˜æ›´ | +| ohos.prompt | ShowToastOptions |old : message: string;<br>new : message: string \| Resource; | å˜æ›´ | +| ArkUI | BorderOptions |old : style?: BorderStyle;<br>new : style?: EdgeStyles \| BorderStyle; | å˜æ›´ | +| ArkUI | BorderOptions |old : radius?: Length;<br>new : radius?: BorderRadiuses \| Length; | å˜æ›´ | +| ArkUI | BorderOptions |old : color?: ResourceColor;<br>new : color?: EdgeColors \| ResourceColor; | å˜æ›´ | +| ArkUI | BorderOptions |old : width?: Length;<br>new : width?: EdgeWidths \| Length; | å˜æ›´ | +| ArkUI | AnimateParam |old : curve?: Curve \| string;<br>new : curve?: Curve \| string \| ICurve; | å˜æ›´ | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-bundle.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-bundle.md new file mode 100644 index 0000000000000000000000000000000000000000..faf69f24b1cd1502a8944018f8e082dff009ae7a --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-bundle.md @@ -0,0 +1,100 @@ +# 包管ç†å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,包管ç†å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| abilityInfo | AbilityInfo | readonly minWindowHeight: number; | 新增 | +| abilityInfo | AbilityInfo | readonly maxWindowHeight: number; | 新增 | +| abilityInfo | AbilityInfo | readonly minWindowWidth: number; | 新增 | +| abilityInfo | AbilityInfo | readonly maxWindowWidth: number; | 新增 | +| abilityInfo | AbilityInfo | readonly minWindowRatio: number; | 新增 | +| abilityInfo | AbilityInfo | readonly maxWindowRatio: number; | 新增 | +| abilityInfo | AbilityInfo | readonly supportWindowMode: Array\<bundle.SupportWindowMode>; | 新增 | +| bundleInstaller | InstallParam | crowdtestDeadline?: number; | 新增 | +| bundleInstaller | InstallParam | hashParams?: Array\<HashParam>; | 新增 | +| bundleInstaller | HashParam | hashValue: string; | 新增 | +| bundleInstaller | HashParam | moduleName: string; | 新增 | +| dispatchInfo | DispatchInfo | readonly dispatchAPI: string; | 新增 | +| dispatchInfo | DispatchInfo | readonly verison: string; | 新增 | +| hapModuleInfo | HapModuleInfo | readonly hashValue: string; | 新增 | +| ohos.bundle | bundle | getDisposedStatus(bundleName: string, callback: AsyncCallback\<number>): void;<br>getDisposedStatus(bundleName: string): Promise\<number>; | 新增 | +| ohos.bundle | bundle | setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback\<void>): void;<br>setDisposedStatus(bundleName: string, status: number): Promise\<void>; | 新增 | +| ohos.bundle | bundle | getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;<br>getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\<Array\<string>>; | 新增 | +| ohos.bundle | bundle | getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\<Array\<string>>): void;<br>getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\<Array\<string>>; | 新增 | +| ohos.bundle | bundle | getDispatcherVersion(callback: AsyncCallback\<DispatchInfo>): void;<br>getDispatcherVersion(): Promise\<DispatchInfo>; | 新增 | +| ohos.bundle | bundle | getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback\<pack.BundlePackInfo>): void;<br>getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): Promise\<pack.BundlePackInfo>; | 新增 | +| ohos.bundle | SupportWindowMode | FLOATING = 2 | 新增 | +| ohos.bundle | SupportWindowMode | SPLIT = 1 | 新增 | +| ohos.bundle | SupportWindowMode | FULL_SCREEN = 0 | 新增 | +| ohos.bundle | ExtensionAbilityType | ENTERPRISE_ADMIN = 11 | 新增 | +| ohos.bundle | DisplayOrientation | LOCKED | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION_PORTRAIT_RESTRICTED | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION_LANDSCAPE_RESTRICTED | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION_RESTRICTED | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION_PORTRAIT | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION_LANDSCAPE | 新增 | +| ohos.bundle | DisplayOrientation | AUTO_ROTATION | 新增 | +| ohos.bundle | DisplayOrientation | PORTRAIT_INVERTED | 新增 | +| ohos.bundle | DisplayOrientation | LANDSCAPE_INVERTED | 新增 | +| ohos.bundle | BundleFlag | GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT = 0x00000400 | 新增 | +| ohos.bundle | BundleFlag | GET_BUNDLE_WITH_HASH_VALUE = 0x00000030 | 新增 | +| ohos.bundle.defaultAppManager | defaultAppManager | resetDefaultApplication(type: string, userId?: number) : Promise\<void>;<br>resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\<void>) : void;<br>resetDefaultApplication(type: string, callback: AsyncCallback\<void>) : void; | 新增 | +| ohos.bundle.defaultAppManager | defaultAppManager | setDefaultApplication(type: string, elementName: ElementName, userId?: number) : Promise\<void>;<br>setDefaultApplication(type: string, elementName: ElementName, userId: number, callback: AsyncCallback\<void>) : void;<br>setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCallback\<void>) : void; | 新增 | +| ohos.bundle.defaultAppManager | defaultAppManager | getDefaultApplication(type: string, userId?: number) : Promise\<BundleInfo>;<br>getDefaultApplication(type: string, userId: number, callback: AsyncCallback\<BundleInfo>) : void;<br>getDefaultApplication(type: string, callback: AsyncCallback\<BundleInfo>) : void; | 新增 | +| ohos.bundle.defaultAppManager | defaultAppManager | isDefaultApplication(type: string) : Promise\<boolean>;<br>isDefaultApplication(type: string, callback: AsyncCallback\<boolean>) : void; | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | PPT = "PPT" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | EXCEL = "EXCEL" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | WORD = "WORD" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | PDF = "PDF" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | VIDEO = "VIDEO" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | AUDIO = "AUDIO" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | IMAGE = "IMAGE" | 新增 | +| ohos.bundle.defaultAppManager | ApplicationType | BROWSER = "BROWSER" | 新增 | +| packInfo | BundlePackFlag | GET_MODULE_SUMMARY = 0x00000004 | 新增 | +| packInfo | BundlePackFlag | GET_BUNDLE_SUMMARY = 0x00000002 | 新增 | +| packInfo | BundlePackFlag | GET_PACKAGES = 0x00000001 | 新增 | +| packInfo | BundlePackFlag | GET_PACK_INFO_ALL = 0x00000000 | 新增 | +| packInfo | ApiVersion | readonly target: number; | 新增 | +| packInfo | ApiVersion | readonly compatible: number; | 新增 | +| packInfo | ApiVersion | readonly releaseType: string; | 新增 | +| packInfo | Version | readonly code: number; | 新增 | +| packInfo | Version | readonly name: string; | 新增 | +| packInfo | Version | readonly minCompatibleVersionCode: number; | 新增 | +| packInfo | AbilityFormInfo | readonly defaultDimension: number; | 新增 | +| packInfo | AbilityFormInfo | readonly supportDimensions: Array\<number>; | 新增 | +| packInfo | AbilityFormInfo | readonly updateDuration: number; | 新增 | +| packInfo | AbilityFormInfo | readonly scheduledUpdateTime: string; | 新增 | +| packInfo | AbilityFormInfo | readonly updateEnabled: boolean; | 新增 | +| packInfo | AbilityFormInfo | readonly type: string; | 新增 | +| packInfo | AbilityFormInfo | readonly name: string; | 新增 | +| packInfo | ModuleAbilityInfo | readonly forms: Array\<AbilityFormInfo>; | 新增 | +| packInfo | ModuleAbilityInfo | readonly visible: boolean; | 新增 | +| packInfo | ModuleAbilityInfo | readonly label: string; | 新增 | +| packInfo | ModuleAbilityInfo | readonly name: string; | 新增 | +| packInfo | ModuleDistroInfo | readonly moduleType: string; | 新增 | +| packInfo | ModuleDistroInfo | readonly moduleName: string; | 新增 | +| packInfo | ModuleDistroInfo | readonly installationFree: boolean; | 新增 | +| packInfo | ModuleDistroInfo | readonly deliveryWithInstall: boolean; | 新增 | +| packInfo | ModuleDistroInfo | readonly mainAbility: string; | 新增 | +| packInfo | ModuleConfigInfo | readonly extensionAbilities: Array\<ExtensionAbilities>; | 新增 | +| packInfo | ModuleConfigInfo | readonly abilities: Array\<ModuleAbilityInfo>; | 新增 | +| packInfo | ModuleConfigInfo | readonly distro: ModuleDistroInfo; | 新增 | +| packInfo | ModuleConfigInfo | readonly deviceType: Array\<string>; | 新增 | +| packInfo | ModuleConfigInfo | readonly apiVersion: ApiVersion; | 新增 | +| packInfo | ExtensionAbilities | readonly forms: Array\<AbilityFormInfo>; | 新增 | +| packInfo | ExtensionAbilities | readonly name: string; | 新增 | +| packInfo | BundleConfigInfo | readonly version: Version; | 新增 | +| packInfo | BundleConfigInfo | readonly bundleName: string; | 新增 | +| packInfo | PackageSummary | readonly modules: Array\<ModuleConfigInfo>; | 新增 | +| packInfo | PackageSummary | readonly app: BundleConfigInfo; | 新增 | +| packInfo | PackageConfig | readonly deliveryWithInstall: boolean; | 新增 | +| packInfo | PackageConfig | readonly moduleType: string; | 新增 | +| packInfo | PackageConfig | readonly name: string; | 新增 | +| packInfo | PackageConfig | readonly deviceType: Array\<string>; | 新增 | +| packInfo | BundlePackInfo | readonly summary: PackageSummary; | 新增 | +| packInfo | BundlePackInfo | readonly packages: Array\<PackageConfig>; | 新增 | +| shortcutInfo | ShortcutInfo | readonly moduleName?: string; | 新增 | +| shortcutInfo | ShortcutWant | readonly targetModule: string; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-communicate.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-communicate.md new file mode 100644 index 0000000000000000000000000000000000000000..cd21be290412414987d493d2475878ce93f9e311 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-communicate.md @@ -0,0 +1,158 @@ +# 基础通信å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,基础通信å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| nfctech | NdefFormatableTag | formatReadOnly(message: NdefMessage): Promise\<number>;<br>formatReadOnly(message: NdefMessage, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | NdefFormatableTag | format(message: NdefMessage): Promise\<number>;<br>format(message: NdefMessage, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareUltralightTag | getType(): MifareUltralightType; | 新增 | +| nfctech | MifareUltralightTag | writeSinglePages(pageIndex: number, data: string): Promise\<number>;<br>writeSinglePages(pageIndex: number, data: string, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareUltralightTag | readMultiplePages(pageIndex: number): Promise\<string>;<br>readMultiplePages(pageIndex: number, callback: AsyncCallback\<string>): void; | 新增 | +| nfctech | MifareUltralightType | TYPE_ULTRALIGHT_C = 2 | 新增 | +| nfctech | MifareUltralightType | TYPE_ULTRALIGHT = 1 | 新增 | +| nfctech | MifareUltralightType | TYPE_UNKOWN = -1 | 新增 | +| nfctech | MifareClassicTag | getSectorIndex(blockIndex: number): number; | 新增 | +| nfctech | MifareClassicTag | getBlockIndex(sectorIndex: number): number; | 新增 | +| nfctech | MifareClassicTag | isEmulatedTag(): boolean; | 新增 | +| nfctech | MifareClassicTag | getTagSize(): number; | 新增 | +| nfctech | MifareClassicTag | getType(): MifareClassicType; | 新增 | +| nfctech | MifareClassicTag | getBlockCountInSector(sectorIndex: number): number; | 新增 | +| nfctech | MifareClassicTag | getSectorCount(): number; | 新增 | +| nfctech | MifareClassicTag | restoreFromBlock(blockIndex: number): Promise\<number>;<br>restoreFromBlock(blockIndex: number, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareClassicTag | transferToBlock(blockIndex: number): Promise\<number>;<br>transferToBlock(blockIndex: number, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareClassicTag | decrementBlock(blockIndex: number, value: number): Promise\<number>;<br>decrementBlock(blockIndex: number, value: number, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareClassicTag | incrementBlock(blockIndex: number, value: number): Promise\<number>;<br>incrementBlock(blockIndex: number, value: number, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareClassicTag | writeSingleBlock(blockIndex: number, data: string): Promise\<number>;<br>writeSingleBlock(blockIndex: number, data: string, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | MifareClassicTag | readSingleBlock(blockIndex: number): Promise\<string>;<br>readSingleBlock(blockIndex: number, callback: AsyncCallback\<string>): void; | 新增 | +| nfctech | MifareClassicTag | authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise\<boolean>;<br>authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback\<boolean>): void; | 新增 | +| nfctech | MifareTagSize | MC_SIZE_4K = 4096 | 新增 | +| nfctech | MifareTagSize | MC_SIZE_2K = 2048 | 新增 | +| nfctech | MifareTagSize | MC_SIZE_1K = 1024 | 新增 | +| nfctech | MifareTagSize | MC_SIZE_MINI = 320 | 新增 | +| nfctech | MifareClassicType | TYPE_PRO = 2 | 新增 | +| nfctech | MifareClassicType | TYPE_PLUS = 1 | 新增 | +| nfctech | MifareClassicType | TYPE_CLASSIC = 0 | 新增 | +| nfctech | MifareClassicType | TYPE_UNKNOWN = -1 | 新增 | +| nfctech | NdefTag | getNdefTagTypeString(type: NfcForumType): string; | 新增 | +| nfctech | NdefTag | setReadOnly(): Promise\<number>;<br>setReadOnly(callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | NdefTag | canSetReadOnly(): Promise\<boolean>;<br>canSetReadOnly(callback: AsyncCallback\<boolean>): void; | 新增 | +| nfctech | NdefTag | writeNdef(msg: NdefMessage): Promise\<number>;<br>writeNdef(msg: NdefMessage, callback: AsyncCallback\<number>): void; | 新增 | +| nfctech | NdefTag | readNdef(): Promise\<NdefMessage>;<br>readNdef(callback: AsyncCallback\<NdefMessage>): void; | 新增 | +| nfctech | NdefTag | isNdefWritable(): Promise\<boolean>;<br>isNdefWritable(callback: AsyncCallback\<boolean>): void; | 新增 | +| nfctech | NdefTag | getNdefMessage(): NdefMessage; | 新增 | +| nfctech | NdefTag | getNdefTagType(): NfcForumType; | 新增 | +| nfctech | NdefTag | createNdefMessage(data: string): NdefMessage;<br>createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; | 新增 | +| nfctech | NfcForumType | MIFARE_CLASSIC = 101 | 新增 | +| nfctech | NfcForumType | NFC_FORUM_TYPE_4 = 4 | 新增 | +| nfctech | NfcForumType | NFC_FORUM_TYPE_3 = 3 | 新增 | +| nfctech | NfcForumType | NFC_FORUM_TYPE_2 = 2 | 新增 | +| nfctech | NfcForumType | NFC_FORUM_TYPE_1 = 1 | 新增 | +| nfctech | NdefMessage | messageToString(ndefMessage: NdefMessage): string; | 新增 | +| nfctech | NdefMessage | makeExternalRecord(domainName: string, serviceName: string, externalData: string): NdefRecord; | 新增 | +| nfctech | NdefMessage | makeMimeRecord(mimeType: string, mimeData: string): NdefRecord; | 新增 | +| nfctech | NdefMessage | makeTextRecord(text: string, locale: string): NdefRecord; | 新增 | +| nfctech | NdefMessage | makeUriRecord(uri: string): NdefRecord; | 新增 | +| nfctech | NdefMessage | getNdefRecords(): NdefRecord[]; | 新增 | +| nfctech | RtdType | RTD_URI: 'U'; | 新增 | +| nfctech | RtdType | RTD_TEXT: 'T'; | 新增 | +| nfctech | TnfType | TNF_UNCHANGED = 0x6 | 新增 | +| nfctech | TnfType | TNF_UNKNOWN = 0x5 | 新增 | +| nfctech | TnfType | TNF_EXT_APP = 0x4 | 新增 | +| nfctech | TnfType | TNF_ABSOLUTE_URI = 0x3 | 新增 | +| nfctech | TnfType | TNF_MEDIA = 0x2 | 新增 | +| nfctech | TnfType | TNF_WELL_KNOWN = 0x1 | 新增 | +| nfctech | TnfType | TNF_EMPTY = 0x0 | 新增 | +| nfctech | NdefRecord | payload: string; | 新增 | +| nfctech | NdefRecord | id: string; | 新增 | +| nfctech | NdefRecord | rtdType: string; | 新增 | +| nfctech | NdefRecord | tnf: number; | 新增 | +| nfctech | IsoDepTag | isExtendedApduSupported(): Promise\<boolean>;<br>isExtendedApduSupported(callback: AsyncCallback\<boolean>): void; | 新增 | +| nfctech | IsoDepTag | getHiLayerResponse(): string; | 新增 | +| nfctech | IsoDepTag | getHistoricalBytes(): string; | 新增 | +| ohos.bluetooth | ProfileId | PROFILE_PAN_NETWORK = 7 | 新增 | +| ohos.bluetooth | ScanFilter | manufactureDataMask?: ArrayBuffer; | 新增 | +| ohos.bluetooth | ScanFilter | manufactureData?: ArrayBuffer; | 新增 | +| ohos.bluetooth | ScanFilter | manufactureId?: number; | 新增 | +| ohos.bluetooth | ScanFilter | serviceDataMask?: ArrayBuffer; | 新增 | +| ohos.bluetooth | ScanFilter | serviceData?: ArrayBuffer; | 新增 | +| ohos.bluetooth | ScanFilter | serviceSolicitationUuidMask?: string; | 新增 | +| ohos.bluetooth | ScanFilter | serviceSolicitationUuid?: string; | 新增 | +| ohos.bluetooth | ScanFilter | serviceUuidMask?: string; | 新增 | +| ohos.bluetooth | PanProfile | isTetheringOn(): boolean; | 新增 | +| ohos.bluetooth | PanProfile | setTethering(enable: boolean): void; | 新增 | +| ohos.bluetooth | PanProfile | off(type: "connectionStateChange", callback?: Callback\<StateChangeParam>): void; | 新增 | +| ohos.bluetooth | PanProfile | on(type: "connectionStateChange", callback: Callback\<StateChangeParam>): void; | 新增 | +| ohos.bluetooth | PanProfile | disconnect(device: string): boolean; | 新增 | +| ohos.bluetooth | bluetooth | getProfileInst(profileId: ProfileId): A2dpSourceProfile \| HandsFreeAudioGatewayProfile \| HidHostProfile \| PanProfile; | 新增 | +| ohos.nfc.tag | TagInfo | remoteTagService: rpc.RemoteObject; | 新增 | +| ohos.nfc.tag | TagInfo | tagRfDiscId: number; | 新增 | +| ohos.nfc.tag | TagInfo | extrasData: PacMap[]; | 新增 | +| ohos.nfc.tag | TagInfo | technology: number[]; | 新增 | +| ohos.nfc.tag | TagInfo | uid: string; | 新增 | +| ohos.nfc.tag | tag | getNdefFormatableTag(tagInfo: TagInfo): NdefFormatableTag | 新增 | +| ohos.nfc.tag | tag | getMifareUltralightTag(tagInfo: TagInfo): MifareUltralightTag | 新增 | +| ohos.nfc.tag | tag | getMifareClassicTag(tagInfo: TagInfo): MifareClassicTag | 新增 | +| ohos.nfc.tag | tag | getNdefTag(tagInfo: TagInfo): NdefTag | 新增 | +| ohos.nfc.tag | tag | getIsoDepTag(tagInfo: TagInfo): IsoDepTag | 新增 | +| ohos.nfc.tag | tag | const NDEF_FORMATABLE = 10; | 新增 | +| ohos.wifi | WifiLinkedInfo | macType: number; | 新增 | +| ohos.wifi | WifiSecurityType | WIFI_SEC_TYPE_WAPI_PSK = 9 | 新增 | +| ohos.wifi | WifiSecurityType | WIFI_SEC_TYPE_WAPI_CERT = 8 | 新增 | +| ohos.wifi | WifiSecurityType | WIFI_SEC_TYPE_OWE = 7 | 新增 | +| ohos.wifi | WifiSecurityType | WIFI_SEC_TYPE_EAP_SUITE_B = 6 | 新增 | +| ohos.wifi | WifiSecurityType | WIFI_SEC_TYPE_EAP = 5 | 新增 | +| ohos.wifi | WifiScanInfo | infoElems: Array\<WifiInfoElem>; | 新增 | +| ohos.wifi | WifiScanInfo | centerFrequency1: number; | 新增 | +| ohos.wifi | WifiScanInfo | centerFrequency0: number; | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_INVALID | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_80MHZ_PLUS = 4 | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_160MHZ = 3 | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_80MHZ = 2 | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_40MHZ = 1 | 新增 | +| ohos.wifi | WifiChannelWidth | WIDTH_20MHZ = 0 | 新增 | +| ohos.wifi | WifiInfoElem | content: Uint8Array; | 新增 | +| ohos.wifi | WifiInfoElem | eid: number; | 新增 | +| ohos.wifi | WifiDeviceConfig | eapConfig: WifiEapConfig; | 新增 | +| ohos.wifi | WifiEapConfig | eapSubId: number; | 新增 | +| ohos.wifi | WifiEapConfig | plmn: string; | 新增 | +| ohos.wifi | WifiEapConfig | realm: string; | 新增 | +| ohos.wifi | WifiEapConfig | domainSuffixMatch: string; | 新增 | +| ohos.wifi | WifiEapConfig | altSubjectMatch: string; | 新增 | +| ohos.wifi | WifiEapConfig | clientCertAliases: string; | 新增 | +| ohos.wifi | WifiEapConfig | caPath: string; | 新增 | +| ohos.wifi | WifiEapConfig | caCertAliases: string; | 新增 | +| ohos.wifi | WifiEapConfig | password: string; | 新增 | +| ohos.wifi | WifiEapConfig | anonymousIdentity: string; | 新增 | +| ohos.wifi | WifiEapConfig | identity: string; | 新增 | +| ohos.wifi | WifiEapConfig | phase2Method: Phase2Method; | 新增 | +| ohos.wifi | WifiEapConfig | eapMethod: EapMethod; | 新增 | +| ohos.wifi | Phase2Method | PHASE2_AKA_PRIME | 新增 | +| ohos.wifi | Phase2Method | PHASE2_AKA | 新增 | +| ohos.wifi | Phase2Method | PHASE2_SIM | 新增 | +| ohos.wifi | Phase2Method | PHASE2_GTC | 新增 | +| ohos.wifi | Phase2Method | PHASE2_MSCHAPV2 | 新增 | +| ohos.wifi | Phase2Method | PHASE2_MSCHAP | 新增 | +| ohos.wifi | Phase2Method | PHASE2_PAP | 新增 | +| ohos.wifi | Phase2Method | PHASE2_NONE | 新增 | +| ohos.wifi | EapMethod | EAP_UNAUTH_TLS | 新增 | +| ohos.wifi | EapMethod | EAP_AKA_PRIME | 新增 | +| ohos.wifi | EapMethod | EAP_AKA | 新增 | +| ohos.wifi | EapMethod | EAP_SIM | 新增 | +| ohos.wifi | EapMethod | EAP_PWD | 新增 | +| ohos.wifi | EapMethod | EAP_TTLS | 新增 | +| ohos.wifi | EapMethod | EAP_TLS | 新增 | +| ohos.wifi | EapMethod | EAP_PEAP | 新增 | +| ohos.wifi | EapMethod | EAP_NONE | 新增 | +| ohos.wifi | wifi | getP2pGroups(): Promise\<Array\<WifiP2pGroupInfo>>;<br>getP2pGroups(callback: AsyncCallback\<Array\<WifiP2pGroupInfo>>): void; | 新增 | +| ohos.wifi | wifi | getP2pLocalDevice(): Promise\<WifiP2pDevice>;<br>getP2pLocalDevice(callback: AsyncCallback\<WifiP2pDevice>): void; | 新增 | +| ohos.wifi | wifi | connectToCandidateConfig(networkId: number): void; | 新增 | +| ohos.wifi | wifi | getCandidateConfigs(): Array\<WifiDeviceConfig>; | 新增 | +| ohos.wifi | wifi | removeCandidateConfig(networkId: number): Promise\<void>;<br>removeCandidateConfig(networkId: number, callback: AsyncCallback\<void>): void; | 新增 | +| ohos.wifi | wifi | addCandidateConfig(config: WifiDeviceConfig): Promise\<number>;<br>addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.wifi | wifi | getScanInfosSync(): Array\<WifiScanInfo>; | 新增 | +| ohos.bluetooth | A2dpSourceProfile | getPlayingState(device: string): PlayingState; | 废弃 | +| ohos.nfc.tag | TagInfo | supportedProfiles: number[]; | 废弃 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-complier-and-runtime.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-complier-and-runtime.md new file mode 100644 index 0000000000000000000000000000000000000000..26156bf385cd5536cb9be029d7cc33708903970a --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-complier-and-runtime.md @@ -0,0 +1,9 @@ +# 公共基础库å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,公共基础库å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.util | util | promisify(original: (err: Object, value: Object) => void): Function; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-dfx.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-dfx.md new file mode 100644 index 0000000000000000000000000000000000000000..0bf067aeb367bae5d77c05e9750a5e57a7237a72 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-dfx.md @@ -0,0 +1,37 @@ +# DFXå系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,DFXå系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.hiSysEvent | hiSysEvent | query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): number; | 新增 | +| ohos.hiSysEvent | hiSysEvent | removeWatcher(wathcer: Watcher): number; | 新增 | +| ohos.hiSysEvent | hiSysEvent | addWatcher(watcher: Watcher): number; | 新增 | +| ohos.hiSysEvent | Querier | onComplete: (reason: number, total: number) => void; | 新增 | +| ohos.hiSysEvent | Querier | onQuery: (infos: SysEventInfo[], seqs: number[]) => void; | 新增 | +| ohos.hiSysEvent | QueryRule | names: string[]; | 新增 | +| ohos.hiSysEvent | QueryRule | domain: string; | 新增 | +| ohos.hiSysEvent | QueryArg | maxEvents: number; | 新增 | +| ohos.hiSysEvent | QueryArg | endTime: number; | 新增 | +| ohos.hiSysEvent | QueryArg | beginTime: number; | 新增 | +| ohos.hiSysEvent | Watcher | onServiceDied: () => void; | 新增 | +| ohos.hiSysEvent | Watcher | onEvent: (info: SysEventInfo) => void; | 新增 | +| ohos.hiSysEvent | Watcher | rules: WatchRule[]; | 新增 | +| ohos.hiSysEvent | WatchRule | ruleType: RuleType; | 新增 | +| ohos.hiSysEvent | WatchRule | tag: string; | 新增 | +| ohos.hiSysEvent | WatchRule | name: string; | 新增 | +| ohos.hiSysEvent | WatchRule | domain: string; | 新增 | +| ohos.hiSysEvent | RuleType | REGULAR = 3 | 新增 | +| ohos.hiSysEvent | RuleType | PREFIX = 2 | 新增 | +| ohos.hiSysEvent | RuleType | WHOLE_WORD = 1 | 新增 | +| ohos.hiSysEvent | hiSysEvent | write(info: SysEventInfo): Promise\<void>;<br>write(info: SysEventInfo, callback: AsyncCallback\<void>): void; | 新增 | +| ohos.hiSysEvent | SysEventInfo | params: object; | 新增 | +| ohos.hiSysEvent | SysEventInfo | eventType: EventType; | 新增 | +| ohos.hiSysEvent | SysEventInfo | name: string; | 新增 | +| ohos.hiSysEvent | SysEventInfo | domain: string; | 新增 | +| ohos.hiSysEvent | EventType | BEHAVIOR = 4 | 新增 | +| ohos.hiSysEvent | EventType | SECURITY = 3 | 新增 | +| ohos.hiSysEvent | EventType | STATISTIC = 2 | 新增 | +| ohos.hiSysEvent | EventType | FAULT = 1 | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-distributed-data.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-distributed-data.md new file mode 100644 index 0000000000000000000000000000000000000000..344e734bf53cb75dd71c978d32b7a9aa2937dbec --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-distributed-data.md @@ -0,0 +1,91 @@ +# 分布å¼æ•°æ®ç®¡ç†å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,分布å¼æ•°æ®ç®¡ç†å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.data.dataShare | DataShareHelper | notifyChange(uri: string, callback: AsyncCallback\<void>): void;<br>notifyChange(uri: string): Promise\<void>; | 新增 | +| ohos.data.dataShare | DataShareHelper | denormalizeUri(uri: string, callback: AsyncCallback\<string>): void;<br>denormalizeUri(uri: string): Promise\<string>; | 新增 | +| ohos.data.dataShare | DataShareHelper | normalizeUri(uri: string, callback: AsyncCallback\<string>): void;<br>normalizeUri(uri: string): Promise\<string>; | 新增 | +| ohos.data.dataShare | DataShareHelper | getFileTypes(uri: string, mimeTypeFilter:string, callback: AsyncCallback\<Array\<string>>): void;<br>getFileTypes(uri: string, mimeTypeFilter: string): Promise\<Array\<string>>; | 新增 | +| ohos.data.dataShare | DataShareHelper | getType(uri: string, callback: AsyncCallback\<string>): void;<br>getType(uri: string): Promise\<string>; | 新增 | +| ohos.data.dataShare | DataShareHelper | batchInsert(uri: string, values: Array\<ValuesBucket>, callback: AsyncCallback\<number>): void;<br>batchInsert(uri: string, values: Array\<ValuesBucket>): Promise\<number>; | 新增 | +| ohos.data.dataShare | DataShareHelper | update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket, callback: AsyncCallback\<number>): void;<br>update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise\<number>; | 新增 | +| ohos.data.dataShare | DataShareHelper | query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array\<string>, callback: AsyncCallback\<DataShareResultSet>): void;<br>query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array\<string>): Promise\<DataShareResultSet>; | 新增 | +| ohos.data.dataShare | DataShareHelper | delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback\<number>): void;<br>delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise\<number>; | 新增 | +| ohos.data.dataShare | DataShareHelper | insert(uri: string, value: ValuesBucket, callback: AsyncCallback\<number>): void;<br>insert(uri: string, value: ValuesBucket): Promise\<number>; | 新增 | +| ohos.data.dataShare | DataShareHelper | off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void; | 新增 | +| ohos.data.dataShare | DataShareHelper | on(type: 'dataChange', uri: string, callback: AsyncCallback\<void>): void; | 新增 | +| ohos.data.dataShare | DataShareHelper | openFile(uri: string, mode: string, callback: AsyncCallback\<number>): void;<br>openFile(uri: string, mode: string): Promise\<number>; | 新增 | +| ohos.data.dataShare | dataShare | function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback\<DataShareHelper>): void;<br>function createDataShareHelper(context: Context, uri: string): Promise\<DataShareHelper>; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | inKeys(keys: Array\<string>): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | prefixKey(prefix: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | notIn(field: string, value: Array\<ValueType>): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | in(field: string, value: Array\<ValueType>): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | indexedBy(field: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | groupBy(fields: Array\<string>): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | limit(total: number, offset: number): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | distinct(): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | orderByDesc(field: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | orderByAsc(field: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | lessThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | greaterThanOrEqualTo(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | lessThan(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | greaterThan(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | notBetween(field: string, low: ValueType, high: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | between(field: string, low: ValueType, high: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | glob(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | unlike(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | like(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | isNotNull(field: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | isNull(field: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | endsWith(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | beginsWith(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | contains(field: string, value: string): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | and(): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | or(): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | endWrap(): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | beginWrap(): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | notEqualTo(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.dataSharePredicates | DataSharePredicates | equalTo(field: string, value: ValueType): DataSharePredicates; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getDataType(columnIndex: number): DataType; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getColumnName(columnIndex: number): string; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getColumnIndex(columnName: string): number; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | close(): void; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getDouble(columnIndex: number): number; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getLong(columnIndex: number): number; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getString(columnIndex: number): string; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | getBlob(columnIndex: number): Uint8Array; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goToRow(position: number): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goTo(offset: number): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goToPreviousRow(): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goToNextRow(): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goToLastRow(): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | goToFirstRow(): boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | isClosed: boolean; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | rowCount: number; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | columnCount: number; | 新增 | +| ohos.data.DataShareResultSet | DataShareResultSet | columnNames: Array\<string>; | 新增 | +| ohos.data.DataShareResultSet | DataType | TYPE_BLOB = 4 | 新增 | +| ohos.data.DataShareResultSet | DataType | TYPE_STRING = 3 | 新增 | +| ohos.data.DataShareResultSet | DataType | TYPE_DOUBLE = 2 | 新增 | +| ohos.data.DataShareResultSet | DataType | TYPE_LONG = 1 | 新增 | +| ohos.data.DataShareResultSet | DataType | TYPE_NULL = 0 | 新增 | +| ohos.data.distributedData | DeviceKVStore | off(event:'dataChange', listener?: Callback\<ChangeNotification>): void; | 新增 | +| ohos.data.distributedData | DeviceKVStore | on(event: 'dataChange', type: SubscribeType, listener: Callback\<ChangeNotification>): void; | 新增 | +| ohos.data.distributedData | SingleKVStore | off(event:'dataChange', listener?: Callback\<ChangeNotification>): void; | 新增 | +| ohos.data.distributedData | SingleKVStore | on(event: 'dataChange', type: SubscribeType, listener: Callback\<ChangeNotification>): void; | 新增 | +| ohos.data.distributedData | KVStore | off(event: 'syncComplete', syncCallback?: Callback\<Array\<[string, number]>>): void; | 新增 | +| ohos.data.distributedData | KVManagerConfig | context: Context; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | revokeSave(callback: AsyncCallback\<RevokeSaveSuccessResponse>): void;<br>revokeSave(): Promise\<RevokeSaveSuccessResponse>; | 新增 | +| ohos.data.distributedDataObject | DistributedObject | save(deviceId: string, callback: AsyncCallback\<SaveSuccessResponse>): void;<br>save(deviceId: string): Promise\<SaveSuccessResponse>; | 新增 | +| ohos.data.distributedDataObject | RevokeSaveSuccessResponse | sessionId: string; | 新增 | +| ohos.data.distributedDataObject | SaveSuccessResponse | deviceId: string; | 新增 | +| ohos.data.distributedDataObject | SaveSuccessResponse | version: number; | 新增 | +| ohos.data.distributedDataObject | SaveSuccessResponse | sessionId: string; | 新增 | +| ohos.data.rdb | RdbStore | restore(srcName:string, callback: AsyncCallback\<void>):void;<br>restore(srcName:string): Promise\<void>; | 新增 | +| ohos.data.rdb | RdbStore | backup(destName:string, callback: AsyncCallback\<void>):void;<br>backup(destName:string): Promise\<void>; | 新增 | + + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-event-and-notification.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-event-and-notification.md new file mode 100644 index 0000000000000000000000000000000000000000..9b21c15e940377202de677db0defde261568d24a --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-event-and-notification.md @@ -0,0 +1,15 @@ +# 事件通知å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,事件通知å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| notificationRequest | NotificationRequest | badgeNumber?: number; | 新增 | +| notificationRequest | NotificationRequest | removalWantAgent?: WantAgent; | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_SPN_INFO_CHANGED = "usual.event.SPN_INFO_CHANGED" | 新增 | +| ohos.commonEvent | Support | COMMON_EVENT_SLOT_CHANGE = "usual.event.SLOT_CHANGE" | 新增 | +| ohos.notification | notification | getSyncNotificationEnabledForUninstallApp(userId: number, callback: AsyncCallback\<boolean>): void;<br>getSyncNotificationEnabledForUninstallApp(userId: number): Promise\<boolean>; | 新增 | +| ohos.notification | notification | setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean, callback: AsyncCallback\<void>): void;<br>setSyncNotificationEnabledForUninstallApp(userId: number, enable: boolean): Promise\<void>; | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-file-management.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-file-management.md new file mode 100644 index 0000000000000000000000000000000000000000..05aff45189bae78ea6a4377f7a2a32a1283df3b5 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-file-management.md @@ -0,0 +1,14 @@ +# 文件管ç†å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,文件管ç†å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.volumeManager | Volume | diskId: string; | 新增 | +| ohos.volumeManager | volumeManager | partition(volId: string, fstype: string, callback: AsyncCallback\<void>): void;<br>partition(volId: string, fstype: string): Promise\<void>; | å˜æ›´ | +| ohos.volumeManager | volumeManager | format(volId: string, callback: AsyncCallback\<void>): void;<br>format(volId: string): Promise\<void>; | å˜æ›´ | +| ohos.volumeManager | volumeManager | old :<br>getVolumeById(id: string, callback: AsyncCallback\<Volume>): void;<br>getVolumeById(id: string): Promise\<Volume>;<br>new :<br>getVolumeById(volumeId: string, callback: AsyncCallback\<Volume>): void;<br>getVolumeById(volumeId: string): Promise\<Volume> | å˜æ›´ | +| ohos.volumeManager | volumeManager | old :<br>format(volId: string, callback: AsyncCallback\<void>): void;<br>format(volId: string): Promise\<void>;<br>new :<br>format(volumeId: string, fsType: string, callback: AsyncCallback\<void>): void;<br>format(volumeId: string, fsType: string): Promise\<void>; | å˜æ›´ | +| ohos.volumeManager | volumeManager | old :<br>partition(volId: string, fstype: string, callback: AsyncCallback\<void>): void;<br>partition(volId: string, fstype: string): Promise\<void>;<br>new :<br>partition(diskId: string, type: number, callback: AsyncCallback\<void>): void;<br>partition(diskId: string, type: number): Promise\<void>; | å˜æ›´ | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-geolocation.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-geolocation.md new file mode 100644 index 0000000000000000000000000000000000000000..cc1e7691c26454ea153114f8ee2938eb8bac878c --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-geolocation.md @@ -0,0 +1,32 @@ +# ä½ç½®æœåŠ¡å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,ä½ç½®æœåŠ¡å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.geolocation | CountryCodeType | COUNTRY_CODE_FROM_NETWORK | 新增 | +| ohos.geolocation | CountryCodeType | COUNTRY_CODE_FROM_LOCATION | 新增 | +| ohos.geolocation | CountryCodeType | COUNTRY_CODE_FROM_SIM | 新增 | +| ohos.geolocation | CountryCodeType | COUNTRY_CODE_FROM_LOCALE = 1 | 新增 | +| ohos.geolocation | CountryCode | type: CountryCodeType; | 新增 | +| ohos.geolocation | CountryCode | country: string; | 新增 | +| ohos.geolocation | GeoLocationErrorCode | QUERY_COUNTRY_CODE_ERROR | 新增 | +| ohos.geolocation | GeoLocationErrorCode | NOT_SUPPORTED = 100 | 新增 | +| ohos.geolocation | Location | isFromMock: Boolean; | 新增 | +| ohos.geolocation | GeoAddress | isFromMock: Boolean; | 新增 | +| ohos.geolocation | LocationMockConfig | locations: Array\<Location>; | 新增 | +| ohos.geolocation | LocationMockConfig | timeInterval: number; | 新增 | +| ohos.geolocation | ReverseGeocodingMockInfo | geoAddress: GeoAddress; | 新增 | +| ohos.geolocation | ReverseGeocodingMockInfo | location: ReverseGeoCodeRequest; | 新增 | +| ohos.geolocation | geolocation | setReverseGeocodingMockInfo(mockInfos: Array\<ReverseGeocodingMockInfo>, callback: AsyncCallback\<void>) : void;<br>setReverseGeocodingMockInfo(mockInfos: Array\<ReverseGeocodingMockInfo>) : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | disableReverseGeocodingMock(callback: AsyncCallback\<void>) : void;<br>disableReverseGeocodingMock() : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | enableReverseGeocodingMock(callback: AsyncCallback\<void>) : void;<br>enableReverseGeocodingMock() : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | setMockedLocations(config: LocationMockConfig, callback: AsyncCallback\<void>) : void;<br>setMockedLocations(config: LocationMockConfig) : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | disableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback\<void>) : void;<br>disableLocationMock(scenario?: LocationRequestScenario) : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | enableLocationMock(scenario?: LocationRequestScenario, callback: AsyncCallback\<void>) : void;<br>enableLocationMock(scenario?: LocationRequestScenario) : Promise\<void>; | 新增 | +| ohos.geolocation | geolocation | getCountryCode(callback: AsyncCallback\<CountryCode>) : void;<br>getCountryCode() : Promise\<CountryCode>; | 新增 | +| ohos.geolocation | geolocation | off(type: 'countryCodeChange', callback?: Callback\<CountryCode>) : void; | 新增 | +| ohos.geolocation | geolocation | on(type: 'countryCodeChange', callback: Callback\<CountryCode>) : void; | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-global.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-global.md new file mode 100644 index 0000000000000000000000000000000000000000..dad55539edc028b5f849bbdab285cf52d8fc0686 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-global.md @@ -0,0 +1,33 @@ +# å…¨çƒåŒ–å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,全çƒåŒ–å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.EnterpriseAdminExtensionAbility | EnterpriseAdminExtensionAbility | onAdminDisabled(): void; | 新增 | +| ohos.EnterpriseAdminExtensionAbility | EnterpriseAdminExtensionAbility | onAdminEnabled(): void; | 新增 | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void;<br>isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void;<br>isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>; | 新增 | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | disableSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void;<br>disableSuperAdmin(bundleName: String): Promise\<boolean>; | 新增 | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | disableAdmin(admin: Want, callback: AsyncCallback\<boolean>): void;<br>disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void;<br>disableAdmin(admin: Want, userId?: number): Promise\<boolean>; | 新增 | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<boolean>): void;<br>enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<boolean>): void;<br>enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<boolean>; | 新增 | +| ohos.i18n | i18n | getUsingLocalDigit(): boolean; | 新增 | +| ohos.i18n | i18n | setUsingLocalDigit(flag: boolean): boolean; | 新增 | +| ohos.i18n | Transliterator | transform(text: string): string; | 新增 | +| ohos.i18n | Transliterator | static getInstance(id: string): Transliterator; | 新增 | +| ohos.i18n | Transliterator | static getAvailableIDs(): string[]; | 新增 | +| ohos.i18n | TimeZone | static getTimezoneFromCity(cityID: string): TimeZone; | 新增 | +| ohos.i18n | TimeZone | static getCityDisplayName(cityID: string, locale: string): string; | 新增 | +| ohos.i18n | TimeZone | static getAvailableZoneCityIDs(): Array\<string>; | 新增 | +| ohos.i18n | TimeZone | static getAvailableIDs(): Array\<string>; | 新增 | +| ohos.i18n | PhoneNumberFormat | getLocationName(number: string, locale: string): string; | 新增 | +| ohos.i18n | Util | getDateOrder(locale: string): string; | 新增 | +| resource | Resource | id: number; | 新增 | +| resource | Resource | moduleName: string; | 新增 | +| resource | Resource | bundleName: string; | 新增 | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | isAdminAppActive(admin: Want, callback: AsyncCallback\<boolean>): void;<br>isAdminAppActive(admin: Want): Promise\<boolean>; | åˆ é™¤ | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | deactivateSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void;<br>deactivateSuperAdmin(bundleName: String): Promise\<boolean>; | åˆ é™¤ | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | deactivateAdmin(admin: Want, callback: AsyncCallback\<boolean>): void;<br>deactivateAdmin(admin: Want): Promise\<boolean>; | åˆ é™¤ | +| ohos.enterpriseDeviceManager | enterpriseDeviceManager | activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<boolean>): void;<br>activateAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType): Promise\<boolean>; | åˆ é™¤ | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-graphic.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-graphic.md new file mode 100644 index 0000000000000000000000000000000000000000..81fcd04c71a421ebbdcade6726423171d034ea39 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-graphic.md @@ -0,0 +1,20 @@ +# 图形图åƒå系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,图形图åƒå系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.effectKit | effectKit | createColorPicker(source: image.PixelMap): Promise\<ColorPicker>;<br>function createColorPicker(source: image.PixelMap, callback: AsyncCallback\<ColorPicker>): void; | 新增 | +| ohos.effectKit | effectKit | createEffect(source: image.PixelMap): Filter; | 新增 | +| ohos.effectKit | Color | alpha: number; | 新增 | +| ohos.effectKit | Color | blue: number; | 新增 | +| ohos.effectKit | Color | green: number; | 新增 | +| ohos.effectKit | Color | red: number; | 新增 | +| ohos.effectKit | ColorPicker | getMainColorSync(): Color; | 新增 | +| ohos.effectKit | ColorPicker | getMainColor(): Promise\<Color>; | 新增 | +| ohos.effectKit | Filter | getPixelMap(): image.PixelMap; | 新增 | +| ohos.effectKit | Filter | grayscale(): Filter; | 新增 | +| ohos.effectKit | Filter | brightness(bright:number): Filter; | 新增 | +| ohos.effectKit | Filter | blur(radius:number): Filter; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-misc.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-misc.md new file mode 100644 index 0000000000000000000000000000000000000000..3864cc5a9292d4f8013397a50344a721b8f8f3ed --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-misc.md @@ -0,0 +1,10 @@ +# æ‚散软件æœåŠ¡å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,æ‚散软件æœåŠ¡å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | 方法/事件å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.inputmethod | inputMethod | switchInputMethod(target: InputMethodProperty, callback: AsyncCallback\<boolean>): void;<br>switchInputMethod(target: InputMethodProperty): Promise\<boolean>; | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multi-modal-input.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multi-modal-input.md new file mode 100644 index 0000000000000000000000000000000000000000..52418335985f71ab825b3e0c475d9ee028e418cf --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multi-modal-input.md @@ -0,0 +1,10 @@ +# 多模输入å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,多模输入å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.multimodalInput.inputMonitor | inputMonitor | off(type:"mouse", receiver?:Callback\<MouseEvent>):void; | 新增 | +| ohos.multimodalInput.inputMonitor | inputMonitor | on(type:"mouse", receiver:Callback\<MouseEvent>):void; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multimedia.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multimedia.md new file mode 100644 index 0000000000000000000000000000000000000000..829b4213767d943c2c53f038753a9a97accd0226 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-multimedia.md @@ -0,0 +1,67 @@ +# 媒体å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,媒体å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.multimedia.audio | AudioRenderer | setInterruptMode(mode: InterruptMode, callback: AsyncCallback\<void>): void;<br>setInterruptMode(mode: InterruptMode): Promise\<void>; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly channelMasks: Array\<number>; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly channelCounts: Array\<number>; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly sampleRates: Array\<number>; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly address: string; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly name: string; | 新增 | +| ohos.multimedia.audio | AudioDeviceDescriptor | readonly id: number; | 新增 | +| ohos.multimedia.audio | AudioCapturerChangeInfo | readonly deviceDescriptors: AudioDeviceDescriptors; | 新增 | +| ohos.multimedia.audio | AudioCapturerChangeInfo | readonly capturerState: AudioState; | 新增 | +| ohos.multimedia.audio | AudioCapturerChangeInfo | readonly capturerInfo: AudioCapturerInfo; | 新增 | +| ohos.multimedia.audio | AudioCapturerChangeInfo | readonly clientUid: number; | 新增 | +| ohos.multimedia.audio | AudioCapturerChangeInfo | readonly streamId: number; | 新增 | +| ohos.multimedia.audio | AudioRendererChangeInfo | readonly deviceDescriptors: AudioDeviceDescriptors; | 新增 | +| ohos.multimedia.audio | AudioRendererChangeInfo | readonly rendererState: AudioState; | 新增 | +| ohos.multimedia.audio | AudioRendererChangeInfo | readonly rendererInfo: AudioRendererInfo; | 新增 | +| ohos.multimedia.audio | AudioRendererChangeInfo | readonly clientUid: number; | 新增 | +| ohos.multimedia.audio | AudioRendererChangeInfo | readonly streamId: number; | 新增 | +| ohos.multimedia.audio | AudioStreamManager | off(type: "audioCapturerChange"); | 新增 | +| ohos.multimedia.audio | AudioStreamManager | on(type: "audioCapturerChange", callback: Callback\<AudioCapturerChangeInfoArray>): void; | 新增 | +| ohos.multimedia.audio | AudioStreamManager | off(type: "audioRendererChange"); | 新增 | +| ohos.multimedia.audio | AudioStreamManager | on(type: "audioRendererChange", callback: Callback\<AudioRendererChangeInfoArray>): void; | 新增 | +| ohos.multimedia.audio | AudioStreamManager | getCurrentAudioCapturerInfoArray(callback: AsyncCallback\<AudioCapturerChangeInfoArray>): void;<br>getCurrentAudioCapturerInfoArray(): Promise\<AudioCapturerChangeInfoArray>; | 新增 | +| ohos.multimedia.audio | AudioStreamManager | getCurrentAudioRendererInfoArray(callback: AsyncCallback\<AudioRendererChangeInfoArray>): void;<br>getCurrentAudioRendererInfoArray(): Promise\<AudioRendererChangeInfoArray>; | 新增 | +| ohos.multimedia.audio | AudioManager | getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void;<br>getStreamManager(): Promise\<AudioStreamManager>; | 新增 | +| ohos.multimedia.audio | AudioManager | off(type: 'independentInterrupt', callback?: Callback\<InterruptEvent>): void; | 新增 | +| ohos.multimedia.audio | AudioManager | on(type: 'independentInterrupt', callback: Callback\<InterruptEvent>): void; | 新增 | +| ohos.multimedia.audio | AudioManager | abandonIndependentInterrupt(focusType: FocusType, callback: AsyncCallback\<boolean>): void;<br>abandonIndependentInterrupt(focusType: FocusType): Promise\<boolean>; | 新增 | +| ohos.multimedia.audio | AudioManager | requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback\<boolean>): void;<br>requestIndependentInterrupt(focusType: FocusType): Promise\<boolean>; | 新增 | +| ohos.multimedia.audio | InterruptMode | INDEPENDENT_MODE = 1 | 新增 | +| ohos.multimedia.audio | InterruptMode | SHARE_MODE = 0 | 新增 | +| ohos.multimedia.audio | FocusType | FOCUS_TYPE_RECORDING = 0 | 新增 | +| ohos.multimedia.audio | AudioSampleFormat | SAMPLE_FORMAT_F32LE = 4 | 新增 | +| ohos.multimedia.audio | AudioVolumeType | ALL = 100 | 新增 | +| ohos.multimedia.image | PixelMap | crop(region: Region, callback: AsyncCallback\<void>): void;<br>crop(region: Region): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): void;<br>flip(horizontal: boolean, vertical: boolean): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | rotate(angle: number, callback: AsyncCallback\<void>): void;<br>rotate(angle: number): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | translate(x: number, y: number, callback: AsyncCallback\<void>): void;<br>translate(x: number, y: number): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | scale(x: number, y: number, callback: AsyncCallback\<void>): void;<br>scale(x: number, y: number): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | createAlphaPixelmap(): Promise\<PixelMap>;<br>createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void; | 新增 | +| ohos.multimedia.image | PixelMap | opacity(rate: number, callback: AsyncCallback\<void>): void;<br>opacity(rate: number): Promise\<void>; | 新增 | +| ohos.multimedia.image | PixelMap | getDensity():number; | 新增 | +| ohos.multimedia.image | SourceOptions | sourceSize?: Size; | 新增 | +| ohos.multimedia.image | SourceOptions | sourcePixelFormat?: PixelMapFormat; | 新增 | +| ohos.multimedia.image | SourceOptions | sourceDensity: number; | 新增 | +| ohos.multimedia.media | VideoScaleType | VIDEO_SCALE_TYPE_FIT_CROP | 新增 | +| ohos.multimedia.media | VideoScaleType | VIDEO_SCALE_TYPE_FIT = 0 | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'availableBitratesCollected', callback: (bitrates: Array\<number>) => void): void | 新增 | +| ohos.multimedia.media | VideoPlayer | on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | selectBitrate(bitrate: number): Promise\<number>;<br>selectBitrate(bitrate: number, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.multimedia.media | VideoPlayer | videoScaleType ?: VideoScaleType; | 新增 | +| ohos.multimedia.media | VideoPlayer | audioInterruptMode ?: audio.InterruptMode; | 新增 | +| ohos.multimedia.media | VideoPlayer | fdSrc: AVFileDescriptor; | 新增 | +| ohos.multimedia.media | AudioPlayer | on(type: 'audioInterrupt', callback: (info: audio.InterruptEvent) => void): void; | 新增 | +| ohos.multimedia.media | AudioPlayer | audioInterruptMode ?: audio.InterruptMode; | 新增 | +| ohos.multimedia.media | AudioPlayer | fdSrc: AVFileDescriptor; | 新增 | +| ohos.multimedia.media | AVFileDescriptor | length?: number | 新增 | +| ohos.multimedia.media | AVFileDescriptor | offset?: number | 新增 | +| ohos.multimedia.media | AVFileDescriptor | fd: number | 新增 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-resource-scheduler.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-resource-scheduler.md new file mode 100644 index 0000000000000000000000000000000000000000..2d84ced6d3519b3d71c7c9d13dd7e554cdab1a37 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-resource-scheduler.md @@ -0,0 +1,29 @@ +# 资æºè°ƒåº¦å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,资æºè°ƒåº¦å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.bundleState | bundleState | queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback\<Array\<BundleActiveEventState>>): void;<br>queryAppNotificationNumber(begin: number, end: number): Promise\<Array\<BundleActiveEventState>>; | 新增 | +| ohos.bundleState | bundleState | queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback\<Array\<BundleActiveEventState>>): void;<br>queryBundleActiveEventStates(begin: number, end: number): Promise\<Array\<BundleActiveEventState>>; | 新增 | +| ohos.bundleState | bundleState | unRegisterGroupCallBack(callback: AsyncCallback\<void>): void;<br>unRegisterGroupCallBack(): Promise\<void>; | 新增 | +| ohos.bundleState | bundleState | registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>, callback: AsyncCallback\<void>): void;<br>registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>): Promise\<void>; | 新增 | +| ohos.bundleState | bundleState | setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback\<void>): void;<br>setBundleGroup(bundleName: string, newGroup: GroupType): Promise\<void>; | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_NEVER = 60 | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_LIMIT = 50 | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_RARE = 40 | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_FIXED = 30 | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_DAILY = 20 | 新增 | +| ohos.bundleState | GroupType | ACTIVE_GROUP_ALIVE = 10 | 新增 | +| ohos.bundleState | BundleActiveGroupCallbackInfo | bundleName: string; | 新增 | +| ohos.bundleState | BundleActiveGroupCallbackInfo | changeReason: number; | 新增 | +| ohos.bundleState | BundleActiveGroupCallbackInfo | userId: number; | 新增 | +| ohos.bundleState | BundleActiveGroupCallbackInfo | appUsageNewGroup: number; | 新增 | +| ohos.bundleState | BundleActiveGroupCallbackInfo | appUsageOldGroup: number; | 新增 | +| ohos.bundleState | BundleActiveEventState | count: number; | 新增 | +| ohos.bundleState | BundleActiveEventState | eventId: number; | 新增 | +| ohos.bundleState | BundleActiveEventState | name: string; | 新增 | + + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-security.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-security.md new file mode 100644 index 0000000000000000000000000000000000000000..082f64e179f9d95cb947d418670c846ce029a245 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-security.md @@ -0,0 +1,55 @@ +# 安全å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,安全å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.privacyManager | UsedRecordDetail | accessDuration: number; | 新增 | +| ohos.privacyManager | UsedRecordDetail | timestamp: number; | 新增 | +| ohos.privacyManager | UsedRecordDetail | status: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | rejectRecords: Array\<UsedRecordDetail>; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | accessRecords: Array\<UsedRecordDetail>; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | lastAccessDuration: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | lastRejectTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | lastAccessTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | rejectCount: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | accessCount: number; | 新增 | +| ohos.privacyManager | PermissionUsedRecord | permissionName: string; | 新增 | +| ohos.privacyManager | BundleUsedRecord | permissionRecords: Array\<PermissionUsedRecord>; | 新增 | +| ohos.privacyManager | BundleUsedRecord | bundleName: string; | 新增 | +| ohos.privacyManager | BundleUsedRecord | deviceId: string; | 新增 | +| ohos.privacyManager | BundleUsedRecord | isRemote: boolean; | 新增 | +| ohos.privacyManager | BundleUsedRecord | tokenId: number; | 新增 | +| ohos.privacyManager | PermissionUsedResponse | bundleRecords: Array\<BundleUsedRecord>; | 新增 | +| ohos.privacyManager | PermissionUsedResponse | endTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedResponse | beginTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | flag: PermissionUsageFlag; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | endTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | beginTime: number; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | permissionNames: Array\<string>; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | bundleName: string; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | deviceId: string; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | isRemote: boolean; | 新增 | +| ohos.privacyManager | PermissionUsedRequest | tokenId: number; | 新增 | +| ohos.privacyManager | PermissionUsageFlag | FLAG_PERMISSION_USAGE_DETAIL = 1 | 新增 | +| ohos.privacyManager | PermissionUsageFlag | FLAG_PERMISSION_USAGE_SUMMARY = 0 | 新增 | +| ohos.privacyManager | privacyManager | getPermissionUsedRecords(request: PermissionUsedRequest): Promise\<PermissionUsedResponse>;<br>getPermissionUsedRecords(request: PermissionUsedRequest, callback: AsyncCallback\<PermissionUsedResponse>): void; | 新增 | +| ohos.privacyManager | privacyManager | addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number): Promise\<number>;<br>addPermissionUsedRecord(tokenID: number, permissionName: string, successCount: number, failCount: number, callback: AsyncCallback\<number>): void; | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_UNWRAP_ALGORITHM_SUITE = HuksTagType.HUKS_TAG_TYPE_UINT \| 26 | 新增 | +| ohos.security.huks | HuksTag | HUKS_TAG_IMPORT_KEY_TYPE = HuksTagType.HUKS_TAG_TYPE_UINT \| 25 | 新增 | +| ohos.security.huks | HuksImportKeyType | HUKS_KEY_TYPE_KEY_PAIR = 2 | 新增 | +| ohos.security.huks | HuksImportKeyType | HUKS_KEY_TYPE_PRIVATE_KEY = 1 | 新增 | +| ohos.security.huks | HuksImportKeyType | HUKS_KEY_TYPE_PUBLIC_KEY = 0 | 新增 | +| ohos.security.huks | HuksUnwrapSuite | HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2 | 新增 | +| ohos.security.huks | HuksUnwrapSuite | HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_SM4 = 152 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_SM3 = 151 | 新增 | +| ohos.security.huks | HuksKeyAlg | HUKS_ALG_SM2 = 150 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_SM4_KEY_SIZE_128 = 128 | 新增 | +| ohos.security.huks | HuksKeySize | HUKS_SM2_KEY_SIZE_256 = 256 | 新增 | +| ohos.security.huks | HuksKeyDigest | HUKS_DIGEST_SM3 = 2 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_USAGE_OF_KEY = -127 | 新增 | +| ohos.security.huks | HuksErrorCode | HUKS_ERROR_INVALID_WRAPPED_FORMAT = -126 | 新增 | +| ohos.security.huks | huks | importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void;<br>importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise\<HuksResult>; | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-sensor.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-sensor.md new file mode 100644 index 0000000000000000000000000000000000000000..e2a16af8a470e34b6e1dafe7dd332391576cb4b8 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-sensor.md @@ -0,0 +1,22 @@ +# æ³›Sensorå系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,泛Sensorå系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.sensor | SensorType | SENSOR_TYPE_ID_HEART_BEAT_RATE = 278 | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_LINEAR_ACCELEROMETER = 258 | 新增 | +| ohos.sensor | sensor | getSensorLists(callback: AsyncCallback\<Array\<Sensor>>): void;<br>getSensorLists(): Promise\<Array\<Sensor>>; | 新增 | +| ohos.sensor | sensor | getSingleSensor(type: SensorType, callback: AsyncCallback\<Sensor>): void;<br>getSingleSensor(type: SensorType): Promise\<Sensor>; | 新增 | +| ohos.sensor | Sensor | power:number; | 新增 | +| ohos.sensor | Sensor | precision:number; | 新增 | +| ohos.sensor | Sensor | maxRange:number; | 新增 | +| ohos.sensor | Sensor | sensorTypeId:number; | 新增 | +| ohos.sensor | Sensor | hardwareVersion:string; | 新增 | +| ohos.sensor | Sensor | firmwareVersion:string; | 新增 | +| ohos.sensor | Sensor | venderName:string; | 新增 | +| ohos.sensor | Sensor | sensorName:string; | 新增 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_HEART_RATE = 278 | 废弃 | +| ohos.sensor | SensorType | SENSOR_TYPE_ID_LINEAR_ACCELERATION = 258 | 废弃 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-soft-bus.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-soft-bus.md new file mode 100644 index 0000000000000000000000000000000000000000..17e2996e6520b16c00f435a5a55437d158e1de5d --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-soft-bus.md @@ -0,0 +1,11 @@ +# 分布å¼è½¯æ€»çº¿å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,分布å¼è½¯æ€»çº¿å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.rpc | RemoteProxy | sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise\<SendRequestResult>; | 新增 | +| ohos.rpc | RemoteObject | sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise\<SendRequestResult>; | 新增 | +| ohos.rpc | IRemoteObject | sendRequestAsync(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise\<SendRequestResult>; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-unitest.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-unitest.md new file mode 100644 index 0000000000000000000000000000000000000000..90cffeb3f8b1d07f4a7bbcdbe2da72c31e5eb4b6 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-unitest.md @@ -0,0 +1,50 @@ +# 测试框架å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,测试框架å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.uitest | UiWindow | close():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | resume():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | minimize():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | maximize():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | split():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | resize(wide: number, height: number, direction: ResizeDirection):Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | moveTo(x: number, y: number):Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | focus():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | isActived():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | isFocused():Promise\<bool>; | 新增 | +| ohos.uitest | UiWindow | getWindowMode():Promise\<WindowMode>; | 新增 | +| ohos.uitest | UiWindow | getTitle():Promise\<string>; | 新增 | +| ohos.uitest | UiWindow | getBounds():Promise\<Rect>; | 新增 | +| ohos.uitest | UiWindow | getBundleName():Promise\<string>; | 新增 | +| ohos.uitest | UiDriver | triggerCombineKeys(key0: number, key1: number, key2?: number): Promise\<void>; | 新增 | +| ohos.uitest | UiDriver | findWindow(filter:WindowFilter):Promise\<UiWindow>; | 新增 | +| ohos.uitest | UiComponent | pinchIn(scale: number): Promise\<void>; | 新增 | +| ohos.uitest | UiComponent | pinchOut(scale: number): Promise\<void>; | 新增 | +| ohos.uitest | UiComponent | getBoundsCenter(): Promise\<Point>; | 新增 | +| ohos.uitest | WindowFilter | readonly actived?: bool; | 新增 | +| ohos.uitest | WindowFilter | readonly focused?: bool; | 新增 | +| ohos.uitest | WindowFilter | readonly title?: string; | 新增 | +| ohos.uitest | WindowFilter | readonly bundleName?: string; | 新增 | +| ohos.uitest | Point | readonly Y: number; | 新增 | +| ohos.uitest | Point | readonly X: number; | 新增 | +| ohos.uitest | WindowMode | FLOATING | 新增 | +| ohos.uitest | WindowMode | SECONDARY | 新增 | +| ohos.uitest | WindowMode | PRIMARY | 新增 | +| ohos.uitest | WindowMode | FULLSCREEN | 新增 | +| ohos.uitest | ResizeDirection | RIGHT_DOWN | 新增 | +| ohos.uitest | ResizeDirection | RIGHT_UP | 新增 | +| ohos.uitest | ResizeDirection | LEFT_DOWN | 新增 | +| ohos.uitest | ResizeDirection | LEFT_UP | 新增 | +| ohos.uitest | ResizeDirection | DOWN | 新增 | +| ohos.uitest | ResizeDirection | UP | 新增 | +| ohos.uitest | ResizeDirection | RIGHT | 新增 | +| ohos.uitest | ResizeDirection | LEFT | 新增 | +| ohos.uitest | UiDriver | swipe(startx:number,starty:number,endx:number,endy:number):Promise\<void>; | 废弃 | +| ohos.uitest | UiDriver |old : drag(startx: number, starty: number, endx: number, endy: number): Promise\<void>;<br>new : drag(startx: number, starty: number, endx: number, endy: number, speed?: number): Promise\<void>;| å˜æ›´ | +| ohos.uitest | UiComponent |old : scrollToBottom(): Promise\<void>;<br>new : scrollToTop(speed?: number): Promise\<void>;| å˜æ›´ | +| ohos.uitest | UiComponent |old : scrollToTop(): Promise\<void>;<br>new : scrollToTop(speed?: number): Promise\<void>; | å˜æ›´ | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-update.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-update.md new file mode 100644 index 0000000000000000000000000000000000000000..7cbb4007169b963dfefc277b5d8a386b1ba54529 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-update.md @@ -0,0 +1,183 @@ +# å‡çº§æœåŠ¡å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,å‡çº§æœåŠ¡å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.update | EventId | EVENT_UPGRADE_FAIL | 新增 | +| ohos.update | EventId | EVENT_UPGRADE_SUCCESS | 新增 | +| ohos.update | EventId | EVENT_APPLY_START | 新增 | +| ohos.update | EventId | EVENT_APPLY_WAIT | 新增 | +| ohos.update | EventId | EVENT_UPGRADE_UPDATE | 新增 | +| ohos.update | EventId | EVENT_UPGRADE_START | 新增 | +| ohos.update | EventId | EVENT_UPGRADE_WAIT | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_FAIL | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_SUCCESS | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_RESUME | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_PAUSE | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_UPDATE | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_START | 新增 | +| ohos.update | EventId | EVENT_DOWNLOAD_WAIT | 新增 | +| ohos.update | EventId | EVENT_TASK_CANCEL | 新增 | +| ohos.update | EventId | EVENT_TASK_RECEIVE | 新增 | +| ohos.update | EventId | EVENT_TASK_BASE = EventClassify.TASK | 新增 | +| ohos.update | EventClassify | TASK = 0x01000000 | 新增 | +| ohos.update | UpgradeStatus | UPGRADE_FAIL = 51 | 新增 | +| ohos.update | UpgradeStatus | UPGRADE_SUCCESS = 50 | 新增 | +| ohos.update | UpgradeStatus | APPLYING = 41 | 新增 | +| ohos.update | UpgradeStatus | WAITING_APPLY = 40 | 新增 | +| ohos.update | UpgradeStatus | UPDATING = 31 | 新增 | +| ohos.update | UpgradeStatus | WAITING_INSTALL = 30 | 新增 | +| ohos.update | UpgradeStatus | DOWNLOAD_FAIL = 23 | 新增 | +| ohos.update | UpgradeStatus | DOWNLOAD_PAUSED = 22 | 新增 | +| ohos.update | UpgradeStatus | DOWNLOADING = 21 | 新增 | +| ohos.update | UpgradeStatus | WAITING_DOWNLOAD = 20 | 新增 | +| ohos.update | Order | APPLY = 4 | 新增 | +| ohos.update | Order | INSTALL = 2 | 新增 | +| ohos.update | Order | DOWNLOAD = 1 | 新增 | +| ohos.update | NetType | NOT_METERED_WIFI = 4 | 新增 | +| ohos.update | NetType | METERED_WIFI = 2 | 新增 | +| ohos.update | NetType | CELLULAR = 1 | 新增 | +| ohos.update | DescriptionType | URI = 1 | 新增 | +| ohos.update | DescriptionType | CONTENT = 0 | 新增 | +| ohos.update | EffectiveMode | LIVE_AND_COLD = 3 | 新增 | +| ohos.update | EffectiveMode | LIVE = 2 | 新增 | +| ohos.update | EffectiveMode | COLD = 1 | 新增 | +| ohos.update | UpgradeAction | RECOVERY = "recovery" | 新增 | +| ohos.update | UpgradeAction | UPGRADE = "upgrade" | 新增 | +| ohos.update | ComponentType | OTA = 1 | 新增 | +| ohos.update | BusinessSubType | PARAM = 2 | 新增 | +| ohos.update | BusinessSubType | FIRMWARE = 1 | 新增 | +| ohos.update | BusinessVendor | PUBLIC = "public" | 新增 | +| ohos.update | UpgradeTaskCallback | (eventInfo: EventInfo): void; | 新增 | +| ohos.update | UpgradeFile | filePath: string; | 新增 | +| ohos.update | UpgradeFile | fileType: ComponentType; | 新增 | +| ohos.update | EventClassifyInfo | extraInfo: string; | 新增 | +| ohos.update | EventClassifyInfo | eventClassify: EventClassify; | 新增 | +| ohos.update | ErrorMessage | errorMessage: string; | 新增 | +| ohos.update | ErrorMessage | errorCode: number; | 新增 | +| ohos.update | TaskBody | versionComponents: Array\<VersionComponent>; | 新增 | +| ohos.update | TaskBody | errorMessages: Array\<ErrorMessage>; | 新增 | +| ohos.update | TaskBody | installMode: number; | 新增 | +| ohos.update | TaskBody | progress: number; | 新增 | +| ohos.update | TaskBody | subStatus: number; | 新增 | +| ohos.update | TaskBody | status: UpgradeStatus; | 新增 | +| ohos.update | TaskBody | versionDigestInfo: VersionDigestInfo; | 新增 | +| ohos.update | EventInfo | taskBody: TaskBody; | 新增 | +| ohos.update | EventInfo | eventId: EventId; | 新增 | +| ohos.update | TaskInfo | taskBody: TaskBody; | 新增 | +| ohos.update | TaskInfo | existTask: boolean; | 新增 | +| ohos.update | UpgradePeriod | end: number; | 新增 | +| ohos.update | UpgradePeriod | start: number; | 新增 | +| ohos.update | UpgradePolicy | autoUpgradePeriods: Array\<UpgradePeriod>; | 新增 | +| ohos.update | UpgradePolicy | autoUpgradeStrategy: boolean; | 新增 | +| ohos.update | UpgradePolicy | downloadStrategy: boolean; | 新增 | +| ohos.update | ClearOptions | status: UpgradeStatus; | 新增 | +| ohos.update | UpgradeOptions | order: Order; | 新增 | +| ohos.update | PauseDownloadOptions | isAllowAutoResume: boolean; | 新增 | +| ohos.update | ResumeDownloadOptions | allowNetwork: NetType; | 新增 | +| ohos.update | DownloadOptions | order: Order; | 新增 | +| ohos.update | DownloadOptions | allowNetwork: NetType; | 新增 | +| ohos.update | CurrentVersionInfo | versionComponents: Array\<VersionComponent>; | 新增 | +| ohos.update | CurrentVersionInfo | deviceName: string; | 新增 | +| ohos.update | CurrentVersionInfo | osVersion: string; | 新增 | +| ohos.update | DescriptionInfo | descriptionType: DescriptionType; | 新增 | +| ohos.update | VersionComponent | descriptionInfo: DescriptionInfo; | 新增 | +| ohos.update | VersionComponent | effectiveMode: EffectiveMode; | 新增 | +| ohos.update | VersionComponent | size: number; | 新增 | +| ohos.update | VersionComponent | innerVersion: string; | 新增 | +| ohos.update | VersionComponent | displayVersion: string; | 新增 | +| ohos.update | VersionComponent | upgradeAction: UpgradeAction; | 新增 | +| ohos.update | VersionComponent | componentType: ComponentType; | 新增 | +| ohos.update | VersionDigestInfo | versionDigest: string; | 新增 | +| ohos.update | NewVersionInfo | versionComponents: Array\<VersionComponent>; | 新增 | +| ohos.update | NewVersionInfo | versionDigestInfo: VersionDigestInfo; | 新增 | +| ohos.update | CheckResult | newVersionInfo: NewVersionInfo; | 新增 | +| ohos.update | CheckResult | isExistNewVersion: boolean; | 新增 | +| ohos.update | BusinessType | subType: BusinessSubType; | 新增 | +| ohos.update | BusinessType | vendor: BusinessVendor; | 新增 | +| ohos.update | UpgradeInfo | businessType: BusinessType; | 新增 | +| ohos.update | UpgradeInfo | upgradeApp: string; | 新增 | +| ohos.update | LocalUpdater | off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void; | 新增 | +| ohos.update | LocalUpdater | on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void; | 新增 | +| ohos.update | LocalUpdater | applyNewVersion(upgradeFiles: Array\<UpgradeFile>, callback: AsyncCallback\<void>): void;<br>applyNewVersion(upgradeFiles: Array\<UpgradeFile>): Promise\<void>; | 新增 | +| ohos.update | LocalUpdater | verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: AsyncCallback\<number>): void;<br>verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\<number>; | 新增 | +| ohos.update | Restorer | factoryReset(callback: AsyncCallback\<void>): void;<br>factoryReset(): Promise\<void>; | 新增 | +| ohos.update | Updater | off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): void; | 新增 | +| ohos.update | Updater | on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): void; | 新增 | +| ohos.update | Updater | terminateUpgrade(callback: AsyncCallback\<void>): void;<br>terminateUpgrade(): Promise\<void>; | 新增 | +| ohos.update | Updater | setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\<number>): void;<br>setUpgradePolicy(policy: UpgradePolicy): Promise\<number>; | 新增 | +| ohos.update | Updater | getUpgradePolicy(callback: AsyncCallback\<UpgradePolicy>): void;<br>getUpgradePolicy(): Promise\<UpgradePolicy>; | 新增 | +| ohos.update | Updater | clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, callback: AsyncCallback\<void>): void;<br>clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Promise\<void>; | 新增 | +| ohos.update | Updater | pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions, callback: AsyncCallback\<void>): void;<br>pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseDownloadOptions): Promise\<void>; | 新增 | +| ohos.update | Updater | resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions, callback: AsyncCallback\<void>): void;<br>resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: ResumeDownloadOptions): Promise\<void>; | 新增 | +| ohos.update | Updater | getTaskInfo(callback: AsyncCallback\<TaskInfo>): void;<br>getTaskInfo(): Promise\<TaskInfo>; | 新增 | +| ohos.update | Updater | getCurrentVersionInfo(callback: AsyncCallback\<CurrentVersionInfo>): void;<br>getCurrentVersionInfo(): Promise\<CurrentVersionInfo>; | 新增 | +| ohos.update | update | getLocalUpdater(): LocalUpdater; | 新增 | +| ohos.update | update | getRestorer(): Restorer; | 新增 | +| ohos.update | update | getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater; | 新增 | +| ohos.update | update | getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater; | åˆ é™¤ | +| ohos.update | update | getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater; | åˆ é™¤ | +| ohos.update | update | getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater; | åˆ é™¤ | +| ohos.update | Updater | cancel(): void; | åˆ é™¤ | +| ohos.update | Updater | verifyUpdatePackage(upgradeFile: string, certsFile: string): void; | åˆ é™¤ | +| ohos.update | Updater | rebootAndCleanUserData(callback: AsyncCallback\<number>): void;<br>rebootAndCleanUserData(): Promise\<number>; | åˆ é™¤ | +| ohos.update | Updater | rebootAndCleanCache(callback: AsyncCallback\<number>): void;<br>rebootAndCleanCache(): Promise\<number>; | åˆ é™¤ | +| ohos.update | Updater | applyNewVersion(callback: AsyncCallback\<number>): void;<br>applyNewVersion(): Promise\<number>; | åˆ é™¤ | +| ohos.update | Updater | setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void;<br>setUpdatePolicy(policy: UpdatePolicy): Promise\<number>; | åˆ é™¤ | +| ohos.update | Updater | getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void;<br>getUpdatePolicy(): Promise\<UpdatePolicy>; | åˆ é™¤ | +| ohos.update | UpdateProgressCallback | (progress: Progress): void; | åˆ é™¤ | +| ohos.update | UpdatePolicy | autoUpgradeInterval: Array\<number>; | åˆ é™¤ | +| ohos.update | UpdatePolicy | installMode: INSTALL_MODE; | åˆ é™¤ | +| ohos.update | UpdatePolicy | autoDownload: boolean; | åˆ é™¤ | +| ohos.update | InstallMode | INSTALL_MODE_AUTO | åˆ é™¤ | +| ohos.update | InstallMode | INSTALL_MODE_NIGHT | åˆ é™¤ | +| ohos.update | InstallMode | INSTALL_MODE_NORMAL | åˆ é™¤ | +| ohos.update | Progress | endReason: string; | åˆ é™¤ | +| ohos.update | Progress | status: UpdateState; | åˆ é™¤ | +| ohos.update | Progress | percent: number; | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_UPDATE_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_UPDATE_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_UPDATE_ON = 90 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_INSTALL_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_INSTALL_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_INSTALL_ON = 80 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_PACKAGE_TRANS_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_PACKAGE_TRANS_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_PACKAGE_TRANS_ON = 70 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_VERIFY_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_VERIFY_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_VERIFY_ON = 30 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_DOWNLOAD_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_DOWNLOAD_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_DOWNLOAD_CANCEL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_DOWNLOAD_PAUSE | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_DOWNLOAD_ON = 20 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_CHECK_VERSION_SUCCESS | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_CHECK_VERSION_FAIL | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_CHECK_VERSION_ON = 10 | åˆ é™¤ | +| ohos.update | UpdateState | UPDATE_STATE_INIT = 0 | åˆ é™¤ | +| ohos.update | NewVersionInfo | descriptionInfo: Array\<DescriptionInfo>; | åˆ é™¤ | +| ohos.update | NewVersionInfo | checkResults: Array\<CheckResult>; | åˆ é™¤ | +| ohos.update | NewVersionInfo | errMsg: string; | åˆ é™¤ | +| ohos.update | NewVersionInfo | status: NewVersionStatus; | åˆ é™¤ | +| ohos.update | NewVersionStatus | VERSION_STATUS_BUSY = 2 | åˆ é™¤ | +| ohos.update | NewVersionStatus | VERSION_STATUS_NONE = 1 | åˆ é™¤ | +| ohos.update | NewVersionStatus | VERSION_STATUS_NEW = 0 | åˆ é™¤ | +| ohos.update | NewVersionStatus | VERSION_STATUS_ERR = -1 | åˆ é™¤ | +| ohos.update | DescriptionInfo | descriptionId: string; | åˆ é™¤ | +| ohos.update | CheckResult | descriptionId: string; | åˆ é™¤ | +| ohos.update | CheckResult | packageType: PackageTypes; | åˆ é™¤ | +| ohos.update | CheckResult | verifyInfo: string; | åˆ é™¤ | +| ohos.update | CheckResult | size: number; | åˆ é™¤ | +| ohos.update | CheckResult | versionCode: string; | åˆ é™¤ | +| ohos.update | CheckResult | versionName: number; | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_PATCH = 7 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_VERSION = 6 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_COTA = 5 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_PRELOAD = 4 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_CUST = 3 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_BASE = 2 | åˆ é™¤ | +| ohos.update | PackageTypes | PACKAGE_TYPE_NORMAL = 1 | åˆ é™¤ | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-usb.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-usb.md new file mode 100644 index 0000000000000000000000000000000000000000..eb54f06a9f1ef0c0d20fb15d5b6c3627c8eb87c9 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-usb.md @@ -0,0 +1,42 @@ +# USBæœåŠ¡å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,USBæœåŠ¡å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.usb | FunctionType | NCM = 256 | 新增 | +| ohos.usb | FunctionType | AUDIO_SOURCE = 128 | 新增 | +| ohos.usb | FunctionType | MIDI = 64 | 新增 | +| ohos.usb | FunctionType | RNDIS = 32 | 新增 | +| ohos.usb | FunctionType | PTP = 16 | 新增 | +| ohos.usb | FunctionType | MTP = 8 | 新增 | +| ohos.usb | FunctionType | HDC = 4 | 新增 | +| ohos.usb | FunctionType | ECM = 2 | 新增 | +| ohos.usb | FunctionType | ACM = 1 | 新增 | +| ohos.usb | FunctionType | NONE = 0 | 新增 | +| ohos.usb | USBPort | status: USBPortStatus; | 新增 | +| ohos.usb | USBPort | supportedModes: PortModeType; | 新增 | +| ohos.usb | USBPort | id: number; | 新增 | +| ohos.usb | USBPortStatus | currentDataRole: number; | 新增 | +| ohos.usb | USBPortStatus | currentPowerRole: number; | 新增 | +| ohos.usb | USBPortStatus | currentMode: number; | 新增 | +| ohos.usb | PortModeType | NUM_MODES = 4 | 新增 | +| ohos.usb | PortModeType | DRP = 3 | 新增 | +| ohos.usb | PortModeType | DFP = 2 | 新增 | +| ohos.usb | PortModeType | UFP = 1 | 新增 | +| ohos.usb | PortModeType | NONE = 0 | 新增 | +| ohos.usb | DataRoleType | DEVICE = 2 | 新增 | +| ohos.usb | DataRoleType | HOST = 1 | 新增 | +| ohos.usb | DataRoleType | NONE = 0 | 新增 | +| ohos.usb | PowerRoleType | SINK = 2 | 新增 | +| ohos.usb | PowerRoleType | SOURCE = 1 | 新增 | +| ohos.usb | PowerRoleType | NONE = 0 | 新增 | +| ohos.usb | usb | setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\<boolean>; | 新增 | +| ohos.usb | usb | getSupportedModes(portId: number): PortModeType; | 新增 | +| ohos.usb | usb | getPorts(): Array\<USBPort>; | 新增 | +| ohos.usb | usb | getCurrentFunctions(): FunctionType; | 新增 | +| ohos.usb | usb | setCurrentFunctions(funcs: FunctionType): Promise\<boolean>; | 新增 | +| ohos.usb | usb | usbFunctionsToString(funcs: FunctionType): string; | 新增 | +| ohos.usb | usb | usbFunctionsFromString(funcs: string): number; | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-user-authentication.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-user-authentication.md new file mode 100644 index 0000000000000000000000000000000000000000..76447fdcdbe79b1ff287d94cbb3727758dd3f197 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-user-authentication.md @@ -0,0 +1,12 @@ +# 用户身份认è¯å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Release版本相较于OpenHarmony 3.2 Beta1版本,用户身份认è¯å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.userIAM.faceAuth | ResultCode | FAIL = 1 | 新增 | +| ohos.userIAM.faceAuth | ResultCode | SUCCESS = 0 | 新增 | +| ohos.userIAM.faceAuth | FaceAuthManager | setSurfaceId(surfaceId: string): ResultCode; | 新增 | +| ohos.userIAM.faceAuth | FaceAuthManager | constructor(); | 新增 | diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-web.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-web.md new file mode 100644 index 0000000000000000000000000000000000000000..7f9cc35433534d1607e28312b4a0973c9968a7d0 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-web.md @@ -0,0 +1,40 @@ +# Webå系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,Webå系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 函数 | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.web | WebDataBase | static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; | 新增 | +| ohos.web | WebDataBase | static getHttpAuthCredentials(host: string, realm: string): Array\<string>; | 新增 | +| ohos.web | WebDataBase | static deleteHttpAuthCredentials(): void; | 新增 | +| ohos.web | WebDataBase | static existHttpAuthCredentials(): boolean; | 新增 | +| ohos.web | WebStorage | static getOriginUsage(origin : string) : Promise\<number> ;<br>static getOriginUsage(origin : string, callback : AsyncCallback\<number>) : void; | 新增 | +| ohos.web | WebStorage | static getOriginQuota(origin : string) : Promise\<number>;<br>static getOriginQuota(origin : string, callback : AsyncCallback\<number>) : void; | 新增 | +| ohos.web | WebStorage | static getOrigins() : Promise\<Array\<WebStorageOrigin>>;<br>static getOrigins(callback: AsyncCallback\<Array\<WebStorageOrigin>>) : void; | 新增 | +| ohos.web | WebStorage | static deleteOrigin(origin : string): void; | 新增 | +| ohos.web | WebStorage | static deleteAllData() : void; | 新增 | +| ohos.web | WebStorageOrigin | quota: number; | 新增 | +| ohos.web | WebStorageOrigin | usage: number; | 新增 | +| ohos.web | WebStorageOrigin | origin: string; | 新增 | +| Web | WebAttribute | onInterceptRequest(callback: (event?: { request: WebResourceRequest}) => WebResourceResponse): WebAttribute; | 新增 | +| Web | WebAttribute | onHttpAuthRequest(callback: (event?: { handler: HttpAuthHandler, host: string, realm: string }) => boolean): WebAttribute; | 新增 | +| Web | WebAttribute | onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void): WebAttribute; | 新增 | +| Web | WebAttribute | onResourceLoad(callback: (event: {url: string}) => void): WebAttribute; | 新增 | +| Web | WebAttribute | onPrompt(callback: (event?: {url: string, message: string, value: string, result: JsResult }) => boolean): WebAttribute; | 新增 | +| Web | WebAttribute | initialScale(percent: number): WebAttribute; | 新增 | +| Web | WebController | backOrForward(step: number): void; | 新增 | +| Web | WebController | getPageHeight(): number; | 新增 | +| Web | WebController | getTitle(): string; | 新增 | +| Web | WebController | getDefaultUserAgent(): string; | 新增 | +| Web | WebController | getWebId(): number; | 新增 | +| Web | WebController | getHitTestValue(): HitTestValue; | 新增 | +| Web | WebController | zoomOut(): boolean; | 新增 | +| Web | WebController | zoomIn(): boolean; | 新增 | +| Web | WebResourceResponse | setResponseCode(code: number); | 新增 | +| Web | WebResourceResponse | setResponseHeader(header: Array\<Header>); | 新增 | +| Web | WebResourceResponse | setReasonMessage(reason: string); | 新增 | +| Web | WebResourceResponse | setResponseMimeType(mimeType: string); | 新增 | +| Web | WebResourceResponse | setResponseEncoding(encoding: string); | 新增 | +| Web | WebResourceResponse | setResponseData(data: string); | 新增 | \ No newline at end of file diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-window.md b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-window.md new file mode 100644 index 0000000000000000000000000000000000000000..763b558ce1fb0e0f97bcfedb8d35ef5d4d0b1513 --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/js-apidiff-window.md @@ -0,0 +1,77 @@ +# 窗å£ç®¡ç†å系统JS APIå˜æ›´ + +OpenHarmony 3.2 Beta2版本相较于OpenHarmony 3.2 Beta1版本,窗å£ç®¡ç†å系统的APIå˜æ›´å¦‚下: + +## 接å£å˜æ›´ + +| 模å—å | ç±»å | 方法/属性/枚举/å¸¸é‡ | å˜æ›´ç±»åž‹ | +|---|---|---|---| +| ohos.animation.windowAnimationManager | WindowAnimationController | onScreenUnlock(finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onCloseWindow(closingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onMinimizeWindow(minimizingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onAppTransition(fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onStartAppFromOther(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onStartAppFromRecent(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationController | onStartAppFromLauncher(startingWindowTarget: WindowAnimationTarget, finishCallback: WindowAnimationFinishedCallback): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationFinishedCallback | onAnimationFinish(): void; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationTarget | readonly windowBounds: RRect; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationTarget | readonly abilityName: string; | 新增 | +| ohos.animation.windowAnimationManager | WindowAnimationTarget | readonly bundleName: string; | 新增 | +| ohos.animation.windowAnimationManager | RRect | radius: number; | 新增 | +| ohos.animation.windowAnimationManager | RRect | height: number; | 新增 | +| ohos.animation.windowAnimationManager | RRect | width: number; | 新增 | +| ohos.animation.windowAnimationManager | RRect | top: number; | 新增 | +| ohos.animation.windowAnimationManager | RRect | left: number; | 新增 | +| ohos.animation.windowAnimationManager | windowAnimationManager | setController(controller: WindowAnimationController): void; | 新增 | +| ohos.display | display | getDefaultDisplaySync(): Display; | 新增 | +| ohos.screen | Screen | setDensityDpi(densityDpi: number, callback: AsyncCallback\<void>): void;<br>setDensityDpi(densityDpi: number): Promise\<void>; | 新增 | +| ohos.screen | VirtualScreenOption | surfaceId: string | 新增 | +| ohos.screen | VirtualScreenOption | density: number | 新增 | +| ohos.screen | VirtualScreenOption | height: number | 新增 | +| ohos.screen | VirtualScreenOption | width: number | 新增 | +| ohos.screen | VirtualScreenOption | name: string | 新增 | +| ohos.screen | screen | setScreenRotationLocked(isLocked:boolean, callback: AsyncCallback\<void>): void;<br>setScreenRotationLocked(isLocked:boolean): Promise\<void>; | 新增 | +| ohos.screen | screen | isScreenRotationLocked(callback: AsyncCallback\<boolean>): void;<br>isScreenRotationLocked(): Promise\<boolean>; | 新增 | +| ohos.screen | screen | setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback\<void>): void;<br>setVirtualScreenSurface(screenId:number, surfaceId: string): Promise\<void>; | 新增 | +| ohos.screen | screen | destroyVirtualScreen(screenId:number, callback: AsyncCallback\<void>): void;<br>destroyVirtualScreen(screenId:number): Promise\<void>; | 新增 | +| ohos.screen | screen | createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback\<Screen>): void;<br>createVirtualScreen(options:VirtualScreenOption): Promise\<Screen>; | 新增 | +| ohos.window | WindowStage | setShowOnLockScreen(showOnLockScreen: boolean): void; | 新增 | +| ohos.window | WindowStage | disableWindowDecor(): void; | 新增 | +| ohos.window | Window | setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback\<void>): void;<br>setForbidSplitMove(isForbidSplitMove: boolean): Promise\<void>; | 新增 | +| ohos.window | Window | off(type: 'touchOutside', callback?: Callback\<void>): void; | 新增 | +| ohos.window | Window | on(type: 'touchOutside', callback: Callback\<void>): void; | 新增 | +| ohos.window | Window | off(type: 'avoidAreaChange', callback?: Callback\<{ type: AvoidAreaType, area: AvoidArea }>): void; | 新增 | +| ohos.window | Window | on(type: 'avoidAreaChange', callback: Callback\<{ type: AvoidAreaType, area: AvoidArea }>): void; | 新增 | +| ohos.window | Window | setPreferredOrientation(orientation: Orientation): Promise\<void>;<br>setPreferredOrientation(orientation: Orientation, callback: AsyncCallback\<void>): void; | 新增 | +| ohos.window | Orientation | LOCKED = 11 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION_PORTRAIT_RESTRICTED = 9 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION_RESTRICTED = 8 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION_LANDSCAPE = 7 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION_PORTRAIT = 6 | 新增 | +| ohos.window | Orientation | AUTO_ROTATION = 5 | 新增 | +| ohos.window | Orientation | LANDSCAPE_INVERTED = 4 | 新增 | +| ohos.window | Orientation | PORTRAIT_INVERTED = 3 | 新增 | +| ohos.window | Orientation | LANDSCAPE = 2 | 新增 | +| ohos.window | Orientation | PORTRAIT = 1 | 新增 | +| ohos.window | Orientation | UNSPECIFIED = 0 | 新增 | +| ohos.window | AvoidArea | visible: boolean; | 新增 | +| ohos.window | AvoidAreaType | TYPE_KEYBOARD | 新增 | +| ohos.window | AvoidAreaType | TYPE_SYSTEM_GESTURE | 新增 | +| ohos.window | WindowType | TYPE_POINTER | 新增 | +| ohos.window | WindowType | TYPE_VOICE_INTERACTION | 新增 | +| ohos.window | WindowType | TYPE_LAUNCHER_DOCK | 新增 | +| ohos.window | WindowType | TYPE_LAUNCHER_RECENT | 新增 | +| ohos.window | WindowType | TYPE_DESKTOP | 新增 | +| ohos.window | WindowType | TYPE_WALLPAPER | 新增 | +| ohos.window | WindowType | TYPE_FLOAT | 新增 | +| ohos.window | WindowType | TYPE_NAVIGATION_BAR | 新增 | +| ohos.window | WindowType | TYPE_VOLUME_OVERLAY | 新增 | +| ohos.window | WindowType | TYPE_KEYGUARD | 新增 | +| ohos.window | WindowType | TYPE_PANEL | 新增 | +| ohos.window | WindowType | TYPE_STATUS_BAR | 新增 | +| ohos.window | WindowType | TYPE_INPUT_METHOD | 新增 | +| ohos.window | Window | dump(params: Array\<string>): Array\<string>; | åˆ é™¤ | +| ohos.window | Window | off(type: 'systemAvoidAreaChange', callback?: Callback\<AvoidArea>): void; | 废弃 | +| ohos.window | Window | on(type: 'systemAvoidAreaChange', callback: Callback\<AvoidArea>): void; | 废弃 | + diff --git a/zh-cn/release-notes/api-change/v3.2-beta2/native-apidiff-v3.2-beta2.md b/zh-cn/release-notes/api-change/v3.2-beta2/native-apidiff-v3.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..b8e6c8a45ece7f1c7b9ea6d3c58297678af3a17d --- /dev/null +++ b/zh-cn/release-notes/api-change/v3.2-beta2/native-apidiff-v3.2-beta2.md @@ -0,0 +1,13 @@ +# Native API 差异报告 + +OpenHarmony 3.2 Beta2相较于OpenHarmony 3.2 Beta1版本的APIå˜æ›´å¦‚下: + +## æ ‡å‡†ç³»ç»ŸæŽ¥å£å˜æ›´ + +| 模å—å称 | 接å£å称 | å˜æ›´ç±»åž‹ | å˜æ›´è¯´æ˜Ž | +| -------- | ------------------------------------------------------------ | -------- | ----------------------------------------------- | +| 包管ç†-BundleFramework | OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo() | 新增 | 获å–当å‰åº”用的包åå’ŒæŒ‡çº¹ä¿¡æ¯ | +| 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence, OHScalingMode scalingMode) | 新增 | 新增通过NativeWindow设置缩放模å¼çš„æŽ¥å£ | +| 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size, const OHHDRMetaData *metaData) | 新增 | 新增通过NativeWindow设置HDR元数æ®çš„æŽ¥å£ | +| 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t *metaData) | 新增 | 新增通过NativeWindow设置HDR元数æ®é›†çš„æŽ¥å£ | +| 图形-NativeWindow | int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle) | 新增 | 新增通过NativeWindow设置tunnelhandleçš„æŽ¥å£ | \ No newline at end of file diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md b/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md new file mode 100644 index 0000000000000000000000000000000000000000..7e7f81e258da29f05da52b4d9f61f855ad40269b --- /dev/null +++ b/zh-cn/release-notes/changelog/v3.2-beta2/application-sandbox-adaptation-guide.md @@ -0,0 +1,112 @@ +# OpenHarmonyå¯ç”¨åº”用沙箱机制-适é…指导 + +## 验è¯æµç¨‹ + + + +1. å–å‘布版本自验è¯åŠŸèƒ½ï¼Œå¦‚果功能æ£å¸¸ï¼Œåˆ™é€‚é…æµç¨‹ç»“æŸã€‚ +2. å–版本验è¯å‘现自身应用功能异常,则进行问题定ä½ï¼Œé€šè¿‡åˆ†æžä»£ç 识别到问题点,通过[适é…æµç¨‹](#适é…æµç¨‹)ä¸çš„方法æ¥è¿›è¡Œæ–‡ä»¶è®¿é—®æ¨¡åž‹çš„适é…。 +3. 适é…完毕之åŽï¼Œé‡æ–°éªŒè¯åŠŸèƒ½ï¼ŒåŠŸèƒ½æ£å¸¸åˆ™é€‚é…æµç¨‹ç»“æŸã€‚功能ä¾æ—§å˜åœ¨é—®é¢˜åˆ™é‡æ–°å›žåˆ°ç¬¬äºŒæ¥ç»§ç»å®šä½ï¼Œç›´åˆ°é—®é¢˜è§£å†³ä¸ºæ¢ã€‚ + +## 适é…æµç¨‹ + + + +1. 定ä½å‡ºapp异常的问题点之åŽï¼Œè¯†åˆ«è¯¥é—®é¢˜æ˜¯å¦æ˜¯appæºä»£ç 访问路径出错导致的,是å¦æ˜¯è®¿é—®æœ‰æ•ˆæ–‡ä»¶å¯ä»¥é€šè¿‡ä¸‹ä¸€ç« 节的[æ²™ç®±æ–‡ä»¶è®¿é—®è§„æ ¼æ¸…å•](#æ²™ç®±æ–‡ä»¶è®¿é—®è§„æ ¼æ¸…å•)自查。 +2. 如果是appæºç è®¿é—®æ— æ•ˆè·¯å¾„ï¼Œåˆ™å¯ä»¥é€šè¿‡è°ƒæ•´è®¿é—®è·¯å¾„çš„ç–略,将原æ¥è®¿é—®/data目录从ç»å¯¹è·¯å¾„访问方å¼è°ƒæ•´ä¸ºä½¿ç”¨context接å£è¿›è¡Œè®¿é—®ï¼Œå…·ä½“请è§context接å£ä½¿ç”¨è¯´æ˜Žï¼š + https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ability/context-userguide.md + https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-ability-context.md + https://gitee.com/OpenHarmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-Context.md +3. 如果是app调用三方模å—ï¼Œå¼‚å¸¸è°ƒç”¨æ ˆå‡ºçŽ°åœ¨ä¸‰æ–¹æ¨¡å—ä¸ï¼Œè€Œappæºç 没有使用ç»å¯¹è·¯å¾„去访问文件,则适é…过程如下: + - 通知三方模å—,让其访问文件路径通过context接å£è¿›è¡Œè®¿é—®è€Œéžä½¿ç”¨ç»å¯¹è·¯å¾„çš„æ–¹å¼ã€‚ + - 如果三方模å—是个公共模å—,除了给appspawnåµåŒ–的进程使用之外还给native进程使用,则å¯ä»¥å°†ä¸‰æ–¹æ¨¡å—抽象æˆä¸€ä¸ªæœåŠ¡ï¼Œåº”用通过ipcçš„æ–¹å¼åŽ»è®¿é—®æœåŠ¡ã€‚ + +## æ²™ç®±æ–‡ä»¶è®¿é—®è§„æ ¼æ¸…å• + +**åº”ç”¨æ ¹ç›®å½•è®¿é—®è·¯å¾„æ¸…å•** + +| 路径å | 备注 | +| --------------------- | ------------------------------------------ | +| bin | å˜æ”¾ç€å„ç§äºŒè¿›åˆ¶æ–‡ä»¶ | +| config | é…置目录 | +| data | 应用数æ®ç›®å½• | +| dev | 设备节点 | +| etc | /system/etc的软连接 | +| init | /system/bin/init的软连接 | +| lib | /system/lib的软连接 | +| mnt | 挂载目录 | +| proc | proc文件系统目录 | +| sys | sys文件系统目录 | +| sys_prod | æ¤ç›®å½•ä¸åŒè®¾å¤‡ä¸Šå˜åœ¨å·®å¼‚ï¼Œéƒ¨åˆ†è®¾å¤‡æ— æ¤ç›®å½• | +| system/app | ç³»ç»Ÿç›®å½•èµ„æº | +| system/fonts | 系统文å—èµ„æº | +| system/lib | 系统库 | +| system/data | ç³»ç»Ÿç›®å½•èµ„æº | +| system/usr | ç³»ç»Ÿç›®å½•èµ„æº | +| system/profile | ç³»ç»Ÿç›®å½•èµ„æº | +| system/bin | ç³»ç»Ÿç¨‹åº | +| system/etc | 系统é…ç½® | +| vendor/lib/chipsetsdk | 芯片组件目录,目å‰ä»…挂载chipsetsdk | + +**应用数æ®ç›®å½•è®¿é—®è·¯å¾„清å•** + +| 路径å | 备注 | +| ---------------------------------- | ------------------------------------------------------------ | +| /data | 应用数æ®ç›®å½• | +| /data/storage | åº”ç”¨æ•°æ® | +| /data/bundles | 所有应用安装目录,仅应用aplæƒé™ä¸ºBASICåŠä»¥ä¸Šæƒé™çš„应用å¯è®¿é—® | +| /data/storage/el1 | 应用el1åŠ å¯†çº§åˆ«æ•°æ®ç›®å½• | +| /data/storage/el2 | 应用el2åŠ å¯†çº§åˆ«æ•°æ®ç›®å½• | +| /data/storage/el1/base | 应用el1åŠ å¯†çº§åˆ«æ•°æ®ç›®å½• | +| /data/storage/el1/bundles | 应用el1åŠ å¯†çº§åˆ«åº”ç”¨å®‰è£…åŒ…ç›®å½• | +| /data/storage/el1/database | 应用el1åŠ å¯†çº§åˆ«æ•°æ®åº“å˜å‚¨ç›®å½• | +| /data/storage/el2/base | 应用el2åŠ å¯†çº§åˆ«æ•°æ®ç›®å½• | +| /data/storage/el2/database | 应用el2åŠ å¯†çº§åˆ«æ•°æ®åº“å˜å‚¨ç›®å½• | +| /data/storage/el2/auth_groups | 应用el2åŠ å¯†çº§åˆ«æ— è´¦å·åˆ†å¸ƒå¼æ•°æ®èžåˆç›®å½• | +| /data/storage/el2/distributedfiles | 应用el2åŠ å¯†çº§åˆ«æœ‰è´¦å·åˆ†å¸ƒå¼æ•°æ®èžåˆç›®å½• | + +å¯ç”¨åº”用沙箱之åŽï¼Œåº”用命åç©ºé—´å†…æ— æ³•å†è®¿é—®ç‰©ç†è·¯å¾„下数æ®ç›®å½•çš„访问方å¼ï¼Œè€Œæ˜¯åªèƒ½é€šè¿‡context接å£æ¥è®¿é—®åº”用的数æ®ç›®å½•ï¼Œå…·ä½“访问应用数æ®ç›®å½•çš„æ–¹å¼å¯ä»¥é€šè¿‡context接å£è¿›è¡Œè®¿é—®ï¼Œå‚考[适é…æµç¨‹](#适é…æµç¨‹)ä¸çš„context接å£è®¿é—®é“¾æŽ¥äº†è§£æ›´å¤šç»†èŠ‚。 +应用的物ç†æ•°æ®ç›®å½•è·Ÿæ²™ç®±æ•°æ®ç›®å½•å˜å‚¨çš„是åŒä¸€ä»½åº”用的数æ®ï¼Œé€šè¿‡bind mount技术进行关è”,改动任æ„一处会影å“å¦ä¸€å¤„çš„æ•°æ®ã€‚应用在命å空间下访问数æ®ï¼Œåªèƒ½é€šè¿‡æ²™ç®±è·¯å¾„æ¥è®¿é—®ï¼Œä¸‹é¢åˆ—出应用的数æ®ç›®å½•åœ¨ç‰©ç†è·¯å¾„跟沙箱路径下的对应关系。 + +**应用的数æ®ç›®å½•åœ¨ç‰©ç†è·¯å¾„跟沙箱路径下的对应关系** + +| 物ç†è·¯å¾„ | 沙箱路径 | 备注 | +| ------------------------------------------------------------ | ---------------------------------- | --------------------------------------- | +| /data/app/el1/bundle/public/\<PackageName>\ | /data/storage/el1/bundle | 应用安装包目录 | +| /data/app/el1/\<USERID\>/base/\<PACKAGENAME\> | /data/storage/el1/base | 应用el1çº§åˆ«åŠ å¯†æ•°æ®ç›®å½• | +| /data/app/el2/\<USERID\>/base/\<PACKAGENAME\> | /data/storage/el2/base | 应用el2çº§åˆ«åŠ å¯†æ•°æ®ç›®å½• | +| /data/app/el1/\<USERID\>/database/\<PACKAGENAME\> | /data/storage/el1/database | 应用el1çº§åˆ«åŠ å¯†æ•°æ®åº“目录 | +| /data/app/el2/\<USERID\>/database/\<PACKAGENAME\> | /data/storage/el2/database | 应用el2çº§åˆ«åŠ å¯†æ•°æ®åº“目录 | +| /mnt/hmdfs/\<USERID\>/account/merge_view/data/\<PACKAGENAME\> | /data/storage/el2/distributedfiles | 应用el2åŠ å¯†çº§åˆ«æœ‰è´¦å·åˆ†å¸ƒå¼æ•°æ®èžåˆç›®å½• | +| /mnt/hmdfs/\<USERID\>/non_account/merge_view/data/ | /data/storage/el2/auth_groups | 应用el2åŠ å¯†çº§åˆ«æ— è´¦å·åˆ†å¸ƒå¼æ•°æ®èžåˆç›®å½• | +| /mnt/hmdfs/ | /mnt/hmdfs/ | 分布å¼æ–‡ä»¶ç³»ç»Ÿç›®å½• | + +> **说明:**<br>\<USERID\>代表当å‰çš„用户ID +> \<PACKAGENAME\>代表当å‰çš„应用包å + +更多物ç†è·¯å¾„沙箱路径的对应关系,请访问: +https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox64.json + +## 案例:Contacts.hap拨å·åœºæ™¯æ— 法触å‘音频问题 + +è”系人应用沙箱整改å‰è®¿é—®èµ„æºæ–‡ä»¶çš„æ–¹å¼å¦‚下,å¯ä»¥çœ‹åˆ°è®¿é—®çš„路径是ç»å¯¹è·¯å¾„硬编ç ,为/data/app/el1æ¤ç±»ç›®å½•ï¼Œè€Œæ¤ç±»ç›®å½•åœ¨åº”用沙箱ä¸æ˜¯è®¿é—®å—é™çš„ï¼Œæ‰€ä»¥ä¼šé€ æˆè®¿é—®å¼‚常。 + + + +æ¤ä»£ç çš„æ ¸å¿ƒæ˜¯æƒ³é€šè¿‡fileIO接å£open固定路径得到fdNumber,使用fdNumber去åšæŽ¥ä¸‹æ¥çš„文件访问。FileIO是通过路径得到fdNumber的,而现在路径访问已ç»è¢«é™åˆ¶äº†ï¼Œå› æ¤è€ƒè™‘用其他的接å£åŽ»èŽ·å–fdNumberå³å¯ï¼Œ +查阅OpenHarmony相关开å‘手册得知,使用resourceManagerå¯ä»¥èŽ·å–fdNumber。 +更改åŽçš„代ç 如下: + + + +## 规é¿æ–¹æ¡ˆ + +如果å‘现应用异常且定ä½æ²¡æœ‰ç»“论,å¯ä»¥ä½¿ç”¨å…³é—进程沙箱的方å¼æ¥è§„é¿é—®é¢˜ï¼Œè§„é¿æ–¹å¼å¦‚下: + +1. 打开OpenHarmony startup_appspawn仓的æºç ,找到应用沙箱é…ç½®æ–‡ä»¶ï¼Œæ ¹æ®è‡ªå·±ç¼–译类型修改对应的é…置代ç 文件。 + 32ä½ä¿®æ”¹:https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox.json + 64ä½ä¿®æ”¹:https://gitee.com/OpenHarmony/startup_appspawn/blob/master/appdata-sandbox.json + +2. 在jsonä¸æ–‡ä»¶æ‰¾åˆ°cameraçš„é…置,在下方å‚ç…§cameraçš„é…置新建一æ¡è‡ªèº«åº”用的é…置,将包å改为自身应用报å,其他项ä¿æŒè·Ÿcamera一致å³å¯ï¼ŒOFFå—段代表关é—进程沙箱。 + +  \ No newline at end of file diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md b/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md new file mode 100644 index 0000000000000000000000000000000000000000..97cc21a129800e7f6018318d098ceeb4657e37d2 --- /dev/null +++ b/zh-cn/release-notes/changelog/v3.2-beta2/changelog-v3.2-beta2.md @@ -0,0 +1,58 @@ +# 3.2 beta2相对3.2 beta1å˜æ›´è¯¦ç»†è¯´æ˜Ž + +## å¯ç”¨åº”用沙箱机制 + +基于namespace机制强化OpenHarmony应用数æ®å®‰å…¨ï¼Œå»ºç«‹åº”ç”¨æ²™ç›’æœºåˆ¶ï¼Œå¢žåŠ ç›®å½•å¯è§æ€§æ•°æ®è®¿é—®é˜²çº¿ï¼Œå‡å°‘了应用数æ®å’Œç”¨æˆ·éšç§ä¿¡æ¯æ³„éœ²ï¼Œå»ºç«‹äº†æ›´åŠ ä¸¥æ ¼å®‰å…¨çš„åº”ç”¨æ²™ç›’éš”ç¦»èƒ½åŠ›ã€‚ +åŒæ—¶ä¹Ÿè§£å†³äº†ç›®å½•æ··ä¹±ã€æ–‡ä»¶è®¿é—®æ–¹å¼å¤šé€”å¾„é€ æˆçš„文件管ç†çš„垃圾文件ã€æ–‡ä»¶æ··ä¹±ç‰ä½“验问题和并å‘稳定性问题。 + +**å˜æ›´å½±å“** + +OpenHarmonyå¯ç”¨åº”用沙箱机制åŽï¼Œæ‰€æœ‰è¢«appspawn进程åµåŒ–的应用访问资æºä¼šå—到应用沙箱的é™åˆ¶ã€‚ +如果应用没有适é…应用沙箱的文件访问模型,则会导致应用功能异常。 +应用对于/data目录下文件的访问,需è¦å°†æ‰€æœ‰ç¡¬ç¼–ç 路径访问的方å¼è°ƒæ•´ä¸ºä½¿ç”¨context接å£è®¿é—®ï¼Œå…·ä½“请è§[适é…æµç¨‹](application-sandbox-adaptation-guide.md#适é…æµç¨‹)。 + +**关键的接å£/组件å˜æ›´** + +OpenHarmony应用沙箱组件 + +**适é…指导** + +请å‚考[适é…指导](application-sandbox-adaptation-guide.md)。 + +## å¢žåŠ å¯¹äºŽè‡ªå®šä¹‰ç»„ä»¶Structçš„ç¼–è¯‘æ ¡éªŒ + +**å˜æ›´1**:自定义组件Struct的生命周期函数(比如aboutToAppear)ä¸èƒ½ä½¿ç”¨private修饰。 + +**å˜æ›´å½±å“** + +旧版本åªæœ‰ç¼–辑器åšäº†æ ¡éªŒï¼Œæ–°ç‰ˆæœ¬ç¼–è¯‘ä¹ŸåŠ äº†æ ¡éªŒæŠ¥é”™ã€‚ + +**关键的接å£/组件å˜æ›´** + +æ— + +**适é…指导** + +当出现以下情况时,将private修饰去掉,å³å¯é€šè¿‡ç¼–译。 + + + + + +**å˜æ›´2:**自定义组件Structçš„æˆå‘˜å±žæ€§ä¸èƒ½å’Œå†…置属性方法åé‡å。 + +**å˜æ›´å½±å“** + +与内置属性方法åé‡åçš„Structçš„æˆå‘˜å±žæ€§æ— æ³•é€šè¿‡æ ¡éªŒã€‚ + +**关键的接å£/组件å˜æ›´** + +æ— + +**适é…指导** + +当出现以下情况时,修改属性å,使其与内置属性方法åä¸é‡å。 + + + + \ No newline at end of file diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png new file mode 100644 index 0000000000000000000000000000000000000000..05b1892b5508c56ca029e930a6f0c1360f6a7967 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/adaptation-process.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..01e3e90dd66f2aad624a5fbbf88600833442a3fc Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..3607345cc1b59633f8dc0c35ae99393525c15496 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change1-2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png new file mode 100644 index 0000000000000000000000000000000000000000..22c62fb46ef2311b6ff4f040baf72938317b1ef2 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png new file mode 100644 index 0000000000000000000000000000000000000000..6ef778e4d6b361f43b5e7d8493236bda03cd9b24 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/compile-change2-2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png new file mode 100644 index 0000000000000000000000000000000000000000..db7b455ef72cac51d6bea1be36283c1c1c269ec0 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example1.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png new file mode 100644 index 0000000000000000000000000000000000000000..9bb60d4b1e05dcb152e15553611db0c1da4d2b33 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example2.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png new file mode 100644 index 0000000000000000000000000000000000000000..b9923c8a00716601316b4129b143a3fad854beb7 Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/example3.png differ diff --git a/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png b/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png new file mode 100644 index 0000000000000000000000000000000000000000..97bb2b82243470253462271e1c7164d77d64b4dc Binary files /dev/null and b/zh-cn/release-notes/changelog/v3.2-beta2/figures/verification-process.png differ diff --git a/zh-cn/third-party-components/npm-third-party-guide.md b/zh-cn/third-party-components/npm-third-party-guide.md index e9231f9f6d748935f668594cc5fde1e22c12a9a6..60222a480c852f19216688d99dda1dd9822005cc 100644 --- a/zh-cn/third-party-components/npm-third-party-guide.md +++ b/zh-cn/third-party-components/npm-third-party-guide.md @@ -1,11 +1,11 @@ -# OpenHarmony JS/TS三方组件使用指导 -## OpenHarmony JS/TSä¸‰æ–¹ç»„ä»¶ä»‹ç» +# OpenHarmony JSå’ŒTS三方组件使用指导 +## OpenHarmony JSå’ŒTSä¸‰æ–¹ç»„ä»¶ä»‹ç» -OpenHarmony JS/TS三方组件是以OpenHarmony npm包的形å¼ï¼Œåœ¨ä¼ 统的npm三方组件的基础上,定义了OpenHarmony npm共享包特定的工程结构和é…置文件,支æŒOpenHarmony页é¢ç»„件相关APIã€èµ„æºçš„调用。通过OpenHarmony npm包,å¯ä»¥å®žçŽ°å¤šä¸ªæ¨¡å—或者多个工程共享OpenHarmony页é¢ã€èµ„æºç‰ç›¸å…³ä»£ç 。å‰å¾€[npm官方文档](https://docs.npmjs.com/about-npm),å¯ä»¥äº†è§£å’ŒæŽŒæ¡npm的基础功能和机制。 +OpenHarmony JSå’ŒTS三方组件是以OpenHarmony npm包的形å¼ï¼Œåœ¨ä¼ 统的npm三方组件的基础上,定义了OpenHarmony npm共享包特定的工程结构和é…置文件,支æŒOpenHarmony页é¢ç»„件相关APIã€èµ„æºçš„调用。通过OpenHarmony npm包,å¯ä»¥å®žçŽ°å¤šä¸ªæ¨¡å—或者多个工程共享OpenHarmony页é¢ã€èµ„æºç‰ç›¸å…³ä»£ç 。å‰å¾€[npm官方文档](https://docs.npmjs.com/about-npm),å¯ä»¥äº†è§£å’ŒæŽŒæ¡npm的基础功能和机制。 -## 查找OpenHarmony JS/TS三方组件 +## 查找OpenHarmony JSå’ŒTS三方组件 1. 关注Gitee官网OpenHarmony-TPC[三方组件资æºæ±‡æ€»](https://gitee.com/openharmony-tpc/tpc_resource)é¡¹ç›®ï¼Œæ ¹æ®ç›®å½•ç´¢å¼•å³å¯æ‰¾åˆ°å¯¹åº”分类下的具体组件。 @@ -16,9 +16,9 @@ OpenHarmony JS/TS三方组件是以OpenHarmony npm包的形å¼ï¼Œåœ¨ä¼ 统的npm -## 安装并使用OpenHarmony JS/TSè¯è¨€çš„三方组件 +## 安装并使用OpenHarmony JSå’ŒTSè¯è¨€çš„三方组件 -在应用开å‘的过程ä¸ï¼ŒJS/TSè¯è¨€çš„三方组件,通常以æºç 或OpenHarmony npm包的方å¼è¢«å¼•å…¥ä½¿ç”¨ã€‚按照以下æ¥éª¤å³å¯å°†OpenHarmony npm包引入应用并使用,æºç 的具体引入åŠä½¿ç”¨è¯·å‚考å„三方组件README.md指导介ç»ã€‚ +在应用开å‘的过程ä¸ï¼ŒJSå’ŒTSè¯è¨€çš„三方组件,通常以æºç 或OpenHarmony npm包的方å¼è¢«å¼•å…¥ä½¿ç”¨ã€‚按照以下æ¥éª¤å³å¯å°†OpenHarmony npm包引入应用并使用,æºç 的具体引入åŠä½¿ç”¨è¯·å‚考å„三方组件README.md指导介ç»ã€‚ 1. é…ç½®OpenHarmony npm环境,详情请å‚考安装教程 [如何安装OpenHarmony npm包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_npm_usage.md)。 diff --git a/zh-cn/third-party-components/third-party-components-introduction.md b/zh-cn/third-party-components/third-party-components-introduction.md index 17e06934e35a1e17ac5931b1ea6e057a2fbc7ec9..31f1ab1bfd795ff7b8154455a16d59ca234cd494 100644 --- a/zh-cn/third-party-components/third-party-components-introduction.md +++ b/zh-cn/third-party-components/third-party-components-introduction.md @@ -1,6 +1,6 @@ # OpenHarmony三方组件 -OpenHarmony三方组件,是ç»è¿‡éªŒè¯å¯åœ¨OpenHarmony系统上å¯é‡å¤ä½¿ç”¨çš„软件组件,å¯å¸®åŠ©å¼€å‘者快速开å‘OpenHarmonyç³»ç»Ÿæˆ–åº”ç”¨ã€‚æ ¹æ®å…¶å¼€å‘è¯è¨€åˆ†ä¸ºäº†2ç§ï¼Œä¸€ç§æ˜¯ä½¿ç”¨JavaScript或TypeScriptè¯è¨€çš„三方组件,通常以æºç 或OpenHarmony npm包的方å¼å¼•å…¥ï¼Œåœ¨åº”用开å‘ä¸ä½¿ç”¨ã€‚å¦ä¸€ç§æ˜¯C/C++è¯è¨€çš„三方组件,通常以æºç 或OpenHarmony hpm包的方å¼å¼•å…¥ï¼Œåœ¨åº”用开å‘ä¸ä»¥NAPIçš„æ–¹å¼ä½¿ç”¨ï¼Œæˆ–直接编译在OpenHarmonyæ“作系统镜åƒä¸ã€‚ +OpenHarmony三方组件,是ç»è¿‡éªŒè¯å¯åœ¨OpenHarmony系统上å¯é‡å¤ä½¿ç”¨çš„软件组件,å¯å¸®åŠ©å¼€å‘者快速开å‘OpenHarmonyç³»ç»Ÿæˆ–åº”ç”¨ã€‚æ ¹æ®å…¶å¼€å‘è¯è¨€åˆ†ä¸ºäº†2ç§ï¼Œä¸€ç§æ˜¯ä½¿ç”¨JavaScriptå’ŒTypeScriptè¯è¨€çš„三方组件,通常以æºç 或OpenHarmony npm包的方å¼å¼•å…¥ï¼Œåœ¨åº”用开å‘ä¸ä½¿ç”¨ã€‚å¦ä¸€ç§æ˜¯Cå’ŒC++è¯è¨€çš„三方组件,通常以æºç 或OpenHarmony hpm包的方å¼å¼•å…¥ï¼Œåœ¨åº”用开å‘ä¸ä»¥NAPIçš„æ–¹å¼ä½¿ç”¨ï¼Œæˆ–直接编译在OpenHarmonyæ“作系统镜åƒä¸ã€‚ diff --git a/zh-cn/website.md b/zh-cn/website.md index 71f9807caf9ec13c4e8d4fad036702839b24633f..1edc4cf36f5c38ac154fac3af0336e2c89ab9a03 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -5,6 +5,7 @@ - 版本说明 - OpenHarmony 3.x Releases + - [OpenHarmony v3.2 Beta2 (2022-07-30)](release-notes/OpenHarmony-v3.2-beta2.md) - [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) @@ -13,43 +14,75 @@ - [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 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差异报告 + + - OpenHamrony 3.2 Beta2 + - JS API差异报告 + - [元能力](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md) + - [æ— éšœç¢](release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md) + - [å¸å·](release-notes/api-change/v3.2-beta2/js-apidiff-account.md) + - [ArkUI](release-notes/api-change/v3.2-beta2/js-apidiff-arkui.md) + - [包管ç†](release-notes/api-change/v3.2-beta2/js-apidiff-bundle.md) + - [基础通信](release-notes/api-change/v3.2-beta2/js-apidiff-communicate.md) + - [公共基础库](release-notes/api-change/v3.2-beta2/js-apidiff-complier-and-runtime.md) + - [DFX](release-notes/api-change/v3.2-beta2/js-apidiff-dfx.md) + - [分布å¼æ•°æ®ç®¡ç†](release-notes/api-change/v3.2-beta2/js-apidiff-distributed-data.md) + - [事件通知](release-notes/api-change/v3.2-beta2/js-apidiff-event-and-notification.md) + - [文件管ç†](release-notes/api-change/v3.2-beta2/js-apidiff-file-management.md) + - [ä½ç½®æœåŠ¡](release-notes/api-change/v3.2-beta2/js-apidiff-geolocation.md) + - [å…¨çƒåŒ–](release-notes/api-change/v3.2-beta2/js-apidiff-global.md) + - [图形图åƒ](release-notes/api-change/v3.2-beta2/js-apidiff-graphic.md) + - [Misc](release-notes/api-change/v3.2-beta2/js-apidiff-misc.md) + - [多模输入](release-notes/api-change/v3.2-beta2/js-apidiff-multi-modal-input.md) + - [多媒体](release-notes/api-change/v3.2-beta2/js-apidiff-multimedia.md) + - [资æºè°ƒåº¦](release-notes/api-change/v3.2-beta2/js-apidiff-resource-scheduler.md) + - [安全](release-notes/api-change/v3.2-beta2/js-apidiff-security.md) + - [æ³›Sensor](release-notes/api-change/v3.2-beta2/js-apidiff-sensor.md) + - [分布å¼è½¯æ€»çº¿](release-notes/api-change/v3.2-beta2/js-apidiff-soft-bus.md) + - [测试框架](release-notes/api-change/v3.2-beta2/js-apidiff-unitest.md) + - [å‡çº§æœåŠ¡](release-notes/api-change/v3.2-beta2/js-apidiff-update.md) + - [USBæœåŠ¡](release-notes/api-change/v3.2-beta2/js-apidiff-usb.md) + - [用户身份认è¯](release-notes/api-change/v3.2-beta2/js-apidiff-user-authentication.md) + - [Web](release-notes/api-change/v3.2-beta2/js-apidiff-web.md) + - [窗å£ç®¡ç†](release-notes/api-change/v3.2-beta2/js-apidiff-window.md) + - OpenHarmony 3.2 Beta1 - JS API差异报告 - - [元能力](release-notes/api-change/v3.2-beta/js-apidiff-ability.md) - - [ArkUI](release-notes/api-change/v3.2-beta/js-apidiff-arkui.md) - - [电æº](release-notes/api-change/v3.2-beta/js-apidiff-battery.md) - - [包管ç†](release-notes/api-change/v3.2-beta/js-apidiff-bundle.md) - - [基础通信](release-notes/api-change/v3.2-beta/js-apidiff-communicate.md) - - [DFX](release-notes/api-change/v3.2-beta/js-apidiff-dfx.md) - - [分布å¼æ•°æ®ç®¡ç†](release-notes/api-change/v3.2-beta/js-apidiff-distributed-data.md) - - [事件通知](release-notes/api-change/v3.2-beta/js-apidiff-event-and-notification.md) - - [文件管ç†](release-notes/api-change/v3.2-beta/js-apidiff-file-management.md) - - [å…¨çƒåŒ–](release-notes/api-change/v3.2-beta/js-apidiff-global.md) - - [å¯åŠ¨æ¢å¤](release-notes/api-change/v3.2-beta/js-apidiff-init.md) - - [Misc](release-notes/api-change/v3.2-beta/js-apidiff-misc.md) - - [多模输入](release-notes/api-change/v3.2-beta/js-apidiff-multi-modal-input.md) - - [多媒体](release-notes/api-change/v3.2-beta/js-apidiff-multimedia.md) - - [资æºè°ƒåº¦](release-notes/api-change/v3.2-beta/js-apidiff-resource-scheduler.md) - - [分布å¼è½¯æ€»çº¿](release-notes/api-change/v3.2-beta/js-apidiff-soft-bus.md) - - [测试框架](release-notes/api-change/v3.2-beta/js-apidiff-unitest.md) - - [Web](release-notes/api-change/v3.2-beta/js-apidiff-web.md) - - [窗å£ç®¡ç†](release-notes/api-change/v3.2-beta/js-apidiff-window.md) - - [Native API差异报告](release-notes/api-change/v3.2-beta/native-apidiff-v3.2-beta.md) + - [元能力](release-notes/api-change/v3.2-beta1/js-apidiff-ability.md) + - [ArkUI](release-notes/api-change/v3.2-beta1/js-apidiff-arkui.md) + - [电æº](release-notes/api-change/v3.2-beta1/js-apidiff-battery.md) + - [包管ç†](release-notes/api-change/v3.2-beta1/js-apidiff-bundle.md) + - [基础通信](release-notes/api-change/v3.2-beta1/js-apidiff-communicate.md) + - [DFX](release-notes/api-change/v3.2-beta1/js-apidiff-dfx.md) + - [分布å¼æ•°æ®ç®¡ç†](release-notes/api-change/v3.2-beta1/js-apidiff-distributed-data.md) + - [事件通知](release-notes/api-change/v3.2-beta1/js-apidiff-event-and-notification.md) + - [文件管ç†](release-notes/api-change/v3.2-beta1/js-apidiff-file-management.md) + - [å…¨çƒåŒ–](release-notes/api-change/v3.2-beta1/js-apidiff-global.md) + - [å¯åŠ¨æ¢å¤](release-notes/api-change/v3.2-beta1/js-apidiff-init.md) + - [Misc](release-notes/api-change/v3.2-beta1/js-apidiff-misc.md) + - [多模输入](release-notes/api-change/v3.2-beta1/js-apidiff-multi-modal-input.md) + - [多媒体](release-notes/api-change/v3.2-beta1/js-apidiff-multimedia.md) + - [资æºè°ƒåº¦](release-notes/api-change/v3.2-beta1/js-apidiff-resource-scheduler.md) + - [分布å¼è½¯æ€»çº¿](release-notes/api-change/v3.2-beta1/js-apidiff-soft-bus.md) + - [测试框架](release-notes/api-change/v3.2-beta1/js-apidiff-unitest.md) + - [Web](release-notes/api-change/v3.2-beta1/js-apidiff-web.md) + - [窗å£ç®¡ç†](release-notes/api-change/v3.2-beta1/js-apidiff-window.md) + - [Native API差异报告](release-notes/api-change/v3.2-beta1/native-apidiff-v3.2-beta.md) - OpenHarmony 3.1 Release - JS API差异报告(API Version 8) - [元能力](release-notes/api-change/v3.1-Release/js-apidiff-ability.md) @@ -60,7 +93,7 @@ - [包管ç†](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-compiler-and-runtime.md) - - [DFX](release-notes/api-change/v3.1-Release/js-apidiff-dfx.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) - [事件通知](release-notes/api-change/v3.1-Release/js-apidiff-event-and-notification.md) @@ -92,7 +125,14 @@ - [资æºè°ƒåº¦](release-notes/api-change/v3.1-Release/js-apidiff-resource-scheduler_api-9-canary.md) - [窗å£ç®¡ç†](release-notes/api-change/v3.1-Release/js-apidiff-window_api-9-canary.md) - [Native API差异报告](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md) - + - å˜æ›´è¯´æ˜Ž + - OpenHamrony 3.2 Beta2 + - [3.2 beta2相对3.2 beta1å˜æ›´è¯¦ç»†è¯´æ˜Ž](release-notes\changelog\v3.2-beta2\changelog-v3.2-beta2.md) + - [OpenHarmonyå¯ç”¨åº”用沙箱机制-适é…指导](release-notes\changelog\v3.2-beta2\application-sandbox-adaptation-guide.md) +- OpenHarmony三方组件 + - [OpenHarmony三方组件简介](third-party-components/third-party-components-introduction.md) + - [OpenHarmony JS/TS三方组件使用指导](third-party-components/npm-third-party-guide.md) + - 贡献 - [å‚与贡献](contribute/å‚与贡献.md) - [行为准则](contribute/行为准则.md)